help-octave
[Top][All Lists]
Advanced

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

Re: testing for uint8: a solution


From: David Bateman
Subject: Re: testing for uint8: a solution
Date: Sun, 05 Jun 2005 06:39:36 +0200
User-agent: Mozilla Thunderbird 0.8 (X11/20040923)

I found the following solution for testing whether a variable is uint8 (a question I had asked some time ago). Is there anything wrong with using this solution?

int is_uint8(const octave_value &val) {

   if ((val.type_id() == octave_uint8_matrix::static_type_id()) ||
       (val.type_id () == octave_uint8_scalar::static_type_id())) {
     return(1);
   } else {
     return(0);
   }

}


I think that is probably the best way in C++ (in dot-m Bill is probably right).. You could also use Bill's solution in C++ using class_name() instead of type_id() and replace the two integer compares above with a single string compare to "uint8". However I think two integer compare will be faster than a string compare...

Cheers
David


--
David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary



-------------------------------------------------------------
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]