Complex<T> Structure

Represents a generic complex value.

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
C#
[SerializableAttribute]
public readonly struct Complex<T> : IEquatable<Complex<T>>, 
	IEquatable<T>, IComparable<Complex<T>>
Inheritance
Object  →  ValueType  →  Complex<T>
Implements
IComparable<Complex<T>>, IEquatable<Complex<T>>, IEquatable<T>

Type Parameters

T

Remarks

The complex value type represents a complex value made of real and imaginary parts of type T.

Complex numbers arise in algebra in the solution of quadratic equations. The equation x2= –R.One does not have any real solutions. However, if we define a new number, i as the square root of -R.One, then we have two solutions: i and -i.

This, in turn, gives rise to an entirely new class of numbers of the form a + ib with a and b real, and i defined as above. These are the complex numbers.

The complex structure provides methods for all the common operations on complex numbers. The Re property returns the real element of the complex number, while Im returns the imaginary part. Because the complex numbers don't have a natural ordering, only equality and inequality operators are available.

Overloaded versions of the major arithmetic operators are provided for languages that support them. For languages that don't support operator overloading, equivalent static methods are supplied.

When performing binary operations, if one of the operands is a complex, then the other operand is required to be either of type complex or . Prior to performing the operation, if the other operand is not a complex, it is converted to complex. If the operation produces a numeric result, the type of the result is complex.

Exceptions to this are methods that return a real property of a complex number: Phase, Magnitude, MagnitudeSquared and Abs(Complex<T>). These methods return a T value.

If T is a floating-point type, then operations including the assignment operators, do not throw exceptions. Instead, in exceptional situations, the result of a floating-point operation is zero, Infinity, or NaN, as described below:

  • If the result of a complex floating-point operation is too small for the destination format, the result of the operation is zero.
  • If the magnitude of the complex result of a floating-point operation is too large for the destination format, the result of the operation is Infinity. Directed infinities are currently not supported.
  • If a complex floating-point operation is invalid, the result of the operation is NaN.
  • If one or both operands of a complex floating-point operation are NaN, the result of the operation is NaN.

Many elementary functions have been extended to the complex domain. These are implemented by static methods.

Some of these functions are multi-valued. If there is one real argument, then any symmetry or anti-symmetry about the origin is preserved. For example, the inverse sine function satisfies asin(-x) == -asin(x) for -1 <= x <= 1. The Asin(Complex<T>) method satisfies this relationship for any real value of x.

For complex arguments, the identity Conjugate(f(x)) == f(Conjugate(x)) is preserved. The branch cuts for all complex functions defined here are along either the real or the imaginary axis. Along the branch cuts, the functions have different values depending on whether the zero element is normal (positive) zero or negative zero.

The real and imaginary parts of complex numbers are real numbers.

Constructors

Complex<T>(T) Constructs a complex number from a real number.
Complex<T>(T, T) Constructs a complex number from its real and imaginary parts.
Complex<T>(T, T, Boolean) Constructs a complex number from rectangular or polar elements.
Obsolete.

Properties

Im Gets the imaginary part of the complex number.
IsImaginary Indicates whether a complex number is a pure imaginary number.
IsReal Indicates whether a complex number is, in fact, real.
IsZero Indicates whether a complex number is equal to zero.
Magnitude Gets the modulus or absolute value of a complex number.
MagnitudeSquared Returns the square of the modulus of a complex number.
OneNorm Returns the sum of the absolute values of the real and the imaginary part of the complex number.
Phase Gets the phase or argument of a complex number.
Re Gets the real part of the complex number.

Methods

