C++ Eigen initialize static matrix -
is possible initialize static eigen matrix4d in header file? want use global variable.
i'd along lines of:
static eigen::matrix4d foo = eigen::matrix4d(1, 2 ... 16);
or similar vectors:
static eigen::matrix4d foo = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
here link eigen matrix docs. can't seem find how there.
on lines of dawid's answer (which has small issue, see comments), can do:
static eigen::matrix4d foo = [] { eigen::matrix4d tmp; tmp << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16; return tmp; }();
return value optimization takes care of temporary, no worries copy.
Comments
Post a Comment