Jpp  15.0.1-rc.2-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSpline.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JSPLINE__
2 #define __JTOOLS__JSPLINE__
3 
4 #include <utility>
5 
6 #include "JMath/JZero.hh"
7 #include "JLang/JException.hh"
8 #include "JLang/JClass.hh"
9 #include "JTools/JFunctional.hh"
10 #include "JTools/JDistance.hh"
11 #include "JTools/JResult.hh"
12 #include "JTools/JMapCollection.hh"
13 
14 
15 /**
16  * \author mdejong
17  */
18 
19 namespace JTOOLS {}
20 namespace JPP { using namespace JTOOLS; }
21 
22 namespace JTOOLS {
23 
24  using JLANG::JNoValue;
28 
29 
30  /**
31  * Auxiliary class to define first derivates of the spline function at the two extrema.
32  */
33  template<class JOrdinate_t>
34  class JSplineBounds {
35  public:
36 
37  typedef JOrdinate_t ordinate_type;
39 
40 
41  /**
42  * Default constructor.
43  */
45  fp_at_xmin(false, ordinate_type()),
46  fp_at_xmax(false, ordinate_type())
47  {}
48 
49 
50  /**
51  * Constructor.
52  *
53  * \param fpAtXmin 1st derivative at minimal abscissa value
54  * \param fpAtXmax 1st derivative at maximal abscissa value
55  */
57  argument_type fpAtXmax) :
58  fp_at_xmin(true, fpAtXmin),
59  fp_at_xmax(true, fpAtXmax)
60  {}
61 
62 
63  /**
64  * Set first derivative of function at minimal abscissa value.
65  *
66  * \param fp 1st derivative
67  */
69  {
70  fp_at_xmin.first = true;
71  fp_at_xmin.second = fp;
72  }
73 
74 
75  /**
76  * Set first derivative of function at maximal abscissa value.
77  *
78  * \param fp 1st derivative
79  */
81  {
82  fp_at_xmax.first = true;
83  fp_at_xmax.second = fp;
84  }
85 
86 
87  /**
88  * Has first derivative of function at minimal abscissa value.
89  *
90  * \return true if 1st derivative is set; else false
91  */
92  const bool& hasFirstDerivativeAtXmin() const
93  {
94  return fp_at_xmin.first;
95  }
96 
97 
98  /**
99  * Has first derivative of function at maximal abscissa value.
100  *
101  * \return true if 1st derivative is set; else false
102  */
103  const bool& hasFirstDerivativeAtXmax() const
104  {
105  return fp_at_xmax.first;
106  }
107 
108 
109  /**
110  * Get first derivative of function at minimal abscissa value.
111  *
112  * \return 1st derivative
113  */
115  {
116  if (fp_at_xmin.first)
117  return fp_at_xmin.second;
118  else
119  throw JNoValue("JSplineBounds: missing 1st derivative.");
120  }
121 
122 
123  /**
124  * Get first derivative of function at maximal abscissa value.
125  *
126  * \return 1st derivative
127  */
129  {
130  if (fp_at_xmax.first)
131  return fp_at_xmax.second;
132  else
133  throw JNoValue("JSplineBounds: missing 1st derivative.");
134  }
135 
136  protected:
139  };
140 
141 
142  /**
143  * Helper method for JSplineBounds.
144  *
145  * \param fpAtXmin 1st derivative at minimal abscissa value
146  * \param fpAtXmax 1st derivative at maximal abscissa value
147  * \return spline bounds
148  */
149  template<class JOrdinate_t>
150  inline JSplineBounds<JOrdinate_t> make_spline_bounds(const JOrdinate_t fpAtXmin,
151  const JOrdinate_t fpAtXmax)
152  {
153  return JSplineBounds<JOrdinate_t>(fpAtXmin, fpAtXmax);
154  }
155 
156 
157  /**
158  * Template base class for spline interpolations.
159  *
160  * This class partially implements the JFunctional interface.
161  *
162  * Note that the data structure of the elements in the collection should have the additional methods:
163  * <pre>
164  * ordinate_type getU() const;
165  * void setU(ordinate_type u);
166  * </pre>
167  * to get and set the second derivatives, respectively.
168  *
169  * Spline interpolation code is taken from reference:
170  * Numerical Recipes in C++, W.H. Press, S.A. Teukolsky, W.T. Vetterling and B.P. Flannery,
171  * Cambridge University Press.
172  */
173  template<class JElement_t, template<class, class> class JCollection_t, class JDistance_t>
175  public JCollection_t<JElement_t, JDistance_t>,
176  public virtual JFunctional<>
177  {
178  public:
179 
180  typedef JCollection_t<JElement_t, JDistance_t> collection_type;
181 
182  typedef typename collection_type::abscissa_type abscissa_type;
183  typedef typename collection_type::ordinate_type ordinate_type;
184  typedef typename collection_type::value_type value_type;
185 
186  typedef typename collection_type::const_iterator const_iterator;
187  typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
188  typedef typename collection_type::iterator iterator;
189  typedef typename collection_type::reverse_iterator reverse_iterator;
190 
192 
193 
194  /**
195  * Determination of second derivatives with specified bounds.
196  *
197  * \param bounds 1st derivatives at two extrema.
198  */
200  {
201  const int numberOfElements = this->size();
202 
203  using namespace std;
204 
205  if (numberOfElements > 2) {
206 
207  std::vector<double> buffer(numberOfElements);
208 
209  if (bounds.hasFirstDerivativeAtXmin()) {
210 
211  iterator j = this->begin();
212  iterator i = j++;
213 
214  const double dx = this->getDistance(i->getX(), j->getX());
215  const ordinate_type dy = (j->getY() - i->getY());
216 
217  buffer[0] = -0.5;
218 
219  i->setU((3.0/dx) * (dy/dx - bounds.getFirstDerivativeAtXmin()));
220 
221  } else {
222 
223  buffer[0] = 0.0;
224 
225  this->begin()->setU(JMATH::zero);
226  }
227 
228  int index = 1;
229 
230  for (iterator k = this->begin(), i = k++, j = k++; k != this->end(); ++i, ++j, ++k, ++index) {
231 
232  const abscissa_type x1 = i->getX();
233  const abscissa_type x2 = j->getX();
234  const abscissa_type x3 = k->getX();
235 
236  const ordinate_type& y1 = i->getY();
237  const ordinate_type& y2 = j->getY();
238  const ordinate_type& y3 = k->getY();
239 
240  const double sig = this->getDistance(x1, x2) / this->getDistance(x1, x3);
241  const double h = sig * buffer[index-1] + 2.0;
242 
243  buffer[index] = (sig - 1.0) / h;
244 
245  j->setU((y3 - y2) / this->getDistance(x2, x3) -
246  (y2 - y1) / this->getDistance(x1, x2));
247 
248  j->setU((6.0 * j->getU() / this->getDistance(x1, x3) - sig * i->getU()) / h);
249  }
250 
251 
252  if (bounds.hasFirstDerivativeAtXmax()) {
253 
254  reverse_iterator j = this->rbegin();
255  reverse_iterator i = j++;
256 
257  index = numberOfElements - 2;
258 
259  const double dx = this->getDistance(i->getX(), j->getX());
260  const ordinate_type dy = (j->getY() - i->getY());
261 
262  i->setU((3.0/dx) * (bounds.getFirstDerivativeAtXmax() - dy/dx));
263 
264  i->setU((i->getU() - 0.5*j->getU()) / (0.5*buffer[index] + 1.0));
265 
266  } else {
267 
268  this->rbegin()->setU(JMATH::zero);
269  }
270 
271 
272  reverse_iterator j = this->rbegin();
273  reverse_iterator i = j++;
274 
275  index = numberOfElements - 2;
276 
277  for ( ; j != this->rend(); ++i, ++j, --index) {
278  j->setU(j->getU() + i->getU() * buffer[index]);
279  }
280 
281  } else {
282 
283  for (iterator i = this->begin(); i != this->end(); ++i) {
284  i->setU(JMATH::zero);
285  }
286  }
287  }
288 
289 
290  protected:
291  /**
292  * Default constructor.
293  */
295  {}
296 
297 
298  /**
299  * Determination of second derivatives with no bounds.
300  */
301  virtual void do_compile() override
302  {
304  }
305  };
306 
307 
308  /**
309  * Template definition for functional collection with spline interpolation.
310  */
311  template<class JElement_t,
312  template<class, class> class JCollection_t,
313  class JResult_t,
314  class JDistance_t>
316 
317 
318  /**
319  * Template specialisation for functional collection with spline interpolation.
320  */
321  template<class JElement_t, template<class, class> class JCollection_t, class JDistance_t>
322  class JSplineFunction<JElement_t,
323  JCollection_t,
324  typename JResultType<typename JElement_t::ordinate_type>::result_type,
325  JDistance_t> :
326  public JSplineCollection<JElement_t, JCollection_t, JDistance_t>,
327  public JFunction<typename JElement_t::abscissa_type,
328  typename JResultType<typename JElement_t::ordinate_type>::result_type>
329  {
330  public:
331 
333 
334  typedef typename collection_type::abscissa_type abscissa_type;
335  typedef typename collection_type::ordinate_type ordinate_type;
336  typedef typename collection_type::value_type value_type;
337  typedef typename collection_type::distance_type distance_type;
338 
339  typedef typename collection_type::const_iterator const_iterator;
340  typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
341  typedef typename collection_type::iterator iterator;
342  typedef typename collection_type::reverse_iterator reverse_iterator;
343 
346 
350 
351 
352  /**
353  * Default constructor.
354  */
356  {}
357 
358 
359  /**
360  * Recursive interpolation method implementation.
361  *
362  * \param pX pointer to abscissa values
363  * \return function value
364  */
365  virtual result_type evaluate(const argument_type* pX) const override
366  {
367  if (this->size() <= 1u) {
368  return this->getExceptionHandler().action(JFunctionalException("JSplineFunction<>::evaluate() not enough data."));
369  }
370 
371  const argument_type x = *pX;
372 
373  const_iterator p = this->lower_bound(x);
374 
375  if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
376  (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
377 
378  return this->getExceptionHandler().action(JValueOutOfRange("JSplineFunction::evaluate() x out of range."));
379  }
380 
381  const_iterator q = p--;
382 
383  const double dx = this->getDistance(p->getX(), q->getX());
384  const double a = this->getDistance(x, q->getX()) / dx;
385  const double b = 1.0 - a;
386 
387  return a * p->getY() + b * q->getY()
388  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
389  }
390  };
391 
392 
393  /**
394  * Template specialisation for spline interpolation method with returning JResultDerivative data structure.
395  */
396  template<class JElement_t, template<class, class> class JCollection_t, class JDistance_t>
397  class JSplineFunction<JElement_t,
398  JCollection_t,
399  JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type>,
400  JDistance_t> :
401  public JSplineCollection<JElement_t, JCollection_t, JDistance_t>,
402  public JFunction<typename JElement_t::abscissa_type,
403  JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
404  {
405  public:
406 
408 
409  typedef typename collection_type::abscissa_type abscissa_type;
410  typedef typename collection_type::ordinate_type ordinate_type;
411  typedef typename collection_type::value_type value_type;
412  typedef typename collection_type::distance_type distance_type;
413 
414  typedef typename collection_type::const_iterator const_iterator;
415  typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
416  typedef typename collection_type::iterator iterator;
417  typedef typename collection_type::reverse_iterator reverse_iterator;
418 
421 
425 
427 
428 
429  /**
430  * Default constructor.
431  */
433  {}
434 
435 
436  /**
437  * Recursive interpolation method implementation.
438  *
439  * \param pX pointer to abscissa values
440  * \return function value
441  */
442  virtual result_type evaluate(const argument_type* pX) const override
443  {
444  if (this->size() <= 1u) {
445  return this->getExceptionHandler().action(JFunctionalException("JSplineFunction<>::evaluate() not enough data."));
446  }
447 
448  const argument_type x = *pX;
449 
450  const_iterator p = this->lower_bound(x);
451 
452 
453  if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
454  (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
455 
456  return this->getExceptionHandler().action(JValueOutOfRange("JSplineFunction::evaluate() x out of range."));
457  }
458 
459  const_iterator q = p--;
460 
461  const double dx = this->getDistance(p->getX(), q->getX());
462  const double a = this->getDistance(x, q->getX()) / dx;
463  const double b = 1.0 - a;
464 
465  result.f = a * p->getY() + b * q->getY()
466  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
467 
468  result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*a) -
469  q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
470 
471  return result;
472  }
473 
474 
475  private:
477  };
478 
479 
480  /**
481  * Template specialisation for spline interpolation method with returning JResultPDF data structure.
482  *
483  * Note that the data structure of the elements in the collection should have the additional methods:
484  * <pre>
485  * ordinate_type getIntegral() const;
486  * void setIntegral(ordinate_type v);
487  * </pre>
488  * to get and set the integral values, respectively.
489  */
490  template<class JElement_t, template<class, class> class JCollection_t, class JDistance_t>
491  class JSplineFunction<JElement_t,
492  JCollection_t,
493  JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type>,
494  JDistance_t> :
495  public JSplineCollection<JElement_t, JCollection_t, JDistance_t>,
496  public JFunction<typename JElement_t::abscissa_type,
497  JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
498  {
499  public:
500 
502 
503  typedef typename collection_type::abscissa_type abscissa_type;
504  typedef typename collection_type::ordinate_type ordinate_type;
505  typedef typename collection_type::value_type value_type;
506  typedef typename collection_type::distance_type distance_type;
507 
508  typedef typename collection_type::const_iterator const_iterator;
509  typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
510  typedef typename collection_type::iterator iterator;
511  typedef typename collection_type::reverse_iterator reverse_iterator;
512 
515 
519 
521 
522 
523  /**
524  * Default constructor.
525  */
527  {}
528 
529 
530  /**
531  * Determination of second derivatives with specified bounds.
532  *
533  * \param bounds 1st derivatives at two extrema.
534  */
536  {
537  if (this->size() >= 2u) {
538 
539  collection_type::compile(bounds);
540 
541  this->begin()->setIntegral(JMATH::zero);
542 
543  for (iterator j = this->begin(), i = j++; j != this->end(); ++i, ++j) {
544 
545  const double dx = this->getDistance(i->getX(), j->getX());
546  const ordinate_type y = i->getY() + j->getY();
547  const ordinate_type z = i->getU() + j->getU();
548 
549  const ordinate_type v = dx * 0.50 * y;
550  const ordinate_type w = dx * 0.25 * z*dx*dx/6;
551 
552  j->setIntegral(i->getIntegral() + v - w);
553  }
554  }
555  }
556 
557 
558  /**
559  * Recursive interpolation method implementation.
560  *
561  * \param pX pointer to abscissa values
562  * \return function value
563  */
564  virtual result_type evaluate(const argument_type* pX) const override
565  {
566  if (this->size() <= 1u) {
567  return this->getExceptionHandler().action(JFunctionalException("JSplineFunction<>::evaluate() not enough data."));
568  }
569 
570  const argument_type x = *pX;
571 
572  const_iterator p = this->lower_bound(x);
573 
574  if (p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) {
575 
576  try {
577 
578  result = this->getExceptionHandler().action(JValueOutOfRange("JSplineFunction<>::operator() x < xmin."));
579 
580  // overwrite integral values
581 
582  result.v = 0;
583  result.V = this->rbegin()->getIntegral();
584 
585  } catch(const JValueOutOfRange& exception) {
586  throw exception;
587  }
588 
589  return result;
590 
591  } else if (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision) {
592 
593  try {
594 
595  result = this->getExceptionHandler().action(JValueOutOfRange("JSplineFunction<>::operator() x > xmax."));
596 
597  // overwrite integral values
598 
599  result.v = this->rbegin()->getIntegral();
600  result.V = this->rbegin()->getIntegral();
601 
602  } catch(const JValueOutOfRange& exception) {
603  throw exception;
604  }
605 
606  return result;
607  }
608 
609  const_iterator q = p--;
610 
611  const double dx = this->getDistance(p->getX(), q->getX());
612  const double a = this->getDistance(x, q->getX()) / dx;
613  const double b = 1.0 - a;
614 
615  result.f = a * p->getY() + b * q->getY()
616  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
617 
618  result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*a) -
619  q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
620 
621  result.v = p->getIntegral()
622  + 0.5*dx * (p->getY() - 0.5*p->getU()*dx*dx/6)
623  - 0.5*dx * ((a*a*p->getY() - b*b*q->getY()) +
624  (p->getU() * a*a*(0.5*a*a - 1.0) -
625  q->getU() * b*b*(0.5*b*b - 1.0)) * dx*dx/6);
626 
627  result.V = this->rbegin()->getIntegral();
628 
629  return result;
630  }
631 
632 
633  protected:
634  /**
635  * Determination of second derivatives with no bounds.
636  */
637  virtual void do_compile() override
638  {
640  }
641 
642 
643  private:
645  };
646 
647 
648  /**
649  * Template class for spline interpolation in 1D
650  *
651  * This class implements the JFunction1D interface.
652  */
653  template<class JElement_t,
654  template<class, class> class JCollection_t,
655  class JResult_t = typename JElement_t::ordinate_type,
658  public JSplineFunction<JElement_t, JCollection_t, JResult_t, JDistance_t>,
659  public JFunction1D<typename JElement_t::abscissa_type, JResult_t>
660  {
661  public:
662 
664 
668  typedef typename collection_type::distance_type distance_type;
669 
674 
676 
680 
681 
682  /**
683  * Default contructor.
684  */
686  {}
687  };
688 
689 
690  /**
691  * \cond NEVER
692  * Forward declarations.
693  * \endcond
694  */
695  template<class JAbscissa_t, class JOrdinate_t>
696  struct JSplineElement2D;
697 
698  template<template<class, class, class> class JMap_t>
699  struct JMapCollection;
700 
701 
702  /**
703  * Functional map with spline interpolation.
704  */
705  template<class JKey_t,
706  class JValue_t,
707  template<class, class, class> class JMap_t,
708  class JResult_t,
709  class JDistance_t = JDistance<JKey_t> >
710  class JSplineMap :
711  public JMap_t<JKey_t, JValue_t, JDistance_t>,
712  public JFunction<JKey_t, JResult_t>
713  {
714  public:
715 
716  typedef JMap_t<JKey_t, JValue_t, JDistance_t> collection_type;
718 
723 
728 
731  typedef typename function_type::JExceptionHandler exceptionhandler_type;
732 
737 
738 
739  /**
740  * Default constructor.
741  */
743  {}
744 
745 
746  /**
747  * Recursive interpolation method implementation.
748  *
749  * \param pX pointer to abscissa values
750  * \return function value
751  */
752  virtual result_type evaluate(const argument_type* pX) const override
753  {
754  const argument_type x = *pX;
755 
756  ++pX; // next argument value
757 
758  const_iterator p = this->begin();
759 
760  for (typename JSplineFunction1D_t::iterator q = buffer.begin(); q != buffer.end(); ++q, ++p) {
761  q->getY() = JFunction<argument_type, data_type>::getValue(p->getY(), pX);
762  }
763 
764  buffer.compile();
765 
766  return buffer(x);
767  }
768 
769 
770  private:
771  /**
772  * Function compilation.
773  */
774  virtual void do_compile() override
775  {
776  buffer.clear();
777 
778  for (iterator i = this->begin(); i != this->end(); ++i) {
779  buffer.put(i->getX(), data_type());
780  }
781  }
782 
783 
785  };
786 
787 
788  /**
789  * Conversion of data points to integral values.
790  *
791  * The integration includes the use of 2nd derivatives of the data points of the input spline interpolating function.
792  *
793  * \param input collection
794  * \param output mappable collection
795  * \return integral
796  */
797  template<class JElement_t,
798  template<class, class> class JCollection_t,
799  class JResult_t,
800  class JDistance_t>
801  inline typename JElement_t::ordinate_type
803  typename JMappable<JElement_t>::map_type& output)
804  {
805  typedef typename JElement_t::ordinate_type ordinate_type;
807 
808  ordinate_type V(JMATH::zero);
809 
810  if (input.getSize() > 1) {
811 
812  output.put(input.begin()->getX(), V);
813 
814  for (const_iterator j = input.begin(), i = j++; j != input.end(); ++i, ++j) {
815 
816  const double dx = input.getDistance(i->getX(), j->getX());
817  const ordinate_type y = i->getY() + j->getY();
818  const ordinate_type z = i->getU() + j->getU();
819  const ordinate_type v = dx * 0.50 * y;
820  const ordinate_type w = dx * 0.25 * z*dx*dx/6;
821 
822  V += v - w;
823 
824  output.put(j->getX(), V);
825  }
826  }
827 
828  return V;
829  }
830 
831 
832  /**
833  * Conversion of data points to integral values.
834  *
835  * The integration directly uses the integral values of the input spline interpolating function.
836  *
837  * \param input collection
838  * \param output mappable collection
839  * \return integral
840  */
841  template<class JElement_t,
842  template<class, class> class JCollection_t,
843  class JDistance_t>
844  inline typename JElement_t::ordinate_type
845  integrate(const JSplineFunction1D<JElement_t, JCollection_t, JResultPDF<typename JElement_t::ordinate_type>, JDistance_t>& input,
846  typename JMappable<JElement_t>::map_type& output)
847  {
848  typedef typename JElement_t::ordinate_type ordinate_type;
851 
852  if (input.getSize() > 1) {
853 
854  for (const_iterator i = input.begin(); i != input.end(); ++i) {
855  output.put(i->getX(), i->getIntegral());
856  }
857 
858  return input.rbegin()->getIntegral();
859  }
860 
861  return JMATH::zero;
862  }
863 }
864 
865 #endif
virtual result_type evaluate(const argument_type *pX) const override
Recursive interpolation method implementation.
Definition: JSpline.hh:442
collection_type::const_iterator const_iterator
Definition: JSpline.hh:670
ordinate_type getFirstDerivativeAtXmax() const
Get first derivative of function at maximal abscissa value.
Definition: JSpline.hh:128
function_type::JExceptionHandler exceptionhandler_type
Definition: JSpline.hh:731
function_type::argument_type argument_type
Definition: JSpline.hh:729
JSplineFunction1D< JSplineElement2D< argument_type, data_type >, JMapCollection< JMap_t >::template collection_type, result_type > JSplineFunction1D_t
Definition: JSpline.hh:736
data_type w[N+1][M+1]
Definition: JPolint.hh:741
Exceptions.
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
JMap_t< JKey_t, JValue_t, JDistance_t > collection_type
Definition: JSpline.hh:716
Exception for a functional operation.
Definition: JException.hh:126
JSplineFunction1D()
Default contructor.
Definition: JSpline.hh:685
const bool & hasFirstDerivativeAtXmin() const
Has first derivative of function at minimal abscissa value.
Definition: JSpline.hh:92
void setFirstDerivativeAtXmin(argument_type fp)
Set first derivative of function at minimal abscissa value.
Definition: JSpline.hh:68
Template class for distance evaluation.
Definition: JDistance.hh:24
JSplineBounds()
Default constructor.
Definition: JSpline.hh:44
This include file containes various data structures that can be used as specific return types for the...
collection_type::reverse_iterator reverse_iterator
Definition: JSpline.hh:727
Template base class for spline interpolations.
Definition: JSpline.hh:174
functional_type::argument_type argument_type
Definition: JFunctional.hh:323
void compile(const JSplineBounds< ordinate_type > &bounds)
Determination of second derivatives with specified bounds.
Definition: JSpline.hh:535
Template interface definition for associative collection of elements.
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:103
collection_type::const_reverse_iterator const_reverse_iterator
Definition: JSpline.hh:671
Definition of zero value for any class.
JCollection_t< JElement_t, JDistance_t > collection_type
Definition: JSpline.hh:180
virtual result_type evaluate(const argument_type *pX) const override
Recursive interpolation method implementation.
Definition: JSpline.hh:365
function_type::argument_type argument_type
Definition: JSpline.hh:677
Template definition of function object interface in one dimension.
Definition: JFunctional.hh:317
virtual void do_compile() override
Function compilation.
Definition: JSpline.hh:774
collection_type::reverse_iterator reverse_iterator
Definition: JSpline.hh:189
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
std::pair< bool, ordinate_type > fp_at_xmax
Definition: JSpline.hh:138
virtual result_type evaluate(const argument_type *pX) const override
Recursive interpolation method implementation.
Definition: JSpline.hh:564
Template class for spline interpolation in 1D.
Definition: JSpline.hh:657
collection_type::abscissa_type abscissa_type
Definition: JSpline.hh:665
collection_type::iterator iterator
Definition: JSpline.hh:188
Exception for missing value.
Definition: JException.hh:198
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
JFunction< JKey_t, JResult_t > function_type
Definition: JSpline.hh:717
static result_type getValue(const JFunctional &function, const argument_type *pX)
Recursive function value evaluation.
Definition: JFunctional.hh:107
collection_type::iterator iterator
Definition: JSpline.hh:726
function_type::JExceptionHandler exceptionhandler_type
Definition: JSpline.hh:679
collection_type::const_iterator const_iterator
Definition: JSpline.hh:186
ordinate_type getFirstDerivativeAtXmin() const
Get first derivative of function at minimal abscissa value.
Definition: JSpline.hh:114
JLANG::JClass< ordinate_type >::argument_type argument_type
Definition: JSpline.hh:38
JFunction1D< abscissa_type, JResult_t > function_type
Definition: JSpline.hh:675
JResultType< ordinate_type >::result_type data_type
Definition: JSpline.hh:733
collection_type::iterator iterator
Definition: JGridMap.hh:43
Data structure for result including value, first derivative and integrals of function.
Definition: JResult.hh:337
Template definition of function object interface.
Definition: JFunctional.hh:32
return result
Definition: JPolint.hh:727
collection_type::distance_type distance_type
Definition: JSpline.hh:722
function_type::result_type result_type
Definition: JSpline.hh:678
collection_type::value_type value_type
Definition: JSpline.hh:721
JSplineBounds< JOrdinate_t > make_spline_bounds(const JOrdinate_t fpAtXmin, const JOrdinate_t fpAtXmax)
Helper method for JSplineBounds.
Definition: JSpline.hh:150
functional_type::result_type result_type
Definition: JFunctional.hh:324
Auxiliary class to evaluate result type.
Definition: JFunctional.hh:377
collection_type::abscissa_type abscissa_type
Definition: JSpline.hh:182
collection_type::const_iterator const_iterator
Definition: JSpline.hh:724
JSplineCollection< JElement_t, JCollection_t, JDistance_t > collection_type
Definition: JSpline.hh:663
void put(typename JClass< key_type >::argument_type key, typename JClass< mapped_type >::argument_type value)
Put pair-wise element (key,value) into collection.
Template class to define the corresponding JCollection for a given template JMap. ...
Data structure for result including value and first derivative of function.
Definition: JResult.hh:43
collection_type::abscissa_type abscissa_type
Definition: JSpline.hh:719
Exception handler for functional object.
Definition: JFunctional.hh:131
JSplineBounds(argument_type fpAtXmin, argument_type fpAtXmax)
Constructor.
Definition: JSpline.hh:56
Template definition of function object interface in multidimensions.
Definition: JFunctional.hh:303
void compile(const JSplineBounds< ordinate_type > &bounds)
Determination of second derivatives with specified bounds.
Definition: JSpline.hh:199
function_type::result_type result_type
Definition: JSpline.hh:730
JSplineMap()
Default constructor.
Definition: JSpline.hh:742
collection_type::value_type value_type
Definition: JSpline.hh:667
Functional map with spline interpolation.
Definition: JSpline.hh:710
collection_type::ordinate_type ordinate_type
Definition: JSpline.hh:666
functional_type::result_type result_type
Definition: JFunctional.hh:308
collection_type::reverse_iterator reverse_iterator
Definition: JSpline.hh:673
const JExceptionHandler & getExceptionHandler() const
Get exception handler.
Definition: JFunctional.hh:277
Exception for division by zero.
Definition: JException.hh:270
then JCalibrateToT a
Definition: JTuneHV.sh:116
collection_type::ordinate_type ordinate_type
Definition: JSpline.hh:720
collection_type::const_iterator const_iterator
Definition: JGridMap.hh:41
2D Element for spline interpolations.
Definition: JElement.hh:153
void setFirstDerivativeAtXmax(argument_type fp)
Set first derivative of function at maximal abscissa value.
Definition: JSpline.hh:80
2D Element.
Definition: JElement.hh:46
collection_type::const_reverse_iterator const_reverse_iterator
Definition: JSpline.hh:187
collection_type::ordinate_type ordinate_type
Definition: JSpline.hh:183
collection_type::iterator iterator
Definition: JSpline.hh:672
JSplineFunction1D_t buffer
Definition: JSpline.hh:784
int j
Definition: JPolint.hh:666
collection_type::const_reverse_iterator const_reverse_iterator
Definition: JSpline.hh:725
virtual result_type evaluate(const argument_type *pX) const override
Recursive interpolation method implementation.
Definition: JSpline.hh:752
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
functional_type::argument_type argument_type
Definition: JFunctional.hh:307
data_type v[N+1][M+1]
Definition: JPolint.hh:740
double u[N+1]
Definition: JPolint.hh:739
JOrdinate_t ordinate_type
Definition: JSpline.hh:37
std::pair< bool, ordinate_type > fp_at_xmin
Definition: JSpline.hh:137
JSplineCollection()
Default constructor.
Definition: JSpline.hh:294
collection_type::value_type value_type
Definition: JSpline.hh:184
Template definition for functional collection with spline interpolation.
Definition: JSpline.hh:315
Auxiliary class to define first derivates of the spline function at the two extrema.
Definition: JSpline.hh:34
JElement_t::ordinate_type integrate(const JCollection< JElement_t, JDistance_t > &input, typename JMappable< JElement_t >::map_type &output)
Conversion of data points to integral values.
Definition: JCollection.hh:813
virtual void do_compile() override
Determination of second derivatives with no bounds.
Definition: JSpline.hh:301
collection_type::distance_type distance_type
Definition: JSpline.hh:668