Newbie : innerproduct function from Numarray

Ohkyu Yoon okyoon at
Mon Jan 26 22:29:25 CET 2004

I have two vectors that have about 2000 elements.
I need to calculate the innerproducts of those vectors 2000 times where
one of them cycles left(ie 1234, then 2341, then 3412, etc)
Basically, I want to calculate A*x, where A is a left-circulant cyclic
and x is a vector.

I tried it two ways.
vector1 & vector2 are lists.

from Numarray import innerproduct
output = []
temp = vector1 + vector1    # temp is twice the length of vector1
for i in range(2000):
output = []
temp = vector1 + vector1
for i in range(2000):
    sum = 0
    for j in range(2000):
        sum += temp[i+j] * vector2[j]

I thought the first method using Numarray should be faster.
But it looks like the second method is faster.
Am I doing anything wrong?
Do you guys know any faster way to do this?

Thank you.

More information about the Python-list mailing list