简体   繁体   中英

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,

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. 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++.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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