Boost logo

Ublas :

From: Andreas Zilian (a.koelke_at_[hidden])
Date: 2007-11-22 03:58:17


Hello ublas,

I would like to add a vector my_vec to a matrix my_mat as follows:

before:

0000 and XXX
0000
0000
0000

after:

0000
0XXX
0000
0000

I tried the construction:

ublas::subrange( ublas::row (my_mat, 1), 1, 4 ) += my_vec;

but the compiler (icpc) failed and stated the error:

error #137: expression must be a modifiable lvalue
              t1 = t2;
              ^

A possible way to circumvent works:

ublas::matrix_row<matrix<double>> tmp (my_mat, 0);
ublas::subrange( tmp, 0, 8 ) += my_vec;

but I was wondering about performance issues on that solution.

So, my question is how is the reference solution to add a vector to
a sub-region of a matrix?

Thanks in advance for your help,

Andreas.