[Numpy-discussion] best way to get vector representation in a basis?

Alan G Isaac aisaac@american....
Thu Apr 16 09:33:02 CDT 2009


On 4/16/2009 5:06 AM dmitrey apparently wrote:
> I have orthonormal set of vectors B = [b_0, b_1,..., b_k-1],
> b_i from R^n (k may be less than n), and vector a from R^n
> 
> What is most efficient way in numpy to get r from R^n and c_0, ...,
> c_k-1 from R:
> a = c_0*b_0+...+c_k-1*b_k-1 + r
> (r is rest)


I must misunderstand this problem:
efficient would be to set c=0 and r=a.

I would have said to use np.linalg.lstsq,
if you would like r to be small,
but if B is really orthonormal, you can
just put c=B'a (since B'B is a k dimensional identity).

But I suspect I have failed to understand
what you are after.

Alan Isaac



More information about the Numpy-discussion mailing list