I would like the simplest way to an element of a multidimensional array in Python from a tuple/list of the indexes.
I.e. f( M, (a,b,c) ) returns M[a][b][c]
Is there a straightforward way to get this without coding it myself?
I would like the simplest way to an element of a multidimensional array in Python from a tuple/list of the indexes.
I.e. f( M, (a,b,c) ) returns M[a][b][c]
Is there a straightforward way to get this without coding it myself?
You can use numpy arrays for that.
Example:
import numpy as np
x = [ [[1,1,1],[1,1,1], [1,1,1]], [[2,2,2],[2,2,2],[2,2,2]], [[3,3,3], [3,3,3], [3,3,3]]]
matrix = np.array(x)
print(matrix[0,0,0]) # prints first element in matrix