Struct VectorC
- Namespace
- VirtualLabAPI.Core.Numerics
- Assembly
- VirtualLabAPI.dll
This struct defines a two-dimensional vector of complex numbers. Operators \(a+b\), \(a-b\) and \(a|b\) (Scalar product) can be used. One operand on \(a*b\), \(a/b\) (applied separate on components) can also be a Complex. Implicit casting from VectorD is supported.
[Serializable]
public struct VectorC
- Inherited Members
Constructors
VectorC(Complex, Complex)
Creates a VectorC from two Complex values.
public VectorC(Complex x, Complex y)
Parameters
VectorC(VectorC)
Creates a new VectorC object from an existing object.
public VectorC(VectorC vec)
Parameters
vecVectorCVectorC object to copy.
VectorC(VectorD, VectorD)
Creates a VectorC from two VectorD objects. The first VectorD stands for the real part of x- and y-component and the second VectorD stands for the imaginary part of the two components.
public VectorC(VectorD Re, VectorD Im)
Parameters
ReVectorDReal part of x- and y-component of the new VectorC.
ImVectorDImaginary part of x- and y-component of the new VectorC.
Fields
UnitVectorX
A constant containing the unit vector in x-direction.
public static readonly VectorC UnitVectorX
Field Value
UnitVectorY
A constant containing the unit vector in y-direction.
public static readonly VectorC UnitVectorY
Field Value
X
x-value of this VectorC object.
public Complex X
Field Value
Y
y-value of this VectorC object.
public Complex Y
Field Value
ZeroVector
A constant containing the zero vector (0, 0).
public static readonly VectorC ZeroVector
Field Value
Properties
Im
Sets or gets a VectorD object containing the imaginary part of the x- and y-components of this VectorC object.
public VectorD Im { get; set; }
Property Value
Re
Sets or gets a VectorD object containing the real part of the x- and y-components of this VectorC object.
public VectorD Re { get; set; }
Property Value
Methods
Abs()
Calculates the absolute value of this VectorC object. The absolute value is defined as the square root of the Norm().
public double Abs()
Returns
- double
The absolute value of this VectorC.
Equals(object)
This function compares the values of this vector and the vector given as parameter.
public override bool Equals(object obj)
Parameters
objobjectVectorC to be compared with this vector.
Returns
- bool
Returns true if both object values are equal.
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Norm()
Calculates the norm of this VectorC object.
The norm is defined as (X * Complex.Conjugate(X) + Y * Complex.Conjugate(Y)).Re which is equal to the sum of the norms of the vector components.
public double Norm()
Returns
- double
The norm of this VectorC object.
Normalize()
Normalizes this VectorC object.
public void Normalize()
Parse(string, ComplexToStringConversionFormat, NumberFormatInfo)
Parse function for the VectorC class
public static VectorC Parse(string vectorCAsString, ComplexToStringConversionFormat complexNumberFormat, NumberFormatInfo doubleFormat = null)
Parameters
vectorCAsStringstringThe string which should be parsed.
complexNumberFormatComplexToStringConversionFormatThe format of the complex numbers (real / imaginary, amplitude / phase and so on).
doubleFormatNumberFormatInfoThe format of the double numbers, especially the decimal separator. If this optional parameter is not specified the default format ('.' as decimal separator) is used.
Returns
- VectorC
the VectorC object which was parsed from input string
Exceptions
- ArgumentException
The VectorC could not be parsed.
Sqrt()
Calculates the square roots of the components of this VectorC object and returns them as new vector.
public VectorC Sqrt()
Returns
- VectorC
The square root of the components of this VectorC object.
ToString()
Converts this VectorC to a string using the format (real / imaginary, amplitude / phase and so on) defined by the FormatOfComplexNumbers.
public override string ToString()
Returns
- string
String containing the VectorC information.
ToString(ComplexToStringConversionFormat, int)
Converts this VectorC to a string.
public string ToString(ComplexToStringConversionFormat complexNumberFormat, int numberOfDigits)
Parameters
complexNumberFormatComplexToStringConversionFormatThe complex number format (real / imaginary, amplitude / phase and so on) to be used for the conversion.
numberOfDigitsintThe number of significant digits.
Returns
- string
String containing the \markAsCode{VectorC} information.
Operators
operator +(VectorC, VectorC)
Adds two VectorC objects.
public static VectorC operator +(VectorC a, VectorC b)
Parameters
Returns
- VectorC
Returns the sum of the two VectorC objects.
operator |(VectorC, VectorC)
Calculates the scalar product of two VectorC objects.
The scalar product is defined as a.X * b.X + a.Y * b.Y.
public static Complex operator |(VectorC a, VectorC b)
Parameters
Returns
- Complex
Scalar product of the two VectorC objects.
operator /(Complex, VectorC)
Performs a component-wise division of a double value and a VectorC object.
The result is defined as new VectorC(number / vector.X, number / vector.Y).
public static VectorC operator /(Complex number, VectorC vector)
Parameters
numberComplexThe double value to divide by the components of the VectorD object.
vectorVectorCThe VectorC object used as divisor.
Returns
- VectorC
Returns the quotient of the double value and the VectorC object.
operator /(VectorC, Complex)
public static VectorC operator /(VectorC vector, Complex divisor)
Parameters
vectorVectorCThe VectorC object to divide by the Complex value.
divisorComplexThe Complex value used as divisor.
Returns
- VectorC
Returns the quotient of the VectorC object and the Complex value.
operator /(VectorC, VectorC)
Performs a component-wise division of two VectorC objects.
public static VectorC operator /(VectorC a, VectorC b)
Parameters
aVectorCThe first VectorC object to divide by parameter b.
bVectorCThe second VectorC object used as divisor.
Returns
- VectorC
Returns the quotient of the two VectorC objects.
operator ==(VectorC, VectorC)
Compares two VectorC for equality. The comparison will be done by comparing the values of the two x- and y- components respectively.
public static bool operator ==(VectorC vector1, VectorC vector2)
Parameters
Returns
- bool
Returns true if the two objects are equal.
implicit operator VectorC(VectorD)
public static implicit operator VectorC(VectorD vectorD)
Parameters
vectorDVectorDVectorD object to convert into a VectorC object.
Returns
- VectorC
The converted VectorC object.
operator !=(VectorC, VectorC)
Compares two VectorC for inequality. The comparison will be done by comparing the values of the two x- and y- components respectively.
public static bool operator !=(VectorC vector1, VectorC vector2)
Parameters
Returns
- bool
Returns true if the two objects are unequal.
operator *(Complex, VectorC)
public static VectorC operator *(Complex factor, VectorC vector)
Parameters
Returns
- VectorC
Returns the product of the VectorC object and the Complex value.
operator *(VectorC, Complex)
public static VectorC operator *(VectorC vector, Complex factor)
Parameters
Returns
- VectorC
Returns the product of the VectorC object and the Complex value.
operator *(VectorC, VectorC)
Multiplies two VectorC objects.
public static VectorC operator *(VectorC a, VectorC b)
Parameters
Returns
- VectorC
Returns the product of the two VectorC objects.
operator -(VectorC, VectorC)
Subtracts two VectorC objects.
public static VectorC operator -(VectorC a, VectorC b)
Parameters
aVectorCThe first VectorC object to subtract from.
bVectorCThe second VectorC object to subtract.
Returns
- VectorC
Returns the difference of the two VectorC objects.