Re: [Numpy-discussion] How to speed up this function?

2006-12-05 Thread Nadav Horesh
You can speed it up easily by avoiding the loop. The main idea is to replace the indexing of the type [i+1,j], [i-1,j], [i,j+1], [i,j-1] by the appropriate slicing. For example for i in xrange(1,n): for j in xrange(1,m) a[i,j] = b[i-1,j] + c[i,j+1] can be replaced by a[1:,:-1] = b[:-1] +

Re: [Numpy-discussion] Precision in Python

2006-12-05 Thread Nadav Horesh
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Elton Mendes Sent: Monday, November 27, 2006 13:57 To: numpy-discussion@scipy.org Subject: [Numpy-discussion] Precision in Python Hi. I'm having a precision problem in python Example: >>> a = 5.14

Re: [Numpy-discussion] dot operations on multidimensional arrays

2006-12-05 Thread Nadav Horesh
Try numpy.tensordot Nadav -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Carsten Rostgaard Sent: Thursday, November 23, 2006 10:06 To: numpy-discussion@scipy.org Subject: [Numpy-discussion] dot operations on multidimensional arrays Hi! I am trying to us

Re: [Numpy-discussion] take semantics (bug?)

2006-12-05 Thread Robert Kern
Michael McNeil Forbes wrote: > Robert Kern <[EMAIL PROTECTED]> wrote: >> Michael McNeil Forbes wrote: >>> What are the semantics of the "take" function? >>> >>> I would have expected that the following have the same shape and size: >>> >> a = array([1,2,3]) >> inds = a.nonzero() >> a[in

Re: [Numpy-discussion] take semantics (bug?)

2006-12-05 Thread Michael McNeil Forbes
Robert Kern <[EMAIL PROTECTED]> wrote: > Michael McNeil Forbes wrote: > > What are the semantics of the "take" function? > > > > I would have expected that the following have the same shape and size: > > > a = array([1,2,3]) > inds = a.nonzero() > a[inds] > > array([1, 2, 3]) > >>>

[Numpy-discussion] numpy in debian

2006-12-05 Thread Keith Goodman
I'm impressed with how easy it is to compile numpy. I'm even more impressed with how easy it is let someone else compile it and just apt-get it. Does anyone know the numpy plans for debian? It is currently at 1.0rc1. I'm afraid to ask the debian numpy maintainers since they have already done me

[Numpy-discussion] compile scipy by using intel compiler

2006-12-05 Thread Gennan Chen
Hi! All, I have a dual opteron 285 with 8G ram machine. And I ran FC6 x86_64 on that. I did manage to get numpy (from svn) compiled by using icc 9.1.0.45 and mkl 9.0 ( got 3 errors when I ran the est). But no such luck for scipy (from svn). Below is the error: Lib/special/cephes/mconf.h(137): rem

Re: [Numpy-discussion] dot operations on multidimensional arrays

2006-12-05 Thread Johannes Loehnert
Hi, > The question is then: > 1) Is there any way to change the axis for which the product-sum is > performed. This can of course be done by a swapaxis before and after the > operation, but this makes the array non-contiguous, in which case the > dot operation often makes bugs (at least in Numeric

Re: [Numpy-discussion] Numpy and Python 2.2 on RHEL3

2006-12-05 Thread Robert Kern
David Bogen wrote: > All: > > Is it possible to build Numpy using Python 2.2? I haven't been able to > find anything that explicitly lists the versions of Python with which > Numpy functions so I've been working under the assumption that the two > bits will mesh together somehow. numpy requires

Re: [Numpy-discussion] Precision in Python

2006-12-05 Thread Charles R Harris
On 11/27/06, Elton Mendes <[EMAIL PROTECTED]> wrote: Hi. I'm having a precision problem in python Example: >>> a = 5.14343434 >>> b = round(a,1) >>> b 5.0996 >>> It´s possible to round the number exactly to 5.1 Short answer, no. The number 5.1 can't be exactly represented as a

Re: [Numpy-discussion] How to speed up this function?

2006-12-05 Thread Charles R Harris
On 12/5/06, Charles R Harris <[EMAIL PROTECTED]> wrote: On 12/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello, > > I'm taking a CFD class, one of the codes I wrote runs very slow. When I > look at hotshot is says the function below is the problem. Since this is an > explicit step,

Re: [Numpy-discussion] How to speed up this function?

2006-12-05 Thread Brent Pedersen
it looks like you could use weave.blitz() without much change to your code. or weave.inline() if needed. see this page: http://scipy.org/PerformancePython On 12/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hello, I'm taking a CFD class, one of the codes I wrote runs very slow. When I loo

Re: [Numpy-discussion] How to speed up this function?

2006-12-05 Thread Charles R Harris
On 12/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hello, I'm taking a CFD class, one of the codes I wrote runs very slow. When I look at hotshot is says the function below is the problem. Since this is an explicit step, the for loops are only traversed once, so I think it's caused by mem

Re: [Numpy-discussion] Precision in Python

2006-12-05 Thread Tim Hochberg
Elton Mendes wrote: > Hi. > I'm having a precision problem in python > > Example: > > > >>> a = 5.14343434 > >>> b = round(a,1) > >>> b > 5.0996 > >>> > > It´s possible to round the number exactly to 5.1 Read this: http://www.python.org/infogami-faq/general/why-are-floating-point-calc

Re: [Numpy-discussion] How to speed up this function?

2006-12-05 Thread Tim Hochberg
[EMAIL PROTECTED] wrote: > Hello, > > I'm taking a CFD class, one of the codes I wrote runs very slow. When I look > at hotshot is says the function below is the problem. Since this is an > explicit step, the for loops are only traversed once, so I think it's caused > by memory usage, but I'm no

Re: [Numpy-discussion] dot operations on multidimensional arrays

2006-12-05 Thread Charles R Harris
On 11/23/06, Carsten Rostgaard <[EMAIL PROTECTED]> wrote: Hi! I am trying to use the "dot" method on multi-(more than 2)-dimensional arrays. Specifically I do >> y = dot(a, b) where a is a 2D array and b is a 3D array. using numpy I get the the help: " dot(...) dot(a,v) returns matrix-

[Numpy-discussion] ValueError: dimensions too large.

2006-12-05 Thread koara
Hello, i tried to create a 2d array, but encountered: ValueError: dimensions too large. Does this refer to insufficient memory, or is there really a limit on dimension sizes? Cheers. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http:

Re: [Numpy-discussion] problems installing NumPy on OSX

2006-12-05 Thread Travis Oliphant
> It seems running from the source dir has been the main problem all > along. It works fine outside (I guess). > > I get one error in the test Steve recommends though. But hey, 519 out > of 520 ain't so bad, is it? > Don't worry about the failing test. It's a bad test on your platform.

[Numpy-discussion] How to speed up this function?

2006-12-05 Thread fsenkel
Hello, I'm taking a CFD class, one of the codes I wrote runs very slow. When I look at hotshot is says the function below is the problem. Since this is an explicit step, the for loops are only traversed once, so I think it's caused by memory usage, but I'm not sure if it's the local variables o

Re: [Numpy-discussion] seting the dtype for where...

2006-12-05 Thread Travis Oliphant
Chris Barker wrote: > Hi all, > > I'd like to set the data type for what numpy.where creates. For example: > > import numpy as N > > N.where(a >= 5, 5, 0) > > creates an integer array, which makes sense. > > N.where(a >= 5, 5.0, 0) > > creates a float64 array, which also makes sense, but I'd like a

Re: [Numpy-discussion] Wanted: Numeric/NumPy compatible array creation expression

2006-12-05 Thread Travis Oliphant
[EMAIL PROTECTED] wrote: > I am looking for a way to create an array of the same type as another > given array (but of different shape) that works both with Numeric and > NumPy without being unreasonably slow. In other words, I am looking > for a a replacement for the expression > > arr

[Numpy-discussion] Precision in Python

2006-12-05 Thread Elton Mendes
Hi. I'm having a precision problem in python Example: a = 5.14343434 b = round(a,1) b 5.0996 It´s possible to round the number exactly to 5.1 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mail

[Numpy-discussion] Strange numpy behaviour with pickle

2006-12-05 Thread Jerome Fuselier
Hello,  I've discovered a small problem when I tried to save a numpy array with the pickle module. The dumped array is not always equal to the loaded one and the error is not always here, depending on the way I express matrix operations. I illustrated the error with a small script attached w

[Numpy-discussion] dot operations on multidimensional arrays

2006-12-05 Thread Carsten Rostgaard
Hi! I am trying to use the "dot" method on multi-(more than 2)-dimensional arrays. Specifically I do >> y = dot(a, b) where a is a 2D array and b is a 3D array. using numpy I get the the help: " dot(...) dot(a,v) returns matrix-multiplication between a and b. The product-sum is over t

Re: [Numpy-discussion] Numpy and Python 2.2 on RHEL3

2006-12-05 Thread David Bogen
Bill Spotz wrote: > > you might try > > from __future__ import generators > Some research did turn up that alternative, but then I started getting this error: $ /usr/bin/python2.2 setup.py build Running from numpy source directory. Traceback (most recent call last): File "setup.py", line

Re: [Numpy-discussion] Numpy and Python 2.2 on RHEL3

2006-12-05 Thread Bill Spotz
From http://docs.python.org/ref/yield.html you might try from __future__ import generators On Dec 5, 2006, at 9:07 AM, David Bogen wrote: > All: > > Is it possible to build Numpy using Python 2.2? I haven't been > able to > find anything that explicitly lists the versions of Pytho

[Numpy-discussion] Numpy and Python 2.2 on RHEL3

2006-12-05 Thread David Bogen
All: Is it possible to build Numpy using Python 2.2? I haven't been able to find anything that explicitly lists the versions of Python with which Numpy functions so I've been working under the assumption that the two bits will mesh together somehow. When I try to build Numpy 1.0.1 on RedHat Ente