help-octave
[Top][All Lists]
Advanced

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

Custom type subscript assignment


From: r-j-k
Subject: Custom type subscript assignment
Date: Wed, 22 Jul 2009 05:42:37 -0700 (PDT)

Hi, I'm close to finishing my custom matrix type. I have implemented
subscript assignment and it works correctly:

octave:13> x = my_matrix([10, 9, 8]);
octave:14> x(2)
ans =  9
octave:15> x(2) = 5
x =

   10    5    8

However, when I make a copy of x, y = x, and try to assign to either y or x,
the behaviour is as if x or y are undefined:

octave:16> x = my_matrix([10, 9, 8]);
octave:17> y = x
y =

   10    9    8

octave:18> y(2) = 5
y =

   0   5

After the value of y is changed as above, I can correctly assign to x:

octave:19> x(2) = 5
x =

   10    5    8


I realise that y is not a deep copy and something related to that is
probably causing my problem. I know that my subscript assign operator is not
being called at all in the problematic case. Any ideas how to correct this? 

Many thanks.
-- 
View this message in context: 
http://www.nabble.com/Custom-type-subscript-assignment-tp24605107p24605107.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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