|
From: | Doug Stewart |
Subject: | Re: oct file ; problem with argument checking |
Date: | Fri, 22 Sep 2017 07:24:50 -0400 |
Hello,
Using octave version = 3.8.0, I begin to play with octfiles.
I would check if the first argument of my function is an integer.
My toto.cc file contains :
DEFUN_DLD ( toto, args, nargout , "AIDE fonction toto")
{
if ( ! args(0).is_integer_type() )
error("Non integer value \n");
const int dimension = args(0).int_value();
octave_stdout << " DIMENSION " << dimension << std::endl;
}
When I run the .oct version of toto in octave with :
[x,y] = toto(2)
I get :
error: Non integer value
DIMENSION 0
Obviously, that's not what I expect.
Being less ambitious, I check if my first arg is a scalar with "is_scalar_type()" instead of "is_integer_type"
DEFUN_DLD ( toto, args, nargout , "AIDE fonction toto")
{
if ( ! args(0).is_scalar_type() )
error("Non scalar value \n");
const int dimension = args(0).int_value();
octave_stdout << " DIMENSION " << dimension << std::endl;
}
Runing
[x,y] = toto(2)
Then It works and I get as expected
DIMENSION 2
But I want to be sure my scalar type is an integer one.
Please could you help me and tell me what's wrong in my integer type checking with "is_integer_type" ?
Thanks for your help
Arnaud
_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |