Skip to content

Commit

Permalink
fixed files form Math #37
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 103faf6 commit 90f2c86
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions projects/Math/37/org/apache/commons/math/complex/Complex.java
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,15 @@ public Complex sqrt1z() {
* @since 1.2
*/
public Complex tan() {
if (isNaN) {
if (isNaN || Double.isInfinite(real)) {
return NaN;
}
if (imaginary > 20.0) {
return createComplex(0.0, 1.0);
}
if (imaginary < -20.0) {
return createComplex(0.0, -1.0);
}

double real2 = 2.0 * real;
double imaginary2 = 2.0 * imaginary;
Expand Down Expand Up @@ -1060,9 +1066,15 @@ public Complex tan() {
* @since 1.2
*/
public Complex tanh() {
if (isNaN) {
if (isNaN || Double.isInfinite(imaginary)) {
return NaN;
}
if (real > 20.0) {
return createComplex(1.0, 0.0);
}
if (real < -20.0) {
return createComplex(-1.0, 0.0);
}
double real2 = 2.0 * real;
double imaginary2 = 2.0 * imaginary;
double d = FastMath.cosh(real2) + FastMath.cos(imaginary2);
Expand Down

0 comments on commit 90f2c86

Please sign in to comment.