Jpp  18.2.1-ARCA-DF-PATCH
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  try {
379  return this->getExceptionHandler().action();
380  }
381  catch (const JException& error) {
382 
383  std::ostringstream os;
384 
385  os << __FILE__ << ':' << __LINE__ << " abscissa out of range "
386  << STREAM("?") << x << " <> "
387  << STREAM("?") << this->begin() ->getX() << ' '
388  << STREAM("?") << this->rbegin()->getX();
389 
390  throw JValueOutOfRange(os.str());
391  }
392  }
393 
394  const_iterator q = p--;
395 
396  const double dx = this->getDistance(p->getX(), q->getX());
397  const double a = this->getDistance(x, q->getX()) / dx;
398  const double b = 1.0 - a;
399 
400  return (a * p->getY() + b * q->getY()
401  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6);
402 
403  } else if (this->size() == 1u && this->getDistance(x, this->begin()->getX()) <= distance_type::precision) {
404 
405  return this->begin()->getY();
406 
407  } else {
408 
409  try {
410  return this->getExceptionHandler().action();
411  }
412  catch (const JException& error) {
413 
414  std::ostringstream os;
415 
416  os << __FILE__ << ':' << __LINE__ << " not enough data " << STREAM("?") << x;
417 
418  throw JFunctionalException(os.str());
419  }
420  }
421  }
422  };
423 
424 
425  /**
426  * Template specialisation for spline interpolation method with returning JResultDerivative data structure.
427  */
428  template<class JElement_t, template<class, class> class JCollection_t, class JDistance_t>
429  class JSplineFunction<JElement_t,
430  JCollection_t,
431  JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type>,
432  JDistance_t> :
433  public JSplineCollection<JElement_t, JCollection_t, JDistance_t>,
434  public virtual JFunction<typename JElement_t::abscissa_type,
435  JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
436  {
437  public:
438 
440 
441  typedef typename collection_type::abscissa_type abscissa_type;
442  typedef typename collection_type::ordinate_type ordinate_type;
443  typedef typename collection_type::value_type value_type;
444  typedef typename collection_type::distance_type distance_type;
445 
446  typedef typename collection_type::const_iterator const_iterator;
447  typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
448  typedef typename collection_type::iterator iterator;
449  typedef typename collection_type::reverse_iterator reverse_iterator;
450 
453 
457 
459 
460 
461  /**
462  * Default constructor.
463  */
465  {}
466 
467 
468  /**
469  * Recursive interpolation method implementation.
470  *
471  * \param pX pointer to abscissa values
472  * \return function value
473  */
474  virtual result_type evaluate(const argument_type* pX) const override
475  {
476  const argument_type x = *pX;
477 
478  if (this->size() <= 1u) {
479 
480  try {
481  return this->getExceptionHandler().action();
482  }
483  catch (const JException& error) {
484 
485  std::ostringstream os;
486 
487  os << __FILE__ << ':' << __LINE__ << " not enough data " << STREAM("?") << x;
488 
489  throw JFunctionalException(os.str());
490  }
491  }
492 
493  const_iterator p = this->lower_bound(x);
494 
495 
496  if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
497  (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
498 
499  try {
500  return this->getExceptionHandler().action();
501  }
502  catch (const JException& error) {
503 
504  std::ostringstream os;
505 
506  os << __FILE__ << ':' << __LINE__ << " abscissa out of range "
507  << STREAM("?") << x << " <> "
508  << STREAM("?") << this->begin() ->getX() << ' '
509  << STREAM("?") << this->rbegin()->getX();
510 
511  throw JValueOutOfRange(os.str());
512  }
513  }
514 
515  const_iterator q = p--;
516 
517  const double dx = this->getDistance(p->getX(), q->getX());
518  const double a = this->getDistance(x, q->getX()) / dx;
519  const double b = 1.0 - a;
520 
521  result.f = a * p->getY() + b * q->getY()
522  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
523 
524  result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*a) -
525  q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
526 
527  return result;
528  }
529 
530 
531  private:
533  };
534 
535 
536  /**
537  * Template specialisation for spline interpolation method with returning JResultPDF data structure.
538  *
539  * Note that the data structure of the elements in the collection should have the additional methods:
540  * <pre>
541  * ordinate_type getIntegral() const;
542  * void setIntegral(ordinate_type v);
543  * </pre>
544  * to get and set the integral values, respectively.
545  */
546  template<class JElement_t, template<class, class> class JCollection_t, class JDistance_t>
547  class JSplineFunction<JElement_t,
548  JCollection_t,
549  JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type>,
550  JDistance_t> :
551  public JSplineCollection<JElement_t, JCollection_t, JDistance_t>,
552  public virtual JFunction<typename JElement_t::abscissa_type,
553  JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
554  {
555  public:
556 
558 
559  typedef typename collection_type::abscissa_type abscissa_type;
560  typedef typename collection_type::ordinate_type ordinate_type;
561  typedef typename collection_type::value_type value_type;
562  typedef typename collection_type::distance_type distance_type;
563 
564  typedef typename collection_type::const_iterator const_iterator;
565  typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
566  typedef typename collection_type::iterator iterator;
567  typedef typename collection_type::reverse_iterator reverse_iterator;
568 
571 
575 
577 
578 
579  /**
580  * Default constructor.
581  */
583  {}
584 
585 
586  /**
587  * Determination of second derivatives with specified bounds.
588  *
589  * \param bounds 1st derivatives at two extrema.
590  */
592  {
593  if (this->size() >= 2u) {
594 
595  collection_type::compile(bounds);
596 
597  this->begin()->setIntegral(JMATH::zero);
598 
599  for (iterator j = this->begin(), i = j++; j != this->end(); ++i, ++j) {
600 
601  const double dx = this->getDistance(i->getX(), j->getX());
602  const ordinate_type y = i->getY() + j->getY();
603  const ordinate_type z = i->getU() + j->getU();
604 
605  const ordinate_type v = dx * 0.50 * y;
606  const ordinate_type w = dx * 0.25 * z*dx*dx/6;
607 
608  j->setIntegral(i->getIntegral() + v - w);
609  }
610  }
611  }
612 
613 
614  /**
615  * Recursive interpolation method implementation.
616  *
617  * \param pX pointer to abscissa values
618  * \return function value
619  */
620  virtual result_type evaluate(const argument_type* pX) const override
621  {
622  const argument_type x = *pX;
623 
624  if (this->size() <= 1u) {
625 
626  try {
627  return this->getExceptionHandler().action();
628  }
629  catch (const JException& error) {
630 
631  std::ostringstream os;
632 
633  os << __FILE__ << ':' << __LINE__ << " not enough data " << STREAM("?") << x;
634 
635  throw JFunctionalException(os.str());
636  }
637  }
638 
639  const_iterator p = this->lower_bound(x);
640 
641  if (p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) {
642 
643  try {
644 
645  result = this->getExceptionHandler().action();
646 
647  // overwrite integral values
648 
649  result.v = 0;
650  result.V = this->rbegin()->getIntegral();
651 
652  } catch(const JException& error) {
653 
654  std::ostringstream os;
655 
656  os << __FILE__ << ':' << __LINE__ << " abscissa out of range " << STREAM("?") << x << " < " << STREAM("?") << this->begin() ->getX();
657 
658  throw JValueOutOfRange(os.str());
659  }
660 
661  return result;
662 
663  } else if (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision) {
664 
665  try {
666 
667  result = this->getExceptionHandler().action();
668 
669  // overwrite integral values
670 
671  result.v = this->rbegin()->getIntegral();
672  result.V = this->rbegin()->getIntegral();
673 
674  } catch(const JException& error) {
675 
676  std::ostringstream os;
677 
678  os << __FILE__ << ':' << __LINE__ << " abscissa out of range " << STREAM("?") << x << " > " << STREAM("?") << this->rbegin()->getX();
679 
680  throw JValueOutOfRange(os.str());
681  }
682 
683  return result;
684  }
685 
686  const_iterator q = p--;
687 
688  const double dx = this->getDistance(p->getX(), q->getX());
689  const double a = this->getDistance(x, q->getX()) / dx;
690  const double b = 1.0 - a;
691 
692  result.f = a * p->getY() + b * q->getY()
693  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
694 
695  result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*a) -
696  q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
697 
698  result.v = p->getIntegral()
699  + 0.5*dx * (p->getY() - 0.5*p->getU()*dx*dx/6)
700  - 0.5*dx * ((a*a*p->getY() - b*b*q->getY()) +
701  (p->getU() * a*a*(0.5*a*a - 1.0) -
702  q->getU() * b*b*(0.5*b*b - 1.0)) * dx*dx/6);
703 
704  result.V = this->rbegin()->getIntegral();
705 
706  return result;
707  }
708 
709 
710  protected:
711  /**
712  * Determination of second derivatives with no bounds.
713  */
714  virtual void do_compile() override
715  {
717  }
718 
719 
720  private:
722  };
723 
724 
725  /**
726  * Template class for spline interpolation in 1D
727  *
728  * This class implements the JFunction1D interface.
729  */
730  template<class JElement_t,
731  template<class, class> class JCollection_t,
732  class JResult_t = typename JElement_t::ordinate_type,
735  public JSplineFunction<JElement_t, JCollection_t, JResult_t, JDistance_t>,
736  public JFunction1D<typename JElement_t::abscissa_type, JResult_t>
737  {
738  public:
739 
741 
745  typedef typename collection_type::distance_type distance_type;
746 
751 
753 
757 
758 
759  /**
760  * Default contructor.
761  */
763  {}
764  };
765 
766 
767  /**
768  * \cond NEVER
769  * Forward declarations.
770  * \endcond
771  */
772  template<class JAbscissa_t, class JOrdinate_t>
773  struct JSplineElement2D;
774 
775  template<template<class, class, class> class JMap_t>
776  struct JMapCollection;
777 
778 
779  /**
780  * Functional map with spline interpolation.
781  */
782  template<class JKey_t,
783  class JValue_t,
784  template<class, class, class> class JMap_t,
785  class JResult_t,
786  class JDistance_t = JDistance<JKey_t> >
787  class JSplineMap :
788  public JMap_t<JKey_t, JValue_t, JDistance_t>,
789  public JFunction<JKey_t, JResult_t>
790  {
791  public:
792 
793  typedef JMap_t<JKey_t, JValue_t, JDistance_t> collection_type;
795 
800 
805 
808  typedef typename function_type::JExceptionHandler exceptionhandler_type;
809 
814 
815 
816  /**
817  * Default constructor.
818  */
820  {}
821 
822 
823  /**
824  * Recursive interpolation method implementation.
825  *
826  * \param pX pointer to abscissa values
827  * \return function value
828  */
829  virtual result_type evaluate(const argument_type* pX) const override
830  {
831  const argument_type x = *pX;
832 
833  ++pX; // next argument value
834 
835  const_iterator p = this->begin();
836 
837  for (typename JSplineFunction1D_t::iterator q = buffer.begin(); q != buffer.end(); ++q, ++p) {
838  q->getY() = JFunction<argument_type, data_type>::getValue(p->getY(), pX);
839  }
840 
841  buffer.compile();
842 
843  return buffer(x);
844  }
845 
846 
847  private:
848  /**
849  * Function compilation.
850  */
851  virtual void do_compile() override
852  {
853  buffer.clear();
854 
855  for (iterator i = this->begin(); i != this->end(); ++i) {
856  buffer.put(i->getX(), data_type());
857  }
858  }
859 
860 
862  };
863 
864 
865  /**
866  * Conversion of data points to integral values.
867  *
868  * The integration includes the use of 2nd derivatives of the data points of the input spline interpolating function.
869  *
870  * \param input collection
871  * \param output mappable collection
872  * \return integral
873  */
874  template<class JElement_t,
875  template<class, class> class JCollection_t,
876  class JResult_t,
877  class JDistance_t>
878  inline typename JElement_t::ordinate_type
880  typename JMappable<JElement_t>::map_type& output)
881  {
882  typedef typename JElement_t::ordinate_type ordinate_type;
884 
885  ordinate_type V(JMATH::zero);
886 
887  if (input.getSize() > 1) {
888 
889  output.put(input.begin()->getX(), V);
890 
891  for (const_iterator j = input.begin(), i = j++; j != input.end(); ++i, ++j) {
892 
893  const double dx = input.getDistance(i->getX(), j->getX());
894  const ordinate_type y = i->getY() + j->getY();
895  const ordinate_type z = i->getU() + j->getU();
896  const ordinate_type v = dx * 0.50 * y;
897  const ordinate_type w = dx * 0.25 * z*dx*dx/6;
898 
899  V += v - w;
900 
901  output.put(j->getX(), V);
902  }
903  }
904 
905  return V;
906  }
907 
908 
909  /**
910  * Conversion of data points to integral values.
911  *
912  * The integration directly uses the integral values of the input spline interpolating function.
913  *
914  * \param input collection
915  * \param output mappable collection
916  * \return integral
917  */
918  template<class JElement_t,
919  template<class, class> class JCollection_t,
920  class JDistance_t>
921  inline typename JElement_t::ordinate_type
922  integrate(const JSplineFunction1D<JElement_t, JCollection_t, JResultPDF<typename JElement_t::ordinate_type>, JDistance_t>& input,
923  typename JMappable<JElement_t>::map_type& output)
924  {
925  typedef typename JElement_t::ordinate_type ordinate_type;
928 
929  if (input.getSize() > 1) {
930 
931  for (const_iterator i = input.begin(); i != input.end(); ++i) {
932  output.put(i->getX(), i->getIntegral());
933  }
934 
935  return input.rbegin()->getIntegral();
936  }
937 
938  return JMATH::zero;
939  }
940 }
941 
942 #endif
virtual result_type evaluate(const argument_type *pX) const override
Recursive interpolation method implementation.
Definition: JSpline.hh:474
collection_type::const_iterator const_iterator
Definition: JSpline.hh:747
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:808
General exception.
Definition: JException.hh:24
function_type::argument_type argument_type
Definition: JSpline.hh:806
JSplineFunction1D< JSplineElement2D< argument_type, data_type >, JMapCollection< JMap_t >::template collection_type, result_type > JSplineFunction1D_t
Definition: JSpline.hh:813
data_type w[N+1][M+1]
Definition: JPolint.hh:867
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:793
Exception for a functional operation.
Definition: JException.hh:142
JSplineFunction1D()
Default contructor.
Definition: JSpline.hh:762
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:804
Template base class for spline interpolations.
Definition: JSpline.hh:176
functional_type::argument_type argument_type
Definition: JFunctional.hh:338
void compile(const JSplineBounds< ordinate_type > &bounds)
Determination of second derivatives with specified bounds.
Definition: JSpline.hh:591
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:748
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:754
Template definition of function object interface in one dimension.
Definition: JFunctional.hh:332
virtual void do_compile() override
Function compilation.
Definition: JSpline.hh:851
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:620
Template class for spline interpolation in 1D.
Definition: JSpline.hh:734
collection_type::abscissa_type abscissa_type
Definition: JSpline.hh:742
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:794
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:803
function_type::JExceptionHandler exceptionhandler_type
Definition: JSpline.hh:756
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:752
JResultType< ordinate_type >::result_type data_type
Definition: JSpline.hh:810
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:799
function_type::result_type result_type
Definition: JSpline.hh:755
collection_type::value_type value_type
Definition: JSpline.hh:798
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:339
Auxiliary class to evaluate result type.
Definition: JFunctional.hh:392
collection_type::abscissa_type abscissa_type
Definition: JSpline.hh:184
collection_type::const_iterator const_iterator
Definition: JSpline.hh:801
JSplineCollection< JElement_t, JCollection_t, JDistance_t > collection_type
Definition: JSpline.hh:740
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:796
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:318
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:807
JSplineMap()
Default constructor.
Definition: JSpline.hh:819
collection_type::value_type value_type
Definition: JSpline.hh:744
Functional map with spline interpolation.
Definition: JSpline.hh:787
collection_type::ordinate_type ordinate_type
Definition: JSpline.hh:743
functional_type::result_type result_type
Definition: JFunctional.hh:323
collection_type::reverse_iterator reverse_iterator
Definition: JSpline.hh:750
const JExceptionHandler & getExceptionHandler() const
Get exception handler.
Definition: JFunctional.hh:292
Exception for division by zero.
Definition: JException.hh:286
collection_type::ordinate_type ordinate_type
Definition: JSpline.hh:797
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:749
JSplineFunction1D_t buffer
Definition: JSpline.hh:861
int j
Definition: JPolint.hh:792
collection_type::const_reverse_iterator const_reverse_iterator
Definition: JSpline.hh:802
virtual result_type evaluate(const argument_type *pX) const override
Recursive interpolation method implementation.
Definition: JSpline.hh:829
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:322
data_type v[N+1][M+1]
Definition: JPolint.hh:866
double u[N+1]
Definition: JPolint.hh:865
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:745