All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BoxLCP.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_PROBLEMS_BOXLCP_H_
36 #define _BLAZE_MATH_PROBLEMS_BOXLCP_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <cmath>
46 #include <blaze/math/Functions.h>
47 #include <blaze/system/Precision.h>
48 #include <blaze/util/Types.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // CLASS DEFINITION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
66 struct BoxLCP
67 {
68  //**Utility functions***************************************************************************
71  inline size_t size () const;
72  inline void project ( size_t index );
73  inline real lbound ( size_t index ) const;
74  inline real ubound ( size_t index ) const;
75  inline real residual( size_t index ) const;
76  inline real residual() const;
78  //**********************************************************************************************
79 
80  //**Member variables****************************************************************************
84  VecN b_;
85  VecN x_;
88 
89  //**********************************************************************************************
90 };
91 //*************************************************************************************************
92 
93 
94 
95 
96 //=================================================================================================
97 //
98 // UTILITY FUNCTIONS
99 //
100 //=================================================================================================
101 
102 //*************************************************************************************************
107 inline size_t BoxLCP::size() const
108 {
109  return x_.size();
110 }
111 //*************************************************************************************************
112 
113 
114 //*************************************************************************************************
120 inline void BoxLCP::project( size_t index )
121 {
122  x_[index] = min( xmax_[index], max( xmin_[index], x_[index] ) );
123 }
124 //*************************************************************************************************
125 
126 
127 //*************************************************************************************************
133 inline real BoxLCP::lbound( size_t index ) const
134 {
135  return xmin_[index];
136 }
137 //*************************************************************************************************
138 
139 
140 //*************************************************************************************************
146 inline real BoxLCP::ubound( size_t index ) const
147 {
148  return xmax_[index];
149 }
150 //*************************************************************************************************
151 
152 
153 //*************************************************************************************************
159 inline real BoxLCP::residual( size_t index ) const
160 {
161  // Computing the residual using max( x - xmax, min( x - xmin, Ax+b ) )
162  return max( x_[index] - ubound( index ),
163  min( x_[index] - lbound( index ), ( A_ * x_ )[index] + b_[index] ) );
164 }
165 //*************************************************************************************************
166 
167 
168 //*************************************************************************************************
173 inline real BoxLCP::residual() const
174 {
175  real rmax( 0 );
176 
177  for( size_t i=0; i<size(); ++i )
178  rmax = max( rmax, std::fabs( residual( i ) ) );
179 
180  return rmax;
181 }
182 //*************************************************************************************************
183 
184 } // namespace blaze
185 
186 #endif
Header file for mathematical functions.
VecN xmin_
The lower bound of the BLCP.
Definition: BoxLCP.h:86
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
real lbound(size_t index) const
Returns the lower bound of the unknown at the given index.
Definition: BoxLCP.h:133
Header file for the floating point precision of the Blaze library.
VecN x_
The vector of unknowns .
Definition: BoxLCP.h:85
size_t size() const
Returns the current size/dimension of the vector.
Definition: DynamicVector.h:1060
VecN xmax_
The upper bound of the BLCP.
Definition: BoxLCP.h:87
Header file for the complete DynamicVector implementation.
void project(size_t index)
Projects the unknown at the given index on the solution range.
Definition: BoxLCP.h:120
real ubound(size_t index) const
Returns the upper bound of the unknown at the given index.
Definition: BoxLCP.h:146
size_t size() const
Returns the size of the BLCP.
Definition: BoxLCP.h:107
double real
Floating point data type of the Blaze library.This type definition offers the possibility to switch t...
Definition: Precision.h:47
VecN b_
The right-hand side vector .
Definition: BoxLCP.h:84
Header file for the complete CompressedMatrix implementation.
Header file for basic type definitions.
real residual() const
Calculates the maximum norm of the residual of the BLCP.
Definition: BoxLCP.h:173
CMatMxN A_
The system matrix .
Definition: BoxLCP.h:83