Re: [Numpy-discussion] speeding up the following expression

2011-11-12 Thread Geoffrey Zhu
Hi Warren, On Sat, Nov 12, 2011 at 9:31 AM, Warren Weckesser wrote: > > > On Sat, Nov 12, 2011 at 6:43 AM, wrote: >> >> On Sat, Nov 12, 2011 at 3:36 AM, Geoffrey Zhu wrote: >> > Hi, >> > >> > I am playing with multiple ways to speed up the fo

[Numpy-discussion] speeding up the following expression

2011-11-12 Thread Geoffrey Zhu
Hi, I am playing with multiple ways to speed up the following expression (it is in the inner loop): C[1:(M - 1)]=(a * C[2:] + b * C[1:(M-1)] + c * C[:(M-2)]) where C is an array of about 200-300 elements, M=len(C), a, b, c are scalars. I played with numexpr, but it was way slower than directly

Re: [Numpy-discussion] OT: A Way to Approximate and Compress a 3D Surface

2007-11-23 Thread Geoffrey Zhu
<[EMAIL PROTECTED]> > > Date: > > Tue, 20 Nov 2007 17:13:31 -0500 > > To: > > "Discussion of Numerical Python" > > > > To: > > "Discussion of Numerical Python" > > > > > > On 20/11/2007, Geoffrey Zhu <[EMAIL

[Numpy-discussion] OT: A Way to Approximate and Compress a 3D Surface

2007-11-20 Thread Geoffrey Zhu
Hi Everyone, This is off topic for this mailing list but I don't know where else to ask. I have N tabulated data points { (x_i, y_i, z_i) } that describes a 3D surface. The surface is pretty "smooth." However, the number of data points is too large to be stored and manipulated efficiently. To mak

Re: [Numpy-discussion] Problem with numpy.linalg.eig?

2007-11-13 Thread Geoffrey Zhu
On Nov 13, 2007 2:37 AM, David Cournapeau <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > > > Yes, with the MSI I can always reproduce the problem with > > numpy.test(). It always hangs.With the egg it does not hang. Pointer > > problems are usually random, b

Re: [Numpy-discussion] Problem with numpy.linalg.eig?

2007-11-12 Thread Geoffrey Zhu
On Nov 12, 2007 10:26 PM, David Cournapeau <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > On Nov 12, 2007 12:37 PM, Keith Goodman <[EMAIL PROTECTED]> wrote: > >> On Nov 12, 2007 10:10 AM, Peter Creasey <[EMAIL PROTECTED]> wrote: > >>>

Re: [Numpy-discussion] Problem with numpy.linalg.eig?

2007-11-12 Thread Geoffrey Zhu
On Nov 12, 2007 12:37 PM, Keith Goodman <[EMAIL PROTECTED]> wrote: > > On Nov 12, 2007 10:10 AM, Peter Creasey <[EMAIL PROTECTED]> wrote: > > The following code calling numpy v1.0.4 fails to terminate on my machine, > > which was not the case with v1.0.3.1 > > > > from numpy import arange, floa

Re: [Numpy-discussion] numpy 1.04 numpy.test() hang

2007-11-09 Thread Geoffrey Zhu
On Nov 9, 2007 11:42 AM, Nils Wagner <[EMAIL PROTECTED]> wrote: > On Fri, 9 Nov 2007 11:31:54 -0600 > "Geoffrey Zhu" <[EMAIL PROTECTED]> wrote: > > > Very interesting! If I use the MSI file, numpy.test() > >hangs. If, > >

Re: [Numpy-discussion] numpy 1.04 numpy.test() hang

2007-11-09 Thread Geoffrey Zhu
On Nov 9, 2007 11:45 AM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > Very interesting! If I use the MSI file, numpy.test() hangs. If, > > however, I use the EGG file, it is actually fine. > > > > Can you find the md5sum of these fi

Re: [Numpy-discussion] numpy 1.04 numpy.test() hang

2007-11-09 Thread Geoffrey Zhu
Very interesting! If I use the MSI file, numpy.test() hangs. If, however, I use the EGG file, it is actually fine. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] numpy 1.04 numpy.test() hang

