octave-maintainers
[Top][All Lists]
Advanced

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

Re: Reducing memory by emulating IDL's temporary() function


From: Judd Storrs
Subject: Re: Reducing memory by emulating IDL's temporary() function
Date: Thu, 24 Apr 2008 16:51:41 -0400

On Thu, Apr 24, 2008 at 4:09 PM, John W. Eaton <address@hidden> wrote:
Given this definition, what happens if you write

 A = something;
 A = temporary ("A") + A

octave:1> A = [1,2,3,4];
octave:2> A = temporary ("A") + A
error: `A' undefined near line 2 column 23
error: evaluating binary operator `+' near line 2, column 21
error: evaluating assignment _expression_ near line 2, column 3
octave:2> A = [1,2,3,4];
octave:3> A = A + temporary ("A")
A =

   2   4   6   8

In the last case A = A + temporary("A") takes the same amount of memory as A = A + A

Both cases fail in IDL:

IDL> A = [1,2,3,4]
IDL> B = A + temporary(A)
% Variable is undefined: A.
% Execution halted at: $MAIN$         
IDL> A = [1,2,3,4]      
IDL> B = temporary(A) + A
% Variable is undefined: A.
% Execution halted at: $MAIN$         
IDL>

Failing for both cases is probably the correct behavior.

I don't think generating these sorts of errors is a problem. I tend to think of using temporary() in IDL as a performance tweak similar to vectorizing loops.

Also, since you are accessing the symbol table, your code will not
work with Octave 3.1 since the symbol table code in Octave has been
completely rewritten since 3.0 in order to support Matlab compatible
classes.

Thanks for the heads up. I'll look at the development version.

--judd


reply via email to

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