Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
a390f109
"vscode:/vscode.git/clone" did not exist on "743985a1afeb76e98cfbf6e0127227ebed91d0df"
Commit
a390f109
authored
Oct 23, 2016
by
Davis King
Browse files
Made approximate derivative calculation slightly more numerically robust.
parent
ff9f597a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
dlib/optimization/optimization.h
dlib/optimization/optimization.h
+3
-3
No files found.
dlib/optimization/optimization.h
View file @
a390f109
...
...
@@ -42,7 +42,7 @@ namespace dlib
e
(
i
)
=
old_val
-
eps
;
const
double
delta_minus
=
f
(
e
);
der
(
i
)
=
(
delta_plus
-
delta_minus
)
/
(
2
*
eps
)
;
der
(
i
)
=
(
delta_plus
-
delta_minus
)
/
(
(
old_val
+
eps
)
-
(
old_val
-
eps
)
);
// and finally restore the old value of this element
e
(
i
)
=
old_val
;
...
...
@@ -68,7 +68,7 @@ namespace dlib
e
(
i
)
=
old_val
-
eps
;
const
double
delta_minus
=
f
(
item
,
e
);
der
(
i
)
=
(
delta_plus
-
delta_minus
)
/
(
2
*
eps
)
;
der
(
i
)
=
(
delta_plus
-
delta_minus
)
/
(
(
old_val
+
eps
)
-
(
old_val
-
eps
)
);
// and finally restore the old value of this element
e
(
i
)
=
old_val
;
...
...
@@ -80,7 +80,7 @@ namespace dlib
double
operator
()(
const
double
&
x
)
const
{
return
(
f
(
x
+
eps
)
-
f
(
x
-
eps
))
/
(
2
*
eps
);
return
(
f
(
x
+
eps
)
-
f
(
x
-
eps
))
/
(
(
x
+
eps
)
-
(
x
-
eps
)
);
}
private:
...
...
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