mirror of
https://github.com/gonum/gonum.git
synced 2025-10-09 00:50:16 +08:00
Switched receiver and slice order in cumsum and added check for nil receiver
This commit is contained in:
@@ -61,7 +61,10 @@ func Prod(s []float64) (prod float64) {
|
||||
// Finds the cumulative sum of the first i elements in
|
||||
// s and puts them in place into the ith element of the
|
||||
// receiver. If the receiver is nil a new slice is created
|
||||
func CumSum(s, receiver []float64) []float64 {
|
||||
func CumSum(receiver, s []float64) []float64 {
|
||||
if receiver == nil {
|
||||
receiver = make([]float64, len(s))
|
||||
}
|
||||
if len(s) == 0 {
|
||||
return receiver[:0]
|
||||
}
|
||||
|
Reference in New Issue
Block a user