Go to the documentation of this file. 1 #ifndef __JTOOLS__JSPLINE__
2 #define __JTOOLS__JSPLINE__
33 template<
class JOrdinate_t>
119 throw JNoValue(
"JSplineBounds: missing 1st derivative.");
133 throw JNoValue(
"JSplineBounds: missing 1st derivative.");
149 template<
class JOrdinate_t>
151 const JOrdinate_t fpAtXmax)
173 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
175 public JCollection_t<JElement_t, JDistance_t>,
188 typedef typename collection_type::iterator
iterator;
201 const int numberOfElements = this->size();
205 if (numberOfElements > 2) {
214 const double dx = this->
getDistance(i->getX(),
j->getX());
230 for (
iterator k = this->begin(), i = k++,
j = k++; k != this->end(); ++i, ++
j, ++k, ++index) {
241 const double h = sig * buffer[index-1] + 2.0;
243 buffer[index] = (sig - 1.0) / h;
248 j->setU((6.0 *
j->getU() / this->
getDistance(x1, x3) - sig * i->getU()) / h);
257 index = numberOfElements - 2;
259 const double dx = this->
getDistance(i->getX(),
j->getX());
264 i->setU((i->getU() - 0.5*
j->getU()) / (0.5*buffer[index] + 1.0));
275 index = numberOfElements - 2;
277 for ( ;
j != this->rend(); ++i, ++
j, --index) {
278 j->setU(
j->getU() + i->getU() * buffer[index]);
283 for (
iterator i = this->begin(); i != this->end(); ++i) {
311 template<
class JElement_t,
312 template<
class,
class>
class JCollection_t,
321 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
327 public JFunction<typename JElement_t::abscissa_type,
328 typename JResultType<typename JElement_t::ordinate_type>::result_type>
341 typedef typename collection_type::iterator
iterator;
367 if (this->size() <= 1
u) {
375 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
376 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
383 const double dx = this->
getDistance(p->getX(), q->getX());
384 const double a = this->
getDistance(x, q->getX()) / dx;
385 const double b = 1.0 - a;
387 return a * p->getY() + b * q->getY()
388 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
396 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
402 public JFunction<typename JElement_t::abscissa_type,
403 JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
416 typedef typename collection_type::iterator
iterator;
444 if (this->size() <= 1
u) {
453 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
454 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
461 const double dx = this->
getDistance(p->getX(), q->getX());
462 const double a = this->
getDistance(x, q->getX()) / dx;
463 const double b = 1.0 - a;
465 result.f = a * p->getY() + b * q->getY()
466 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
468 result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*a) -
469 q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
490 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
496 public JFunction<typename JElement_t::abscissa_type,
497 JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
510 typedef typename collection_type::iterator
iterator;
537 if (this->size() >= 2
u) {
539 collection_type::compile(bounds);
543 for (
iterator j = this->begin(), i =
j++;
j != this->end(); ++i, ++
j) {
545 const double dx = this->
getDistance(i->getX(),
j->getX());
552 j->setIntegral(i->getIntegral() +
v -
w);
566 if (this->size() <= 1
u) {
574 if (p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) {
583 result.V = this->rbegin()->getIntegral();
591 }
else if (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision) {
599 result.v = this->rbegin()->getIntegral();
600 result.V = this->rbegin()->getIntegral();
611 const double dx = this->
getDistance(p->getX(), q->getX());
612 const double a = this->
getDistance(x, q->getX()) / dx;
613 const double b = 1.0 - a;
615 result.f = a * p->getY() + b * q->getY()
616 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
618 result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*a) -
619 q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
621 result.v = p->getIntegral()
622 + 0.5*dx * (p->getY() - 0.5*p->getU()*dx*dx/6)
623 - 0.5*dx * ((a*a*p->getY() - b*b*q->getY()) +
624 (p->getU() * a*a*(0.5*a*a - 1.0) -
625 q->getU() * b*b*(0.5*b*b - 1.0)) * dx*dx/6);
627 result.V = this->rbegin()->getIntegral();
653 template<
class JElement_t,
654 template<
class,
class>
class JCollection_t,
655 class JResult_t =
typename JElement_t::ordinate_type,
658 public JSplineFunction<JElement_t, JCollection_t, JResult_t, JDistance_t>,
659 public JFunction1D<typename JElement_t::abscissa_type, JResult_t>
693 template<
class JKey_t,
695 template<
class,
class,
class>
class JMap_t,
699 public JMap_t<JKey_t, JValue_t, JDistance_t>,
766 for (
iterator i = this->begin(); i != this->end(); ++i) {
785 template<
class JElement_t,
786 template<
class,
class>
class JCollection_t,
789 inline typename JElement_t::ordinate_type
798 if (input.getSize() > 1) {
800 output.
put(input.begin()->getX(), V);
804 const double dx = input.getDistance(i->getX(),
j->getX());
812 output.
put(
j->getX(), V);
829 template<
class JElement_t,
830 template<
class,
class>
class JCollection_t,
832 inline typename JElement_t::ordinate_type
840 if (input.getSize() > 1) {
843 output.
put(i->getX(), i->getIntegral());
846 return input.rbegin()->getIntegral();
Exception for missing value.
JArgument< T >::argument_type argument_type
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
Exception for accessing a value in a collection that is outside of its range.
Exception for a functional operation.
Exception for division by zero.
static const JZero zero
Function object to assign zero value.