CARMA C++
Interpolator.h
1 #ifndef CARMA_SERVICES_INTERPOLATOR_H
2 #define CARMA_SERVICES_INTERPOLATOR_H
3 
4 #include "carma/services/Types.h"
5 #include <vector>
6 #include <cstddef>
7 
8 extern "C" {
9 #include <gsl/gsl_errno.h>
10 #include <gsl/gsl_interp.h>
11 #include <gsl/gsl_spline.h>
12 }
13 
14 
15 namespace carma {
16  namespace services {
17 
18  class Interpolator {
19  public:
20 
31  Interpolator (
32  const ::std::vector<double> & xvalue,
33  const ::std::vector<double> & yvalue,
34  const interpolationType type );
35 
36  virtual ~Interpolator ( );
37 
43  double evaluate( double x );
44 
45 
46  private:
47  void freeAllocations();
48  void freeGslAllocations();
49  void freeDoubleAllocations();
50  void initialize();
57  void setInterpType( interpolationType type );
58 
59 
60  ::gsl_interp_accel * acc_;
61  ::gsl_interp * interp_;
62  ::gsl_spline * spline_;
63  // eventually do away with these if not allowing
64  // interp type to be changed after instantiation.
65  ::std::vector<double> xval_;
66  ::std::vector<double> yval_;
67  size_t size_;
68  double * x_;
69  double * y_;
70  double answer_;
71  interpolationType interpType_;
72  }; // class Interpolator
73 
74 } // namespace services
75 } // namespace carma
76 
77 
78 #endif //CARMA_SERVICES_INTERPOLATOR_H
79 
Various type definitions for services classes.