66 void setType(std::string
const typeString);
72#ifndef N2P2_NO_ASYM_POLY
89 double f(
double x)
const;
95 double df(
double x)
const;
102 void fdf(
double x,
double& fx,
double& dfx)
const;
107 std::vector<std::string>
info()
const;
110 static double const PI;
112 static double const E;
115#ifndef N2P2_NO_ASYM_POLY
129 double fCOS(
double x)
const;
130 double dfCOS(
double x)
const;
131 void fdfCOS(
double x,
double& fx,
double& dfx)
const;
133 double fPOLY1(
double x)
const;
134 double dfPOLY1(
double x)
const;
135 void fdfPOLY1(
double x,
double& fx,
double& dfx)
const;
137 double fPOLY2(
double x)
const;
138 double dfPOLY2(
double x)
const;
139 void fdfPOLY2(
double x,
double& fx,
double& dfx)
const;
141 double fPOLY3(
double x)
const;
142 double dfPOLY3(
double x)
const;
143 void fdfPOLY3(
double x,
double& fx,
double& dfx)
const;
145 double fPOLY4(
double x)
const;
146 double dfPOLY4(
double x)
const;
147 void fdfPOLY4(
double x,
double& fx,
double& dfx)
const;
149 double fEXP(
double x)
const;
150 double dfEXP(
double x)
const;
151 void fdfEXP(
double x,
double& fx,
double& dfx)
const;
160#ifndef N2P2_NO_ASYM_POLY
173#ifndef N2P2_NO_ASYM_POLY
176 return (this->*
fPtr)(x);
181#ifndef N2P2_NO_ASYM_POLY
182 if (
asymmetric)
return (2.0 - 2.0 * x) * (this->*
dfPtr)((2.0 - x) * x);
183 else return (this->*
dfPtr)(x);
185 return (this->*
dfPtr)(x);
191#ifndef N2P2_NO_ASYM_POLY
194 (this->*
fdfPtr)((2.0 - x) * x, fx, dfx);
195 dfx *= 2.0 - 2.0 * x;
197 else (this->*
fdfPtr)(x, fx, dfx);
199 (this->*
fdfPtr)(x, fx, dfx);
206 return 0.5 * (cos(
PI * x) + 1.0);
211 return -
PI_2 * sin(
PI * x);
216 double const temp = cos(
PI * x);
217 fx = 0.5 * (temp + 1.0);
218 dfx = -0.5 *
PI * sqrt(1.0 - temp * temp);
224 return (2.0 * x - 3.0) * x * x + 1.0;
229 return x * (6.0 * x - 6.0);
234 fx = (2.0 * x - 3.0) * x * x + 1.0;
235 dfx = x * (6.0 * x - 6.0);
241 return ((15.0 - 6.0 * x) * x - 10.0) * x * x * x + 1.0;
246 return x * x * ((60.0 - 30.0 * x) * x - 30.0);
251 double const x2 = x * x;
252 fx = ((15.0 - 6.0 * x) * x - 10.0) * x * x2 + 1.0;
253 dfx = x2 * ((60.0 - 30.0 * x) * x - 30.0);
259 double const x2 = x * x;
260 return (x * (x * (20.0 * x - 70.0) + 84.0) - 35.0) * x2 * x2 + 1.0;
265 return x * x * x * (x * (x * (140.0 * x - 420.0) + 420.0) - 140.0);
270 double const x2 = x * x;
271 fx = (x * (x * (20.0 * x - 70.0) + 84.0) - 35.0) * x2 * x2 + 1.0;
272 dfx = x2 * x * (x * (x * (140.0 * x - 420.0) + 420.0) - 140.0);
278 double const x2 = x * x;
279 return (x * (x * ((315.0 - 70.0 * x) * x - 540.0) + 420.0) - 126.0) *
285 double const x2 = x * x;
287 (x * (x * ((2520.0 - 630.0 * x) * x - 3780.0) + 2520.0) - 630.0);
294 fx = (x * (x * ((315.0 - 70.0 * x) * x - 540.0) + 420.0) - 126.0) *
297 (x * (x * ((2520.0 - 630.0 * x) * x - 3780.0) + 2520.0) - 630.0);
303 return E * exp(1.0 / (x * x - 1.0));
308 double const temp = 1.0 / (x * x - 1.0);
309 return -2.0 *
E * x * temp * temp * exp(temp);
314 double const temp = 1.0 / (x * x - 1.0);
315 double const temp2 = exp(temp);
317 dfc = -2.0 *
E * x * temp * temp * temp2;
double fPOLY4(double x) const
double dfPOLY2(double x) const
double fCOS(double x) const
void fdfEXP(double x, double &fx, double &dfx) const
void setAsymmetric(bool asymmetric)
Set asymmetric property.
std::vector< std::string > info() const
Get string with formula of compact function.
double fPOLY1(double x) const
Type type
Core function type.
void fdfPOLY3(double x, double &fx, double &dfx) const
double dfPOLY4(double x) const
void fdf(double x, double &fx, double &dfx) const
Calculate function and derivative at once.
void(CoreFunction::* fdfPtr)(double x, double &fx, double &dfx) const
Function pointer to fdf.
double dfEXP(double x) const
double(CoreFunction::* dfPtr)(double x) const
Function pointer to df.
double dfPOLY3(double x) const
double fEXP(double x) const
double df(double x) const
Calculate derivative of function at argument .
void fdfPOLY4(double x, double &fx, double &dfx) const
double dfCOS(double x) const
bool asymmetric
Enables asymmetry modification (use with polynomials).
void fdfPOLY1(double x, double &fx, double &dfx) const
void setType(Type const type)
Set function type.
Type getType() const
Getter for type.
void fdfCOS(double x, double &fx, double &dfx) const
double fPOLY2(double x) const
void fdfPOLY2(double x, double &fx, double &dfx) const
double dfPOLY1(double x) const
double f(double x) const
Calculate function value .
Type
List of available function types.
CoreFunction()
Constructor, initializes to #Type::POLY2.
double fPOLY3(double x) const
bool getAsymmetric() const
Getter for asymmetric.
double(CoreFunction::* fPtr)(double x) const
Function pointer to f.