Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
JTOOLS::JQuadrature Class Reference

Type definition for numerical integration. More...

#include <JQuadrature.hh>

Inheritance diagram for JTOOLS::JQuadrature:
JTOOLS::JCollection< JElement2D_t > std::vector< JElement_t, JAllocator_t > JTOOLS::JMappableCollection< JElement_t::abscissa_type, JElement_t::ordinate_type > JTOOLS::JAbstractCollection< JElement_t::abscissa_type > JMATH::JMath< JFirst_t, JSecond_t > JTOOLS::JBitangent JTOOLS::JCotangent JTOOLS::JGaussHermite JTOOLS::JGaussLaguerre JTOOLS::JGaussLegendre JTOOLS::JHenyeyGreenstein JTOOLS::JRayleigh JPHYSICS::JPDF JPHYSICS::JAbstractPDF JPHYSICS::JPDF_C

Public Types

typedef JElement_t::abscissa_type abscissa_type
 
typedef JElement_t::ordinate_type ordinate_type
 
typedef JElement2D_t value_type
 
typedef JDistance< typename JElement_t::abscissa_type > distance_type
 
typedef JCollection< JElement2D_t, JDistance< typename JElement_t::abscissa_type > > collection_type
 
typedef std::vector< value_typecontainer_type
 
typedef container_type::const_iterator const_iterator
 
typedef container_type::const_reverse_iterator const_reverse_iterator
 
typedef container_type::iterator iterator
 
typedef container_type::reverse_iterator reverse_iterator
 
typedef JCollectionElementTransformer< value_typetransformer_type
 
typedef std::pair< const_iterator, bool > pair_type
 
typedef JElement_t::abscissa_type key_type
 
typedef JElement_t::ordinate_type mapped_type
 

Public Member Functions

 JQuadrature ()
 Default constructor.
 
template<class JFunction_t >
 JQuadrature (const double xmin, const double xmax, const int nx, JFunction_t integral, const double eps=1.0e-4)
 General purpose constructor.
 
virtual void clear () override
 Clear.
 
virtual const ordinate_typeget (typename JClass< abscissa_type >::argument_type x) const override
 Get ordinate value.
 
virtual ordinate_typeget (typename JClass< abscissa_type >::argument_type x) override
 Get ordinate value.
 
virtual int getSize () const override
 Get number of elements.
 
virtual abscissa_type getX (int index) const override
 Get abscissa value.
 
virtual abscissa_type getXmin () const override
 Get minimal abscissa value.
 
virtual abscissa_type getXmax () const override
 Get maximal abscissa value.
 
const ordinate_typegetY (int index) const
 Get ordinate value.
 
ordinate_typegetY (int index)
 Get ordinate value.
 
void transform (const transformer_type &transformer)
 Transform collection.
 
void sort ()
 Sort elements.
 
const_iterator lower_bound (typename JClass< abscissa_type >::argument_type x) const
 Get first position of element i, where x >= i->getX().
 
iterator lower_bound (typename JClass< abscissa_type >::argument_type x)
 Get first position of element i, where x >= i->getX().
 
pair_type insert (const value_type &element)
 Insert element.
 
void configure (const JAbstractCollection< abscissa_type > &bounds)
 Configure collection.
 
void configure (const JAbstractCollection< abscissa_type > &bounds, typename JClass< ordinate_type >::argument_type value)
 Configure collection.
 
void configure (const JAbstractCollection< abscissa_type > &bounds, const JFunction1D_t &function)
 Configure collection.
 
bool is_compatible (const JCollection &collection) const
 Test whether collections are compatible.
 
bool in_range (typename JClass< abscissa_type >::argument_type x) const
 Check if given abscissa is in range of this collection.
 
JCollectionnegate ()
 Negate collection.
 
JCollectionadd (const JCollection &collection)
 Add collection.
 
JCollectionadd (typename JClass< ordinate_type >::argument_type value)
 Add offset.
 
JCollectionadd (const JFunction1D_t &function)
 Add function.
 
JCollectionsub (const JCollection &collection)
 Subtract collection.
 
JCollectionsub (typename JClass< ordinate_type >::argument_type value)
 Subtract offset.
 
JCollectionsub (const JFunction1D_t &function)
 Subtract function.
 
JCollectionmul (const double value)
 Scale contents.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 
JCollectiondiv (const double value)
 Scale contents.
 
const JComparator & getComparator () const
 Get comparator.
 
const mapped_typeoperator[] (typename JClass< key_type >::argument_type key) const
 Get mapped value.
 
mapped_typeoperator[] (typename JClass< key_type >::argument_type key)
 Get mapped value.
 
void put (typename JClass< key_type > ::argument_type key, typename JClass< mapped_type >::argument_type value)
 Put pair-wise element (key,value) into collection.
 
