From octave-sources-request at bevo dot che dot wisc dot edu Fri Oct 2 03:30:06 1998 Subject: Re: new function: is_complex From: Erik de Castro Lopo To: octave-sources at bevo dot che dot wisc dot edu Date: Fri, 02 Oct 1998 18:32:25 +1000 John W. Eaton wrote: > Thanks for the code. I think the following is a bit better. It will > work correctly even for structures and user-defined types that may > give error messages when passed to imag(), and it will also be much > faster for large matrices. Thanks John, I like this approach better. There is however a typo below. The usage statement is passed "is_struct" instead of "is_complex". Erik > jwe > > *** src/data.cc~ Mon Apr 20 22:29:48 1998 > --- src/data.cc Thu Oct 1 22:39:27 1998 > *************** > *** 739,744 **** > --- 739,757 ---- > return retval; > } > > + DEFUN (is_complex, args, , > + "is_complex (x): return nonzero if x is a complex numeric object") > + { > + octave_value retval; > + > + if (args.length () == 1) > + retval = args(0).is_complex_type () ? 1.0 : 0.0; > + else > + print_usage ("is_struct"); > + > + return retval; > + } > + > DEFUN (is_struct, args, , > "is_struct (x): return nonzero if x is a structure") > { -- +-------------------------------------------------+ Erik de Castro Lopo erikd at zip dot com dot au +-------------------------------------------------+ Linux: generous programmers from around the world all join forces to help you shoot yourself in the foot for free.