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
37d17745
Commit
37d17745
authored
May 25, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing dlib namespace
parent
d93a02e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
71 deletions
+79
-71
integrate_function_adapt_simpson.h
.../numerical_integration/integrate_function_adapt_simpson.h
+53
-50
integrate_function_adapt_simpson_abstract.h
...l_integration/integrate_function_adapt_simpson_abstract.h
+26
-21
No files found.
dlib/numerical_integration/integrate_function_adapt_simpson.h
View file @
37d17745
...
@@ -7,72 +7,75 @@
...
@@ -7,72 +7,75 @@
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
,
typename
funct
>
namespace
dlib
T
impl_adapt_simp_stop
(
const
funct
&
f
,
T
a
,
T
b
,
T
fa
,
T
fm
,
T
fb
,
T
is
,
int
cnt
)
{
{
const
int
MAXINT
=
500
;
template
<
typename
T
,
typename
funct
>
T
impl_adapt_simp_stop
(
const
funct
&
f
,
T
a
,
T
b
,
T
fa
,
T
fm
,
T
fb
,
T
is
,
int
cnt
)
T
m
=
(
a
+
b
)
/
2
.
0
;
T
h
=
(
b
-
a
)
/
4
.
0
;
T
fml
=
f
(
a
+
h
);
T
fmr
=
f
(
b
-
h
);
T
i1
=
h
/
1
.
5
*
(
fa
+
4
.
0
*
fm
+
fb
);
T
i2
=
h
/
3
.
0
*
(
fa
+
4
.
0
*
(
fml
+
fmr
)
+
2
.
0
*
fm
+
fb
);
i1
=
(
16
.
0
*
i2
-
i1
)
/
15
.
0
;
T
Q
=
0
;
if
((
std
::
abs
(
i1
-
i2
)
<=
std
::
abs
(
is
))
||
(
m
<=
a
)
||
(
b
<=
m
))
{
{
Q
=
i1
;
const
int
MAXINT
=
500
;
}
else
T
m
=
(
a
+
b
)
/
2
.
0
;
{
T
h
=
(
b
-
a
)
/
4
.
0
;
if
(
cnt
<
MAXINT
)
T
fml
=
f
(
a
+
h
);
T
fmr
=
f
(
b
-
h
);
T
i1
=
h
/
1
.
5
*
(
fa
+
4
.
0
*
fm
+
fb
);
T
i2
=
h
/
3
.
0
*
(
fa
+
4
.
0
*
(
fml
+
fmr
)
+
2
.
0
*
fm
+
fb
);
i1
=
(
16
.
0
*
i2
-
i1
)
/
15
.
0
;
T
Q
=
0
;
if
((
std
::
abs
(
i1
-
i2
)
<=
std
::
abs
(
is
))
||
(
m
<=
a
)
||
(
b
<=
m
))
{
Q
=
i1
;
}
else
{
{
cnt
=
cnt
+
1
;
if
(
cnt
<
MAXINT
)
{
cnt
=
cnt
+
1
;
Q
=
impl_adapt_simp_stop
(
f
,
a
,
m
,
fa
,
fml
,
fm
,
is
,
cnt
)
Q
=
impl_adapt_simp_stop
(
f
,
a
,
m
,
fa
,
fml
,
fm
,
is
,
cnt
)
+
impl_adapt_simp_stop
(
f
,
m
,
b
,
fm
,
fmr
,
fb
,
is
,
cnt
);
+
impl_adapt_simp_stop
(
f
,
m
,
b
,
fm
,
fmr
,
fb
,
is
,
cnt
);
}
}
}
}
return
Q
;
return
Q
;
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
,
typename
funct
>
template
<
typename
T
,
typename
funct
>
T
integrate_function_adapt_simp
(
T
integrate_function_adapt_simp
(
const
funct
&
f
,
const
funct
&
f
,
T
a
,
T
a
,
T
b
,
T
b
,
T
tol
=
1e-10
T
tol
=
1e-10
)
)
{
T
eps
=
std
::
numeric_limits
<
T
>::
epsilon
();
if
(
tol
<
eps
)
{
{
tol
=
eps
;
T
eps
=
std
::
numeric_limits
<
T
>::
epsilon
();
}
if
(
tol
<
eps
)
{
tol
=
eps
;
}
const
T
ba
=
b
-
a
;
const
T
ba
=
b
-
a
;
const
T
fa
=
f
(
a
);
const
T
fa
=
f
(
a
);
const
T
fb
=
f
(
b
);
const
T
fb
=
f
(
b
);
const
T
fm
=
f
((
a
+
b
)
/
2
);
const
T
fm
=
f
((
a
+
b
)
/
2
);
T
is
=
ba
/
8
*
(
fa
+
fb
+
fm
+
f
(
a
+
0
.
9501
*
ba
)
+
f
(
a
+
0
.
2311
*
ba
)
+
f
(
a
+
0
.
6068
*
ba
)
T
is
=
ba
/
8
*
(
fa
+
fb
+
fm
+
f
(
a
+
0
.
9501
*
ba
)
+
f
(
a
+
0
.
2311
*
ba
)
+
f
(
a
+
0
.
6068
*
ba
)
+
f
(
a
+
0
.
4860
*
ba
)
+
f
(
a
+
0
.
8913
*
ba
));
+
f
(
a
+
0
.
4860
*
ba
)
+
f
(
a
+
0
.
8913
*
ba
));
if
(
is
==
0
)
if
(
is
==
0
)
{
{
is
=
b
-
a
;
is
=
b
-
a
;
}
}
is
=
is
*
tol
;
is
=
is
*
tol
;
int
cnt
=
0
;
int
cnt
=
0
;
return
impl_adapt_simp_stop
(
f
,
a
,
b
,
fa
,
fm
,
fb
,
is
,
cnt
);
return
impl_adapt_simp_stop
(
f
,
a
,
b
,
fa
,
fm
,
fb
,
is
,
cnt
);
}
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/numerical_integration/integrate_function_adapt_simpson_abstract.h
View file @
37d17745
...
@@ -3,27 +3,32 @@
...
@@ -3,27 +3,32 @@
#undef DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_ABSTRACT__
#undef DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_ABSTRACT__
#ifdef DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_ABSTRACT__
#ifdef DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_ABSTRACT__
template
<
typename
T
,
typename
funct
>
namespace
dlib
T
integrate_function_adapt_simp
(
{
const
funct
&
f
,
T
a
,
template
<
typename
T
,
typename
funct
>
T
b
,
T
integrate_function_adapt_simp
(
T
tol
=
1e-10
const
funct
&
f
,
);
T
a
,
/*!
T
b
,
requires
T
tol
=
1e-10
- b > a
);
- tol > 0
/*!
- T should be either float, double, or long double
requires
- The expression f(a) should be a valid expression that evaluates to a T.
- b > a
I.e. f() should be a real valued function of a single variable.
- tol > 0
ensures
- T should be either float, double, or long double
- returns an approximation of the integral of f over the domain [a,b] using the
- The expression f(a) should be a valid expression that evaluates to a T.
adaptive Simpson method outlined in Gander, W. and W. Gautshi, "Adaptive
I.e. f() should be a real valued function of a single variable.
Quadrature -- Revisited" BIT, Vol. 40, (2000), pp.84-101
ensures
- tol is a tolerance parameter that determines the overall accuracy of approximated
- returns an approximation of the integral of f over the domain [a,b] using the
integral. We suggest a default value of 1e-10 for tol.
adaptive Simpson method outlined in Gander, W. and W. Gautshi, "Adaptive
!*/
Quadrature -- Revisited" BIT, Vol. 40, (2000), pp.84-101
- tol is a tolerance parameter that determines the overall accuracy of
approximated integral. We suggest a default value of 1e-10 for tol.
!*/
}
#endif // DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON__
#endif // DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON__
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