/*!@addtogroup Solvers */
/*@{*/
+namespace internal
+{
+ /**
+ * Class containing the non-parameter non-template values used by the
+ * SolverBicgstab class.
+ */
+ class SolverBicgstabData
+ {
+ protected:
+ /**
+ * Auxiliary value.
+ */
+ double alpha;
+ /**
+ * Auxiliary value.
+ */
+ double beta;
+ /**
+ * Auxiliary value.
+ */
+ double omega;
+ /**
+ * Auxiliary value.
+ */
+ double rho;
+ /**
+ * Auxiliary value.
+ */
+ double rhobar;
+
+ /**
+ * Current iteration step.
+ */
+ unsigned int step;
+
+ /**
+ * Residual.
+ */
+ double res;
+
+ /**
+ * Default constructor. This is protected so that only SolverBicgstab can
+ * create instances.
+ */
+ SolverBicgstabData();
+ };
+}
+
/**
* Bicgstab algorithm by van der Vorst.
*
*
*/
template <typename VectorType = Vector<double> >
-class SolverBicgstab : public Solver<VectorType>
+class SolverBicgstab : public Solver<VectorType>,
+ protected internal::SolverBicgstabData
{
public:
/**
const PreconditionerType &preconditioner);
protected:
- /**
- * Computation of the stopping criterion.
- */
- template <typename MatrixType>
- double criterion (const MatrixType &A, const VectorType &x, const VectorType &b);
-
- /**
- * Interface for derived class. This function gets the current iteration
- * vector, the residual and the update vector in each step. It can be used
- * for graphical output of the convergence history.
- */
- virtual void print_vectors(const unsigned int step,
- const VectorType &x,
- const VectorType &r,
- const VectorType &d) const;
-
/**
* Auxiliary vector.
*/
VectorType *Vx;
+
/**
* Auxiliary vector.
*/
typename VectorMemory<VectorType>::Pointer Vr;
+
/**
* Auxiliary vector.
*/
typename VectorMemory<VectorType>::Pointer Vrbar;
+
/**
* Auxiliary vector.
*/
typename VectorMemory<VectorType>::Pointer Vp;
+
/**
* Auxiliary vector.
*/
typename VectorMemory<VectorType>::Pointer Vy;
+
/**
* Auxiliary vector.
*/
typename VectorMemory<VectorType>::Pointer Vz;
+
/**
* Auxiliary vector.
*/
typename VectorMemory<VectorType>::Pointer Vt;
+
/**
* Auxiliary vector.
*/
typename VectorMemory<VectorType>::Pointer Vv;
+
/**
* Right hand side vector.
*/
const VectorType *Vb;
/**
- * Auxiliary value.
- */
- double alpha;
- /**
- * Auxiliary value.
- */
- double beta;
- /**
- * Auxiliary value.
- */
- double omega;
- /**
- * Auxiliary value.
- */
- double rho;
- /**
- * Auxiliary value.
- */
- double rhobar;
-
- /**
- * Current iteration step.
+ * Computation of the stopping criterion.
*/
- unsigned int step;
+ template <typename MatrixType>
+ double criterion (const MatrixType &A, const VectorType &x, const VectorType &b);
/**
- * Residual.
+ * Interface for derived class. This function gets the current iteration
+ * vector, the residual and the update vector in each step. It can be used
+ * for graphical output of the convergence history.
*/
- double res;
+ virtual void print_vectors(const unsigned int step,
+ const VectorType &x,
+ const VectorType &r,
+ const VectorType &d) const;
/**
* Additional parameters.
{}
+
+internal::SolverBicgstabData::SolverBicgstabData ()
+ :
+ alpha(0.),
+ beta(0.),
+ omega(0.),
+ rho(0.),
+ rhobar(0.),
+ step(numbers::invalid_unsigned_int),
+ res(numbers::signaling_nan<double>())
+{}
+
+
+
template <typename VectorType>
SolverBicgstab<VectorType>::SolverBicgstab (SolverControl &cn,
VectorMemory<VectorType> &mem,
const AdditionalData &data)
:
Solver<VectorType>(cn,mem),
+ Vx (nullptr),
+ Vb (nullptr),
additional_data(data)
{}
const AdditionalData &data)
:
Solver<VectorType>(cn),
- alpha(0.),
- beta(0.),
- omega(0.),
- rho(0.),
- rhobar(0.),
- step(numbers::invalid_unsigned_int),
- res(numbers::signaling_nan<double>()),
+ Vx (nullptr),
+ Vb (nullptr),
additional_data(data)
{}
AdditionalData additional_data;
private:
-
/**
* A structure returned by the iterate() function representing what it found
* is happening during the iteration.
#ifndef DOXYGEN
+
template <class VectorType>
SolverQMRS<VectorType>::IterationResult::IterationResult (const SolverControl::State state,
const double last_residual)
:
state (state),
last_residual (last_residual)
-{
-}
+{}
+
+
template <class VectorType>
-SolverQMRS<VectorType>::SolverQMRS (SolverControl &cn,
+SolverQMRS<VectorType>::SolverQMRS (SolverControl &cn,
VectorMemory<VectorType> &mem,
- const AdditionalData &data)
+ const AdditionalData &data)
:
Solver<VectorType> (cn, mem),
- additional_data (data)
+ additional_data (data),
+ step (0)
{
}
template <class VectorType>
-SolverQMRS<VectorType>::SolverQMRS (SolverControl &cn,
+SolverQMRS<VectorType>::SolverQMRS (SolverControl &cn,
const AdditionalData &data)
:
Solver<VectorType> (cn),
- additional_data (data)
+ additional_data (data),
+ step (0)
{
}