Dominique Orban wrote:
> On 10/5/07, Robert Kern <robert.kern@gmail.com> wrote:
>> Dominique Orban wrote:
>>>>> I believe dot(X,Y) means X^T Y, so that dot(A.T, A) is in fact AA=A^2.
>> No, this is not correct. dot() is simply matrix multiplication.
>> Isn't this counter-intuitive, given that for vectors, dot(u,v) is u^T v ?
Well, I lied about dot() being matrix multiplication. It is if the two arguments
are matrices. Really it is an operation on N-D arrays: and product-sum over the
last dimension of the first argument and the second-to-last dimension (or the
closest in case of len(v.shape) < 2) of the second argument. There are two
hypothetical paths you can take to explain the "meaning" of that very
mechanistic operation:
* You could say that we treat u and v both like a (n,1) column vector and
dot(u, v) is equivalent to (u^T v).
* You could say that we treat the first shape-(n,) array like a (1,n) row vector
and the the second shape-(n,) array like an (n,1) column vector and did matrix
multiplication on them directly.
The latter is consistent with the other behavior of dot() while the former is
not. Since they're both hypothetical semantics, we are free to choose the one
that makes sense.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco