#ifndef _SplineSolver_Spline_h_ #define _SplineSolver_Spline_h_ #include #include #include #include namespace Spline { typedef unsigned char dim_t; enum BoundaryConditionType { eNatural = 0, /* minimize total curvature */ ePeriodic = 1, /* for a polar coordinate */ eFirstDerivative = 2, /* set 1st derivatives at endpoints */ eSecondDerivative = 3 /* set 2nd derivatives at endpoints */ }; struct BoundaryCondition { BoundaryCondition(const BoundaryConditionType type = eNatural, const double vLeft = 0.0, const double vRight = 0.0) : fType(type), fLeft(vLeft), fRight(vRight) { } inline bool operator==(const BoundaryConditionType type) const { return fType == type; } BoundaryConditionType fType; double fLeft; double fRight; }; /// Computes B-spline coefficients template class Solver { public: /// Prepare inversion matrix void Configure(const dim_t idim, const AKnotVector& xs, const std::vector& bs, const BoundaryCondition& bc) { fBCs[idim] = bc; fSizes[idim] = bs.size(); if (fBuffer.size() < bs.size()) fBuffer.resize(bs.size()); const size_t n = bs.size(); fInv[idim].resize(boost::extents[n][n]); for (size_t i=0;i fBuffer; boost::multi_array fInv[ADimension]; }; } // NS Spline #endif