33 #ifndef __H__UG__SMALL_ALGEBRA__DENSEMATRIX_INVERT_H__
34 #define __H__UG__SMALL_ALGEBRA__DENSEMATRIX_INVERT_H__
36 #include "../small_matrix/densematrix.h"
37 #include "../small_matrix/densevector.h"
38 #include "../../common/operations.h"
49 template<
typename TStorage>
72 inline void resize(
size_t k,
size_t k2)
91 UG_COND_THROW(mat.num_rows() != mat.num_cols(),
"only for square matrices");
99 if(
densemat.num_rows() == 0)
return false;
107 {
UG_THROW(
"ERROR in 'DenseMatrixInverse::invert': Matrix singular in U(i,i), with i="<<info<<
"\n");}
109 {
UG_THROW(
"ERROR in 'DenseMatrixInverse::invert': i-th argument had had illegal value, with i="<<info<<
"\n");}
114 template<
typename vector_t>
117 if(vec.size() == 0)
return;
120 UG_COND_THROW(info != 0,
"DenseMatrixInverse::mat_mult: getrs failed.");
133 for(
size_t r=0; r<mat.
num_rows(); ++r)
135 for(
size_t c=0; c<mat.
num_cols(); ++c)
137 if(r != mat.
num_rows()-1) out <<
"| ";
140 out <<
" (DenseMatrixInverse " << mat.
num_rows() <<
"x" << mat.
num_cols() <<
", " << ((T::ordering ==
ColMajor) ?
"ColMajor)" :
"RowMajor)");
Definition: densematrix.h:57
Definition: lapack_densematrix_inverse.h:51
double & operator()(int r, int c)
Definition: lapack_densematrix_inverse.h:78
void resize(size_t k, size_t k2)
Definition: lapack_densematrix_inverse.h:72
void resize(size_t k)
Definition: lapack_densematrix_inverse.h:67
bool invert()
Definition: lapack_densematrix_inverse.h:97
std::vector< lapack_int > interchange
Definition: lapack_densematrix_inverse.h:54
void apply(DenseVector< vector_t > &vec) const
Definition: lapack_densematrix_inverse.h:115
size_t num_cols() const
Definition: lapack_densematrix_inverse.h:57
DenseMatrix< TStorage > densemat
Definition: lapack_densematrix_inverse.h:53
size_t num_rows() const
Definition: lapack_densematrix_inverse.h:62
bool set_as_inverse_of(const DenseMatrix< TStorage > &mat)
initializes this object as inverse of mat
Definition: lapack_densematrix_inverse.h:89
friend std::ostream & operator<<(std::ostream &out, const DenseMatrixInverse< T > &mat)
Definition: lapack_densematrix_inverse.h:130
const double & operator()(int r, int c) const
Definition: lapack_densematrix_inverse.h:82
Definition: densevector.h:101
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition: math_matrix.cpp:38
#define UG_THROW(msg)
Definition: error.h:57
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
@ ColMajor
Definition: storage.h:49
@ ModeNoTrans
Definition: lapack.h:80
@ MATRIX_USE_GLOBAL_FUNCTIONS
Definition: matrix_algebra_types.h:69
lapack_int getrs(eTransposeMode transposeMode, lapack_int n, lapack_int nrOfRHS, const float *pColMajorMatrix, lapack_int lda, const lapack_int *pPivot, lapack_float *pRHS, lapack_int ldb)
Definition: lapack.h:231
lapack_int getrf(lapack_int rows, lapack_int cols, lapack_float *pColMajorMatrix, lapack_int lda, lapack_int *pPivot)
Definition: lapack.h:161
Definition: matrix_algebra_types.h:79
static const int type
Definition: matrix_algebra_types.h:80