Jpp  18.2.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t > Class Template Referenceabstract

Template base class for spline interpolations. More...

#include <JSpline.hh>

Inheritance diagram for JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >:
JTOOLS::JFunctional<> JTOOLS::JSplineFunction< JElement_t, JCollection_t, JResultDerivative< typename JResultType< typename JElement_t::ordinate_type >::result_type >, JDistance_t > JTOOLS::JSplineFunction< JElement_t, JCollection_t, JResultPDF< typename JResultType< typename JElement_t::ordinate_type >::result_type >, JDistance_t > JTOOLS::JSplineFunction< JElement_t, JCollection_t, typename JResultType< typename JElement_t::ordinate_type >::result_type, 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::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 JNullType argument_type
 
typedef JNullType result_type
 
typedef JFunctional
< argument_type, result_type
functional_type
 
typedef JSupervisor supervisor_type
 

Public Member Functions

void compile (const JSplineBounds< ordinate_type > &bounds)
 Determination of second derivatives with specified bounds. More...
 
virtual result_type evaluate (const argument_type *pX) const =0
 Recursive function value evaluation. More...
 
JSupervisor getSupervisor () const
 Get supervisor. More...
 
const JExceptionHandler & getExceptionHandler () 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 Member Functions

 JSplineCollection ()
 Default constructor. More...
 
virtual void do_compile () override
 Determination of second derivatives with no bounds. More...
 

Protected Attributes

JSupervisor supervisor
 

Detailed Description

template<class JElement_t, template< class, class > class JCollection_t, class JDistance_t>
class JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >

Template base class for spline interpolations.

This class partially implements the JFunctional interface.

Note that the data structure of the elements in the collection should have the additional methods:

    ordinate_type getU() const;
    void setU(ordinate_type u);

to get and set the second derivatives, respectively.

Spline interpolation 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 176 of file JSpline.hh.

Member Typedef Documentation

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
typedef JCollection_t<JElement_t, JDistance_t> JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::collection_type

Definition at line 182 of file JSpline.hh.

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
typedef collection_type::abscissa_type JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::abscissa_type

Definition at line 184 of file JSpline.hh.

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
typedef collection_type::ordinate_type JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::ordinate_type

Definition at line 185 of file JSpline.hh.

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
typedef collection_type::value_type JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::value_type

Definition at line 186 of file JSpline.hh.

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
typedef collection_type::const_iterator JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::const_iterator

Definition at line 188 of file JSpline.hh.

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
typedef collection_type::const_reverse_iterator JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::const_reverse_iterator

Definition at line 189 of file JSpline.hh.

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
typedef collection_type::iterator JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::iterator

Definition at line 190 of file JSpline.hh.

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
typedef collection_type::reverse_iterator JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::reverse_iterator

Definition at line 191 of file JSpline.hh.

Definition at line 84 of file JFunctional.hh.

Definition at line 87 of file JFunctional.hh.

Definition at line 88 of file JFunctional.hh.

typedef JSupervisor JTOOLS::JFunctional< JNullType , JNullType >::supervisor_type
inherited

Definition at line 89 of file JFunctional.hh.

Constructor & Destructor Documentation

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::JSplineCollection ( )
inlineprotected

Default constructor.

Definition at line 296 of file JSpline.hh.

297  {}

Member Function Documentation

template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
void JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::compile ( const JSplineBounds< ordinate_type > &  bounds)
inline

Determination of second derivatives with specified bounds.

Parameters
bounds1st derivatives at two extrema.

Definition at line 201 of file JSpline.hh.

