### Element-wise multiplication using Eiegn I am trying to perform an element-wise multiplication of a row vector with matrix. In MATLAB this would be simply done by the "dot" operator or:

 `` `` `` data_deriv = 1i * k .* fk;``

where k is row vector and fk is a matrix.
Now in C++ I have this code:
 ``12345678910111213141516`` ``````Matrix eKX; eKX.setZero(); for(int i = 0; i < nx; i++){ eKX[i] = //some expression } for (int i = 0; i < nx; i++){ for (int j = 0; j < ny+1; j++){ for (int k = 0; k < ncomp; k++){ uhkOutX[i*(ny+1)+j][k] = //FFT of some expression } } } Eigen::Map euhX(reinterpret_cast*>(uhkOutX),(ny+1),nx); //(nyk),nx); ``````

Now, I am trying to take the product of eKX which is a row vector of 1 x 10 and the matrix euhX of a 11 x 10. I tried few things, none of which seem to work really:
 `` `` ``eduxk = 1i * eKX.array() * euhX.array() ; //ERROR ``

 ``` static assertion failed: YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES ```

Last edited on I was able to solve this issue with replacing the last line with:

 ``12`` ``````eduxk = euhX * (eKX * 1i).asDiagonal(); ``````

Topic archived. No new replies allowed.