detect complex number in matrix

11 views
Skip to first unread message

Ken

unread,
Apr 19, 2012, 12:54:29 PM4/19/12
to mpmath
Is there some function that can tell me if a matrix contains any
complex numbers? Right now I loop through every matrix element and
test its type. Is there a better way?

Fredrik Johansson

unread,
Apr 20, 2012, 5:02:22 AM4/20/12
to mpm...@googlegroups.com

I don't think there's a better way.

Fredrik

Vinzent Steinberg

unread,
Apr 20, 2012, 5:57:17 AM4/20/12
to mpm...@googlegroups.com
Am Freitag, 20. April 2012 11:02:22 UTC+2 schrieb Fredrik Johansson:
On Thu, Apr 19, 2012 at 18:54, Ken Allen wrote:
> Is there some function that can tell me if a matrix contains any
> complex numbers?  Right now I loop through every matrix element and
> test its type.  Is there a better way?

I don't think there's a better way.


Maybe we single type matrices could help (force_type=mpf should do the job).

But I also would just use any(type(x) is mpc for x in mymatrix).

Vinzent
Reply all
Reply to author
Forward
0 new messages