Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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 JArgument_t argument_type
 
typedef JResult_t result_type
 
typedef JFunctional< argument_type, result_typefunctional_type
 

Public Member Functions

void compile (const JSplineBounds< ordinate_type > &bounds)
 Determination of second derivatives with specified bounds.
 
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.
 

Protected Member Functions

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

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 177 of file JSpline.hh.

Member Typedef Documentation

◆ collection_type

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

Definition at line 183 of file JSpline.hh.

◆ abscissa_type

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

Definition at line 185 of file JSpline.hh.

◆ ordinate_type

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

Definition at line 186 of file JSpline.hh.

◆ value_type

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

Definition at line 187 of file JSpline.hh.

◆ const_iterator

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

Definition at line 189 of file JSpline.hh.

◆ const_reverse_iterator

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

Definition at line 190 of file JSpline.hh.

◆ iterator

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

Definition at line 191 of file JSpline.hh.

◆ reverse_iterator

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

Definition at line 192 of file JSpline.hh.

◆ argument_type

JArgument_t JTOOLS::JFunctional< JArgument_t, JResult_t >::argument_type
inherited

Definition at line 83 of file JFunctional.hh.

◆ result_type

JResult_t JTOOLS::JFunctional< JArgument_t, JResult_t >::result_type
inherited

Definition at line 84 of file JFunctional.hh.

◆ functional_type

JFunctional<argument_type, result_type> JTOOLS::JFunctional< JArgument_t, JResult_t >::functional_type
inherited

Definition at line 85 of file JFunctional.hh.

Constructor & Destructor Documentation

◆ JSplineCollection()

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 297 of file JSpline.hh.

298 {}

Member Function Documentation

◆ compile()

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 202 of file JSpline.hh.

203 {
204 const int numberOfElements = this->size();
205
206 using namespace std;
207
208 if (numberOfElements > 2) {
209
210 std::vector<double> buffer(numberOfElements);
211
212 if (bounds.hasFirstDerivativeAtXmin()) {
213
214 iterator j = this->begin();
215 iterator i = j++;
216
217 const double dx = this->getDistance(i->getX(), j->getX());
218 const ordinate_type dy = (j->getY() - i->getY());
219
220 buffer[0] = -0.5;
221
222 i->setU((3.0/dx) * (dy/dx - bounds.getFirstDerivativeAtXmin()));
223
224 } else {
225
226 buffer[0] = 0.0;
227
228 this->begin()->setU(JMATH::zero);
229 }
230
231 int index = 1;
232
233 for (iterator k = this->begin(), i = k++, j = k++; k != this->end(); ++i, ++j, ++k, ++index) {
234
235 const abscissa_type x1 = i->getX();
236 const abscissa_type x2 = j->getX();
237 const abscissa_type x3 = k->getX();
238
239 const ordinate_type& y1 = i->getY();
240 const ordinate_type& y2 = j->getY();
241 const ordinate_type& y3 = k->getY();
242
243 const double sig = this->getDistance(x1, x2) / this->getDistance(x1, x3);
244 const double h = sig * buffer[index-1] + 2.0;
245
246 buffer[index] = (sig - 1.0) / h;
247
248 j->setU((y3 - y2) / this->getDistance(x2, x3) -
249 (y2 - y1) / this->getDistance(x1, x2));
250
251 j->setU((6.0 * j->getU() / this->getDistance(x1, x3) - sig * i->getU()) / h);
252 }
253
254
255 if (bounds.hasFirstDerivativeAtXmax()) {
256
257 reverse_iterator j = this->rbegin();
258 reverse_iterator i = j++;
259
260 index = numberOfElements - 2;
261
262 const double dx = this->getDistance(i->getX(), j->getX());
263 const ordinate_type dy = (j->getY() - i->getY());
264
265 i->setU((3.0/dx) * (bounds.getFirstDerivativeAtXmax() - dy/dx));
266
267 i->setU((i->getU() - 0.5*j->getU()) / (0.5*buffer[index] + 1.0));
268
269 } else {
270
271 this->rbegin()->setU(JMATH::zero);
272 }
273
274
275 reverse_iterator j = this->rbegin();
276 reverse_iterator i = j++;
277
278 index = numberOfElements - 2;
279
280 for ( ; j != this->rend(); ++i, ++j, --index) {
281 j->setU(j->getU() + i->getU() * buffer[index]);
282 }
283
284 } else {
285
286 for (iterator i = this->begin(); i != this->end(); ++i) {
287 i->setU(JMATH::zero);
288 }
289 }
290 }
collection_type::ordinate_type ordinate_type
Definition JSpline.hh:186
collection_type::abscissa_type abscissa_type
Definition JSpline.hh:185
collection_type::reverse_iterator reverse_iterator
Definition JSpline.hh:192
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
int j
Definition JPolint.hh:801

◆ do_compile()

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 304 of file JSpline.hh.

305 {
306 compile(JSplineBounds<ordinate_type>());
307 }
void compile(const JSplineBounds< ordinate_type > &bounds)
Determination of second derivatives with specified bounds.
Definition JSpline.hh:202

◆ evaluate()

◆ getValue() [1/2]

static result_type JTOOLS::JFunctional< JArgument_t, JResult_t >::getValue ( const JFunctional<> & 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< 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 117 of file JFunctional.hh.

119 {
120 return value;
121 }

◆ getExceptionHandler()

virtual const JExceptionHandler & JTOOLS::JFunctional< JArgument_t, JResult_t >::getExceptionHandler ( ) const
pure virtualinherited

Get exception handler.

Returns
exception handler

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