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