[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
oct file ; problem with argument checking
From: |
arnaud Lejeune |
Subject: |
oct file ; problem with argument checking |
Date: |
Fri, 22 Sep 2017 12:53:58 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
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
- oct file ; problem with argument checking,
arnaud Lejeune <=