[Numpy-discussion] matrix indexing question

Paulo Jose da Silva e Silva pjssilva@ime.usp...
Sun Mar 25 12:48:44 CDT 2007


Em Dom, 2007-03-25 às 13:07 -0400, Alan G Isaac escreveu:

> So this ::
> 
>     >>> x[1]
>     matrix([[1, 0]])
> 
> feels wrong.  (Similarly when iterating across rows.)
> Of course I realize that I can just ::
> 
>     >>> x.A[1]
>     array([1, 0])
> 
> but since the above keeps feeling wrong I felt I should 
> raise this as a possible design issue, better discussed
> early than latter.

I think the point here is that if you are using matrices, then all you
"should" want are matrices, just like in MATLAB:


        >> A = [1 2; 3 4]
        
        A =
        
             1     2
             3     4
        
        >> b = A(1, :)
        
        b =
        
             1     2
        
        >> size(b)
        
        ans =
        
             1     2
        
        >> b = A(:, 1)
        
        b =
        
             1
             3
        
        >> size(b)
        
        ans =
        
             2     1
        
        >> b = 1
        
        b =
        
             1
        
        >> size(b)
        
        ans =
        
             1     1
        
        
You see, rows, columnes, and even numbers, are treated as matrices.

Paulo
 
        
-- 
Paulo José da Silva e Silva 
Professor Assistente do Dep. de Ciência da Computação
(Assistant Professor of the Computer Science Dept.)
Universidade de São Paulo - Brazil

e-mail: rsilva@ime.usp.br           Web: http://www.ime.usp.br/~rsilva

Teoria é o que não entendemos o     (Theory is something we don't)
suficiente para chamar de prática.  (understand well enough to call practice)



More information about the Numpy-discussion mailing list