47 typedef memory::shared_ptr<gsPreconditionerOp>
Ptr;
50 typedef memory::unique_ptr<gsPreconditionerOp>
uPtr;
81 x.setZero(this->
rows(),input.cols());
82 for (
index_t i = 0; i < m_num_of_sweeps; ++i )
92 GISMO_ASSERT ( n > 0,
"Number of sweeps needs to be positive." );
99 return m_num_of_sweeps;
106 opt.
addInt(
"NumOfSweeps",
"Number of sweeps to be applied in the member function apply", 1 );
114 m_num_of_sweeps = opt.
askInt(
"NumOfSweeps", m_num_of_sweeps );
124 x.setRandom(this->
rows(),1);
125 for (
index_t i=0; i<steps; ++i)
127 x.array() /= math::sqrt( x.col(0).dot(x.col(0)) );
129 x.setZero(this->
rows(),1);
132 return math::sqrt( x.col(0).dot(x.col(0)) );
156 typedef memory::shared_ptr<gsPreconditionerFromOp>
Ptr;
159 typedef memory::unique_ptr<gsPreconditionerFromOp>
uPtr;
174 : m_underlying(
give(underlying)), m_preconditioner(
give(preconditioner)), m_tau(tau)
176 GISMO_ASSERT( m_underlying->rows() == m_underlying->cols()
177 && m_preconditioner->rows() == m_preconditioner->cols()
178 && m_underlying->rows() == m_preconditioner->rows(),
179 "The dimensions do not agree." );
193 GISMO_ASSERT( m_underlying->rows() == x.rows() && x.rows() == rhs.rows() && x.cols() == rhs.cols(),
194 "The dimensions do not agree." );
196 m_underlying->apply(x, m_res);
198 m_preconditioner->apply(m_res, m_corr);
206 GISMO_ASSERT( m_underlying->rows() == rhs.rows(),
"The dimensions do not agree." );
209 m_preconditioner->apply(rhs, x);
213 for (
index_t i=1; i<m_num_of_sweeps; ++i)
215 m_underlying->apply(x, m_res);
217 m_preconditioner->apply(m_res, m_corr);
232 opt.
addReal(
"Damping",
"Damping parameter of the operator preconditioner", 1 );
240 m_tau = opt.
askReal(
"Damping", m_tau );
T estimateLargestEigenvalueOfPreconditionedSystem(index_t steps=10) const
Estimates the largest eigenvalue of .
Definition: gsPreconditioner.h:121
virtual void setOptions(const gsOptionList &opt)
Set options based on a gsOptionList object.
Definition: gsPreconditioner.h:111
void step(const gsMatrix< T > &rhs, gsMatrix< T > &x) const
Apply the method for given right hand side and current iterate.
Definition: gsPreconditioner.h:191
gsLinearOperator< T >::Ptr BasePtr
Base class.
Definition: gsPreconditioner.h:56
T getDamping() const
Get damping parameter.
Definition: gsPreconditioner.h:226
virtual index_t rows() const =0
Returns the number of rows of the operator.
static gsOptionList defaultOptions()
Get the default options as gsOptionList object.
Definition: gsLinearOperator.h:65
S give(S &x)
Definition: gsMemory.h:266
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
apply the operator on the input vector and store the result in x
Definition: gsPreconditioner.h:79
#define index_t
Definition: gsConfig.h:32
index_t numOfSweeps()
Get the number of sweeps to be applied in the member function apply.
Definition: gsPreconditioner.h:97
virtual void setOptions(const gsOptionList &)
Set options based on a gsOptionList object.
Definition: gsLinearOperator.h:69
void setDamping(const T tau)
Set damping parameter.
Definition: gsPreconditioner.h:223
Simple class allowing to construct a preconditioner from a linear operator.
Definition: gsPreconditioner.h:151
gsLinearOperator< T > Base
Base class.
Definition: gsPreconditioner.h:53
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
gsLinearOperator< T > Base
Base class.
Definition: gsPreconditioner.h:162
void addInt(const std::string &label, const std::string &desc, const index_t &value)
Adds a option named label, with description desc and value value.
Definition: gsOptionList.cpp:201
Provides a list of labeled parameters/options that can be set and accessed easily.
static uPtr make(BasePtr underlying, BasePtr preconditioner, T tau=(T) 1)
Make function returning a smart pointer.
Definition: gsPreconditioner.h:188
memory::unique_ptr< gsPreconditionerFromOp > uPtr
Unique pointer for gsLinearOperator.
Definition: gsPreconditioner.h:159
virtual BasePtr underlyingOp() const =0
Return the underlying operator .
memory::shared_ptr< gsLinearOperator > Ptr
Shared pointer for gsLinearOperator.
Definition: gsLinearOperator.h:33
virtual void step(const gsMatrix< T > &rhs, gsMatrix< T > &x) const =0
Apply the method for given right hand side and current iterate.
void setNumOfSweeps(index_t n)
Set the number of sweeps to be applied in the member function apply.
Definition: gsPreconditioner.h:90
memory::unique_ptr< gsLinearOperator > uPtr
Unique pointer for gsLinearOperator.
Definition: gsLinearOperator.h:36
memory::unique_ptr< gsPreconditionerOp > uPtr
Unique pointer for gsLinearOperator.
Definition: gsPreconditioner.h:50
Simple abstract class for perconditioners.
Definition: gsPreconditioner.h:42
gsLinearOperator< T >::Ptr BasePtr
Base class.
Definition: gsPreconditioner.h:165
Real askReal(const std::string &label, const Real &value=0) const
Reads value for option label from options.
Definition: gsOptionList.cpp:139
memory::shared_ptr< gsPreconditionerFromOp > Ptr
Shared pointer for gsLinearOperator.
Definition: gsPreconditioner.h:156
Simple abstract class for discrete operators.
Definition: gsLinearOperator.h:28
index_t askInt(const std::string &label, const index_t &value=0) const
Reads value for option label from options.
Definition: gsOptionList.cpp:117
void addReal(const std::string &label, const std::string &desc, const Real &value)
Adds a option named label, with description desc and value value.
Definition: gsOptionList.cpp:211
virtual void stepT(const gsMatrix< T > &rhs, gsMatrix< T > &x) const
Apply the transposed variant of the method for given right hand side and current iterate.
Definition: gsPreconditioner.h:76
void apply(const gsMatrix< T > &rhs, gsMatrix< T > &x) const
apply the operator on the input vector and store the result in x
Definition: gsPreconditioner.h:204
BasePtr underlyingOp() const
Return the underlying operator .
Definition: gsPreconditioner.h:243
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
static gsOptionList defaultOptions()
Get the default options as gsOptionList object.
Definition: gsPreconditioner.h:229
static gsOptionList defaultOptions()
Get the default options as gsOptionList object.
Definition: gsPreconditioner.h:103
index_t cols() const
Returns the number of columns of the operator.
Definition: gsPreconditioner.h:245
index_t rows() const
Returns the number of rows of the operator.
Definition: gsPreconditioner.h:244
Simple abstract class for (discrete) linear operators.
void setOptions(const gsOptionList &opt)
Set options based on a gsOptionList object.
Definition: gsPreconditioner.h:237
memory::shared_ptr< gsPreconditionerOp > Ptr
Shared pointer for gsLinearOperator.
Definition: gsPreconditioner.h:47