My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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: matrix.h 1825 2011-03-11 20:42:14Z ela $
22  *
23  */
24 
25 #ifndef __MATRIX_H__
26 #define __MATRIX_H__
27 
28 class vector;
29 class matrix;
30 
31 matrix eye (int);
32 
34 class matrix
35 {
36  public:
37  matrix ();
38  matrix (int);
39  matrix (int, int);
40  matrix (const matrix &);
41  const matrix& operator = (const matrix &);
42  ~matrix ();
43  nr_complex_t get (int, int);
44  void set (int, int, nr_complex_t);
45  int getCols (void) { return cols; }
46  int getRows (void) { return rows; }
47  nr_complex_t * getData (void) { return data; }
48  void print (void);
49  void exchangeRows (int, int);
50  void exchangeCols (int, int);
51 
52  // operator functions
56  friend matrix operator + (nr_double_t, matrix);
57  friend matrix operator + (matrix, nr_double_t);
61  friend matrix operator - (nr_double_t, matrix);
62  friend matrix operator - (matrix, nr_double_t);
64  friend matrix operator / (matrix, nr_double_t);
67  friend matrix operator * (nr_double_t, matrix);
68  friend matrix operator * (matrix, nr_double_t);
70 
71  // intrinsic operator functions
75 
76  // other operations
77  friend matrix transpose (matrix);
78  friend matrix conj (matrix);
79  friend matrix abs (matrix);
80  friend matrix dB (matrix);
81  friend matrix arg (matrix);
82  friend matrix adjoint (matrix);
83  friend matrix real (matrix);
84  friend matrix imag (matrix);
85  friend matrix eye (int, int);
86  friend matrix diagonal (vector);
87  friend matrix pow (matrix, int);
88  friend nr_complex_t cofactor (matrix, int, int);
90  friend nr_complex_t detGauss (matrix);
91  friend nr_complex_t det (matrix);
92  friend matrix inverseLaplace (matrix);
94  friend matrix inverse (matrix);
95  friend matrix stos (matrix, nr_complex_t, nr_complex_t z0 = 50.0);
96  friend matrix stos (matrix, nr_double_t, nr_double_t z0 = 50.0);
97  friend matrix stos (matrix, vector, nr_complex_t z0 = 50.0);
99  friend matrix stos (matrix, vector, vector);
100  friend matrix stoz (matrix, nr_complex_t z0 = 50.0);
101  friend matrix stoz (matrix, vector);
102  friend matrix ztos (matrix, nr_complex_t z0 = 50.0);
103  friend matrix ztos (matrix, vector);
104  friend matrix ztoy (matrix);
105  friend matrix stoy (matrix, nr_complex_t z0 = 50.0);
106  friend matrix stoy (matrix, vector);
107  friend matrix ytos (matrix, nr_complex_t z0 = 50.0);
108  friend matrix ytos (matrix, vector);
109  friend matrix ytoz (matrix);
110  friend matrix stoa (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
111  friend matrix atos (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
112  friend matrix stoh (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
113  friend matrix htos (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
114  friend matrix stog (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
115  friend matrix gtos (matrix, nr_complex_t z1 = 50.0, nr_complex_t z2 = 50.0);
116  friend matrix cytocs (matrix, matrix);
117  friend matrix cztocs (matrix, matrix);
118  friend matrix cztocy (matrix, matrix);
119  friend matrix cstocy (matrix, matrix);
120  friend matrix cytocz (matrix, matrix);
121  friend matrix cstocz (matrix, matrix);
122 
123  friend matrix twoport (matrix, char, char);
124  friend nr_double_t rollet (matrix);
125  friend nr_double_t b1 (matrix);
126 
135  nr_complex_t operator () (int r, int c) const { return data[r * cols + c]; }
144  nr_complex_t& operator () (int r, int c) { return data[r * cols + c]; }
145 
146  private:
148  int cols;
150  int rows;
152  nr_complex_t * data;
153 };
154 
155 #endif /* __MATRIX_H__ */