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
d93a02e8
"examples/pytorch/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "f4a9a455f5812e623f42bea3d0978ccbb422d206"
Commit
d93a02e8
authored
May 24, 2013
by
Davis King
Browse files
Minor cleanup
parent
8b6cd008
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
19 deletions
+16
-19
examples/integrate_function_adapt_simp_ex.cpp
examples/integrate_function_adapt_simp_ex.cpp
+16
-19
No files found.
examples/integrate_function_adapt_simp_ex.cpp
View file @
d93a02e8
// The contents of this file are in the public domain. See
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
// LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*
/*
This example demonstrates the usage of the numerical quadrature function
This example demonstrates the usage of the numerical quadrature function
integrate_function_adapt_simp
son
. This function takes as input a single variable
integrate_function_adapt_simp
()
. This function takes as input a single variable
function, the endpoints of a domain over which the function will be integrated, and a
function, the endpoints of a domain over which the function will be integrated, and a
tolerance parameter. It outputs an approximation of the integral of this function
tolerance parameter. It outputs an approximation of the integral of this function
over
over
the specified domain. The algorithm is based on the adaptive Simpson method outlined in:
the specified domain. The algorithm is based on the adaptive Simpson method outlined in:
Numerical Integration method based on the adaptive Simpson method in
Numerical Integration method based on the adaptive Simpson method in
Gander, W. and W. Gautschi, "Adaptive Quadrature – Revisited,"
Gander, W. and W. Gautschi, "Adaptive Quadrature – Revisited,"
BIT, Vol. 40, 2000, pp. 84-101
BIT, Vol. 40, 2000, pp. 84-101
*/
*/
...
@@ -24,40 +22,39 @@
...
@@ -24,40 +22,39 @@
using
namespace
std
;
using
namespace
std
;
using
namespace
dlib
;
using
namespace
dlib
;
// Here we
define a class that consists of the set of functions that we
// Here we
the set of functions that we wish to integrate and comment in the domain of
//
wish to integrate and comment in the domain of
integration.
// integration.
// x in [0,1]
// x in [0,1]
static
double
gg1
(
double
x
)
double
gg1
(
double
x
)
{
{
return
pow
(
e
,
x
);
return
pow
(
e
,
x
);
}
}
// x in [0,1]
// x in [0,1]
static
double
gg2
(
double
x
)
double
gg2
(
double
x
)
{
{
return
x
*
x
;
return
x
*
x
;
}
}
// x in [0, pi]
// x in [0, pi]
static
double
gg3
(
double
x
)
double
gg3
(
double
x
)
{
{
return
1
/
(
x
*
x
+
cos
(
x
)
*
cos
(
x
));
return
1
/
(
x
*
x
+
cos
(
x
)
*
cos
(
x
));
}
}
// x in [-pi, pi]
// x in [-pi, pi]
static
double
gg4
(
double
x
)
double
gg4
(
double
x
)
{
{
return
sin
(
x
);
return
sin
(
x
);
}
}
// x in [0,2]
// x in [0,2]
static
double
gg5
(
double
x
)
double
gg5
(
double
x
)
{
{
return
1
/
(
1
+
x
*
x
);
return
1
/
(
1
+
x
*
x
);
}
}
// Examples
int
main
()
int
main
()
{
{
// We first define a tolerance parameter. Roughly speaking, a lower tolerance will
// We first define a tolerance parameter. Roughly speaking, a lower tolerance will
...
...
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