Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61346178
IntegrationSolver1D.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, May 6, 02:34
Size
3 KB
Mime Type
text/x-c++
Expires
Wed, May 8, 02:34 (2 d)
Engine
blob
Format
Raw Data
Handle
17498812
Attached To
R7917 Guggisberg-Liardon - Numerical integration
IntegrationSolver1D.hpp
View Options
#ifndef PROJECT_INTEGRALSOLVER1D_HPP
#define PROJECT_INTEGRALSOLVER1D_HPP
#include "IntegrationSolver.hpp"
#include "DomainCartesian.hpp"
#include "FunctionRntoR.hpp"
#include <vector>
class
IntegrationSolver1D
:
public
IntegrationSolver
<
FunctionRntoR
,
DomainCartesian
,
double
>
{
public
:
// Constructor and destructor
IntegrationSolver1D
(
FunctionRntoR
function_
,
DomainCartesian
domain_
,
Method
method_
);
virtual
~
IntegrationSolver1D
();
// Integration methods
double
IntegrationMidpoint
();
double
IntegrationTrapeze
();
double
IntegrationSimpson
();
// Compute method
double
Compute
();
private
:
double
a
;
double
b
;
double
n
;
std
::
string
type
;
};
#endif
//PROJECT_INTEGRALSOLVER1D_HPP
/*! \class IntegrationSolver1D class.h "inc/class.h"
* \brief Class using the template IntegrationSolver for the specific case of a 1D domain.
*
* It computes the integral of f : R -> R, over the linear domain (a to b) with a regular subdivision of n parts.
*
* It uses the user-specified method of integration, which is either Midpoint, Trapeze or Simpson.
*/
/*! \fn IntegrationSolver1D::IntegrationSolver1D(FunctionRntoR function_,DomainCartesian domain_, Method method_)
* \brief Standard constructor using a specialization of the template one from IntegrationSolver.
* \param function_ is a FunctionRntoR type object containing the function to be integrated
* \param domain_ is a DomainCartesian type object containing the domain of integration
* \param method_ is a Method type object containing the integration method
*/
/*! \fn IntegrationSolver1D::Compute()
* \brief Method that trigger the computing of the integration.
*
* When called, it fills the private variables of boundaries and subdivision for this specific case of 1D domain, and
* returns the result of the integration using the integration method from the class Method.
* \returns a double, which is the result of the integration of f over the domain.
*/
/*! \fn IntegrationSolver1D::IntegrationMidpoint()
* \brief Method that computes the integral using Midpoint method.
*
* Midpoint consists in the discretization of the domain into sub-intervals. The integral is the sum of the function
* evaluated at the center of the sub-intervals multiplied by the interval's length. Result is computed by iterating
* over the sub-intervals.
* \returns a double.
*/
/*! \fn IntegrationSolver1D::IntegrationTrapeze()
* \brief Method that computes the integral using Trapeze method.
*
* Trapeze consists in the discretization of the domain into sub-intervals. The integral is the sum for each sub-interval
* of the mean of the function evaluated at the corner of the sub-interval, multiplied by the sub-interval's length.
* Result is computed by iterating over the sub-intervals.
* \returns a double.
*/
/*! \fn IntegrationSolver1D::IntegrationSimpson()
* \brief Method that computes the integral using Simpson method.
*
* Simpson consists uses a discretization of the domain into sub-intervals. The integral is the sum of an integration over
* each sub-intervals. This integration uses a quadratic approximation on the sub-intervals, using the corners and a
* point at the middle. Values of the integration of a quadratic approximation for a given set of values are known.
* Result is obtained by iterating over the sub-intervals and summing the quadratic integral.
* \returns a double.
*/
Event Timeline
Log In to Comment