Пример #1
0
            MixedInterpolationImpl(const I1& xBegin, const I1& xEnd,
                                   const I2& yBegin, Size n,
                                   MixedInterpolation::Behavior behavior
                                            = MixedInterpolation::ShareRanges,
                                   const Interpolator1& factory1 = Interpolator1(),
                                   const Interpolator2& factory2 = Interpolator2())
            : Interpolation::templateImpl<I1,I2>(
                               xBegin, xEnd, yBegin,
                               std::max<Size>(Interpolator1::requiredPoints,
                                              Interpolator2::requiredPoints)),
              n_(n) {

                xBegin2_ = this->xBegin_ + n_;
                yBegin2_ = this->yBegin_ + n_;

                QL_REQUIRE(xBegin2_<this->xEnd_,
                           "too large n (" << n << ") for " <<
                           this->xEnd_-this->xBegin_ << "-element x sequence");

                switch (behavior) {
                  case MixedInterpolation::ShareRanges:
                    interpolation1_ = factory1.interpolate(this->xBegin_,
                                                           this->xEnd_,
                                                           this->yBegin_);
                    interpolation2_ = factory2.interpolate(this->xBegin_,
                                                           this->xEnd_,
                                                           this->yBegin_);
                    break;
                  case MixedInterpolation::SplitRanges:
                    interpolation1_ = factory1.interpolate(this->xBegin_,
                                                           this->xBegin2_+1,
                                                           this->yBegin_);
                    interpolation2_ = factory2.interpolate(this->xBegin2_,
                                                           this->xEnd_,
                                                           this->yBegin2_);
                    break;
                  default:
                    QL_FAIL("unknown mixed-interpolation behavior: " << behavior);
                }
            }
Пример #2
0
            MixedInterpolationImpl(const I1& xBegin, const I1& xEnd,
                                   const I2& yBegin, Size n,
                                   const Interpolator1& factory1 = Interpolator1(),
                                   const Interpolator2& factory2 = Interpolator2())
            : Interpolation::templateImpl<I1,I2>(xBegin, xEnd, yBegin),
              n_(n) {

                xBegin2_ = this->xBegin_+n;

                QL_REQUIRE(xBegin2_<this->xEnd_,
                           "too large n (" << n << ") for " <<
                           this->xEnd_-this->xBegin_ << "-element x sequence");

                interpolation1_ = factory1.interpolate(this->xBegin_,
                                                       this->xEnd_,
                                                       this->yBegin_);
                interpolation2_ = factory2.interpolate(this->xBegin_,
                                                       this->xEnd_,
                                                       this->yBegin_);
            }