Skip to content

Commit

Permalink
refactor: use more general zero utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
crhntr committed Feb 13, 2024
1 parent 3cbcfe1 commit de59c66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/crhntr/neldermead

go 1.21
go 1.22
5 changes: 3 additions & 2 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,9 @@ func distance(x1, x2 []float64) float64 {
return math.Sqrt(sum)
}

func setZero(s []float64) {
func setZero[T any](s []T) {
var zero T
for i := range s {
s[i] = 0
s[i] = zero
}
}

0 comments on commit de59c66

Please sign in to comment.