[OctDev] Can we implement isinteger this way?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[OctDev] Can we implement isinteger this way?

William Poetra Yoga H
Hi, I'm new here, and I have a question: can we implement isinteger this way?

function retval=isinteger(A)

if ismatrix(A) && (round(A) == A)
  retval=1;
else
  retval=0;
end


William Poetra Yoga Hadisoeseno


       
               
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way?

Paul Kienzle-3
Or even

function retval = isinteger(A)
     retval = ismatrix(A) && (round(A) == A);

- Paul

On Nov 6, 2005, at 10:00 AM, William Poetra Yoga H wrote:

> Hi, I'm new here, and I have a question: can we implement isinteger
> this way?
>
> function retval=isinteger(A)
>
> if ismatrix(A) && (round(A) == A)
>   retval=1;
> else
>   retval=0;
> end
>
>
> William Poetra Yoga Hadisoeseno
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Octave-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/octave-dev
>



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way?

Andy Adler-8
In reply to this post by William Poetra Yoga H
On 11/6/05, William Poetra Yoga H <[hidden email]> wrote:
> Hi, I'm new here, and I have a question: can we implement isinteger this way?
>
> function retval=isinteger(A)
>
> if ismatrix(A) && (round(A) == A)
>   retval=1;
> else
>   retval=0;
> end

Are you happy with the way this function will handle large
exponents where the interger part is lost? For example

octave:6> isinteger(1e10/3)
ans = 0
octave:7> isinteger(1e20/3)
ans = 1

Andy


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way?

William Poetra Yoga H
--- Andy Adler <[hidden email]> wrote:

>
> Are you happy with the way this function will handle large
> exponents where the interger part is lost? For example
>
> octave:6> isinteger(1e10/3)
> ans = 0
> octave:7> isinteger(1e20/3)
> ans = 1
>
> Andy
>

Well... I'm not. But I can't think of a better way...
Btw, actually 1e20/3 should be treated as an integer anyway (or a floating
point with zero behind the decimal point) because Octave can't handle it. I
meant to use this function to check for integer count arguments passed to
functions, and I think most people would do the same thing, so...

In the meantime, I've modified it a bit (thanks Paul):

function retval = isinteger(A)
## -*- texinfo -*-
## @deftypefn {Function File} {} isinteger (@var{A})
## Return 1 if @var{A} is an integer array.  Otherwise, return 0.
## @end deftypefn
##
## @seealso{isa, isnumeric, isfloat}

if (nargin ~= 1)
  usage("isinteger(A)");
end

retval = ismatrix(A) && all((round(A) == A)(:));

And now I also have an isfloat function:

function retval = isfloat(A)
## -*- texinfo -*-
## @deftypefn {Function File} {} isfloat (@var{A})
## Return 1 if @var{A} is a floating point array.  Otherwise, return 0.
## @end deftypefn
##
## @seealso{isa, isinteger, isnumeric}

if (nargin ~= 1)
  usage("isfloat(A)");
end

retval = ismatrix(A) && ~all((round(A) == A)(:));


William Poetra Yoga Hadisoeseno


               
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way?

Quentin Spencer
William Poetra Yoga H wrote:

>--- Andy Adler <[hidden email]> wrote:
>  
>
>>Are you happy with the way this function will handle large
>>exponents where the interger part is lost? For example
>>
>>octave:6> isinteger(1e10/3)
>>ans = 0
>>octave:7> isinteger(1e20/3)
>>ans = 1
>>
>>Andy
>>
>>    
>>
>
>Well... I'm not. But I can't think of a better way...
>Btw, actually 1e20/3 should be treated as an integer anyway (or a floating
>point with zero behind the decimal point) because Octave can't handle it. I
>meant to use this function to check for integer count arguments passed to
>functions, and I think most people would do the same thing, so...
>
>In the meantime, I've modified it a bit (thanks Paul):
>
>function retval = isinteger(A)
>## -*- texinfo -*-
>## @deftypefn {Function File} {} isinteger (@var{A})
>## Return 1 if @var{A} is an integer array.  Otherwise, return 0.
>## @end deftypefn
>##
>## @seealso{isa, isnumeric, isfloat}
>
>if (nargin ~= 1)
>  usage("isinteger(A)");
>end
>
>retval = ismatrix(A) && all((round(A) == A)(:));
>
>And now I also have an isfloat function:
>
>function retval = isfloat(A)
>## -*- texinfo -*-
>## @deftypefn {Function File} {} isfloat (@var{A})
>## Return 1 if @var{A} is a floating point array.  Otherwise, return 0.
>## @end deftypefn
>##
>## @seealso{isa, isinteger, isnumeric}
>
>if (nargin ~= 1)
>  usage("isfloat(A)");
>end
>
>retval = ismatrix(A) && ~all((round(A) == A)(:));
>
>
>  
>



If we're aiming for compatibility with the Matlab functions isinteger
and isfloat, we should look at what they do:
 >> isinteger(1)
