1
0
Fork 0
golang-github-wcharczuk-go-.../matrix/vector.go
Daniel Baumann 41a2f19f12
Adding upstream version 2.1.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-05-18 07:17:02 +02:00

17 lines
344 B
Go

package matrix
// Vector is just an array of values.
type Vector []float64
// DotProduct returns the dot product of two vectors.
func (v Vector) DotProduct(v2 Vector) (result float64, err error) {
if len(v) != len(v2) {
err = ErrDimensionMismatch
return
}
for i := 0; i < len(v); i++ {
result = result + (v[i] * v2[i])
}
return
}