With a python background but new to numpy, I have the following.
Suppose I have a 2-D array and I want to apply a function to each element.
The function needs to access the direct neighbouring elements in order
to set a new value for the element. How would I do that in the most
efficient way with
Is it safe to compile numpy with gcc 'strict aliasing'?
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
What you do here is a convolution with
0 1 0
1 1 1
0 1 0
kernel, and thresholding, you can use numpy.numarray.nd_image package:
import numpy.numarray.nd_image as NI
.
.
.
ker = array([[0,1,0], [1,1,1],[0,1,0]])
result = (NI.convolve(self.bufbw, ker) == 1).astype(uint8)
for nore general
On Sat, May 3, 2008 at 5:31 PM, Keith Goodman [EMAIL PROTECTED] wrote:
On Sat, May 3, 2008 at 5:05 PM, Christopher Barker
[EMAIL PROTECTED] wrote:
Robert Kern wrote:
I can get a ~20% improvement with the following:
In [9]: def mycut(x, i):
...: A = x[:i,:i]
...:
On Sun, May 4, 2008 at 7:40 AM, Timothy Hochberg [EMAIL PROTECTED] wrote:
If you don't need the old array after the cut, I think that you could use
the input array as the output array and then take a slice, saving a
temporary and one-quarter of your assignments (on average). Something like.
and then update the others only if the row you're updating has that
minimum value in it. Then, when scanning for the min dist, you only
need to scan O(n) rows.
Sorry, let me clarify -- Update the entries corresponding to entries
in the row you're updating if they are the same as the
On Sun, May 4, 2008 at 8:14 AM, Hoyt Koepke [EMAIL PROTECTED] wrote:
and then update the others only if the row you're updating has that
minimum value in it. Then, when scanning for the min dist, you only
need to scan O(n) rows.
Sorry, let me clarify -- Update the entries
On Fri, May 2, 2008 at 7:25 PM, Robert Kern [EMAIL PROTECTED] wrote:
Assuming x is contiguous and you can modify x in-place:
In [1]: from numpy import *
In [2]: def dist(x):
...:x = x + 1e10 * eye(x.shape[0])
...:i, j = where(x == x.min())
...:return i[0], j[0]
On Sun, May 4, 2008 at 3:11 AM, Neal Becker [EMAIL PROTECTED] wrote:
Is it safe to compile numpy with gcc 'strict aliasing'?
No! And depending on the compiler version you might find whole bits of code
disappearing during optimization without warning, yielding fantastic
benchmarks but
Hi everyone,
We will need to do some more on the network today, Sunday May 4, from
1pm to 3pm Central time. (This is 2pm-4pm Eastern, 6pm-8pm UTC.)
This affects the main Enthought and Scipy.org servers, including SVN,
Trac, the mailing lists, and the web site. As usual, we don't
On Sun, May 4, 2008 at 5:59 PM, Damian R. Eads [EMAIL PROTECTED] wrote:
Hi,
Looks like a fun discussion: it's too bad for me I did not join it
earlier. My first try at scipy-cluster was completely in Python. Like you,
I also tried to find the most efficient way to transform the distance
Keith Goodman wrote:
Why is it so slow to copy data
I think the speed of copying data is highly dependent on what's in
cache, but in any case, much faster than:
create an empty array?
creating a new array requires a memory allocation, which is apparently a
bunch slower than moving data
Charles R Harris wrote:
As far as I can tell, strict aliasing assumes that pointers are only
cast between types of the same length.
Strictly speaking, strict aliasing just says that locations pointed by
pointers do not alias. If you use two pointers of different types,
that's one case
On Mon, May 05, 2008 at 03:17:20AM +0300, Pauli Virtanen wrote:
Some time ago there was discussion about MoinMoin - docstrings
gateway. Did it produce some results?
My girlfriend, Emmanuelle, (Cced, I am not sure she follows this mailing
list) has been working on this, with some progress.
14 matches
Mail list logo