Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t > Class Template Referenceabstract

Functional collection with Legendre polynomial interpolation. More...

#include <JPolfit.hh>

Inheritance diagram for JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >:
JTOOLS::JFunctional< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_type > JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >

Public Types

typedef JCollection_t< JElement_t, JDistance_t > collection_type
 
typedef collection_type::abscissa_type abscissa_type
 
typedef collection_type::ordinate_type ordinate_type
 
typedef collection_type::value_type value_type
 
typedef collection_type::distance_type distance_type
 
typedef collection_type::const_iterator const_iterator
 
typedef collection_type::const_reverse_iterator const_reverse_iterator
 
typedef collection_type::iterator iterator
 
typedef collection_type::reverse_iterator reverse_iterator
 
typedef JResultType< ordinate_type >::result_type data_type
 
typedef JFunctional< abscissa_type, data_typefunction_type
 
typedef function_type::argument_type argument_type
 
typedef function_type::result_type result_type
 
typedef function_type::JExceptionHandler exceptionhandler_type
 
typedef JFunctional< argument_type, result_typefunctional_type
 

Public Member Functions

 JPolfitFunction ()
 Default constructor.
 
virtual result_type evaluate (const argument_type *pX) const override
 Recursive interpolation method implementation.
 
virtual result_type evaluate (const argument_type *pX) const=0
 Recursive function value evaluation.
 
virtual const JExceptionHandler & getExceptionHandler () const=0
 Get exception handler.
 

Static Public Member Functions

static result_type getValue (const JFunctional &function, const argument_type *pX)
 Recursive function value evaluation.
 
static JClass< result_type >::argument_type getValue (typename JClass< result_type >::argument_type value, const argument_type *pX)
 Termination of recursive function value evaluation.
 

Private Member Functions

virtual void do_compile () override
 Function compilation.
 

Private Attributes

std::vector< std::pair< abscissa_type, result_type > > buffer
 

Detailed Description

template<unsigned int N, unsigned int M, class JElement_t, template< class, class > class JCollection_t, class JResult_t, class JDistance_t>
class JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >

Functional collection with Legendre polynomial interpolation.

Definition at line 45 of file JPolfit.hh.

Member Typedef Documentation

◆ collection_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
JCollection_t<JElement_t, JDistance_t> JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::collection_type

Definition at line 52 of file JPolfit.hh.

◆ abscissa_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
collection_type::abscissa_type JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::abscissa_type

Definition at line 54 of file JPolfit.hh.

◆ ordinate_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
collection_type::ordinate_type JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::ordinate_type

Definition at line 55 of file JPolfit.hh.

◆ value_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
collection_type::value_type JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::value_type

Definition at line 56 of file JPolfit.hh.

◆ distance_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
collection_type::distance_type JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::distance_type

Definition at line 57 of file JPolfit.hh.

◆ const_iterator

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
collection_type::const_iterator JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::const_iterator

Definition at line 59 of file JPolfit.hh.

◆ const_reverse_iterator

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
collection_type::const_reverse_iterator JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::const_reverse_iterator

Definition at line 60 of file JPolfit.hh.

◆ iterator

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
collection_type::iterator JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::iterator

Definition at line 61 of file JPolfit.hh.

◆ reverse_iterator

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
collection_type::reverse_iterator JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::reverse_iterator

Definition at line 62 of file JPolfit.hh.

◆ data_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
JResultType<ordinate_type>::result_type JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::data_type

Definition at line 64 of file JPolfit.hh.

◆ function_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
JFunctional<abscissa_type, data_type> JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::function_type

Definition at line 65 of file JPolfit.hh.

◆ argument_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
function_type::argument_type JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::argument_type

Definition at line 67 of file JPolfit.hh.

◆ result_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
function_type::result_type JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::result_type

Definition at line 68 of file JPolfit.hh.

◆ exceptionhandler_type

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
function_type::JExceptionHandler JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::exceptionhandler_type

Definition at line 69 of file JPolfit.hh.

◆ functional_type

JFunctional<argument_type, result_type> JTOOLS::JFunctional< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_type >::functional_type
inherited

Definition at line 85 of file JFunctional.hh.

Constructor & Destructor Documentation

◆ JPolfitFunction()

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::JPolfitFunction ( )
inline

Default constructor.


Definition at line 75 of file JPolfit.hh.

76 {
77 STATIC_CHECK((N > M));
78 }
#define STATIC_CHECK(expr)
Definition JAssert.hh:31

Member Function Documentation

◆ evaluate() [1/2]

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
virtual result_type JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::evaluate ( const argument_type * pX) const
inlineoverridevirtual

Recursive interpolation method implementation.

Parameters
pXpointer to abscissa values
Returns
function value

Definition at line 87 of file JPolfit.hh.

88 {
89 using namespace std;
90 using namespace JPP;
91
92 const argument_type x = *pX;
93
94 if (this->size() <= 1u) {
95
96 try {
97 return this->getExceptionHandler().action();
98 }
99 catch (const JException& error) {
100
101 std::ostringstream os;
102
103 os << __FILE__ << ':' << __LINE__ << " not enough data " << STREAM("?") << x;
104
105 throw JFunctionalException(os.str());
106 }
107 }
108
109 const_iterator p = this->lower_bound(x);
110
111 if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
112 (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
113
114 try {
115 return this->getExceptionHandler().action();
116 }
117 catch (const JException& error) {
118
119 std::ostringstream os;
120
121 os << __FILE__ << ':' << __LINE__ << " abscissa out of range "
122 << STREAM("?") << x << " <> "
123 << STREAM("?") << this->begin() ->getX() << ' '
124 << STREAM("?") << this->rbegin()->getX();
125
126 throw JValueOutOfRange(os.str());
127 }
128 }
129
130 ++pX; // next argument value
131
132
133 int n = std::min((int) (N + 1), (int) this->size()); // number of points to interpolate
134
135 for (int i = n/2; i != 0 && p != this->end(); --i, ++p) {} // move p to begin of data
136 for (int i = n ; i != 0 && p != this->begin(); --i, --p) {}
137
138 buffer.clear();
139
140 for (const_iterator q = p; n != 0; ++q, --n) {
141 buffer.push_back(make_pair(this->getDistance(p->getX(), q->getX()), function_type::getValue(q->getY(), pX)));
142 }
143
144 const JLegendre<result_type, M> g1(buffer.begin(), buffer.end());
145
146 return g1(this->getDistance(p->getX(), x));
147 }
Double_t g1(const Double_t x)
Function.
Definition JQuantiles.cc:25
General exception.
Definition JException.hh:24
Exception for a functional operation.
Exception for accessing a value in a collection that is outside of its range.
static result_type getValue(const JFunctional &function, const argument_type *pX)
Recursive function value evaluation.
function_type::argument_type argument_type
Definition JPolfit.hh:67
std::vector< std::pair< abscissa_type, result_type > > buffer
Definition JPolfit.hh:156
collection_type::const_iterator const_iterator
Definition JPolfit.hh:59
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const int n
Definition JPolint.hh:791
Template definition for function evaluation of Legendre polynome.
Definition JLegendre.hh:269
Auxiliary data structure for handling std::ostream.

◆ do_compile()

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
virtual void JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::do_compile ( )
inlineoverrideprivatevirtual

Function compilation.

Definition at line 153 of file JPolfit.hh.

154 {}

◆ evaluate() [2/2]

virtual result_type JTOOLS::JFunctional< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_type >::evaluate ( const argument_type * pX) const
pure virtualinherited

Recursive function value evaluation.

Parameters
pXpointer to abscissa values
Returns
function value

◆ getValue() [1/2]

static result_type JTOOLS::JFunctional< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_type >::getValue ( const JFunctional< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_type > & function,
const argument_type * pX )
inlinestaticinherited

Recursive function value evaluation.

Parameters
functionfunction
pXpointer to abscissa values

Definition at line 103 of file JFunctional.hh.

105 {
106 return function.evaluate(pX);
107 }

◆ getValue() [2/2]

static JClass< result_type >::argument_type JTOOLS::JFunctional< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_type >::getValue ( typename JClass< result_type >::argument_type value,
const argument_type * pX )
inlinestaticinherited

Termination of recursive function value evaluation.

Parameters
valueresult
pXpointer to abscissa values

Definition at line 117 of file JFunctional.hh.

119 {
120 return value;
121 }

◆ getExceptionHandler()

virtual const JExceptionHandler & JTOOLS::JFunctional< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_type >::getExceptionHandler ( ) const
pure virtualinherited

Get exception handler.

Returns
exception handler

Member Data Documentation

◆ buffer

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t , class JDistance_t >
std::vector< std::pair<abscissa_type, result_type> > JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::buffer
mutableprivate

Definition at line 156 of file JPolfit.hh.


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