0
$\begingroup$

I have a very large matrix of numbers. I want to check if all its entries are real. At the moment I am using

realQ = And @@ Thread[Flatten[Im @ #] == 0] &

Is there any faster/safer/better way to do it?

$\endgroup$
  • $\begingroup$ Duplicate: How to check if an expression is a real-valued number With the realQ from this link, you just need to do MatrixQ[mat, realQ] $\endgroup$ – rm -rf Mar 1 '14 at 21:28
  • $\begingroup$ To check each element, first take a look at rm's link, then use things like VectorQ[..., realQ], MatrixQ[..., realQ], ArrayQ[..., _, realQ], etc. $\endgroup$ – Szabolcs Mar 1 '14 at 21:36
  • 1
    $\begingroup$ .......TensorQ $\endgroup$ – halirutan Mar 1 '14 at 21:49