[Numpy-discussion] matrix indexing question

Robert Kern robert.kern@gmail....
Tue Mar 27 15:21:15 CDT 2007


Alan G Isaac wrote:
> Hi Zach,
> 
> The use case I requested was for iteration over a
> matrix where it is desirable that matrices are yielded.
> That is not what you offered.
> 
> The context for this request is my own experience:
> whenever I have needed to iterate over matrices,
> I have always wanted the arrays.  So I am simply
> interested in seeing an example of the opposite desire.

Gram-Schmidt orthogonalization.

ortho = [mat[0] / sqrt(mat[0] * mat[0].T)]
for rowv in mat[1:]:
    for base in ortho:
        rowv = rowv - base * float(rowv * base.T)
    rowv = rowv / sqrt(rowv * rowv.T)
    ortho.append(rowv)

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list