2007-11-09 Thread Geoffrey Zhu
On Nov 9, 2007 10:14 AM, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > > On Nov 8, 2007 10:06 PM, David Cournapeau <[EMAIL PROTECTED]> wrote: > > > > Geoffrey Zhu wrote: > > > On Nov 8, 2007 12:12 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > > >

Re: [Numpy-discussion] numpy 1.04 numpy.test() hang

2007-11-09 Thread Geoffrey Zhu
On Nov 8, 2007 10:06 PM, David Cournapeau <[EMAIL PROTECTED]> wrote: > > Geoffrey Zhu wrote: > > On Nov 8, 2007 12:12 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > > > >> Geoffrey Zhu wrote: > >> > >>> Good morning. > >>

Re: [Numpy-discussion] numpy 1.04 numpy.test() hang

2007-11-08 Thread Geoffrey Zhu
On Nov 8, 2007 12:12 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > > Geoffrey Zhu wrote: > > Good morning. > > > > I just installed the Windows binary of numpy 1.04. When I ran > > numpy.test() in IDLE (the Python shell that comes with Python), the > > pro

[Numpy-discussion] numpy 1.04 numpy.test() hang

2007-11-08 Thread Geoffrey Zhu
Good morning. I just installed the Windows binary of numpy 1.04. When I ran numpy.test() in IDLE (the Python shell that comes with Python), the program hang (or at least is running for half an hour). I am using Windows XP, duel core intel CPU. Does anyone know what is going on? Thanks, Geoffrey

[Numpy-discussion] Bug in piecewise?

2007-10-19 Thread Geoffrey Zhu
Hi All, If I execute the following code, I find that function f() sometimes is called with an empty array. I am not sure why this is necessary. Is this a bug? def f(x): return x**2 return numpy.piecewise(u, abs(u)<1, [f, 0]) Thanks, Geoffrey ___ Num

Re: [Numpy-discussion] Sum of the product of three or more arrays

2007-10-19 Thread Geoffrey Zhu
On 10/18/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > Hi All, > > > > Given three vectors of the same lengths, X, Y, and Z, I am looking for > > an efficient way to calculate the following: > > > > sum(x[i]*y[i]*z[i], for i=

Re: [Numpy-discussion] Sum of the product of three or more arrays

2007-10-18 Thread Geoffrey Zhu
I think I figured out: sum(X*Y*Z). Never mind. On 10/18/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > Hi All, > > Given three vectors of the same lengths, X, Y, and Z, I am looking for > an efficient way to calculate the following: > > sum(x[i]*y[i]*z[i], for i=1..n

[Numpy-discussion] Sum of the product of three or more arrays

2007-10-18 Thread Geoffrey Zhu
Hi All, Given three vectors of the same lengths, X, Y, and Z, I am looking for an efficient way to calculate the following: sum(x[i]*y[i]*z[i], for i=1..n ) I am not sure if there is a vectorized way to do this. Thanks, Geoffrey ___ Numpy-discussion

Re: [Numpy-discussion] "Extended" Outer Product

2007-08-21 Thread Geoffrey Zhu
On 8/21/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > > On 8/21/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > > > > > On 8/20/07, Geoffrey Zhu < [EMAIL PROTECTED]> wrote: > > > Hi Everyone, > > > > > &g

[Numpy-discussion] "Extended" Outer Product

2007-08-20 Thread Geoffrey Zhu
Hi Everyone, I am wondering if there is an "extended" outer product. Take the example in "Guide to Numpy." Instead of doing an multiplication, I want to call a custom function for each pair. >>> print outer([1,2,3],[10,100,1000]) [[ 10 100 1000] [ 20 200 2000] [ 30 300 3000]] So I want: [ [f

Re: [Numpy-discussion] numpy.array does not take generators

2007-08-17 Thread Geoffrey Zhu
On 8/17/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > Hi All, > > > > I want to construct a numpy array based on Python objects. In the > > below code, opts is a list of tuples. > > > > For example, > > > > opts=[ (&#

[Numpy-discussion] numpy.array does not take generators

2007-08-16 Thread Geoffrey Zhu
Hi All, I want to construct a numpy array based on Python objects. In the below code, opts is a list of tuples. For example, opts=[ ('C', 100, 3, 'A'), ('K', 200, 5.4, 'B')] If I use a generator like the following: K=numpy.array(o[2]/1000.0 for o in opts) It does not work. I have to use: nu

Re: [Numpy-discussion] How to implement a 'pivot table?'

2007-07-31 Thread Geoffrey Zhu
Hi Timothy, On 7/31/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > [SNIP] > > > The 'brute-force' way is basically what you suggested -- looping > > through all the records and building a two-way hash-table of the data. > > > > The problem of the brute-force' approach is that it is not taking

Re: [Numpy-discussion] How to implement a 'pivot table?'

2007-07-30 Thread Geoffrey Zhu
Hi Timothy, On 7/30/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > On 7/30/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > > Hi Everyone, > > > > I am wondering what is the best (and fast) way to build a pivot table > > aside from the 'brut

[Numpy-discussion] How to implement a 'pivot table?'

2007-07-30 Thread Geoffrey Zhu
Hi Everyone, I am wondering what is the best (and fast) way to build a pivot table aside from the 'brute force way?' I want to transform an numpy array into a pivot table. For example, if I have a numpy array like below: Region Date # of Units -------

Re: [Numpy-discussion] Build external C functions that take numpy arrays as parameters and return numpy arrays

2007-07-29 Thread Geoffrey Zhu
On 7/29/07, Lou Pecora <[EMAIL PROTECTED]> wrote: > I wrote a basic article on C extensions using NumPy > arrays on the SciPy.org site. See: > Cookbook/C_Extensions/NumPy at > > http://www.scipy.org/Cookbook/C_Extensions/NumPy_arrays?highlight=%28%28%28-%2A%29%28%5Cr%29%3F%5Cn%29%28.%2A%29Cate

Re: [Numpy-discussion] Build external C functions that take numpy arrays as parameters and return numpy arrays

2007-07-29 Thread Geoffrey Zhu
Hi Sebastian, > Oooh - I see - there is the date: July 24 ... > [ another email just came in is from 7/18 ...] > That's quite interesting. > I have never seen such a delay before > Was some computer sitting on them being turnted off for 10 days ? ;-) > > -Sebastian. Not knowing that the

Re: [Numpy-discussion] C-extension -- how do I accept a vector of both type double and type int?

2007-07-26 Thread Geoffrey Zhu
On 7/26/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > >>>>> How do I handle this situation? Is there any way to access any data > >>>>> type that can be converted into a double? > >>>> I usually use PyArray_FROM_O

Re: [Numpy-discussion] C-extension -- how do I accept a vector of both type double and type int?

2007-07-26 Thread Geoffrey Zhu
> >>> How do I handle this situation? Is there any way to access any data > >>> type that can be converted into a double? > >> I usually use PyArray_FROM_OTF(). That handles the usual cases. It's > >> pretty much > >> like starting off a pure Python function with asarray(x, dtype=whatever). > >> >

Re: [Numpy-discussion] C-extension -- how do I accept a vector of both type double and type int?

2007-07-26 Thread Geoffrey Zhu
On 7/26/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > Hi Everyone, > > > > I finally build a C extension. The one problem I found is that it is > > too picky about the input. For example, it accepts > > array([1.0,2.0,3.0]) with n

[Numpy-discussion] C-extension -- how do I accept a vector of both type double and type int?

2007-07-26 Thread Geoffrey Zhu
Hi Everyone, I finally build a C extension. The one problem I found is that it is too picky about the input. For example, it accepts array([1.0,2.0,3.0]) with no problem, but when I pass in array([1,2,3]), since the dtype of the array is now int, my extension does not like it. How do I handle thi

[Numpy-discussion] Should I use numpy array?

2007-07-25 Thread Geoffrey Zhu
Hi, I am writing a function that would take a list of datetime objects and a list of single letter characters (such as ["A","B","C"]). The number of items tend to be big and both the list and the numpy array have all the functionalities I need. Do you think I should use numpy arrays or the regula

Re: [Numpy-discussion] Compile extension modules with Visual Studio 2005

2007-07-24 Thread Geoffrey Zhu
Hi Robert, On 7/24/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > Thanks for your help. Do you know what exactly is the issue of having > > to use VS2003 to build extensions? If the interactions are done at DLL > > level, shouldn't call compi

Re: [Numpy-discussion] Compile extension modules with Visual Studio 2005

2007-07-24 Thread Geoffrey Zhu
Hi Robert, On 7/24/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > Hi, > > > > I am about to write a C extension module. C functions in the module will > > take and return numpy arrays. I found a tutorial online, but I am not > > sur

[Numpy-discussion] Compile extension modules with Visual Studio 2005

2007-07-24 Thread Geoffrey Zhu
Hi, I am about to write a C extension module. C functions in the module will take and return numpy arrays. I found a tutorial online, but I am not sure about the following: 1. Can I compile my extension with Visual Studio 2005? My impression is that I will have to link with numpy libraries, and,

Re: [Numpy-discussion] Logical Selector

2007-07-20 Thread Geoffrey Zhu
>Hi, >Well maybe it is a bug on my box (thunderbird) but the topic of the thread is "-lmkl_lapack64 on i368 ??". >Nothing to do with "Logical Selector" ;) Should I post another mail about this topic? >Xavier >ps : I'm just sorry for the noise if it is a bug on my side. >-- Hi Xavier, I di

[Numpy-discussion] Logical Selector

2007-07-18 Thread Geoffrey Zhu
Hi Everyone, I am finding that numpy cannot operate on boolean arrays. For example, the following does not work: x=3Darray([(1,2),(2,1),(3,1),(4,1)]) x[x[:,0]>x[:,1] and x[1:]>1,:] It gives me an syntax error: --- Traceback (most recent call last): File "", line 1, in x[

Re: [Numpy-discussion] How is NumPy implemented?

2007-06-28 Thread Geoffrey Zhu
semantics. I'm sure they are also documented somewhere but I usually find trying many examples helpful. --Tom On 6/28/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > Hi All, > > I am curious how numpy is implemented. Syntax such as x[10::-2] is > completely foreign to Pyt

[Numpy-discussion] How is NumPy implemented?

2007-06-28 Thread Geoffrey Zhu
Hi All, I am curious how numpy is implemented. Syntax such as x[10::-2] is completely foreign to Python. How does numpy get Python to support it? Thanks, Geoffrey PS. Ignore the disclaimer. The mail server automatically insert that. ___=0A= =0

Re: [Numpy-discussion] Numpy and iterative procedures

2007-02-16 Thread Geoffrey Zhu
over i, by replacing [i] by [:-2], [i+1] by [1:-1] and [i+2] by [2:]. But I might be wrong. Can you submit the piece of code with at least the most internal loop? Nadav. -Original Message- From: [EMAIL PROTECTED] on behalf of Geoffrey Zhu Sent: Thu 15-Feb-07 18:32 To: Discussio

Re: [Numpy-discussion] Numpy and iterative procedures

2007-02-16 Thread Geoffrey Zhu
IL PROTECTED] on behalf of Geoffrey Zhu > Sent: Thu 15-Feb-07 18:32 > To: Discussion of Numerical Python > Cc: > Subject: Re: [Numpy-discussion] Numpy and iterative procedures > > Thanks Chuck. > > I am trying to use Successive Over-relaxation to solve linear

[Numpy-discussion] Confusing selector?

2007-02-15 Thread Geoffrey Zhu
I am really new to numpy but I just found that v[2:4] means selecting v[2] and v[3]. V[4] is not included! This is quite different from the conventions of matlab and R. ___=0A= =0A= The information in this email or in any file attached=0A= h

Re: [Numpy-discussion] Numpy and iterative procedures

2007-02-15 Thread Geoffrey Zhu
Numpy-discussion] Numpy and iterative procedures On 2/15/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: Hi, I am new to numpy. I'd like to know if it is possible to code efficient iterative procedures with numpy. Specifically, I have the following problem.

[Numpy-discussion] Numpy and iterative procedures

2007-02-15 Thread Geoffrey Zhu
Hi, I am new to numpy. I'd like to know if it is possible to code efficient iterative procedures with numpy. Specifically, I have the following problem. M is an N*N matrix. Q is a N*1 vector. V is an N*1 vector I am trying to find iteratively from the initial value V_0. The procedure is simply