Skip to content

Commit

Permalink
Changed comparison to new complex to compare magnitudes
Browse files Browse the repository at this point in the history
  • Loading branch information
StaticBeagle committed Jan 1, 2025
1 parent e11c7df commit f8a5582
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public SolverResults<Complex> solve() {
if (derivative != null) {
while (currentIteration++ < maxNumberOfIterations) {
Complex funcValue = func.evaluateAt(xCurrent);
if (Objects.equals(funcValue, new Complex())) {
if (funcValue.abs() == 0) {
double error = xFinal.subtract(xCurrent).abs();
SolverResults<Complex> solverResults = new SolverResults<>();
solverResults.setSolverStatus("Converged");
Expand All @@ -134,7 +134,7 @@ public SolverResults<Complex> solve() {
return solverResults;
}
Complex funcDerivativeValue = derivative.evaluateAt(xCurrent);
if (Objects.equals(funcDerivativeValue, new Complex())) {
if (funcDerivativeValue.abs() == 0) {
double error = xFinal.subtract(xCurrent).abs();
SolverResults<Complex> solverResults = new SolverResults<>();
solverResults.setSolverStatus("Derivative was zero");
Expand Down

0 comments on commit f8a5582

Please sign in to comment.