# [Numpy-discussion] Behaviour of vdot(array2d, array1d)

Nikolas Tezak Nikolas.Tezak at gmx.de
Thu Jan 7 12:51:44 EST 2010

```Hi,
I am new to this list, but I have been using scipy for a couple of
months now with great satisfaction.
Currently I have a problem:

I diagonalize a hermitian complex matrix using the eigh routine from
scipy.linalg (this is still a numpy question, see below)
This returns the eigenvectors as columns of a 2d array.

Now I would like to project a vector onto this new basis.
I could either do:

inital_state = array(...) #dtype=complex, shape=(dim,)
coefficients = zeros( shape=(dim,), dtype=complex)
matrix = array(...) #dtype=complex, shape=(dim, dim)
eigenvalues, eigenvectors = eigh(matrix)
for i in xrange(dim):
coefficients[i] = vdot(eigenvalues[:, i], initial_state)

But it seems to me after reading the documentation for vdot, that it
should also be possible to do this without a loop:

initial_state = array(...) #dtype=complex, shape=(dim,)

matrix = array(...) #dtype=complex, shape=(dim, dim)
eigenvalues, eigenvectors = eigh(matrix)

coefficients = vdot( eigenvalues.transpose(), initial_state)

However when I do this, vdot raises a ValueError complaining that the
"vectors have different lengths".
It seems that vdot (as opposed to dot) cannot handle arguments with
different shape although the documentation suggests otherwise.
I am using numpy version 1.3.0. Is this a bug or am I missing something?

Regards,

Nikolas

```