Re: [Numpy-discussion] matrix default to column vector?

2009-06-05 Thread Charles R Harris
On Fri, Jun 5, 2009 at 11:30 AM, Alan G Isaac wrote: > On 6/5/2009 11:38 AM Olivier Verdier apparently wrote: > > I think matrices can be pretty tricky when used for > > teaching. For instance, you have to explain that all the > > operators work component-wise, except the multiplication! > > Ano

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 5:59 PM, Brent Pedersen wrote: > On Fri, Jun 5, 2009 at 2:01 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >>> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: > On Fri, J

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] IndexExpression bug?

2009-06-05 Thread Robert Kern
On Fri, Jun 5, 2009 at 16:14, Michael McNeil Forbes wrote: >  >>> np.array([0,1,2,3])[1:-1] > array([1, 2]) > > but > >  >>> np.array([0,1,2,3])[np.s_[1:-1]] > array([1, 2, 3]) >  >>> np.array([0,1,2,3])[np.index_exp[1:-1]] > array([1, 2, 3]) > > Possible fix: > class IndexExpression(object): >  

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] vectorizing

2009-06-05 Thread Brent Pedersen
On Fri, Jun 5, 2009 at 2:01 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 12:53 PM,   wrote: > On Fri, Jun 5, 2009 at

Re: [Numpy-discussion] Maturing the Matrix class in NumPy

2009-06-05 Thread Chris Colbert
well, it sounded like a good idea. Oh, well. On Fri, Jun 5, 2009 at 5:28 PM, Robert Kern wrote: > On Fri, Jun 5, 2009 at 16:24, Chris Colbert wrote: > > How about just introducing a slightly different syntax which tells numpy > to > > handle the array like a matrix: > > > > Some thing along

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread Chris Colbert
I'll caution anyone from using Atlas from the repos in Ubuntu 9.04 as the package is broken: https://bugs.launchpad.net/ubuntu/+source/atlas/+bug/363510 just build Atlas yourself, you get better performance AND threading. Building it is not the nightmare it sounds like. I think i've done it a t

[Numpy-discussion] IndexExpression bug?

