OONSTD: Dot Product

E. Robert Tisdale (edwin@maxwell.hrl.hac.com)
Mon, 13 Jul 1998 16:25:32 -0700 (PDT)

scalar vector matrix tensor
scalar 1 1 1 1
vector 1 1 0 0
matrix 1 0 1 0
tensor 1 0 0 1

Both operands of an element by element binary operator
(*, /, +, -, %, &, |, ^, <, <=, >, >=, ==, !=, &&, ||, etc.)
must be the same size unless one of them is a scalar.

Both operands must be the same length in the vector dot product

u.dot(v) = uv'

if you think u and v are row vectors or

u.dot(v) = u'v

if you think u and v are column vectors. (' denotes transpose.)

Both vector v and the rows of matrix M must be the same length
in the vector-matrix dot product

v.dot(M) = vM'

and in the matrix-vector dot product

M.dot(v) = Mv' = (vM')'

The rows of both matrix M and N must be the same length
in the matrix-matrix dot product

M.dot(N) = MN'

The common matrix-matrix product is effected by

M.dot(N.t()) = MN

but the application programmer may be wise
to store Nt = N.t() instead of N in system memory
in order to avoid striding across the rows of N.