"Alan G Isaac" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> This times faster than the alternatives I have seen mentioned so far,
> given scipy.
Actually, since I am new to 'timeit', I probably should check that
I am not overlooking something. Especially since I see an order
of m
[Rahul].
> I want to compute dot product of two vectors stored as lists a and b.a
> and b are of the same length
from scipy import dot
ans=dot(a,b)
This times faster than the alternatives I have seen mentioned so far,
given scipy.
Cheers,
Alan Isaac
--
http://mail.python.org/mailman/listinfo/
[Rahul].
> > I want to compute dot product of two vectors stored as lists a and b.a
> > and b are of the same length.
> >
> > one simple way is
> > sum(a[i]*b[i] for i in range(len(a)))
> >
> > another simple way is
> > ans=0.0
> > for i in range(len(a)):
> > ans=ans+a[i]*b[i]
> >
> > But is there
On Sun, Dec 19, 2004 at 03:04:15AM -0800, Rahul wrote:
> HI.
> I want to compute dot product of two vectors stored as lists a and b.a
> and b are of the same length.
>
> one simple way is
> sum(a[i]*b[i] for i in range(len(a)))
>
> another simple way is
> ans=0.0
> for i in range(len(a)):
> ans=a
On 19 Dec 2004 03:04:15 -0800, "Rahul" <[EMAIL PROTECTED]> wrote:
>HI.
>I want to compute dot product of two vectors stored as lists a and b.a
>and b are of the same length.
>
>one simple way is
>sum(a[i]*b[i] for i in range(len(a)))
>
>another simple way is
>ans=0.0
>for i in range(len(a)):
>ans=
Raymond Hettinger wrote:
> [Rahul].
> > I want to compute dot product of two vectors stored as lists a and
b.a
> > and b are of the same length.
> >
> > one simple way is
> > sum(a[i]*b[i] for i in range(len(a)))
> >
> > another simple way is
> > ans=0.0
> > for i in range(len(a)):
> > ans=ans+a[i
Raymond Hettinger wrote:
> * applying itertools instead of genexps can save the eval-loop overhead
> * however, genexps are usually more readable than itertools solutions
I'm still waiting for you to implement itertools as a parse-tree analyzer/code
generator,
rather than an "bare" extension mod
[Rahul].
> I want to compute dot product of two vectors stored as lists a and b.a
> and b are of the same length.
>
> one simple way is
> sum(a[i]*b[i] for i in range(len(a)))
>
> another simple way is
> ans=0.0
> for i in range(len(a)):
> ans=ans+a[i]*b[i]
>
> But is there any other way which is f
Rahul wrote:
I want to compute dot product of two vectors stored as lists a and b.a
and b are of the same length.
. >>> import numarray as na
. >>> a, b = na.arange(5), na.arange(5, 10)
. >>> na.dot(a, b)
. 80
Steve
--
http://mail.python.org/mailman/listinfo/python-list
Rahul wrote:
> I want to compute dot product of two vectors stored as lists a and b.a
> and b are of the same length.
>
> one simple way is
> sum(a[i]*b[i] for i in range(len(a)))
>
> another simple way is
> ans=0.0
> for i in range(len(a)):
> ans=ans+a[i]*b[i]
>
> But is there any other way wh
Rahul wrote:
HI.
I want to compute dot product of two vectors stored as lists a and b.a
and b are of the same length.
one simple way is
sum(a[i]*b[i] for i in range(len(a)))
another simple way is
ans=0.0
for i in range(len(a)):
ans=ans+a[i]*b[i]
But is there any other way which is faster than any o
Rahul wrote:
I want to compute dot product of two vectors stored as lists a and b.a
and b are of the same length.
one simple way is
sum(a[i]*b[i] for i in range(len(a)))
btw, imho the most "Pythonic" would be:
sum(i*j for (i,j) in zip(a,b))
--
http://mail.python.org/mailman/listinfo/python-list
HI.
I want to compute dot product of two vectors stored as lists a and b.a
and b are of the same length.
one simple way is
sum(a[i]*b[i] for i in range(len(a)))
another simple way is
ans=0.0
for i in range(len(a)):
ans=ans+a[i]*b[i]
But is there any other way which is faster than any of the abov
13 matches
Mail list logo