bool is_equal (const JAbstractCollection &collection) const
 Test whether abstract collections are equal.
 

Public Attributes

JDistance< typename JElement_t::abscissa_type > getDistance
 Function object for distance evaluation.
 

Protected Member Functions

void resize (typename container_type::size_type size)
 Resize collection.
 

Protected Attributes

JComparator compare
 Function object for comparison.
 

Private Member Functions

void erase ()
 
void push_back ()
 
void pop_back ()
 

Detailed Description

Type definition for numerical integration.

     \f[\displaystyle \int_{x_1}^{x_2} f(x) dx = \sum_{i=1}^{N} w_i f(x_i) \f]

The abscissa and ordinate values of the collection can be used as abscissa and weight values of the summation to approximately determine the integral of the function.

Definition at line 37 of file JQuadrature.hh.

Member Typedef Documentation

◆ abscissa_type

typedef JElement_t::abscissa_type JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::abscissa_type
inherited

Definition at line 82 of file JCollection.hh.

◆ ordinate_type

typedef JElement_t::ordinate_type JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::ordinate_type
inherited

Definition at line 83 of file JCollection.hh.

◆ value_type

typedef JElement2D_t JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::value_type
inherited

Definition at line 84 of file JCollection.hh.

◆ distance_type

typedef JDistance<typename JElement_t::abscissa_type> JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::distance_type
inherited

Definition at line 85 of file JCollection.hh.

◆ collection_type

typedef JCollection<JElement2D_t , JDistance<typename JElement_t::abscissa_type> > JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::collection_type
inherited

Definition at line 87 of file JCollection.hh.

◆ container_type

typedef std::vector<value_type> JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::container_type
inherited

Definition at line 89 of file JCollection.hh.

◆ const_iterator

typedef container_type::const_iterator JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::const_iterator
inherited

Definition at line 91 of file JCollection.hh.

◆ const_reverse_iterator

typedef container_type::const_reverse_iterator JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::const_reverse_iterator
inherited

Definition at line 92 of file JCollection.hh.

◆ iterator

typedef container_type::iterator JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::iterator
inherited

Definition at line 93 of file JCollection.hh.

◆ reverse_iterator

typedef container_type::reverse_iterator JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::reverse_iterator
inherited

Definition at line 94 of file JCollection.hh.

◆ transformer_type

typedef JCollectionElementTransformer<value_type> JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::transformer_type
inherited

Definition at line 96 of file JCollection.hh.

◆ pair_type

typedef std::pair<const_iterator, bool> JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::pair_type
inherited

Definition at line 97 of file JCollection.hh.

◆ key_type

typedef JElement_t::abscissa_type JTOOLS::JMappableCollection< JElement_t::abscissa_type , JElement_t::ordinate_type >::key_type
inherited

Definition at line 33 of file JMappableCollection.hh.

◆ mapped_type

typedef JElement_t::ordinate_type JTOOLS::JMappableCollection< JElement_t::abscissa_type , JElement_t::ordinate_type >::mapped_type
inherited

Definition at line 34 of file JMappableCollection.hh.

Constructor & Destructor Documentation

◆ JQuadrature() [1/2]

JTOOLS::JQuadrature::JQuadrature ( )
inline

Default constructor.

Definition at line 44 of file JQuadrature.hh.

45 {}

◆ JQuadrature() [2/2]

template<class JFunction_t >
JTOOLS::JQuadrature::JQuadrature ( const double xmin,
const double xmax,
const int nx,
JFunction_t integral,
const double eps = 1.0e-4 )
inline

General purpose constructor.

The template argument should correspond to a function requiring two arguments.
These two arguments should correspond to the lower and upper integration limit, respectively.
The given function should return the value of the integral between the two integration limits.

Parameters
xminminimal x
xmaxmaximal x
nxnumber of points
integralintegral
epsprecision

Definition at line 62 of file JQuadrature.hh.

67 {
68 double Xmin = xmin;
69 double Xmax = xmax;
70
71 const double Vmin = integral(Xmin, Xmax) / (double) nx;
72
73 for (int i = 0; i != nx; ++i) {
74
75 for (double xmin = Xmin, xmax = Xmax; ; ) {
76
77 const double x = 0.5 * (xmin + xmax);
78 const double v = integral(Xmin, x);
79
80 if (fabs(Vmin - v) < eps * Vmin ||
81 fabs(xmax - xmin) < eps * (Xmax - Xmin)) {
82
83 const double __x = 0.5 * (Xmin + x);
84 const double __y = Vmin / integral(__x);
85
86 insert(JElement2D_t(__x,__y));
87
88 Xmin = x;
89 xmax = Xmax;
90
91 break;
92 }
93
94 if (v < Vmin)
95 xmin = x;
96 else
97 xmax = x;
98 }
99 }
100 }
pair_type insert(const value_type &element)
Insert element.
JElement2D< double, double > JElement2D_t
Type definition of basic element for quadratures.

