35 #ifndef _BLAZE_MATH_SOLVERS_PGS_H_
36 #define _BLAZE_MATH_SOLVERS_PGS_H_
85 template<
typename CP >
bool solve( CP& cp );
93 template<
typename CP >
inline real sweep( CP& cp )
const;
125 template<
typename CP >
128 const size_t n( cp.size() );
130 bool converged(
false );
136 for(
size_t i=0; i<n; ++i ) {
137 const real tmp( A(i,i) );
143 for(
size_t i=0; i<n; ++i ) {
163 log <<
" Solved the complementarity problem in " << it <<
" PGS iterations.";
183 template<
typename CP >
186 real maxResidual( 0 ), xold( 0 );
187 const size_t n( cp.size() );
190 const VecN& b( cp.b_ );
193 for(
size_t i=0; i<n; ++i )
195 const real residual( - b[i] - ( A * x )[i] );
201 maxResidual = max( maxResidual,
std::fabs( xold - x[i] ) );
221 const size_t N( cp.
size() / 3 );
222 real rmax( 0 ), residual, flimit, aux;
229 for(
size_t i=0; i<N; ++i )
232 residual = -b[j] - ( A * x )[j];
233 aux = max( 0, x[j] +
diagonal_[j] * residual );
234 rmax = max( rmax,
std::fabs( x[j] - aux ) );
237 flimit = cp.
cof_[i] * x[j];
240 residual = -b[j] - ( A * x )[j];
241 aux = max( -flimit, min( flimit, x[j] +
diagonal_[j] * residual ) );
242 rmax = max( rmax,
std::fabs( x[j] - aux ) );
246 residual = -b[j] - ( A * x )[j];
247 aux = max( -flimit, min( flimit, x[j] +
diagonal_[j] * residual ) );
248 rmax = max( rmax,
std::fabs( x[j] - aux ) );
267 #if !defined(_MSC_VER)
268 extern template bool PGS::solve<LCP>(
LCP& );
269 extern template bool PGS::solve<BoxLCP>(
BoxLCP& );
270 extern template bool PGS::solve<ContactLCP>(
ContactLCP& );
A data structure for box linear complementarity problems.
real lastPrecision_
The precision of the solution after the solution process.
Definition: Solver.h:99
Header file for color macros.
Header file for the log debug section.
const StaticMatrix< Type, 3UL, 3UL, false > fabs(const RotationMatrix< Type > &m)
Returns a matrix containing the absolute values of each single element of m.
Definition: RotationMatrix.h:1102
A box linear complementarity problem (BLCP) data structure.The BoxLCP class represent a box linear co...
Definition: BoxLCP.h:66
bool solve(CP &cp)
Solves the provided complementarity problem.
Definition: PGS.h:126
#define BLAZE_YELLOW
Switches the text color to yellow in case the BLAZE_COLOR_OUTPUT macro is set.
Definition: ColorMacros.h:147
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: DynamicVector.h:1158
size_t maxIterations_
The maximum number of iterations.
Definition: Solver.h:95
#define BLAZE_LOG_DEBUG_SECTION(NAME)
Logging section for debug information.This macro starts a log section for debug information. These messages are written to the log file(s) in case the blaze::loglevel has been set to debug or higher. The following example demonstrates how this log section is used:
Definition: DebugSection.h:96
PGS()
The default constructor for the PGS class.
Definition: PGS.cpp:54
VecN diagonal_
Vector for the diagonal entries of the LCP matrix.
Definition: PGS.h:100
Header file for the complete DynamicVector implementation.
Header file for the base class of all solvers.
#define BLAZE_OLDCOLOR
Switches the text color back to the default color.
Definition: ColorMacros.h:162
Header file for run time assertion macros.
A data structure for linear complementarity problems.
double real
Floating point data type of the Blaze library.This type definition offers the possibility to switch t...
Definition: Precision.h:47
A projected Gauss-Seidel Solver for (box) LCPs.TODO: description of the PGS solver TODO: capabilities...
Definition: PGS.h:72
Header file for the complete CompressedMatrix implementation.
real threshold_
Precision threshold for the solution.
Definition: Solver.h:100
real sweep(CP &cp) const
TODO.
Definition: PGS.h:184
Header file for basic type definitions.
size_t lastIterations_
The number of iterations spent in the last solution process.
Definition: Solver.h:98
A linear complementarity problem (LCP) data structure.The LCP class represent a linear complementarit...
Definition: LCP.h:67
Base class for all solver classes.TODO: description of the Solver class TODO: description of its func...
Definition: Solver.h:63
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101