Conversion from 2D <array> to double[i][j]

Hi everyone,
I'm working on a little project, using threads and vector on Visual C++ 2010.
I have this problem.

I need to elaborate arrays of double 4x4 that I've in this format:

1
2
3
4
5
double T6[4][4] = {
	{-0.9485,    0.3013,   -0.0979,    0.1197},
	{0.1479,    0.1478,   -0.9779,    0.0971},
	{-0.2801,   -0.9420,   -0.1847,    0.7642},
	{0,         0,         0,    1.00000 }};


etc...I have "N" of these arrays.

I need to use them in a fuction "verifica_punti" that take in input one matrix at time in that format, because in this fuction there is this cycle:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

int verifica_punti(punto P, Mat& I, double TC[4][4], const double fc[2],const double KC[5], const double cc[2],const double alpha)

{

              double P1[4] = {P.x, P.y, P.z, 1.0};	
              double Pc[3] = {TC[0][3], TC[1][3], TC[2][3]};
	...	
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			Pc[i] += TC[i][j] * P1[j];
		}
	}
       ...
       other operations...
       }


I'm refer to TC[4][4]. That is array[4][4] that I've to pass.

Because I need to re-call this function in a for cycle with an integer variables (0 to N) I need to have these matrix stored on another vector, so I can access to single matrix with a refer like "vectorofmatrix[i]" or doing a "pop" from a vector/queue of these matrix store.

Someone tell me to use a combination of vector and array to doing this, and I wrote this code:

1
2
3
4
5
6
7
8
9
10
11
12
typedef array<array<double,4>,4> Matrix;


Matrix T1 = {{
			{{-1.0000,   0.0000,  -0.0000,   0.1531}},
			{{0.0000,   0.0000,  -1.0000,   0.1502 }},
			{{-0.0000,  -1.0000,  -0.0000,   1.0790}},
			{{0 ,       0,        0,   1.0000	  }}}}; 


Matrix T2 = ....


and so on for other 9 matrixs. Then, create a vector of these and fill it:

1
2
3
4
5
6
7
8
9
10
11
vector <Matrix> TCS;

        TCS.push_back(T1);
	TCS.push_back(T2);
	TCS.push_back(T3);
	TCS.push_back(T4);
	TCS.push_back(T5);
	TCS.push_back(T6);
	TCS.push_back(T7);
	TCS.push_back(T8);
	TCS.push_back(T9);


Now, for accessing at single matrix putted in, and convert it to standard double[4][4] array to have the correct format when I call the function, how can I do?

Because I've wrote:

(double**) m = TCS.pop_back();
or
 
(double**) m = TCS[i];


but isn't correct.

Someone can help me to doing this?

I have to convert "Matrix" typedef to "double[4][4]" so that function can be able to work on the stored values as you can see in the for cycle...

Thanks in advance at all.

Topic archived. No new replies allowed.