Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
b4ec8d3d
Commit
b4ec8d3d
authored
Jul 29, 2017
by
ᴚ∀W∀ᴎ
Committed by
Davis E. King
Jul 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
differential std::clamp from c++17 with dlib:: prefix to clamp() (#734)
parent
1c96db9e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
15 deletions
+15
-15
mpc.h
dlib/control/mpc.h
+2
-2
matrix_la.h
dlib/matrix/matrix_la.h
+1
-1
optimization.h
dlib/optimization/optimization.h
+2
-2
optimization_solve_qp_using_smo.h
dlib/optimization/optimization_solve_qp_using_smo.h
+4
-4
matrix2.cpp
dlib/test/matrix2.cpp
+6
-6
No files found.
dlib/control/mpc.h
View file @
b4ec8d3d
...
...
@@ -339,8 +339,8 @@ namespace dlib
for
(
unsigned
long
i
=
0
;
i
<
horizon
;
++
i
)
{
v_old
[
i
]
=
v
[
i
];
v
[
i
]
=
clamp
(
controls
[
i
]
-
1
.
0
/
lambda
*
df
[
i
],
lower
,
upper
);
controls
[
i
]
=
clamp
(
v
[
i
]
+
(
std
::
sqrt
(
lambda
)
-
1
)
/
(
std
::
sqrt
(
lambda
)
+
1
)
*
(
v
[
i
]
-
v_old
[
i
]),
lower
,
upper
);
v
[
i
]
=
dlib
::
clamp
(
controls
[
i
]
-
1
.
0
/
lambda
*
df
[
i
],
lower
,
upper
);
controls
[
i
]
=
dlib
::
clamp
(
v
[
i
]
+
(
std
::
sqrt
(
lambda
)
-
1
)
/
(
std
::
sqrt
(
lambda
)
+
1
)
*
(
v
[
i
]
-
v_old
[
i
]),
lower
,
upper
);
}
}
}
...
...
dlib/matrix/matrix_la.h
View file @
b4ec8d3d
...
...
@@ -1646,7 +1646,7 @@ convergence:
if
(
dot
(
delta
,
g
)
<
0
)
return
p
;
else
return
vector
<
double
,
2
>
(
p
)
+
clamp
(
delta
,
-
1
,
1
);
return
vector
<
double
,
2
>
(
p
)
+
dlib
::
clamp
(
delta
,
-
1
,
1
);
}
// ----------------------------------------------------------------------------------------
...
...
dlib/optimization/optimization.h
View file @
b4ec8d3d
...
...
@@ -527,7 +527,7 @@ namespace dlib
last_alpha
=
alpha
;
// Take the search step indicated by the above line search
x
=
clamp
(
x
+
alpha
*
s
,
x_lower
,
x_upper
);
x
=
dlib
::
clamp
(
x
+
alpha
*
s
,
x_lower
,
x_upper
);
g
=
der
(
x
);
if
(
!
is_finite
(
f_value
))
...
...
@@ -658,7 +658,7 @@ namespace dlib
last_alpha
=
alpha
;
// Take the search step indicated by the above line search
x
=
clamp
(
x
+
alpha
*
s
,
x_lower
,
x_upper
);
x
=
dlib
::
clamp
(
x
+
alpha
*
s
,
x_lower
,
x_upper
);
g
=
-
der
(
x
);
// Don't forget to negate the output from the line search since it is from the
...
...
dlib/optimization/optimization_solve_qp_using_smo.h
View file @
b4ec8d3d
...
...
@@ -286,7 +286,7 @@ namespace dlib
lambda
=
A
*
alpha
;
else
lambda
=
A
*
alpha
+
d
;
lambda
=
clamp
(
lambda
,
0
,
max_lambda
);
lambda
=
dlib
::
clamp
(
lambda
,
0
,
max_lambda
);
// Compute f'(alpha) (i.e. the gradient of f(alpha) with respect to alpha) for the current alpha.
matrix
<
T
,
NR
,
NC
,
MM
,
L
>
df
=
Q
*
alpha
-
b
-
trans
(
A
)
*
lambda
;
...
...
@@ -333,7 +333,7 @@ namespace dlib
lambda
=
A
*
alpha
;
else
lambda
=
A
*
alpha
+
d
;
lambda
=
clamp
(
lambda
,
0
,
max_lambda
);
lambda
=
dlib
::
clamp
(
lambda
,
0
,
max_lambda
);
df
=
Q
*
alpha
-
b
-
trans
(
A
)
*
lambda
;
if
(
trans
(
alpha
)
*
df
-
C
*
min
(
df
)
<
eps
)
...
...
@@ -375,7 +375,7 @@ namespace dlib
lambda
=
A
*
alpha
;
else
lambda
=
A
*
alpha
+
d
;
lambda
=
clamp
(
lambda
,
0
,
max_lambda
);
lambda
=
dlib
::
clamp
(
lambda
,
0
,
max_lambda
);
// Perform this form of the update every so often because doing so can help
// avoid the buildup of numerical errors you get with the alternate update
...
...
@@ -524,7 +524,7 @@ namespace dlib
df
=
Q
*
alpha
+
b
;
// now take a projected gradient step using Nesterov's method.
v
=
clamp
(
alpha
-
1
.
0
/
lipschitz_bound
*
df
,
lower
,
upper
);
alpha
=
clamp
((
1
-
gamma
)
*
v
+
gamma
*
v_old
,
lower
,
upper
);
alpha
=
dlib
::
clamp
((
1
-
gamma
)
*
v
+
gamma
*
v_old
,
lower
,
upper
);
// check for convergence every 10 iterations
...
...
dlib/test/matrix2.cpp
View file @
b4ec8d3d
...
...
@@ -379,23 +379,23 @@ namespace
u
=
2
,
2.2
;
out
=
2
,
2.2
;
DLIB_TEST
(
equal
(
clamp
(
x
,
l
,
u
)
,
out
));
DLIB_TEST
(
equal
(
dlib
::
clamp
(
x
,
l
,
u
)
,
out
));
out
=
3
,
2.2
;
DLIB_TEST
(
!
equal
(
clamp
(
x
,
l
,
u
)
,
out
));
DLIB_TEST
(
!
equal
(
dlib
::
clamp
(
x
,
l
,
u
)
,
out
));
out
=
2
,
4.2
;
DLIB_TEST
(
!
equal
(
clamp
(
x
,
l
,
u
)
,
out
));
DLIB_TEST
(
!
equal
(
dlib
::
clamp
(
x
,
l
,
u
)
,
out
));
x
=
1.5
,
1.5
;
out
=
x
;
DLIB_TEST
(
equal
(
clamp
(
x
,
l
,
u
)
,
out
));
DLIB_TEST
(
equal
(
dlib
::
clamp
(
x
,
l
,
u
)
,
out
));
x
=
0.5
,
1.5
;
out
=
1
,
1.5
;
DLIB_TEST
(
equal
(
clamp
(
x
,
l
,
u
)
,
out
));
DLIB_TEST
(
equal
(
dlib
::
clamp
(
x
,
l
,
u
)
,
out
));
x
=
1.5
,
0.5
;
out
=
1.5
,
1.0
;
DLIB_TEST
(
equal
(
clamp
(
x
,
l
,
u
)
,
out
));
DLIB_TEST
(
equal
(
dlib
::
clamp
(
x
,
l
,
u
)
,
out
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment