00001 #ifndef __GENERIC_SPLINE_H__
00002 #define __GENERIC_SPLINE_H__
00003
00004 #include "func_expansion1d.h"
00005 #include "tnt_array1d.h"
00006 #include "message.h"
00007
00008 using namespace TNT;
00009
00010 class CGenericSpline1d: public CBasisFunctionExpansion1d{
00011 public:
00012 Array1D<double> knots;
00013 int spline_degree;
00014
00015
00016 CGenericSpline1d(int _l=0, int _m=0, bool r=true, int N=1, double _xmin=0., double _xmax=1.0,int deg=0):
00017 CBasisFunctionExpansion1d(_l,_m,r,N,_xmin,_xmax),knots(0),spline_degree(deg){}
00018 CGenericSpline1d(const CGenericSpline1d& h):
00019 CBasisFunctionExpansion1d(h), knots(h.knots){}
00020
00021
00022 bool Read(const parameterMap& m);
00023 bool Write(parameterMap& m);
00024
00025
00026 void CopyState(const CGenericSpline1d& a);
00027
00028
00029 double basisFunction(double, int, int) const{
00030 throw MESSAGE << "Don't use CGenericSpline1d::basisFunction directly, override it in derived class!" <<ENDM_FATAL;
00031 return 0.0;
00032 }
00033 virtual double getLeftSupport(int i) const{
00034 throw MESSAGE << "Don't use CGenericSpline1d::getLeftSupport directly, override it in derived class!" <<ENDM_FATAL;
00035 return 0.0;
00036 }
00037 virtual double getRightSupport(int i) const{
00038 throw MESSAGE << "Don't use CGenericSpline1d::getRightSupport directly, override it in derived class!" <<ENDM_FATAL;
00039 return 0.0;
00040 }
00041
00042
00043 int getKnotToLeft(double x) const;
00044
00046 bool setDefaultKnots( void );
00047
00049 bool setOptimalKnots(const Array1D<double>& colloc);
00050
00052 bool setDim(int ncoeffs);
00053
00055 bool checkDim(int splinedeg, int nknots, int ncoeffs) const
00056 {return (splinedeg>=0)&&(nknots>=2*splinedeg+2)&&(ncoeffs<=nknots-splinedeg-1);}
00057 };
00058
00059 #endif