LCOV - code coverage report
Current view: top level - src/math - matrix.h (source / functions) Hit Total Coverage
Test: qucs-core-0.0.19 Code Coverage Lines: 4 4 100.0 %
Date: 2015-01-05 16:01:02 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       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                 :            : 
      25                 :            : /*!\file matrix.h
      26                 :            :    \brief Dense matrix class header file
      27                 :            : */
      28                 :            : 
      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                 :            : 
      88                 :            : /*!\class matrix
      89                 :            :  * \brief Dense complex matrix class
      90                 :            :  * This class defines a matrix object with its methods, operators and operations.
      91                 :            : */
      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                 :     282180 :   int getCols (void) { return cols; }
     104                 :      70960 :   int getRows (void) { return rows; }
     105                 :       3740 :   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);
     112                 :            :   friend matrix operator + (nr_complex_t, matrix);
     113                 :            :   friend matrix operator + (matrix, nr_complex_t);
     114                 :            :   friend matrix operator + (nr_double_t, matrix);
     115                 :            :   friend matrix operator + (matrix, nr_double_t);
     116                 :            :   friend matrix operator - (matrix, matrix);
     117                 :            :   friend matrix operator - (nr_complex_t, matrix);
     118                 :            :   friend matrix operator - (matrix, nr_complex_t);
     119                 :            :   friend matrix operator - (nr_double_t, matrix);
     120                 :            :   friend matrix operator - (matrix, nr_double_t);
     121                 :            :   friend matrix operator / (matrix, nr_complex_t);
     122                 :            :   friend matrix operator / (matrix, nr_double_t);
     123                 :            :   friend matrix operator * (nr_complex_t, matrix);
     124                 :            :   friend matrix operator * (matrix, nr_complex_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
     130                 :            :   matrix operator  - ();
     131                 :            :   matrix operator += (matrix);
     132                 :            :   matrix operator -= (matrix);
     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);
     152                 :            :   friend matrix inverseGaussJordan (matrix);
     153                 :            :   friend matrix inverse (matrix);
     154                 :            :   friend matrix stos (matrix, nr_complex_t, nr_complex_t);
     155                 :            :   friend matrix stos (matrix, nr_double_t, nr_double_t);
     156                 :            :   friend matrix stos (matrix, qucs::vector, nr_complex_t);
     157                 :            :   friend matrix stos (matrix, nr_complex_t, qucs::vector);
     158                 :            :   friend matrix stos (matrix, qucs::vector, qucs::vector);
     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);
     169                 :            :   friend matrix stoa (matrix, nr_complex_t, nr_complex_t);
     170                 :            :   friend matrix atos (matrix, nr_complex_t, nr_complex_t);
     171                 :            :   friend matrix stoh (matrix, nr_complex_t, nr_complex_t);
     172                 :            :   friend matrix htos (matrix, nr_complex_t, nr_complex_t);
     173                 :            :   friend matrix stog (matrix, nr_complex_t, nr_complex_t);
     174                 :            :   friend matrix gtos (matrix, nr_complex_t, nr_complex_t);
     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                 :            : 
     186                 :            :   /*! \brief Read access operator
     187                 :            :       \param[in] r: row number (from 0 like usually in C)
     188                 :            :       \param[in] c: column number (from 0 like usually in C)
     189                 :            :       \return Cell in the row r and column c
     190                 :            :       \todo: Why not inline
     191                 :            :       \todo: Why not r and c not const
     192                 :            :       \todo: Create a debug version checking out of bound (using directly assert)
     193                 :            :   */
     194                 :            :   nr_complex_t  operator () (int r, int c) const { return data[r * cols + c]; }
     195                 :            :   /*! \brief Write access operator
     196                 :            :       \param[in] r: row number (from 0 like usually in C)
     197                 :            :       \param[in] c: column number (from 0 like usually in C)
     198                 :            :       \return Reference to cell in the row r and column c
     199                 :            :       \todo: Why not inline
     200                 :            :       \todo: Why r and c not const
     201                 :            :       \todo: Create a debug version checking out of bound (using directly assert)
     202                 :            :   */
     203                 :     823240 :   nr_complex_t& operator () (int r, int c) { return data[r * cols + c]; }
     204                 :            : 
     205                 :            :  private:
     206                 :            :   /*! Number of colunms */
     207                 :            :   int cols;
     208                 :            :   /*! Number of rows */
     209                 :            :   int rows;
     210                 :            :   /*! Matrix data */
     211                 :            :   nr_complex_t * data;
     212                 :            : };
     213                 :            : 
     214                 :            : } // namespace qucs
     215                 :            : 
     216                 :            : #endif /* __MATRIX_H__ */

Generated by: LCOV version 1.11