Boost logo

Ublas :

From: Sebastian Gesemann (s.gesemann_at_[hidden])
Date: 2008-06-13 07:37:16


On Mon, Jun 9, 2008 at 8:24 PM, Jesse Manning wrote:
> This is the most straight forward way I can think of.
>
> typedef ublas::matrix<double> Mat_t;
> typedef ublas::matrix_row<Mat_t> Row_t;
> typedef Mat_t::size_type size_t;
>
> Mat_t data(10, 3);
> // fill out matrix here
>
> for (size_t index = 0, end = data.size1(); index != end; ++index)
> {
> Row_t row(ublas::row(data, index));
>
> row /= ublas::norm_2(row);
> }

"Row_t row(data, index);" should suffice. Otherwise you'd be creating
a temporary row vector and invoke the copy c'tor for 'row', I suppose.

Cheers,
SG