Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
matrix.h
Go to the documentation of this file.
1 /*
2  * matrix.h - matrix class definitions
3  *
4  * Copyright (C) 2003-2009 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id$
22  *
23  */
24 
29 #ifndef __MATRIX_H__
30 #define __MATRIX_H__
31 
32 namespace qucs {
33 
34 class vector;
35 class matrix;
36 
37 matrix eye (int);
38 matrix transpose (matrix);
39 matrix conj (matrix);
40 matrix abs (matrix);
41 matrix dB (matrix);
42 matrix arg (matrix);
43 matrix adjoint (matrix);
44 matrix real (matrix);
45 matrix imag (matrix);
46 matrix sqr (matrix);
47 matrix eye (int, int);
48 matrix diagonal (vector);
49 matrix pow (matrix, int);
50 nr_complex_t cofactor (matrix, int, int);
51 nr_complex_t detLaplace (matrix);
52 nr_complex_t detGauss (matrix);
53 nr_complex_t det (matrix);
54 matrix inverseLaplace (matrix);
55 matrix inverseGaussJordan (matrix);
56 matrix inverse (matrix);
57 matrix stos (matrix, nr_complex_t, nr_complex_t z0 = 50.0);
58 matrix stos (matrix, nr_double_t, nr_double_t z0 = 50.0);
59 matrix stos (matrix, vector, nr_complex_t z0 = 50.0);
60 matrix stos (matrix, nr_complex_t, vector);
61 matrix stos (matrix, vector, vector);
62 matrix stoz (matrix, nr_complex_t z0 = 50.0);
63 matrix stoz (matrix, vector);
64 matrix ztos (matrix, nr_complex_t z0 = 50.0);
65 matrix ztos (matrix, vector);
66 matrix ztoy (matrix);
67 matrix stoy (matrix, nr_complex_t z0 = 50.0);
68 matrix stoy (matrix, vector);
69 matrix ytos (matrix, nr_complex_t z0 = 50.0);
70 matrix ytos (matrix, vector);
71 matrix ytoz (matrix);
72 matrix stoa (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
73 matrix atos (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
74 matrix stoh (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
75 matrix htos (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
76 matrix stog (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
77 matrix gtos (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
78 matrix cytocs (matrix, matrix);
79 matrix cztocs (matrix, matrix);
80 matrix cztocy (matrix, matrix);
81 matrix cstocy (matrix, matrix);
82 matrix cytocz (matrix, matrix);
83 matrix cstocz (matrix, matrix);
84 matrix twoport (matrix, char, char);
85 nr_double_t rollet (matrix);
86 nr_double_t b1 (matrix);
87 
92 class matrix
93 {
94  public:
95  matrix ();
96  matrix (int);
97  matrix (int, int);
98  matrix (const matrix &);
99  const matrix& operator = (const matrix &);
100  ~matrix ();
101  nr_complex_t get (int, int);
102  void set (int, int, nr_complex_t);
103  int getCols (void) { return cols; }
104  int getRows (void) { return rows; }
105  nr_complex_t * getData (void) { return data; }
106  void print (void);
107  void exchangeRows (int, int);
108  void exchangeCols (int, int);
109 
110  // operator functions
111  friend matrix operator + (matrix, matrix);
114  friend matrix operator + (nr_double_t, matrix);
115  friend matrix operator + (matrix, nr_double_t);
116  friend matrix operator - (matrix, matrix);
119  friend matrix operator - (nr_double_t, matrix);
120  friend matrix operator - (matrix, nr_double_t);
122  friend matrix operator / (matrix, nr_double_t);
125  friend matrix operator * (nr_double_t, matrix);
126  friend matrix operator * (matrix, nr_double_t);
127  friend matrix operator * (matrix, matrix);
128 
129  // intrinsic operator functions
133 
134  // other operations
135  friend matrix transpose (matrix);
136  friend matrix conj (matrix);
137  friend matrix abs (matrix);
138  friend matrix dB (matrix);
139  friend matrix arg (matrix);
140  friend matrix adjoint (matrix);
141  friend matrix real (matrix);
142  friend matrix imag (matrix);
143  friend matrix sqr (matrix);
144  friend matrix eye (int, int);
145  friend matrix diagonal (qucs::vector);
146  friend matrix pow (matrix, int);
147  friend nr_complex_t cofactor (matrix, int, int);
148  friend nr_complex_t detLaplace (matrix);
149  friend nr_complex_t detGauss (matrix);
150  friend nr_complex_t det (matrix);
151  friend matrix inverseLaplace (matrix);
153  friend matrix inverse (matrix);
155  friend matrix stos (matrix, nr_double_t, nr_double_t);
159  friend matrix stoz (matrix, nr_complex_t);
160  friend matrix stoz (matrix, qucs::vector);
161  friend matrix ztos (matrix, nr_complex_t);
162  friend matrix ztos (matrix, qucs::vector);
163  friend matrix ztoy (matrix);
164  friend matrix stoy (matrix, nr_complex_t);
165  friend matrix stoy (matrix, qucs::vector);
166  friend matrix ytos (matrix, nr_complex_t);
167  friend matrix ytos (matrix, qucs::vector);
168  friend matrix ytoz (matrix);
175  friend matrix cytocs (matrix, matrix);
176  friend matrix cztocs (matrix, matrix);
177  friend matrix cztocy (matrix, matrix);
178  friend matrix cstocy (matrix, matrix);
179  friend matrix cytocz (matrix, matrix);
180  friend matrix cstocz (matrix, matrix);
181 
182  friend matrix twoport (matrix, char, char);
183  friend nr_double_t rollet (matrix);
184  friend nr_double_t b1 (matrix);
185 
194  nr_complex_t operator () (int r, int c) const { return data[r * cols + c]; }
203  nr_complex_t& operator () (int r, int c) { return data[r * cols + c]; }
204 
205  private:
207  int cols;
209  int rows;
212 };
213 
214 } // namespace qucs
215 
216 #endif /* __MATRIX_H__ */
matrix operator-()
Unary minus.
Definition: matrix.cpp:270
matrix inverse(matrix a)
Compute inverse matrix.
Definition: matrix.cpp:847
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
matrix adjoint(matrix a)
adjoint matrix
Definition: matrix.cpp:522
matrix ytos(matrix y, qucs::vector z0)
Admittance matrix to scattering parameters.
Definition: matrix.cpp:1133
friend nr_complex_t detGauss(matrix)
matrix real(matrix a)
Real part matrix.
Definition: matrix.cpp:568
matrix abs(matrix a)
Computes magnitude of each matrix element.
Definition: matrix.cpp:531
friend matrix dB(matrix)
int cols
Definition: matrix.h:207
matrix ytoz(matrix y)
Convert admittance matrix to impedance matrix.
Definition: matrix.cpp:1380
friend matrix conj(matrix)
friend matrix ytoz(matrix)
nr_complex_t pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
Definition: complex.cpp:238
matrix stos(matrix s, qucs::vector zref, qucs::vector z0)
S params to S params.
Definition: matrix.cpp:890
nr_complex_t detLaplace(matrix a)
Compute determinant of the given matrix using Laplace expansion.
Definition: matrix.cpp:686
nr_complex_t * data
Definition: matrix.h:211
void exchangeRows(int, int)
The function swaps the given rows with each other.
Definition: matrix.cpp:1543
friend matrix cytocs(matrix, matrix)
friend matrix inverseLaplace(matrix)
friend matrix cztocs(matrix, matrix)
friend matrix ztos(matrix, nr_complex_t)
nr_complex_t operator()(int r, int c) const
Read access operator.
Definition: matrix.h:194
matrix twoport(matrix m, char in, char out)
Generic conversion matrix.
Definition: matrix.cpp:1594
const matrix & operator=(const matrix &)
Assignment operator.
Definition: matrix.cpp:164
nr_double_t rollet(matrix)
friend nr_double_t b1(matrix)
nr_complex_t * getData(void)
Definition: matrix.h:105
friend matrix twoport(matrix, char, char)
matrix stoh(matrix s, nr_complex_t z1, nr_complex_t z2)
Converts scattering parameters to hybrid matrix.
Definition: matrix.cpp:1269
r
Definition: parse_mdl.y:515
nr_double_t b1(matrix)
friend nr_double_t rollet(matrix)
matrix diagonal(qucs::vector diag)
Create a diagonal matrix from a vector.
Definition: matrix.cpp:624
matrix()
Create an empty matrix.
Definition: matrix.cpp:104
matrix inverseGaussJordan(matrix a)
Compute inverse matrix using Gauss-Jordan elimination.
Definition: matrix.cpp:798
matrix htos(matrix h, nr_complex_t z1, nr_complex_t z2)
Converts hybrid matrix to scattering parameters.
Definition: matrix.cpp:1307
friend matrix ztoy(matrix)
friend matrix htos(matrix, nr_complex_t, nr_complex_t)
friend matrix cstocz(matrix, matrix)
nr_complex_t sqr(const nr_complex_t z)
Square of complex number.
Definition: complex.cpp:673
matrix imag(matrix a)
Imaginary part matrix.
Definition: matrix.cpp:581
void exchangeCols(int, int)
The function swaps the given column with each other.
Definition: matrix.cpp:1561
friend matrix inverseGaussJordan(matrix)
matrix stoy(matrix s, qucs::vector z0)
Scattering parameters to admittance matrix.
Definition: matrix.cpp:1082
void print(void)
matrix inverseLaplace(matrix a)
Compute inverse matrix using Laplace expansion.
Definition: matrix.cpp:779
matrix cztocs(matrix cz, matrix s)
Converts impedance noise correlation matrix to S-parameter noise correlation matrix.
Definition: matrix.cpp:1457
matrix operator+=(matrix)
Intrinsic matrix addition.
Definition: matrix.cpp:243
nr_double_t dB(const nr_complex_t z)
Magnitude in dB Compute .
Definition: complex.cpp:528
matrix ztos(matrix z, qucs::vector z0)
Convert impedance matrix scattering parameters.
Definition: matrix.cpp:1018
friend matrix stoz(matrix, nr_complex_t)
friend matrix arg(matrix)
friend matrix stos(matrix, nr_complex_t, nr_complex_t)
friend matrix adjoint(matrix)
nr_complex_t detGauss(matrix a)
Compute determinant Gaussian algorithm.
Definition: matrix.cpp:717
matrix cstocz(matrix cs, matrix z)
Converts S-parameter noise correlation matrix to impedance noise correlation matrix.
Definition: matrix.cpp:1483
friend nr_complex_t det(matrix)
nr_complex_t det(matrix a)
Compute determinant of the given matrix.
Definition: matrix.cpp:762
friend nr_complex_t detLaplace(matrix)
friend matrix diagonal(qucs::vector)
Create a diagonal matrix from a vector.
Definition: matrix.cpp:624
void set(int, int, nr_complex_t)
Sets the matrix element at the given row and column.
Definition: matrix.cpp:205
matrix cytocz(matrix cy, matrix z)
Converts admittance noise correlation matrix to impedance noise correlation matrix.
Definition: matrix.cpp:1531
friend matrix stoa(matrix, nr_complex_t, nr_complex_t)
matrix transpose(matrix a)
Matrix transposition.
Definition: matrix.cpp:492
friend matrix operator+(matrix, matrix)
matrix cstocy(matrix cs, matrix y)
Converts S-parameter noise correlation matrix to admittance noise correlation matrix.
Definition: matrix.cpp:1430
Dense complex matrix class This class defines a matrix object with its methods, operators and operati...
Definition: matrix.h:92
nr_complex_t cofactor(matrix a, int u, int v)
Computes the complex cofactor of the given determinant.
Definition: matrix.cpp:657
friend matrix pow(matrix, int)
friend matrix stog(matrix, nr_complex_t, nr_complex_t)
matrix cytocs(matrix cy, matrix s)
Admittance noise correlation matrix to S-parameter noise correlation matrix.
Definition: matrix.cpp:1404
friend nr_complex_t cofactor(matrix, int, int)
matrix stoa(matrix s, nr_complex_t z1, nr_complex_t z2)
Converts chain matrix to scattering parameters.
Definition: matrix.cpp:1181
matrix stoz(matrix s, qucs::vector z0)
Scattering parameters to impedance matrix.
Definition: matrix.cpp:973
matrix cztocy(matrix cz, matrix y)
Converts impedance noise correlation matrix to admittance noise correlation matrix.
Definition: matrix.cpp:1507
friend matrix cztocy(matrix, matrix)
friend matrix cytocz(matrix, matrix)
int getCols(void)
Definition: matrix.h:103
List int
Definition: parse_citi.y:183
friend matrix abs(matrix)
matrix stog(matrix s, nr_complex_t z1, nr_complex_t z2)
Definition: matrix.cpp:1331
friend matrix gtos(matrix, nr_complex_t, nr_complex_t)
matrix gtos(matrix g, nr_complex_t z1, nr_complex_t z2)
Definition: matrix.cpp:1355
matrix eye(int rs, int cs)
Create identity matrix with specified number of rows and columns.
Definition: matrix.cpp:603
friend matrix imag(matrix)
friend matrix atos(matrix, nr_complex_t, nr_complex_t)
matrix conj(matrix a)
Conjugate complex matrix.
Definition: matrix.cpp:505
friend matrix stoh(matrix, nr_complex_t, nr_complex_t)
friend matrix transpose(matrix)
matrix atos(matrix a, nr_complex_t z1, nr_complex_t z2)
Converts chain matrix to scattering parameters.
Definition: matrix.cpp:1222
friend matrix sqr(matrix)
friend matrix real(matrix)
friend matrix stoy(matrix, nr_complex_t)
friend matrix operator/(matrix, nr_complex_t)
friend matrix cstocy(matrix, matrix)
friend matrix inverse(matrix)
matrix ztoy(matrix z)
impedance matrix to admittance matrix.
Definition: matrix.cpp:1050
int rows
Definition: matrix.h:209
int getRows(void)
Definition: matrix.h:104
friend matrix operator*(nr_complex_t, matrix)
friend matrix eye(int, int)
Create identity matrix with specified number of rows and columns.
Definition: matrix.cpp:603
matrix arg(matrix a)
Computes the argument of each matrix element.
Definition: matrix.cpp:555
matrix operator-=(matrix)
Intrinsic matrix subtraction.
Definition: matrix.cpp:283
friend matrix ytos(matrix, nr_complex_t)