[Numpy-discussion] matrix indexing question

Alan G Isaac aisaac at american.edu
Tue Mar 27 21:43:59 EDT 2007


>>  On Tue, 27 Mar 2007, Robert Kern apparently wrote: 
>>>  Gram-Schmidt orthogonalization 

 
> Alan G Isaac wrote:
>>  I take it from context that you consider it desirable
>>  to end up with a list of matrices?


Robert wrote:
> Honestly, I don't care. You asked about iteration, and 
> I gave you an example
> where it was important that the iterates were matrices 
> (such that .T worked correctly).
> Please stop moving the goal posts.

It is really not my intent to be irritating or to move the posts.
But I had two reasons to ask.

First, your claim is false that this was important in your example.
(To see this, replace M[1:] with M.A[1:].)
So actually your code would work the same if iteration over 
matrices were producing arrays
(after replacing M[0] with M[0,:] to match that case).

Second, when I spoke of *desirability*, the output is relevant.
Try nump.mat(ortho) to see what I mean.
If iteration were to produce arrays,
the outcome of implementing the algorithm
(e.g., using ``dot``)
would be I suggest more "desirable",
in that numpy.mat(ortho) would work as hoped/expected.

In this sense, the example perhaps speaks against your intent.
You offer code that would work just fine if iteration 
yielded arrays.

Apologies in advance if this again seems tangential to my 
original request.  To me it does not.


> If you really want iterates to be arrays, just use .A.

I have mentioned that several times.
It is orthogonal to the design issue I raised.
(I suggested that under the current behavior you do not 
usually end up with what you want when iterating over matrices.)
But again, I recognize that I am alone in that view.
I am just trying to understand why.

Cheers,
Alan Isaac





More information about the NumPy-Discussion mailing list