33 #ifndef FAMG_ADDITIONAL_MATH_H_
34 #define FAMG_ADDITIONAL_MATH_H_
47 for (
size_t i = 1; i < vec.size(); i++)
69 template<
typename T1,
typename T2>
72 for (
size_t r = 0; mat.num_rows(); r++)
75 for (
size_t c = 1; c < mat.num_cols(); c++)
81 template<
typename T1,
typename T2>
93 for (
size_t r = 0; mat.num_rows(); r++)
94 for (
size_t c = 1; c < mat.num_cols(); c++)
104 template<
typename T1>
108 const size_t rk = (mat.num_rows() < mat.num_cols()) ? mat.num_rows() : mat.num_cols();
109 for (
size_t k = 0; k<rk; k++)
121 template<
typename T1>
126 const size_t rk = (mat.num_rows() < mat.num_cols()) ? mat.num_rows() : mat.num_cols();
127 for (
size_t k = 0; k<rk; k++)
129 double abs=fabs(mat(k, k));
149 template<
typename T1,
typename T2>
152 UG_ASSERT(m.num_rows()==m.num_cols(),
"");
153 m1.resize(m.num_rows(), m.num_rows());
155 for (
size_t i = 0; i < m.num_rows(); i++)
159 template<
typename T1,
typename T2>
162 UG_ASSERT(m.num_rows()==m.num_cols(),
"");
163 v.resize(m.num_rows());
164 for (
size_t i = 0; i < m.num_rows(); i++)
165 v[i] = sqrt(m(i, i));
178 template<
typename T1,
typename T2>
182 for (
size_t r = 0; r < M.num_rows(); r++)
185 for (
size_t c = 0; c < M.num_cols(); c++)
186 t += M(r, c) * v2[c];
192 template<
typename TMatrix>
196 Ad.resize(blockSize*Ab.num_rows(), blockSize*Ab.num_cols());
198 for(
size_t i=0; i<Ab.num_rows(); i++)
200 for(
size_t j=0; j<Ab.num_cols(); j++)
201 for(
size_t r=0; r<blockSize; r++)
202 for(
size_t c=0; c<blockSize; c++)
203 Ad(i*blockSize+r, j*blockSize+c) =
BlockRef(Ab(i, j), r, c);
Definition: densematrix.h:57
TStorage::value_type value_type
Definition: densematrix.h:59
Definition: variable_array.h:139
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
void matSum(double &erg, double alpha, double vec)
Definition: additional_math.h:64
void GetDiagSqrt(T1 &v, const T2 &m)
Definition: additional_math.h:160
DenseMatrix< T1 >::value_type Sum1Mat1(const DenseMatrix< T1 > &mat)
Definition: additional_math.h:90
double matDiagMax(const double d)
Definition: additional_math.h:116
double matTrace(const double d)
Definition: additional_math.h:99
double EnergyProd(vector_type &v1, matrix_type &A, vector_type &v2, vector_type &tmp)
Definition: additional_math.h:90
double & BlockRef(T &vec, size_t i)
Definition: blocks.h:66
void vecSum(double &erg, double alpha, double vec)
Definition: additional_math.h:38
void BlockMatrixToDoubleMatrix(DenseMatrix< VariableArray2< double > > &Ad, TMatrix &Ab)
Definition: additional_math.h:193
void GetDiag(double &a, double b)
Definition: additional_math.h:144
T value_type
Definition: sparsematrix_interface.h:2
Definition: communication_policies.h:58