mirror of
https://github.com/gonum/gonum.git
synced 2025-10-08 16:40:06 +08:00
Fixed minor bug
This commit is contained in:
13
floats.go
13
floats.go
@@ -245,6 +245,19 @@ func Mul(s []float64, t []float64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MulTo performs element-wise multiplication between s
|
||||||
|
// and t and stores the value in dst. Panics if the
|
||||||
|
// lengths of s, t, and dst are not equal
|
||||||
|
func MulTo(dst []float64, s []float64, t []float64) []float64 {
|
||||||
|
if len(s) != len(t) || len(dst) != len(t) {
|
||||||
|
panic("floats: slice lengths do not match")
|
||||||
|
}
|
||||||
|
for i, val := range t {
|
||||||
|
dst[i] = val * s[i]
|
||||||
|
}
|
||||||
|
return dst
|
||||||
|
}
|
||||||
|
|
||||||
// Nearest returns the index of the element in s
|
// Nearest returns the index of the element in s
|
||||||
// whose value is nearest to v. If several such
|
// whose value is nearest to v. If several such
|
||||||
// elements exist, the lowest index is returned
|
// elements exist, the lowest index is returned
|
||||||
|
@@ -282,6 +282,10 @@ func TestMin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMul(t *testing.T) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestNearest(t *testing.T) {
|
func TestNearest(t *testing.T) {
|
||||||
s := []float64{6.2, 3, 5, 6.2, 8}
|
s := []float64{6.2, 3, 5, 6.2, 8}
|
||||||
ind := Nearest(s, 2.0)
|
ind := Nearest(s, 2.0)
|
||||||
|
Reference in New Issue
Block a user