Re: [Numpy-discussion] Matrix multiplication infix operator PEP nearly ready to go

2014-03-12 Thread Nathaniel Smith
On Thu, Mar 13, 2014 at 1:03 AM, Alan G Isaac wrote: > On 3/12/2014 6:04 PM, Nathaniel Smith wrote: >>https://github.com/numpy/numpy/pull/4351 > > The Semantics section still begins with 0d, then 2d, then 1d, then nd. > Given the context of the proposal, the order should be: > > 2d (the core n

Re: [Numpy-discussion] Matrix multiplication infix operator PEP nearly ready to go

2014-03-12 Thread Alan G Isaac
On 3/12/2014 6:04 PM, Nathaniel Smith wrote: >https://github.com/numpy/numpy/pull/4351 The Semantics section still begins with 0d, then 2d, then 1d, then nd. Given the context of the proposal, the order should be: 2d (the core need expressed in the proposal) nd (which generalizes via broadca

[Numpy-discussion] Matrix multiplication infix operator PEP nearly ready to go

2014-03-12 Thread Nathaniel Smith
Hi all, The proposal to add an infix operator to Python for matrix multiplication is nearly ready for its debut on python-ideas; so if you want to look it over first, just want to check out where it's gone, then now's a good time: https://github.com/numpy/numpy/pull/4351 The basic idea here is

Re: [Numpy-discussion] matrix multiplication

2009-06-06 Thread Gael Varoquaux
On Fri, Jun 05, 2009 at 06:02:09PM -0400, Alan G Isaac wrote: > I think something close to this would be possible: > add dot as an array method. > A .dot(B) .dot(C) > is not as pretty as > A * B * C > but it is much better than > np.dot(np.dot(A,B),C) > In fact it is so much bett

Re: [Numpy-discussion] matrix multiplication

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 5:19 PM, Christopher Barker wrote: > Robert Kern wrote: > x = np.array([1,2,3]) > timeit x.sum() >>> 10 loops, best of 3: 3.01 µs per loop > from numpy import sum > timeit sum(x) >>> 10 loops, best of 3: 4.84 µs per loop > > that is a VERY short array

Re: [Numpy-discussion] matrix multiplication

2009-06-05 Thread Christopher Barker
Robert Kern wrote: x = np.array([1,2,3]) timeit x.sum() >> 10 loops, best of 3: 3.01 µs per loop from numpy import sum timeit sum(x) >> 10 loops, best of 3: 4.84 µs per loop that is a VERY short array, so one extra function call overhead could make the difference. Is i

Re: [Numpy-discussion] matrix multiplication

2009-06-05 Thread Robert Kern
On Fri, Jun 5, 2009 at 17:54, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 3:02 PM, Alan G Isaac wrote: >> I think something close to this would be possible: >> add dot as an array method. >>        A .dot(B) .dot(C) >> is not as pretty as >>        A * B * C >> but it is much better than >>    

Re: [Numpy-discussion] matrix multiplication

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 3:02 PM, Alan G Isaac wrote: > I think something close to this would be possible: > add dot as an array method. >        A .dot(B) .dot(C) > is not as pretty as >        A * B * C > but it is much better than >        np.dot(np.dot(A,B),C) I've noticed that x.sum() is faste

Re: [Numpy-discussion] matrix multiplication

2009-06-05 Thread Charles R Harris
On Fri, Jun 5, 2009 at 4:02 PM, Alan G Isaac wrote: > On 6/5/2009 5:41 PM Chris Colbert apparently wrote: > > well, it sounded like a good idea. > > > I think something close to this would be possible: > add dot as an array method. >A .dot(B) .dot(C) > is not as pretty as >A * B *

Re: [Numpy-discussion] matrix multiplication

2009-06-05 Thread Matthew Brett
> I think something close to this would be possible: > add dot as an array method. >        A .dot(B) .dot(C) > is not as pretty as >        A * B * C > but it is much better than >        np.dot(np.dot(A,B),C) That is much better. Matthew ___ Numpy-dis

Re: [Numpy-discussion] matrix multiplication

2009-06-05 Thread Alan G Isaac
On 6/5/2009 5:41 PM Chris Colbert apparently wrote: > well, it sounded like a good idea. I think something close to this would be possible: add dot as an array method. A .dot(B) .dot(C) is not as pretty as A * B * C but it is much better than np.dot(np.dot(A,B),C) In fact

Re: [Numpy-discussion] matrix multiplication A x, x has some zeros

2007-12-14 Thread Alan G Isaac
>> idx=N.ravel(x)!=0 >> A[:,idx]*x[idx] On Fri, 14 Dec 2007, dmitrey apparently wrote: > I expect being vector of length n A and x change > every iter. A is not sparse. Still, whenever x has a lot of zeros, this should have a substantial payoff. That seems the only exploitable information yo

Re: [Numpy-discussion] matrix multiplication A x, x has some zeros

2007-12-14 Thread dmitrey
Thank you for the tip, however, I expect being vector of length n A and x change every iter. A is not sparse. Alan G Isaac wrote: > On Fri, 14 Dec 2007, dmitrey apparently wrote: > >> I guess it doesn't matter, but typical n are 1...1000. >> However, I need to call the operation hundreds or t

Re: [Numpy-discussion] matrix multiplication A x, x has some zeros

2007-12-14 Thread Bruce Southey
Hi, How sparse are A, x and Ax? You probably will not find any time or operation efficiency unless A and x are relatively sparse. With the small size of n, any efficiency will typically be small in any case. As you indicate that this has to be repeated multiple times, perhaps you should look at y

Re: [Numpy-discussion] matrix multiplication A x, x has some zeros

2007-12-14 Thread Alan G Isaac
On Fri, 14 Dec 2007, dmitrey apparently wrote: > I guess it doesn't matter, but typical n are 1...1000. > However, I need to call the operation hundreds or thousands times (while > running NLP solver ralg, so 4..5 * nIter times). > Number of zeros can be 0...n-1 Do both A and x change every it

Re: [Numpy-discussion] matrix multiplication A x, x has some zeros

2007-12-14 Thread dmitrey
I guess it doesn't matter, but typical n are 1...1000. However, I need to call the operation hundreds or thousands times (while running NLP solver ralg, so 4..5 * nIter times). Number of zeros can be 0...n-1 Charles R Harris wrote: > How big is n? > > On Dec 14, 2007 1:24 AM, dmitrey <[EMAIL PROT

Re: [Numpy-discussion] matrix multiplication A x, x has some zeros

2007-12-14 Thread Charles R Harris
How big is n? On Dec 14, 2007 1:24 AM, dmitrey <[EMAIL PROTECTED]> wrote: > Hi all, > I have to get Ax, A is n x n matrix, x is vector of length n. > Some coords of x are zeros, so I want to economy time/cputime somehow > w/o connecting sparse module from scipy. > What's the easiest way to do so

[Numpy-discussion] matrix multiplication A x, x has some zeros

2007-12-14 Thread dmitrey
Hi all, I have to get Ax, A is n x n matrix, x is vector of length n. Some coords of x are zeros, so I want to economy time/cputime somehow w/o connecting sparse module from scipy. What's the easiest way to do so? Thx, D. ___ Numpy-discussion mailing l