help-octave
[Top][All Lists]
Advanced

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

Re: foo = eye (5); foo(1:3,:)(1:6) = 1


From: Paul Kienzle
Subject: Re: foo = eye (5); foo(1:3,:)(1:6) = 1
Date: Thu, 18 Mar 2004 22:44:28 -0500


On Mar 18, 2004, at 5:13 PM, Etienne Grossmann wrote:

I was surprised to see that

   foo = eye (5); foo(1:3,:)(1:6) = 1


   error: in indexed assignment of matrix, last lhs index must be ()
   error: assignment failed, or no method for `matrix = scalar'
   error: evaluating assignment expression near line 32, column 32

doesn't work w/ octave-2.1.53. Is that normal, or a bug?

I'm not surprised.  In fact I would be surprised if it had
worked.  I'm also pleased by the polite error message.

Not that I believe it should or should not work,  just that
the underlying array implementation uses dense arrays,
with no option to represent an array as a slice of another
array, so it would be tricky to map the assignment back
into the original array through two levels of subscripting.

The same construct, foo(1:3,:)(1:6), works as RHS because
foo(1:3,:) becomes a temporary octave value which then is
subscripted by (1:6).

BTW, doesn't foo(1:3,1:2)=1 give you what you want?

Paul Kienzle
address@hidden



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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