Logo Search packages:      
Sourcecode: quantlib version File versions

Real QuantLib::SampledCurve::secondDerivativeAtCenter (  )  const

Todo:
replace or complement with a more general function secondDerivativeAt(spot)

Definition at line 46 of file sampledcurve.cpp.

References QL_REQUIRE.

                                                      {
        QL_REQUIRE(size()>=4,
                   "the size of the curve must be at least 4");
        Size jmid = size()/2;
        if (size() % 2 == 1) {
            Real deltaPlus = (values_[jmid+1]-values_[jmid])/
                (grid_[jmid+1]-grid_[jmid]);
            Real deltaMinus = (values_[jmid]-values_[jmid-1])/
                (grid_[jmid]-grid_[jmid-1]);
            Real dS = (grid_[jmid+1]-grid_[jmid-1])/2.0;
            return (deltaPlus-deltaMinus)/dS;
        } else {
            Real deltaPlus = (values_[jmid+1]-values_[jmid-1])/
                (grid_[jmid+1]-grid_[jmid-1]);
            Real deltaMinus = (values_[jmid]-values_[jmid-2])/
                (grid_[jmid]-grid_[jmid-2]);
            return (deltaPlus-deltaMinus)/
                (grid_[jmid]-grid_[jmid-1]);
        }
    }


Generated by  Doxygen 1.6.0   Back to index