Discussion:
octave c++ api: sparse matrix vector product ?
(too old to reply)
h***@googlemail.com
2008-02-26 19:55:07 UTC
Permalink
Hello octave group!

I am using octave libraries in my C++ programs, and recently switched
to the sparse matrix classes provided therein.

However, I am missing e.g. a simple matrix vector product
implementation of SparseComplexMatrix, i.e. multiplying it by a
ComplexColumnVector from the right.
Until now, I use my own quick and dirty approach, but I am shure that
there exists a more efficient implementation for this workhorse
routine.

Furthermore it would be convenient, to simply have the "*" operator
for the sparse classes, when applied to ColumnVector classes

So is this feature hidden somewhere?

Thanks in advance,

Hannu Wichterich
David Bateman
2008-03-04 17:34:26 UTC
Permalink
Post by h***@googlemail.com
Hello octave group!
This is not really where the "octave group" hangs out, which explains
the low number of messages here and the slow response to your message.
Post by h***@googlemail.com
I am using octave libraries in my C++ programs, and recently switched
to the sparse matrix classes provided therein.
Good to know someones using the code I wrote :-)
Post by h***@googlemail.com
However, I am missing e.g. a simple matrix vector product
implementation of SparseComplexMatrix, i.e. multiplying it by a
ComplexColumnVector from the right.
Until now, I use my own quick and dirty approach, but I am shure that
there exists a more efficient implementation for this workhorse
routine.
Furthermore it would be convenient, to simply have the "*" operator
for the sparse classes, when applied to ColumnVector classes
So is this feature hidden somewhere?
Sure it exists. A ColumnVector is just a special class of a Matrix (or
rather the Array<T> class) that just happens to have a single column and
n rows. There you want to use the

Matrix operator * (const SparseMatrix& m, const Matrix& a);

operator exactly as you suspected... I suppose we might include the operator

ColumnVector
operator * (const SparseMatrix& m, const ColumnVector& a)
{
return ColumnVector (m * Matrix (a));
}

for convenience, but it doesn't really add any functionality.


D.

Loading...