Python/numpy tricky slicing problem -


I have a problem with some oval stuff. I need an oval array to behave abnormally by returning a piece as a view of a chopped data, if not a copy, then I have an example of what I want to do:

We say that there is a simple array like this:

  a = array ([1, 0, 0, 0])  

I With the entry, I would like to update the entries in the array continuously (from left to right), in this way Using the settings:

  a [1:] = a [0: 3]  

This will bring the following result:

  a = array ([1, 1, 1, 1])  

or something like this:

  a [1:] = 2 * A [: 3] # a = [1, 2,4,8]  

To clarify further, I need the following types of behavior:

  For Category (lane (a)): if i == 0 or I + 1 == lane (a): a [i + 1] = a [i]  

Continue, except I want speed of numpy

The numpy's default behavior is to take a copy of the piece, so what exactly do I get:

  a = array ([1, 1, 0, 0 ])  

I already have this array as the subclass of ndarray, so if necessary I can make more changes for this, I just need slices on right hand Because it can be constantly updated as it updates slices to the left hand

Do I dream See or do this magic possible?

Update: This is all because I am trying to use Gauss-Seal, so that a linear algebra problem can be solved, more or less. This is a special case related to harmonic work, I was trying to avoid going into this because it is not really possible to confuse the necessary and potential things, but it goes here.

The algorithm is:

Not collected until: I (lane (u [:, 0]) in the category: (U [0,:]): Leave on #Remember entries, i, j == 0 or lane (u) u [i, j] = 0.25 * (u [i-1, j] + u + 1, J] + [[I, J-1] + U [I, J + 1])

Right? But you can do these two ways, in order to carry it in the loop, without taking into account the updates included in Jacobi without thinking about updating each element with its neighbors, without loop cycles If you copy the array, update an array with the copied array however Gauss-Seedel updates you for each i-1 and j-1 entries already. Went uses information, thus does not require a copy of the loop should be essentially 'know' because each re-evaluate the array after an element update. This means that every time we call an entry like u [i-1, j] or u [i, j-1] then the information computed in the last loop will be there.

I want to change this slow and ugly nested loop position with the use of narrow pieces with a very nice line:

  u [1: -1] , 1: -1] = 0.25 (U [: - 2, 1: -1] + U [2:, 1: -1] + U [1: -1,: - 2] + U [1: -1] , 2:])  

But the result is to walk Jacob because when you take a piece: u [:, - 2,1: -1] You copy the data, this Do not know about any update type piece still numpy still loops correct? This is a quick way of loop that looks like a parallel operation in Python. I want to hacking like samples to exploit this behavior, when I take a piece, then I will return an indicator instead of the copy. right? Then every time the oval ends, this piece has to be 'updated' or whatever actually happened in the update, it has to be repeated. To do this I need slices on either side of the array to be pointers.

Even if there is some really smart person who is very good, but I have given very much permission that I believe the only answer is Loop in C.

The late reply, but it has turned on Google, so I probably do not know the doctor's OP. Your problem is clear: when using NumPy slices, templates are made

Read the weave.blitz section for complete information.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -