--- trunk/src/math/CubicSpline.hpp 2012/08/22 02:28:28 1782 +++ trunk/src/math/CubicSpline.hpp 2015/03/03 15:22:26 2057 @@ -35,7 +35,7 @@ * * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). - * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ @@ -56,20 +56,36 @@ namespace OpenMD { virtual ~CubicSpline() {} void addPoint(const RealType xp, const RealType yp); void addPoints(const vector& xps, const vector& yps); - RealType getValueAt(RealType t); - pair getValueAndDerivativeAt(RealType t); + RealType getValueAt(const RealType& t); + pair getLimits(); + void getValueAt(const RealType& t, RealType& v); + void getValueAndDerivativeAt(const RealType& t, RealType& v, RealType& d); private: void generate(); + std::vector sort_permutation(std::vector& v); + std::vector apply_permutation(std::vector const& v, + std::vector const& p); + bool isUniform; bool generated; - RealType dx; - int n; - vector > data_; + RealType dx, dt, yval, dydx; + int n, j; + vector x_; + vector y_; vector b; vector c; vector d; }; + + class Comparator{ + std::vector& _v; + public: + Comparator(std::vector& v) : _v(v) {} + bool operator()(size_t i, size_t j){ + return _v[i] < _v[j]; + } + }; } #endif