Simpatico  v1.10
CardinalBSpline.h
1 #ifndef UTIL_CARDINAL_B_SPLINE_H
2 #define UTIL_CARDINAL_B_SPLINE_H
3 
4 /*
5 * Util Package - C++ Utilities for Scientific Computation
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <util/containers/DArray.h>
12 #include <util/math/Polynomial.h>
13 #include <util/math/Rational.h>
14 #include <util/global.h>
15 
16 
17 #include <iostream>
18 
19 namespace Util
20 {
21 
43  {
44 
45  public:
46 
48 
49 
56  CardinalBSpline(int degree, bool verbose = false);
57 
62 
64 
75  Polynomial<double> const & operator [](int i) const;
76 
86  double operator ()(double x) const;
87 
91  int degree() const;
92 
93  private:
94 
102  DArray< Polynomial<double> > floatPolynomials_;
103 
111  int degree_;
112 
113  };
114 
115  /*
116  * Get polynomial with real coefficients for domain [i,i+1]
117  */
118  inline
120  { return floatPolynomials_[i]; }
121 
122  /*
123  * Get value of spline.
124  */
125  inline
126  double CardinalBSpline::operator ()(double x) const
127  {
128  if (x <= 0.0) return 0.0;
129  int i = x;
130  UTIL_ASSERT(i >= 0);
131  if (i > degree_) return 0.0;
132  return floatPolynomials_[i](x);
133  }
134 
135  /*
136  * Return degree of basis function (i.e., degree of polynomials).
137  */
138  inline
140  { return degree_; }
141 
142 }
143 #endif
A cardinal B-spline basis function.
~CardinalBSpline()
Destructor.
Polynomial< double > const & operator[](int i) const
Get Polynomial<double> object for domain [i,i+1].
File containing preprocessor macros for error handling.
CardinalBSpline(int degree, bool verbose=false)
Construct a spline basis of specified degree.
Utility classes for scientific computation.
Definition: accumulators.mod:1
double operator()(double x) const
Compute the value of the spline basis function.
Dynamically allocatable contiguous array template.
Definition: DArray.h:31
int degree() const
Return degree of basis function (i.e., degree of polynomials).
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
Definition: global.h:75