mirror of
https://github.com/gonum/gonum.git
synced 2025-10-14 19:26:30 +08:00
Fixed error in cumprod code. Added test for cumprod
This commit is contained in:
@@ -115,3 +115,16 @@ func TestCumSum(t *testing.T) {
|
||||
t.Errorf("Wrong cumsum returned with non-nil receiver. Expected %v, returned %v", truth, val)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCumProd(t *testing.T) {
|
||||
s := []float64{3, 4, 1, 7, 5}
|
||||
val := CumProd(nil, s)
|
||||
truth := []float64{3, 12, 12, 84, 420}
|
||||
if !Eq(val, truth, 1E-15) {
|
||||
t.Errorf("Wrong cumprod returned with nil receiver. Expected %v, returned %v", truth, val)
|
||||
}
|
||||
val = CumProd(val, s)
|
||||
if !Eq(val, truth, 1E-15) {
|
||||
t.Errorf("Wrong cumprod returned with non-nil receiver. Expected %v, returned %v", truth, val)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user