33 #ifndef __H__UG__CPU_ALGEBRA__LAPACK_INVERT_H__
34 #define __H__UG__CPU_ALGEBRA__LAPACK_INVERT_H__
36 #include "../small_matrix/densematrix.h"
37 #include "../small_matrix/densevector.h"
38 #include "../small_matrix/block_dense.h"
49 std::vector<lapack_int> interchange(mat.num_rows());
51 int info =
getrf(mat.num_rows(), mat.num_cols(), &mat(0,0), mat.num_rows(), &interchange[0]);
53 if(info != 0)
return false;
56 double worksize;
int iWorksize = -1;
57 info =
getri(mat.num_rows(), &mat(0,0), mat.num_rows(), &interchange[0], &worksize, iWorksize);
59 iWorksize = (int)worksize;
61 std::vector<double> work(iWorksize);
63 info =
getri(mat.num_rows(), &mat(0,0), mat.num_rows(), &interchange[0], &work[0], iWorksize);
65 if(info != 0)
return false;
70 template<
typename T,
size_t TUnknowns>
75 int info =
getrf(mat.num_rows(), mat.num_cols(), &mat(0,0), mat.num_rows(), interchange);
76 UG_COND_THROW(info != 0,
"info is " << info << ( info > 0 ?
": Matrix singular in mat(i,i)" :
": i-th argument had an illegal value"));
77 if(info != 0)
return false;
81 double worksize;
int iWorksize = -1;
82 info =
getri(mat.num_rows(), &mat(0,0), mat.num_rows(), interchange, &worksize, iWorksize);
84 iWorksize = (int)worksize;
86 std::vector<double> work;
87 work.resize(iWorksize);
89 info =
getri(mat.num_rows(), &mat(0,0), mat.num_rows(), interchange, &work[0], iWorksize);
91 if(info != 0)
return false;
Definition: densematrix.h:57
Definition: fixed_array.h:135
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
lapack_int getri(lapack_int n, lapack_float *pColMajorMatrix, lapack_int lda, const int *pPivot, lapack_float *pWork, lapack_int worksize)
Definition: lapack.h:306
lapack_int getrf(lapack_int rows, lapack_int cols, lapack_float *pColMajorMatrix, lapack_int lda, lapack_int *pPivot)
Definition: lapack.h:161
bool InvertNdyn(DenseMatrix< T > &mat)
Definition: lapack_invert.h:47
int lapack_int
Definition: lapack.h:71