39 #include "../../types.h"
61 template <std::
size_t N,
typename T = number>
94 for(std::size_t i = 0; i <
m_size; ++i)
109 for(std::size_t i = 0; i <
m_size; ++i)
124 for(std::size_t i = 0; i <
m_size; ++i)
139 for(std::size_t i = 0; i <
m_size; ++i)
154 for(std::size_t i = 0; i <
m_size; ++i)
169 for(std::size_t i = 0; i <
m_size; ++i)
184 for(std::size_t i = 0; i <
m_size; ++i)
200 for(std::size_t i = 0; i < N; ++i)
202 for(std::size_t j = 0; j < N; ++j)
204 res += this->
entry(i,j) * v(i,j);
215 UG_ASSERT(row < N && col < N,
"Accessing "<<N<<
"x"<<N<<
"Matrix at entry ("<<row<<
","<<col<<
")");
216 if (row<col)
return m_data[row * N - (row - 1) * row / 2 + col - row];
217 else return m_data[col * N - (col - 1) * col / 2 + row - col];
222 UG_ASSERT(row < N && col < N,
"Accessing "<<N<<
"x"<<N<<
"Matrix at entry ("<<row<<
","<<col<<
")");
223 if (row<col)
return m_data[row * N - (row - 1) * row / 2 + col - row];
224 else return m_data[col * N - (col - 1) * col / 2 + row - col];
232 UG_ASSERT(row < N && col < N,
"Accessing "<<N<<
"x"<<N<<
"Matrix at entry ("<<row<<
","<<col<<
")");
233 if (row<col)
return m_data[row * N - (row - 1) * row / 2 + col - row];
234 else return m_data[col * N - (col - 1) * col / 2 + row - col];
239 UG_ASSERT(row < N && col < N,
"Accessing "<<N<<
"x"<<N<<
"Matrix at entry ("<<row<<
","<<col<<
")");
240 if (row<col)
return m_data[row * N - (row - 1) * row / 2 + col - row];
241 else return m_data[col * N - (col - 1) * col / 2 + row - col];
247 for (
size_t i=1;i<
m_size-1;i++){
252 for (
size_t diag=1;diag<N-1;diag++)
253 norm -=
m_data[diag * N - (diag - 1) * diag / 2]*
m_data[diag * N - (diag - 1) * diag / 2];
254 return sqrt(2.0*norm);
264 static const size_t m_size = (size_t)((N*N+N)/2);
270 for(std::size_t i = 0; i <
m_size; ++i)
279 template <std::
size_t N>
282 for(std::size_t i = 0; i < N; ++i)
284 for(std::size_t j = 0; j < N; ++j)
286 outStream <<
"[" << i <<
"][" << j <<
"]: " << std::scientific << std::setprecision(8) << std::setw(15) << m.
entry(i, j) << std::endl;
A class for fixed size, dense matrices.
Definition: math_symmetric_matrix.h:63
static const std::size_t ColSize
Definition: math_symmetric_matrix.h:68
value_type & entry(std::size_t row, std::size_t col)
Definition: math_symmetric_matrix.h:213
MathSymmetricMatrix & operator+=(const MathSymmetricMatrix &B)
Adds a matrix to 'this' one: .
Definition: math_symmetric_matrix.h:92
MathSymmetricMatrix(const MathSymmetricMatrix &v)
Definition: math_symmetric_matrix.h:72
MathSymmetricMatrix & operator-=(const MathSymmetricMatrix &B)
Subtracts a matrix from 'this' one: .
Definition: math_symmetric_matrix.h:107
value_type operator*(const MathSymmetricMatrix &v) const
Multiplies the matrix element-wise with another matrix and sums up the entries.
Definition: math_symmetric_matrix.h:197
const value_type & entry(std::size_t row, std::size_t col) const
Definition: math_symmetric_matrix.h:220
const value_type & operator[](std::size_t index) const
Definition: math_symmetric_matrix.h:228
value_type & operator[](std::size_t index)
Definition: math_symmetric_matrix.h:227
MathSymmetricMatrix & operator/=(const value_type &val)
Divides all elements of the matrix by the given value.
Definition: math_symmetric_matrix.h:167
void scale_by_fnorm()
Definition: math_symmetric_matrix.h:258
MathSymmetricMatrix()
Definition: math_symmetric_matrix.h:71
std::size_t size_type
Definition: math_symmetric_matrix.h:66
static const std::size_t RowSize
Definition: math_symmetric_matrix.h:67
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition: math_matrix.cpp:38
MathSymmetricMatrix & operator=(const MathSymmetricMatrix &v)
Assigns the elements of the given matrix to this one.
Definition: math_symmetric_matrix.h:80
static const size_t m_size
Definition: math_symmetric_matrix.h:264
T value_type
Definition: math_symmetric_matrix.h:65
value_type & operator()(std::size_t row, std::size_t col)
Definition: math_symmetric_matrix.h:230
std::size_t num_rows() const
Definition: math_symmetric_matrix.h:210
std::size_t num_cols() const
Definition: math_symmetric_matrix.h:211
MathSymmetricMatrix & operator*=(const value_type &val)
Multiplies all elements of the matrix with the given value.
Definition: math_symmetric_matrix.h:182
value_type m_data[m_size]
Definition: math_symmetric_matrix.h:266
value_type fnorm()
Definition: math_symmetric_matrix.h:245
void assign(const MathSymmetricMatrix &v)
Definition: math_symmetric_matrix.h:268
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
double number
Definition: types.h:124