Member Function Documentation

◆ clear()

virtual void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::clear ( )
inlineoverridevirtualinherited

◆ get() [1/2]

virtual const ordinate_type & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::get ( typename JClass< abscissa_type >::argument_type x) const
inlineoverridevirtualinherited

Get ordinate value.

Parameters
xabscissa value
Returns
ordinate value

Implements JTOOLS::JMappableCollection< JElement_t::abscissa_type, JElement_t::ordinate_type >.

Definition at line 162 of file JCollection.hh.

◆ get() [2/2]

virtual ordinate_type & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::get ( typename JClass< abscissa_type >::argument_type x)
inlineoverridevirtualinherited

Get ordinate value.

Parameters
xabscissa value
Returns
ordinate value

Implements JTOOLS::JMappableCollection< JElement_t::abscissa_type, JElement_t::ordinate_type >.

Definition at line 180 of file JCollection.hh.

◆ getSize()

virtual int JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::getSize ( ) const
inlineoverridevirtualinherited

Get number of elements.

Returns
number of elements

Implements JTOOLS::JAbstractCollection< JElement_t::abscissa_type >.

Definition at line 197 of file JCollection.hh.

◆ getX()

virtual abscissa_type JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::getX ( int index) const
inlineoverridevirtualinherited

Get abscissa value.

Parameters
indexindex
Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JElement_t::abscissa_type >.

Definition at line 209 of file JCollection.hh.

◆ getXmin()

virtual abscissa_type JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::getXmin ( ) const
inlineoverridevirtualinherited

Get minimal abscissa value.

Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JElement_t::abscissa_type >.

Definition at line 220 of file JCollection.hh.

◆ getXmax()

virtual abscissa_type JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::getXmax ( ) const
inlineoverridevirtualinherited

Get maximal abscissa value.

Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JElement_t::abscissa_type >.

Definition at line 231 of file JCollection.hh.

◆ getY() [1/2]

const ordinate_type & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::getY ( int index) const
inlineinherited

Get ordinate value.

Parameters
indexindex
Returns
ordinate value

Definition at line 244 of file JCollection.hh.

◆ getY() [2/2]

ordinate_type & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::getY ( int index)
inlineinherited

Get ordinate value.

Parameters
indexindex
Returns
ordinate value

Definition at line 256 of file JCollection.hh.

◆ transform()

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::transform ( const transformer_type & transformer)
inlineinherited

Transform collection.

Parameters
transformerelement transformer

Definition at line 267 of file JCollection.hh.

◆ sort()

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::sort ( )
inlineinherited

Sort elements.

Definition at line 280 of file JCollection.hh.

◆ lower_bound() [1/2]

const_iterator JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::lower_bound ( typename JClass< abscissa_type >::argument_type x) const
inlineinherited

Get first position of element i, where x >= i->getX().

Parameters
xabscissa value
Returns
position of corresponding element

Definition at line 292 of file JCollection.hh.

◆ lower_bound() [2/2]

iterator JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::lower_bound ( typename JClass< abscissa_type >::argument_type x)
inlineinherited

Get first position of element i, where x >= i->getX().

Parameters
xabscissa value
Returns
position of corresponding element

Definition at line 304 of file JCollection.hh.

◆ insert()

pair_type JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::insert ( const value_type & element)
inlineinherited

Insert element.

Parameters
elementelement
Returns
(iterator, status), where status is true if inserted; else false

Definition at line 316 of file JCollection.hh.

◆ configure() [1/3]

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::configure ( const JAbstractCollection< abscissa_type > & bounds)
inlineinherited

Configure collection.

Parameters
boundsabscissa values

Definition at line 332 of file JCollection.hh.

◆ configure() [2/3]

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::configure ( const JAbstractCollection< abscissa_type > & bounds,
typename JClass< ordinate_type >::argument_type value )
inlineinherited

Configure collection.

Parameters
boundsabscissa values
valueordinate value

Definition at line 344 of file JCollection.hh.

◆ configure() [3/3]

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::configure ( const JAbstractCollection< abscissa_type > & bounds,
const JFunction1D_t & function )
inlineinherited

Configure collection.

Parameters
boundsabscissa values
functionfunction

Definition at line 365 of file JCollection.hh.

◆ is_compatible()

bool JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::is_compatible ( const JCollection< JElement2D_t > & collection) const
inlineinherited

Test whether collections are compatible.

Parameters
collectioncollection
Returns
true if collections are compatible; else false

Definition at line 394 of file JCollection.hh.

