My Project
0.0.16
QUCS Mapping
|
Dense complex matrix class. More...
#include <matrix.h>
Public Member Functions | |
matrix () | |
Create an empty matrix. | |
matrix (int) | |
Creates a square matrix. | |
matrix (int, int) | |
matrix (const matrix &) | |
const matrix & | operator= (const matrix &) |
Assignment operator. | |
~matrix () | |
nr_complex_t | get (int, int) |
Returns the matrix element at the given row and column. | |
void | set (int, int, nr_complex_t) |
Sets the matrix element at the given row and column. | |
int | getCols (void) |
int | getRows (void) |
nr_complex_t * | getData (void) |
void | print (void) |
void | exchangeRows (int, int) |
The function swaps the given rows with each other. | |
void | exchangeCols (int, int) |
The function swaps the given column with each other. | |
matrix | operator- () |
Unary minus. | |
matrix | operator+= (matrix) |
Intrinsic matrix addition. | |
matrix | operator-= (matrix) |
Intrinsic matrix subtraction. | |
nr_complex_t | operator() (int r, int c) const |
Read access operator. | |
nr_complex_t & | operator() (int r, int c) |
Write access operator. | |
Friends | |
matrix | operator+ (matrix, matrix) |
Matrix addition. | |
matrix | operator+ (nr_complex_t, matrix) |
Complex scalar addition different order. | |
matrix | operator+ (matrix, nr_complex_t) |
Complex scalar addition. | |
matrix | operator+ (nr_double_t, matrix) |
Real scalar addition different order. | |
matrix | operator+ (matrix, nr_double_t) |
Real scalar addition. | |
matrix | operator- (matrix, matrix) |
Matrix subtraction. | |
matrix | operator- (nr_complex_t, matrix) |
Complex scalar substraction different order. | |
matrix | operator- (matrix, nr_complex_t) |
Complex scalar substraction. | |
matrix | operator- (nr_double_t, matrix) |
Real scalar substraction different order. | |
matrix | operator- (matrix, nr_double_t) |
Real scalar substraction. | |
matrix | operator/ (matrix, nr_complex_t) |
Matrix scaling division by complex version. | |
matrix | operator/ (matrix, nr_double_t) |
Matrix scaling division by real version. | |
matrix | operator* (nr_complex_t, matrix) |
Matrix scaling complex version (different order) | |
matrix | operator* (matrix, nr_complex_t) |
Matrix scaling complex version. | |
matrix | operator* (nr_double_t, matrix) |
Matrix scaling real version (different order) | |
matrix | operator* (matrix, nr_double_t) |
Matrix scaling complex version. | |
matrix | operator* (matrix, matrix) |
matrix | transpose (matrix) |
Matrix transposition. | |
matrix | conj (matrix) |
Conjugate complex matrix. | |
matrix | abs (matrix) |
Computes magnitude of each matrix element. | |
matrix | dB (matrix) |
Computes magnitude in dB of each matrix element. | |
matrix | arg (matrix) |
Computes the argument of each matrix element. | |
matrix | adjoint (matrix) |
adjoint matrix | |
matrix | real (matrix) |
Real part matrix. | |
matrix | imag (matrix) |
Imaginary part matrix. | |
matrix | eye (int, int) |
Create identity matrix with specified number of rows and columns. | |
matrix | diagonal (vector) |
Create a diagonal matrix from a vector. | |
matrix | pow (matrix, int) |
nr_complex_t | cofactor (matrix, int, int) |
Computes the complex cofactor of the given determinant. | |
nr_complex_t | detLaplace (matrix) |
Compute determinant of the given matrix using Laplace expansion. | |
nr_complex_t | detGauss (matrix) |
Compute determinant Gaussian algorithm. | |
nr_complex_t | det (matrix) |
Compute determinant of the given matrix. | |
matrix | inverseLaplace (matrix) |
Compute inverse matrix using Laplace expansion. | |
matrix | inverseGaussJordan (matrix) |
Compute inverse matrix using Gauss-Jordan elimination. | |
matrix | inverse (matrix) |
Compute inverse matrix. | |
matrix | stos (matrix, nr_complex_t, nr_complex_t z0=50.0) |
S renormalization with all part identic. | |
matrix | stos (matrix, nr_double_t, nr_double_t z0=50.0) |
S renormalization with all part identic and real. | |
matrix | stos (matrix, vector, nr_complex_t z0=50.0) |
S renormalization (variation) | |
matrix | stos (matrix, nr_complex_t, vector) |
S renormalization (variation) | |
matrix | stos (matrix, vector, vector) |
S params to S params. | |
matrix | stoz (matrix, nr_complex_t z0=50.0) |
Scattering parameters to impedance matrix identic case. | |
matrix | stoz (matrix, vector) |
Scattering parameters to impedance matrix. | |
matrix | ztos (matrix, nr_complex_t z0=50.0) |
Convert impedance matrix to scattering parameters identic case. | |
matrix | ztos (matrix, vector) |
Convert impedance matrix scattering parameters. | |
matrix | ztoy (matrix) |
impedance matrix to admittance matrix. | |
matrix | stoy (matrix, nr_complex_t z0=50.0) |
Convert scattering pto adminttance parameters identic case. | |
matrix | stoy (matrix, vector) |
Scattering parameters to admittance matrix. | |
matrix | ytos (matrix, nr_complex_t z0=50.0) |
Convert Admittance matrix to scattering parameters identic case. | |
matrix | ytos (matrix, vector) |
Admittance matrix to scattering parameters. | |
matrix | ytoz (matrix) |
Convert admittance matrix to impedance matrix. | |
matrix | stoa (matrix, nr_complex_t z1=50.0, nr_complex_t z2=50.0) |
Converts chain matrix to scattering parameters. | |
matrix | atos (matrix, nr_complex_t z1=50.0, nr_complex_t z2=50.0) |
Converts chain matrix to scattering parameters. | |
matrix | stoh (matrix, nr_complex_t z1=50.0, nr_complex_t z2=50.0) |
Converts scattering parameters to hybrid matrix. | |
matrix | htos (matrix, nr_complex_t z1=50.0, nr_complex_t z2=50.0) |
Converts hybrid matrix to scattering parameters. | |
matrix | stog (matrix, nr_complex_t z1=50.0, nr_complex_t z2=50.0) |
matrix | gtos (matrix, nr_complex_t z1=50.0, nr_complex_t z2=50.0) |
matrix | cytocs (matrix, matrix) |
Admittance noise correlation matrix to S-parameter noise correlation matrix. | |
matrix | cztocs (matrix, matrix) |
Converts impedance noise correlation matrix to S-parameter noise correlation matrix. | |
matrix | cztocy (matrix, matrix) |
Converts impedance noise correlation matrix to admittance noise correlation matrix. | |
matrix | cstocy (matrix, matrix) |
Converts S-parameter noise correlation matrix to admittance noise correlation matrix. | |
matrix | cytocz (matrix, matrix) |
Converts admittance noise correlation matrix to impedance noise correlation matrix. | |
matrix | cstocz (matrix, matrix) |
Converts S-parameter noise correlation matrix to impedance noise correlation matrix. | |
matrix | twoport (matrix, char, char) |
Generic conversion matrix. | |
nr_double_t | rollet (matrix) |
nr_double_t | b1 (matrix) |
matrix::matrix | ( | ) |
Create an empty matrix.
Constructor creates an unnamed instance of the matrix class.
Definition at line 102 of file matrix.cpp.
matrix::matrix | ( | int | s | ) |
Creates a square matrix.
Constructor creates an unnamed instance of the matrix class with a certain number of rows and columns. Particularly creates a square matrix.
[in] | s | number of rows or colums of square matrix |
Definition at line 115 of file matrix.cpp.
matrix::matrix | ( | int | r, |
int | c | ||
) |
Definition at line 129 of file matrix.cpp.
matrix::matrix | ( | const matrix & | m | ) |
Definition at line 141 of file matrix.cpp.
matrix::~matrix | ( | ) |
void matrix::exchangeCols | ( | int | c1, |
int | c2 | ||
) |
The function swaps the given column with each other.
[in] | c1 | source column |
[in] | c2 | destination column |
Definition at line 1552 of file matrix.cpp.
void matrix::exchangeRows | ( | int | r1, |
int | r2 | ||
) |
The function swaps the given rows with each other.
[in] | r1 | source row |
[in] | r2 | destination row |
Definition at line 1534 of file matrix.cpp.
nr_complex_t matrix::get | ( | int | r, |
int | c | ||
) |
Returns the matrix element at the given row and column.
[in] | r | row number |
[in] | c | column number |
Why not inline and synonymous of ()
c and r const
Definition at line 192 of file matrix.cpp.
|
inline |
|
inline |
Read access operator.
[in] | r,: | row number (from 0 like usually in C) |
[in] | c,: | column number (from 0 like usually in C) |
: Why not inline
: Why not r and c not const
: Create a debug version checking out of bound (using directly assert)
|
inline |
Write access operator.
[in] | r,: | row number (from 0 like usually in C) |
[in] | c,: | column number (from 0 like usually in C) |
: Why not inline
: Why r and c not const
: Create a debug version checking out of bound (using directly assert)
Intrinsic matrix addition.
[in] | a | matrix to add |
Definition at line 241 of file matrix.cpp.
matrix matrix::operator- | ( | ) |
Intrinsic matrix subtraction.
[in] | a | matrix to substract |
Definition at line 281 of file matrix.cpp.
Assignment operator.
The assignment copy constructor creates a new instance based on the given matrix object.
[in] | m | object to copy |
Definition at line 162 of file matrix.cpp.
void matrix::print | ( | void | ) |
void matrix::set | ( | int | r, |
int | c, | ||
nr_complex_t | z | ||
) |
Sets the matrix element at the given row and column.
[in] | r | row number |
[in] | c | column number |
[in] | z | complex number to assign |
Why not inline and synonymous of ()
r c and z const
Definition at line 203 of file matrix.cpp.
Computes magnitude of each matrix element.
[in] | a | matrix |
add abs in place
a is const
Definition at line 529 of file matrix.cpp.
adjoint matrix
The function returns the adjoint complex matrix. This is also called the adjugate or transpose conjugate.
[in] | a | Matrix to transpose |
add adjoint in place
Do not lazy and avoid conj and transpose copy
a is const
Definition at line 520 of file matrix.cpp.
Computes the argument of each matrix element.
[in] | a | matrix |
add arg in place
a is const
Definition at line 553 of file matrix.cpp.
|
friend |
Converts chain matrix to scattering parameters.
Converts chain matrix to scattering parameters Formulae are given by [5] and are remembered here:
Where:
[in] | a | Chain matrix |
[in] | z1 | impedance at input 1 |
[in] | z2 | impedance at input 2 |
Definition at line 1213 of file matrix.cpp.
|
friend |
|
friend |
Computes the complex cofactor of the given determinant.
The cofactor is the determinant obtained by deleting the row and column of a given element of a matrix or determinant. The cofactor is preceded by a + or - sign depending of the sign of
((u + v) & 1) is cryptic use (u + v)% 2
#ifdef 0
static?
Definition at line 648 of file matrix.cpp.
Conjugate complex matrix.
[in] | a | Matrix to conjugate |
add conj in place
a is const
Definition at line 503 of file matrix.cpp.
Converts S-parameter noise correlation matrix to admittance noise correlation matrix.
According to [7] fig 2:
Where is the scattering noise correlation matrix, the admittance noise correlation matrix, the identity matrix and the scattering matrix of device. is the adjoint of
[in] | cs | S parameter noise correlation |
[in] | y | Admittance matrix of device |
Definition at line 1421 of file matrix.cpp.
Converts S-parameter noise correlation matrix to impedance noise correlation matrix.
According to [7] fig 2:
Where is the scattering noise correlation matrix, the impedance noise correlation matrix, the identity matrix and the scattering matrix of device. is the adjoint of
[in] | cs | S parameter noise correlation |
[in] | z | Impedance matrix of device |
Definition at line 1474 of file matrix.cpp.
Admittance noise correlation matrix to S-parameter noise correlation matrix.
Converts admittance noise correlation matrix to S-parameter noise correlation matrix. According to [7] fig 2:
Where is the scattering noise correlation matrix, the admittance noise correlation matrix, the identity matrix and the scattering matrix of device. is the adjoint of
[in] | cy | Admittance noise correlation |
[in] | s | S parameter matrix of device |
Definition at line 1395 of file matrix.cpp.
Converts admittance noise correlation matrix to impedance noise correlation matrix.
According to [7] fig 2:
Where is the impedance correlation matrix, the identity matrix and the admittance noise correlation matrix. is the adjoint of
[in] | cy | Admittance noise correlation |
[in] | z | Impedance matrix of device |
Definition at line 1522 of file matrix.cpp.
Converts impedance noise correlation matrix to S-parameter noise correlation matrix.
According to [7] fig 2:
Where is the scattering noise correlation matrix, the impedance noise correlation matrix, the identity matrix and the scattering matrix of device. is the adjoint of
[in] | cz | Impedance noise correlation |
[in] | s | S parameter matrix of device |
Definition at line 1448 of file matrix.cpp.
Converts impedance noise correlation matrix to admittance noise correlation matrix.
According to [7] fig 2:
Where is the impedance correlation matrix, the identity matrix and the admittance noise correlation matrix. is the adjoint of
[in] | cz | impedance noise correlation |
[in] | y | Admittance matrix of device |
Definition at line 1498 of file matrix.cpp.
Computes magnitude in dB of each matrix element.
[in] | a | matrix |
Definition at line 540 of file matrix.cpp.
|
friend |
Compute determinant of the given matrix.
[in] | a | matrix |
Definition at line 753 of file matrix.cpp.
|
friend |
Compute determinant Gaussian algorithm.
Compute determinant of the given matrix using the Gaussian algorithm. This means to triangulate the matrix and multiply all the diagonal elements.
[in] | a | matrix |
static ?
a const?
Definition at line 708 of file matrix.cpp.
|
friend |
Compute determinant of the given matrix using Laplace expansion.
The Laplace expansion of the determinant of an n by n square matrix a expresses the determinant of a as a sum of n determinants of (n-1) by (n-1) sub-matrices of a. There are 2n such expressions, one for each row and column of a.
See Wikipedia http://en.wikipedia.org/wiki/Laplace_expansion
[in] | a | matrix |
#ifdef 0
static ?
Definition at line 677 of file matrix.cpp.
Create a diagonal matrix from a vector.
[in] | diag | vector to write on the diagonal |
Definition at line 615 of file matrix.cpp.
|
friend |
Create identity matrix with specified number of rows and columns.
[in] | rs | row number |
[in] | cs | column number |
Avoid res.get*
Use memset
rs, cs are const
Definition at line 594 of file matrix.cpp.
|
friend |
Definition at line 1346 of file matrix.cpp.
|
friend |
Converts hybrid matrix to scattering parameters.
Formulae are given by [5] and are remembered here:
Where is:
[in] | h | hybrid matrix |
[in] | z1 | impedance at input 1 |
[in] | z2 | impedance at input 2 |
Definition at line 1298 of file matrix.cpp.
Imaginary part matrix.
[in] | a | matrix |
add imag in place
a is const
Definition at line 579 of file matrix.cpp.
Compute inverse matrix.
[in] | a | matrix to invert |
Definition at line 838 of file matrix.cpp.
Compute inverse matrix using Gauss-Jordan elimination.
Compute inverse matrix of the given matrix by Gauss-Jordan elimination.
a const?
static?
[in] | a | matrix to invert |
Definition at line 789 of file matrix.cpp.
Compute inverse matrix using Laplace expansion.
Compute inverse matrix of the given matrix using Laplace expansion.
[in] | a | matrix to invert |
Static?
#ifdef 0
Definition at line 770 of file matrix.cpp.
|
friend |
Matrix scaling complex version (different order)
[in] | a | matrix to scale |
[in] | z | scaling complex |
Why not a and z const
Why not inline
Definition at line 311 of file matrix.cpp.
|
friend |
Matrix scaling complex version.
[in] | a | matrix to scale |
[in] | z | scaling complex |
Definition at line 296 of file matrix.cpp.
Matrix scaling real version (different order)
[in] | a | matrix to scale |
[in] | d | scaling real |
Why not inline?
Why not d and a const
Definition at line 336 of file matrix.cpp.
Matrix scaling complex version.
[in] | a | matrix to scale |
[in] | d | scaling real |
Definition at line 321 of file matrix.cpp.
Matrix multiplication.
Dumb and not optimized matrix multiplication
a] | first matrix |
b] | second matrix |
Definition at line 376 of file matrix.cpp.
Matrix addition.
a] | first matrix |
b] | second matrix |
Definition at line 226 of file matrix.cpp.
|
friend |
Complex scalar addition different order.
[in] | a | matrix |
[in] | z | complex to add |
Move near other +
a and z are const
Why not inline
Definition at line 412 of file matrix.cpp.
|
friend |
Complex scalar addition.
[in] | a | matrix |
[in] | z | complex to add |
Move near other +
a and z are const
Definition at line 397 of file matrix.cpp.
Real scalar addition different order.
[in] | a | matrix |
[in] | d | real to add |
Move near other +
a and d are const
Why not inline
Definition at line 437 of file matrix.cpp.
Real scalar addition.
[in] | a | matrix |
[in] | d | real to add |
Move near other +
a and d are const
Definition at line 422 of file matrix.cpp.
Matrix subtraction.
a] | first matrix |
b] | second matrix |
Definition at line 257 of file matrix.cpp.
|
friend |
Complex scalar substraction different order.
[in] | a | matrix |
[in] | z | complex to add |
Move near other +
a and z are const
Why not inline
Definition at line 459 of file matrix.cpp.
|
friend |
Complex scalar substraction.
[in] | a | matrix |
[in] | z | complex to add |
Move near other +
a and z are const
Why not inline
Definition at line 448 of file matrix.cpp.
Real scalar substraction different order.
[in] | a | matrix |
[in] | z | real to add |
Move near other +
a and z are const
Why not inline
Definition at line 481 of file matrix.cpp.
Real scalar substraction.
[in] | a | matrix |
[in] | z | real to add |
Move near other +
a and z are const
Why not inline
Definition at line 470 of file matrix.cpp.
|
friend |
Matrix scaling division by complex version.
[in] | a | matrix to scale |
[in] | z | scaling complex |
Definition at line 346 of file matrix.cpp.
Matrix scaling division by real version.
[in] | a | matrix to scale |
[in] | d | scaling real |
Definition at line 360 of file matrix.cpp.
Definition at line 623 of file matrix.cpp.
Real part matrix.
[in] | a | matrix |
add real in place
a is const
Definition at line 566 of file matrix.cpp.
|
friend |
|
friend |
Converts chain matrix to scattering parameters.
Converts scattering parameters to chain matrix. Formulae are given by [5] tab 1. and are remembered here:
Where:
[in] | s | Scattering matrix |
[in] | z1 | impedance at input 1 |
[in] | z2 | impedance at input 2 |
Definition at line 1172 of file matrix.cpp.
|
friend |
Definition at line 1322 of file matrix.cpp.
|
friend |
Converts scattering parameters to hybrid matrix.
Converts chain matrix to scattering parameters Formulae are given by [5] and are remembered here:
Where is:
[in] | s | Scattering matrix |
[in] | z1 | impedance at input 1 |
[in] | z2 | impedance at input 2 |
Definition at line 1260 of file matrix.cpp.
|
friend |
S renormalization with all part identic.
[in] | s | original S matrix |
[in] | zref | original reference impedance |
[in] | z0 | new reference impedance |
Definition at line 901 of file matrix.cpp.
S renormalization with all part identic and real.
[in] | s | original S matrix |
[in] | zref | original reference impedance |
[in] | z0 | new reference impedance |
Definition at line 914 of file matrix.cpp.
|
friend |
S renormalization (variation)
[in] | s | original S matrix |
[in] | zref | original reference impedance |
[in] | z0 | new reference impedance |
Definition at line 926 of file matrix.cpp.
|
friend |
S renormalization (variation)
[in] | s | original S matrix |
[in] | zref | original reference impedance |
[in] | z0 | new reference impedance |
Why not inline
s, zref and z0 const
Definition at line 938 of file matrix.cpp.
S params to S params.
Convert scattering parameters with the reference impedance 'zref' to scattering parameters with the reference impedance 'z0'.
Detail are given in [1], under equation (32)
New scatering matrix is:
Where x^+ is the adjoint (or complex tranposate) of x, I the identity matrix and is diagonal the matrix such as: and the diagonal matrix such as:
Where is the complex conjugate of and is wave reflexion coefficient of with respect to (where is the new impedance and is the old impedance), ie:
[in] | s | original S matrix |
[in] | zref | original reference impedance |
[in] | z0 | new reference impedance |
Correct documentation about standing waves [1-4]
Implement Speciale implementation [2-3] if applicable
Definition at line 881 of file matrix.cpp.
|
friend |
Convert scattering pto adminttance parameters identic case.
[in] | S | Scattering matrix |
[in] | z0 | Normalisation impedance |
Why not inline
s and z0 const
Definition at line 1092 of file matrix.cpp.
Scattering parameters to admittance matrix.
Convert scattering parameters to admittance matrix. According to [1] eq (19):
Where is the scattering matrix, is the adjoint of x, I the identity matrix. The matrix F and G are diagonal matrix defined by:
Using the well know formula , we derivate:
[in] | s | Scattering matrix |
[in] | z0 | Normalisation impedance |
Definition at line 1073 of file matrix.cpp.
|
friend |
Scattering parameters to impedance matrix identic case.
[in] | s | Scattering matrix |
[in] | z0 | Normalisation impedance |
Why not inline?
s and z0 const?
Definition at line 983 of file matrix.cpp.
Scattering parameters to impedance matrix.
Convert scattering parameters to impedance matrix. According to [1] eq (19):
Where is the scattering matrix, is the adjoint of x, I the identity matrix. The matrix F and G are diagonal matrix defined by:
[in] | s | Scattering matrix |
[in] | z0 | Normalisation impedance |
Definition at line 964 of file matrix.cpp.
Matrix transposition.
[in] | a | Matrix to transpose |
add transpose in place
a is const
Definition at line 490 of file matrix.cpp.
Generic conversion matrix.
This function converts 2x2 matrices from any of the matrix forms Y, Z, H, G and A to any other. Also converts S<->(A, T, H, Y and Z) matrices. Convertion assumed:
Y->Y, Y->Z, Y->H, Y->G, Y->A, Y->S, Z->Y, Z->Z, Z->H, Z->G, Z->A, Z->S, H->Y, H->Z, H->H, H->G, H->A, H->S, G->Y, G->Z, G->H, G->G, G->A, G->S, A->Y, A->Z, A->H, A->G, A->A, A->S, S->Y, S->Z, S->H, S->G, S->A, S->S, S->T,T->T,T->S
[in] | m | base matrix |
[in] | in | matrix |
[in] | out | matrix |
Definition at line 1585 of file matrix.cpp.
|
friend |
Convert Admittance matrix to scattering parameters identic case.
[in] | y | Admittance matrix |
[in] | z0 | Normalisation impedance |
Why not inline
y and z0 const
Definition at line 1142 of file matrix.cpp.
Admittance matrix to scattering parameters.
Convert admittance matrix to scattering parameters. Using the same methodology as [1] eq (16-19), but writing (16) as , ie
Where is the scattering matrix, is the adjoint of x, I the identity matrix. The matrix F and G are diagonal matrix defined by:
Using the well know formula , we derivate:
[in] | y | admittance matrix |
[in] | z0 | Normalisation impedance |
Definition at line 1124 of file matrix.cpp.
Convert admittance matrix to impedance matrix.
Convert matrix to matrix using well known relation
[in] | y | admittance matrix |
Definition at line 1371 of file matrix.cpp.
|
friend |
Convert impedance matrix to scattering parameters identic case.
[in] | Z | Impedance matrix |
[in] | z0 | Normalisation impedance |
Why not inline
z and z0 const
Definition at line 1028 of file matrix.cpp.
Convert impedance matrix scattering parameters.
Convert scattering parameters to impedance matrix. According to [1] eq (18):
Where is the scattering matrix, is the adjoint of x, I the identity matrix. The matrix F and G are diagonal matrix defined by:
[in] | Z | Impedance matrix |
[in] | z0 | Normalisation impedance |
Definition at line 1009 of file matrix.cpp.
impedance matrix to admittance matrix.
Convert impedance matrix to admittance matrix. By definition
[in] | z | impedance matrix |
Why not inline
z const
Definition at line 1041 of file matrix.cpp.