From: David G. <Dav...@no...> - 2006-10-03 20:22:04
|
numpy.isreal(a) is a "top level" function (i.e., not a class member function) in numpy; here's its help doc: Help on function isreal in module numpy.lib.type_check: isreal(x) Return a boolean array where elements are True if that element is real (has zero imaginary part) For scalars, return a boolean. As for checking for pure imaginaries (i.e., real part == 0), one could use: x.imag == -j*x or numpy.isreal(i*x) or simply (x.real == 0.0) and (x.imag != 0.0) DG Kenny Ortmann wrote: > excuse my laziness for not looking this up, I googled it but could not find > a solution. > matlab has a > isreal(array) > where if the array is full of real numbers the value returned is 1. > I'm translating matlab code and ran across > > if ~isreal(array) > array = abs(array) > > Is there a way to check to see if a number is real or complex? and if so is > there a way to extract the(a + ib) because the absolute value of a complex > number is like the pythagorean therom on a and b? > > thanks for your help, > Kenny > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |