[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Overhead on isindex
From: |
Rik |
Subject: |
Overhead on isindex |
Date: |
Wed, 02 Jun 2010 14:25:14 -0700 |
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.
--Rik
- Overhead on isindex,
Rik <=