[Numpy-discussion] Retrieving and flattening lower triangular components of inner axes of 3d array

Damien Moore damienlmoore at gmail.com
Fri May 25 10:19:34 EDT 2012

Hi List,

I have an array, x, with dimensions (K,M,M). I would like to compute a
new array, y ~ (K,M*(M+1)/2), such that

y[k] = numpy.tril(x[k]).flatten() for each k = 0,..,K-1

Is there a way to do this without looping? I was trying with
tril_indices but couldn't quite get the logic right.


More information about the NumPy-Discussion mailing list