Пример #1
0
 Y interpolate(const X&x) const {
     if (mElements.size() == 0) return Y();
 
     typename std::vector<element_type>::const_iterator it;
     it = std::lower_bound(mElements.begin(), mElements.end(), element_type(x));
     if (it != mElements.begin()) {
         it--;
     }   
     
     return it->eval(x);
 }
Пример #2
0
        /* Evaluate at multiple locations, assuming xx is sorted ascending */
        std::vector<Y> interpolate(const std::vector<X>& xx) const {
            if (mElements.size() == 0) return std::vector<Y>(xx.size());
        
            typename std::vector<X>::const_iterator it;
            typename std::vector<element_type>::const_iterator it2;
            it2 = mElements.begin();
            std::vector<Y> ys;
            for (it = xx.begin(); it != xx.end(); it++) {
                it2 = std::lower_bound(it2, mElements.end(), element_type(*it));
                if (it2 != mElements.begin()) {
                    it2--;
                }
                
                ys.push_back(it2->eval(*it));
            }

            return ys;
        }