1#ifndef __JTOOLS__JHERMITESPLINE__
2#define __JTOOLS__JHERMITESPLINE__
49 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
51 public JCollection_t<JElement_t, JDistance_t>,
65 typedef typename collection_type::iterator
iterator;
80 if (this->size() >= 2u) {
85 i->setU((
j->getY() - i->getY()) / this->getDistance(i->getX(),
j->getX()));
91 i->setU((
j->getY() - i->getY()) / this->getDistance(i->getX(),
j->getX()));
94 for (
iterator k = this->begin(), i = k++,
j = k++; k != this->end(); ++i, ++
j, ++k) {
95 j->setU(0.5 * ((
j->getY() - i->getY()) / this->getDistance(i->getX(),
j->getX()) +
96 (k->getY() -
j->getY()) / this->getDistance(
j->getX(), k->getX())));
101 for (
iterator j = this->begin(), i =
j++;
j != this->end(); ++i, ++
j) {
102 if (i->getY() ==
j->getY()) {
107 for (
iterator j = this->begin(), i =
j++;
j != this->end(); ++i, ++
j) {
109 const ordinate_type u = (
j->getY() - i->getY()) / this->getDistance(i->getX(),
j->getX());
116 i->setU(v*i->getU());
117 j->setU(v*
j->getU());
163 template<
class JElement_t,
164 template<
class,
class>
class JCollection_t,
173 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
179 public virtual JFunctional<typename JElement_t::abscissa_type,
180 typename JResultType<typename JElement_t::ordinate_type>::result_type>
221 if (this->size() <= 1u) {
224 return this->getExceptionHandler().action();
228 std::ostringstream os;
230 os << __FILE__ <<
':' << __LINE__ <<
" not enough data " <<
STREAM(
"?") << x;
238 if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
239 (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
242 return this->getExceptionHandler().action();
246 std::ostringstream os;
248 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range "
249 <<
STREAM(
"?") << x <<
" <> "
250 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
251 <<
STREAM(
"?") << this->rbegin()->getX();
259 const double dx = this->getDistance(p->getX(), q->getX());
260 const double t = this->getDistance(p->getX(), x) / dx;
262 return h00(t)*p->getY() + h10(t)*p->getU()*dx + h01(t)*q->getY() + h11(t)*q->getU()*dx;
267 using collection_type::h00;
268 using collection_type::h10;
269 using collection_type::h01;
270 using collection_type::h11;
277 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
283 public virtual JFunctional<typename JElement_t::abscissa_type,
284 JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
327 if (this->size() <= 1u) {
330 return this->getExceptionHandler().action();
334 std::ostringstream os;
336 os << __FILE__ <<
':' << __LINE__ <<
" not enough data " <<
STREAM(
"?") << x;
345 if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
346 (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
349 return this->getExceptionHandler().action();
353 std::ostringstream os;
355 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range "
356 <<
STREAM(
"?") << x <<
" <> "
357 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
358 <<
STREAM(
"?") << this->rbegin()->getX();
366 const double dx = this->getDistance(p->getX(), q->getX());
367 const double t = this->getDistance(p->getX(), x) / dx;
369 result.f = h00 (t)*p->getY() + h10 (t)*p->getU()*dx + h01 (t)*q->getY() + h11 (t)*q->getU()*dx;
370 result.fp = h00p(t)*p->getY()/dx + h10p(t)*p->getU() + h01p(t)*q->getY()/dx + h11p(t)*q->getU();
378 using collection_type::h00;
379 using collection_type::h10;
380 using collection_type::h01;
381 using collection_type::h11;
383 using collection_type::h00p;
384 using collection_type::h10p;
385 using collection_type::h01p;
386 using collection_type::h11p;
400 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
406 public virtual JFunctional<typename JElement_t::abscissa_type,
407 JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
450 if (this->size() <= 1u) {
453 return this->getExceptionHandler().action();
457 std::ostringstream os;
459 os << __FILE__ <<
':' << __LINE__ <<
" not enough data " <<
STREAM(
"?") << x;
467 if (p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) {
471 result = this->getExceptionHandler().action();
476 result.V = this->rbegin()->getIntegral();
480 std::ostringstream os;
482 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range " <<
STREAM(
"?") << x <<
" < " <<
STREAM(
"?") << this->begin() ->getX();
489 }
else if (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision) {
493 result = this->getExceptionHandler().action();
497 result.v = this->rbegin()->getIntegral();
498 result.V = this->rbegin()->getIntegral();
502 std::ostringstream os;
504 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range " <<
STREAM(
"?") << x <<
" > " <<
STREAM(
"?") << this->rbegin()->getX();
514 const double dx = this->getDistance(p->getX(), q->getX());
515 const double t = this->getDistance(p->getX(), x) / dx;
517 result.f = h00 (t)*p->getY() + h10 (t)*p->getU()*dx + h01 (t)*q->getY() + h11 (t)*q->getU()*dx;
518 result.fp = h00p(t)*p->getY()/dx + h10p(t)*p->getU() + h01p(t)*q->getY()/dx + h11p(t)*q->getU();
519 result.v = (p->getIntegral() +
520 (H00 (t)*p->getY() + H10 (t)*p->getU()*dx + H01 (t)*q->getY() + H11 (t)*q->getU()*dx)*dx);
521 result.V = this->rbegin()->getIntegral();
529 using collection_type::h00;
530 using collection_type::h10;
531 using collection_type::h01;
532 using collection_type::h11;
534 using collection_type::h00p;
535 using collection_type::h10p;
536 using collection_type::h01p;
537 using collection_type::h11p;
539 using collection_type::H00;
540 using collection_type::H10;
541 using collection_type::H01;
542 using collection_type::H11;
549 if (!this->empty()) {
551 collection_type::do_compile();
555 for (
iterator j = this->begin(), i =
j++;
j != this->end(); ++i, ++
j) {
557 const double dx = this->getDistance(i->getX(),
j->getX());
564 j->setIntegral(i->getIntegral() + v + w);
576 template<
class JElement_t,
577 template<
class,
class>
class JCollection_t,
578 class JResult_t =
typename JElement_t::ordinate_type,
582 public JFunction1D<typename JElement_t::abscissa_type, JResult_t>
616 template<
class JKey_t,
618 template<
class,
class,
class>
class JMap_t,
622 public JMap_t<JKey_t, JValue_t, JDistance_t>,
637 typedef typename collection_type::iterator
iterator;
689 for (
iterator i = this->begin(); i != this->end(); ++i) {
708 template<
class JElement_t,
709 template<
class,
class>
class JCollection_t,
712 inline typename JElement_t::ordinate_type
716 typedef typename JElement_t::ordinate_type ordinate_type;
721 if (input.getSize() > 1) {
723 output.
put(input.begin()->getX(), V);
725 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
727 const double dx = input.getDistance(i->getX(),
j->getX());
728 const ordinate_type y = i->getY() +
j->getY();
729 const ordinate_type z = i->getU() -
j->getU();
731 const ordinate_type v = dx * 0.50 * y;
732 const ordinate_type w = dx * 1.00 * z*dx/12.0;
736 output.
put(
j->getX(), V);
753 template<
class JElement_t,
754 template<
class,
class>
class JCollection_t,
756 inline typename JElement_t::ordinate_type
760 typedef typename JElement_t::ordinate_type ordinate_type;
764 if (input.getSize() > 1) {
766 for (const_iterator i = input.begin(); i != input.end(); ++i) {
767 output.
put(i->getX(), i->getIntegral());
770 return input.rbegin()->getIntegral();
The elements in a collection are sorted according to their abscissa values and a given distance opera...
This include file containes various data structures that can be used as specific return types for the...
Definition of zero value for any class.
Exception for division by zero.
Exception for a functional operation.
Exception for missing value.
Exception for accessing a value in a collection that is outside of its range.
static const JZero zero
Function object to assign zero value.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for handling std::ostream.