[Numpy-discussion] dot product: large speed difference metween seemingly indentical operations

2015-10-17 Thread Nadav Horesh
The functions dot, matmul and tensordot performs the same on a MxN matrix multiplied by length N vector, but very different if the matrix is replaced by a PxQxN array. Why? In [3]: a = rand(100,3) In [4]: a1 = a.reshape(1000,1000,3) In [5]: w = rand(3) In [6]: %timeit a.dot(w) 100 loops,

[Numpy-discussion] dot product by 1*n maxtrix multiply it's transform not equal to raw python dot product?

2014-02-21 Thread Li Li
hi all I am porting some python code to java but got different results. after long time debugging, I found the reason is numpy's result is not the same as java(even the result of raw python codes) one case is: vector:[0.446141, 0.104149996](that's not accurate) it's binary represen

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread josef . pktd
On Fri, Sep 11, 2009 at 5:25 AM, David Cournapeau wrote: > V. Armando Solé wrote: >> David Cournapeau wrote: >> >>> V. Armando Solé wrote: >>> >>> Hello, It seems to point towards a packaging problem. In python 2.5, I can do: import numpy.core._dotblas as dotblas

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread David Cournapeau
V. Armando Solé wrote: > David Cournapeau wrote: > >> V. Armando Solé wrote: >> >> >>> Hello, >>> >>> It seems to point towards a packaging problem. >>> >>> In python 2.5, I can do: >>> >>> import numpy.core._dotblas as dotblas >>> dotblas.__file__ >>> >>> and I get: >>> >>> C:\\Python25

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread V. Armando Solé
David Cournapeau wrote: > V. Armando Solé wrote: > >> Hello, >> >> It seems to point towards a packaging problem. >> >> In python 2.5, I can do: >> >> import numpy.core._dotblas as dotblas >> dotblas.__file__ >> >> and I get: >> >> C:\\Python25\\lib\\site-packages\\numpy\\core\\_dotblas.pyd >>

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread V. Armando Solé
Sturla Molden wrote: > V. Armando Solé skrev: > >> In python 2.6: >> >> >>>import numpy.core._dotblas as dotblas >> ... >> ImportError: No module named _dotblas >> >> > > >>> import numpy.core._dotblas as dotblas > >>> dotblas.__file__ > 'C:\\Python26\\lib\\site-packages\\numpy\\core\

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread Sturla Molden
V. Armando Solé skrev: > In python 2.6: > > >>>import numpy.core._dotblas as dotblas > ... > ImportError: No module named _dotblas > >>> import numpy.core._dotblas as dotblas >>> dotblas.__file__ 'C:\\Python26\\lib\\site-packages\\numpy\\core\\_dotblas.pyd' ___

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread David Cournapeau
V. Armando Solé wrote: > Hello, > > It seems to point towards a packaging problem. > > In python 2.5, I can do: > > import numpy.core._dotblas as dotblas > dotblas.__file__ > > and I get: > > C:\\Python25\\lib\\site-packages\\numpy\\core\\_dotblas.pyd > That's where the error lies: if you insta

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread Sturla Molden
V. Armando Solé skrev: > import numpy > import time > a=numpy.arange(100.) > a.shape=1000,1000 > t0=time.time() > b=numpy.dot(a.T,a) > print "Elapsed time = ",time.time()-t0 > > reports an "Elapsed time" of 1.4 seconds under python 2.5 and 15 seconds > under python 2.6 > My computer reports

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread V. Armando Solé
Hello, It seems to point towards a packaging problem. In python 2.5, I can do: import numpy.core._dotblas as dotblas dotblas.__file__ and I get: C:\\Python25\\lib\\site-packages\\numpy\\core\\_dotblas.pyd In python 2.6: >>>import numpy.core._dotblas as dotblas ... ImportError: No module nam

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread V. Armando Solé
David Cournapeau wrote: > V. Armando Solé wrote: > >> Hello, >> >> I have found performance problems under windows when using python 2.6 >> In my case, they seem to be related to the dot product. >> >> The following simple script: >> >> import numpy >> import time >> a=numpy.arange(100.) >>

