On Fri, Jul 25, 2008 at 12:36 PM, Keith Goodman <[EMAIL PROTECTED]> wrote:
> On Fri, Jul 25, 2008 at 12:32 PM, Frank Lagor <[EMAIL PROTECTED]> wrote:
>> Perhaps I do not understand something properly, if so could someone please
>> explain the behavior I notice with numpy.linalg.svd when acting on arrays.
>> It gives the incorrect answer, but works fine with matrices. My numpy is
>> 1.1.0.
>>
>>>>> R = n.array([[3.6,.35],[.35,1.8]])
>>>>> V,D,W = n.linalg.svd(R)
>>>>> V*n.diag(D)*W.transpose()
>> array([[ 3.5410365 , 0. ],
>> [ 0. , 1.67537611]])
>>>>> R = n.matrix([[3.6,.35],[.35,1.8]])
>>>>> V,D,W = n.linalg.svd(R)
>>>>> V*n.diag(D)*W.transpose()
>> matrix([[ 3.6 , 0.35],
>> [ 0.35, 1.8 ]])
>
> '*' does element-by-element multiplication for arrays but matrix
> multiplication for matrices.
As a check (for the array case):
>> n.dot(V, n.dot(n.diag(D), W.transpose())) # That's hard to read!
array([[ 3.6 , 0.35],
[ 0.35, 1.8 ]])
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion