This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Matrix multiplication involving empty columns or rows

Tags: None
(comma "," separated)
coolcat
Registered Member
Posts
20
Karma
0
OS
Hi,

This seems to be nonsense but somethimes I need the following operations:

-----------------------------------------------------------
Eigen::Matrix<double, 6, 2> B;
Eigen::Matrix<double, 2, 1> b;
B.setConstant(1);
b.setZero();

Eigen::Matrix<double, 6, 1> c = B.rightCols<0>() * b.head<0>();
std::cout << c;
-----------------------------------------------------------------

Logically thinking, multiplication of 6-by-0 matrix to 0-by-1 vector is feasible and
it gives 6-by-1 zero vector. However, Eigen doesn't allow this operation. It signals the assert
"Assertion failed: lhs.cols()>0 && "you are using a non initialized matrix", file d:\.......\eigen\Eigen\src\core\products\coeffvaseproduct.h, line 265".

Is there any way to make this operation feasible?

Thanks in advance.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
This is currently not possible because for small matrices the reduction is implemented like this:

res = lhs.coeff(row, 0) * rhs.coeff(0, col);
for(Index i = 1; i < lhs.cols(); ++i)
res += lhs.coeff(row, i) * rhs.coeff(i, col);

Feel free to add a bug entry so that we don't forget about it: http://eigen.tuxfamily.org/bz/


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]