ans =
     0

 >> isinteger(int8(1))
ans =
     1

So, the outputs of these functions are based not on whether the contents
of the array happen to be integers, which can happen with a double
array, but on whether they are _stored_ as integers. In addition to the
compatibility issue, checking all elements of an array to see if they
are an integer could be much slower with a large array than just
checking the array type. Given this, it would seem that the correct
implementation of isinteger would involve parsing the output of the
typeinfo function.

-Quentin



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way?

William Poetra Yoga H
--- Quentin Spencer <[hidden email]> wrote:

>
> If we're aiming for compatibility with the Matlab functions isinteger
> and isfloat, we should look at what they do:
>  >> isinteger(1)
> ans =
>      0
>
>  >> isinteger(int8(1))
> ans =
>      1
>
> So, the outputs of these functions are based not on whether the contents
> of the array happen to be integers, which can happen with a double
> array, but on whether they are _stored_ as integers. In addition to the
> compatibility issue, checking all elements of an array to see if they
> are an integer could be much slower with a large array than just
> checking the array type. Given this, it would seem that the correct
> implementation of isinteger would involve parsing the output of the
> typeinfo function.
>
> -Quentin
>

Yeah, sorry, I don't have access to a legal copy of Matlab, so... OK, then this
should be correct, right?

isfloat.m:

function retval = isfloat(A)
## -*- texinfo -*-
## @deftypefn {Function File} {} isfloat (@var{A})
## Return 1 if @var{A} is a floating point array.  Otherwise, return 0.
## @end deftypefn
##
## @seealso{isa, isinteger, isnumeric}

if (nargin ~= 1)
  usage("isfloat (A)");
end

# Octave doesn't have a single-precision floating point data type
switch (class(A))
case "double" retval = 1;
otherwise     retval = 0;
endswitch


isinteger.m:

function retval = isinteger(A)
## -*- texinfo -*-
## @deftypefn {Function File} {} isinteger (@var{A})
## Return 1 if @var{A} is an integer array.  Otherwise, return 0.
## @end deftypefn
##
## @seealso{isa, isnumeric, isfloat}

if (nargin ~= 1)
  usage("isinteger (A)");
end

switch class(A)
case  "int8"  retval = 1;
case  "int16" retval = 1;
case  "int32" retval = 1;
case  "int64" retval = 1;
case "uint8"  retval = 1;
case "uint16" retval = 1;
case "uint32" retval = 1;
case "uint64" retval = 1;
otherwise     retval = 0;
endswitch


issorted.m:

function retval = issorted(A,r)
## -*- texinfo -*-
## @deftypefn {Function File} {} issorted (@var{A}, ["rows"])
## Return 1 if @var{A} is equal to sort(@var{A}), otherwise return 0.
## If "rows" is specified, return 1 if @var{A} is equal to sortrows(@var{A}).
## @end deftypefn
##
## @seealso{sort, sortrows}

switch nargin
case 1
  retval = isequal(A,sort(A));
case 2
  if strcmp(r,"rows")
    retval = isequal(A,sortrows(A));
  else
    usage("issorted (A, [\"rows\"])");
  endif
otherwise
  usage("issorted (A, [\"rows\"])");
endswitch


isstudent.m:

function retval = isstudent
## -*- texinfo -*-
## @deftypefn {Function File} {} isstudent
## Always returns 0, 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}

if (nargin ~= 0)
  usage("isstudent");
end

retval = 0;


P.S.: I got excited and wrote those functions too...


William Poetra Yoga Hadisoeseno


       
               
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way?

Paul Kienzle-3
John,

Let me know which of these you want in octave and I will put the rest
in octave-forge.

- Paul

On Nov 11, 2005, at 7:08 AM, William Poetra Yoga H wrote:

> --- Quentin Spencer <[hidden email]> wrote:
>>
>> If we're aiming for compatibility with the Matlab functions isinteger
>> and isfloat, we should look at what they do:
>>>> isinteger(1)
>> ans =
>>      0
>>
>>>> isinteger(int8(1))
>> ans =
>>      1
>>
>> So, the outputs of these functions are based not on whether the
>> contents
>> of the array happen to be integers, which can happen with a double
>> array, but on whether they are _stored_ as integers. In addition to
>> the
>> compatibility issue, checking all elements of an array to see if they
>> are an integer could be much slower with a large array than just
>> checking the array type. Given this, it would seem that the correct
>> implementation of isinteger would involve parsing the output of the
>> typeinfo function.


isfloat.m:

function retval = isfloat(A)
## -*- texinfo -*-
## @deftypefn {Function File} {} isfloat (@var{A})
## Return 1 if @var{A} is a floating point array.  Otherwise, return 0.
## @end deftypefn
##
## @seealso{isa, isinteger, isnumeric}

if (nargin ~= 1)
   usage("isfloat (A)");
end

# Octave doesn't have a single-precision floating point data type
switch (class(A))
case "double" retval = 1;
otherwise     retval = 0;
endswitch


