Skip to content

Commit

Permalink
disable atan2 checks (slow and more confusing)
Browse files Browse the repository at this point in the history
  • Loading branch information
bourgesl committed Oct 3, 2024
1 parent bce9666 commit 33da7fb
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/main/java/fr/jmmc/jmcs/util/NumberUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ public final class NumberUtils {

/** Smallest positive number used in double comparisons (rounding). */
public final static double EPSILON = 1e-6;
/* PI and PI/2 constants */
public final static double PI = Math.PI;
public final static double PI_HALF = PI / 2.0;
/** Typical scale precision in re/im comparisons (rounding). */
public static final double ARG_EPSILON = Math.ulp(1.0);
/* shared Double instances */
/** shared Double = NaN instance */
public final static Double DBL_NAN = Double.valueOf(Double.NaN);
Expand All @@ -71,25 +66,6 @@ public static double getArgumentInDegrees(final double re, final double im) {
}

public static double getArgument(final double re, final double im) {
// check |re| == 0
final double normRe = Math.abs(re);
if (normRe == 0.0) {
return (im >= 0.0) ? PI_HALF : -PI_HALF;
}
// check |im| == 0
final double normIm = Math.abs(im);
if (normIm == 0.0) {
return (re >= 0.0) ? 0.0 : PI;
}
final double epsilon = ARG_EPSILON * (normRe + normIm);
// check |re| << |im| or |im| << |re|
if (normIm <= epsilon) {
return (re >= 0.0) ? 0.0 : PI;
}
// check |im| << |re|
if (normRe <= epsilon) {
return (im >= 0.0) ? PI_HALF : -PI_HALF;
}
return Math.atan2(im, re);
}

Expand Down

0 comments on commit 33da7fb

Please sign in to comment.