Boost logo

Boost Users :

From: mikehayford mikeh_at_[hidden])
Date: 2003-01-06 20:25:33


--- In Boost-Users_at_[hidden], jhr.walter_at_t... wrote:
>
> ----- Original Message -----
> From: Mike Hayford
> To: Boost-Users_at_[hidden]
> Sent: Tuesday, December 31, 2002 8:20 AM
> Subject: [Boost-Users] ublas - newbie question and comment
>
stuff clipped...
> >
> > Problem: write the product of a diagonal matrix and a vector when
the
> diagonal matrix is stored as a vector.
> >
>
> I'd use a banded_matrix with number of upper and lower diagonals set
to
> zero. Another strategy could be to add an expression tree node class
for
> this operation based on vector_binary.

The banded_matrix approach is straightforward. Here's what I wound up
with:

int n = 5;

vector<double> x(n), y(n), diag(n);
banded_matrix<double> dMat(n, n, 0, 0);
matrix_vector_slice<banded_matrix<double> > diagSlice(dMat, slice(0,
1, n), slice(0, 1, n));

diagSlice = diag;

x = prod(dMat, y);

Thanks for the help.

Regards,
Mike


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net