Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
Functions.h
Go to the documentation of this file.
1 
8 #ifndef __FUNCTIONS_H
9 #define __FUNCTIONS_H
10 
11 #include "../Core/SharedLibraryExportMacros.h"
12 #include "Common.h"
13 #include "Error.h"
14 //#include <solve_polynomial.h>
15 #include <cmath>
16 #include <limits>
17 #include <valarray>
18 #include <list>
19 #include <iterator>
20 #include <iostream>
21 
22 #ifndef NO_SERIALIZE
23  #include <boost/serialization/base_object.hpp>
24  #include <boost/archive/text_oarchive.hpp>
25  #include <boost/archive/text_iarchive.hpp>
26  #include <boost/serialization/export.hpp>
27 #endif
28 
29 namespace Core {
30 
31  class InterpSolutionIterator;
32 
35  template<class InputDataType, class OutputDataType>
36  class LIB_LOCAL OneArgumentFunction {
37 #ifndef NO_SERIALIZE
38  friend class boost::serialization::access;
40 
42  template<class Archive>
43  void serialize(Archive &, const unsigned int) {}
44 #endif
45  public:
47  virtual OutputDataType operator()(
48  InputDataType in_value
49  ) const =0;
50 
52  virtual InputDataType range_high() const=0;
53 
55  virtual InputDataType range_low() const=0;
56 
59  virtual InterpSolutionIterator crossings(double y=0) const =0;
60 
62  virtual ~OneArgumentFunction() {};
63  };
64 
66  class LIB_LOCAL FunctionDerivatives {
67  public:
70  virtual double order(unsigned deriv_order=1) const =0;
71 
73  virtual ~FunctionDerivatives() {};
74  };
75 
77  class LIB_LOCAL CubicSplineDerivatives : public FunctionDerivatives {
78  private:
79  double zeroth,
80  first,
81  second;
82  public:
90  double func_value,
91 
93  double first_deriv,
94 
96  double second_deriv);
97 
99  double order(unsigned deriv_order=1) const;
100  };
101 
104  class LIB_LOCAL OneArgumentDiffFunction
105  : public OneArgumentFunction<double,double> {
106  private :
107 #ifndef NO_SERIALIZE
108  friend class boost::serialization::access;
110 
113  template<class Archive>
114  void serialize(Archive & ar, const unsigned int) {
115  ar & boost::serialization::base_object<
117  >(*this);
118  }
119 #endif
120  public:
125  virtual const FunctionDerivatives *deriv(double x) const=0;
126 
127  virtual ~OneArgumentDiffFunction() {}
128  };
129 
133  class LIB_LOCAL ZeroDerivatives : public FunctionDerivatives {
134  public:
137 
139  double order(unsigned =1) const {return 0;}
140  };
141 
143  class LIB_LOCAL ZeroFunction : public OneArgumentDiffFunction {
144  private :
145 #ifndef NO_SERIALIZE
146  friend class boost::serialization::access;
148 
151  template<class Archive>
152  void serialize(Archive & ar, const unsigned int) {
153  ar & boost::serialization::base_object< OneArgumentDiffFunction >(
154  *this
155  );
156  }
157 #endif
158 
159  public:
161  virtual const FunctionDerivatives *deriv(double) const
162  {return new ZeroDerivatives;}
163 
165  double operator()(double) const {return 0;}
166 
168  double range_high() const {return Inf;}
169 
171  double range_low() const {return -Inf;}
172 
175  InterpSolutionIterator crossings(double =0) const;
176  };
177 
178 } //End Core namespace.
179 
180 #endif
181 
double order(unsigned=1) const
The deriv_order-th derivative.
Definition: Functions.h:139
const double Inf
Infinity.
Definition: Common.h:36
double range_high() const
The function is defined everywhere.
Definition: Functions.h:168
The derivatives of an identically zero quantity.
Definition: Functions.h:133
double zeroth
The value of the function.
Definition: Functions.h:79
A class representing a once differentiable function of a single argument.
Definition: Functions.h:104
virtual ~OneArgumentFunction()
Provide a virtual destructor for a virtual class.
Definition: Functions.h:62
An iterator over a set of solutions to an interpolating function.
Defines the exception hierarchy used by this code.
double operator()(double) const
The function value (=0).
Definition: Functions.h:165
void serialize(Archive &ar, const unsigned int)
Definition: Functions.h:152
A class representing arbitrary order derivatives of a function.
Definition: Functions.h:66
double range_low() const
The function is defined everywhere.
Definition: Functions.h:171
A class representing a function that is identically zero.
Definition: Functions.h:143
virtual ~FunctionDerivatives()
Clean up.
Definition: Functions.h:73
A class for the derivatives of a cubic spline (=0 for order>2).
Definition: Functions.h:77
The base class for functions which take a single argument and return a single value.
Definition: Functions.h:36
ZeroDerivatives()
Create a derivative of an identically zero quantity.
Definition: Functions.h:136
void serialize(Archive &, const unsigned int)
Serialize this function.
Definition: Functions.h:43
Declaration of some general purpose utilities.
void serialize(Archive &ar, const unsigned int)
Definition: Functions.h:114
virtual const FunctionDerivatives * deriv(double) const
See OneArgumentDiffFunction::deriv()
Definition: Functions.h:161