help-octave
[Top][All Lists]
Advanced

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

Re: slow 'eval' function - maybe pointers would do?


From: Judd Storrs
Subject: Re: slow 'eval' function - maybe pointers would do?
Date: Thu, 29 Oct 2009 15:24:32 -0400

On Thu, Oct 29, 2009 at 1:52 PM, Guido Walter Pettinari
<address@hidden> wrote:
> where N is big and is determined at runtime. I do not want to use a
> vector named 'ks' such that ks(i) = ks_i and so on.

Are you aware of cell arrays? Are you opposed to them also?

> I thought that one could solve the
> problem by using pointers to access them, but I could not find support
> for pointers in Octave.

I don't think pointers exist in octave/matlab. The closest thing that
exists here are cell arrays. Octave/Matlab don't have pointers as far
as I know, but in most cases cell arrays get close enough to be usable
as a substitute. You can store mixed data types into cell arrays and
then use an index like a pointer.

> However, using 'eval' the execution time of my loop increases ~6 fold.

This is a well known challenge that plagues most (if not all)
interpreted languages and I don't think there is a solution. The
problem is that there is no way reasonable way to know what the
contents of the string will be before eval'd is called. As a
consequence, using eval requires the interpreter to decode the string
before it can process it. eval is pretty much the biggest enemy of
performance in octave and Matlab (and python and IDL ...).


--judd


reply via email to

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