I was looking for a built in method to convert an linear array to triangular matrix. As I failed in find one I am asking for help in implementing one.
Imagine an array like:
In [203]: dm
Out[203]: array([ 0.80487805, 0.90243902, 0.85365854, ..., 0.95121951,
0.90243902, 1. ])
In [204]: dm.shape
Out[204]: (2211,)
And I would like to convert this array to a an triangular matrix or a symmetric rectangular matrix.
In [205]: reshapedDm = dm.trian_reshape(67, 67)
How I would implement trian_reshape as function that returns an triangular matrix from 1-D array?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…