Re: [Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread David Cournapeau
V. Armando Solé wrote: > Hello, > > I have found performance problems under windows when using python 2.6 > In my case, they seem to be related to the dot product. > > The following simple script: > > import numpy > import time > a=numpy.arange(100.) > a.shape=1000,1000 > t0=time.time() > b=num

[Numpy-discussion] Dot product performance on python 2.6 (windows)

2009-09-11 Thread V. Armando Solé
Hello, I have found performance problems under windows when using python 2.6 In my case, they seem to be related to the dot product. The following simple script: import numpy import time a=numpy.arange(100.) a.shape=1000,1000 t0=time.time() b=numpy.dot(a.T,a) print "Elapsed time = ",time.tim

Re: [Numpy-discussion] dot product

2009-03-10 Thread Nadav Horesh
dot(X.transpose(), Y)**2 / ( (X*X).sum(0)[:,None] * (Y*Y).sum(0) ) Nadav -הודעה מקורית- מאת: numpy-discussion-boun...@scipy.org בשם Nils Wagner נשלח: ג 10-מרץ-09 11:37 אל: numpy-discussion@scipy.org נושא: [Numpy-discussion] dot product Hi all, The dot product can be defined for

[Numpy-discussion] dot product

2009-03-10 Thread Nils Wagner
Hi all, The dot product can be defined for two vectors x and y by x·y=|x||y| \cos(\theta), where theta is the angle between the vectors and |x| is the norm. Now assume that we have arrays(matrices) X = [x_1, ..., x_m] Y = [y_1, ..., y_s] m <> s Is there a built-in function to comp

Re: [Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robert Kern
Robin wrote: > > On 10/8/07, *Robert Kern* <[EMAIL PROTECTED] > > wrote: > > Aha. Yes, that is the correct way to do it. However, it appears that > there is a > bug in how dot() is interpreting the non-contiguous array. In the > meantime, you > can ma

Re: [Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robin
On 10/8/07, Robert Kern <[EMAIL PROTECTED]> wrote: > > Aha. Yes, that is the correct way to do it. However, it appears that there > is a > bug in how dot() is interpreting the non-contiguous array. In the > meantime, you > can make a contiguous array with array(y2). Thanks very much for the promp

Re: [Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robert Kern
Robin wrote: > It works for me with a recent SVN numpy on OS X. What version of > numpy are you > using? What platform are you on? Did you build with ATLAS or other > optimized > linear algebra library? > > > I am on Ubuntu 7.04, gcc 4.1.2 > > In [181]: numpy.__version__ > Ou

Re: [Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robin
> > It works for me with a recent SVN numpy on OS X. What version of numpy are > you > using? What platform are you on? Did you build with ATLAS or other > optimized > linear algebra library? I am on Ubuntu 7.04, gcc 4.1.2 In [181]: numpy.__version__ Out[181]: '1.0.4.dev4155' Built with ATLAS 3

Re: [Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robert Kern
Robin wrote: > Hi, > > I have a problem using numpy.dot, see below: > > In [151]: m=5 > > In [152]: n=5 > > In [153]: x=(m*ones((1,5)))**arange(0,n) > > In [154]: y=test.order_length[::-1] > > In [155]: x > Out[155]: array([[ 1.,5., 25., 125., 625.]]) > > In [156]: y > Out[156]: >

[Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robin
Hi, I have a problem using numpy.dot, see below: In [151]: m=5 In [152]: n=5 In [153]: x=(m*ones((1,5)))**arange(0,n) In [154]: y=test.order_length[::-1] In [155]: x Out[155]: array([[ 1.,5., 25., 125., 625.]]) In [156]: y Out[156]: array([[ 1024.], [ 1280.], [ 640.]