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 JFunction<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 JFunction<typename JElement_t::abscissa_type,
284 JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
325 if (this->size() <= 1u) {
328 return this->getExceptionHandler().action();
332 std::ostringstream os;
334 os << __FILE__ <<
':' << __LINE__ <<
" not enough data " <<
STREAM(
"?") << x;
343 if ((p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) ||
344 (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision)) {
347 return this->getExceptionHandler().action();
351 std::ostringstream os;
353 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range "
354 <<
STREAM(
"?") << x <<
" <> "
355 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
356 <<
STREAM(
"?") << this->rbegin()->getX();
364 const double dx = this->getDistance(p->getX(), q->getX());
365 const double t = this->getDistance(p->getX(), x) / dx;
367 result.f = h00 (t)*p->getY() + h10 (t)*p->getU()*dx + h01 (t)*q->getY() + h11 (t)*q->getU()*dx;
368 result.fp = h00p(t)*p->getY()/dx + h10p(t)*p->getU() + h01p(t)*q->getY()/dx + h11p(t)*q->getU();
376 using collection_type::h00;
377 using collection_type::h10;
378 using collection_type::h01;
379 using collection_type::h11;
381 using collection_type::h00p;
382 using collection_type::h10p;
383 using collection_type::h01p;
384 using collection_type::h11p;
401 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
407 public virtual JFunction<typename JElement_t::abscissa_type,
408 JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
449 if (this->size() <= 1u) {
452 return this->getExceptionHandler().action();
456 std::ostringstream os;
458 os << __FILE__ <<
':' << __LINE__ <<
" not enough data " <<
STREAM(
"?") << x;
466 if (p == this->begin() && this->getDistance(x, (p++)->getX()) > distance_type::precision) {
470 result = this->getExceptionHandler().action();
475 result.V = this->rbegin()->getIntegral();
479 std::ostringstream os;
481 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range " <<
STREAM(
"?") << x <<
" < " <<
STREAM(
"?") << this->begin() ->getX();
488 }
else if (p == this->end() && this->getDistance((--p)->getX(), x) > distance_type::precision) {
492 result = this->getExceptionHandler().action();
496 result.v = this->rbegin()->getIntegral();
497 result.V = this->rbegin()->getIntegral();
501 std::ostringstream os;
503 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range " <<
STREAM(
"?") << x <<
" > " <<
STREAM(
"?") << this->rbegin()->getX();
513 const double dx = this->getDistance(p->getX(), q->getX());
514 const double t = this->getDistance(p->getX(), x) / dx;
516 result.f = h00 (t)*p->getY() + h10 (t)*p->getU()*dx + h01 (t)*q->getY() + h11 (t)*q->getU()*dx;
517 result.fp = h00p(t)*p->getY()/dx + h10p(t)*p->getU() + h01p(t)*q->getY()/dx + h11p(t)*q->getU();
518 result.v = (p->getIntegral() +
519 (H00 (t)*p->getY() + H10 (t)*p->getU()*dx + H01 (t)*q->getY() + H11 (t)*q->getU()*dx)*dx);
520 result.V = this->rbegin()->getIntegral();
528 using collection_type::h00;
529 using collection_type::h10;
530 using collection_type::h01;
531 using collection_type::h11;
533 using collection_type::h00p;
534 using collection_type::h10p;
535 using collection_type::h01p;
536 using collection_type::h11p;
538 using collection_type::H00;
539 using collection_type::H10;
540 using collection_type::H01;
541 using collection_type::H11;
548 if (!this->empty()) {
550 collection_type::do_compile();
554 for (
iterator j = this->begin(), i =
j++;
j != this->end(); ++i, ++
j) {
556 const double dx = this->getDistance(i->getX(),
j->getX());
563 j->setIntegral(i->getIntegral() +
v +
w);
578 template<
class JElement_t,
579 template<
class,
class>
class JCollection_t,
580 class JResult_t =
typename JElement_t::ordinate_type,
584 public virtual JFunction1D<typename JElement_t::abscissa_type, JResult_t>
618 template<
class JKey_t,
620 template<
class,
class,
class>
class JMap_t,
624 public JMap_t<JKey_t, JValue_t, JDistance_t>,
639 typedef typename collection_type::iterator
iterator;
691 for (
iterator i = this->begin(); i != this->end(); ++i) {
710 template<
class JElement_t,
711 template<
class,
class>
class JCollection_t,
714 inline typename JElement_t::ordinate_type
718 typedef typename JElement_t::ordinate_type ordinate_type;
723 if (input.getSize() > 1) {
725 output.
put(input.begin()->getX(), V);
727 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
729 const double dx = input.getDistance(i->getX(),
j->getX());
730 const ordinate_type y = i->getY() +
j->getY();
731 const ordinate_type z = i->getU() -
j->getU();
733 const ordinate_type
v = dx * 0.50 * y;
734 const ordinate_type
w = dx * 1.00 * z*dx/12.0;
738 output.
put(
j->getX(), V);
755 template<
class JElement_t,
756 template<
class,
class>
class JCollection_t,
758 inline typename JElement_t::ordinate_type
762 typedef typename JElement_t::ordinate_type ordinate_type;
766 if (input.getSize() > 1) {
768 for (const_iterator i = input.begin(); i != input.end(); ++i) {
769 output.
put(i->getX(), i->getIntegral());
772 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.