ASL  0.1.7
Advanced Simulation Library
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 
35  class MatrixOfElements
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;
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 
109 
111 
129 
132 
135 
138 
141 
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 
159 
161 
166 
168 
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 
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
The class represents a matrix elements of Element.
MatrixOfElements operator-(const MatrixOfElements &a, const MatrixOfElements &b)
difference of two matrices
MatrixOfElements elementProduct(const VectorOfElements &a, const VectorOfElements &b)
element product of two vectors
const Element getElement(unsigned int r, unsigned int c) const
void setRow(unsigned int r, const VectorOfElements &a)
void setColumn(unsigned int c, const VectorOfElements &a)
VectorOfElements det(const MatrixOfElements &m)
computes determinant expression fo cases 2x2 and 3x3 only
VectorOfElements & getInternalVector()
void resize(unsigned int nr, unsigned int nc)
MatrixOfElements operator=(const MatrixOfElements &m)
MatrixOfElements generateME(const vector< VectorOfElements > &a)
generates a matrix with n rows
MatrixOfElements operator+(const MatrixOfElements &a, const MatrixOfElements &b)
summ of two matrices
const unsigned int getNColumns() const
VectorOfElements trace(const MatrixOfElements &a, const MatrixOfElements &b)
Trace of a matrix product
VectorOfElements operator*(const VectorOfElements &a, const MatrixOfElements &b)
product of vector and matrix
void setElement(unsigned int r, unsigned int c, Element a)
VectorOfElements trace(const MatrixOfElements &a)
Trace of a matrix
const VectorOfElements & getInternalVector() const
vector< Element > gcMatrixInversion(const MatrixOfElements &a, MatrixOfElements &inv)
returns vector of elements for computing the inverse matrix for cases 2x2 and 3x3
MatrixOfElements transpose(MatrixOfElements &source)
transposed matrix
MatrixOfElements generateMatrixCofactors(const MatrixOfElements &a)
returns the matrix of cofactors for cases 2x2 and 3x3
MatrixOfElements generateME(const VectorOfElements &a)
generates a matrix with a row
MatrixOfElements generateME(const VectorOfElements &a, const VectorOfElements &b, const VectorOfElements &c)
generates a matrix with three rows
VectorOfElements getOffDiagonalUp(const MatrixOfElements &a)
returns VectorOfElements containing the uper off diagonal elements
MatrixOfElements replaceColumn(const MatrixOfElements &a, const VectorOfElements &b, unsigned int c)
generate matrix with content of the matrix a but with replaced column c by vector b
void copy(const MatrixOfElements &source, MatrixOfElements &destination)
function copies the MatrixOfElements class.
MatrixOfElements replaceRow(const MatrixOfElements &a, const VectorOfElements &b, unsigned int r)
generate matrix with content of the matrix a but with replaced row r by vector b
MatrixOfElements(unsigned int nR=0, unsigned int nC=0)
MatrixOfElements generateME(const VectorOfElements &a, VectorOfElements &b)
generates a matrix with two rows
VectorOfElements getDiagonal(const MatrixOfElements &a)
returns VectorOfElements containing the diagonal elements
MatrixOfElements operator/(const MatrixOfElements &a, const VectorOfElements &b)
division of a matrix on a VectorOfElements with 1 element
MatrixOfElements generateME(const VectorOfElements *a, unsigned int n)
generates a matrix with n rows
const unsigned int getNRows() const
MatrixOfElements operator*(const MatrixOfElements &a, const MatrixOfElements &b)
product of two matrices
const VectorOfElements getVE(unsigned int r, unsigned int c) const
VectorOfElements operator*(const MatrixOfElements &a, const VectorOfElements &b)
product of vector and matrix
The class represents several 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
VectorOfElements solveSystem(const MatrixOfElements &a, const VectorOfElements &b)
returns solution of a system of linear equations
vector< Element > gcSolveSystem(const MatrixOfElements &a, const VectorOfElements &b, const VectorOfElements &x)
generates code for solving the solution of a system of linear equations
Advanced Computational Language.
Definition: acl.h:41
std::shared_ptr< ElementBase > Element
Definition: acl.h:49