[Numpy-discussion] transpose of a matrix should be another matrix

Phillip M. Feldman pfeldman at verizon.net
Tue Jul 7 11:52:49 EDT 2009


Chris and David-

I've verified that both of your solutions work.  I have a lot to learn!  
Thanks!

Phillip

David Goldsmith wrote:
> Also, there is a "non-method" way: the .T property:
>
>   
>>>> a = np. matrix([[1,2,3],[4,5,6],[7,8,9]])
>>>> a
>>>>         
> matrix([[1, 2, 3],
>         [4, 5, 6],
>         [7, 8, 9]])
>   
>>>> b = a.T
>>>> b
>>>>         
> matrix([[1, 4, 7],
>         [2, 5, 8],
>         [3, 6, 9]])
>
> DG
>
> --- On Mon, 7/6/09, Chris Colbert <sccolbert at gmail.com> wrote:
>
>   
>> From: Chris Colbert <sccolbert at gmail.com>
>> Subject: Re: [Numpy-discussion] transpose of a matrix should be another matrix
>> To: "Discussion of Numerical Python" <numpy-discussion at scipy.org>
>> Date: Monday, July 6, 2009, 10:42 PM
>> you actually have to call the method as
>> transpose(). What you requested was the actual method. 
>>
>>     
>>>>> import numpy as np
>>>>> a = np. matrix([[1,2,3],[4,5,6],[7,8,9]])
>>>>> a
>>>>>           
>> matrix([[1, 2, 3],
>>
>>         [4, 5, 6],
>>         [7, 8, 9]])
>>     
>>>>> b = a.transpose()
>>>>> b
>>>>>           
>> matrix([[1, 4, 7],
>>         [2, 5, 8],
>>         [3, 6, 9]])
>>     
>> On Tue, Jul 7, 2009 at 1:34 AM,
>> Dr. Phillip M. Feldman <pfeldman at verizon.net>
>> wrote:
>>
>>
>>
>> I'm using the Enthought Python Distribution. When I
>> define a matrix and
>>
>> transpose it, it appears that the result is no longer a
>> matrix (see below).
>>
>> This is both surprising and disappointing.  Any
>> suggestions will be
>>
>> appreciated.
>>
>>
>>
>> In [16]: A=matrix([[1,2,3],[4,5,6],[7,8,9]])
>>
>>
>>
>> In [17]: B=A.transpose
>>
>>
>>
>> In [18]: A
>>
>> Out[18]:
>>
>> matrix([[1, 2, 3],
>>
>>         [4, 5, 6],
>>
>>         [7, 8, 9]])
>>
>>
>>
>> In [19]: B
>>
>> Out[19]: <built-in method transpose of matrix object at
>> 0x00CF2A30>
>>
>> --
>>
>> View this message in context: http://www.nabble.com/transpose-of-a-matrix-should-be-another-matrix-tp24367402p24367402.html
>>
>>
>> Sent from the Numpy-discussion mailing list archive at
>> Nabble.com.
>>
>>
>>
>> _______________________________________________
>>
>> Numpy-discussion mailing list
>>
>> Numpy-discussion at scipy.org
>>
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>>
>>
>> -----Inline Attachment Follows-----
>>
>> _______________________________________________
>> Numpy-discussion mailing list
>> Numpy-discussion at scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>     
>
>
>       
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090707/0c737811/attachment.html>


More information about the NumPy-Discussion mailing list