1 #ifndef __JTOOLS__JHERMITESPLINE__
2 #define __JTOOLS__JHERMITESPLINE__
21 namespace JPP {
using namespace JTOOLS; }
45 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
47 public JCollection_t<JElement_t, JDistance_t>,
61 typedef typename collection_type::iterator
iterator;
74 const int numberOfElements = this->size();
78 if (numberOfElements >= 2) {
83 i->setU((j->getY() - i->getY()) / this->
getDistance(i->getX(), j->getX()));
89 i->setU((j->getY() - i->getY()) / this->
getDistance(i->getX(), j->getX()));
92 for (
iterator k = this->begin(), i = k++, j = k++; k != this->end(); ++i, ++j, ++k) {
93 j->setU(0.5 * ((j->getY() - i->getY()) / this->
getDistance(i->getX(), j->getX()) +
94 (k->getY() - j->getY()) / this->
getDistance(j->getX(), k->getX())));
99 for (
iterator j = this->begin(), i = j++; j != this->end(); ++i, ++j) {
100 if (i->getY() == j->getY()) {
105 for (
iterator j = this->begin(), i = j++; j != this->end(); ++i, ++j) {
108 const ordinate_type w = (i->getU()*i->getU() + j->getU()*j->getU());
114 i->setU(v*i->getU());
115 j->setU(v*j->getU());
161 template<
class JElement_t,
162 template<
class,
class>
class JCollection_t,
171 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
177 public JFunction<typename JElement_t::abscissa_type,
178 typename JResultType<typename JElement_t::ordinate_type>::result_type>
191 typedef typename collection_type::iterator
iterator;
225 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
226 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
233 const double dx = this->
getDistance(p->getX(), q->getX());
234 const double t = this->
getDistance(p->getX(), x) / dx;
236 return h00(t)*p->getY() +
h10(t)*p->getU()*dx +
h01(t)*q->getY() +
h11(t)*q->getU()*dx;
241 using collection_type::h00;
242 using collection_type::h10;
243 using collection_type::h01;
244 using collection_type::h11;
251 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
257 public JFunction<typename JElement_t::abscissa_type,
258 JResultHesse<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
271 typedef typename collection_type::iterator
iterator;
306 if ((p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) ||
307 (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision)) {
314 const double dx = this->
getDistance(p->getX(), q->getX());
315 const double t = this->
getDistance(p->getX(), x) / dx;
317 result.f =
h00 (t)*p->getY() +
h10 (t)*p->getU()*dx +
h01 (t)*q->getY() +
h11 (t)*q->getU()*dx;
318 result.fp =
h00p(t)*p->getY()/dx +
h10p(t)*p->getU() +
h01p(t)*q->getY()/dx +
h11p(t)*q->getU();
326 using collection_type::h00;
327 using collection_type::h10;
328 using collection_type::h01;
329 using collection_type::h11;
331 using collection_type::h00p;
332 using collection_type::h10p;
333 using collection_type::h01p;
334 using collection_type::h11p;
351 template<
class JElement_t,
template<
class,
class>
class JCollection_t,
class JDistance_t>
357 public JFunction<typename JElement_t::abscissa_type,
358 JResultPDF<typename JResultType<typename JElement_t::ordinate_type>::result_type> >
371 typedef typename collection_type::iterator
iterator;
405 if (p == this->begin() && this->
getDistance(x, (p++)->getX()) > distance_type::precision) {
414 result.V = this->rbegin()->getIntegral();
422 }
else if (p == this->end() && this->
getDistance((--p)->getX(), x) > distance_type::precision) {
430 result.v = this->rbegin()->getIntegral();
431 result.V = this->rbegin()->getIntegral();
442 const double dx = this->
getDistance(p->getX(), q->getX());
443 const double t = this->
getDistance(p->getX(), x) / dx;
445 result.f =
h00 (t)*p->getY() +
h10 (t)*p->getU()*dx +
h01 (t)*q->getY() +
h11 (t)*q->getU()*dx;
446 result.fp =
h00p(t)*p->getY()/dx +
h10p(t)*p->getU() +
h01p(t)*q->getY()/dx +
h11p(t)*q->getU();
447 result.v = (p->getIntegral() +
448 (
H00 (t)*p->getY() +
H10 (t)*p->getU()*dx +
H01 (t)*q->getY() +
H11 (t)*q->getU()*dx)*dx);
449 result.V = this->rbegin()->getIntegral();
457 using collection_type::h00;
458 using collection_type::h10;
459 using collection_type::h01;
460 using collection_type::h11;
462 using collection_type::h00p;
463 using collection_type::h10p;
464 using collection_type::h01p;
465 using collection_type::h11p;
467 using collection_type::H00;
468 using collection_type::H10;
469 using collection_type::H01;
470 using collection_type::H11;
477 if (!this->empty()) {
479 collection_type::do_compile();
483 for (
iterator j = this->begin(), i = j++; j != this->end(); ++i, ++j) {
485 const double dx = this->
getDistance(i->getX(), j->getX());
492 j->setIntegral(i->getIntegral() + v + w);
507 template<
class JElement_t,
508 template<
class,
class>
class JCollection_t,
509 class JResult_t =
typename JElement_t::ordinate_type,
513 public JFunction1D<typename JElement_t::abscissa_type, JResult_t>
547 template<
class JKey_t,
549 template<
class,
class,
class>
class JMap_t,
553 public JMap_t<JKey_t, JValue_t, JDistance_t>,
568 typedef typename collection_type::iterator
iterator;
620 for (
iterator i = this->begin(); i != this->end(); ++i) {
639 template<
class JElement_t,
640 template<
class,
class>
class JCollection_t,
643 inline typename JElement_t::ordinate_type
652 if (input.getSize() > 1) {
654 output.
put(input.begin()->getX(), V);
656 for (const_iterator j = input.begin(), i = j++; j != input.end(); ++i, ++j) {
658 const double dx = input.getDistance(i->getX(), j->getX());
659 const ordinate_type y = i->getY() + j->getY();
660 const ordinate_type z = i->getU() - j->getU();
662 const ordinate_type v = dx * 0.50 * y;
663 const ordinate_type w = dx * 1.00 * z*dx/12.0;
667 output.
put(j->getX(), V);
684 template<
class JElement_t,
685 template<
class,
class>
class JCollection_t,
687 inline typename JElement_t::ordinate_type
695 if (input.getSize() > 1) {
697 for (const_iterator i = input.begin(); i != input.end(); ++i) {
698 output.
put(i->getX(), i->getIntegral());
701 return input.rbegin()->getIntegral();
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.
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.
Exception for division by zero.
Exception for an empty collection.
Exception for accessing a value in a collection that is outside of its range.