Table of Contents

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

x Complex

x-value of new VectorC object.

y Complex

y-value of new VectorC object.

VectorC(VectorC)

Creates a new VectorC object from an existing object.

public VectorC(VectorC vec)

Parameters

vec VectorC

VectorC 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

Re VectorD

Real part of x- and y-component of the new VectorC.

Im VectorD

Imaginary 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

VectorC

UnitVectorY

A constant containing the unit vector in y-direction.

public static readonly VectorC UnitVectorY

Field Value

VectorC

X

x-value of this VectorC object.

public Complex X

Field Value

Complex

Y

y-value of this VectorC object.

public Complex Y

Field Value

Complex

ZeroVector

A constant containing the zero vector (0, 0).

public static readonly VectorC ZeroVector

Field Value

VectorC

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

VectorD

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

VectorD

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

obj object

VectorC 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

vectorCAsString string

The string which should be parsed.

complexNumberFormat ComplexToStringConversionFormat

The format of the complex numbers (real / imaginary, amplitude / phase and so on).

doubleFormat NumberFormatInfo

The 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

complexNumberFormat ComplexToStringConversionFormat

The complex number format (real / imaginary, amplitude / phase and so on) to be used for the conversion.

numberOfDigits int

The 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

a VectorC

The first VectorC object to add.

b VectorC

The second VectorC object to add.

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

a VectorC

FirstVectorC object.

b VectorC

Second VectorC object.

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

number Complex

The double value to divide by the components of the VectorD object.

vector VectorC

The VectorC object used as divisor.

Returns

VectorC

Returns the quotient of the double value and the VectorC object.

operator /(VectorC, Complex)

Performs a component-wise division of a VectorC object and a Complex value.

public static VectorC operator /(VectorC vector, Complex divisor)

Parameters

vector VectorC

The VectorC object to divide by the Complex value.

divisor Complex

The 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

a VectorC

The first VectorC object to divide by parameter b.

b VectorC

The 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

vector1 VectorC

First VectorC object to compare.

vector2 VectorC

Second VectorC object to compare.

Returns

bool

Returns true if the two objects are equal.

implicit operator VectorC(VectorD)

Converts a VectorD object into a VectorC object.

public static implicit operator VectorC(VectorD vectorD)

Parameters

vectorD VectorD

VectorD 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

vector1 VectorC

First VectorC object to compare.

vector2 VectorC

Second VectorC object to compare.

Returns

bool

Returns true if the two objects are unequal.

operator *(Complex, VectorC)

Multiplies a VectorC object with a Complex value.

public static VectorC operator *(Complex factor, VectorC vector)

Parameters

factor Complex

The Complex value to multiply.

vector VectorC

The VectorC object to multiply.

Returns

VectorC

Returns the product of the VectorC object and the Complex value.

operator *(VectorC, Complex)

Multiplies a VectorC object with a Complex value.

public static VectorC operator *(VectorC vector, Complex factor)

Parameters

vector VectorC

The VectorC object to multiply.

factor Complex

The Complex value to multiply.

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

a VectorC

The first VectorC object to multiply.

b VectorC

The second VectorC object to multiply.

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

a VectorC

The first VectorC object to subtract from.

b VectorC

The second VectorC object to subtract.

Returns

VectorC

Returns the difference of the two VectorC objects.