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

Template class for polynomial interpolation in 1D. More...

#include <JPolfit.hh>

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

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 JFunction1D< abscissa_type, JResult_t > function_type
 
typedef function_type::argument_type argument_type
 
typedef function_type::result_type result_type
 
typedef function_type::JExceptionHandler exceptionhandler_type
 
typedef JResultType< ordinate_type >::result_type data_type
 
enum  
 
typedef JFunctional< JElement_t::abscissa_type, typename JElement_t::ordinate_type > functional_type
 
typedef functional_type::JExceptionHandler JExceptionHandler
 
typedef JSupervisor supervisor_type
 
typedef JFunctional< argument_type, result_typefunctional_type
 

Public Member Functions

 JPolfitFunction1D ()
 Default contructor.
 
virtual result_type evaluate (const argument_type *pX) const override
 Recursive interpolation method implementation.
 
result_type operator() (const argument_type x) const
 Function value evaluation.
 
const JSupervisor & getSupervisor () const
 Get supervisor.
 
const JExceptionHandler & getExceptionHandler () const override
 Get exception handler.
 
void setExceptionHandler (const JSupervisor &supervisor)
 Set the supervisor for handling of exceptions.
 
virtual result_type evaluate (const argument_type *pX) const=0
 Recursive function value evaluation.
 
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.
 
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.
 

Protected Attributes

JSupervisor __supervisor
 

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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
class JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >

Template class for polynomial interpolation in 1D.

This class implements the JFunction1D interface.

Definition at line 171 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JCollection_t<JElement_t, JDistance_t> JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::collection_type

Definition at line 177 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::abscissa_type JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::abscissa_type

Definition at line 179 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::ordinate_type JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::ordinate_type

Definition at line 180 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::value_type JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::value_type

Definition at line 181 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::distance_type JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::distance_type

Definition at line 182 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::const_iterator JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::const_iterator

Definition at line 184 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::const_reverse_iterator JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::const_reverse_iterator

Definition at line 185 of file JPolfit.hh.

◆ iterator

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::iterator JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::iterator

Definition at line 186 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::reverse_iterator JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::reverse_iterator

Definition at line 187 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JFunction1D<abscissa_type, JResult_t> JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::function_type

Definition at line 189 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
function_type::argument_type JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::argument_type

Definition at line 191 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
function_type::result_type JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::result_type

Definition at line 192 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 = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
function_type::JExceptionHandler JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::exceptionhandler_type

Definition at line 193 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
inherited

Definition at line 64 of file JPolfit.hh.

◆ functional_type [1/2]

JFunctional<JElement_t::abscissa_type, typename JElement_t::ordinate_type> JTOOLS::JFunction1D< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::functional_type
inherited

Definition at line 332 of file JFunctional.hh.

◆ JExceptionHandler

functional_type::JExceptionHandler JTOOLS::JFunction< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::JExceptionHandler
inherited

Definition at line 235 of file JFunctional.hh.

◆ supervisor_type

JSupervisor JTOOLS::JFunction< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::supervisor_type
inherited

Definition at line 237 of file JFunctional.hh.

◆ functional_type [2/2]

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.

Member Enumeration Documentation

◆ anonymous enum

Constructor & Destructor Documentation

◆ JPolfitFunction1D()

template<unsigned int N, unsigned int M, class JElement_t , template< class, class > class JCollection_t, class JResult_t = typename JElement_t::ordinate_type, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JTOOLS::JPolfitFunction1D< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t >::JPolfitFunction1D ( )
inline

Default contructor.

Definition at line 199 of file JPolfit.hh.

200 {}

Member Function Documentation

◆ evaluate() [1/3]

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
inlineoverridevirtualinherited

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 ( )
inlineoverrideprivatevirtualinherited

Function compilation.

Definition at line 153 of file JPolfit.hh.

154 {}

◆ operator()()

result_type JTOOLS::JFunction1D< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::operator() ( const argument_type x) const
inlineinherited

Function value evaluation.

Parameters
xargument value
Returns
function value

Definition at line 343 of file JFunctional.hh.

344 {
345 return this->evaluate(&x);
346 }

◆ getSupervisor()

const JSupervisor & JTOOLS::JFunction< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::getSupervisor ( ) const
inlineinherited

Get supervisor.

Returns
supervisor

Definition at line 290 of file JFunctional.hh.

◆ getExceptionHandler() [1/2]

const JExceptionHandler & JTOOLS::JFunction< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::getExceptionHandler ( ) const
inlineoverridevirtualinherited

Get exception handler.

Returns
exception handler

Implements JTOOLS::JFunctional< JElement_t::abscissa_type, typename JElement_t::ordinate_type >.

Definition at line 301 of file JFunctional.hh.

302 {
303 return *__supervisor.handler;
304 }

◆ setExceptionHandler()

void JTOOLS::JFunction< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::setExceptionHandler ( const JSupervisor & supervisor)
inlineinherited

Set the supervisor for handling of exceptions.

Parameters
supervisorsupervisor

Definition at line 312 of file JFunctional.hh.

313 {
314 this->__supervisor = supervisor;
315 }

◆ evaluate() [2/3]

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

Recursive function value evaluation.

Parameters
pXpointer to abscissa values
Returns
function value

◆ getValue() [1/4]

static result_type JTOOLS::JFunctional< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::getValue ( const JFunctional< JElement_t::abscissa_type, typename JElement_t::ordinate_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/4]

static JClass< result_type >::argument_type JTOOLS::JFunctional< JElement_t::abscissa_type, typename JElement_t::ordinate_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 }

◆ evaluate() [3/3]

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() [3/4]

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() [4/4]

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() [2/2]

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
mutableprivateinherited

Definition at line 156 of file JPolfit.hh.

◆ __supervisor

JSupervisor JTOOLS::JFunction< JElement_t::abscissa_type, typename JElement_t::ordinate_type >::__supervisor
protectedinherited

Definition at line 318 of file JFunctional.hh.


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