From: Travis O. <oli...@ee...> - 2006-07-07 20:21:46
|
I didn't compile the results, but the discussion on the idea of adding new attributes to the array object led to the following result. Added: .T attribute to mean self.transpose() .T This was rather controversial with many possibilities emerging. In the end, I think the common case of going back and forth between C-order and Fortran-order codes in a wide variety of settings convinced me to make .T a short-hand for .transpose() and add it as an attribute. This is now the behavior in SVN. Right now, for self.ndim < 2, this just returns a new reference to self (perhaps it should return a new view instead). .M While some were in favor, too many people opposed this (although the circular reference argument was not convincing). Instead a numpy.matlib module was started to store matrix versions of the standard array-creation functions and mat was re-labeled to "asmatrix" so that a copy is not made by default. .A A few were in favor, but as this is just syntactic sugar for .__array__() or asarray(obj) or .view(ndarray) it was thrown out because it is not used enough to add an additional attribute .H A few were in favor, but this can now be written .T.conj() which is not bad so does not get a new attribute. -Travis |
From: Fernando P. <fpe...@gm...> - 2006-07-08 19:50:19
|
Hi all, On 7/7/06, Travis Oliphant <oli...@ee...> wrote: > > I didn't compile the results, but the discussion on the idea of adding > new attributes to the array object led to the following result. > > Added: .T attribute to mean self.transpose() [...] > .H > > A few were in favor, but this can now be written .T.conj() which is not > bad so does not get a new attribute. I didn't have strong feelings one way or another on this, so I didn't vote, but at this point I'd like to make a comment before the freeze. Given that .T went in, I'd argue that .H should be in as well. Basically, I now think these two should have been considered as a bundle and not as separate options. The reason isn't (just) my OCD surfacing again, but the fact that the hermitian conjugate plays /exactly/ the role that transposition plays, in regards to defining norms and (positive definite) inner products, when complex arrays are in play. The fact that numpy has excellent complex support is a major source of joy for many. I think that having .T but not .H would be a big wart in this regard. If you are trying to write code for inner products with complex arrays, the natural language change from real ones is: dot(A.T,B) -> dot(A.H,B) For people who play with quantum mechanics this is an everyday need (self-adjoint operators require expressions like this all the time), but I suspect its use will be common in any field requiring normed spaces with complex arrays. Just my 1e-2j Cheers, f |
From: Charles R H. <cha...@gm...> - 2006-07-08 19:57:46
|
Hi all, On 7/8/06, Fernando Perez <fpe...@gm...> wrote: > > Hi all, > > On 7/7/06, Travis Oliphant <oli...@ee...> wrote: > > > > I didn't compile the results, but the discussion on the idea of adding > > new attributes to the array object led to the following result. > > > > Added: .T attribute to mean self.transpose() > > [...] > > > .H > > > > A few were in favor, but this can now be written .T.conj() which is not > > bad so does not get a new attribute. > > I didn't have strong feelings one way or another on this, so I didn't > vote, but at this point I'd like to make a comment before the freeze. > Given that .T went in, I'd argue that .H should be in as well. > Basically, I now think these two should have been considered as a > bundle and not as separate options. +1. H is just the complex counterpart of T. Chuck |
From: Keith G. <kwg...@gm...> - 2006-07-10 18:30:13
|
On 7/7/06, Travis Oliphant <oli...@ee...> wrote: > a numpy.matlib module was started to store matrix versions of the > standard array-creation functions and mat was re-labeled to "asmatrix" > so that a copy is not made by default. Holy crap! It works. This is great. Thank you. >> import numpy.matlib >> numpy.__version__ '0.9.9.2788' >> from numpy.matlib import * >> rand(2,2) matrix([[ 0.23834437, 0.60329722], <--- matrix by default [ 0.03907811, 0.55134035]]) >> ones((2,2)) matrix([[ 1., 1.], <--- matrix by default [ 1., 1.]]) >> numpy.matlib. numpy.matlib.N numpy.matlib.__name__ numpy.matlib.eye numpy.matlib.__all__ numpy.matlib.__new__ numpy.matlib.identity numpy.matlib.__class__ numpy.matlib.__reduce__ numpy.matlib.matrix numpy.matlib.__delattr__ numpy.matlib.__reduce_ex__ numpy.matlib.ndarray numpy.matlib.__dict__ numpy.matlib.__repr__ numpy.matlib.ones numpy.matlib.__doc__ numpy.matlib.__setattr__ numpy.matlib.rand numpy.matlib.__file__ numpy.matlib.__str__ numpy.matlib.randn numpy.matlib.__getattribute__ numpy.matlib.array numpy.matlib.zeros numpy.matlib.__hash__ numpy.matlib.asmatrix numpy.matlib.__init__ numpy.matlib.empty |