[Numpy-discussion] Efficient orthogonalisation with scipy/numpy

Gael Varoquaux gael.varoquaux at normalesup.org
Tue Jan 19 15:12:53 EST 2010


Hi there,

Forgive me for turning to the mailing list to do my homework. I am
currently optimizing a code, and it turns out that the main bottleneck is
the orthogonalisation of a vector 'y' to a set of vectors 'confounds',
that I am currently doing with the following code:

y = y - np.dot(confounds.T, linalg.lstsq(confounds.T, y)[0])

with np = numpy and linalg = scipy.linalg where scipy calls ATLAS.

Most of the time is spent in linalg.lstsq. The length of the vectors is
810, and there are about 10 confounds.

Is there a better way of doing this?

Cheers,

Gaël



More information about the NumPy-Discussion mailing list