This forum has been archived. All content is frozen. Please use KDE Discuss instead.

initializing a const Eigen::Matrix

Tags: None
(comma "," separated)
hazelnusse
Registered Member
Posts
5
Karma
0
OS

initializing a const Eigen::Matrix

Mon Aug 20, 2012 7:40 pm
I have a fixed sized matrix whose size and elements are known at compile time. Is it possible to declare and initialize a const Eigen::Matrix? I'm looking for something like:
Code: Select all
  const Eigen::Matrix<float, 2, 2> A = {1.0, 2.0, 3.0, 4.0}

When I do this, I get errors like:
Matrix.h:261:7: error: static assertion failed: THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE


I'm using this in an embedded (arm cortex-m3, bare metal) environment and want to make sure that there is zero runtime cost associated with initializing the Eigen::Matrix. Is this possible?
Hauke
Registered Member
Posts
109
Karma
3
OS
Hi hazelnusse,

try using
Code: Select all
const Eigen::Matrix<float, 2, 2> A = (Eigen::Matrix<float, 2, 2>() << 1.0f, 2.0f, 3.0f, 4.0f).finished()


Regards,
Hauke


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]