CppNoddy
0.92
|
A quadrature class that takes a function pointer. More...
#include <FnQuadrature.h>
Public Types | |
typedef void(* | fn_ptr) (const double &, double &) |
The function pointer associated with this instance. More... | |
Public Member Functions | |
FnQuadrature (fn_ptr ptr_to_fn, const double &x1, const double &x2, const unsigned &num_of_regions) | |
Constructor. More... | |
FnQuadrature (fn_ptr ptr_to_fn, const double &x1, const double &x2, const DenseVector< double > &nodes) | |
Constructor. More... | |
void | set_subintervals (const unsigned &n) |
A set method to define a UNIFORM number of sub intervals. More... | |
double | Gauss (const int &n) |
n-point Gauss rule inefficiently written! More... | |
double | sub_Gauss (const int &n) |
Evaluate the integral by applying an n-point Gauss rule on each of N sub-intervals. More... | |
double | trapezium () |
Quick trapezium summation again for sanity checking. More... | |
A quadrature class that takes a function pointer.
Definition at line 15 of file FnQuadrature.h.
typedef void(* CppNoddy::FnQuadrature::fn_ptr) (const double &, double &) |
The function pointer associated with this instance.
Definition at line 20 of file FnQuadrature.h.
CppNoddy::FnQuadrature::FnQuadrature | ( | fn_ptr | ptr_to_fn, |
const double & | x1, | ||
const double & | x2, | ||
const unsigned & | num_of_regions | ||
) |
Constructor.
ptr_to_fn | the function that defines the integrand. |
x1 | left hand boundary of the domain. |
x2 | right hand boundary of the domain. |
num_of_regions | initial number of sub-regions to divide the domain into. |
Definition at line 15 of file FnQuadrature.cpp.
References CppNoddy::Utility::uniform_node_vector().
CppNoddy::FnQuadrature::FnQuadrature | ( | fn_ptr | ptr_to_fn, |
const double & | x1, | ||
const double & | x2, | ||
const DenseVector< double > & | nodes | ||
) |
Constructor.
ptr_to_fn | the function that defines the integrand. |
x1 | left hand boundary of the domain. |
x2 | right hand boundary of the domain. |
nodes | A vector of nodal positions. |
Definition at line 26 of file FnQuadrature.cpp.
double CppNoddy::FnQuadrature::Gauss | ( | const int & | n | ) |
n-point Gauss rule inefficiently written!
n | The number of points. |
Definition at line 40 of file FnQuadrature.cpp.
References f, m, CppNoddy::DenseVector< _Type >::push_back(), CppNoddy::DenseVector< _Type >::scale(), and CppNoddy::DenseVector< _Type >::size().
Referenced by sub_Gauss().
void CppNoddy::FnQuadrature::set_subintervals | ( | const unsigned & | n | ) |
A set method to define a UNIFORM number of sub intervals.
n | Number of sub intervals |
Definition at line 36 of file FnQuadrature.cpp.
References CppNoddy::Utility::uniform_node_vector().
Referenced by main().
double CppNoddy::FnQuadrature::sub_Gauss | ( | const int & | n | ) |
Evaluate the integral by applying an n-point Gauss rule on each of N sub-intervals.
This is inefficient in terms of class instantiation for each sub-interval, but not currently an issue.
n | The order of the Gauss rule. |
Definition at line 88 of file FnQuadrature.cpp.
References Gauss(), and CppNoddy::DenseVector< _Type >::size().
Referenced by main().
double CppNoddy::FnQuadrature::trapezium | ( | ) |
Quick trapezium summation again for sanity checking.
Should be essentially equivalent to the 1-point Gauss rule.
Definition at line 106 of file FnQuadrature.cpp.
References h, and CppNoddy::DenseVector< _Type >::size().
Referenced by main().
© 2012
R.E. Hewitt