202  {
203  const int numberOfElements = this->size();
204 
205  using namespace std;
206 
207  if (numberOfElements > 2) {
208 
209  std::vector<double> buffer(numberOfElements);
210 
211  if (bounds.hasFirstDerivativeAtXmin()) {
212 
213  iterator j = this->begin();
214  iterator i = j++;
215 
216  const double dx = this->getDistance(i->getX(), j->getX());
217  const ordinate_type dy = (j->getY() - i->getY());
218 
219  buffer[0] = -0.5;
220 
221  i->setU((3.0/dx) * (dy/dx - bounds.getFirstDerivativeAtXmin()));
222 
223  } else {
224 
225  buffer[0] = 0.0;
226 
227  this->begin()->setU(JMATH::zero);
228  }
229 
230  int index = 1;
231 
232  for (iterator k = this->begin(), i = k++, j = k++; k != this->end(); ++i, ++j, ++k, ++index) {
233 
234  const abscissa_type x1 = i->getX();
235  const abscissa_type x2 = j->getX();
236  const abscissa_type x3 = k->getX();
237 
238  const ordinate_type& y1 = i->getY();
239  const ordinate_type& y2 = j->getY();
240  const ordinate_type& y3 = k->getY();
241 
242  const double sig = this->getDistance(x1, x2) / this->getDistance(x1, x3);
243  const double h = sig * buffer[index-1] + 2.0;
244 
245  buffer[index] = (sig - 1.0) / h;
246 
247  j->setU((y3 - y2) / this->getDistance(x2, x3) -
248  (y2 - y1) / this->getDistance(x1, x2));
249 
250  j->setU((6.0 * j->getU() / this->getDistance(x1, x3) - sig * i->getU()) / h);
251  }
252 
253 
254  if (bounds.hasFirstDerivativeAtXmax()) {
255 
256  reverse_iterator j = this->rbegin();
257  reverse_iterator i = j++;
258 
259  index = numberOfElements - 2;
260 
261  const double dx = this->getDistance(i->getX(), j->getX());
262  const ordinate_type dy = (j->getY() - i->getY());
263 
264  i->setU((3.0/dx) * (bounds.getFirstDerivativeAtXmax() - dy/dx));
265 
266  i->setU((i->getU() - 0.5*j->getU()) / (0.5*buffer[index] + 1.0));
267 
268  } else {
269 
270  this->rbegin()->setU(JMATH::zero);
271  }
272 
273 
274  reverse_iterator j = this->rbegin();
275  reverse_iterator i = j++;
276 
277  index = numberOfElements - 2;
278 
279  for ( ; j != this->rend(); ++i, ++j, --index) {
280  j->setU(j->getU() + i->getU() * buffer[index]);
281  }
282 
283  } else {
284 
285  for (iterator i = this->begin(); i != this->end(); ++i) {
286  i->setU(JMATH::zero);
287  }
288  }
289  }
ordinate_type getFirstDerivativeAtXmax() const
Get first derivative of function at maximal abscissa value.
Definition: JSpline.hh:130
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
const bool & hasFirstDerivativeAtXmin() const
Has first derivative of function at minimal abscissa value.
Definition: JSpline.hh:94
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
const bool & hasFirstDerivativeAtXmax() const
Has first derivative of function at maximal abscissa value.
Definition: JSpline.hh:105
collection_type::reverse_iterator reverse_iterator
Definition: JSpline.hh:191
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
ordinate_type getFirstDerivativeAtXmin() const
Get first derivative of function at minimal abscissa value.
Definition: JSpline.hh:116
collection_type::abscissa_type abscissa_type
Definition: JSpline.hh:184
collection_type::ordinate_type ordinate_type
Definition: JSpline.hh:185
int j
Definition: JPolint.hh:792
template<class JElement_t , template< class, class > class JCollection_t, class JDistance_t >
virtual void JTOOLS::JSplineCollection< JElement_t, JCollection_t, JDistance_t >::do_compile ( )
inlineoverrideprotectedvirtual

Determination of second derivatives with no bounds.

Reimplemented in JTOOLS::JSplineFunction< JElement_t, JCollection_t, JResultPDF< typename JResultType< typename JElement_t::ordinate_type >::result_type >, JDistance_t >.

Definition at line 303 of file JSpline.hh.

304  {
306  }
void compile(const JSplineBounds< ordinate_type > &bounds)
Determination of second derivatives with specified bounds.
Definition: JSpline.hh:201
Auxiliary class to define first derivates of the spline function at the two extrema.
Definition: JSpline.hh:36
virtual result_type JTOOLS::JFunctional< JNullType , JNullType >::evaluate ( const argument_type pX) const
pure virtualinherited

Recursive function value evaluation.

Parameters
pXpointer to abscissa values
Returns
function value
static result_type JTOOLS::JFunctional< JNullType , JNullType >::getValue ( const JFunctional<> &  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  }
static JClass<result_type>::argument_type JTOOLS::JFunctional< JNullType , JNullType >::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  }
JSupervisor JTOOLS::JFunctional< JNullType , JNullType >::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
const JExceptionHandler& JTOOLS::JFunctional< JNullType , JNullType >::getExceptionHandler ( ) const
inlineinherited

Get exception handler.

Returns
exception handler

Definition at line 292 of file JFunctional.hh.

293  {
294  return *supervisor;
295  }
JSupervisor supervisor
Definition: JFunctional.hh:310
void JTOOLS::JFunctional< JNullType , JNullType >::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  }
JSupervisor supervisor
Definition: JFunctional.hh:310

Member Data Documentation

JSupervisor JTOOLS::JFunctional< JNullType , JNullType >::supervisor
protectedinherited

Definition at line 310 of file JFunctional.hh.


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