help-octave
[Top][All Lists]
Advanced

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

Re: Distinguishing Octave from Matlab


From: David Bateman
Subject: Re: Distinguishing Octave from Matlab
Date: Fri, 15 Feb 2008 11:32:34 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20070914)

Søren Hauberg wrote:
> fre, 15 02 2008 kl. 11:02 +0100, skrev David Bateman:
>   
>> A function that does what you want is
>>
>> function ret = isoctave ()
>>   persistent isoct
>>   if (isempty (isoct))
>>      isoct = exist('OCTAVE_VERSION') ~= 0;
>>   end
>>   ret = isoct;
>> end
>>     
> Is the 'exist' call really so slow that you need to use a persistent
> variable? Wouldn't it be just as good to use
>
> function ret = isoctave ()
>   ret = (exist('OCTAVE_VERSION') ~= 0);
> endfunction
>
> ?
>
>   
In this case yes.. The reason is that "OCTAVE_VERSION" is a builtin in
recent versions of Octave and was previously a variable, therefore we
can either check both "var" and "builtin" resulting in the need two
tests, or as we don't care about the speed of the first call, just check
all possibilities for the type of OCTAVE_VERSION. This allows this
function to identify all versions of Octave I know of.. However, the use
of exist twice will be slower, and a generic exist call is even slower
as it searches the loadpath for possible functions, thus causing disk
activity. So its better to use a persistent in this case.

D.




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

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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