33 #ifndef __H__LIB_ALGEBRA__LAPACK_LU_OPERATOR__
34 #define __H__LIB_ALGEBRA__LAPACK_LU_OPERATOR__
44 #include "../preconditioner/ilut_scalar.h"
45 #include "../interface/preconditioned_linear_operator_inverse.h"
50 #include "../operator_util.h"
53 template <
typename TAlgebra>
56 typename TAlgebra::vector_type>
80 #ifdef LAPACK_AVAILABLE
111 virtual const char*
name()
const {
return "LU";}
118 UG_LOG(
"Matrix " << A.num_rows() <<
" x " << A.num_rows() <<
" with " << blockSize <<
" x " << blockSize <<
" blocks");
129 UG_LOG(
"LU, using DenseLU on ");
136 if(
m_mat.invert() ==
false)
138 UG_THROW(
"ERROR in Matrix is singular");
189 UG_LOG(
"LU using Sparse LU on ");
209 for(
size_t i=0, k=0; i<b.size(); i++)
211 for(
size_t j=0; j<
GetSize(b[i]); j++)
217 for(
size_t i=0, k=0; i<b.size(); i++)
219 for(
size_t j=0; j<
GetSize(b[i]); j++)
241 if(
m_pMatrix->num_rows() == 0)
return true;
246 UG_LOG(
"ERROR in 'LU::init': No Matrix given.\n");
258 m_size = A.num_rows() * nrOfRows;
273 if(
m_pMatrix->num_rows() == 0)
return true;
281 " wrong size! has to be " <<
m_size <<
", but is " << b <<
" and " << x);
286 for(
size_t i=0; i<b.size(); i++)
313 UG_LOG(
"ERROR in 'LU::init': Cannot init LU Decomposition.\n");
331 UG_LOG(
"ERROR: In 'LU::apply': "
332 "Inadequate storage format of Vector f.\n");
337 UG_LOG(
"ERROR: In 'LU::apply': "
338 "Inadequate storage format of Vector u.\n");
344 UG_ASSERT(f.size() == u.size(),
"Vector sizes have to match!");
348 UG_LOG(
"ERROR in 'LU::apply': "
349 "Cannot apply LU decomposition.\n");
368 if(!
apply(u, f))
return false;
373 UG_LOG(
"ERROR in 'LU::apply_return_defect': "
374 "Cannot apply matmul_minus.\n");
384 std::stringstream ss;
385 ss <<
"LU Decomposition: Direct Solver for Linear Equation Systems.\n";
388 ss <<
" (= always Sparse LU)";
Definition: smart_pointer.h:108
Definition: lapack_densematrix_inverse.h:51
Definition: densevector.h:101
Definition: ilut_scalar.h:53
ConstSmartPtr< IConvergenceCheck< X > > convergence_check() const
returns the convergence check
Definition: linear_operator_inverse.h:202
describes an inverse linear mapping X->Y based on a matrix
Definition: matrix_operator_inverse.h:64
virtual bool init(SmartPtr< MatrixOperator< M, Y, X > > A)=0
initializes this inverse operator for a matrix-based operator
DenseVector< VariableArray1< double > > m_tmp
Definition: lu.h:405
bool solve_dense(vector_type &x, const vector_type &b)
Definition: lu.h:203
virtual bool apply_return_defect(vector_type &u, vector_type &f)
Compute u = L^{-1} * f AND return defect f := f - L*u.
Definition: lu.h:364
bool init_lu(const matrix_type *pA)
initializes the solver for a matrix A
Definition: lu.h:236
bool init_sparse(const matrix_type &A)
Definition: lu.h:181
size_t m_size
Definition: lu.h:408
TAlgebra::matrix_type matrix_type
Matrix type.
Definition: lu.h:66
bool m_bDense
Definition: lu.h:410
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition: lu.h:88
void set_info(bool b)
Definition: lu.h:101
bool init_dense(const matrix_type &A)
returns name of solver
Definition: lu.h:122
LU()
constructor
Definition: lu.h:78
CPUAlgebra::vector_type m_u
Definition: lu.h:406
bool m_bSortSparse
Definition: lu.h:413
size_t m_iMinimumForSparse
Definition: lu.h:412
SmartPtr< MatrixOperator< matrix_type, vector_type > > m_spOperator
Operator to invert.
Definition: lu.h:394
void set_show_progress(bool b)
Definition: lu.h:106
virtual bool apply(vector_type &u, const vector_type &f)
Compute u = L^{-1} * f.
Definition: lu.h:322
virtual std::string config_string() const
returns information about configuration parameters
Definition: lu.h:382
void print_info(const matrix_type &A)
Definition: lu.h:115
SmartPtr< ILUTScalarPreconditioner< algebra_type > > ilut_scalar
Definition: lu.h:411
virtual ~LU()
Destructor.
Definition: lu.h:394
void set_sort_sparse(bool b)
Definition: lu.h:96
IMatrixOperatorInverse< matrix_type, vector_type > base_type
Base type.
Definition: lu.h:69
virtual const char * name() const
returns the name of the operator inverse
Definition: lu.h:111
bool m_bShowProgress
Definition: lu.h:413
TAlgebra algebra_type
Algebra type.
Definition: lu.h:60
bool apply_lu(vector_type &x, const vector_type &b)
Definition: lu.h:271
bool m_bInfo
Definition: lu.h:413
bool solve_sparse(vector_type &x, const vector_type &b)
Definition: lu.h:227
DenseMatrixInverse< DenseMatrix< VariableArray2< double > > > m_mat
inverse
Definition: lu.h:404
void set_minimum_for_sparse(size_t N)
Definition: lu.h:91
virtual bool init(SmartPtr< MatrixOperator< matrix_type, vector_type > > Op)
set operator L, that will be inverted
Definition: lu.h:305
void init_var(const matrix_type &A)
Definition: lu.h:145
CPUAlgebra::vector_type m_b
Definition: lu.h:407
TAlgebra::vector_type vector_type
Vector type.
Definition: lu.h:63
const matrix_type * m_pMatrix
matrix to invert
Definition: lu.h:401
Definition: matrix_operator.h:49
@ PST_CONSISTENT
Definition: parallel_storage_type.h:68
@ PST_ADDITIVE
Definition: parallel_storage_type.h:69
size_t GetDenseDoubleFromSparse(TDenseType &A, const TSparseMatrix &S)
Definition: sparsematrix_util.h:1207
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
double & BlockRef(T &vec, size_t i)
Definition: blocks.h:66
string GetBytesSizeString(size_t s, int length)
Definition: string_util.cpp:489
size_t GetSize(const T &t)
#define PROFILE_BEGIN_GROUP(name, groups)
Definition: profiler.h:255
#define PROFILE_FUNC()
Definition: profiler.h:257
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition: smart_pointer.h:836
Definition: communication_policies.h:58