mirror of
https://github.com/muesli/kmeans.git
synced 2025-09-27 03:56:17 +08:00
Added Point.Equal(other) for convenience
This commit is contained in:
11
point.go
11
point.go
@@ -20,6 +20,17 @@ func (p Point) Distance(p2 Point) float64 {
|
||||
return r
|
||||
}
|
||||
|
||||
// Equal returns true if the two points have equal values
|
||||
func (p Point) Equal(p2 Point) bool {
|
||||
for i := range p {
|
||||
if p[i] != p2[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Mean returns the mean point of p
|
||||
func (p Points) Mean() (Point, error) {
|
||||
var l = len(p)
|
||||
|
Reference in New Issue
Block a user