EOL BSpline Library  Version 1.6
BSplineBase.h
Go to the documentation of this file.
1 /************************************************************************
2  * Copyright 2009 University Corporation for Atmospheric Research.
3  * All rights reserved.
4  *
5  * Use of this code is subject to the standard BSD license:
6  *
7  * http://www.opensource.org/licenses/bsd-license.html
8  *
9  * See the COPYRIGHT file in the source distribution for the license text,
10  * or see this web page:
11  *
12  * http://www.eol.ucar.edu/homes/granger/bspline/doc/
13  *
14  *************************************************************************/
15 #ifndef BSPLINEBASE_H_
16 #define BSPLINEBASE_H_
17 
18 #ifndef _BSPLINEBASE_IFACE_ID
19 #define _BSPLINEBASE_IFACE_ID "$Id: BSpline.h 6353 2008-05-05 19:30:48Z martinc $"
20 #endif
21 
28 template <class T> class BSpline;
29 
30 /*
31  * Opaque member structure to hide the matrix implementation.
32  */
33 template <class T> struct BSplineBaseP;
34 
168 template <class T>
170 {
171 public:
172  // Datum type
173  typedef T datum_type;
174 
176  static const char *ImplVersion();
177 
179  static const char *IfaceVersion();
180 
186  static bool Debug (int on = -1);
187 
192  {
199  };
200 
201 public:
202 
209  BSplineBase (const T *x, int nx,
210  double wl, int bc_type = BC_ZERO_SECOND,
211  int num_nodes = 0);
212 
214  BSplineBase (const BSplineBase &);
215 
241  bool setDomain (const T *x, int nx, double wl,
242  int bc_type = BC_ZERO_SECOND,
243  int num_nodes = 0);
244 
252  BSpline<T> *apply (const T *y);
253 
259  const T *nodes (int *nnodes);
260 
264  int nNodes () { return M+1; }
265 
269  int nX () { return NX; }
270 
272  T Xmin () { return xmin; }
273 
275  T Xmax () { return xmin + (M * DX); }
276 
281  double Alpha (double wavelength);
282 
286  double Alpha () { return alpha; }
287 
296  bool ok () { return OK; }
297 
298  virtual ~BSplineBase();
299 
300 protected:
301 
302  typedef BSplineBaseP<T> Base;
303 
304  // Provided
305  double waveLength; // Cutoff wavelength (l sub c)
306  int NX;
307  int K; // Degree of derivative constraint (currently fixed at 2)
308  int BC; // Boundary conditions type (0,1,2)
309 
310  // Derived
311  T xmax;
312  T xmin;
313  int M; // Number of intervals (M+1 nodes)
314  double DX; // Interval length in same units as X
315  double alpha;
316  bool OK;
317  Base *base; // Hide more complicated state members
318  // from the public interface.
319 
320  bool Setup (int num_nodes = 0);
321  void calculateQ ();
322  double qDelta (int m1, int m2);
323  double Beta (int m);
324  void addP ();
325  bool factor ();
326  double Basis (int m, T x);
327  double DBasis (int m, T x);
328 
329  static const double BoundaryConditions[3][4];
330  static const double PI;
331 
332  double Ratiod (int&, double &, double &);
333 };
334 
335 #endif /*BSPLINEBASE_H_*/
Definition: BSplineBase.cpp:90
The base class for a spline object containing the nodes for a given domain, cutoff wavelength...
Definition: BSplineBase.h:169
double Alpha()
Return alpha currently in use by this domain.
Definition: BSplineBase.h:286
Set the second derivative to zero.
Definition: BSplineBase.h:198
BSplineBase(const T *x, int nx, double wl, int bc_type=BC_ZERO_SECOND, int num_nodes=0)
Construct a spline domain for the given set of x values, cutoff wavelength, and boundary condition ty...
Definition: BSplineBase.cpp:171
T Xmax()
Maximum x value found.
Definition: BSplineBase.h:275
int nX()
Number of original x values.
Definition: BSplineBase.h:269
bool ok()
Return the current state of the object, either ok or not ok.
Definition: BSplineBase.h:296
BSpline< T > * apply(const T *y)
Create a BSpline smoothed curve for the given set of NX y values.
Definition: BSplineBase.cpp:289
Set the first derivative of the spline to zero at the endpoints.
Definition: BSplineBase.h:196
Set the endpoints of the spline to zero.
Definition: BSplineBase.h:194
BoundaryConditionTypes
Boundary condition types.
Definition: BSplineBase.h:191
const T * nodes(int *nnodes)
Return array of the node coordinates.
Definition: BSplineBase.cpp:681
static const char * IfaceVersion()
Return a string describing the interface version.
Definition: BSplineBase.cpp:141
static bool Debug(int on=-1)
Call this class method with a value greater than zero to enable debug messages, or with zero to disab...
Definition: BSplineBase.cpp:124
static const char * ImplVersion()
Return a string describing the implementation version.
Definition: BSplineBase.cpp:135
bool setDomain(const T *x, int nx, double wl, int bc_type=BC_ZERO_SECOND, int num_nodes=0)
Change the domain of this base.
Definition: BSplineBase.cpp:183
int nNodes()
Return the number of nodes (one more than the number of intervals).
Definition: BSplineBase.h:264
Used to evaluate a BSpline.
Definition: BSpline.h:33
T Xmin()
Minimum x value found.
Definition: BSplineBase.h:272