◆ in_range()

bool JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::in_range ( typename JClass< abscissa_type >::argument_type x) const
inlineinherited

Check if given abscissa is in range of this collection.

Parameters
xabscissa value
Returns
true if in tange: else false

Definition at line 437 of file JCollection.hh.

◆ negate()

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::negate ( )
inlineinherited

Negate collection.

Returns
this collection

Definition at line 452 of file JCollection.hh.

◆ add() [1/3]

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::add ( const JCollection< JElement2D_t > & collection)
inlineinherited

Add collection.

Parameters
collectioncollection
Returns
this collection

Definition at line 468 of file JCollection.hh.

◆ add() [2/3]

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::add ( typename JClass< ordinate_type >::argument_type value)
inlineinherited

Add offset.

Parameters
valueoffset
Returns
this collection

Definition at line 620 of file JCollection.hh.

◆ add() [3/3]

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::add ( const JFunction1D_t & function)
inlineinherited

Add function.

Parameters
functionfunction
Returns
this collection

Definition at line 653 of file JCollection.hh.

◆ sub() [1/3]

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::sub ( const JCollection< JElement2D_t > & collection)
inlineinherited

Subtract collection.

Parameters
collectioncollection
Returns
this collection

Definition at line 528 of file JCollection.hh.

◆ sub() [2/3]

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::sub ( typename JClass< ordinate_type >::argument_type value)
inlineinherited

Subtract offset.

Parameters
valueoffset
Returns
this collection

Definition at line 636 of file JCollection.hh.

◆ sub() [3/3]

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::sub ( const JFunction1D_t & function)
inlineinherited

Subtract function.

Parameters
functionfunction
Returns
this collection

Definition at line 670 of file JCollection.hh.

◆ mul() [1/2]

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::mul ( const double value)
inlineinherited

Scale contents.

Parameters
valuemultiplication factor
Returns
this collection

Definition at line 588 of file JCollection.hh.

◆ mul() [2/2]

template<class JFirst_t , class JSecond_t >
JFirst_t & JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t & object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355 {
356 return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357 }

◆ div()

JCollection & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::div ( const double value)
inlineinherited

Scale contents.

Parameters
valuedivision factor
Returns
this collection

Definition at line 604 of file JCollection.hh.

◆ getComparator()

const JComparator & JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::getComparator ( ) const
inlineinherited

Get comparator.

Returns
comparator

Definition at line 784 of file JCollection.hh.

◆ resize()

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::resize ( typename container_type::size_type size)
inlineprotectedinherited

Resize collection.

Parameters
sizesize

Definition at line 808 of file JCollection.hh.

◆ erase()

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::erase ( )
privateinherited

◆ push_back()

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::push_back ( )
privateinherited

◆ pop_back()

void JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::pop_back ( )
privateinherited

◆ operator[]() [1/2]

const mapped_type & JTOOLS::JMappableCollection< JElement_t::abscissa_type , JElement_t::ordinate_type >::operator[] ( typename JClass< key_type >::argument_type key) const
inlineinherited

Get mapped value.

Parameters
keykey
Returns
value

Definition at line 73 of file JMappableCollection.hh.

◆ operator[]() [2/2]

mapped_type & JTOOLS::JMappableCollection< JElement_t::abscissa_type , JElement_t::ordinate_type >::operator[] ( typename JClass< key_type >::argument_type key)
inlineinherited

Get mapped value.

Parameters
keykey
Returns
value

Definition at line 85 of file JMappableCollection.hh.

◆ put()

void JTOOLS::JMappableCollection< JElement_t::abscissa_type , JElement_t::ordinate_type >::put ( typename JClass< key_type > ::argument_type key,
typename JClass< mapped_type >::argument_type value )
inlineinherited

Put pair-wise element (key,value) into collection.

Parameters
keykey
valuevalue

Definition at line 97 of file JMappableCollection.hh.

◆ is_equal()

bool JTOOLS::JAbstractCollection< JElement_t::abscissa_type >::is_equal ( const JAbstractCollection< JElement_t::abscissa_type > & collection) const
inlineinherited

Test whether abstract collections are equal.

Parameters
collectionabstract collection
Returns
true if collections are equals; else false

Definition at line 72 of file JAbstractCollection.hh.

Member Data Documentation

◆ getDistance

JDistance<typename JElement_t::abscissa_type> JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::getDistance
inherited

Function object for distance evaluation.

Definition at line 793 of file JCollection.hh.

◆ compare

JComparator JTOOLS::JCollection< JElement2D_t , JDistance<typename JElement_t::abscissa_type> >::compare
protectedinherited

Function object for comparison.

Definition at line 800 of file JCollection.hh.


The documentation for this class was generated from the following file: