Friends,
I have to save only the lower half of a symmetric matrix to a file. I used
numpy.tril to extract the lower half. However when i use 'numpy.savetxt',
numpy saves the whole matrix (with upper half values replaced as zeros)
rather than only the lower half. Any better idea to achieve this.

as an example
>>>import numpy as np
>>> d=np.arange(1,26,1)
>>> d=d.reshape(5,5)
>>> np.tril(d)
array([[ 1,  0,  0,  0,  0],
       [ 6,  7,  0,  0,  0],
       [11, 12, 13,  0,  0],
       [16, 17, 18, 19,  0],
       [21, 22, 23, 24, 25]])

>>> np.savetxt( 'test', np.tril(d))
output test also contains the zeros, what i want is only the lower half
like below.
1
6    7
11 12 13
 -     -     -    -  etc

Thanks,
Bala


-- 
C. Balasubramanian
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to