简体   繁体   English

在一行中创建和填充非常量特征矩阵?

[英]Create and fill non-constant Eigen matrix in one line?

How can I create and initialize a non-constant eigen matrix in one line?如何在一行中创建和初始化非常量特征矩阵? Here is an example of what I'm trying to do with 2 lines,这是我试图用 2 行做的一个例子,

auto a = Eigen::Matrix<int, 4, 4>{};
a.fill(0);

or或者

a.fill(1);
a.fill(2);
// etc.

In C++ most whitespaces are not necessary.在 C++ 中,大多数空格不是必需的。 You could remove most whitespaces and write all your code in one line.您可以删除大多数空格并将所有代码写在一行中。 This这个

auto a = Eigen::Matrix<int, 4, 4>{}; a.fill(0); a.fill(1); a.fill(2);

is a valid one-liner in C++.是 C++ 中的有效单行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM