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

Fixed Size Matrices

Tags: None
(comma "," separated)
blubber
Registered Member
Posts
6
Karma
0

Fixed Size Matrices  Topic is solved

Wed Oct 06, 2010 8:26 pm
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?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Fixed Size Matrices

Thu Oct 07, 2010 5:28 pm
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 ?
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: Fixed Size Matrices

Thu Oct 14, 2010 9:25 pm
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!


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient