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 JFunction<typename JElement_t::abscissa_type,
329 typename JResultType<typename JElement_t::ordinate_type>::result_type>
342 typedef typename collection_type::iterator
iterator;
368 if (this->size() <= 1
u) {
376 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
377 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
380 <<
STREAM(
"?") << x <<
" <> "
381 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
382 <<
STREAM(
"?") << this->rbegin()->getX()));
387 const double dx = this->
getDistance(p->getX(), q->getX());
389 const double b = 1.0 -
a;
391 return a * p->getY() + b * q->getY()
392 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
400 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
406 public JFunction<typename JElement_t::abscissa_type,
407 JResultDerivative<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
420 typedef typename collection_type::iterator
iterator;
448 if (this->size() <= 1
u) {
457 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
458 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
461 <<
STREAM(
"?") << x <<
" <> "
462 <<
STREAM(
"?") << this->begin() ->getX() <<
' '
463 <<
STREAM(
"?") << this->rbegin()->getX()));
468 const double dx = this->
getDistance(p->getX(), q->getX());
470 const double b = 1.0 -
a;
472 result.f = a * p->getY() + b * q->getY()
473 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
475 result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*
a) -
476 q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
497 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
503 public JFunction<typename JElement_t::abscissa_type,
504 JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
517 typedef typename collection_type::iterator
iterator;
544 if (this->size() >= 2
u) {
546 collection_type::compile(bounds);
550 for (
iterator j = this->begin(), i =
j++;
j != this->end(); ++i, ++
j) {
552 const double dx = this->
getDistance(i->getX(),
j->getX());
559 j->setIntegral(i->getIntegral() + v -
w);
573 if (this->size() <= 1
u) {
581 if (p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) {
586 <<
STREAM(
"?") << x <<
" < " <<
STREAM(
"?") << this->begin() ->getX()));
591 result.V = this->rbegin()->getIntegral();
599 }
else if (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision) {
604 <<
STREAM(
"?") << x <<
" > " <<
STREAM(
"?") << this->rbegin() ->getX()));
608 result.v = this->rbegin()->getIntegral();
609 result.V = this->rbegin()->getIntegral();
620 const double dx = this->
getDistance(p->getX(), q->getX());
622 const double b = 1.0 -
a;
624 result.f = a * p->getY() + b * q->getY()
625 - a*b * ((a + 1.0)*p->getU() + (b + 1.0)*q->getU()) * dx*dx/6;
627 result.fp = (q->getY() - p->getY() + (p->getU()*(1.0 - 3*a*
a) -
628 q->getU()*(1.0 - 3*b*b)) * dx*dx/6) / dx;
630 result.v = p->getIntegral()
631 + 0.5*dx * (p->getY() - 0.5*p->getU()*dx*dx/6)
632 - 0.5*dx * ((a*a*p->getY() - b*b*q->getY()) +
633 (p->getU() * a*a*(0.5*a*a - 1.0) -
634 q->getU() * b*b*(0.5*b*b - 1.0)) * dx*dx/6);
636 result.V = this->rbegin()->getIntegral();
662 template<
class JElement_t,
663 template<
class,
class>
class JCollection_t,
664 class JResult_t =
typename JElement_t::ordinate_type,
667 public JSplineFunction<JElement_t, JCollection_t, JResult_t, JDistance_t>,
668 public JFunction1D<typename JElement_t::abscissa_type, JResult_t>
704 template<
class JAbscissa_t,
class JOrdinate_t>
707 template<
template<
class,
class,
class>
class JMap_t>
714 template<
class JKey_t,
716 template<
class,
class,
class>
class JMap_t,
720 public JMap_t<JKey_t, JValue_t, JDistance_t>,
787 for (
iterator i = this->begin(); i != this->end(); ++i) {
806 template<
class JElement_t,
807 template<
class,
class>
class JCollection_t,
810 inline typename JElement_t::ordinate_type
819 if (input.getSize() > 1) {
821 output.
put(input.begin()->getX(),
V);
823 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
825 const double dx = input.getDistance(i->getX(),
j->getX());
826 const ordinate_type y = i->getY() +
j->getY();
827 const ordinate_type z = i->getU() +
j->getU();
828 const ordinate_type
v = dx * 0.50 * y;
829 const ordinate_type
w = dx * 0.25 * z*dx*dx/6;
833 output.
put(
j->getX(),
V);
850 template<
class JElement_t,
851 template<
class,
class>
class JCollection_t,
853 inline typename JElement_t::ordinate_type
861 if (input.getSize() > 1) {
863 for (const_iterator i = input.begin(); i != input.end(); ++i) {
864 output.
put(i->getX(), i->getIntegral());
867 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.