Debian Codegraph @

matrix/vector.go

raw symbols SCIP
1 package matrix
2
3 // Vector is just an array of values.
4 type Vector []float64
5
6 // DotProduct returns the dot product of two vectors.
7 func (v Vector) DotProduct(v2 Vector) (result float64, err error) {
8 if len(v) != len(v2) {
9 err = ErrDimensionMismatch
10 return
11 }
12
13 for i := 0; i < len(v); i++ {
14 result = result + (v[i] * v2[i])
15 }
16 return
17 }