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::JGaussHermite Class Reference

Numerical integrator for $ W(x) = e^{-x^{2}} $. More...

#include <JQuadrature.hh>

Inheritance diagram for JTOOLS::JGaussHermite:
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 >

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

 JGaussHermite (const int n, const double eps=1.0e-12)
 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

Numerical integrator for $ W(x) = e^{-x^{2}} $.

Gauss-Hermite integration code is taken from reference: Numerical Recipes in C++, W.H. Press, S.A. Teukolsky, W.T. Vetterling and B.P. Flannery, Cambridge University Press.

Definition at line 249 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

◆ JGaussHermite()

JTOOLS::JGaussHermite::JGaussHermite ( const int n,
const double eps = 1.0e-12 )
inline

Constructor.

Parameters
nnumber of points
epsprecision

Definition at line 259 of file JQuadrature.hh.

260 :
262 {
263 resize(n);
264
265 const double pii = 1.0 / pow(PI,0.25);
266
267 const int number_of_iterations = 100;
268
269 const int M = (n + 1) / 2;
270
271 double p0, p1, p2, pp;
272 double z = 0.0;
273 double z1;
274
275 for (int i = 0; i < M; ++i) {
276
277 switch (i) {
278
279 case 0:
280 z = sqrt((double) (2*n+1)) - 1.85575 * pow((double) (2*n+1),-0.16667);
281 break;
282
283 case 1:
284 z -= 1.14 * pow((double) n,0.426) / z;
285 break;
286
287 case 2:
288 z = 1.86*z + 0.86*at( 0 ).getX();
289 break;
290
291 case 3:
292 z = 1.91*z + 0.91*at( 1 ).getX();
293 break;
294
295 default:
296 z = 2.00*z + 1.00*at(i-2).getX();
297 break;
298 }
299
300 for (int k = 0; k != number_of_iterations; ++k) {
301
302 p1 = 0.0;
303 p2 = pii;
304
305 // recurrence relation
306
307 for (int j = 0; j < n; ++j) {
308 p0 = p1;
309 p1 = p2;
310 p2 = z * sqrt(2.0/(double) (j+1)) * p1 - sqrt((double) j / (double) (j+1)) * p0;
311 }
312
313 pp = sqrt((double) (2*n)) * p1;
314
315 z1 = z;
316 z = z1 - p2/pp;
317
318 if (fabs(z-z1) < eps)
319 break;
320 }
321
322 const double y = 2.0 / (pp*pp);
323
324 at( i ) = JElement2D_t(-z,y);
325 at(n-i-1) = JElement2D_t(+z,y);
326 }
327 }
TPaveText * p1
void resize(typename container_type::size_type size)
Resize collection.
JQuadrature()
Default constructor.
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97
JElement2D< double, double > JElement2D_t
Type definition of basic element for quadratures.
const int n
Definition JPolint.hh:791
int j
Definition JPolint.hh:801

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: