Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
JTOOLS::JPolfitFunction< N, M, JElement_t, JCollection_t, JResult_t, JDistance_t > Class Template Reference

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::JFunction< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_type > JTOOLS::JFunctional< JArgument_t, JResult_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 JFunction< 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< JElement_t::abscissa_type, JResultType< JElement_t::ordinate_type >::result_typefunctional_type
 
typedef JSupervisor supervisor_type
 

Public Member Functions

 JPolfitFunction ()
 Default constructor. More...
 
virtual result_type evaluate (const argument_type *pX) const override
 Recursive interpolation method implementation. More...
 
JSupervisor getSupervisor () const
 Get supervisor. More...
 
const JExceptionHandlergetExceptionHandler () const
 Get exception handler. More...
 
void setExceptionHandler (const JSupervisor &supervisor)
 Set the supervisor for handling of exceptions. More...
 

Static Public Member Functions

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

Protected Attributes

JSupervisor supervisor
 

Private Member Functions

virtual void do_compile () override
 Function compilation. More...
 

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 >
typedef 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 >
typedef 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 >
typedef 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 >
typedef 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 >
typedef 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 >
typedef 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 >
typedef 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 >
typedef 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 >
typedef 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 >
typedef 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 >
typedef JFunction<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 >
typedef 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 >
typedef 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 >
typedef 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

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

Definition at line 321 of file JFunctional.hh.

◆ supervisor_type

template<class JArgument_t , class JResult_t >
typedef JSupervisor JTOOLS::JFunctional< JArgument_t, JResult_t >::supervisor_type
inherited

Definition at line 89 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()

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

Implements JTOOLS::JFunctional< JArgument_t, JResult_t >.

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.
Definition: JException.hh:144
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
const JExceptionHandler & getExceptionHandler() const
Get exception handler.
Definition: JFunctional.hh:292
static result_type getValue(const JFunctional &function, const argument_type *pX)
Recursive function value evaluation.
Definition: JFunctional.hh:107
collection_type::const_iterator const_iterator
Definition: JPolfit.hh:59
function_type::argument_type argument_type
Definition: JPolfit.hh:67
std::vector< std::pair< abscissa_type, result_type > > buffer
Definition: JPolfit.hh:156
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const int n
Definition: JPolint.hh:786
Definition: JSTDTypes.hh:14
Template definition for function evaluation of Legendre polynome.
Definition: JLegendre.hh:269
result_type action() const
Implementation of exception handler.
Definition: JFunctional.hh:155
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  {}

◆ getValue() [1/2]

template<class JArgument_t , class JResult_t >
static result_type JTOOLS::JFunctional< JArgument_t, JResult_t >::getValue ( const JFunctional< JArgument_t, JResult_t > &  function,
const argument_type pX 
)
inlinestaticinherited

Recursive function value evaluation.

Parameters
functionfunction
pXpointer to abscissa values

Definition at line 107 of file JFunctional.hh.

109  {
110  return function.evaluate(pX);
111  }

◆ getValue() [2/2]

template<class JArgument_t , class JResult_t >
static JClass<result_type>::argument_type JTOOLS::JFunctional< JArgument_t, JResult_t >::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 121 of file JFunctional.hh.

123  {
124  return value;
125  }

◆ getSupervisor()

template<class JArgument_t , class JResult_t >
JSupervisor JTOOLS::JFunctional< JArgument_t, JResult_t >::getSupervisor ( ) const
inlineinherited

Get supervisor.

Returns
supervisor

Definition at line 281 of file JFunctional.hh.

282  {
283  return supervisor;
284  }
JSupervisor supervisor
Definition: JFunctional.hh:310

◆ getExceptionHandler()

template<class JArgument_t , class JResult_t >
const JExceptionHandler& JTOOLS::JFunctional< JArgument_t, JResult_t >::getExceptionHandler ( ) const
inlineinherited

Get exception handler.

Returns
exception handler

Definition at line 292 of file JFunctional.hh.

293  {
294  return *supervisor;
295  }

◆ setExceptionHandler()

template<class JArgument_t , class JResult_t >
void JTOOLS::JFunctional< JArgument_t, JResult_t >::setExceptionHandler ( const JSupervisor supervisor)
inlineinherited

Set the supervisor for handling of exceptions.

Parameters
supervisorsupervisor

Definition at line 303 of file JFunctional.hh.

304  {
305  this->supervisor = supervisor;
306  }

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.

◆ supervisor

template<class JArgument_t , class JResult_t >
JSupervisor JTOOLS::JFunctional< JArgument_t, JResult_t >::supervisor
protectedinherited

Definition at line 310 of file JFunctional.hh.


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