Package org.hipparchus.complex
Class ComplexUtils
java.lang.Object
org.hipparchus.complex.ComplexUtils
Static implementations of common
Complex
utilities functions.-
Method Summary
Modifier and TypeMethodDescriptionstatic Complex[]
convertToComplex
(double[] real) Convert an array of primitive doubles to an array ofComplex
objects.static Complex
polar2Complex
(double r, double theta) Creates a complex number from the given polar representation.static <T extends CalculusFieldElement<T>>
FieldComplex<T>polar2Complex
(T r, T theta) Creates a complex number from the given polar representation.
-
Method Details
-
polar2Complex
Creates a complex number from the given polar representation.The value returned is
r·ei·theta
, computed asr·cos(theta) + r·sin(theta)i
If either
r
ortheta
is NaN, ortheta
is infinite,Complex.NaN
is returned.If
r
is infinite andtheta
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 createtheta
- the argument of the complex number to create- Returns:
r·ei·theta
- Throws:
MathIllegalArgumentException
- ifr
is negative.
-
polar2Complex
public static <T extends CalculusFieldElement<T>> FieldComplex<T> polar2Complex(T r, T theta) throws MathIllegalArgumentException Creates a complex number from the given polar representation.The value returned is
r·ei·theta
, computed asr·cos(theta) + r·sin(theta)i
If either
r
ortheta
is NaN, ortheta
is infinite,Complex.NaN
is returned.If
r
is infinite andtheta
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
- Type Parameters:
T
- type of the field elements- Parameters:
r
- the modulus of the complex number to createtheta
- the argument of the complex number to create- Returns:
r·ei·theta
- Throws:
MathIllegalArgumentException
- ifr
is negative.- Since:
- 2.0
-
convertToComplex
Convert an array of primitive doubles to an array ofComplex
objects.- Parameters:
real
- Array of numbers to be converted to theirComplex
equivalent.- Returns:
- an array of
Complex
objects.
-