[英]creating sub-matrices inside a big one in Eigen Library
I would like to construct the following matrix 我想构造以下矩阵
A(3x3) B(3x3N)
F = [|1 0 0| |0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0|;
(6x3+3N) |0 1 0| |0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0|;
|0 0 1| |0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0|;
------- -----------------------------------
|0 0 0| |0 0 0 1 0 0 0 0 0 0 0 0 ... 0 0 0|;
|0 0 0| |0 0 0 0 1 0 0 0 0 0 0 0 ... 0 0 0|;
|0 0 0| |0 0 0 0 0 1 0 0 0 0 0 0 ... 0 0 0|];
C(3x3) D(3x3N)
B & C
are always zeros. B & C
始终为零。 A
is an identity matrix. A
是一个单位矩阵。 D
is tricky. D
很棘手。 The ones are specified based on an index. 这些是基于索引指定的。 For example, if the index is 0
, then D
is 例如,如果索引为0
,则D
为
|1 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0|;
|0 1 0 0 0 0 0 0 0 0 0 0 ... 0 0 0|;
|0 0 1 0 0 0 0 0 0 0 0 0 ... 0 0 0|;
D(3x3N)
if the index is 1
then D
is 如果索引为1
则D
为
|0 0 0 1 0 0 0 0 0 0 0 0 ... 0 0 0|;
|0 0 0 0 1 0 0 0 0 0 0 0 ... 0 0 0|;
|0 0 0 0 0 1 0 0 0 0 0 0 ... 0 0 0|;
D(3x3N)
How is it possible to fulfil this procedure in Eigen Library? 如何在本征库中完成此过程? I know how to create matrices in Eigen but I don't know how to construct them as a one matrix. 我知道如何在Eigen中创建矩阵,但不知道如何将它们构造为一个矩阵。
Have a look at the page Advanced initialization in Eigen. 看一下Eigen中的高级初始化页面。 I think the following (untested) code constructs the matrix you want: 我认为以下(未经测试的)代码可以构建您想要的矩阵:
MatrixXd F(6, 3 + 3 * N); // you need to specify the size before doing F << ...
F << MatrixXd::Identity(3, 3), // matrix A
MatrixXd::Zero(3, 3 * N), // matrix B
MatrixXd::Zero(3, 3 + 3 * index), // matrix C plus left zero block in D
MatrixXd::Identity(3, 3), // indentity block in D
MatrixXd::Zero(3, 3 * (N - index - 1)); // right zero block in D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.