Salome HOME
Renamed test names
[tools/solverlab.git] / CDMATH / base / inc / Matrix.hxx
1 /*
2  * Matrix.hxx
3  *
4  *  Created on: 13 April. 2013
5  *      Authors: CDMAT
6  */
7
8 #ifndef MATRIX_HXX_
9 #define MATRIX_HXX_
10
11
12 /**
13  * Matrix class is defined by
14  * - number of rows
15  * - number of columns
16  * - values array
17  */
18
19 #include <iostream>
20
21 #include "GenericMatrix.hxx"
22
23 class Vector ;
24
25 class Matrix: public GenericMatrix
26 {
27     public: //----------------------------------------------------------------
28     /**
29      * default constructor
30      */
31     Matrix ( void ) ;
32
33     /**
34      * constructor with data
35      * @param dim : The number of rows and columns
36      */
37     Matrix ( int dim ) ;
38
39     /**
40      * constructor with data
41      * @param numberOfRows : The number of rows
42      * @param numberOfColumns : The number of columns
43      */
44     Matrix ( int numberOfRows, int numberOfColumns ) ;
45
46     /**
47      * constructor by copy
48      * @param matrix : The Matrix object to be copied
49      */
50     Matrix ( const Matrix& matrix ) ;
51
52     /**
53      * deep copy of a matrix (values are copied)
54      * @param matrix : The Matrix object to be copied
55      */
56     Matrix deepCopy(  ) const;
57
58     /**
59      * destructor
60      */
61     virtual ~Matrix ( void ) ;
62
63     const DoubleTab& getValues( void ) const ;
64
65         DoubleTab getValues( void ) ;
66
67         void setValues(const DoubleTab& values) ;
68
69         //returns the array of matrix coefficients
70         std::vector< double > getArray();
71
72         //returns the maximum coefficient
73     double max() const;
74
75         //returns the minimum coefficient
76     double min() const;
77
78     bool isSparseMatrix( void ) const ;
79
80     double& operator () ( int i, int j ) ;
81
82     double operator () ( int i, int j ) const ;
83
84     Matrix& operator+= (const Matrix& matrix) ;
85
86     Matrix& operator-= (const Matrix& matrix) ;
87
88     Matrix& operator*= (double value) ;
89
90     Matrix& operator*= (const Matrix& matrix) ;
91
92     Matrix& operator/= (double value) ;
93
94     Vector operator* (const Vector& vector) const ;
95
96     Matrix transpose() const ;
97
98     Matrix partMatrix(int row, int column) const ;
99
100     double determinant() const ;
101
102     const Matrix& operator= ( const Matrix& matrix ) ;
103
104     friend Matrix operator+ (const Matrix& matrix1, const Matrix& matrix2);
105
106     friend Matrix operator- (const Matrix& matrix1, const Matrix& matrix2);
107
108     friend Matrix operator* (double value , const Matrix& matrix ) ;
109
110     friend Matrix operator* (const Matrix& matrix, double value ) ;
111
112     friend Matrix operator/ (const Matrix& matrix, double value) ;
113
114     friend Matrix operator*(const Matrix& M, const Matrix& N) ;
115
116     friend std::ostream& operator<<(std::ostream& out, const Matrix& matrix ) ;
117
118
119     protected: //----------------------------------------------------------------
120
121     DoubleTab _values ;
122
123         //This function is used in the computation of the determinant
124     int coefficient(int index) const ;
125 };
126
127 #endif /* MATRIX_HXX_ */