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
cb42b8fb
Commit
cb42b8fb
authored
Jul 29, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
afcd4d8f
b4ec8d3d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
16 deletions
+16
-16
mpc.h
dlib/control/mpc.h
+2
-2
random_hashing.h
dlib/general_hash/random_hashing.h
+1
-1
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 @
cb42b8fb
...
...
@@ -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/general_hash/random_hashing.h
View file @
cb42b8fb
...
...
@@ -862,7 +862,7 @@ namespace dlib
const
static
uint64
mask
=
max
-
1
;
return
logvals
[
h
.
first
&
mask
]
*
cosvals
[
h
.
second
&
mask
];
// Note that we are just using the Box
–
Muller transform to compute the result. In
// Note that we are just using the Box
-
Muller transform to compute the result. In
// particular, we are doing this (where u1 and u2 are uniform random variables in
// the range [0,1]):
// return sqrt(-2*log(u1)) * cos(2*PI*u2);
...
...
dlib/matrix/matrix_la.h
View file @
cb42b8fb
...
...
@@ -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 @
cb42b8fb
...
...
@@ -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 @
cb42b8fb
...
...
@@ -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 @
cb42b8fb
...
...
@@ -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