Complex<T> Structure
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
[SerializableAttribute]
public readonly struct Complex<T> : IEquatable<Complex<T>>,
IEquatable<T>, IComparable<Complex<T>>, INumberBase<Complex<T>>,
IFormattable, IParsable<Complex<T>>, ISpanFormattable, ISpanParsable<Complex<T>>,
IUtf8SpanFormattable, IUtf8SpanParsable<Complex<T>>, IAdditionOperators<Complex<T>, Complex<T>, Complex<T>>,
IAdditiveIdentity<Complex<T>, Complex<T>>, IDecrementOperators<Complex<T>>,
IDivisionOperators<Complex<T>, Complex<T>, Complex<T>>, IEqualityOperators<Complex<T>, Complex<T>, bool>,
IIncrementOperators<Complex<T>>, IMultiplicativeIdentity<Complex<T>, Complex<T>>,
IMultiplyOperators<Complex<T>, Complex<T>, Complex<T>>, ISubtractionOperators<Complex<T>, Complex<T>, Complex<T>>,
IUnaryNegationOperators<Complex<T>, Complex<T>>, IUnaryPlusOperators<Complex<T>, Complex<T>>
- Implements
- IComparable<Complex<T>>, IEquatable<Complex<T>>, IEquatable<T>, IFormattable, IParsable<Complex<T>>, ISpanFormattable, ISpanParsable<Complex<T>>, IUtf8SpanFormattable, IUtf8SpanParsable<Complex<T>>, IAdditionOperators<Complex<T>, Complex<T>, Complex<T>>, IAdditiveIdentity<Complex<T>, Complex<T>>, IDecrementOperators<Complex<T>>, IDivisionOperators<Complex<T>, Complex<T>, Complex<T>>, IEqualityOperators<Complex<T>, Complex<T>, Boolean>, IIncrementOperators<Complex<T>>, IMultiplicativeIdentity<Complex<T>, Complex<T>>, IMultiplyOperators<Complex<T>, Complex<T>, Complex<T>>, INumberBase<Complex<T>>, ISubtractionOperators<Complex<T>, Complex<T>, Complex<T>>, IUnaryNegationOperators<Complex<T>, Complex<T>>, IUnaryPlusOperators<Complex<T>, Complex<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
<i>x</i><sup>2</sup> = -1
#8211;1
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. |
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 magnitude, modulus or absolute value of a complex number. |
Magnitude | Returns the square of the modulus of a complex number. |
One | 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( | Gets the inverse cosine of a real number. |
Acos( | Gets the inverse cosine of a complex number. |
Acosh | Gets the inverse hyperbolic cosine of a complex number. |
Add( | Adds a complex number to a real number. |
Add( | Adds a complex number to a real number. |
Add( | Adds two complex numbers. |
Arg | Returns the argument of a complex number. |
Asin( | Gets the inverse sine of a real number. |
Asin( | 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. |
Cbrt | Returns the first square root of a complex number. |
Conjugate() | Returns the conjugate of this complex number. |
Conjugate( | Returns the conjugate of a complex number. |
Conjugate | 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( | Divides a real number by a complex number. |
Divide( | Divides a complex number by a real number. |
Divide( | Divides a complex number by another. |
Equals( | Compares a complex number to a real number. |
Equals( | Compares a complex number to another complex number. |
Equals( |
Overridden. Returns whether this
instance is equal to a specified object.
(Overrides ValueType.Equals(Object)) |
Exp | Returns e raised to the specified power. |
Exp10 | Returns 10 raised to the specified power. |
Exp2 | Returns 2 raised to the specified power. |
Exp | Evaluates the exponential function for an imaginary argument. |
Exp | Computes E raised to a given power and subtracts one. |
From | Constructs a complex number from polar elements. |
Get |
Overridden. Returns the hash code for this instance.
(Overrides ValueType.GetHashCode()) |
Get | Returns an array of Doubles that contains the imaginary parts of an array of complex numbers. |
Get | Returns an array of Doubles that contains the real parts of an array of complex numbers. |
Get | Gets 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. |
IsNa | Indicates whether a complex number is undefined. |
Log( | Returns the natural logarithm of a complex number. |
Log( | Returns the logarithm of a complex number to the specified base. |
Log10 | Returns the base 10 logarithm of a complex number. |
Log2 | Returns the base 2 logarithm of a complex number. |
Multiply( | Multiplies a complex number and a real number. |
Multiply( | Multiplies a complex number and a real number. |
Multiply( | Multiplies two complex numbers. |
Negate | Negates a complex number. |
Parse( | Parses a span of characters into a value. |
Parse( | Parses a string into a value. |
Parse( | Parses a span of characters into a value. |
Parse( | Parses a string into a value. |
Plus | Applies the unary plus operator to a complex number. |
Pow( | Returns a complex number raised to the specified power. |
Pow( | Returns a complex number raised to the specified power. |
Pow( | Returns a complex number raised to the specified integer power. |
Reciprocal | Returns the reciprocal of a complex number. |
Root | Returns a complex number that is the specified root of unity of the specified degree. |
Sin | Gets the sine of a complex number. |
Sin | Gets the sine and cosine of a complex number. |
Sinh | Gets the hyperbolic sine of a complex number. |
Sqrt( | Returns the first square root of a real number. |
Sqrt( | Returns the first square root of a complex number. |
Subtract( | Subtracts a complex number from a real number. |
Subtract( | Subtracts a real number from a complex number. |
Subtract( | 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( | Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information. |
ToString( | Converts the numeric value of this instance to its equivalent string representation using the specified format. |
ToString( | Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information. |
Try | Tries to format the value of the current instance into the provided span of characters. |
Try | Tries to parse a span of characters into a value. |
Try | Tries to parse a string into a value. |
Try | Tries to parse a span of characters into a value. |
Try | Tries to parse a string into a value. |
Operators
Addition( | Adds a complex number to a real number. |
Addition( | Adds a complex number to a real number. |
Addition( | Adds two complex numbers. |
Decrement( | Decrements the real part of a complex number by one. |
Division( | Divides a real number by a complex number. |
Division( | Divides a complex number by a real number. |
Division( | Divides a complex number by another. |
Equality( | Compares a complex number and a real number for equality. |
Equality( | Compares a complex number and a real number for equality. |
Equality( | 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( | Represents the exponentiation operator. |
Exponent( | Represents the exponentiation operator. |
Exponent( | Represents the exponentiation operator. |
Exponentiation( | Represents the exponentiation operator. |
Exponentiation( | Represents the exponentiation operator. |
Exponentiation( | 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( | Increments the real part of a complex number by one. |
Inequality( | Compares a complex number and a real number for inequality. |
Inequality( | Compares a complex number and a real number for inequality. |
Inequality( | Compares two complex numbers for inequality. |
Multiply( | Multiplies a complex number and a real number. |
Multiply( | Multiplies a complex number and a real number. |
Multiply( | Multiplies two complex numbers. |
Subtraction( | Subtracts a complex number from a real number. |
Subtraction( | Subtracts a real number from a complex number. |
Subtraction( | Subtracts two complex numbers. |
Unary | Negates a complex number. |
Unary | 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. |