From octave-sources-request at bevo dot che dot wisc dot edu Thu Oct 1 20:00:47 1998 Subject: 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 11:03:00 +1000 Hi all, I found a need for a function to tell me is a vector or matrix had any complex components. I took the sources for is_vector our of /usr/local/share/octave/2.0.13/m/general/ and modified it as follows. I'll leave it with John's copyright as I really don't feel I did enough to warant putting my name on it. I do hwoever think that this is probably useful enough to place in the standard distribution. --------------------------------------------------------- ## Copyright (C) 1996 John W. Eaton ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2, or (at your option) ## any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, write to the Free ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. ## usage: is_complex (x) ## ## Return 1 if X has one complex component or more. Otherwise, return 0. ## ## See also: size, rows, columns, length, is_scalar, is_matrix, is_vector ## Author: jwe function retval = is_complex (x) if (nargin == 1) retval = any (any (imag (x))); else usage ("is_complex (x)"); endif endfunction --------------------------------------------------------- Cheers, Erik -- +-------------------------------------------------+ Erik de Castro Lopo erikd at zip dot com dot au +-------------------------------------------------+ UNIX *is* user-friendly, just picky about who it chooses for friends!