Re: [Numpy-discussion] Some help on matlab to numpy translation

2010-03-15 Thread josef . pktd
On Mon, Mar 15, 2010 at 5:58 PM, Nicolas Rougier wrote: > > > Thanks and in fact, I already wasted quite some time on and your last version > will help me a lot. Unfortunately, I'm not a specialist at lattice Boltzmann > methods at all so I'm not able to answer your questions (my initial idea wa

Re: [Numpy-discussion] Some help on matlab to numpy translation

2010-03-15 Thread Nicolas Rougier
Thanks and in fact, I already wasted quite some time on and your last version will help me a lot. Unfortunately, I'm not a specialist at lattice Boltzmann methods at all so I'm not able to answer your questions (my initial idea was to convert the matlab script to be have a running example to g

Re: [Numpy-discussion] Some help on matlab to numpy translation

2010-03-15 Thread Friedrich Romstedt
Ok, so I send yet another version. Maybe Bruce is right, but I didn't care, because we have fret enough. Now it not only computes something, but also displays something :-( Nicolas, maybe you can now waste some of your time with it? I was curious, both to understand and to get it working, but I

Re: [Numpy-discussion] problem with applying patch

2010-03-15 Thread alex
Pauli Virtanen iki.fi> writes: Thank you. the problem is solved ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] basic numpy array operation

2010-03-15 Thread Robert Kern
On Mon, Mar 15, 2010 at 13:20, gerardo.berbeglia wrote: > > Suppose i have an array A of length n > I want a variable b to be an array consisting of the first k elements of A > and variable c to be an array with the last n-k elements of A. > > How do you do this? > > Example A = np.array([1,2,3,4,

[Numpy-discussion] basic numpy array operation

2010-03-15 Thread gerardo.berbeglia
Suppose i have an array A of length n I want a variable b to be an array consisting of the first k elements of A and variable c to be an array with the last n-k elements of A. How do you do this? Example A = np.array([1,2,3,4,5,6]), k = 2 b = [1,2] c=[3,4,5,6] Thanks. -- View this message in

Re: [Numpy-discussion] Numpi array and typemap

2010-03-15 Thread Bill Spotz
Michel, A couple observations: 1) I don't see anything in your interface file for which numpy.i would be helpful. Is that for something else not shown? 2) When you call PyArray_SimpleNewFromData(), the data buffer pointer argument should be cast to (void*). I am surprised the compiler di

Re: [Numpy-discussion] long integers in genfromtxt

2010-03-15 Thread josef . pktd
On Mon, Mar 15, 2010 at 11:25 AM, Bruce Southey wrote: > On 03/15/2010 11:06 AM, Pierre GM wrote: >> On Mar 13, 2010, at 3:51 PM, josef.p...@gmail.com wrote: >> >>> I was trying to find out what the "helpful" message >>> "TypeError: expected a readable buffer object"  means >>> >>> and it seems ge

Re: [Numpy-discussion] long integers in genfromtxt

2010-03-15 Thread Bruce Southey
On 03/15/2010 11:06 AM, Pierre GM wrote: > On Mar 13, 2010, at 3:51 PM, josef.p...@gmail.com wrote: > >> I was trying to find out what the "helpful" message >> "TypeError: expected a readable buffer object" means >> >> and it seems genfromtxt has problems identifying long integers (at >> least

Re: [Numpy-discussion] long integers in genfromtxt

2010-03-15 Thread Pierre GM
On Mar 13, 2010, at 3:51 PM, josef.p...@gmail.com wrote: > I was trying to find out what the "helpful" message > "TypeError: expected a readable buffer object" means > > and it seems genfromtxt has problems identifying long integers (at > least on Windows 32) > np.array(416068,int) > Tr

[Numpy-discussion] matrix operation.

2010-03-15 Thread gerardo.berbeglia
I have another matrix operations which seems a little more complicated. Let A be an n x n matrix and let S be a subset of {0,...,n-1}. Assume S is represented by a binary vector s, with a 1 at the index i if i is in S. (e.g. if S={0,3} then s = [1,0,0,1]) I re-post the question because the examp

Re: [Numpy-discussion] more complex matrix operation

2010-03-15 Thread josef . pktd
On Mon, Mar 15, 2010 at 9:58 AM, Gerardo Berbeglia wrote: > I have another matrix operations which seems a little more complicated. > > Let A be an n x n matrix and let S be a subset of {0,...,n-1}. Assume > S is represented by a binary vector s, with a 1 at the index i if i is > in S. (e.g. if S=

Re: [Numpy-discussion] more complex matrix operation

2010-03-15 Thread Skipper Seabold
On Mon, Mar 15, 2010 at 10:58 AM, Gerardo Berbeglia wrote: > I have another matrix operations which seems a little more complicated. > > Let A be an n x n matrix and let S be a subset of {0,...,n-1}. Assume > S is represented by a binary vector s, with a 1 at the index i if i is > in S. (e.g. if S

[Numpy-discussion] more complex matrix operation

2010-03-15 Thread Gerardo Berbeglia
I have another matrix operations which seems a little more complicated. Let A be an n x n matrix and let S be a subset of {0,...,n-1}. Assume S is represented by a binary vector s, with a 1 at the index i if i is in S. (e.g. if S={0,3} then s = [1,0,0,1]) I would like to have an efficient way to

Re: [Numpy-discussion] another matrix operation

2010-03-15 Thread josef . pktd
On Mon, Mar 15, 2010 at 9:14 AM, wrote: > On Mon, Mar 15, 2010 at 9:09 AM, Gerardo Berbeglia > wrote: >> I would like to do with numpy the following operation. >> >> Let A be an n x n matrix and let s be an integer between 1 and n. >> >> I would like to have an n x n matrix B = f(A,s) such that

Re: [Numpy-discussion] another matrix operation

2010-03-15 Thread josef . pktd
On Mon, Mar 15, 2010 at 9:09 AM, Gerardo Berbeglia wrote: > I would like to do with numpy the following operation. > > Let A be an n x n matrix and let s be an integer between 1 and n. > > I would like to have an n x n matrix B = f(A,s) such that > > - If we only look at the first s columns of B,

[Numpy-discussion] another matrix operation

2010-03-15 Thread Gerardo Berbeglia
I would like to do with numpy the following operation. Let A be an n x n matrix and let s be an integer between 1 and n. I would like to have an n x n matrix B = f(A,s) such that - If we only look at the first s columns of B, we will not see any difference with respect to the first s columns of

[Numpy-discussion] Numpi array and typemap

2010-03-15 Thread Michel Dupront
Hello, I am trying to do what was suppose to be a very easy exercice. It consists in converting a C++ class Container into a numpy array as show below using typename My problem is that if I make the method getContainer run from python I will get a numpy array as expected by with wrong value