[Numpy-discussion] .T Transpose shortcut for arrays again

Sven Schreiber svetosch at gmx.net
Thu Jul 6 06:45:54 CDT 2006

Travis Oliphant schrieb:
> Bill Baxter wrote:
>> So in short my proposal is to:
>> --  make a.T a property of array that returns a.swapaxes(-2,-1),
>> --  make a.H a property of array that returns 
>> a.conjugate().swapaxes(-2,-1)
>> and maybe
>> --  make a.M a property of array that returns numpy.asmatrix(a)
> I've tentatively implemented all of these suggestions as well as adding 
> the .A attribute to the ndarray as well (so that all sub-classes and 
> array scalars can get back a view as an ndarray). 
> I did this to make it easier to do matrix-like calculations with or 
> with-out matrices.   Matrix-calculation flexibility is still a sore-spot 
> for many and I think these syntatical-sugar attributes will help long term.

I think this is great, thanks to Bill for suggesting it and to Travis
for implementing it!

So the only convenience of matrices over pure arrays that remains (afaics):

-) .I for inverse; actually, why not add that to arrays as well as
"syntactic sugar"?

-) * being the matrix product instead of element-wise; Now, I could live
with using dot and I don't want to push anything, but maybe this is the
right time to consider another operator symbol as a shortcut for the dot
function to be used with arrays? (Unfortunately right now I can't think
of any sensible character(s) for that...)

-) ** analogously for powers. For me this is less important.

-) Being able to distinguish between row and column vectors; I guess
this is just not possible with arrays...

If --apart from the previous changes-- numpy had the .I for arrays I
guess this would get me to say goodbye to matrices. The rest of the list
would be a welcome luxury. I believe this whole thing has the potential
to unify the use of numpy by eventually making the matrix subclass
redundant. IMO that would be more transparent for new users and would
increase the popularity of numpy!


More information about the Numpy-discussion mailing list