/usr/include/ASL/acl/aclMath/aclMatrixOfElements.h is in libasl-dev 0.1.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | /*
* 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
{
/// The class represents a matrix elements of ::Element
/**
\ingroup ComplexDataTypes
*/
class MatrixOfElements
{
private:
/// number of columns
unsigned int nRow;
/// number of rows
unsigned int nCol;
VectorOfElements ve;
/// defines convertion rule of matrix indeces \p i and \p j into vector one
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);
};
///function copies the MatrixOfElements class.
/**
\relates MatrixOfElements
*/
void copy(const MatrixOfElements & source, MatrixOfElements & destination);
///summ of two matrices
/**
\relates MatrixOfElements
*/
MatrixOfElements operator+(const MatrixOfElements & a, const MatrixOfElements & b);
///difference of two matrices
/**
\relates MatrixOfElements
*/
MatrixOfElements operator-(const MatrixOfElements & a, const MatrixOfElements & b);
///product of two matrices
/**
\relates MatrixOfElements
*/
MatrixOfElements operator*(const MatrixOfElements & a, const MatrixOfElements & b);
///product of vector and matrix
/**
\relates MatrixOfElements
*/
VectorOfElements operator*(const VectorOfElements & a, const MatrixOfElements & b);
///product of vector and matrix
/**
\relates MatrixOfElements
*/
VectorOfElements operator*(const MatrixOfElements & a, const VectorOfElements & b);
///division of a matrix on a VectorOfElements with 1 element
/**
\relates MatrixOfElements
*/
MatrixOfElements operator/(const MatrixOfElements & a, const VectorOfElements & b);
///transposed matrix
/**
\relates MatrixOfElements
*/
MatrixOfElements transpose(MatrixOfElements & source);
///element product of two vectors
/**
\relates MatrixOfElements
\f$ elementProduct\left(
\left[\begin{array}{c}
a_1\\ \vdots \\ a_n
\end{array}\right],
\left[\begin{array}{c}
b_1\\ \vdots \\ b_n
\end{array}\right]\right) =
\left[\begin{array}{ccc}
a_1b_1 & \cdots & a_1b_n\\
\vdots & \ddots & \vdots\\
a_nb_1 & \cdots & a_nb_n\\
\end{array}\right]
\f$, \f$A_{ij} = a_i b_j \f$
*/
MatrixOfElements elementProduct(const VectorOfElements & a, const VectorOfElements & b);
///Trace of a matrix \f$Tr(A)\equiv A_{ii}\f$ \relates MatrixOfElements
VectorOfElements trace(const MatrixOfElements & a);
///Trace of a matrix product \f$Tr(A B)\equiv A_{ij}B_{ji}\f$ \relates MatrixOfElements
VectorOfElements trace(const MatrixOfElements & a, const MatrixOfElements & b);
/// generates a matrix with a row \relates MatrixOfElements
MatrixOfElements generateME(const VectorOfElements & a);
/// generates a matrix with two rows \relates MatrixOfElements
MatrixOfElements generateME(const VectorOfElements & a,VectorOfElements & b);
/// generates a matrix with three rows \relates MatrixOfElements
MatrixOfElements generateME(const VectorOfElements & a,
const VectorOfElements & b,
const VectorOfElements & c);
/// generates a matrix with \p n rows \f$ generateME(\{u_i\}_j) = A_{ji}\f$ \relates MatrixOfElements
MatrixOfElements generateME(const VectorOfElements *a, unsigned int n);
/// generates a matrix with \p n rows \f$ generateME(\{u_i\}_j) = A_{ji}\f$ \relates MatrixOfElements
MatrixOfElements generateME(const vector<VectorOfElements> &a);
/// returns VectorOfElements containing the diagonal elements
/**
\relates MatrixOfElements
the finction is valid only for square matrices
*/
VectorOfElements getDiagonal(const MatrixOfElements & a);
/// returns VectorOfElements containing the uper off diagonal elements
/**
\relates MatrixOfElements
the finction is valid only for square matrices
*/
VectorOfElements getOffDiagonalUp(const MatrixOfElements & a);
/// computes determinant expression fo cases 2x2 and 3x3 only
/**
\relates MatrixOfElements
*/
VectorOfElements det(const MatrixOfElements & m);
/// returns solution of a system of linear equations
/**
\ingroup ComplexDataTypes
*/
VectorOfElements solveSystem(const MatrixOfElements & a, const VectorOfElements & b);
/// generates code for solving the solution of a system of linear equations
/**
\ingroup ComplexDataTypes
Solves system of 2 or 3 equations with the Cramer's rule
*/
vector<Element> gcSolveSystem(const MatrixOfElements & a,
const VectorOfElements & b,
const VectorOfElements & x);
/// generates code for solving the solution of a system of linear equations
/**
\ingroup ComplexDataTypes
Solves system of an arbiterary number of equations with the conjugate gradient method.
The function constructs the algorithm with number of iterations of vector size. The initial
value of \f$ x_0 \f$ is \f$b\f$.
*/
vector<Element> gcSolveSystemCG(const MatrixOfElements & a,
const VectorOfElements & b,
const VectorOfElements & x);
/// generate matrix with content of the matrix \p a but with replaced row \p r by vector \p b \relates MatrixOfElements
MatrixOfElements replaceRow(const MatrixOfElements & a, const VectorOfElements & b, unsigned int r);
/// generate matrix with content of the matrix \p a but with replaced column \p c by vector \p b \relates MatrixOfElements
MatrixOfElements replaceColumn(const MatrixOfElements & a, const VectorOfElements & b, unsigned int c);
/// returns the matrix of cofactors for cases 2x2 and 3x3 \relates MatrixOfElements
MatrixOfElements generateMatrixCofactors(const MatrixOfElements & a);
/// returns vector of elements for computing the inverse matrix for cases 2x2 and 3x3 \relates MatrixOfElements
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
|