1 #ifndef __JTOOLS__JSPLINE__
2 #define __JTOOLS__JSPLINE__
21 namespace JPP {
using namespace JTOOLS; }
34 template<
class JOrdinate_t>
120 throw JNoValue(
"JSplineBounds: missing 1st derivative.");
134 throw JNoValue(
"JSplineBounds: missing 1st derivative.");
150 template<
class JOrdinate_t>
152 const JOrdinate_t fpAtXmax)
174 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
176 public JCollection_t<JElement_t, JDistance_t>,
189 typedef typename collection_type::iterator
iterator;
202 const int numberOfElements = this->size();
206 if (numberOfElements > 2) {
215 const double dx = this->
getDistance(i->getX(), j->getX());
231 for (
iterator k = this->begin(),
i =
k++,
j =
k++;
k != this->end(); ++
i, ++
j, ++
k, ++index) {
242 const double h = sig * buffer[index-1] + 2.0;
244 buffer[index] = (sig - 1.0) / h;
249 j->setU((6.0 * j->getU() / this->
getDistance(x1, x3) - sig *
i->getU()) / h);
258 index = numberOfElements - 2;
260 const double dx = this->
getDistance(i->getX(), j->getX());
265 i->setU((i->getU() - 0.5*j->getU()) / (0.5*buffer[index] + 1.0));
276 index = numberOfElements - 2;
278 for ( ; j != this->rend(); ++
i, ++
j, --index) {
279 j->setU(j->getU() + i->getU() * buffer[index]);
284 for (
iterator i = this->begin();
i != this->end(); ++
i) {
312 template<
class JElement_t,
313 template<
class,
class>
class JCollection_t,
322 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
328 public virtual JFunction<typename JElement_t::abscissa_type,
329 typename JResultType<typename JElement_t::ordinate_type>::result_type>
342 typedef typename collection_type::iterator
iterator;
370 if (this->size() > 1
u) {
374 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
375 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
378 <<
STREAM(
"?") << x <<
" <> "
379 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
380 <<
STREAM(
"?") << this->rbegin()->getX()));
385 const double dx = this->
getDistance(p->getX(), q->getX());
387 const double b = 1.0 -
a;
389 return (a * p->getY() + b * q->getY()
390 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6);
392 }
else if (this->size() == 1
u && this->
getDistance(x, this->begin()->getX()) <= distance_type::precision) {
394 return this->begin()->getY();
407 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
413 public virtual JFunction<typename JElement_t::abscissa_type,
414 JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
427 typedef typename collection_type::iterator
iterator;
457 if (this->size() <= 1
u) {
464 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
465 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
468 <<
STREAM(
"?") << x <<
" <> "
469 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
470 <<
STREAM(
"?") << this->rbegin()->getX()));
475 const double dx = this->
getDistance(p->getX(), q->getX());
477 const double b = 1.0 -
a;
479 result.f = a * p->getY() + b * q->getY()
480 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
482 result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*
a) -
483 q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
504 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
510 public virtual JFunction<typename JElement_t::abscissa_type,
511 JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
524 typedef typename collection_type::iterator
iterator;
551 if (this->size() >= 2
u) {
553 collection_type::compile(bounds);
557 for (
iterator j = this->begin(),
i =
j++;
j != this->end(); ++
i, ++
j) {
566 j->setIntegral(
i->getIntegral() + v -
w);
582 if (this->size() <= 1
u) {
588 if (p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) {
593 <<
STREAM(
"?") << x <<
" < " <<
STREAM(
"?") << this->begin() ->getX()));
598 result.V = this->rbegin()->getIntegral();
606 }
else if (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision) {
611 <<
STREAM(
"?") << x <<
" > " <<
STREAM(
"?") << this->rbegin() ->getX()));
615 result.v = this->rbegin()->getIntegral();
616 result.V = this->rbegin()->getIntegral();
627 const double dx = this->
getDistance(p->getX(), q->getX());
629 const double b = 1.0 -
a;
631 result.f = a * p->getY() + b * q->getY()
632 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
634 result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*
a) -
635 q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
637 result.v = p->getIntegral()
638 + 0.5*dx * (p->getY() - 0.5*p->getU()*dx*dx/6)
639 - 0.5*dx * ((a*a*p->getY() - b*b*q->getY()) +
640 (p->getU() * a*a*(0.5*a*a - 1.0) -
641 q->getU() * b*b*(0.5*b*b - 1.0)) * dx*dx/6);
643 result.V = this->rbegin()->getIntegral();
669 template<
class JElement_t,
670 template<
class,
class>
class JCollection_t,
671 class JResult_t =
typename JElement_t::ordinate_type,
674 public JSplineFunction<JElement_t, JCollection_t, JResult_t, JDistance_t>,
675 public JFunction1D<typename JElement_t::abscissa_type, JResult_t>
711 template<
class JAbscissa_t,
class JOrdinate_t>
714 template<
template<
class,
class,
class>
class JMap_t>
721 template<
class JKey_t,
723 template<
class,
class,
class>
class JMap_t,
727 public JMap_t<JKey_t, JValue_t, JDistance_t>,
794 for (
iterator i = this->begin();
i != this->end(); ++
i) {
813 template<
class JElement_t,
814 template<
class,
class>
class JCollection_t,
817 inline typename JElement_t::ordinate_type
826 if (input.getSize() > 1) {
828 output.
put(input.begin()->getX(),
V);
830 for (const_iterator
j = input.begin(),
i =
j++;
j != input.end(); ++
i, ++
j) {
832 const double dx = input.getDistance(
i->getX(),
j->getX());
833 const ordinate_type
y =
i->getY() +
j->getY();
834 const ordinate_type z =
i->getU() +
j->getU();
835 const ordinate_type
v = dx * 0.50 *
y;
836 const ordinate_type
w = dx * 0.25 * z*dx*dx/6;
840 output.
put(
j->getX(),
V);
857 template<
class JElement_t,
858 template<
class,
class>
class JCollection_t,
860 inline typename JElement_t::ordinate_type
868 if (input.getSize() > 1) {
870 for (const_iterator
i = input.begin();
i != input.end(); ++
i) {
871 output.
put(
i->getX(),
i->getIntegral());
874 return input.rbegin()->getIntegral();
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
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.
JArgument< T >::argument_type argument_type
Auxiliary data structure for handling std::ostream.
#define MAKE_EXCEPTION(JException_t, A)
Make exception.
Exception for division by zero.
Exception for accessing a value in a collection that is outside of its range.