mirror of
https://github.com/gonum/gonum.git
synced 2025-10-05 15:16:59 +08:00
Add Laplacian and CrossLaplacian difference functions (#154)
* Add Laplacian and CrossLaplacian difference functions * use usesOrigin
This commit is contained in:
@@ -84,6 +84,7 @@ func hessianSerial(dst *mat.SymDense, f func(x []float64) float64, x []float64,
|
||||
n := len(x)
|
||||
xCopy := make([]float64, n)
|
||||
fo := func() float64 {
|
||||
// Copy x in case it is modified during the call.
|
||||
copy(xCopy, x)
|
||||
return f(x)
|
||||
}
|
||||
@@ -98,7 +99,7 @@ func hessianSerial(dst *mat.SymDense, f func(x []float64) float64, x []float64,
|
||||
if pti.Loc == 0 && ptj.Loc == 0 {
|
||||
v = origin
|
||||
} else {
|
||||
// Copying the code anew has two benefits. First, it
|
||||
// Copying the data anew has two benefits. First, it
|
||||
// avoids floating point issues where adding and then
|
||||
// subtracting the step don't return to the exact same
|
||||
// location. Secondly, it protects against the function
|
||||
@@ -125,7 +126,7 @@ func hessianConcurrent(dst *mat.SymDense, nWorkers, evals int, f func(x []float6
|
||||
}
|
||||
|
||||
send := make(chan run, evals)
|
||||
ans := make(chan run)
|
||||
ans := make(chan run, evals)
|
||||
|
||||
var originWG sync.WaitGroup
|
||||
hasOrigin := usesOrigin(stencil)
|
||||
|
Reference in New Issue
Block a user