[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: indexed assignment for sparse matrices in ov-2.9.4
From: |
Thomas Kasper |
Subject: |
Re: indexed assignment for sparse matrices in ov-2.9.4 |
Date: |
Fri, 20 Jan 2006 16:45:46 +0100 (MET) |
> --- Ursprüngliche Nachricht ---
> Von: David Bateman <address@hidden>
> An: Thomas Kasper <address@hidden>
> Betreff: Re: indexed assignment for sparse matrices in ov-2.9.4
> Datum: Fri, 20 Jan 2006 09:06:28 +0100
>
> Thomas Kasper a écrit :
>
> > Sorry for bothering you again, but I realize the example you just gave
> > me works fine with my version as well. I probably should have told you
> > in my initial report, but RHS indexing has never been an issue.
> >
> > Could you be so kind as to briefly check whether indexing on the LHS
> > of an assignment works? Before recompiling everything from scratch,
> > I just would like to make sure it really adresses my problem.
> > Thank you!
> > Thomas
> >
> Do you mean
>
> octave:1> a = speye(3);
> octave:2> a= a(:,[3,2,1])
> a =
>
> Compressed Column Sparse (rows = 3, cols = 3, nnz = 3)
>
> (3, 1) -> 1
> (2, 2) -> 1
> (1, 3) -> 1
>
> which is RHS idexing. The LHS indexing was the case I showed previously.
> This seems to work perfectly as well, and I believe it worked in 2.9.4
> as well. So I don't see where the problem is...
>
> D.
I consider your code
> > > octave:4> a = speye(3)
> > > octave:5> a(:,[3,2,1])
> > > ans =
> > >
> > > Compressed Column Sparse (rows = 3, cols = 3, nnz = 3)
> > >
> > > (3, 1) -> 1
> > > (2, 2) -> 1
> > > (1, 3) -> 1
to be an implicit form of ans = a(:,[3,2,1]), thus *RHS-indexing*, while in
my sample-code "a(:,[3,2,1]) = a" the indices appeared on the LHS of the
assignment.
You may dismiss this as pedantic, but the distinction is not totally
arbitrary. As far as I can see, the case of RHS-indexing is handled by
template <class T> Sparse<T> Sparse<T>::index (Array<idx_vector>& ra_idx,
int resize_ok) const
whereas LHS-indexing - passing via octave_base_sparse<T>::assign(...) - is
eventually handled by
template <class LT, class RT> int assign (Sparse<LT>& lhs, const Sparse<RT>&
rhs)
(both in /liboctave/Sparse.cc)
Now, comparing octave-2.9.4 to the current CVS, I find that LHS-indexing
works without flaw on either version. But even with today's CVS I keep
getting
octave:1> a = speye(3);
octave:2> a(:,[3,2,1]) = a
a =
Compressed Column Sparse (rows = 3, cols = 3, nnz = 3)
(1, 1) -> 1
(2, 2) -> 1
(3, 3) -> 1
octave:3>
Sorry, I do maintain there is a bug.
Cheers,
Thomas
--
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++
-------------------------------------------------------------
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
-------------------------------------------------------------