All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LCP.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_PROBLEMS_LCP_H_
36 #define _BLAZE_MATH_PROBLEMS_LCP_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <cmath>
46 #include <blaze/math/Functions.h>
47 #include <blaze/math/Infinity.h>
48 #include <blaze/system/Precision.h>
49 #include <blaze/util/Types.h>
50 
51 
52 namespace blaze {
53 
54 //=================================================================================================
55 //
56 // CLASS DEFINITION
57 //
58 //=================================================================================================
59 
60 //*************************************************************************************************
67 struct LCP
68 {
69  public:
70  //**Utility functions***************************************************************************
73  inline size_t size () const;
74  inline void project ( size_t index );
75  inline real lbound ( size_t index ) const;
76  inline real ubound ( size_t index ) const;
77  inline real residual( size_t index ) const;
78  inline real residual() const;
80  //**********************************************************************************************
81 
82  //**Member variables****************************************************************************
86  VecN b_;
87  VecN x_;
88 
89  //**********************************************************************************************
90 };
91 //*************************************************************************************************
92 
93 
94 
95 
96 //=================================================================================================
97 //
98 // UTILITY FUNCTIONS
99 //
100 //=================================================================================================
101 
102 //*************************************************************************************************
107 inline size_t LCP::size() const
108 {
109  return x_.size();
110 }
111 //*************************************************************************************************
112 
113 
114 //*************************************************************************************************
120 inline void LCP::project( size_t index )
121 {
122  x_[index] = max( 0, x_[index] );
123 }
124 //*************************************************************************************************
125 
126 
127 //*************************************************************************************************
133 inline real LCP::lbound( size_t /*index*/ ) const
134 {
135  return real( 0 );
136 }
137 //*************************************************************************************************
138 
139 
140 //*************************************************************************************************
146 inline real LCP::ubound( size_t /*index*/ ) const
147 {
148  return inf;
149 }
150 //*************************************************************************************************
151 
152 
153 //*************************************************************************************************
159 inline real LCP::residual( size_t index ) const
160 {
161  return min( x_[index], ( A_ * x_ )[index] + b_[index] );
162 }
163 //*************************************************************************************************
164 
165 
166 //*************************************************************************************************
171 inline real LCP::residual() const
172 {
173  real rmax( 0 );
174 
175  for( size_t i=0; i<size(); ++i )
176  rmax = max( rmax, std::fabs( residual( i ) ) );
177 
178  return rmax;
179 }
180 //*************************************************************************************************
181 
182 } // namespace blaze
183 
184 #endif
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:994
Header file for mathematical functions.
size_t size() const
Returns the size of the linear complementarity problem.
Definition: LCP.h:107
VecN x_
The vector of unknowns .
Definition: LCP.h:87
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
CMatMxN A_
The system matrix .
Definition: LCP.h:85
real lbound(size_t index) const
Returns the lower bound of the unknown at the given index.
Definition: LCP.h:133
Header file for the floating point precision of the Blaze library.
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
Numerical infinity for built-in data types.
size_t size() const
Returns the current size/dimension of the vector.
Definition: DynamicVector.h:1059
Header file for the complete DynamicVector implementation.
void project(size_t index)
Projects the unknown at the given index on the solution range.
Definition: LCP.h:120
const Infinity inf
Global Infinity instance.The blaze::inf instance can be used wherever a built-in data type is expecte...
Definition: Infinity.h:1098
double real
Floating point data type of the Blaze library.This type definition offers the possibility to switch t...
Definition: Precision.h:47
real ubound(size_t index) const
Returns the upper bound of the unknown at the given index.
Definition: LCP.h:146
VecN b_
The right-hand side vector .
Definition: LCP.h:86
Header file for the complete CompressedMatrix implementation.
Header file for basic type definitions.
A linear complementarity problem (LCP) data structure.The LCP class represent a linear complementarit...
Definition: LCP.h:67
real residual() const
Calculates the maximum norm of the residual of the linear complementarity problem.
Definition: LCP.h:171