org.apache.commons.math3.complex

## Class ComplexUtils

- java.lang.Object
- - org.apache.commons.math3.complex.ComplexUtils

-     public class ComplexUtils
      extends java.lang.Object

  Static implementations of common `Complex` utilities functions.
  Version:
    $Id: ComplexUtils.java 1416643 2012-12-03 19:37:14Z tn $

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `ComplexUtils()` Default constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Complex[]` | `convertToComplex(double[] real)` Convert an array of primitive doubles to an array of `Complex` objects.
    `static Complex` | `polar2Complex(double r, double theta)` Creates a complex number from the given polar representation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ComplexUtils

          private ComplexUtils()

      Default constructor.

  - ### Method Detail

    - #### polar2Complex

          public static Complex polar2Complex(double r,
                              double theta)
                                       throws MathIllegalArgumentException

      Creates a complex number from the given polar representation.

      The value returned is `r·ei·theta`, computed as `r·cos(theta) + r·sin(theta)i`

      If either `r` or `theta` is NaN, or `theta` is infinite, `Complex.NaN` is returned.

      If `r` is infinite and `theta` is finite, infinite or NaN values may be returned in parts of the result, following the rules for double arithmetic.

           Examples:

           polar2Complex(INFINITY, π/4) = INFINITY + INFINITY i
           polar2Complex(INFINITY, 0) = INFINITY + NaN i
           polar2Complex(INFINITY, -π/4) = INFINITY - INFINITY i
           polar2Complex(INFINITY, 5π/4) = -INFINITY - INFINITY i

      Parameters:
        `r` - the modulus of the complex number to create
        `theta` - the argument of the complex number to create
      Returns:
        `r·ei·theta`
      Throws:
        `MathIllegalArgumentException` - if `r` is negative.
      Since:
        1.1

    - #### convertToComplex

          public static Complex[] convertToComplex(double[] real)

      Convert an array of primitive doubles to an array of `Complex` objects.
      Parameters:
        `real` - Array of numbers to be converted to their `Complex` equivalent.
      Returns:
        an array of `Complex` objects.
      Since:
        3.1

Copyright (c) 2003-2013 Apache Software Foundation