logoalt Hacker News

evanblast Monday at 8:48 PM0 repliesview on HN

A dot product is a weighted sum of two vectors, but not in the way the author suggested. The author's use is that one of the vectors is the weights and the other is 'the' vector, so the dot product is the weighted sum of ONE vector. It just so happens that because the author is not interested in the geometric interpretation of the dot product that they forgo the metric.

On the other hand, it is common to need a metric, which is actually the set of weights in the dot product. If `g` is the metric,

    dot(a, g, b) = np.einsum('x,xy,y->', np.conj(a), g, b)
g doesn't have to be diagonal, but if you want the dot product to be symmetric in a and b it ought to be self-adjoint. Then you can find a basis where g is diagonal with real diagonal elements, which you can interpret as the weights.