All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ModifiedBoxLCP.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_PROBLEMS_MODIFIEDBOXLCP_H_
36 #define _BLAZE_MATH_PROBLEMS_MODIFIEDBOXLCP_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 //*************************************************************************************************
73 {
74  //**Utility functions***************************************************************************
77  inline size_t size () const;
78  inline void project ( size_t index );
79  inline real lbound ( size_t index ) const;
80  inline real ubound ( size_t index ) const;
81  inline real residual( size_t index ) const;
82  inline real residual() const;
84  //**********************************************************************************************
85 
86  //**Member variables****************************************************************************
90  VecN b_;
91  VecN x_;
98 
99  //**********************************************************************************************
100 };
101 //*************************************************************************************************
102 
103 
104 
105 
106 //=================================================================================================
107 //
108 // UTILITY FUNCTIONS
109 //
110 //=================================================================================================
111 
112 //*************************************************************************************************
117 inline size_t ModifiedBoxLCP::size() const
118 {
119  return x_.size();
120 }
121 //*************************************************************************************************
122 
123 
124 //*************************************************************************************************
130 inline void ModifiedBoxLCP::project( size_t index )
131 {
132  x_[index] = min( xmax_[index], max( xmin_[index], x_[index] ) );
133 }
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
143 inline real ModifiedBoxLCP::lbound( size_t index ) const
144 {
145  return ( xmin_[index] + lambdamin_[index] * x_[ jmin_[index] ] );
146 }
147 //*************************************************************************************************
148 
149 
150 //*************************************************************************************************
156 inline real ModifiedBoxLCP::ubound( size_t index ) const
157 {
158  return ( xmax_[index] + lambdamax_[index] * x_[ jmax_[index] ] );
159 }
160 //*************************************************************************************************
161 
162 
163 //*************************************************************************************************
169 inline real ModifiedBoxLCP::residual( size_t index ) const
170 {
171  // Computing the residual using max( x - xmax, min( x - xmin, Ax+b ) )
172  return max( x_[index] - ubound( index ),
173  min( x_[index] - lbound( index ), ( A_ * x_ )[index] + b_[index] ) );
174 }
175 //*************************************************************************************************
176 
177 
178 //*************************************************************************************************
184 {
185  real rmax( 0 );
186 
187  for( size_t i=0; i<size(); ++i )
188  rmax = max( rmax, std::fabs( residual( i ) ) );
189 
190  return rmax;
191 }
192 //*************************************************************************************************
193 
194 } // namespace blaze
195 
196 #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.
VecN lambdamin_
The lower bound of the friction coefficients .
Definition: ModifiedBoxLCP.h:94
VecN x_
The vector of unknowns .
Definition: ModifiedBoxLCP.h:91
CMatMxN A_
The system matrix .
Definition: ModifiedBoxLCP.h:89
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
real ubound(size_t index) const
Returns the upper bound of the unknown at the given index.
Definition: ModifiedBoxLCP.h:156
Header file for the floating point precision of the Blaze library.
VecN lambdamax_
The upper bound of the friction coefficients .
Definition: ModifiedBoxLCP.h:95
VecN xmin_
The lower bound of the MBLCP .
Definition: ModifiedBoxLCP.h:92
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
real residual() const
Calculates the maximum norm of the residual of the BLCP.
Definition: ModifiedBoxLCP.h:183
size_t size() const
Returns the current size/dimension of the vector.
Definition: DynamicVector.h:1059
VecN jmax_
The upper bound of the index for the vector of unknowns .
Definition: ModifiedBoxLCP.h:97
real lbound(size_t index) const
Returns the lower bound of the unknown at the given index.
Definition: ModifiedBoxLCP.h:143
A modified box linear complementarity problem (MBLCP) data structure.The ModifiedBoxLCP class represe...
Definition: ModifiedBoxLCP.h:72
Header file for the complete DynamicVector implementation.
void project(size_t index)
Projects the unknown at the given index on the solution range.
Definition: ModifiedBoxLCP.h:130
size_t size() const
Returns the size of the MBLCP.
Definition: ModifiedBoxLCP.h:117
VecN xmax_
The upper bound of the MBLCP .
Definition: ModifiedBoxLCP.h:93
double real
Floating point data type of the Blaze library.This type definition offers the possibility to switch t...
Definition: Precision.h:47
Header file for the complete CompressedMatrix implementation.
VecN jmin_
The lower bound of the index for the vector of unknowns .
Definition: ModifiedBoxLCP.h:96
VecN b_
The right-hand side vector .
Definition: ModifiedBoxLCP.h:90
Header file for basic type definitions.