I'm looking for a way to import N matrices from one file to a single 3D array. I know the number of rows m and the number of columns n of each matrix (respectively listed in two lists m[N] and n[N]).
For example I have N=3 matrices like these:
1 2 3 4
5 6 7 8
9 10 11 12
1 2 3
4 5 6
7 8 9
10 11 12
1 2 3 4 5 6
7 8 9 10 11 12
They are matrices of dimension 3x4, 4x3, 2x6 respectively, so in this case m = [3,4,2] and n = [4,3,6].
I would store them in an object of the type M[i][j][k] where i,j,k are the indeces that identify the matrix, the row and the column respectively (in this case M[1][2][0]=7).
For example in C++ this can be easily done:
ifstream file ("filename.txt");
for(int i = 0; i < N; i++)
for(int j = 0; j < m[i]; j++)
for(int k = 0; k < n[i]; k++)
file >> M[i][j][k];
file.close();
Thanks in advance.
numpyornested python list?M?