all: run gofmt and generate all packages

Changes made in dsp/fourier/internal/fftpack break the formatting used
there, so these are reverted. There will be complaints in CI.

[git-generate]
gofmt -w .
go generate gonum.org/v1/gonum/blas
go generate gonum.org/v1/gonum/blas/gonum
go generate gonum.org/v1/gonum/unit
go generate gonum.org/v1/gonum/unit/constant
go generate gonum.org/v1/gonum/graph/formats/dot
go generate gonum.org/v1/gonum/graph/formats/rdf
go generate gonum.org/v1/gonum/stat/card

git checkout -- dsp/fourier/internal/fftpack
This commit is contained in:
Dan Kortschak
2022-08-05 20:57:59 +09:30
parent fee5019b48
commit 5f0141ca4c
308 changed files with 5004 additions and 3064 deletions

View File

@@ -14,15 +14,16 @@ import (
// Beale implements the Beale's function.
//
// Standard starting points:
// Easy: [1, 1]
// Hard: [1, 4]
//
// Easy: [1, 1]
// Hard: [1, 4]
//
// References:
// - Beale, E.: On an Iterative Method for Finding a Local Minimum of a
// Function of More than One Variable. Technical Report 25, Statistical
// Techniques Research Group, Princeton University (1958)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Beale, E.: On an Iterative Method for Finding a Local Minimum of a
// Function of More than One Variable. Technical Report 25, Statistical
// Techniques Research Group, Princeton University (1958)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type Beale struct{}
func (Beale) Func(x []float64) float64 {
@@ -92,11 +93,13 @@ func (Beale) Minima() []Minimum {
// BiggsEXP2 implements the Biggs' EXP2 function.
//
// Standard starting point:
// [1, 2]
//
// [1, 2]
//
// Reference:
// Biggs, M.C.: Minimization algorithms making use of non-quadratic properties
// of the objective function. IMA J Appl Math 8 (1971), 315-327; doi:10.1093/imamat/8.3.315
//
// Biggs, M.C.: Minimization algorithms making use of non-quadratic properties
// of the objective function. IMA J Appl Math 8 (1971), 315-327; doi:10.1093/imamat/8.3.315
type BiggsEXP2 struct{}
func (BiggsEXP2) Func(x []float64) (sum float64) {
@@ -150,11 +153,13 @@ func (BiggsEXP2) Minima() []Minimum {
// BiggsEXP3 implements the Biggs' EXP3 function.
//
// Standard starting point:
// [1, 2, 1]
//
// [1, 2, 1]
//
// Reference:
// Biggs, M.C.: Minimization algorithms making use of non-quadratic properties
// of the objective function. IMA J Appl Math 8 (1971), 315-327; doi:10.1093/imamat/8.3.315
//
// Biggs, M.C.: Minimization algorithms making use of non-quadratic properties
// of the objective function. IMA J Appl Math 8 (1971), 315-327; doi:10.1093/imamat/8.3.315
type BiggsEXP3 struct{}
func (BiggsEXP3) Func(x []float64) (sum float64) {
@@ -210,11 +215,13 @@ func (BiggsEXP3) Minima() []Minimum {
// BiggsEXP4 implements the Biggs' EXP4 function.
//
// Standard starting point:
// [1, 2, 1, 1]
//
// [1, 2, 1, 1]
//
// Reference:
// Biggs, M.C.: Minimization algorithms making use of non-quadratic properties
// of the objective function. IMA J Appl Math 8 (1971), 315-327; doi:10.1093/imamat/8.3.315
//
// Biggs, M.C.: Minimization algorithms making use of non-quadratic properties
// of the objective function. IMA J Appl Math 8 (1971), 315-327; doi:10.1093/imamat/8.3.315
type BiggsEXP4 struct{}
func (BiggsEXP4) Func(x []float64) (sum float64) {
@@ -272,11 +279,13 @@ func (BiggsEXP4) Minima() []Minimum {
// BiggsEXP5 implements the Biggs' EXP5 function.
//
// Standard starting point:
// [1, 2, 1, 1, 1]
//
// [1, 2, 1, 1, 1]
//
// Reference:
// Biggs, M.C.: Minimization algorithms making use of non-quadratic properties
// of the objective function. IMA J Appl Math 8 (1971), 315-327; doi:10.1093/imamat/8.3.315
//
// Biggs, M.C.: Minimization algorithms making use of non-quadratic properties
// of the objective function. IMA J Appl Math 8 (1971), 315-327; doi:10.1093/imamat/8.3.315
type BiggsEXP5 struct{}
func (BiggsEXP5) Func(x []float64) (sum float64) {
@@ -336,14 +345,15 @@ func (BiggsEXP5) Minima() []Minimum {
// BiggsEXP6 implements the Biggs' EXP6 function.
//
// Standard starting point:
// [1, 2, 1, 1, 1, 1]
//
// [1, 2, 1, 1, 1, 1]
//
// References:
// - Biggs, M.C.: Minimization algorithms making use of non-quadratic
// properties of the objective function. IMA J Appl Math 8 (1971), 315-327;
// doi:10.1093/imamat/8.3.315
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Biggs, M.C.: Minimization algorithms making use of non-quadratic
// properties of the objective function. IMA J Appl Math 8 (1971), 315-327;
// doi:10.1093/imamat/8.3.315
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type BiggsEXP6 struct{}
func (BiggsEXP6) Func(x []float64) (sum float64) {
@@ -417,13 +427,14 @@ func (BiggsEXP6) Minima() []Minimum {
// Box3D implements the Box' three-dimensional function.
//
// Standard starting point:
// [0, 10, 20]
//
// [0, 10, 20]
//
// References:
// - Box, M.J.: A comparison of several current optimization methods, and the
// use of transformations in constrained problems. Comput J 9 (1966), 67-77
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Box, M.J.: A comparison of several current optimization methods, and the
// use of transformations in constrained problems. Comput J 9 (1966), 67-77
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type Box3D struct{}
func (Box3D) Func(x []float64) (sum float64) {
@@ -485,11 +496,14 @@ func (Box3D) Minima() []Minimum {
// BraninHoo implements the Branin-Hoo function. BraninHoo is a 2-dimensional
// test function with three global minima. It is typically evaluated in the domain
// x_0 ∈ [-5, 10], x_1 ∈ [0, 15].
// f(x) = (x_1 - (5.1/(4π^2))*x_0^2 + (5/π)*x_0 - 6)^2 + 10*(1-1/(8π))cos(x_0) + 10
//
// f(x) = (x_1 - (5.1/(4π^2))*x_0^2 + (5/π)*x_0 - 6)^2 + 10*(1-1/(8π))cos(x_0) + 10
//
// It has a minimum value of 0.397887 at x^* = {(-π, 12.275), (π, 2.275), (9.424778, 2.475)}
//
// Reference:
// https://www.sfu.ca/~ssurjano/branin.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/branin.html (obtained June 2017)
type BraninHoo struct{}
func (BraninHoo) Func(x []float64) float64 {
@@ -525,11 +539,12 @@ func (BraninHoo) Minima() []Minimum {
// BrownBadlyScaled implements the Brown's badly scaled function.
//
// Standard starting point:
// [1, 1]
//
// [1, 1]
//
// References:
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type BrownBadlyScaled struct{}
func (BrownBadlyScaled) Func(x []float64) float64 {
@@ -587,14 +602,15 @@ func (BrownBadlyScaled) Minima() []Minimum {
// BrownAndDennis implements the Brown and Dennis function.
//
// Standard starting point:
// [25, 5, -5, -1]
//
// [25, 5, -5, -1]
//
// References:
// - Brown, K.M., Dennis, J.E.: New computational algorithms for minimizing a
// sum of squares of nonlinear functions. Research Report Number 71-6, Yale
// University (1971)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Brown, K.M., Dennis, J.E.: New computational algorithms for minimizing a
// sum of squares of nonlinear functions. Research Report Number 71-6, Yale
// University (1971)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type BrownAndDennis struct{}
func (BrownAndDennis) Func(x []float64) (sum float64) {
@@ -689,14 +705,15 @@ func (BrownAndDennis) Minima() []Minimum {
// Its Hessian matrix is singular at the minimizer.
//
// Standard starting point:
// [3, -1, 0, 3, 3, -1, 0, 3, ..., 3, -1, 0, 3]
//
// [3, -1, 0, 3, 3, -1, 0, 3, ..., 3, -1, 0, 3]
//
// References:
// - Spedicato E.: Computational experience with quasi-Newton algorithms for
// minimization problems of moderatly large size. Towards Global
// Optimization 2 (1978), 209-219
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Spedicato E.: Computational experience with quasi-Newton algorithms for
// minimization problems of moderatly large size. Towards Global
// Optimization 2 (1978), 209-219
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type ExtendedPowellSingular struct{}
func (ExtendedPowellSingular) Func(x []float64) (sum float64) {
@@ -762,13 +779,14 @@ func (ExtendedPowellSingular) Minima() []Minimum {
// function.
//
// Standard starting point:
// Easy: [-1.2, 1, -1.2, 1, ...]
// Hard: any point far from the minimum
//
// Easy: [-1.2, 1, -1.2, 1, ...]
// Hard: any point far from the minimum
//
// References:
// - Rosenbrock, H.H.: An Automatic Method for Finding the Greatest or Least
// Value of a Function. Computer J 3 (1960), 175-184
// - http://en.wikipedia.org/wiki/Rosenbrock_function
// - Rosenbrock, H.H.: An Automatic Method for Finding the Greatest or Least
// Value of a Function. Computer J 3 (1960), 175-184
// - http://en.wikipedia.org/wiki/Rosenbrock_function
type ExtendedRosenbrock struct{}
func (ExtendedRosenbrock) Func(x []float64) (sum float64) {
@@ -858,11 +876,13 @@ func (ExtendedRosenbrock) Minima() []Minimum {
// caused by the finite floating point precision.
//
// Standard starting point:
// [0.4, 1, 0]
//
// [0.4, 1, 0]
//
// Reference:
// More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained optimization
// software. ACM Trans Math Softw 7 (1981), 17-41
//
// More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained optimization
// software. ACM Trans Math Softw 7 (1981), 17-41
type Gaussian struct{}
func (Gaussian) y(i int) (yi float64) {
@@ -939,14 +959,15 @@ func (Gaussian) Minima() []Minimum {
// GulfResearchAndDevelopment implements the Gulf Research and Development function.
//
// Standard starting point:
// [5, 2.5, 0.15]
//
// [5, 2.5, 0.15]
//
// References:
// - Cox, R.A.: Comparison of the performance of seven optimization algorithms
// on twelve unconstrained minimization problems. Ref. 1335CNO4, Gulf
// Research and Development Company, Pittsburg (1969)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Cox, R.A.: Comparison of the performance of seven optimization algorithms
// on twelve unconstrained minimization problems. Ref. 1335CNO4, Gulf
// Research and Development Company, Pittsburg (1969)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type GulfResearchAndDevelopment struct{}
func (GulfResearchAndDevelopment) Func(x []float64) (sum float64) {
@@ -1016,13 +1037,14 @@ func (GulfResearchAndDevelopment) Minima() []Minimum {
// Function is not defined at x[0] = 0.
//
// Standard starting point:
// [-1, 0, 0]
//
// [-1, 0, 0]
//
// References:
// - Fletcher, R., Powell, M.J.D.: A rapidly convergent descent method for
// minimization. Comput J 6 (1963), 163-168
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Fletcher, R., Powell, M.J.D.: A rapidly convergent descent method for
// minimization. Comput J 6 (1963), 163-168
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type HelicalValley struct{}
func (HelicalValley) Func(x []float64) float64 {
@@ -1098,14 +1120,15 @@ func (Linear) Grad(grad, x []float64) []float64 {
// PenaltyI implements the first penalty function by Gill, Murray and Pitfield.
//
// Standard starting point:
// [1, ..., n]
//
// [1, ..., n]
//
// References:
// - Gill, P.E., Murray, W., Pitfield, R.A.: The implementation of two revised
// quasi-Newton algorithms for unconstrained optimization. Report NAC 11,
// National Phys Lab (1972), 82-83
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Gill, P.E., Murray, W., Pitfield, R.A.: The implementation of two revised
// quasi-Newton algorithms for unconstrained optimization. Report NAC 11,
// National Phys Lab (1972), 82-83
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type PenaltyI struct{}
func (PenaltyI) Func(x []float64) (sum float64) {
@@ -1156,14 +1179,15 @@ func (PenaltyI) Minima() []Minimum {
// PenaltyII implements the second penalty function by Gill, Murray and Pitfield.
//
// Standard starting point:
// [0.5, ..., 0.5]
//
// [0.5, ..., 0.5]
//
// References:
// - Gill, P.E., Murray, W., Pitfield, R.A.: The implementation of two revised
// quasi-Newton algorithms for unconstrained optimization. Report NAC 11,
// National Phys Lab (1972), 82-83
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Gill, P.E., Murray, W., Pitfield, R.A.: The implementation of two revised
// quasi-Newton algorithms for unconstrained optimization. Report NAC 11,
// National Phys Lab (1972), 82-83
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type PenaltyII struct{}
func (PenaltyII) Func(x []float64) (sum float64) {
@@ -1236,14 +1260,15 @@ func (PenaltyII) Minima() []Minimum {
// that gives f(x) ≅ 1e-13.
//
// Standard starting point:
// [0, 1]
//
// [0, 1]
//
// References:
// - Powell, M.J.D.: A Hybrid Method for Nonlinear Equations. Numerical
// Methods for Nonlinear Algebraic Equations, P. Rabinowitz (ed.), Gordon
// and Breach (1970)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Powell, M.J.D.: A Hybrid Method for Nonlinear Equations. Numerical
// Methods for Nonlinear Algebraic Equations, P. Rabinowitz (ed.), Gordon
// and Breach (1970)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type PowellBadlyScaled struct{}
func (PowellBadlyScaled) Func(x []float64) float64 {
@@ -1304,14 +1329,15 @@ func (PowellBadlyScaled) Minima() []Minimum {
// Trigonometric implements the trigonometric function.
//
// Standard starting point:
// [1/dim, ..., 1/dim]
//
// [1/dim, ..., 1/dim]
//
// References:
// - Spedicato E.: Computational experience with quasi-Newton algorithms for
// minimization problems of moderatly large size. Towards Global
// Optimization 2 (1978), 209-219
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Spedicato E.: Computational experience with quasi-Newton algorithms for
// minimization problems of moderatly large size. Towards Global
// Optimization 2 (1978), 209-219
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type Trigonometric struct{}
func (Trigonometric) Func(x []float64) (sum float64) {
@@ -1374,11 +1400,13 @@ func (Trigonometric) Minima() []Minimum {
// VariablyDimensioned implements a variably dimensioned function.
//
// Standard starting point:
// [..., (dim-i)/dim, ...], i=1,...,dim
//
// [..., (dim-i)/dim, ...], i=1,...,dim
//
// References:
// More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained optimization
// software. ACM Trans Math Softw 7 (1981), 17-41
//
// More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained optimization
// software. ACM Trans Math Softw 7 (1981), 17-41
type VariablyDimensioned struct{}
func (VariablyDimensioned) Func(x []float64) (sum float64) {
@@ -1447,13 +1475,14 @@ func (VariablyDimensioned) Minima() []Minimum {
// of minimizing the function is very ill conditioned.
//
// Standard starting point:
// [0, ..., 0]
//
// [0, ..., 0]
//
// References:
// - Kowalik, J.S., Osborne, M.R.: Methods for Unconstrained Optimization
// Problems. Elsevier North-Holland, New York, 1968
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Kowalik, J.S., Osborne, M.R.: Methods for Unconstrained Optimization
// Problems. Elsevier North-Holland, New York, 1968
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type Watson struct{}
func (Watson) Func(x []float64) (sum float64) {
@@ -1597,13 +1626,14 @@ func (Watson) Minima() []Minimum {
// Wood implements the Wood's function.
//
// Standard starting point:
// [-3, -1, -3, -1]
//
// [-3, -1, -3, -1]
//
// References:
// - Colville, A.R.: A comparative study of nonlinear programming codes.
// Report 320-2949, IBM New York Scientific Center (1968)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
// - Colville, A.R.: A comparative study of nonlinear programming codes.
// Report 320-2949, IBM New York Scientific Center (1968)
// - More, J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained
// optimization software. ACM Trans Math Softw 7 (1981), 17-41
type Wood struct{}
func (Wood) Func(x []float64) (sum float64) {
@@ -1674,8 +1704,9 @@ func (Wood) Minima() []Minimum {
// of the minimizer which is located at x=sqrt(2).
//
// References:
// More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
// ACM Transactions on Mathematical Software 20(3) (1994), 286307, eq. (5.1)
//
// More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
// ACM Transactions on Mathematical Software 20(3) (1994), 286307, eq. (5.1)
type ConcaveRight struct{}
func (ConcaveRight) Func(x []float64) float64 {
@@ -1700,8 +1731,9 @@ func (ConcaveRight) Grad(grad, x []float64) {
// the minimizer which is located at x=399/250=1.596.
//
// References:
// More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
// ACM Transactions on Mathematical Software 20(3) (1994), 286307, eq. (5.2)
//
// More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
// ACM Transactions on Mathematical Software 20(3) (1994), 286307, eq. (5.2)
type ConcaveLeft struct{}
func (ConcaveLeft) Func(x []float64) float64 {
@@ -1729,8 +1761,9 @@ func (ConcaveLeft) Grad(grad, x []float64) {
// on the derivative is unreliable due to the oscillations.
//
// References:
// More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
// ACM Transactions on Mathematical Software 20(3) (1994), 286307, eq. (5.3)
//
// More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
// ACM Transactions on Mathematical Software 20(3) (1994), 286307, eq. (5.3)
type Plassmann struct {
L float64 // Number of oscillations for |x-1| ≥ Beta.
Beta float64 // Size of the derivative at zero, f'(0) = -Beta.
@@ -1783,10 +1816,10 @@ func (f Plassmann) Grad(grad, x []float64) {
// the parameter values.
//
// References:
// - More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
// ACM Transactions on Mathematical Software 20(3) (1994), 286307, eq. (5.4)
// - Yanai, H., Ozawa, M., and Kaneko, S.: Interpolation methods in one dimensional
// optimization. Computing 27 (1981), 155163
// - More, J.J., and Thuente, D.J.: Line Search Algorithms with Guaranteed Sufficient Decrease.
// ACM Transactions on Mathematical Software 20(3) (1994), 286307, eq. (5.4)
// - Yanai, H., Ozawa, M., and Kaneko, S.: Interpolation methods in one dimensional
// optimization. Computing 27 (1981), 155163
type YanaiOzawaKaneko struct {
Beta1 float64
Beta2 float64

View File

@@ -14,8 +14,9 @@ import (
// values in a unit square centered at the origin.
//
// References:
// Averick, M.B., Carter, R.G., Moré, J.J., Xue, G.-L.: The Minpack-2 Test
// Problem Collection. Preprint MCS-P153-0692, Argonne National Laboratory (1992)
//
// Averick, M.B., Carter, R.G., Moré, J.J., Xue, G.-L.: The Minpack-2 Test
// Problem Collection. Preprint MCS-P153-0692, Argonne National Laboratory (1992)
type MinimalSurface struct {
bottom, top []float64
left, right []float64
@@ -163,10 +164,13 @@ func (ms *MinimalSurface) ExactX() []float64 {
// ExactSolution returns the value of the exact solution to the minimal surface
// problem at (x,y). The exact solution is
// F_exact(x,y) = U^2(x,y) - V^2(x,y),
//
// F_exact(x,y) = U^2(x,y) - V^2(x,y),
//
// where U and V are the unique solutions to the equations
// x = u + uv^2 - u^3/3,
// y = -v - u^2v + v^3/3.
//
// x = u + uv^2 - u^3/3,
// y = -v - u^2v + v^3/3.
func (ms *MinimalSurface) ExactSolution(x, y float64) float64 {
var u = [2]float64{x, -y}
var f [2]float64

View File

@@ -15,11 +15,14 @@ import "math"
// Ackley implements the Ackley function, a function of arbitrary dimension that
// has many local minima. It has a single global minimum of 0 at 0. Its typical
// domain is the hypercube of [-32.768, 32.768]^d.
// f(x) = -20 * exp(-0.2 sqrt(1/d sum_i x_i^2)) - exp(1/d sum_i cos(2π x_i)) + 20 + exp(1)
//
// f(x) = -20 * exp(-0.2 sqrt(1/d sum_i x_i^2)) - exp(1/d sum_i cos(2π x_i)) + 20 + exp(1)
//
// where d is the input dimension.
//
// Reference:
// https://www.sfu.ca/~ssurjano/ackley.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/ackley.html (obtained June 2017)
type Ackley struct{}
func (Ackley) Func(x []float64) float64 {
@@ -35,9 +38,12 @@ func (Ackley) Func(x []float64) float64 {
// Bukin6 implements Bukin's 6th function. The function is two-dimensional, with
// the typical domain as x_0 ∈ [-15, -5], x_1 ∈ [-3, 3]. The function has a unique
// global minimum at [-10, 1], and many local minima.
// f(x) = 100 * sqrt(|x_1 - 0.01*x_0^2|) + 0.01*|x_0+10|
//
// f(x) = 100 * sqrt(|x_1 - 0.01*x_0^2|) + 0.01*|x_0+10|
//
// Reference:
// https://www.sfu.ca/~ssurjano/bukin6.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/bukin6.html (obtained June 2017)
type Bukin6 struct{}
func (Bukin6) Func(x []float64) float64 {
@@ -50,13 +56,18 @@ func (Bukin6) Func(x []float64) float64 {
// CamelThree implements the three-hump camel function, a two-dimensional function
// with three local minima, one of which is global.
// The function is given by
// f(x) = 2*x_0^2 - 1.05*x_0^4 + x_0^6/6 + x_0*x_1 + x_1^2
//
// f(x) = 2*x_0^2 - 1.05*x_0^4 + x_0^6/6 + x_0*x_1 + x_1^2
//
// with the global minimum at
// x^* = (0, 0)
// f(x^*) = 0
//
// x^* = (0, 0)
// f(x^*) = 0
//
// The typical domain is x_i ∈ [-5, 5] for all i.
// Reference:
// https://www.sfu.ca/~ssurjano/camel3.html (obtained December 2017)
//
// https://www.sfu.ca/~ssurjano/camel3.html (obtained December 2017)
type CamelThree struct{}
func (c CamelThree) Func(x []float64) float64 {
@@ -73,13 +84,18 @@ func (c CamelThree) Func(x []float64) float64 {
// CamelSix implements the six-hump camel function, a two-dimensional function.
// with six local minima, two of which are global.
// The function is given by
// f(x) = (4 - 2.1*x_0^2 + x_0^4/3)*x_0^2 + x_0*x_1 + (-4 + 4*x_1^2)*x_1^2
//
// f(x) = (4 - 2.1*x_0^2 + x_0^4/3)*x_0^2 + x_0*x_1 + (-4 + 4*x_1^2)*x_1^2
//
// with the global minima at
// x^* = (0.0898, -0.7126), (-0.0898, 0.7126)
// f(x^*) = -1.0316
//
// x^* = (0.0898, -0.7126), (-0.0898, 0.7126)
// f(x^*) = -1.0316
//
// The typical domain is x_0 ∈ [-3, 3], x_1 ∈ [-2, 2].
// Reference:
// https://www.sfu.ca/~ssurjano/camel6.html (obtained December 2017)
//
// https://www.sfu.ca/~ssurjano/camel6.html (obtained December 2017)
type CamelSix struct{}
func (c CamelSix) Func(x []float64) float64 {
@@ -97,9 +113,12 @@ func (c CamelSix) Func(x []float64) float64 {
// is a two-dimensional function with many local minima, and four global minima
// at (±1.3491, ±1.3491). The function is typically evaluated in the square
// [-10,10]^2.
// f(x) = -0.001(|sin(x_0)sin(x_1)exp(|100-sqrt((x_0^2+x_1^2)/π)|)|+1)^0.1
//
// f(x) = -0.001(|sin(x_0)sin(x_1)exp(|100-sqrt((x_0^2+x_1^2)/π)|)|+1)^0.1
//
// Reference:
// https://www.sfu.ca/~ssurjano/crossit.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/crossit.html (obtained June 2017)
type CrossInTray struct{}
func (CrossInTray) Func(x []float64) float64 {
@@ -115,13 +134,18 @@ func (CrossInTray) Func(x []float64) float64 {
// DixonPrice implements the DixonPrice function, a function of arbitrary dimension
// Its typical domain is the hypercube of [-10, 10]^d.
// The function is given by
// f(x) = (x_0-1)^2 + \sum_{i=1}^{d-1} (i+1) * (2*x_i^2-x_{i-1})^2
//
// f(x) = (x_0-1)^2 + \sum_{i=1}^{d-1} (i+1) * (2*x_i^2-x_{i-1})^2
//
// where d is the input dimension. There is a single global minimum, which has
// a location and value of
// x_i^* = 2^{-(2^{i+1}-2)/(2^{i+1})} for i = 0, ..., d-1.
// f(x^*) = 0
//
// x_i^* = 2^{-(2^{i+1}-2)/(2^{i+1})} for i = 0, ..., d-1.
// f(x^*) = 0
//
// Reference:
// https://www.sfu.ca/~ssurjano/dixonpr.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/dixonpr.html (obtained June 2017)
type DixonPrice struct{}
func (DixonPrice) Func(x []float64) float64 {
@@ -139,9 +163,12 @@ func (DixonPrice) Func(x []float64) float64 {
// DropWave implements the drop-wave function, a two-dimensional function with
// many local minima and one global minimum at 0. The function is typically evaluated
// in the square [-5.12, 5.12]^2.
// f(x) = - (1+cos(12*sqrt(x0^2+x1^2))) / (0.5*(x0^2+x1^2)+2)
//
// f(x) = - (1+cos(12*sqrt(x0^2+x1^2))) / (0.5*(x0^2+x1^2)+2)
//
// Reference:
// https://www.sfu.ca/~ssurjano/drop.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/drop.html (obtained June 2017)
type DropWave struct{}
func (DropWave) Func(x []float64) float64 {
@@ -158,9 +185,12 @@ func (DropWave) Func(x []float64) float64 {
// Eggholder implements the Eggholder function, a two-dimensional function with
// many local minima and one global minimum at [512, 404.2319]. The function
// is typically evaluated in the square [-512, 512]^2.
// f(x) = -(x_1+47)*sin(sqrt(|x_1+x_0/2+47|))-x_1*sin(sqrt(|x_0-(x_1+47)|))
//
// f(x) = -(x_1+47)*sin(sqrt(|x_1+x_0/2+47|))-x_1*sin(sqrt(|x_0-(x_1+47)|))
//
// Reference:
// https://www.sfu.ca/~ssurjano/egg.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/egg.html (obtained June 2017)
type Eggholder struct{}
func (Eggholder) Func(x []float64) float64 {
@@ -175,9 +205,12 @@ func (Eggholder) Func(x []float64) float64 {
// GramacyLee implements the Gramacy-Lee function, a one-dimensional function
// with many local minima. The function is typically evaluated on the domain [0.5, 2.5].
// f(x) = sin(10πx)/(2x) + (x-1)^4
//
// f(x) = sin(10πx)/(2x) + (x-1)^4
//
// Reference:
// https://www.sfu.ca/~ssurjano/grlee12.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/grlee12.html (obtained June 2017)
type GramacyLee struct{}
func (GramacyLee) Func(x []float64) float64 {
@@ -191,11 +224,14 @@ func (GramacyLee) Func(x []float64) float64 {
// Griewank implements the Griewank function, a function of arbitrary dimension that
// has many local minima. It has a single global minimum of 0 at 0. Its typical
// domain is the hypercube of [-600, 600]^d.
// f(x) = \sum_i x_i^2/4000 - \prod_i cos(x_i/sqrt(i)) + 1
//
// f(x) = \sum_i x_i^2/4000 - \prod_i cos(x_i/sqrt(i)) + 1
//
// where d is the input dimension.
//
// Reference:
// https://www.sfu.ca/~ssurjano/griewank.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/griewank.html (obtained June 2017)
type Griewank struct{}
func (Griewank) Func(x []float64) float64 {
@@ -211,9 +247,12 @@ func (Griewank) Func(x []float64) float64 {
// HolderTable implements the Holder table function. The Holder table function
// is a two-dimensional function with many local minima, and four global minima
// at (±8.05502, ±9.66459). The function is typically evaluated in the square [-10,10]^2.
// f(x) = -|sin(x_0)cos(x1)exp(|1-sqrt(x_0^2+x1^2)/π|)|
//
// f(x) = -|sin(x_0)cos(x1)exp(|1-sqrt(x_0^2+x1^2)/π|)|
//
// Reference:
// https://www.sfu.ca/~ssurjano/holder.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/holder.html (obtained June 2017)
type HolderTable struct{}
func (HolderTable) Func(x []float64) float64 {
@@ -228,11 +267,14 @@ func (HolderTable) Func(x []float64) float64 {
// Langermann2 implements the two-dimensional version of the Langermann function.
// The Langermann function has many local minima. The function is typically
// evaluated in the square [0,10]^2.
// f(x) = \sum_1^5 c_i exp(-(1/π)\sum_{j=1}^2(x_j-A_{ij})^2) * cos(π\sum_{j=1}^2 (x_j - A_{ij})^2)
// c = [5]float64{1,2,5,2,3}
// A = [5][2]float64{{3,5},{5,2},{2,1},{1,4},{7,9}}
//
// f(x) = \sum_1^5 c_i exp(-(1/π)\sum_{j=1}^2(x_j-A_{ij})^2) * cos(π\sum_{j=1}^2 (x_j - A_{ij})^2)
// c = [5]float64{1,2,5,2,3}
// A = [5][2]float64{{3,5},{5,2},{2,1},{1,4},{7,9}}
//
// Reference:
// https://www.sfu.ca/~ssurjano/langer.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/langer.html (obtained June 2017)
type Langermann2 struct{}
func (Langermann2) Func(x []float64) float64 {
@@ -258,13 +300,16 @@ func (Langermann2) Func(x []float64) float64 {
// Levy implements the Levy function, a function of arbitrary dimension that
// has many local minima. It has a single global minimum of 0 at 1. Its typical
// domain is the hypercube of [-10, 10]^d.
// f(x) = sin^2(π*w_0) + \sum_{i=0}^{d-2}(w_i-1)^2*[1+10sin^2(π*w_i+1)] +
// (w_{d-1}-1)^2*[1+sin^2(2π*w_{d-1})]
// w_i = 1 + (x_i-1)/4
//
// f(x) = sin^2(π*w_0) + \sum_{i=0}^{d-2}(w_i-1)^2*[1+10sin^2(π*w_i+1)] +
// (w_{d-1}-1)^2*[1+sin^2(2π*w_{d-1})]
// w_i = 1 + (x_i-1)/4
//
// where d is the input dimension.
//
// Reference:
// https://www.sfu.ca/~ssurjano/levy.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/levy.html (obtained June 2017)
type Levy struct{}
func (Levy) Func(x []float64) float64 {
@@ -284,9 +329,12 @@ func (Levy) Func(x []float64) float64 {
// Levy13 implements the Levy-13 function, a two-dimensional function
// with many local minima. It has a single global minimum of 0 at 1. Its typical
// domain is the square [-10, 10]^2.
// f(x) = sin^2(3π*x_0) + (x_0-1)^2*[1+sin^2(3π*x_1)] + (x_1-1)^2*[1+sin^2(2π*x_1)]
//
// f(x) = sin^2(3π*x_0) + (x_0-1)^2*[1+sin^2(3π*x_1)] + (x_1-1)^2*[1+sin^2(2π*x_1)]
//
// Reference:
// https://www.sfu.ca/~ssurjano/levy13.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/levy13.html (obtained June 2017)
type Levy13 struct{}
func (Levy13) Func(x []float64) float64 {
@@ -304,11 +352,14 @@ func (Levy13) Func(x []float64) float64 {
// Rastrigin implements the Rastrigen function, a function of arbitrary dimension
// that has many local minima. It has a single global minimum of 0 at 0. Its typical
// domain is the hypercube of [-5.12, 5.12]^d.
// f(x) = 10d + \sum_i [x_i^2 - 10cos(2π*x_i)]
//
// f(x) = 10d + \sum_i [x_i^2 - 10cos(2π*x_i)]
//
// where d is the input dimension.
//
// Reference:
// https://www.sfu.ca/~ssurjano/rastr.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/rastr.html (obtained June 2017)
type Rastrigin struct{}
func (Rastrigin) Func(x []float64) float64 {
@@ -322,9 +373,12 @@ func (Rastrigin) Func(x []float64) float64 {
// Schaffer2 implements the second Schaffer function, a two-dimensional function
// with many local minima. It has a single global minimum of 0 at 0. Its typical
// domain is the square [-100, 100]^2.
// f(x) = 0.5 + (sin^2(x_0^2-x_1^2)-0.5) / (1+0.001*(x_0^2+x_1^2))^2
//
// f(x) = 0.5 + (sin^2(x_0^2-x_1^2)-0.5) / (1+0.001*(x_0^2+x_1^2))^2
//
// Reference:
// https://www.sfu.ca/~ssurjano/schaffer2.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/schaffer2.html (obtained June 2017)
type Schaffer2 struct{}
func (Schaffer2) Func(x []float64) float64 {
@@ -340,9 +394,12 @@ func (Schaffer2) Func(x []float64) float64 {
// Schaffer4 implements the fourth Schaffer function, a two-dimensional function
// with many local minima. Its typical domain is the square [-100, 100]^2.
// f(x) = 0.5 + (cos(sin(|x_0^2-x_1^2|))-0.5) / (1+0.001*(x_0^2+x_1^2))^2
//
// f(x) = 0.5 + (cos(sin(|x_0^2-x_1^2|))-0.5) / (1+0.001*(x_0^2+x_1^2))^2
//
// Reference:
// https://www.sfu.ca/~ssurjano/schaffer4.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/schaffer4.html (obtained June 2017)
type Schaffer4 struct{}
func (Schaffer4) Func(x []float64) float64 {
@@ -357,11 +414,14 @@ func (Schaffer4) Func(x []float64) float64 {
// Schwefel implements the Schwefel function, a function of arbitrary dimension
// that has many local minima. Its typical domain is the hypercube of [-500, 500]^d.
// f(x) = 418.9829*d - \sum_i x_i*sin(sqrt(|x_i|))
//
// f(x) = 418.9829*d - \sum_i x_i*sin(sqrt(|x_i|))
//
// where d is the input dimension.
//
// Reference:
// https://www.sfu.ca/~ssurjano/schwef.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/schwef.html (obtained June 2017)
type Schwefel struct{}
func (Schwefel) Func(x []float64) float64 {
@@ -375,9 +435,12 @@ func (Schwefel) Func(x []float64) float64 {
// Shubert implements the Shubert function, a two-dimensional function
// with many local minima and many global minima. Its typical domain is the
// square [-10, 10]^2.
// f(x) = (sum_{i=1}^5 i cos((i+1)*x_0+i)) * (\sum_{i=1}^5 i cos((i+1)*x_1+i))
//
// f(x) = (sum_{i=1}^5 i cos((i+1)*x_0+i)) * (\sum_{i=1}^5 i cos((i+1)*x_1+i))
//
// Reference:
// https://www.sfu.ca/~ssurjano/shubert.html (obtained June 2017)
//
// https://www.sfu.ca/~ssurjano/shubert.html (obtained June 2017)
type Shubert struct{}
func (Shubert) Func(x []float64) float64 {