Add Laplacian and CrossLaplacian difference functions (#154)

* Add Laplacian and CrossLaplacian difference functions

* use usesOrigin
This commit is contained in:
Brendan Tracey
2017-08-03 21:29:12 -06:00
committed by GitHub
parent 4d30eb012e
commit 084f84ee0e
7 changed files with 560 additions and 57 deletions

View File

@@ -51,7 +51,8 @@ func Gradient(dst []float64, f func([]float64) float64, x []float64, settings *S
nWorkers := computeWorkers(concurrent, evals)
hasOrigin := usesOrigin(formula.Stencil)
xcopy := make([]float64, len(x)) // So that x is not modified during the call.
// Copy x in case it is modified during the call.
xcopy := make([]float64, len(x))
if hasOrigin && !originKnown {
copy(xcopy, x)
originValue = f(xcopy)
@@ -65,7 +66,7 @@ func Gradient(dst []float64, f func([]float64) float64, x []float64, settings *S
deriv += pt.Coeff * originValue
continue
}
// 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