#include <vector>
#include <base/smartpointer.h>
-#define FLOAT float
-
-
/**
* Abstract base class for coarse grid solvers.
* The interface of a function call operator is defined to execute coarse
* about the matrix is removed to
* that class.
*/
- virtual void operator() (unsigned int level, Vector<FLOAT>& dst,
- const Vector<FLOAT>& src) const = 0;
+ virtual void operator() (unsigned int level, Vector<float>& dst,
+ const Vector<float>& src) const = 0;
};
* things.
*/
virtual void smooth (const unsigned int level,
- Vector<FLOAT> &u,
- const Vector<FLOAT> &rhs) const = 0;
+ Vector<float> &u,
+ const Vector<float> &rhs) const = 0;
};
* This function does nothing.
*/
virtual void smooth (const unsigned int level,
- Vector<FLOAT> &u,
- const Vector<FLOAT> &rhs) const;
+ Vector<float> &u,
+ const Vector<float> &rhs) const;
};
/**
* level.
*/
virtual void prolongate (const unsigned int to_level,
- Vector<FLOAT> &dst,
- const Vector<FLOAT> &src) const = 0;
+ Vector<float> &dst,
+ const Vector<float> &src) const = 0;
/**
* Restrict a vector from level
* level.
*/
virtual void restrict (const unsigned int from_level,
- Vector<FLOAT> &dst,
- const Vector<FLOAT> &src) const = 0;
+ Vector<float> &dst,
+ const Vector<float> &src) const = 0;
};
/**
* matrix, vectors and
* preconditioner.
*/
- virtual void operator() (unsigned int level, Vector<FLOAT>& dst,
- const Vector<FLOAT>& src) const;
+ virtual void operator() (unsigned int level, Vector<float>& dst,
+ const Vector<float>& src) const;
private:
/**
* Reference to the solver.
/**
* Auxiliary vector, defect.
*/
- MGVector<Vector<FLOAT> > d;
+ MGVector<Vector<float> > d;
/**
* Auxiliary vector, solution.
*/
- MGVector<Vector<FLOAT> > s;
+ MGVector<Vector<float> > s;
private:
/**
* Auxiliary vector.
*/
- Vector<FLOAT> t;
+ Vector<float> t;
/**
* Prolongation and restriction object.
* derived class.
*/
virtual void level_residual(unsigned int level,
- Vector<FLOAT>& dst,
- const Vector<FLOAT>& src,
- const Vector<FLOAT>& rhs) = 0;
+ Vector<float>& dst,
+ const Vector<float>& src,
+ const Vector<float>& rhs) = 0;
public:
template<class SOLVER, class MATRIX, class PRECOND>
void
MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND>::operator()
-(unsigned int, Vector<FLOAT>& dst, const Vector<FLOAT>& src) const
+(unsigned int, Vector<float>& dst, const Vector<float>& src) const
{
solver.solve(matrix, dst, src, precondition);
}
for (unsigned int i=0;i<n;++i)
{
for (unsigned int j=0;j<n;++j)
-// s << ((FLOAT)i)/n << '\t' << ((FLOAT)j)/n << '\t' << v(k++) << endl;
+// s << ((float)i)/n << '\t' << ((float)j)/n << '\t' << v(k++) << endl;
s << '\t' << v(k++);
s << endl;
}
void
MGSmootherIdentity::smooth (const unsigned int,
- Vector<FLOAT> &,
- const Vector<FLOAT> &) const
+ Vector<float> &,
+ const Vector<float> &) const
{}
#include <vector>
#include <base/smartpointer.h>
-#define FLOAT float
-
-
/**
* Abstract base class for coarse grid solvers.
* The interface of a function call operator is defined to execute coarse
* about the matrix is removed to
* that class.
*/
- virtual void operator() (unsigned int level, Vector<FLOAT>& dst,
- const Vector<FLOAT>& src) const = 0;
+ virtual void operator() (unsigned int level, Vector<float>& dst,
+ const Vector<float>& src) const = 0;
};
* things.
*/
virtual void smooth (const unsigned int level,
- Vector<FLOAT> &u,
- const Vector<FLOAT> &rhs) const = 0;
+ Vector<float> &u,
+ const Vector<float> &rhs) const = 0;
};
* This function does nothing.
*/
virtual void smooth (const unsigned int level,
- Vector<FLOAT> &u,
- const Vector<FLOAT> &rhs) const;
+ Vector<float> &u,
+ const Vector<float> &rhs) const;
};
/**
* level.
*/
virtual void prolongate (const unsigned int to_level,
- Vector<FLOAT> &dst,
- const Vector<FLOAT> &src) const = 0;
+ Vector<float> &dst,
+ const Vector<float> &src) const = 0;
/**
* Restrict a vector from level
* level.
*/
virtual void restrict (const unsigned int from_level,
- Vector<FLOAT> &dst,
- const Vector<FLOAT> &src) const = 0;
+ Vector<float> &dst,
+ const Vector<float> &src) const = 0;
};
/**
* matrix, vectors and
* preconditioner.
*/
- virtual void operator() (unsigned int level, Vector<FLOAT>& dst,
- const Vector<FLOAT>& src) const;
+ virtual void operator() (unsigned int level, Vector<float>& dst,
+ const Vector<float>& src) const;
private:
/**
* Reference to the solver.
/**
* Auxiliary vector, defect.
*/
- MGVector<Vector<FLOAT> > d;
+ MGVector<Vector<float> > d;
/**
* Auxiliary vector, solution.
*/
- MGVector<Vector<FLOAT> > s;
+ MGVector<Vector<float> > s;
private:
/**
* Auxiliary vector.
*/
- Vector<FLOAT> t;
+ Vector<float> t;
/**
* Prolongation and restriction object.
* derived class.
*/
virtual void level_residual(unsigned int level,
- Vector<FLOAT>& dst,
- const Vector<FLOAT>& src,
- const Vector<FLOAT>& rhs) = 0;
+ Vector<float>& dst,
+ const Vector<float>& src,
+ const Vector<float>& rhs) = 0;
public:
template<class SOLVER, class MATRIX, class PRECOND>
void
MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND>::operator()
-(unsigned int, Vector<FLOAT>& dst, const Vector<FLOAT>& src) const
+(unsigned int, Vector<float>& dst, const Vector<float>& src) const
{
solver.solve(matrix, dst, src, precondition);
}
*/
Solver (SolverControl &, VectorMemory<Vector> &);
- /**
- * Solver procedure. This is in
- * fact only a template for the
- * solve-function to be
- * implemented in derived classes
- */
- template<class Preconditioner>
- ReturnState solve (const Matrix &A,
- Vector &x,
- const Vector &b,
- const Preconditioner& precondition) const;
-
/**
* Access to control object.
*/
SolverControl& control() const;
protected:
- /**
- * Calculation of convergence
- * criterion. To allow further
- * flexibility in solvers, the
- * convergence criterion can be
- * implemented by the user. Each
- * method has it's standard
- * criterion (usually some kind of
- * residual) already implemented.
- */
- virtual double criterion() = 0;
-
- /**
- * Additional entry point for
- * examination. Allows access to
- * internal variables of a solver
- * at a given point dependent of
- * the actual solver method. Does
- * nothing by default and should
- * only be implemented to test
- * iterative methods.
- */
- virtual void expert() {};
/**
* Control structure.
* Solve the original problem
* $Ax=b$.
*/
- virtual ReturnState solve (const Matrix &A,
+ ReturnState solve (const Matrix &A,
Vector &x,
const Vector &b) = 0;
* Solve the two problems
* $Ax=b1$ and $A^Tz=b2$ simultanously.
*/
- virtual ReturnState solve (const Matrix &A,
+ ReturnState solve (const Matrix &A,
Vector &x,
const Vector &b1,
Vector &z,
template <class Matrix, class Vector>
inline
-SolverControl & Solver<Matrix,Vector>::control() const {
+SolverControl & Solver<Matrix,Vector>::control() const
+{
return cntrl;
};
{};
-
-
-
/*---------------------------- solver.h ---------------------------*/
/* end of #ifndef __solver_H */
#endif
* Implementation of the computation of
* the norm of the residual.
*/
- virtual double criterion();
+ virtual long double criterion();
/**
* Temporary vectors, allocated through
* norm of the residual vector and thus
* the square root of the #res2# value.
*/
- double res2;
+ long double res2;
};
template<class Matrix, class Vector>
-double SolverCG<Matrix,Vector>::criterion()
+long double
+SolverCG<Matrix,Vector>::criterion()
{
return sqrt(res2);
};
// Implementation taken from the DEAL
// library
int it=0;
- double res,gh,alpha,beta;
+ long double res,gh,alpha,beta;
res = A.residual(g,x,b);
conv = control().check(0,res);
* for this operation.
*/
template <typename somenumber>
- double matrix_norm (const Vector<somenumber> &v) const;
+ somenumber matrix_norm (const Vector<somenumber> &v) const;
/**
* Return the l1-norm of the matrix, i.e.
* #dst#.
*/
template <typename somenumber>
- double residual (Vector<somenumber>& dst, const Vector<somenumber>& x,
+ somenumber residual (Vector<somenumber>& dst, const Vector<somenumber>& x,
const Vector<somenumber>& b) const;
//
template <typename somenumber>
template <typename number>
template <typename somenumber>
-double
+somenumber
SparseMatrix<number>::matrix_norm (const Vector<somenumber>& v) const
{
Assert (cols != 0, ExcMatrixNotInitialized());
template <typename number>
template <typename somenumber>
-double
+somenumber
SparseMatrix<number>::residual (Vector<somenumber>& dst,
const Vector<somenumber>& u,
const Vector<somenumber>& b) const
for (unsigned int i=0;i<n;++i)
{
for (unsigned int j=0;j<n;++j)
-// s << ((FLOAT)i)/n << '\t' << ((FLOAT)j)/n << '\t' << v(k++) << endl;
+// s << ((float)i)/n << '\t' << ((float)j)/n << '\t' << v(k++) << endl;
s << '\t' << v(k++);
s << endl;
}
void
MGSmootherIdentity::smooth (const unsigned int,
- Vector<FLOAT> &,
- const Vector<FLOAT> &) const
+ Vector<float> &,
+ const Vector<float> &) const
{}
template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
const Vector<TYPE2> &) const;
-template double
+template TYPE2
SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
const Vector<TYPE2> &,
const Vector<TYPE2> &) const;
template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
const Vector<TYPE2> &) const;
-template double
+template TYPE2
SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
const Vector<TYPE2> &,
const Vector<TYPE2> &) const;
template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
const Vector<TYPE2> &) const;
-template double
+template TYPE2
SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
- const Vector<TYPE2> &,
- const Vector<TYPE2> &) const;
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+ const Vector<TYPE2> &,
+ const Vector<TYPE2> &) const;
template void SparseMatrix<TYPEMAT>::precondition_SSOR (Vector<TYPE2> &,
const Vector<TYPE2> &,
template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
const Vector<TYPE2> &) const;
-template double
+template TYPE2
SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
const Vector<TYPE2> &,
const Vector<TYPE2> &) const;
template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
const Vector<TYPE2> &) const;
-template double
+template TYPE2
SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
const Vector<TYPE2> &,
const Vector<TYPE2> &) const;
template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
const Vector<TYPE2> &) const;
-template double
+template TYPE2
SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
const Vector<TYPE2> &,
const Vector<TYPE2> &) const;
template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
const Vector<TYPE2> &) const;
-template double
+template TYPE2
SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
const Vector<TYPE2> &,
const Vector<TYPE2> &) const;
template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
const Vector<TYPE2> &) const;
-template double
+template TYPE2
SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
const Vector<TYPE2> &,
const Vector<TYPE2> &) const;