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) {
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>
193 typedef typename collection_type::iterator
iterator;
221 if (this->size() <= 1u) {
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)) {
246 std::ostringstream os;
248 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range "
250 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
251 <<
STREAM(
"?") << this->rbegin()->getX();
259 const double dx = this->
getDistance(p->getX(), q->getX());
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> >
297 typedef typename collection_type::iterator
iterator;
325 if (this->size() <= 1u) {
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)) {
351 std::ostringstream os;
353 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range "
355 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
356 <<
STREAM(
"?") << this->rbegin()->getX();
364 const double dx = this->
getDistance(p->getX(), q->getX());
367 result.f =
h00 (t)*p->getY() +
h10 (t)*p->getU()*dx +
h01 (t)*q->getY() +
h11 (t)*q->getU()*dx;
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> >
421 typedef typename collection_type::iterator
iterator;
449 if (this->size() <= 1u) {
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) {
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) {
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());
516 result.f =
h00 (t)*p->getY() +
h10 (t)*p->getU()*dx +
h01 (t)*q->getY() +
h11 (t)*q->getU()*dx;
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()) {
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
723 if (input.getSize() > 1) {
725 output.
put(input.begin()->getX(), V);
729 const double dx = input.getDistance(i->getX(),
j->getX());
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
766 if (input.getSize() > 1) {
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.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< event_type > data_type
Auxiliary data structure for handling std::ostream.