I find this definition in wiki
Algebraically, the dot product is the sum of the products of the corresponding entries of the two sequences of numbers.
Translating into julia, it is
function dot_product(x, y) return sum(x .* y) end
But due to the fact that we haven’t restricted the type of args, this function may have some other (pleasantly) unexpected usage. Therefore, I would prefer a more appropriate name for it, see this.
My larger point is: there is no foolproof method. And we should not hope for this.
As an example, if sparsity exists, we may sometimes need to write our own code, see this.
In general, the adjoint
('
) or transpose
are versatile, not restricted to only offering a scalar output (which in math sense, inner product). I think these are already enough.
If there is anyone who knows more about the underlying performance issue, just correct me