Re: [Numpy-discussion] Python function for line intersection??

2013-10-10 Thread Stéfan van der Walt
On Tue, Oct 8, 2013 at 3:15 PM, Happyman wrote: > # slope of each line > m = (B[:, 1] - A[:, 1]) / (B[:, 0] - A[:, 0]) > b = A[:, 1] - m * A[:, 0] Calculating the slope of a line leads to difficulties, e.g. when dealing with vertical lines. Rather, parameterize lines as shown here:

Re: [Numpy-discussion] Bug in numpy.correlate documentation

2013-10-10 Thread Julian Taylor
On 10.10.2013 21:31, Bernhard Spinnler wrote: > > On 10.10.2013, at 19:27, David Goldsmith > wrote: >> >> On Wed, Oct 9, 2013 at 7:48 PM, Bernhard Spinnler >> mailto:bernhard.spinn...@gmx.net>> wrote: >> > Hi Richard, >> > >> > Ah, I searched th

Re: [Numpy-discussion] Bug in numpy.correlate documentation

2013-10-10 Thread Bernhard Spinnler
On 10.10.2013, at 19:27, David Goldsmith wrote: > On Wed, Oct 9, 2013 at 7:48 PM, Bernhard Spinnler > wrote: > > Hi Richard, > > > > Ah, I searched the list but didn't find those posts before? > > > > I can easily imagine that correlation is defined differently in different > > disciplines. Both

Re: [Numpy-discussion] Bug in numpy.correlate documentation

2013-10-10 Thread Bernhard Spinnler
It seems to me that Wolfram is following yet another path. From http://mathworld.wolfram.com/Autocorrelation.html and more importantly http://mathworld.wolfram.com/Cross-Correlation.html, equation (5): z_mathworld[k] = sum_n conj(a[n]) * v[n+k] = conj( sum_n a[n] * conj(v[n+k]) )

Re: [Numpy-discussion] Bug in numpy.correlate documentation

2013-10-10 Thread David Goldsmith
Date: Wed, 9 Oct 2013 21:54:07 +0100 > From: Nathaniel Smith > Subject: Re: [Numpy-discussion] Bug in numpy.correlate documentation > To: Discussion of Numerical Python > Message-ID: > z8v-ahuu+85lz88xywmawxgzhk5ghtfuw8h...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > O

Re: [Numpy-discussion] Efficient square distance computation

2013-10-10 Thread Ke Sun
> > > On a machine I had access to it took about 20 minutes. > > How? I am using matrix multiplication (the same code as > > http://stackoverflow.com/a/4856692) and it runs for around 18 hours. > > > > > make sure you are using an optimized BLAS library. > e.g. with openblas I could also do this si

Re: [Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Andreas Hilboll
On 10.10.2013 15:07, Joe Kington wrote: > You just need to supply the "offset" kwarg to "memmap". > > for example: > > with open(localfile, "r") as fd: > # read offset from first line of file > offset = int(next(fd).split()[-2]) > np.memmap(fd, dtype="float32", mode="r", offset=offset) > >

Re: [Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Andreas Hilboll
On 10.10.2013 14:57, Julian Taylor wrote: > you have to use the offset keyword argument of np.memmap, else it will > always start from the beginning of the file > np.memmap(fd, dtype="float32", mode="r", offset=offset) Thanks for that! I just proposed an update to the memmap docstring to bet

Re: [Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Joe Kington
You just need to supply the "offset" kwarg to "memmap". for example: with open(localfile, "r") as fd: # read offset from first line of file offset = int(next(fd).split()[-2]) np.memmap(fd, dtype="float32", mode="r", offset=offset) Also, there's no need to do things like "offset = int(fd.re

Re: [Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Julian Taylor
you have to use the offset keyword argument of np.memmap, else it will always start from the beginning of the file >>> np.memmap(fd, dtype="float32", mode="r", offset=offset) On Thu, Oct 10, 2013 at 2:43 PM, Andreas Hilboll wrote: > Hi, > > I have a problem using memmap correctly. I need to re

[Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Andreas Hilboll
Hi, I have a problem using memmap correctly. I need to read a data file which consists of an ASCII header and appended binary single precision floating point values. memmap complains that the "Size of available data is not a multiple of the data-type size." But as far as I can tell, the size *doas