dangerChihuahua007
dangerChihuahua007

Reputation: 20895

How do I make a diagonal matrix in eigen with a dynamic size?

I want to make a diagonal matrix with the C++ linear algebra library eigen, but I do not know the size of the matrix during compile time. Hence,

DiagonalMatrix<Scalar, SizeAtCompileTime> diag1(size);

will not work. The values along the diagonal also differ. Help?

Upvotes: 1

Views: 1704

Answers (1)

ggael
ggael

Reputation: 29205

You need to instantiate the template parameter with what is relevant for you:

DiagonalMatrix<double,Eigen::Dynamic> diag1(size);

Upvotes: 4

Related Questions