triqs.operators.util.U_matrix.subarray
- triqs.operators.util.U_matrix.subarray(a, idxlist, n=None)[source]
Extract a subarray from a matrix-like object.
- Parameters:
- anumpy.ndarray
Array to extract the subarray from.
- idxlistlist of tuples of int
For each dimension, the indices to keep along that dimension.
- Returns:
- numpy.ndarray
The extracted subarray.
Examples
>>> import numpy as np >>> a = np.arange(2 * 4 * 4).reshape(2, 4, 4) >>> subarray(a, [(0,), (2, 3), (0, 1, 2, 3)]) array([[[ 8, 9, 10, 11], [12, 13, 14, 15]]])
This keeps
column 0 for the 1st dimension,
columns 2 and 3 for the 2nd dimension,
columns 0, 1, 2 and 3 for the 3rd dimension.