Matrix/Vector component-wise product

Issue #140 new
Fabien Péan created an issue

It would nice to have an optimized expression directly in the library for a matrix-vector component-wise product, like a schur overload, allowing to compute row-wise (or column-wise depending on the vector transpose flag) product between a matrix and a vector

Vector<...,columnVector> v1;
Vector<...,rowVector> v2;
Matrix<...> M1, M2; M3;
M2 = M1%v1; // commutative, equivalent to: 
//for(auto i =0UL; i<M1.columns();i++) 
//    column(M2,i)=column(M1,i)*v1
M3 = M1%v2; // commutative, equivalent to: 
//for(auto i =0UL; i<M1.rows();i++) 
//    row(M3,i)=row(M1,i)*v2;

Depending on the storage order of the matrix, optimization can be done over the simple for-loop.

Comments (1)

  1. Klaus Iglberger

    Hi Fabien!

    Thanks a lot for the proposal. We realize that this can be a useful operation. However, an alternative approach is described in issue #43, which requests an operation that allows to treat a vector as a matrix. With this operation it would be possible to use the regular Schur product. Since the approach of issue #43 is more general and would not require the definition of a new operation, we prefer that solution. Still, we will keep this issue open to remind us about the request and we will resolve it once the componentwise matrix/vector product is possible without an explicit for loop.

    Best regards,

    Klaus!

  2. Log in to comment