octave-maintainers
[Top][All Lists]
Advanced

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

Re: Overhead on isindex


From: Jaroslav Hajek
Subject: Re: Overhead on isindex
Date: Fri, 4 Jun 2010 07:12:52 +0200

On Wed, Jun 2, 2010 at 11:25 PM, Rik <address@hidden> wrote:
> 6/2/10
>
> I'm trying to improve the input validation on a number of the base
> statistics functions.  One of the frequent tests is for a dimension
> along which to perform the operation.  This is a scalar, integer, greater
> than 1 and less than the number of dimensions.
>
> The current error checking code is:
>    if (!(isscalar (dim) && dim == fix (dim)) ||
>        !(1 <= dim && dim <= nd))
>
> I am tempted to use
> if (!(isscalar (dim) && isnumeric (dim) && isindex (dim, nd))
>
> According to the documentation for isindex:
> -----
> Note that, if possible, the internal conversion result is cached
>     so that subsequent indexing will not perform the checking again.
> -----
>
> Is this going to cause excessive memory usage if I use it for input
> validation?  The usual case is something like 'skew (x, 2)' and I'm
> not even sure that the code can cache the results since it is not
> associated with a variable.
>

Due to the way Octave stores constants, even a constant can possess
the index cache. However, scalars don't ever cache anything.

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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