Registered Member
|
Hello,
I want to use eigen to do some matrix calculations and have a question regarding the fixed size matrices. The matrix sizes depend on different variables e.g. a,b,c,d. Some matrices have size a+b times a+b, other bc times bc. a,b,c,d are fixed - but I do not want to write the exact values into the (whole) C code - so I fix them using #define. Also a+b is calculated by the preprocessor, which makes the Code a bit ackward - I need to define several constant, which are only used to for the sizes of matrices. Is there a clever way to avoid these many defines? |
Moderator
|
use const int variables:
const int a = 3; const int b = 4; Matrix<float,a+b+1,a*c> mat; or make them template arguments of your higher level algorithms... Does that answer your concerns ? |
Registered Member
|
Well, const int can still be overwritten (e.g. with a const_cast), so could theoretically be rejected by compilers, so the way we do it in eigen is as enum values
enum { a = b+c; }
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient