39 #include "../../types.h"
52 template <std::
size_t N, std::
size_t M,
typename T = number>
class MathMatrix;
61 template <std::
size_t N, std::
size_t M,
typename T>
94 for(std::size_t i = 0; i < N; ++i){
95 for(std::size_t j = 0; j < M; ++j){
110 for(std::size_t i = 0; i < N; ++i){
111 for(std::size_t j = 0; j < M; ++j){
126 for(std::size_t i = 0; i < N; ++i){
127 for(std::size_t j = 0; j < M; ++j){
142 for(std::size_t i = 0; i < N; ++i){
143 for(std::size_t j = 0; j < M; ++j){
158 for(std::size_t i = 0; i < N; ++i){
159 for(std::size_t j = 0; j < M; ++j){
174 for(std::size_t i = 0; i < N; ++i){
175 for(std::size_t j = 0; j < M; ++j){
190 for(std::size_t i = 0; i < N; ++i){
191 for(std::size_t j = 0; j < M; ++j){
207 for(std::size_t i = 0; i < N; ++i){
208 for(std::size_t j = 0; j < M; ++j){
209 res +=
m_data[i][j] * v.m_data[i][j];
228 UG_ASSERT(row < N && col < M,
"Accessing "<<N<<
"x"<<M<<
"Matrix at entry ("<<row<<
","<<col<<
")");
232 UG_ASSERT(row < N && col < M,
"Accessing "<<N<<
"x"<<M<<
"Matrix at entry ("<<row<<
","<<col<<
")");
237 inline const value_type&
entry(std::size_t row, std::size_t col)
const {
return (*
this)(row,col);}
241 for(std::size_t j = 0; j < N; j++)
250 for(std::size_t i = 0; i < N; ++i){
251 for(std::size_t j = 0; j < M; ++j){
252 m_data[i][j] = v.m_data[i][j] ;
266 template <std::
size_t N,
typename T>
class MathMatrix<N,0,T>{
271 template <std::
size_t N,
typename T>
class MathMatrix<0,N,T>{
279 template <std::
size_t N, std::
size_t M>
282 for(std::size_t i = 0; i < N; ++i)
284 for(std::size_t j = 0; j < M; ++j)
286 outStream <<
"[" << i <<
"][" << j <<
"]: " << std::scientific << std::setprecision(8) << std::setw(15) << m.
entry(i, j) << std::endl;
std::size_t size_type
Definition: math_matrix.h:264
T value_type
Definition: math_matrix.h:263
T value_type
Definition: math_matrix.h:273
std::size_t size_type
Definition: math_matrix.h:274
T value_type
Definition: math_matrix.h:268
std::size_t size_type
Definition: math_matrix.h:269
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
const value_type * operator[](std::size_t index) const
Definition: math_matrix.h:222
MathMatrix(const MathMatrix &v)
Definition: math_matrix.h:72
void assign(const MathMatrix &v)
Definition: math_matrix.h:248
MathMatrix & operator=(const MathMatrix &v)
Assigns the elements of the given matrix to this one.
Definition: math_matrix.h:80
MathMatrix & operator/=(const value_type &val)
Divides all elements of the matrix by the given value.
Definition: math_matrix.h:172
value_type & entry(std::size_t row, std::size_t col)
Definition: math_matrix.h:236
value_type m_data[N][M]
Definition: math_matrix.h:246
static const std::size_t ColSize
Definition: math_matrix.h:68
std::size_t size_type
Definition: math_matrix.h:66
value_type operator*(const MathMatrix &v) const
Multiplies the matrix element-wise with another matrix and sums up the entries.
Definition: math_matrix.h:204
static const std::size_t RowSize
Definition: math_matrix.h:67
value_type * operator[](std::size_t index)
Definition: math_matrix.h:218
T value_type
Definition: math_matrix.h:65
std::size_t num_cols() const
Definition: math_matrix.h:216
std::size_t num_rows() const
Definition: math_matrix.h:215
MathMatrix & operator-=(const MathMatrix &B)
Subtracts a matrix from 'this' one: .
Definition: math_matrix.h:108
value_type & operator()(std::size_t row, std::size_t col)
Definition: math_matrix.h:227
MathMatrix()
Definition: math_matrix.h:71
const value_type & entry(std::size_t row, std::size_t col) const
Definition: math_matrix.h:237
MathMatrix & operator*=(const value_type &val)
Multiplies all elements of the matrix with the given value.
Definition: math_matrix.h:188
void assign(const MathVector< N, value_type > &vec, const std::size_t row)
Definition: math_matrix.h:239
MathMatrix & operator+=(const MathMatrix &B)
Adds a matrix to 'this' one: .
Definition: math_matrix.h:92
a mathematical Vector with N entries.
Definition: math_vector.h:97
static const std::size_t Size
Definition: math_vector.h:101
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition: math_matrix.cpp:38
#define UG_ASSERT(expr, msg)
Definition: assert.h:70