Foundation Classes, math_FunctionRoot - Constructor exception (#1121)

- Guarded `Sol.NbIterations()` calls with `if (Done)` in both `math_FunctionRoot` constructors.
- Prevents `StdFail_NotDone` from being raised during construction when the root is not found.
This commit is contained in:
Vladislav Romashko
2026-02-26 11:35:08 +00:00
committed by GitHub
parent 180906866e
commit 64592d9fcf

View File

@@ -81,10 +81,10 @@ math_FunctionRoot::math_FunctionRoot(math_FunctionWithDerivative& F,
Tol(1) = Tolerance;
math_FunctionSetRoot Sol(Ff, Tol, NbIterations);
Sol.Perform(Ff, V);
Done = Sol.IsDone();
NbIter = Sol.NbIterations();
Done = Sol.IsDone();
if (Done)
{
NbIter = Sol.NbIterations();
F.GetStateNumber();
TheRoot = Sol.Root()(1);
TheDerivative = Sol.Derivative()(1, 1);
@@ -107,10 +107,10 @@ math_FunctionRoot::math_FunctionRoot(math_FunctionWithDerivative& F,
Bb(1) = B;
math_FunctionSetRoot Sol(Ff, Tol, NbIterations);
Sol.Perform(Ff, V, Aa, Bb);
Done = Sol.IsDone();
NbIter = Sol.NbIterations();
Done = Sol.IsDone();
if (Done)
{
NbIter = Sol.NbIterations();
F.GetStateNumber();
TheRoot = Sol.Root()(1);
TheDerivative = Sol.Derivative()(1, 1);