Stellarator-Tools
parity.hpp
Go to the documentation of this file.
1 //******************************************************************************
5 //******************************************************************************
6 
7 #ifndef parity_hpp
8 #define parity_hpp
9 
10 #include <cmath>
11 
12 //------------------------------------------------------------------------------
14 //------------------------------------------------------------------------------
15 class parity {
16 public:
17 //------------------------------------------------------------------------------
22 //------------------------------------------------------------------------------
23  virtual double f(const double x) const=0;
24 //------------------------------------------------------------------------------
29 //------------------------------------------------------------------------------
30  virtual double df(const double x) const=0;
31 };
32 
33 //------------------------------------------------------------------------------
35 //------------------------------------------------------------------------------
36 class sine : public parity {
37 public:
38 //------------------------------------------------------------------------------
43 //------------------------------------------------------------------------------
44  inline double f(const double x) const final {
45  return sin(x);
46  };
47 
48 //------------------------------------------------------------------------------
53 //------------------------------------------------------------------------------
54  inline double df(const double x) const final {
55  return cos(x);
56  };
57 };
58 
59 //------------------------------------------------------------------------------
61 //------------------------------------------------------------------------------
62 class cosine : public parity {
63 public:
64 //------------------------------------------------------------------------------
69 //------------------------------------------------------------------------------
70  inline double f(const double x) const final {
71  return cos(x);
72  };
73 
74 //------------------------------------------------------------------------------
79 //------------------------------------------------------------------------------
80  inline double df(const double x) const final {
81  return -sin(x);
82  };
83 };
84 
85 #endif
Cosine Parity function interface.
Definition: parity.hpp:62
double f(const double x) const final
Evaluate cosine function.
Definition: parity.hpp:70
double df(const double x) const final
Evaluate cosine derivative.
Definition: parity.hpp:80
Parity function interface.
Definition: parity.hpp:15
virtual double f(const double x) const =0
Evaluate parity function.
virtual double df(const double x) const =0
Evaluate parity derivative.
Sine Parity function interface.
Definition: parity.hpp:36
double f(const double x) const final
Evaluate sine function.
Definition: parity.hpp:44
double df(const double x) const final
Evaluate sine derivative.
Definition: parity.hpp:54