I reviewed some math books and concluded that ip
(inner product) is a false name which conveyed a misconception. A correction could be
function sm(p, x) return sum(p .* x) end
where s
stands for vector sum
and m
stands for scalar multiplication
.
The sm
should be a more fundamental operation, which makes sense in, e.g.,
integration theory (p
represents a probability measure while x
represents a measurable function).
And some related useful formulas are:
@assert sm(A, B) == tr(transpose(A) * B)
@assert transpose(z) * A * w == tr(A * w * transpose(z))
@assert tr(A * B) == tr(B * A)
as long assize(A) == size(transpose(B))