This bugzilla service is closed. All entries have been migrated to

Bug 1352

Summary: Generalize replicate(.) to block diagonal replication
Product: Eigen Reporter: Angelos Mantzaflaris <Angelos.Mantzaflaris>
Component: Core - expression templatesAssignee: Nobody <eigen.nobody>
Status: NEW ---    
Severity: Feature Request CC: chtz, gael.guennebaud, jacob.benoit.1
Priority: Normal    
Version: 3.3 (current stable)   
Hardware: All   
OS: All   

Description Angelos Mantzaflaris 2016-11-30 10:22:31 UTC
The Matrix::replicate(int) is very useful for writing compact formulas.

I am also using (through the plugin mechanism) a similar expression, called blockDiag(int):

Eigen::Matrix A;
Eigen::Matrix B = A.blockDiag(3);

produces the matrix exrpression:

[ A 0 0 ] 
[ 0 A 0 ]
[ 0 0 A ]

The implementation is very similar to the replicate. This can be used eg. in the context of elasticity finite element matrices, if A are derivatives of scalar basis functions and the block diagonal expression provides derivatives of (3D) displacement vector.

Maybe a better name could be Matrix::diagonalReplicate(int). Posting it here just in case that it is of interest for other purposes as well.
Comment 1 Gael Guennebaud 2016-11-30 17:04:00 UTC
This feature would be more powerful with a true concept of block-diagonal for which diagonalReplicate would only be a special case. Otherwise the special structure is lost.
Comment 2 Angelos Mantzaflaris 2016-11-30 17:56:18 UTC
Sure, that would be nice, then something like

std::vector<Eigen::Matrix<double> > mVec(3);
Eigen::BlockDiagonal<double> M(mVec);


Eigen::BlockDiagonal<double> M;

to get

[ A 0 0 ] 
[ 0 B 0 ]
[ 0 0 C ]

so that

Eigen::BlockDiagonal<double> M(A,3);

yields diagonalReplicate.
Comment 3 Nobody 2019-12-04 16:33:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: