ASL  0.1.7
Advanced Simulation Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
aclMatrixOfElements.h
Go to the documentation of this file.
1 /*
2  * Advanced Simulation Library <http://asl.org.il>
3  *
4  * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5  *
6  *
7  * This file is part of Advanced Simulation Library (ASL).
8  *
9  * ASL is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU Affero General Public License as
11  * published by the Free Software Foundation, version 3 of the License.
12  *
13  * ASL is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Affero General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
24 #ifndef ACLMATRIXOFELEMENTS_H
25 #define ACLMATRIXOFELEMENTS_H
26 
27 #include "aclVectorOfElementsDef.h"
28 
29 namespace acl
30 {
32 
36  {
37  private:
39  unsigned int nRow;
41  unsigned int nCol;
42 
43  VectorOfElements ve;
45  unsigned int ij2i(unsigned int i, unsigned int j) const;
46  public:
47  explicit MatrixOfElements(unsigned int nR = 0, unsigned int nC = 0);
48 
49  void setElement(unsigned int r, unsigned int c, Element a);
50  void setRow(unsigned int r,const VectorOfElements & a);
51  void setColumn(unsigned int c, const VectorOfElements & a);
52  const Element getElement(unsigned int r, unsigned int c) const;
53  const VectorOfElements getVE(unsigned int r, unsigned int c) const;
54  const unsigned int getNColumns() const;
55  const unsigned int getNRows() const;
57  const VectorOfElements & getInternalVector() const;
58  inline void resize(unsigned int nr, unsigned int nc);
60  };
61 
63 
66  void copy(const MatrixOfElements & source, MatrixOfElements & destination);
67 
69 
74 
78 
80 
84 
86 
90 
92 
96 
98 
102 
103 
105 
108  MatrixOfElements transpose(MatrixOfElements & source);
109 
111 
128  MatrixOfElements elementProduct(const VectorOfElements & a, const VectorOfElements & b);
129 
131  VectorOfElements trace(const MatrixOfElements & a);
132 
134  VectorOfElements trace(const MatrixOfElements & a, const MatrixOfElements & b);
135 
137  MatrixOfElements generateME(const VectorOfElements & a);
138 
140  MatrixOfElements generateME(const VectorOfElements & a,VectorOfElements & b);
141 
143  MatrixOfElements generateME(const VectorOfElements & a,
144  const VectorOfElements & b,
145  const VectorOfElements & c);
146 
148  MatrixOfElements generateME(const VectorOfElements *a, unsigned int n);
149 
151  MatrixOfElements generateME(const vector<VectorOfElements> &a);
152 
154 
158  VectorOfElements getDiagonal(const MatrixOfElements & a);
159 
161 
165  VectorOfElements getOffDiagonalUp(const MatrixOfElements & a);
166 
168 
171  VectorOfElements det(const MatrixOfElements & m);
172 
174 
178 
180 
184  vector<Element> gcSolveSystem(const MatrixOfElements & a,
185  const VectorOfElements & b,
186  const VectorOfElements & x);
187 
189 
195  vector<Element> gcSolveSystemCG(const MatrixOfElements & a,
196  const VectorOfElements & b,
197  const VectorOfElements & x);
198 
200  MatrixOfElements replaceRow(const MatrixOfElements & a, const VectorOfElements & b, unsigned int r);
201 
203  MatrixOfElements replaceColumn(const MatrixOfElements & a, const VectorOfElements & b, unsigned int c);
204 
206  MatrixOfElements generateMatrixCofactors(const MatrixOfElements & a);
207 
209  vector<Element> gcMatrixInversion(const MatrixOfElements & a, MatrixOfElements & inv);
210 
211 // ------------------------------ Implementation -----------------
212 
213  inline void MatrixOfElements::resize(unsigned int nr, unsigned int nc)
214  {
215  nRow=nr;
216  nCol=nc;
217  ve.resize(nr*nc);
218  }
219 
220 
221 } //namespace acl
222 
223 #endif // ACLMATRIXOFELEMENTS_H
MatrixOfElements operator=(const MatrixOfElements &m)
Element operator+(Element e1, Element e2)
vector< Element > gcSolveSystem(const MatrixOfElements &a, const VectorOfElements &b, const VectorOfElements &x)
generates code for solving the solution of a system of linear equations
void setElement(unsigned int r, unsigned int c, Element a)
void setRow(unsigned int r, const VectorOfElements &a)
const unsigned int getNColumns() const
VectorOfElements & getInternalVector()
Element operator/(Element e1, Element e2)
VectorOfElements solveSystem(const MatrixOfElements &a, const VectorOfElements &b)
returns solution of a system of linear equations
Element operator-(Element e)
The class represents a matrix elements of Element.
vector< Element > gcSolveSystemCG(const MatrixOfElements &a, const VectorOfElements &b, const VectorOfElements &x)
generates code for solving the solution of a system of linear equations
void resize(unsigned int nr, unsigned int nc)
const unsigned int getNRows() const
const Element getElement(unsigned int r, unsigned int c) const
The class represents several Element.
void setColumn(unsigned int c, const VectorOfElements &a)
MatrixOfElements(unsigned int nR=0, unsigned int nC=0)
void copy(MemBlock &source, T *destination)
const VectorOfElements getVE(unsigned int r, unsigned int c) const
Element operator*(Element e1, Element e2)