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

(Eigen 3.1.0) Support for empty matrices

Tags: None
(comma "," separated)
sgollamu
Registered Member
Posts
8
Karma
0
OS
Hi, I would like to define a block matrix of size (n+m)x(n+m) as follows:
B11 B12
B21 B22
where B11 is (nxn) and B22 is (mxm). If I use the comma initializer as
Code: Select all
MatrixXd B(n+m,n+m);
B << B11, B12, B21, B22;

This works only if n and m are both non-zero. What can I do to support the possibility that either could be zero? I can use if statements to check, but that would quickly become unmanageable as the number of blocks increases.

Thanks!
S
jitseniesen
Registered Member
Posts
204
Karma
2
I did not try, but I assume from your post that your code does not work if n or m are zero. I think that is a bug, so your best bet is to fix it and send a patch at http://eigen.tuxfamily.org/bz/ . If you cannot fix it yourself, a bug report at the same place would also be helpful in making sure we do not forget about it.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
should be fixed:

https://bitbucket.org/eigen/eigen/chang ... 8f8406ee7/
changeset: 6d68f8406ee7
user: ggael
date: 2012-10-03 21:58:14
summary: fix comma initializer when inserting empty matrices
affected #: 1 file


https://bitbucket.org/eigen/eigen/chang ... d4ec16126/
changeset: 6fbd4ec16126
branch: 3.1
user: ggael
date: 2012-10-03 21:58:14
summary: fix comma initializer when inserting empty matrices
(transplanted from 6d68f8406ee739115a063d3524741411d5a23ab7)
User avatar
alecjacobson
Registered Member
Posts
26
Karma
0
This problem seems to have creeped in again.

If I run:

Code: Select all
  Eigen::VectorXd UL(3),U(3),L;
  UL<<U,L;


I get:

Code: Select all
Assertion failed: ((m_row+m_currentBlockRows) == m_xpr.rows() && m_col == m_xpr.cols() && "Too few coefficients passed to comma initializer (operator<<)"), function ~CommaInitializer, file /usr/local/include/eigen3/Eigen/src/Core/CommaInitializer.h, line 109.
User avatar
alecjacobson
Registered Member
Posts
26
Karma
0
( I have version 3.2.9 )
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
This has been fixed some weeks ago in both 3.2 and 3.3 branches.
User avatar
alecjacobson
Registered Member
Posts
26
Karma
0
On which minor/commit version of the 3.2 branch was this fixed again?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
There is a bunch of commits that are all in 3.2.10:

10f2cc514f6c
1e7d97fea51d
75abaeb43845
44abf0a7b16a

but since the 3.2 branch does not fully handle empty matrices (irrespective to comma-init) there might be some unsupported cases (caught by assertions).


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]