Mercurial > forge
annotate extra/ver20/isreal.m @ 0:6b33357c7561 octave-forge
Initial revision
author | pkienzle |
---|---|
date | Wed, 10 Oct 2001 19:54:49 +0000 |
parents | |
children |
rev | line source |
---|---|
0 | 1 ## usage: b = isreal(x) |
2 ## | |
3 ## Returns 1 if all elements of x are real. | |
4 | |
5 function b = isreal(x) | |
6 if (nargin != 1) | |
7 usage("b = isreal(x)"); | |
8 endif | |
9 b = !any(any(imag(x))); | |
10 endfunction | |
11 | |
12 %!shared x | |
13 %! x=rand(10,10); | |
14 %!assert (isreal (x)); | |
15 %!test x(5,1)=1i; | |
16 %!assert (!isreal (x)); | |
17 %!assert (isreal ([])); | |
18 %!error isreal | |
19 %!error isreal(1,2) |