Adding upstream version 2.1.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
c8c64afc61
commit
41a2f19f12
220 changed files with 19814 additions and 0 deletions
17
matrix/vector.go
Normal file
17
matrix/vector.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue