Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
blaze
math
problems
BoxLCP.h
Go to the documentation of this file.
1
//=================================================================================================
20
//=================================================================================================
21
22
#ifndef _BLAZE_MATH_PROBLEMS_BOXLCP_H_
23
#define _BLAZE_MATH_PROBLEMS_BOXLCP_H_
24
25
26
//*************************************************************************************************
27
// Includes
28
//*************************************************************************************************
29
30
#include <cmath>
31
#include <
blaze/math/CompressedMatrix.h
>
32
#include <
blaze/math/DynamicVector.h
>
33
#include <
blaze/math/Functions.h
>
34
#include <
blaze/system/Precision.h
>
35
#include <
blaze/util/Types.h
>
36
37
38
namespace
blaze {
39
40
//=================================================================================================
41
//
42
// CLASS DEFINITION
43
//
44
//=================================================================================================
45
46
//*************************************************************************************************
53
struct
BoxLCP
54
{
55
//**Utility functions***************************************************************************
58
inline
size_t
size
()
const
;
59
inline
void
project
(
size_t
index );
60
inline
real
lbound
(
size_t
index )
const
;
61
inline
real
ubound
(
size_t
index )
const
;
62
inline
real
residual
(
size_t
index )
const
;
63
inline
real
residual
()
const
;
65
//**********************************************************************************************
66
67
//**Member variables****************************************************************************
70
CMatMxN
A_
;
71
VecN
b_
;
72
VecN
x_
;
73
VecN
xmin_
;
74
VecN
xmax_
;
75
76
//**********************************************************************************************
77
};
78
//*************************************************************************************************
79
80
81
82
83
//=================================================================================================
84
//
85
// UTILITY FUNCTIONS
86
//
87
//=================================================================================================
88
89
//*************************************************************************************************
94
inline
size_t
BoxLCP::size
()
const
95
{
96
return
x_
.
size
();
97
}
98
//*************************************************************************************************
99
100
101
//*************************************************************************************************
107
inline
void
BoxLCP::project
(
size_t
index )
108
{
109
x_
[index] =
min
(
xmax_
[index],
max
(
xmin_
[index],
x_
[index] ) );
110
}
111
//*************************************************************************************************
112
113
114
//*************************************************************************************************
120
inline
real
BoxLCP::lbound
(
size_t
index )
const
121
{
122
return
xmin_
[index];
123
}
124
//*************************************************************************************************
125
126
127
//*************************************************************************************************
133
inline
real
BoxLCP::ubound
(
size_t
index )
const
134
{
135
return
xmax_
[index];
136
}
137
//*************************************************************************************************
138
139
140
//*************************************************************************************************
146
inline
real
BoxLCP::residual
(
size_t
index )
const
147
{
148
// Computing the residual using max( x - xmax, min( x - xmin, Ax+b ) )
149
return
max
(
x_
[index] -
ubound
( index ),
150
min
(
x_
[index] -
lbound
( index ), (
A_
*
x_
)[index] +
b_
[index] ) );
151
}
152
//*************************************************************************************************
153
154
155
//*************************************************************************************************
160
inline
real
BoxLCP::residual
()
const
161
{
162
real
rmax( 0 );
163
164
for
(
size_t
i=0; i<
size
(); ++i )
165
rmax =
max
( rmax,
std::fabs
(
residual
( i ) ) );
166
167
return
rmax;
168
}
169
//*************************************************************************************************
170
171
}
// namespace blaze
172
173
#endif
Generated on Sun Jan 20 2013 08:14:37 by
1.8.3