Boost logo

Ublas :

Subject: Re: [ublas] matrix_row fails with symmetric matrix
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2010-05-18 19:41:58


Hello Andrea,

Andrea Cassioli schrieb:
> I'm pretty sure I'm doing something wrong, but I would expect the
> matrix_row adaptor to behave as a normal vector, that is I would like
> to play with it seamlessly.
>
> Am I wrong or it is a bug??
>

I am not sure if I understand you code. However, a ublas::vector is
_not_ a STL vector. The reason is that ublas' vectors and matrices
represent object for linear algebra, where STL vectors are simply
containers. An ublas vector is much more like a std::valarray than like
any other STL container. Thus it is not possible to assign a vector of
length n to a vector of length (n+1).

Despite that: you can use the free functions project(), row() and
column() to get more expressive code. For example:

matrix<double> A(10,10);
vector<double> v(5);

// untested
v = project( row(A, 3), range(0,5) );
project( column(A, 4), range(5,10) ) = v;

see also
http://www.boost.org/doc/libs/1_43_0/libs/numeric/ublas/doc/operations_overview.htm#sub

mfg
Gunter

__________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 5125 (20100518) __________

E-Mail wurde geprüft mit ESET NOD32 Antivirus.

http://www.eset.com