Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 1:44 PM, Citi, Luca wrote: > Just my 2 cents. > It is duplicated code. > But it is only 3 lines. > "identity" does not need to handle rectangular matrices and non-principal > diagonals, > therefore it can be reasonably faster (especially for small matrices, I > guess). I

Re: [Numpy-discussion] My identity

2009-07-20 Thread Citi, Luca
Just my 2 cents. It is duplicated code. But it is only 3 lines. "identity" does not need to handle rectangular matrices and non-principal diagonals, therefore it can be reasonably faster (especially for small matrices, I guess). ___ NumPy-Discussion mai

Re: [Numpy-discussion] My identity

2009-07-20 Thread David Goldsmith
OK, thanks! (Forgive my being a stickler, but I think it's good to have it in the thread, for posterity.) DG --- On Mon, 7/20/09, Keith Goodman wrote: > From: Keith Goodman > Subject: Re: [Numpy-discussion] My identity > To: "Discussion of Numerical Python" >

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 1:11 PM, David Goldsmith wrote: > > Just to be clear, in which namespace(s) are we talking about making (or > having made) the change: IIUC, the result you're talking about would be > inappropriate for ufunc.identity. np.identity np.matlib.identity ___

Re: [Numpy-discussion] My identity

2009-07-20 Thread David Goldsmith
Just to be clear, in which namespace(s) are we talking about making (or having made) the change: IIUC, the result you're talking about would be inappropriate for ufunc.identity. DG --- On Mon, 7/20/09, Keith Goodman wrote: > From: Keith Goodman > Subject: Re: [Numpy-discussion]

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 10:53 AM, Pauli Virtanen wrote: > On 2009-07-20, Keith Goodman wrote: > [clip] >> Oh, sorry, I misunderstood. Yes, a similar change was made to eye but >> not to identity. > > Nasty, duplicated code there it seems... So def myidentity2(n, dtype=None): return eye(n, M=

Re: [Numpy-discussion] My identity

2009-07-20 Thread Pauli Virtanen
On 2009-07-20, Keith Goodman wrote: [clip] > Oh, sorry, I misunderstood. Yes, a similar change was made to eye but > not to identity. Nasty, duplicated code there it seems... -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 9:32 AM, Keith Goodman wrote: > On Mon, Jul 20, 2009 at 9:03 AM, Charles R > Harris wrote: >> >> >> On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman wrote: >>> >>> Using a trick that Robert Kern recently posted to the list makes the >>> identity function much faster. >>> >>>

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 9:03 AM, Charles R Harris wrote: > > > On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman wrote: >> >> Using a trick that Robert Kern recently posted to the list makes the >> identity function much faster. >> >> Current version: >> >> def identity(n, dtype=None): >>    a = arra

Re: [Numpy-discussion] My identity

2009-07-20 Thread Charles R Harris
On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman wrote: > Using a trick that Robert Kern recently posted to the list makes the > identity function much faster. > > Current version: > > def identity(n, dtype=None): >a = array([1]+n*[0],dtype=dtype) >b = empty((n,n),dtype=dtype) >b.flat =

[Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
Using a trick that Robert Kern recently posted to the list makes the identity function much faster. Current version: def identity(n, dtype=None): a = array([1]+n*[0],dtype=dtype) b = empty((n,n),dtype=dtype) b.flat = a return b Proposed version: def myidentity(n, dtype=None):