mirror of
https://github.com/sjwhitworth/golearn.git
synced 2025-04-25 13:48:49 +08:00
commit
5d79ed7114
@ -14,7 +14,8 @@ func NewEuclidean() *Euclidean {
|
||||
|
||||
// InnerProduct computes a Eucledian inner product.
|
||||
func (e *Euclidean) InnerProduct(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
|
||||
subVector := new(mat.Dense)
|
||||
subVector := mat.NewDense(1, 1, nil)
|
||||
subVector.Reset()
|
||||
subVector.MulElem(vectorX, vectorY)
|
||||
result := mat.Sum(subVector)
|
||||
|
||||
@ -23,7 +24,8 @@ func (e *Euclidean) InnerProduct(vectorX *mat.Dense, vectorY *mat.Dense) float64
|
||||
|
||||
// Distance computes Euclidean distance (also known as L2 distance).
|
||||
func (e *Euclidean) Distance(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
|
||||
subVector := new(mat.Dense)
|
||||
subVector := mat.NewDense(1, 1, nil)
|
||||
subVector.Reset()
|
||||
subVector.Sub(vectorX, vectorY)
|
||||
result := e.InnerProduct(subVector, subVector)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user