From bug-octave-request at bevo dot che dot wisc dot edu Sun Jan 5 18:52:51 2003 Subject: Re: Operations on matrix referenced by a list of indices From: Paul Kienzle To: =?ISO-8859-2?Q?Igor_=D0ukanovi=E6?= Cc: bug-octave at bevo dot che dot wisc dot edu Date: Sun, 05 Jan 2003 19:53:14 -0500 Igor Đukanović wrote: > However statement > A([ 1 1])= A([1 1]) + [ 8 9]; > does (same as in Matlab) > A(1) = A(1) + 9; > and that's bad. I want it to do > A(1) = A(1) + 8; A(1)=A(1) + 9; > producing > A(1)=A(1)+8+9; > otherwise I would not include 1 in index list twice. I'm guessing your real code is much more complicated which is why you don't say A(1) += sum(B). Assuming you have sparse matrices from octave-forge, then instead of A(idx) = A(idx) + B; you can do something like (untested): Bsum = spsum(sparse(1:length(idx),idx,B)); Bidx = find(Bsum); # perhaps spfind. spsum ought to return a sparse vector. A(Bidx) += Bsum(Bidx); > P.S. Info: octave-2.1.36 > Windows 98 on Pentium Use the older version of octave-forge unless you want to install a newer version of octave. 2.1.43 requires octave-forge from CVS to compile. Paul Kienzle pkienzle at users dot sf dot net ------------------------------------------------------------- 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 -------------------------------------------------------------