So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
BlockSolverBase.hpp
1 /*
2  * This file is part of bogus, a C++ sparse block matrix library.
3  *
4  * Copyright 2013 Gilles Daviet <gdaviet@gmail.com>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10 
11 #ifndef BOGUS_BLOCK_SOLVER_BASE_HPP
12 #define BOGUS_BLOCK_SOLVER_BASE_HPP
13 
14 #include "../Block.fwd.hpp"
15 #include "../BlockSolvers.fwd.hpp"
16 
17 #ifndef BOGUS_WITHOUT_EIGEN
18 #include "../Eigen/EigenProblemTraits.hpp"
19 #include "../Eigen/EigenBlockContainers.hpp"
20 #endif
21 
22 #include "../Utils/Signal.hpp"
23 
24 namespace bogus
25 {
26 
28 template < typename BlockMatrixType >
30 {
31 public:
33  typedef typename BlockTraits::Scalar Scalar ;
36 
37  virtual ~BlockSolverBase() { }
38 
40  void setMaxIters( unsigned maxIters ) { m_maxIters = maxIters ; }
41  unsigned maxIters() const { return m_maxIters ; }
42 
44  void setTol( Scalar tol ) { m_tol = tol ; }
45  Scalar tol() const { return m_tol ; }
46 
48 
52  CallBackType &callback() { return m_callback ; }
53  const CallBackType &callback() const { return m_callback ; }
54 
55  const BlockObjectBase< BlockMatrixType > &matrix() const { return *m_matrix ; }
56 
57 protected:
58 
59  BlockSolverBase( const BlockObjectBase< BlockMatrixType > * matrix = BOGUS_NULL_PTR(const BlockObjectBase< BlockMatrixType >),
60  unsigned maxIters = 0, Scalar tol = 0 )
61  : m_matrix( matrix ), m_maxIters( maxIters ), m_tol( tol )
62  {}
63 
66 
68  unsigned m_maxIters;
70  Scalar m_tol ;
71 
72  CallBackType m_callback ;
73 } ;
74 
75 } //namespace bogus
76 
77 #endif
CallBackType & callback()
Callback hook; will be triggered every N iterations, depending on the solver.
Definition: BlockSolverBase.hpp:52
Definition: Traits.hpp:19
Scalar m_tol
See setTol()
Definition: BlockSolverBase.hpp:70
Definition: BlockSolvers.fwd.hpp:33
Base class for solvers that operate on BlockMatrixBase matrices.
Definition: BlockSolverBase.hpp:29
const BlockObjectBase< BlockMatrixType > * m_matrix
Pointer to the matrix of the system.
Definition: BlockSolverBase.hpp:65
unsigned m_maxIters
See setMaxIters()
Definition: BlockSolverBase.hpp:68
void setTol(Scalar tol)
For iterative solvers: sets the solver tolerance.
Definition: BlockSolverBase.hpp:44
void setMaxIters(unsigned maxIters)
For iterative solvers: sets the maximum number of iterations.
Definition: BlockSolverBase.hpp:40