[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Types in 2.1.58
From: |
John W. Eaton |
Subject: |
Re: Types in 2.1.58 |
Date: |
Fri, 3 Sep 2004 11:46:58 -0400 |
On 3-Sep-2004, David Bateman <address@hidden> wrote:
| According to Soren Hauberg <address@hidden> (on 09/03/04):
| > Quite simple I must say...
| > but how do I determine if an octave_value is an int8_array?
| > In the case of a real matrix I have the function is_real_matrix(), but I
| > can't find anything like is_int8_matrix() ??
|
| Humm, yes well not sure its a good idea to have is_int8_matrix, as it
| would mean an explosion in the number of is_* calls... Look at bitfcns.cc
| and you'll see that what is done is someting like
|
| std::string cnam = args(0).class_name();
|
| if (args(0).is_matrix() && cname == "int8")
| {
| int8NDArray m = args(0).int8_array_value();
| }
And, if you know that the object must be a certain type of object, it
is better to just use something like
int8NDArray m = args(0).int8_array_value ();
if (! error_state)
{
// do something with m
}
else
error ("print some additional informative message");
because this allows for possible type conversions (some other non-int8
type might allow itself to be coerced to an int8 array).
jwe
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------