From: William P. Y. H <wil...@ya...> - 2005-11-12 07:57:14
|
Well, I found that I should return true/false and not 1/0... sorry... --------- isfloat.m --------- ## Copyright (C) 2005 William Poetra Yoga Hadisoeseno ## ## 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 of the License, 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; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## -*- texinfo -*- ## @deftypefn {Function File} {} isfloat (@var{A}) ## Return true if @var{A} is a floating point array. Otherwise, return false. ## @end deftypefn ## ## @seealso{isa, isinteger, isnumeric} function retval = isfloat(A) if (nargin != 1) usage("isfloat (A)"); end # Octave doesn't have a single-precision floating point data type switch class(A) case "double" retval = true; otherwise retval = false; endswitch endfunction ----------- isinteger.m ----------- ## Copyright (C) 2005 William Poetra Yoga Hadisoeseno ## ## 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 of the License, 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; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## -*- texinfo -*- ## @deftypefn {Function File} {} isinteger (@var{A}) ## Return true if @var{A} is an integer array. Otherwise, return false. ## @end deftypefn ## ## @seealso{isa, isnumeric, isfloat} function retval = isinteger(A) if (nargin != 1) usage("isinteger (A)"); end switch class(A) case "int8" retval = true; case "int16" retval = true; case "int32" retval = true; case "int64" retval = true; case "uint8" retval = true; case "uint16" retval = true; case "uint32" retval = true; case "uint64" retval = true; otherwise retval = false; endswitch endfunction ---------- issorted.m ---------- ## Copyright (C) 2005 William Poetra Yoga Hadisoeseno ## ## 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 of the License, 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; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## -*- texinfo -*- ## @deftypefn {Function File} {} issorted (@var{A}, ["rows"]) ## Return true if @var{A} is equal to sort(@var{A}). Otherwise, return false. ## If "rows" is specified, return true if @var{A} is equal to sortrows(@var{A}). ## @end deftypefn ## ## @seealso{sort, sortrows} function retval = issorted(A,r) if (nargin == 1) retval = isequal(A,sort(A)); elseif ((nargin == 2) && strcmp(r,"rows")) retval = isequal(A,sortrows(A)); else usage("issorted (A, [\"rows\"])"); endif endfunction ----------- isstudent.m ----------- ## Copyright (C) 2005 William Poetra Yoga Hadisoeseno ## ## 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 of the License, 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; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## -*- texinfo -*- ## @deftypefn {Function File} {} isstudent ## Always returns false, because when you accept Octave's License Agreement ## you always get all the features of Octave and not a stripped-down ## "student" version. ## @end deftypefn ## ## @seealso{ispc, isunix} function retval = isstudent if (nargin != 0) usage("isstudent"); end retval = false; endfunction William Poetra Yoga Hadisoeseno __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com |