mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/expression] Short-circuit brentMinimum and brentRoot
This commit is contained in:
committed by
EmilieNumworks
parent
bb24c21320
commit
a72e4d43ae
@@ -1019,7 +1019,7 @@ Coordinate2D<double> Expression::nextMinimumOfExpression(const char * symbol, do
|
||||
bool endCondition = false;
|
||||
do {
|
||||
bracketMinimum(symbol, x, step, max, bracket, evaluate, context, complexFormat, angleUnit, expression);
|
||||
result = brentMinimum(symbol, bracket[0], bracket[2], evaluate, context, complexFormat, angleUnit, expression);
|
||||
result = Solver::BrentMinimum(bracket[0], bracket[2], evaluate, context, complexFormat, angleUnit, this, symbol, &expression);
|
||||
x = bracket[1];
|
||||
// Because of float approximation, exact zero is never reached
|
||||
if (std::fabs(result.x1()) < std::fabs(step)*k_solverPrecision) {
|
||||
@@ -1077,19 +1077,6 @@ void Expression::bracketMinimum(const char * symbol, double start, double step,
|
||||
result[2] = NAN;
|
||||
}
|
||||
|
||||
Coordinate2D<double> Expression::brentMinimum(const char * symbol, double ax, double bx, Solver::ValueAtAbscissa evaluation, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, const Expression expression) const {
|
||||
return Solver::BrentMinimum(
|
||||
ax,
|
||||
bx,
|
||||
evaluation,
|
||||
context,
|
||||
complexFormat,
|
||||
angleUnit,
|
||||
this,
|
||||
symbol,
|
||||
&expression);
|
||||
}
|
||||
|
||||
double Expression::nextIntersectionWithExpression(const char * symbol, double start, double step, double max, Solver::ValueAtAbscissa evaluation, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, const Expression expression) const {
|
||||
if (start == max || step == 0.0) {
|
||||
return NAN;
|
||||
@@ -1100,7 +1087,7 @@ double Expression::nextIntersectionWithExpression(const char * symbol, double st
|
||||
double x = start+step;
|
||||
do {
|
||||
bracketRoot(symbol, x, step, max, bracket, evaluation, context, complexFormat, angleUnit, expression);
|
||||
result = brentRoot(symbol, bracket[0], bracket[1], std::fabs(step/precisionByGradUnit), evaluation, context, complexFormat, angleUnit, expression);
|
||||
result = Solver::BrentRoot(bracket[0], bracket[1], std::fabs(step/precisionByGradUnit), evaluation, context, complexFormat, angleUnit, this, symbol, &expression);
|
||||
x = bracket[1];
|
||||
} while (std::isnan(result) && (step > 0.0 ? x <= max : x >= max));
|
||||
|
||||
@@ -1149,20 +1136,6 @@ void Expression::bracketRoot(const char * symbol, double start, double step, dou
|
||||
result[1] = NAN;
|
||||
}
|
||||
|
||||
double Expression::brentRoot(const char * symbol, double ax, double bx, double precision, Solver::ValueAtAbscissa evaluation, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, const Expression expression) const {
|
||||
return Solver::BrentRoot(
|
||||
ax,
|
||||
bx,
|
||||
precision,
|
||||
evaluation,
|
||||
context,
|
||||
complexFormat,
|
||||
angleUnit,
|
||||
this,
|
||||
symbol,
|
||||
&expression);
|
||||
}
|
||||
|
||||
template float Expression::Epsilon<float>();
|
||||
template double Expression::Epsilon<double>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user