operator recordComplex

Record defining a Complex number

Information

This record defines a complex number consisting of a real and an imaginary part. Additionally, various utility functions are provided in the record to operate on instances of this record. Example (note: "j" in the comments is defined as j=sqrt(-1)):

   import Modelica.Utilities.Streams;
   import Modelica_LinearSystems2.Math.Complex;
   Complex c1=Complex(re=2, im=3) "= 2 + 3j";
   Complex c2=Complex(3,4) "= 3 + 4j";
 algorithm
   c3 := Complex.'+'(c1, c2) "= c1 + c2";
   Streams.print("c3 = " + Complex.'String'(c3));
   Streams.print("c3 = " + Complex.'String'(c3,"i"));
   // This gives the following print-out:
   c3 = 5 + 7j
   c3 = 5 + 7i

The utility functions are written in such a way that it is convenient to work with them, once operator overloading is provided in Modelica and Modelica tools. Example:

   // Assume operator overloading is available (this is not yet the case):
   Complex j  = Complex.j();
   Complex c4 = -2 + 5*j;
   // A Modelica tool will transform the statement of c4 into
   Complex c4 = Complex.'+'( Complex.(-2,0), Complex.'*'(Complex(5,0),j)));

The utility functions are implemented so that they can be easily inlined by a tool. In such a case, the above statement will not lead to any overhead.

Components

TypeNameDefaultDescription
RealreReal part of complex number
RealimImaginary part of complex number

Contents

NameDescription
ExamplesPackage of examples to demonstrate the usage of complex numbers
VectorsPackage of functions operating on vectors of complex numbers
MatricesPackage of functions operating on matrices of complex numbers
'constructor'Collection of operators to construct a Complex number data record
'-'Collection of operators for subtraction of complex numbers
'+'Add two complex numbers
'*'Multiply two complex numbers
'/'Divide two complex numbers (c1 / c2)
'=='Test whether two complex numbers are identical
'String'Transform Complex number into a String representation
jReturns sqrt(-1)
'abs'Absolute value of complex number
'sqrt'Square root of complex number
'max'Return maximum element of complex vector
expExponential of complex number
logLogarithm of complex number
sinSine of complex number
cosCosine of complex number
argPhase angle of complex number
conjConjugate of complex number
realReal part of complex number
imagImaginary part of complex number
eigenValuesCompute eingenvalues of a matrix A, using lapack routine dgeevx
eigenVectorsCalculate the rigth eigenvectors of a linear state space system and write them columnwise in a matrix.
frequencyFrequency and damping of conjugated complex pole pair
InternalPackage of internal functions operating on complex number (for advanced users only)