1 #ifndef __JTOOLS__JHERMITESPLINE__
2 #define __JTOOLS__JHERMITESPLINE__
22 namespace JPP {
using namespace JTOOLS; }
46 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
48 public JCollection_t<JElement_t, JDistance_t>,
62 typedef typename collection_type::iterator
iterator;
77 if (this->size() >= 2
u) {
82 i->setU((j->getY() -
i->getY()) / this->
getDistance(
i->getX(), j->getX()));
88 i->setU((j->getY() -
i->getY()) / this->
getDistance(
i->getX(), j->getX()));
91 for (
iterator k = this->begin(),
i =
k++,
j =
k++;
k != this->end(); ++
i, ++
j, ++
k) {
92 j->setU(0.5 * ((j->getY() -
i->getY()) / this->
getDistance(
i->getX(), j->getX()) +
93 (
k->getY() - j->getY()) / this->
getDistance(j->getX(),
k->getX())));
98 for (
iterator j = this->begin(),
i = j++; j != this->end(); ++
i, ++
j) {
99 if (
i->getY() == j->getY()) {
104 for (
iterator j = this->begin(),
i = j++; j != this->end(); ++
i, ++
j) {
113 i->setU(v*
i->getU());
114 j->setU(v*j->getU());
160 template<
class JElement_t,
161 template<
class,
class>
class JCollection_t,
170 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
176 public virtual JFunction<typename JElement_t::abscissa_type,
177 typename JResultType<typename JElement_t::ordinate_type>::result_type>
190 typedef typename collection_type::iterator
iterator;
218 if (this->size() <= 1
u) {
220 std::ostringstream os;
222 os << __FILE__ <<
':' << __LINE__ <<
" not enough data " <<
STREAM(
"?") <<
x;
229 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
230 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
232 std::ostringstream os;
234 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range "
235 <<
STREAM(
"?") << x <<
" <> "
236 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
237 <<
STREAM(
"?") << this->rbegin()->getX();
244 const double dx = this->
getDistance(p->getX(), q->getX());
247 return h00(t)*p->getY() +
h10(t)*p->getU()*dx +
h01(t)*q->getY() +
h11(t)*q->getU()*dx;
252 using collection_type::h00;
253 using collection_type::h10;
254 using collection_type::h01;
255 using collection_type::h11;
262 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
268 public virtual JFunction<typename JElement_t::abscissa_type,
269 JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
282 typedef typename collection_type::iterator
iterator;
310 if (this->size() <= 1
u) {
312 std::ostringstream os;
314 os << __FILE__ <<
':' << __LINE__ <<
" not enough data " <<
STREAM(
"?") <<
x;
322 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
323 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
325 std::ostringstream os;
327 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range "
328 <<
STREAM(
"?") << x <<
" <> "
329 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
330 <<
STREAM(
"?") << this->rbegin()->getX();
337 const double dx = this->
getDistance(p->getX(), q->getX());
340 result.f =
h00 (t)*p->getY() +
h10 (t)*p->getU()*dx +
h01 (t)*q->getY() +
h11 (t)*q->getU()*dx;
349 using collection_type::h00;
350 using collection_type::h10;
351 using collection_type::h01;
352 using collection_type::h11;
354 using collection_type::h00p;
355 using collection_type::h10p;
356 using collection_type::h01p;
357 using collection_type::h11p;
374 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
380 public virtual JFunction<typename JElement_t::abscissa_type,
381 JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
394 typedef typename collection_type::iterator
iterator;
422 if (this->size() <= 1
u) {
424 std::ostringstream os;
426 os << __FILE__ <<
':' << __LINE__ <<
" not enough data " <<
STREAM(
"?") <<
x;
433 if (p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) {
437 std::ostringstream os;
439 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range " <<
STREAM(
"?") << x <<
" < " <<
STREAM(
"?") << this->begin() ->getX();
446 result.V = this->rbegin()->getIntegral();
454 }
else if (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision) {
458 std::ostringstream os;
460 os << __FILE__ <<
':' << __LINE__ <<
" abscissa out of range " <<
STREAM(
"?") << x <<
" > " <<
STREAM(
"?") << this->rbegin()->getX();
466 result.v = this->rbegin()->getIntegral();
467 result.V = this->rbegin()->getIntegral();
478 const double dx = this->
getDistance(p->getX(), q->getX());
481 result.f =
h00 (t)*p->getY() +
h10 (t)*p->getU()*dx +
h01 (t)*q->getY() +
h11 (t)*q->getU()*dx;
483 result.v = (p->getIntegral() +
484 (
H00 (t)*p->getY() +
H10 (t)*p->getU()*dx +
H01 (t)*q->getY() +
H11 (t)*q->getU()*dx)*dx);
485 result.V = this->rbegin()->getIntegral();
493 using collection_type::h00;
494 using collection_type::h10;
495 using collection_type::h01;
496 using collection_type::h11;
498 using collection_type::h00p;
499 using collection_type::h10p;
500 using collection_type::h01p;
501 using collection_type::h11p;
503 using collection_type::H00;
504 using collection_type::H10;
505 using collection_type::H01;
506 using collection_type::H11;
513 if (!this->empty()) {
519 for (
iterator j = this->begin(),
i =
j++;
j != this->end(); ++
i, ++
j) {
528 j->setIntegral(
i->getIntegral() + v +
w);
543 template<
class JElement_t,
544 template<
class,
class>
class JCollection_t,
545 class JResult_t =
typename JElement_t::ordinate_type,
549 public virtual JFunction1D<typename JElement_t::abscissa_type, JResult_t>
583 template<
class JKey_t,
585 template<
class,
class,
class>
class JMap_t,
589 public JMap_t<JKey_t, JValue_t, JDistance_t>,
604 typedef typename collection_type::iterator
iterator;
656 for (
iterator i = this->begin();
i != this->end(); ++
i) {
675 template<
class JElement_t,
676 template<
class,
class>
class JCollection_t,
679 inline typename JElement_t::ordinate_type
688 if (input.getSize() > 1) {
690 output.
put(input.begin()->getX(),
V);
692 for (const_iterator
j = input.begin(),
i =
j++;
j != input.end(); ++
i, ++
j) {
694 const double dx = input.getDistance(
i->getX(),
j->getX());
695 const ordinate_type
y =
i->getY() +
j->getY();
696 const ordinate_type z =
i->getU() -
j->getU();
698 const ordinate_type
v = dx * 0.50 *
y;
699 const ordinate_type
w = dx * 1.00 * z*dx/12.0;
703 output.
put(
j->getX(),
V);
720 template<
class JElement_t,
721 template<
class,
class>
class JCollection_t,
723 inline typename JElement_t::ordinate_type
731 if (input.getSize() > 1) {
733 for (const_iterator
i = input.begin();
i != input.end(); ++
i) {
734 output.
put(
i->getX(),
i->getIntegral());
737 return input.rbegin()->getIntegral();
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
std::vector< event_type > data_type
Exception for a functional operation.
This include file containes various data structures that can be used as specific return types for the...
static const JZero zero
Function object to assign zero value.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
Definition of zero value for any class.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
Exception for missing value.
Auxiliary data structure for handling std::ostream.
Exception for division by zero.
Exception for accessing a value in a collection that is outside of its range.