00001
00002
00003
00004
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _BSPLINEBASE_IFACE_ID
00027 #define _BSPLINEBASE_IFACE_ID "$Id: BSpline.h,v 1.21 2005/05/27 21:16:23 granger Exp $"
00028
00040 #if WIN32
00041 # ifndef BSPLINE_DLL_
00042 # define BSPLINE_DLL_ __declspec(dllimport)
00043 # endif
00044 #else
00045 # define BSPLINE_DLL_
00046 #endif
00047
00048
00049 template <class T> class BSpline;
00050
00051
00052
00053
00054 template <class T> struct BSplineBaseP;
00055
00187 template <class T>
00188 class BSPLINE_DLL_ BSplineBase
00189 {
00190 public:
00191
00192 typedef T datum_type;
00193
00195 static const char *ImplVersion();
00196
00198 static const char *IfaceVersion();
00199
00205 static bool Debug (int on = -1);
00206
00210 enum BoundaryConditionTypes
00211 {
00213 BC_ZERO_ENDPOINTS = 0,
00215 BC_ZERO_FIRST = 1,
00217 BC_ZERO_SECOND = 2
00218 };
00219
00220 public:
00221
00228 BSplineBase (const T *x, int nx,
00229 double wl, int bc_type = BC_ZERO_SECOND,
00230 int num_nodes = 0);
00231
00233 BSplineBase (const BSplineBase &);
00234
00260 bool setDomain (const T *x, int nx, double wl,
00261 int bc_type = BC_ZERO_SECOND,
00262 int num_nodes = 0);
00263
00271 BSpline<T> *apply (const T *y);
00272
00278 const T *nodes (int *nnodes);
00279
00283 int nNodes () { return M+1; }
00284
00288 int nX () { return NX; }
00289
00291 T Xmin () { return xmin; }
00292
00294 T Xmax () { return xmin + (M * DX); }
00295
00300 double Alpha (double wavelength);
00301
00305 double Alpha () { return alpha; }
00306
00315 bool ok () { return OK; }
00316
00317 virtual ~BSplineBase();
00318
00319 protected:
00320
00321 typedef BSplineBaseP<T> Base;
00322
00323
00324 double waveLength;
00325 int NX;
00326 int K;
00327 int BC;
00328
00329
00330 T xmax;
00331 T xmin;
00332 int M;
00333 double DX;
00334 double alpha;
00335 bool OK;
00336 Base *base;
00337
00338
00339 bool Setup (int num_nodes = 0);
00340 void calculateQ ();
00341 double qDelta (int m1, int m2);
00342 double Beta (int m);
00343 void addP ();
00344 bool factor ();
00345 double Basis (int m, T x);
00346 double DBasis (int m, T x);
00347
00348 static const double BoundaryConditions[3][4];
00349 static const double PI;
00350
00351 double Ratiod (int&, double &, double &);
00352 };
00353
00354
00355 template <class T> struct BSplineP;
00356
00357
00363 template <class T>
00364 class BSPLINE_DLL_ BSpline : public BSplineBase<T>
00365 {
00366 public:
00390 BSpline (const T *x, int nx,
00391 const T *y,
00392 double wl,
00393 int bc_type = BSplineBase<T>::BC_ZERO_SECOND,
00394 int num_nodes = 0);
00395
00400 BSpline (BSplineBase<T> &base, const T *y);
00401
00409 bool solve (const T *y);
00410
00419 const T *curve (int *nx = 0);
00420
00425 T evaluate (T x);
00426
00431 T slope (T x);
00432
00437 T coefficient (int n);
00438
00439 virtual ~BSpline();
00440
00441 using BSplineBase<T>::Debug;
00442
00443 protected:
00444
00445 using BSplineBase<T>::OK;
00446 using BSplineBase<T>::M;
00447 using BSplineBase<T>::NX;
00448 using BSplineBase<T>::DX;
00449 using BSplineBase<T>::base;
00450 using BSplineBase<T>::xmin;
00451 using BSplineBase<T>::xmax;
00452
00453
00454 BSplineP<T> *s;
00455 T mean;
00456
00457 };
00458
00459 #endif // !defined _BSPLINEBASE_IFACE_ID