33 #ifndef __UG__ADDITIONAL_MATH_H__
34 #define __UG__ADDITIONAL_MATH_H__
38 #define PINVIT_PROFILE_FUNC() PROFILE_FUNC_GROUP("pinvit algebra")
39 #define PINVIT_PROFILE_BEGIN(t) PROFILE_BEGIN_GROUP(t, "pinvit algebra")
40 #define PINVIT_PROFILE_END() PROFILE_END()
68 return fabs(a) < fabs(b);
73 template<
typename vector_type,
typename densematrix_type>
79 UG_ASSERT(n == rA.num_rows() && n == rA.num_cols(),
"");
80 for(
size_t r=0; r<n; r++)
81 for(
size_t c=r; c<n; c++)
82 rA(r, c) = px[c]->dotprod(*px[r]);
84 for(
size_t r=0; r<n; r++)
85 for(
size_t c=0; c<r; c++)
89 template<
typename matrix_type,
typename vector_type>
100 double a = v1.dotprod(tmp);
106 template<
typename matrix_type,
typename vector_type>
114 template<
typename matrix_type,
typename vector_type>
120 template<
typename matrix_type,
typename vector_type>
129 template<
typename matrix_type,
typename vector_type,
typename densematrix_type>
138 UG_ASSERT(n == rA.num_rows() && n == rA.num_cols(),
"");
144 for(
size_t r=0; r<n; r++)
153 for(
size_t c=r; c<n; c++)
155 double a = px(c).dotprod(t);
156 rA(c, r) = rA(r, c) = a;
164 for(
size_t r=0; r<n; r++)
168 for(
size_t r=0; r<n; r++)
174 for(
size_t c=r; c<n; c++)
175 rA(c, r) = rA(r, c) = px[c]->dotprod(t);
182 template<
typename tvector>
189 UG_LOG(
"PST_CONSISTENT ");
200 template<
typename matrix_type>
204 for(
size_t r=0; r<mat.num_rows(); r++)
207 for(
size_t c=0; c<mat.num_cols(); c++)
210 if(c < mat.num_cols()-1)
UG_LOG(
",\t");
218 template<
typename matrix_type>
222 for(
size_t r=0; r<mat.num_rows(); r++)
225 for(
size_t c=0; c<mat.num_cols(); c++)
228 if(c < mat.num_cols()-1)
UG_LOG(
", ");
231 if(r < mat.num_rows()-1)
UG_LOG(
", ");
234 UG_LOG(
"(" << mat.num_rows() <<
" x " << mat.num_cols() <<
")\n");
242 memcpy(c, &a,
sizeof(T));
243 memcpy(&a, &b,
sizeof(T));
244 memcpy(&b, c,
sizeof(T));
location name
Definition: checkpoint_util.lua:128
Definition: pcl_process_communicator.h:70
Definition: densematrix.h:57
Wrapper for sequential matrices to handle them in parallel.
Definition: parallel_matrix.h:65
bool apply(TPVector &res, const TPVector &x) const
calculate res = A x
Definition: parallel_matrix_impl.h:83
@ PST_UNDEFINED
Definition: parallel_storage_type.h:67
@ PST_CONSISTENT
Definition: parallel_storage_type.h:68
@ PST_UNIQUE
Definition: parallel_storage_type.h:70
@ PST_ADDITIVE
Definition: parallel_storage_type.h:69
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_LOG(msg)
Definition: log.h:367
CPUAlgebra::vector_type vector_type
void CloneVector(Vector< TValueType > &dest, const Vector< TValueType > &src)
Definition: vector_impl.h:341
void MultiScalProd(vector_type &px, DenseMatrix< densematrix_type > &rA, size_t n)
Definition: additional_math.h:74
double EnergyNorm(vector_type &x, matrix_type &A, vector_type &tmp)
Definition: additional_math.h:115
bool absCompare(double a, double b)
Definition: additional_math.h:66
void PrintMaple(const matrix_type &mat, const char *name)
Definition: additional_math.h:219
double EnergyProd(vector_type &v1, matrix_type &A, vector_type &v2, vector_type &tmp)
Definition: additional_math.h:90
void PrintMatrix(const matrix_type &mat, const char *name)
Definition: additional_math.h:201
void MemSwap(T &a, T &b)
Definition: additional_math.h:239
void PrintStorageType(const tvector &v)
Definition: additional_math.h:183
void MultiEnergyProd(matrix_type &A, SmartPtrVector< vector_type > &px, DenseMatrix< densematrix_type > &rA, size_t n)
Definition: additional_math.h:130
#define PINVIT_PROFILE_FUNC()
Definition: additional_math.h:38