Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-05-22 06:39:07

On Sunday 21 May 2006 13:25, eeitan_at_[hidden] wrote:
> hello, which is the best way to calculate:
> mat1+=scalar*mat2;
> mat1+=scalar*(mat2+ublas::trans(mat2));
> in case of dense and sparse matrices ???

This is already the best way and very efficient for dense matrices. However,
the operation X+trans(X) may be very slow for sparse matrices and should be

mat1 += scalar * mat2;
mat1 += scalar * trans(mat2);

(if mat1 is sparse, too, this does not help anyway because the left hand side
in general determines the orientation of the computation (row/columnwise).)