Matrix 68x68 transformed into vector of 2346 elements by my_matrix[np.tril_indices(68)]. Done some things with it and after that I would like to reconstruct it back to matrix of 68x68.
Final matrix should be as follows. My matrix would be only in lower part from diagonal. Rest would be zeroed. As you can see image from my original matrix:
Note: Green is values from vector, red is zeros.
Use the same indices from np.tril_indices
to reconstruct -
N = 68 # Number of rows/cols in original array
r,c = np.tril_indices(N) # Get the lower triangular region indices
# Initialize o/p array and assign from data_array (2346) elems array
out = np.zeros((N,N),dtype=data_array.dtype)
out[r,c] = data_array