44template<
class ColVector>
48 {
return ColVector();}
85template<
class MultFunctor,
class ColVector,
class InitFunctor = DefaultFunctor<ColVector> >
89 typedef typename ColVector::Type
Type;
126 inline ColVector
const&
x()
const {
return x_;}
128 inline Real const&
x(
int const&
i)
const {
return x_[
i];}
134 inline ColVector
const&
r()
const {
return r_;}
164 else {
x_ = (*p_init_)();}
187 r_ =
r_ - (alpha *
z);
195 if(
step > 50 ) {
break;}
263template<
class MultFunctor,
class CondFunctor,
class ColVector,
class InitFunctor = DefaultFunctor<ColVector> >
267 typedef typename ColVector::Type
Type;
299 inline ColVector
const&
x()
const {
return x_;}
301 inline Real const&
x(
int const&
i)
const {
return x_[
i];}
303 inline ColVector
const&
r()
const {
return r_;}
334 else {
x_ = (*p_init_)();}
352 alpha =
rty/
p.dot(
z);
358 r_ =
r_ - (alpha *
z);
This file include all the other header files of the project Sdk.
The conjugate gradient method is an algorithm for the numerical solution of particular systems of lin...
int const & nbStart() const
void setEps(Type const &eps)
Set the tolerance.
Real const & x(int const &i) const
int nbStart_
number of restart_
CG * clone() const
clone pattern
CG(CG const &cg)
Copy constructor.
String const & error() const
get the last error message.
CG(MultFunctor const &mult, ColVector const &b, InitFunctor *const &p_init=0, Type eps=Arithmetic< Type >::epsilon())
Constructor.
String msg_error_
String with the last error message.
ColVector const & x() const
void setB(ColVector const &b)
Set the constant vector.
ColVector r_
residuals of the system
MultFunctor const * p_mult_
pointer on the functor performing Ax
ColVector const * p_b_
constant pointer on the second member of the system
void setInitFunctor(InitFunctor *const &p_init)
Set functor computing x at initialization.
ColVector const & r() const
InitFunctor const * p_init_
pointer on the functor initializing x
int iter_
number of iterations
ColVector x_
solution of the system
void setMultFunctor(MultFunctor const &mult)
Set functor computing Ax.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
In most cases, preconditioning is necessary to ensure fast convergence of the conjugate gradient meth...
String msg_error_
String with the last error message.
String const & error() const
get the last error message.
int run()
run the conjugate gradient
void setInitFunctor(InitFunctor const &init)
Set functor computing x at initialization.
PCG(PCG const &pcg)
Copy constructor.
ColVector const & x() const
CondFunctor const * p_cond_
pointer on the functor performing
void setB(ColVector const &b)
Set the constant vector.
ColVector x_
solution of the system
void setMultFunctor(MultFunctor const &mult)
Set functor computing Ax.
void setEps(Type const &eps)
Set the tolerance.
InitFunctor const * p_init_
pointer on the functor initializing x
Real const & x(int const &i) const
int iter_
number of iterations
int pcg()
preconditioned Gradient implementation
ColVector const * p_b_
constant pointer on the second member of the system
ColVector const & r() const
ColVector r_
residuals of the system
PCG * clone() const
clone pattern
MultFunctor const * p_mult_
pointer on the functor performing Ax
void setCondFunctor(CondFunctor const &cond)
Set functor computing the value .
Arrays::MultOp< Lhs, Rhs >::result_type mult(Lhs const &lhs, Rhs const &rhs)
convenience function for the multiplication of two matrices
std::basic_string< Char > String
STK fundamental type of a String.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.
ColVector operator()() const