help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Types in 2.1.58


From: Soren Hauberg
Subject: Re: Types in 2.1.58
Date: Sat, 04 Sep 2004 12:08:38 +0200
User-agent: Mozilla Thunderbird 0.7 (X11/20040615)

OK,
thanks guys

John W. Eaton wrote:
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]