Abs Returns the absolute value of a complex number.
Acos(T) Gets the inverse cosine of a real number.
Acos(Complex<T>) Gets the inverse cosine of a complex number.
Acosh Gets the inverse hyperbolic cosine of a complex number.
Add(T, Complex<T>) Adds a complex number to a real number.
Add(Complex<T>, T) Adds a complex number to a real number.
Add(Complex<T>, Complex<T>) Adds two complex numbers.
Arg Returns the argument of a complex number.
Asin(T) Gets the inverse sine of a real number.
Asin(Complex<T>) Gets the inverse sine of a complex number.
Asinh Gets the inverse hyperbolic sine of a complex number.
Atan Gets the inverse tangent of a complex number.
Atanh Gets the inverse hyperbolic tangent of a complex number.
Conjugate() Returns the conjugate of this complex number.
Conjugate(Complex<T>) Returns the conjugate of a complex number.
ConjugateMultiply Multiplies the Conjugate() of a complex number and a second complex number.
Cos Gets the cosine of a complex number.
Cosh Gets the hyperbolic cosine of a complex number.
Deconstruct Deconstructs a complex number into its real and complex parts.
Decrement Decrements the real part of a complex number by one.
Divide(T, Complex<T>) Divides a real number by a complex number.
Divide(Complex<T>, T) Divides a complex number by a real number.
Divide(Complex<T>, Complex<T>) Divides a complex number by another.
Equals(T) Compares a complex number to a real number.
Equals(Complex<T>) Compares a complex number to another complex number.
Equals(Object) Overridden. Returns a value indicating whether this instance is equal to a specified object.
(Overrides ValueType.Equals(Object))
Exp Returns e raised to the specified power.
ExpI Evaluates the exponential function for an imaginary argument.
FromPolar Constructs a complex number from polar elements.
GetHashCode Overridden. Returns the hash code for this instance.
(Overrides ValueType.GetHashCode())
GetImaginaryPart Returns an array of Doubles that contains the imaginary parts of an array of complex numbers.
GetRealPart Returns an array of Doubles that contains the real parts of an array of complex numbers.
GetTypeGets the Type of the current instance.
(Inherited from Object)
Imaginary Constructs a complex number that has a purely imaginary value.
Increment Increments the real part of a complex number by one.
IsInfinity Indicates whether a complex number is infinite.
IsNaN Indicates whether a complex number is undefined.
Log(Complex<T>) Returns the natural logarithm of a complex number.
Log(Complex<T>, Complex<T>) Returns the logarithm of a complex number to the specified base.
Log10 Returns the base 10 logarithm of a complex number.
Multiply(T, Complex<T>) Multiplies a complex number and a real number.
Multiply(Complex<T>, T) Multiplies a complex number and a real number.
Multiply(Complex<T>, Complex<T>) Multiplies two complex numbers.
Negate Negates a complex number.
Plus Applies the unary plus operator to a complex number.
Pow(Complex<T>, T) Returns a complex number raised to the specified power.
Pow(Complex<T>, Complex<T>) Returns a complex number raised to the specified power.
Pow(Complex<T>, Int32) Returns a complex number raised to the specified integer power.
Reciprocal Returns the reciprocal of a complex number.
RootOfUnity Returns a complex number that is the specified root of unity of the specified degree.
Sin Gets the sine of a complex number.
Sinh Gets the hyperbolic sine of a complex number.
Sqrt(T) Returns the first square root of a real number.
Sqrt(Complex<T>) Returns the first square root of a complex number.
Subtract(T, Complex<T>) Subtracts a complex number from a real number.
Subtract(Complex<T>, T) Subtracts a real number from a complex number.
Subtract(Complex<T>, Complex<T>) Subtracts two complex numbers.
Tan Gets the tangent of a complex number.
Tanh Gets the hyperbolic tangent of a complex number.
ToString() Converts the numeric value of this instance to its equivalent string representation.
(Overrides ValueType.ToString())
ToString(IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
ToString(String) Converts the numeric value of this instance to its equivalent string representation using the specified format.
ToString(String, IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.

Operators

Addition(T, Complex<T>) Adds a complex number to a real number.
Addition(Complex<T>, T) Adds a complex number to a real number.
Addition(Complex<T>, Complex<T>) Adds two complex numbers.
Decrement(Complex<T>) Decrements the real part of a complex number by one.
Division(T, Complex<T>) Divides a real number by a complex number.
Division(Complex<T>, T) Divides a complex number by a real number.
Division(Complex<T>, Complex<T>) Divides a complex number by another.
Equality(T, Complex<T>) Compares a complex number and a real number for equality.
Equality(Complex<T>, T) Compares a complex number and a real number for equality.
Equality(Complex<T>, Complex<T>) Compares two complex numbers for equality.
Explicit(Complex<T> to T) Casts a complex number to a real number. The imaginary part must be zero.
Exponent(Complex<T>, T) Represents the exponentiation operator.
Exponent(Complex<T>, Complex<T>) Represents the exponentiation operator.
Exponent(Complex<T>, Int32) Represents the exponentiation operator.
Exponentiation(Complex<T>, T) Represents the exponentiation operator.
Exponentiation(Complex<T>, Complex<T>) Represents the exponentiation operator.
Exponentiation(Complex<T>, Int32) Represents the exponentiation operator.
Implicit(T to Complex<T>) Implicitly casts a real number to a complex type.
Implicit(ValueTuple<T, T> to Complex<T>) Implicitly casts a tuple of two real numbers to a complex type.
Increment(Complex<T>) Increments the real part of a complex number by one.
Inequality(T, Complex<T>) Compares a complex number and a real number for inequality.
Inequality(Complex<T>, T) Compares a complex number and a real number for inequality.
Inequality(Complex<T>, Complex<T>) Compares two complex numbers for inequality.
Multiply(T, Complex<T>) Multiplies a complex number and a real number.
Multiply(Complex<T>, T) Multiplies a complex number and a real number.
Multiply(Complex<T>, Complex<T>) Multiplies two complex numbers.
Subtraction(T, Complex<T>) Subtracts a complex number from a real number.
Subtraction(Complex<T>, T) Subtracts a real number from a complex number.
Subtraction(Complex<T>, Complex<T>) Subtracts two complex numbers.
UnaryNegation(Complex<T>) Negates a complex number.
UnaryPlus(Complex<T>) Applies the unary plus operator to a complex number.

Fields

I Represents the square root of -1.
Infinity Represents complex infinity.
NaN Represents complex NaN, or Not a Number.
One Represents the complex number one.
Zero Represents the complex number zero.

See Also