Boost logo

Ublas :

From: Jesse Manning (manning.jesse_at_[hidden])
Date: 2008-06-09 14:24:37


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);
 }

On Mon, Jun 9, 2008 at 2:07 PM, Jeremy Conlin <jeremit0_at_[hidden]> wrote:

> I'm trying to figure out how to iterate over the columns or rows of a
> ublas::matrix and I'm having trouble understand the documentation. There
> seems to be many things that may be what I want, i.e. row, matrix_row,
> column/row iterator, but it's difficult to know which one gives what I want.
> I have tried several options, but none seem to fit.
> I want to iterate over the rows of a matrix so I can normalize them as
>
> row = row/ublas::norm_2(row);
>
> What is the best way to do this?
>
> Thanks,
> Jeremy
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>
>