2009-06-05 Thread Michael McNeil Forbes
>>> np.array([0,1,2,3])[1:-1] array([1, 2]) but >>> np.array([0,1,2,3])[np.s_[1:-1]] array([1, 2, 3]) >>> np.array([0,1,2,3])[np.index_exp[1:-1]] array([1, 2, 3]) Possible fix: class IndexExpression(object): ... def __len__(self): return 0 (Presently this returns sys.maxin

Re: [Numpy-discussion] Maturing the Matrix class in NumPy

2009-06-05 Thread Robert Kern
On Fri, Jun 5, 2009 at 16:24, Chris Colbert wrote: > How about just introducing a slightly different syntax which tells numpy to > handle the array like a matrix: > > Some thing along the lines of this: > > A = array[[..]] > B = array[[..]] > > elementwise multipication (as it currently is): > > C

Re: [Numpy-discussion] Maturing the Matrix class in NumPy

2009-06-05 Thread Chris Colbert
How about just introducing a slightly different syntax which tells numpy to handle the array like a matrix: Some thing along the lines of this: A = array[[..]] B = array[[..]] elementwise multipication (as it currently is): C = A * B matrix multiplication: C = {A} * {B} or C = [A] * [B] or

Re: [Numpy-discussion] Maturing the Matrix class in NumPy

2009-06-05 Thread Alan G Isaac
On 6/5/2009 3:49 PM Stéfan van der Walt apparently wrote: > If the Matrix class is to remain, we need to take the steps > necessary to integrate it into NumPy properly. I think this requires a list of current problems. Many of the problems for NumPy have been addressed over time. I believe the rem

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: > On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 12:53 PM,   wrote: On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: > Hello, > I have a v

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 4:35 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:31 PM,   wrote: >> On Fri, Jun 5, 2009 at 4:27 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 1:31 PM, wrote: > On Fri, Jun 5, 2009 at 4:27 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >>> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Brent Pedersen
On Fri, Jun 5, 2009 at 1:27 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 12:53 PM,   wrote: > On Fri, Jun 5, 2009 at

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 4:27 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 12:53 PM,   wrote: > On Fri, Jun 5, 2009 a

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: > On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 12:53 PM,   wrote: On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: > Hello, > I have a v

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Brent Pedersen
On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 12:53 PM,   wrote: >>> On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: Hello, I have a vectorizing problem that I don't see an obvious way to solve.  

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 12:53 PM,   wrote: >> On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: >>> Hello, >>> I have a vectorizing problem that I don't see an obvious way to solve.  What >>> I have is a vector like: >>> obs=array([1,2,3,4,3,

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 3:53 PM, wrote: > On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: >> Hello, >> I have a vectorizing problem that I don't see an obvious way to solve.  What >> I have is a vector like: >> obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) >> and a matrix >> T=zeros((6,6)) >> and

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 12:53 PM, wrote: > On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: >> Hello, >> I have a vectorizing problem that I don't see an obvious way to solve.  What >> I have is a vector like: >> obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) >> and a matrix >> T=zeros((6,6)) >> an

[Numpy-discussion] Maturing the Matrix class in NumPy

2009-06-05 Thread Stéfan van der Walt
Hi Alan 2009/6/5 Alan G Isaac : > You should take it very seriously when someone > reports to you that the matrix object is a crucial to them, > e.g., as a teaching tool.  Even if you do not find > personally persuasive an example like > http://mail.scipy.org/pipermail/numpy-discussion/2009-June/0

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: > Hello, > I have a vectorizing problem that I don't see an obvious way to solve.  What > I have is a vector like: > obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) > and a matrix > T=zeros((6,6)) > and what I want in T is a count of all of the transit

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 11:07 AM, Brian Blais wrote: > Hello, > I have a vectorizing problem that I don't see an obvious way to solve.  What > I have is a vector like: > obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) > and a matrix > T=zeros((6,6)) > and what I want in T is a count of all of the transi

[Numpy-discussion] vectorizing

2009-06-05 Thread Brian Blais
Hello, I have a vectorizing problem that I don't see an obvious way to solve. What I have is a vector like: obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) and a matrix T=zeros((6,6)) and what I want in T is a count of all of the transitions in obs, e.g. T[1,2]=3 because the sequence 1-2 hap

Re: [Numpy-discussion] matrix default to column vector?

2009-06-05 Thread Jason Rennie
As someone who is very used to thinking in terms of matrices and who just went through the adjustment of translating matlab-like code to numpy, I found the current matrix module to be confusing. It's poor integration with the rest of numpy/scipy (in particular, scipy.optimize.fmin_cg) made it more

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread Matthieu Brucher
2009/6/5 David Cournapeau : > Eric Firing wrote: >> >> David, >> >> The eigen web site indicates that eigen achieves high performance >> without all the compilation difficulty of atlas.  Does eigen have enough >> functionality to replace atlas in numpy? > > No, eigen does not provide a (complete) B

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread David Cournapeau
Eric Firing wrote: > > David, > > The eigen web site indicates that eigen achieves high performance > without all the compilation difficulty of atlas. Does eigen have enough > functionality to replace atlas in numpy? No, eigen does not provide a (complete) BLAS/LAPACK interface. I don't know if

Re: [Numpy-discussion] matrix default to column vector?

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 1:33 PM, Geoffrey Ely wrote: > On Jun 5, 2009, at 10:18 AM, josef.p...@gmail.com wrote: >> I'm only using arrays for consistency, but my econometrics code is >> filled with arr[np.newaxis,:] . > > > arr[None,:] is a lot cleaner in my opinion, especially when using > "numpy"

Re: [Numpy-discussion] matrix default to column vector?

2009-06-05 Thread Geoffrey Ely
On Jun 5, 2009, at 10:18 AM, josef.p...@gmail.com wrote: > I'm only using arrays for consistency, but my econometrics code is > filled with arr[np.newaxis,:] . arr[None,:] is a lot cleaner in my opinion, especially when using "numpy" as the namespace. -Geoff ___

Re: [Numpy-discussion] matrix default to column vector?

2009-06-05 Thread Alan G Isaac
On 6/5/2009 11:38 AM Olivier Verdier apparently wrote: > I think matrices can be pretty tricky when used for > teaching. For instance, you have to explain that all the > operators work component-wise, except the multiplication! > Another caveat is that since matrices are always 2x2, the > "sca

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread Eric Firing
David Cournapeau wrote: > > It really depends on the CPU, compiler, how atlas was compiled, etc... > it can be slightly faster to 10 times faster (if you use a very poorly > optimized ATLAS). > > For some recent benchmarks: > > http://eigen.tuxfamily.org/index.php?title=Benchmark > David, Th

Re: [Numpy-discussion] matrix default to column vector?

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 11:38 AM, Olivier Verdier wrote: > I agree. It would be a good idea to have matrices out of numpy as a > standalone package. > Indeed, having matrices in the numpy core comes at a pedagogical cost. > Newcomers (as I once was) do not know which to use. Matrix or array? It > t

Re: [Numpy-discussion] Import fails of scipy.factorial wheninstalled as a zipped egg

2009-06-05 Thread Fadhley Salim
> I don't think numpy/scipy are zip safe, the numpy packageloader uses os.path to find files. Evidently! :-) But the strange thing is that all this worked fine with Scipy 0.6.0 - it's only since 0.7.0 was released that this started going wrong. Sal Disclaimer CALYON UK: This email does not cre

Re: [Numpy-discussion] matrix default to column vector?

2009-06-05 Thread Olivier Verdier
I agree. It would be a good idea to have matrices out of numpy as a standalone package. Indeed, having matrices in the numpy core comes at a pedagogical cost. Newcomers (as I once was) do not know which to use. Matrix or array? It turns out that the vast majority of numpy/scipy modules use arrays,

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread David Paul Reichert
Hi, Thanks for the suggestion. Unfortunately I'm using university managed machines here, so I have no control over the distribution, not even root access. However, I just downloaded the latest Enthought distribution, which uses numpy 1.3, and now numpy is only 30% to 60% slower than matlab, inst

Re: [Numpy-discussion] Import fails of scipy.factorial when installed as a zipped egg

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 9:25 AM, Fadhley Salim wrote: > I've noticed that with scipy 0.7.0 + numpy 1.2.1, an importing the factorial > function from the scipy module always seems to fail when scipy is installed > as a zipped ",egg" file. When the project is installed as an unzipped > directory it w

[Numpy-discussion] Import fails of scipy.factorial when installed as a zipped egg

2009-06-05 Thread Fadhley Salim
I've noticed that with scipy 0.7.0 + numpy 1.2.1, an importing the factorial function from the scipy module always seems to fail when scipy is installed as a zipped ",egg" file. When the project is installed as an unzipped directory it works fine. Is there any reason why this function should not

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread Jason Rennie
Hi David, Let me suggest that you try the latest version of Ubuntu (9.04/Jaunty), which was released two months ago. It sounds like you are effectively using release 5 of RedHat Linux which was originally released May 2007. There have been updates (5.1, 5.2, 5.3), but, if my memory serves me cor

[Numpy-discussion] scipy 0.7.1rc2 released

2009-06-05 Thread David Cournapeau
Hi, The RC2 for 0.7.1 scipy release has just been tagged. This is a bug-fixes only release, see below for the release notes. More information can also be found on the trac website: http://projects.scipy.org/scipy/milestone/0.7.1 The only code change compared to the RC1 is one fix which is ess

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread David Cournapeau
Sebastian Walter wrote: > On Fri, Jun 5, 2009 at 11:58 AM, David > Cournapeau wrote: > >> Sebastian Walter wrote: >> >>> On Thu, Jun 4, 2009 at 10:56 PM, Chris Colbert wrote: >>> >>> I should update after reading the thread Sebastian linked: The current 1.3 version of

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread Sebastian Walter
On Fri, Jun 5, 2009 at 11:58 AM, David Cournapeau wrote: > Sebastian Walter wrote: >> On Thu, Jun 4, 2009 at 10:56 PM, Chris Colbert wrote: >> >>> I should update after reading the thread Sebastian linked: >>> >>> The current 1.3 version of numpy (don't know about previous versions) uses >>> the op

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread David Cournapeau
Sebastian Walter wrote: > On Thu, Jun 4, 2009 at 10:56 PM, Chris Colbert wrote: > >> I should update after reading the thread Sebastian linked: >> >> The current 1.3 version of numpy (don't know about previous versions) uses >> the optimized Atlas BLAS routines for numpy.dot() if numpy was compi

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread Sebastian Walter
On Thu, Jun 4, 2009 at 10:56 PM, Chris Colbert wrote: > I should update after reading the thread Sebastian linked: > > The current 1.3 version of numpy (don't know about previous versions) uses > the optimized Atlas BLAS routines for numpy.dot() if numpy was compiled with > these libraries. I've ve

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-06-05 Thread David Paul Reichert
Thanks for the replies so far. I had already tested using an already transposed matrix in the loop, it didn't make any difference. Oh and btw, I'm on (Scientific) Linux. I used the Enthought distribution, but I guess I'll have to get my hands dirty and try to get that Atlas thing working (I'm not

Re: [Numpy-discussion] extract elements of an array that are contained in another array?

2009-06-05 Thread David Warde-Farley
On 4-Jun-09, at 4:38 PM, Anne Archibald wrote: > It seems to me that this is the basic source of the problem. Perhaps > this can be addressed? I realize maintaining compatibility with the > current behaviour is necessary, so how about a multistage deprecation: > > 1. add a keyword argument to inte