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

Collection of arrays

Tags: None
(comma "," separated)
bravimalko
Registered Member
Posts
2
Karma
0

Collection of arrays

Thu Oct 11, 2012 10:09 am
Hello, I am in need of a 3-dim array which is, in reality, just a collection of 2-dim arrays.
The number of 2-dim arrays is known at compile time, usually between 10-100. The size of the 2-dim arrays is known at compile time but is large, thus I prefear to use dynamic arrays.

At the moment I do this:
Code: Select all
typedef std::complex<mpreal> mpcomplex;
typedef Matrix<mpcomplex, Dynamic, Dynamic> MatrixXmpc;

   MatrixXmpc s[4];

   for (int i = 0; i < 4; i++) s[i].resize(DIM,DIM);   


What I am wondering is if there's a less clumsy way to do this (i.e. is it possible to avoid the iteration and specify the dimension (DIM,DIM) in the declaration of s[4]?).


Thanks!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Collection of arrays  Topic is solved

Fri Oct 12, 2012 7:30 pm
you can use a std::vector< MatrixXmpc > s(4, MatrixXmpc(DIM,DIM) );


Bookmarks



Who is online

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