gpumatrix icon indicating copy to clipboard operation
gpumatrix copied to clipboard

.array().colwise() not supported

Open TianBo-Timothy opened this issue 7 years ago • 2 comments

Hi, I was trying to do a column wise multiplication with gpumatrix. The corresponding code with Eigen is like the following:

Eigen::MatrixXd a = Eigen::MatrixXd::Random(5, 10);
Eigen::VectorXd v = Eigen::VectorXd::Random(5);
Eigen::MatrixXd b = a.array().colwise() * v.array();

When I compiled the following code:

gpumatrix::Matrix<double> da(a);
gpumatrix::Vector<double> dv(v);
gpumatrix::Matrix<double> db = da.array().colwise() * dv.array();

I got error messages like:

error: ‘class gpumatrix::Map<gpumatrix::Array<double, 2> >’ has no member named ‘colwise’

If colwise() is not meant to be implemented in gpumatrix, can you please enlighten me a workaround solution?

TianBo-Timothy avatar Feb 12 '18 12:02 TianBo-Timothy

With eigen, there is a workaround using .asDiagonal() like:

b = a * v.asDiagonal();

However, da * dv.asDiagonal() does not work.

TianBo-Timothy avatar Feb 12 '18 15:02 TianBo-Timothy

Also do you know why colwise is not supported for Eigen::TensorMap or in general dynamically sized Eigen tensor/matrix?

yunjiangster avatar Jan 13 '19 23:01 yunjiangster