cubic_spline.hpp
Go to the documentation of this file.
1
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11
12 #ifndef ECL_GEOMETRY_CUBIC_SPLINE_HPP_
13 #define ECL_GEOMETRY_CUBIC_SPLINE_HPP_
14
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18
19 #include "polynomial.hpp"
20 #include <ecl/config/macros.hpp>
21 #include <ecl/concepts/macros.hpp>
22 #include <ecl/concepts/streams.hpp>
24 #include <ecl/containers/array.hpp>
27
28 /*****************************************************************************
29 ** Namespaces
30 *****************************************************************************/
31
32 namespace ecl {
33
34 /*****************************************************************************
35 ** Forward Declarations
36 *****************************************************************************/
37
38 class CubicSpline;
39
40 namespace blueprints {
41
42 class C2CubicSpline;
43 class DerivativeHeuristicCubicSpline;
44
45 } // namespace blueprints
46
47 /*****************************************************************************
48 ** BluePrintFactory
49 *****************************************************************************/
58 template<>
60  public:
72  static blueprints::C2CubicSpline Natural(const Array<double>& x_set, const Array<double>& y_set);
85  static blueprints::C2CubicSpline ContinuousDerivatives(
86  const Array<double>& x_set, const Array<double>& y_set, const double ydot_0, const double ydot_f);
100  static blueprints::DerivativeHeuristicCubicSpline DerivativeHeuristic(
101  const Array<double>& x_set, const Array<double>& y_set, const double ydot_0, const double ydot_f);
102
103  virtual ~BluePrintFactory() {}
104 };
105
106 /*****************************************************************************
107 ** Interface [CubicSpline]
108 *****************************************************************************/
123 class ECL_PUBLIC CubicSpline : public BluePrintFactory< CubicSpline > {
124  public:
125  /******************************************
126  ** Constructors
127  *******************************************/
133  CubicSpline () {};
160  template<typename Derived>
161  CubicSpline(const BluePrint< Derived > &blueprint) {
162  blueprint.implementApply(*this);
163  }
164  virtual ~CubicSpline () {};
165
166  /******************************************
167  ** Access
168  *******************************************/
179  double operator()(const double &x) const;
188  double derivative(double x) const;
197  double dderivative(double x) const;
198
206  const Array<double>& domain() { return discretised_domain; }
215  const Array<CubicPolynomial>& polynomials() { return cubic_polynomials; }
216
217  /******************************************
218  ** Streaming
219  *******************************************/
231  template <typename OutputStream>
232  friend OutputStream& operator << (OutputStream &ostream, const CubicSpline &cubic_spline);
233
234  private:
236  // Would normally use pointers here, but the polynomials have fixed storage
237  // size, the copy cost is small and the access times will be faster this way.
239 };
240
241 /*****************************************************************************
242 ** Implementation [CubicSpline][Streaming]
243 *****************************************************************************/
244
245 template <typename OutputStream>
246 OutputStream& operator << (OutputStream &ostream, const CubicSpline &cubic_spline) {
247
249
250  for ( unsigned int i = 0; i < cubic_spline.cubic_polynomials.size(); ++i ) {
251  ostream << cubic_spline.cubic_polynomials[i] << "\n";
252  }
253  ostream.flush();
254  return ostream;
255 }
256
257 /*****************************************************************************
258 ** BluePrints
259 *****************************************************************************/
260
261 namespace blueprints {
262
263 /*****************************************************************************
264 ** Interface [C2CubicSpline]
265 *****************************************************************************/
266
276 class ECL_PUBLIC C2CubicSpline : public ecl::BluePrint<C2CubicSpline> {
277  public:
288
301  C2CubicSpline(const ecl::Array<double>& x_set, const ecl::Array<double>& y_set,
302  const double ydot_0, const double ydot_f);
303
304  virtual ~C2CubicSpline() {};
318  C2CubicSpline(const ecl::Array<double>& x_set, const ecl::Array<double>& y_set);
319
327  ecl::CubicSpline instantiate();
328
336  void apply(ecl::CubicSpline& spline) const;
337
338  private:
342 };
343
344 /*****************************************************************************
345 ** Interface [DerivativeHeuristicCubicSpline]
346 *****************************************************************************/
347
362 class ECL_PUBLIC DerivativeHeuristicCubicSpline : public ecl::BluePrint<DerivativeHeuristicCubicSpline> {
363  public:
374
389  const double ydot_0, const double ydot_f);
390
399  ecl::CubicSpline instantiate();
400
408  void apply(ecl::CubicSpline& spline) const;
409
410  private:
414 };
415
416 } // namespace blueprints
417 } // namespace ecl
418
419 #endif /* ECL_GEOMETRY_CUBIC_SPLINE_HPP_ */
Array< CubicPolynomial > cubic_polynomials
OutputStream & operator<<(OutputStream &ostream, const Array< ElementType, ArraySize > &array)
Embedded control libraries.
Blueprint for generating a cubic spline satisfying C2 constraints.
CubicSpline()
Default constructor.
virtual ~CubicSpline()
void implementApply(BaseType &object) const
const Array< double > & domain()
The discretised domain for this spline.
Representations for polynomial functions.
ecl::CubicSpline base_type
Abstract representation of the class to be instantiated/configured.
Storage container for a cubic spline interpolation.
Array< double > discretised_domain
ecl::Array< double > yddot_data
const Array< CubicPolynomial > & polynomials()
The polynomial sequence.
ecl::Array< double > x_data
#define ecl_compile_time_concept_check(Model)
ecl::CubicSpline base_type
Abstract representation of the class to be instantiated/configured.
Blueprint for generating a cubic spline satisfying C2 constraints.
C2CubicSpline()
Default constructor.
CubicSpline(const BluePrint< Derived > &blueprint)
Blueprint constructor.
#define ECL_PUBLIC
ecl::Array< double > y_data

ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Feb 28 2022 22:18:49