Example usage for org.apache.commons.math3.complex Complex isNaN

List of usage examples for org.apache.commons.math3.complex Complex isNaN

Introduction

In this page you can find the example usage for org.apache.commons.math3.complex Complex isNaN.

Prototype

boolean isNaN

To view the source code for org.apache.commons.math3.complex Complex isNaN.

Click Source Link

Document

Record whether this complex number is equal to NaN.

Usage

From source file:org.nd4j.linalg.util.ComplexUtil.java

/**
 * Raise a complex number to a power//  w  ww. ja  v  a 2s .  com
 *
 * @param num   the number to raise
 * @param power the power to raise to
 * @return the number raised to a power
 */
public static IComplexNumber pow(IComplexNumber num, IComplexNumber power) {
    Complex c = new Complex(num.realComponent().doubleValue(), num.imaginaryComponent().doubleValue())
            .pow(new Complex(power.realComponent().doubleValue(), power.imaginaryComponent().doubleValue()));
    if (c.isNaN())
        c = new Complex(Nd4j.EPS_THRESHOLD, 0.0);
    return Nd4j.createDouble(c.getReal(), c.getImaginary());

}

From source file:org.nd4j.linalg.util.ComplexUtil.java

/**
 * Raise a complex number to a power/*from   ww  w  . j  a va2  s.  c  om*/
 *
 * @param num   the number to raise
 * @param power the power to raise to
 * @return the number raised to a power
 */
public static IComplexNumber pow(IComplexNumber num, double power) {
    Complex c = new Complex(num.realComponent().doubleValue(), num.imaginaryComponent().doubleValue())
            .pow(power);
    if (c.isNaN())
        c = new Complex(Nd4j.EPS_THRESHOLD, 0.0);
    return Nd4j.createDouble(c.getReal(), c.getImaginary());

}