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