Jpp  test_elongated_shower_pde
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 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  if (this->size() <= 1u) {
369  return this->getExceptionHandler().action(JFunctionalException("JSplineFunction<>::evaluate() not enough data."));
370  }
371 
372  const argument_type x = *pX;
373 
374  const_iterator p = this->lower_bound(x);
375 
376  if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
377  (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
378 
379  return this->getExceptionHandler().action(MAKE_EXCEPTION(JValueOutOfRange, "abscissa out of range "
380  << STREAM("?") << x << " <> "
381  << STREAM("?") << this->begin() ->getX() << ' '
382  << STREAM("?") << this->rbegin()->getX()));
383  }
384 
385  const_iterator q = p--;
386 
387  const double dx = this->getDistance(p->getX(), q->getX());
388  const double a = this->getDistance(x, q->getX()) / dx;
389  const double b = 1.0 - a;
390 
391  return a * p->getY() + b * q->getY()
392  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
393  }
394  };
395 
396 
397  /**
398  * Template specialisation for spline interpolation method with returning JResultDerivative data structure.
399  */
400  template<class JElement_t, template<class, class> class JCollection_t, class JDistance_t>
401  class JSplineFunction<JElement_t,
402  JCollection_t,
403  JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type>,
404  JDistance_t> :
405  public JSplineCollection<JElement_t, JCollection_t, JDistance_t>,
406  public JFunction<typename JElement_t::abscissa_type,
407  JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
408  {
409  public:
410 
412 
413  typedef typename collection_type::abscissa_type abscissa_type;
414  typedef typename collection_type::ordinate_type ordinate_type;
415  typedef typename collection_type::value_type value_type;
416  typedef typename collection_type::distance_type distance_type;
417 
418  typedef typename collection_type::const_iterator const_iterator;
419  typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
420  typedef typename collection_type::iterator iterator;
421  typedef typename collection_type::reverse_iterator reverse_iterator;
422 
425 
429 
431 
432 
433  /**
434  * Default constructor.
435  */
437  {}
438 
439 
440  /**
441  * Recursive interpolation method implementation.
442  *
443  * \param pX pointer to abscissa values
444  * \return function value
445  */
446  virtual result_type evaluate(const argument_type* pX) const override
447  {
448  if (this->size() <= 1u) {
449  return this->getExceptionHandler().action(JFunctionalException("JSplineFunction<>::evaluate() not enough data."));
450  }
451 
452  const argument_type x = *pX;
453 
454  const_iterator p = this->lower_bound(x);
455 
456 
457  if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
458  (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
459 
460  return this->getExceptionHandler().action(MAKE_EXCEPTION(JValueOutOfRange, "abscissa out of range "
461  << STREAM("?") << x << " <> "
462  << STREAM("?") << this->begin() ->getX() << ' '
463  << STREAM("?") << this->rbegin()->getX()));
464  }
465 
466  const_iterator q = p--;
467 
468  const double dx = this->getDistance(p->getX(), q->getX());
469  const double a = this->getDistance(x, q->getX()) / dx;
470  const double b = 1.0 - a;
471 
472  result.f = a * p->getY() + b * q->getY()
473  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
474 
475  result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*a) -
476  q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
477 
478  return result;
479  }
480 
481 
482  private:
484  };
485 
486 
487  /**
488  * Template specialisation for spline interpolation method with returning JResultPDF data structure.
489  *
490  * Note that the data structure of the elements in the collection should have the additional methods:
491  * <pre>
492  * ordinate_type getIntegral() const;
493  * void setIntegral(ordinate_type v);
494  * </pre>
495  * to get and set the integral values, respectively.
496  */
497  template<class JElement_t, template<class, class> class JCollection_t, class JDistance_t>
498  class JSplineFunction<JElement_t,
499  JCollection_t,
500  JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type>,
501  JDistance_t> :
502  public JSplineCollection<JElement_t, JCollection_t, JDistance_t>,
503  public JFunction<typename JElement_t::abscissa_type,
504  JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
505  {
506  public:
507 
509 
510  typedef typename collection_type::abscissa_type abscissa_type;
511  typedef typename collection_type::ordinate_type ordinate_type;
512  typedef typename collection_type::value_type value_type;
513  typedef typename collection_type::distance_type distance_type;
514 
515  typedef typename collection_type::const_iterator const_iterator;
516  typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
517  typedef typename collection_type::iterator iterator;
518  typedef typename collection_type::reverse_iterator reverse_iterator;
519 
522 
526 
528 
529 
530  /**
531  * Default constructor.
532  */
534  {}
535 
536 
537  /**
538  * Determination of second derivatives with specified bounds.
539  *
540  * \param bounds 1st derivatives at two extrema.
541  */
543  {
544  if (this->size() >= 2u) {
545 
546  collection_type::compile(bounds);
547 
548  this->begin()->setIntegral(JMATH::zero);
549 
550  for (iterator j = this->begin(), i = j++; j != this->end(); ++i, ++j) {
551 
552  const double dx = this->getDistance(i->getX(), j->getX());
553  const ordinate_type y = i->getY() + j->getY();
554  const ordinate_type z = i->getU() + j->getU();
555 
556  const ordinate_type v = dx * 0.50 * y;
557  const ordinate_type w = dx * 0.25 * z*dx*dx/6;
558 
559  j->setIntegral(i->getIntegral() + v - w);
560  }
561  }
562  }
563 
564 
565  /**
566  * Recursive interpolation method implementation.
567  *
568  * \param pX pointer to abscissa values
569  * \return function value
570  */
571  virtual result_type evaluate(const argument_type* pX) const override
572  {
573  if (this->size() <= 1u) {
574  return this->getExceptionHandler().action(JFunctionalException("JSplineFunction<>::evaluate() not enough data."));
575  }
576 
577  const argument_type x = *pX;
578 
579  const_iterator p = this->lower_bound(x);
580 
581  if (p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) {
582 
583  try {
584 
585  result = this->getExceptionHandler().action(MAKE_EXCEPTION(JValueOutOfRange, "abscissa out of range "
586  << STREAM("?") << x << " < " << STREAM("?") << this->begin() ->getX()));
587 
588  // overwrite integral values
589 
590  result.v = 0;
591  result.V = this->rbegin()->getIntegral();
592 
593  } catch(const JValueOutOfRange& exception) {
594  throw exception;
595  }
596 
597  return result;
598 
599  } else if (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision) {
600 
601  try {
602 
603  result = this->getExceptionHandler().action(MAKE_EXCEPTION(JValueOutOfRange, "abscissa out of range "
604  << STREAM("?") << x << " > " << STREAM("?") << this->rbegin() ->getX()));
605 
606  // overwrite integral values
607 
608  result.v = this->rbegin()->getIntegral();
609  result.V = this->rbegin()->getIntegral();
610 
611  } catch(const JValueOutOfRange& exception) {
612  throw exception;
613  }
614 
615  return result;
616  }
617 
618  const_iterator q = p--;
619 
620  const double dx = this->getDistance(p->getX(), q->getX());
621  const double a = this->getDistance(x, q->getX()) / dx;
622  const double b = 1.0 - a;
623 
624  result.f = a * p->getY() + b * q->getY()
625  - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
626 
627  result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*a) -
628  q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
629 
630  result.v = p->getIntegral()
631  + 0.5*dx * (p->getY() - 0.5*p->getU()*dx*dx/6)
632  - 0.5*dx * ((a*a*p->getY() - b*b*q->getY()) +
633  (p->getU() * a*a*(0.5*a*a - 1.0) -
634  q->getU() * b*b*(0.5*b*b - 1.0)) * dx*dx/6);
635 
636  result.V = this->rbegin()->getIntegral();
637 
638  return result;
639  }
640 
641 
642  protected:
643  /**
644  * Determination of second derivatives with no bounds.
645  */
646  virtual void do_compile() override
647  {
649  }
650 
651 
652  private:
654  };
655 
656 
657  /**
658  * Template class for spline interpolation in 1D
659  *
660  * This class implements the JFunction1D interface.
661  */
662  template<class JElement_t,
663  template<class, class> class JCollection_t,
664  class JResult_t = typename JElement_t::ordinate_type,
667  public JSplineFunction<JElement_t, JCollection_t, JResult_t, JDistance_t>,
668  public JFunction1D<typename JElement_t::abscissa_type, JResult_t>
669  {
670  public:
671 
673 
677  typedef typename collection_type::distance_type distance_type;
678 
683 
685 
689 
690 
691  /**
692  * Default contructor.
693  */
695  {}
696  };
697 
698 
699  /**
700  * \cond NEVER
701  * Forward declarations.
702  * \endcond
703  */
704  template<class JAbscissa_t, class JOrdinate_t>
705  struct JSplineElement2D;
706 
707  template<template<class, class, class> class JMap_t>
708  struct JMapCollection;
709 
710 
711  /**
712  * Functional map with spline interpolation.
713  */
714  template<class JKey_t,
715  class JValue_t,
716  template<class, class, class> class JMap_t,
717  class JResult_t,
718  class JDistance_t = JDistance<JKey_t> >
719  class JSplineMap :
720  public JMap_t<JKey_t, JValue_t, JDistance_t>,
721  public JFunction<JKey_t, JResult_t>
722  {
723  public:
724 
725  typedef JMap_t<JKey_t, JValue_t, JDistance_t> collection_type;
727 
732 
737 
740  typedef typename function_type::JExceptionHandler exceptionhandler_type;
741 
746 
747 
748  /**
749  * Default constructor.
750  */
752  {}
753 
754 
755  /**
756  * Recursive interpolation method implementation.
757  *
758  * \param pX pointer to abscissa values
759  * \return function value
760  */
761  virtual result_type evaluate(const argument_type* pX) const override
762  {
763  const argument_type x = *pX;
764 
765  ++pX; // next argument value
766 
767  const_iterator p = this->begin();
768 
769  for (typename JSplineFunction1D_t::iterator q = buffer.begin(); q != buffer.end(); ++q, ++p) {
770  q->getY() = JFunction<argument_type, data_type>::getValue(p->getY(), pX);
771  }
772 
773  buffer.compile();
774 
775  return buffer(x);
776  }
777 
778 
779  private:
780  /**
781  * Function compilation.
782  */
783  virtual void do_compile() override
784  {
785  buffer.clear();
786 
787  for (iterator i = this->begin(); i != this->end(); ++i) {
788  buffer.put(i->getX(), data_type());
789  }
790  }
791 
792 
794  };
795 
796 
797  /**
798  * Conversion of data points to integral values.
799  *
800  * The integration includes the use of 2nd derivatives of the data points of the input spline interpolating function.
801  *
802  * \param input collection
803  * \param output mappable collection
804  * \return integral
805  */
806  template<class JElement_t,
807  template<class, class> class JCollection_t,
808  class JResult_t,
809  class JDistance_t>
810  inline typename JElement_t::ordinate_type
812  typename JMappable<JElement_t>::map_type& output)
813  {
814  typedef typename JElement_t::ordinate_type ordinate_type;
816 
817  ordinate_type V(JMATH::zero);
818 
819  if (input.getSize() > 1) {
820 
821  output.put(input.begin()->getX(), V);
822 
823  for (const_iterator j = input.begin(), i = j++; j != input.end(); ++i, ++j) {
824 
825  const double dx = input.getDistance(i->getX(), j->getX());
826  const ordinate_type y = i->getY() + j->getY();
827  const ordinate_type z = i->getU() + j->getU();
828  const ordinate_type v = dx * 0.50 * y;
829  const ordinate_type w = dx * 0.25 * z*dx*dx/6;
830 
831  V += v - w;
832 
833  output.put(j->getX(), V);
834  }
835  }
836 
837  return V;
838  }
839 
840 
841  /**
842  * Conversion of data points to integral values.
843  *
844  * The integration directly uses the integral values of the input spline interpolating function.
845  *
846  * \param input collection
847  * \param output mappable collection
848  * \return integral
849  */
850  template<class JElement_t,
851  template<class, class> class JCollection_t,
852  class JDistance_t>
853  inline typename JElement_t::ordinate_type
854  integrate(const JSplineFunction1D<JElement_t, JCollection_t, JResultPDF<typename JElement_t::ordinate_type>, JDistance_t>& input,
855  typename JMappable<JElement_t>::map_type& output)
856  {
857  typedef typename JElement_t::ordinate_type ordinate_type;
860 
861  if (input.getSize() > 1) {
862 
863  for (const_iterator i = input.begin(); i != input.end(); ++i) {
864  output.put(i->getX(), i->getIntegral());
865  }
866 
867  return input.rbegin()->getIntegral();
868  }
869 
870  return JMATH::zero;
871  }
872 }
873 
874 #endif
virtual result_type evaluate(const argument_type *pX) const override
Recursive interpolation method implementation.
Definition: JSpline.hh:446
collection_type::const_iterator const_iterator
Definition: JSpline.hh:679
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:740
function_type::argument_type argument_type
Definition: JSpline.hh:738
JSplineFunction1D< JSplineElement2D< argument_type, data_type >, JMapCollection< JMap_t >::template collection_type, result_type > JSplineFunction1D_t
Definition: JSpline.hh:745
data_type w[N+1][M+1]
Definition: JPolint.hh:757
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:725
Exception for a functional operation.
Definition: JException.hh:126
JSplineFunction1D()
Default contructor.
Definition: JSpline.hh:694
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:736
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:542
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:680
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:686
Template definition of function object interface in one dimension.
Definition: JFunctional.hh:317
virtual void do_compile() override
Function compilation.
Definition: JSpline.hh:783
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:571
Template class for spline interpolation in 1D.
Definition: JSpline.hh:666
collection_type::abscissa_type abscissa_type
Definition: JSpline.hh:674
collection_type::iterator iterator
Definition: JSpline.hh:189
Exception for missing value.
Definition: JException.hh:198
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
JFunction< JKey_t, JResult_t > function_type
Definition: JSpline.hh:726
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:735
function_type::JExceptionHandler exceptionhandler_type
Definition: JSpline.hh:688
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
JFunction1D< abscissa_type, JResult_t > function_type
Definition: JSpline.hh:684
JResultType< ordinate_type >::result_type data_type
Definition: JSpline.hh:742
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
return result
Definition: JPolint.hh:743
collection_type::distance_type distance_type
Definition: JSpline.hh:731
function_type::result_type result_type
Definition: JSpline.hh:687
collection_type::value_type value_type
Definition: JSpline.hh:730
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:733
#define MAKE_EXCEPTION(JException_t, A)
Make exception.
Definition: JException.hh:687
JSplineCollection< JElement_t, JCollection_t, JDistance_t > collection_type
Definition: JSpline.hh:672
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:728
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:739
JSplineMap()
Default constructor.
Definition: JSpline.hh:751
collection_type::value_type value_type
Definition: JSpline.hh:676
Functional map with spline interpolation.
Definition: JSpline.hh:719
collection_type::ordinate_type ordinate_type
Definition: JSpline.hh:675
functional_type::result_type result_type
Definition: JFunctional.hh:308
collection_type::reverse_iterator reverse_iterator
Definition: JSpline.hh:682
const JExceptionHandler & getExceptionHandler() const
Get exception handler.
Definition: JFunctional.hh:277
Exception for division by zero.
Definition: JException.hh:270
then JCalibrateToT a
Definition: JTuneHV.sh:116
collection_type::ordinate_type ordinate_type
Definition: JSpline.hh:729
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:681
JSplineFunction1D_t buffer
Definition: JSpline.hh:793
int j
Definition: JPolint.hh:682
collection_type::const_reverse_iterator const_reverse_iterator
Definition: JSpline.hh:734
virtual result_type evaluate(const argument_type *pX) const override
Recursive interpolation method implementation.
Definition: JSpline.hh:761
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
functional_type::argument_type argument_type
Definition: JFunctional.hh:307
data_type v[N+1][M+1]
Definition: JPolint.hh:756
double u[N+1]
Definition: JPolint.hh:755
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:677