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
| Type | Name | Default | Description |
|---|---|---|---|
| Real | re | Real part of complex number | |
| Real | im | Imaginary part of complex number |
Contents
| Name | Description |
|---|---|
| Package of examples to demonstrate the usage of complex numbers | |
| Package of functions operating on vectors of complex numbers | |
| Package 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 |
| j | Returns sqrt(-1) |
| 'abs' | Absolute value of complex number |
| 'sqrt' | Square root of complex number |
| 'max' | Return maximum element of complex vector |
| exp | Exponential of complex number |
| log | Logarithm of complex number |
| sin | Sine of complex number |
| cos | Cosine of complex number |
| arg | Phase angle of complex number |
| conj | Conjugate of complex number |
| real | Real part of complex number |
| imag | Imaginary part of complex number |
| eigenValues | Compute eingenvalues of a matrix A, using lapack routine dgeevx |
| eigenVectors | Calculate the rigth eigenvectors of a linear state space system and write them columnwise in a matrix. |
| frequency | Frequency and damping of conjugated complex pole pair |
| Package of internal functions operating on complex number (for advanced users only) |