isinteger.m:

function retval = isinteger(A)
## -*- texinfo -*-
## @deftypefn {Function File} {} isinteger (@var{A})
## Return 1 if @var{A} is an integer array.  Otherwise, return 0.
## @end deftypefn
##
## @seealso{isa, isnumeric, isfloat}

if (nargin ~= 1)
   usage("isinteger (A)");
end

switch class(A)
case  "int8"  retval = 1;
case  "int16" retval = 1;
case  "int32" retval = 1;
case  "int64" retval = 1;
case "uint8"  retval = 1;
case "uint16" retval = 1;
case "uint32" retval = 1;
case "uint64" retval = 1;
otherwise     retval = 0;
endswitch


issorted.m:

function retval = issorted(A,r)
## -*- texinfo -*-
## @deftypefn {Function File} {} issorted (@var{A}, ["rows"])
## Return 1 if @var{A} is equal to sort(@var{A}), otherwise return 0.
## If "rows" is specified, return 1 if @var{A} is equal to
sortrows(@var{A}).
## @end deftypefn
##
## @seealso{sort, sortrows}

switch nargin
case 1
   retval = isequal(A,sort(A));
case 2
   if strcmp(r,"rows")
     retval = isequal(A,sortrows(A));
   else
     usage("issorted (A, [\"rows\"])");
   endif
otherwise
   usage("issorted (A, [\"rows\"])");
endswitch


isstudent.m:

function retval = isstudent
## -*- texinfo -*-
## @deftypefn {Function File} {} isstudent
## Always returns 0, 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}

if (nargin ~= 0)
   usage("isstudent");
end

retval = 0;



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way?

John W. Eaton-6
On 11-Nov-2005, Paul Kienzle wrote:

| Let me know which of these you want in octave and I will put the rest
| in octave-forge.

Are all of them present in "core" Matlab?  If so, then I would use all
of them.  Did you write all of them?  Is it OK to use the usual Octave
copyright notice for them (with your name in the copyright)?

I might want to make isinteger and isfloat built-in functions, but
these versions are probably OK for now.

Thanks,

jwe


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way?

William Poetra Yoga H
--- "John W. Eaton" <[hidden email]> wrote:

> On 11-Nov-2005, Paul Kienzle wrote:
>
> | Let me know which of these you want in octave and I will put the rest
> | in octave-forge.
>
> Are all of them present in "core" Matlab?  If so, then I would use all
> of them.  Did you write all of them?  Is it OK to use the usual Octave
> copyright notice for them (with your name in the copyright)?
>

I think so. I don't have access to it, but I downloaded the pdf manuals (you
know, the function reference), and they're all there.

I did, and I think it's OK to use that copyright. But I think my formatting is
a bit different from other Octave functions, can you please change them for me?
I mean, I didn't use endfunction (please add) and I started every line at
column 1 (please add 2 spaces).

> I might want to make isinteger and isfloat built-in functions, but
> these versions are probably OK for now.
>

It would be more efficient then. But for issorted(), I'm not sure for the
behaviour if we supply something other than "rows" as the second argument.
Should it exit with an error? Should it silently return 0? Or should it ignore
the option at all?


William Poetra Yoga Hadisoeseno


               
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way? (almost final)

William Poetra Yoga H
I think I shouldn't keep you busy with the files, so here they are:

---------
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 1 if @var{A} is a floating point array.  Otherwise, return 0.
## @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 = 1;
  otherwise     retval = 0;
  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 1 if @var{A} is an integer array.  Otherwise, return 0.
## @end deftypefn
##
## @seealso{isa, isnumeric, isfloat}

function retval = isinteger(A)

  if (nargin != 1)
    usage("isinteger (A)");
  end

  switch class(A)
  case  "int8"  retval = 1;
  case  "int16" retval = 1;
  case  "int32" retval = 1;
  case  "int64" retval = 1;
  case "uint8"  retval = 1;
  case "uint16" retval = 1;
  case "uint32" retval = 1;
  case "uint64" retval = 1;
  otherwise     retval = 0;
  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 1 if @var{A} is equal to sort(@var{A}), otherwise return 0.
## If "rows" is specified, return 1 if @var{A} is equal to sortrows(@var{A}).
## @end deftypefn
##
## @seealso{sort, sortrows}

function retval = issorted(A,r)

  switch nargin
  case 1
    retval = isequal(A,sort(A));
  case 2
    if strcmp(r,"rows")
      retval = isequal(A,sortrows(A));
    else
      usage("issorted (A, [\"rows\"])");
    endif
  otherwise
    usage("issorted (A, [\"rows\"])");
  endswitch

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 0, 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 = 0;

endfunction

P.S.: It's almost final because I haven't determined the exact behaviour of
issorted() yet.


William Poetra Yoga Hadisoeseno


               
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Can we implement isinteger this way? (well...)

William Poetra Yoga H
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


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev