aclMatrixOfElements.h
Go to the documentation of this file.
/*
* Advanced Simulation Library <http://asl.org.il>
*
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
*
*
* This file is part of Advanced Simulation Library (ASL).
*
* ASL is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* ASL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ACLMATRIXOFELEMENTS_H
#define ACLMATRIXOFELEMENTS_H
#include "aclVectorOfElementsDef.h"
namespace acl
{
class MatrixOfElements
{
private:
unsigned int nRow;
unsigned int nCol;
VectorOfElements ve;
unsigned int ij2i(unsigned int i, unsigned int j) const;
public:
explicit MatrixOfElements(unsigned int nR = 0, unsigned int nC = 0);
void setElement(unsigned int r, unsigned int c, Element a);
void setRow(unsigned int r,const VectorOfElements & a);
void setColumn(unsigned int c, const VectorOfElements & a);
const Element getElement(unsigned int r, unsigned int c) const;
const VectorOfElements getVE(unsigned int r, unsigned int c) const;
const unsigned int getNColumns() const;
const unsigned int getNRows() const;
VectorOfElements & getInternalVector();
const VectorOfElements & getInternalVector() const;
inline void resize(unsigned int nr, unsigned int nc);
MatrixOfElements operator= (const MatrixOfElements & m);
};
void copy(const MatrixOfElements & source, MatrixOfElements & destination);
MatrixOfElements operator+(const MatrixOfElements & a, const MatrixOfElements & b);
MatrixOfElements operator-(const MatrixOfElements & a, const MatrixOfElements & b);
MatrixOfElements operator*(const MatrixOfElements & a, const MatrixOfElements & b);
VectorOfElements operator*(const VectorOfElements & a, const MatrixOfElements & b);
VectorOfElements operator*(const MatrixOfElements & a, const VectorOfElements & b);
MatrixOfElements operator/(const MatrixOfElements & a, const VectorOfElements & b);
MatrixOfElements transpose(MatrixOfElements & source);
MatrixOfElements elementProduct(const VectorOfElements & a, const VectorOfElements & b);
VectorOfElements trace(const MatrixOfElements & a);
VectorOfElements trace(const MatrixOfElements & a, const MatrixOfElements & b);
MatrixOfElements generateME(const VectorOfElements & a);
MatrixOfElements generateME(const VectorOfElements & a,VectorOfElements & b);
MatrixOfElements generateME(const VectorOfElements & a,
const VectorOfElements & b,
const VectorOfElements & c);
MatrixOfElements generateME(const VectorOfElements *a, unsigned int n);
MatrixOfElements generateME(const vector<VectorOfElements> &a);
VectorOfElements getDiagonal(const MatrixOfElements & a);
VectorOfElements getOffDiagonalUp(const MatrixOfElements & a);
VectorOfElements det(const MatrixOfElements & m);
VectorOfElements solveSystem(const MatrixOfElements & a, const VectorOfElements & b);
vector<Element> gcSolveSystem(const MatrixOfElements & a,
const VectorOfElements & b,
const VectorOfElements & x);
vector<Element> gcSolveSystemCG(const MatrixOfElements & a,
const VectorOfElements & b,
const VectorOfElements & x);
MatrixOfElements replaceRow(const MatrixOfElements & a, const VectorOfElements & b, unsigned int r);
MatrixOfElements replaceColumn(const MatrixOfElements & a, const VectorOfElements & b, unsigned int c);
MatrixOfElements generateMatrixCofactors(const MatrixOfElements & a);
vector<Element> gcMatrixInversion(const MatrixOfElements & a, MatrixOfElements & inv);
// ------------------------------ Implementation -----------------
inline void MatrixOfElements::resize(unsigned int nr, unsigned int nc)
{
nRow=nr;
nCol=nc;
ve.resize(nr*nc);
}
} //namespace acl
#endif // ACLMATRIXOFELEMENTS_H
acl::MatrixOfElements
The class represents a matrix elements of Element.
Definition: aclMatrixOfElements.h:36
acl::MatrixOfElements::operator-
MatrixOfElements operator-(const MatrixOfElements &a, const MatrixOfElements &b)
difference of two matrices
acl::MatrixOfElements::elementProduct
MatrixOfElements elementProduct(const VectorOfElements &a, const VectorOfElements &b)
element product of two vectors
acl::MatrixOfElements::getElement
const Element getElement(unsigned int r, unsigned int c) const
acl::MatrixOfElements::setRow
void setRow(unsigned int r, const VectorOfElements &a)
acl::MatrixOfElements::setColumn
void setColumn(unsigned int c, const VectorOfElements &a)
acl::MatrixOfElements::det
VectorOfElements det(const MatrixOfElements &m)
computes determinant expression fo cases 2x2 and 3x3 only
acl::MatrixOfElements::getInternalVector
VectorOfElements & getInternalVector()
acl::MatrixOfElements::resize
void resize(unsigned int nr, unsigned int nc)
acl::MatrixOfElements::operator=
MatrixOfElements operator=(const MatrixOfElements &m)
acl::MatrixOfElements::generateME
MatrixOfElements generateME(const vector< VectorOfElements > &a)
generates a matrix with n rows
acl::MatrixOfElements::operator+
MatrixOfElements operator+(const MatrixOfElements &a, const MatrixOfElements &b)
summ of two matrices
acl::MatrixOfElements::getNColumns
const unsigned int getNColumns() const
acl::MatrixOfElements::trace
VectorOfElements trace(const MatrixOfElements &a, const MatrixOfElements &b)
Trace of a matrix product
acl::MatrixOfElements::operator*
VectorOfElements operator*(const VectorOfElements &a, const MatrixOfElements &b)
product of vector and matrix
acl::MatrixOfElements::setElement
void setElement(unsigned int r, unsigned int c, Element a)
acl::MatrixOfElements::trace
VectorOfElements trace(const MatrixOfElements &a)
Trace of a matrix
acl::MatrixOfElements::getInternalVector
const VectorOfElements & getInternalVector() const
acl::MatrixOfElements::gcMatrixInversion
vector< Element > gcMatrixInversion(const MatrixOfElements &a, MatrixOfElements &inv)
returns vector of elements for computing the inverse matrix for cases 2x2 and 3x3
acl::MatrixOfElements::transpose
MatrixOfElements transpose(MatrixOfElements &source)
transposed matrix
acl::MatrixOfElements::generateMatrixCofactors
MatrixOfElements generateMatrixCofactors(const MatrixOfElements &a)
returns the matrix of cofactors for cases 2x2 and 3x3
acl::MatrixOfElements::generateME
MatrixOfElements generateME(const VectorOfElements &a)
generates a matrix with a row
acl::MatrixOfElements::generateME
MatrixOfElements generateME(const VectorOfElements &a, const VectorOfElements &b, const VectorOfElements &c)
generates a matrix with three rows
acl::MatrixOfElements::getOffDiagonalUp
VectorOfElements getOffDiagonalUp(const MatrixOfElements &a)
returns VectorOfElements containing the uper off diagonal elements
acl::MatrixOfElements::replaceColumn
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
acl::MatrixOfElements::copy
void copy(const MatrixOfElements &source, MatrixOfElements &destination)
function copies the MatrixOfElements class.
acl::MatrixOfElements::replaceRow
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
acl::MatrixOfElements::MatrixOfElements
MatrixOfElements(unsigned int nR=0, unsigned int nC=0)
acl::MatrixOfElements::generateME
MatrixOfElements generateME(const VectorOfElements &a, VectorOfElements &b)
generates a matrix with two rows
acl::MatrixOfElements::getDiagonal
VectorOfElements getDiagonal(const MatrixOfElements &a)
returns VectorOfElements containing the diagonal elements
acl::MatrixOfElements::operator/
MatrixOfElements operator/(const MatrixOfElements &a, const VectorOfElements &b)
division of a matrix on a VectorOfElements with 1 element
acl::MatrixOfElements::generateME
MatrixOfElements generateME(const VectorOfElements *a, unsigned int n)
generates a matrix with n rows
acl::MatrixOfElements::getNRows
const unsigned int getNRows() const
acl::MatrixOfElements::operator*
MatrixOfElements operator*(const MatrixOfElements &a, const MatrixOfElements &b)
product of two matrices
acl::MatrixOfElements::getVE
const VectorOfElements getVE(unsigned int r, unsigned int c) const
acl::MatrixOfElements::operator*
VectorOfElements operator*(const MatrixOfElements &a, const VectorOfElements &b)
product of vector and matrix
acl::VectorOfElements
The class represents several Element.
Definition: aclVectorOfElementsDef.h:92
acl::gcSolveSystemCG
vector< Element > gcSolveSystemCG(const MatrixOfElements &a, const VectorOfElements &b, const VectorOfElements &x)
generates code for solving the solution of a system of linear equations
acl::solveSystem
VectorOfElements solveSystem(const MatrixOfElements &a, const VectorOfElements &b)
returns solution of a system of linear equations
acl::gcSolveSystem
vector< Element > gcSolveSystem(const MatrixOfElements &a, const VectorOfElements &b, const VectorOfElements &x)
generates code for solving the solution of a system of linear equations
acl
Advanced Computational Language.
Definition: acl.h:41
acl::Element
std::shared_ptr< ElementBase > Element
Definition: acl.h:49
aclVectorOfElementsDef.h