PowX.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines MathFunctions::PowX.
6 
7 #pragma once
8 
9 #include <pup.h>
10 
11 #include "Options/Options.hpp"
13 #include "PointwiseFunctions/MathFunctions/MathFunction.hpp" // IWYU pragma: keep
14 #include "Utilities/TMPL.hpp"
15 
16 /// \cond
17 class DataVector;
18 /// \endcond
19 
20 namespace MathFunctions {
21 
22 /*!
23  * \ingroup MathFunctionsGroup
24  * \brief Power of X \f$f(x)=x^X\f$
25  */
26 class PowX : public MathFunction<1> {
27  public:
28  struct Power {
29  using type = int;
30  static constexpr OptionString help = {
31  "The power that the double is raised to."};
32  };
33  using options = tmpl::list<Power>;
34 
35  static constexpr OptionString help = {
36  "Raises the input value to a given power"};
37 
38  PowX() = default;
39  ~PowX() override = default;
40  PowX(const PowX& /*rhs*/) = delete;
41  PowX& operator=(const PowX& /*rhs*/) = delete;
42  PowX(PowX&& /*rhs*/) noexcept = default;
43  PowX& operator=(PowX&& /*rhs*/) noexcept = default;
44 
46 
47  explicit PowX(int power) noexcept;
48 
49  explicit PowX(CkMigrateMessage* /*unused*/) noexcept {}
50 
51  double operator()(const double& x) const noexcept override;
52  DataVector operator()(const DataVector& x) const noexcept override;
53 
54  double first_deriv(const double& x) const noexcept override;
55  DataVector first_deriv(const DataVector& x) const noexcept override;
56 
57  double second_deriv(const double& x) const noexcept override;
58  DataVector second_deriv(const DataVector& x) const noexcept override;
59 
60  double third_deriv(const double& x) const noexcept override;
61  DataVector third_deriv(const DataVector& x) const noexcept override;
62 
63  // clang-tidy: google-runtime-references
64  void pup(PUP::er& p) override; // NOLINT
65 
66  private:
67  friend bool operator==(const PowX& lhs, const PowX& rhs) noexcept;
68  template <typename T>
69  T apply_call_operator(const T& x) const noexcept;
70  template <typename T>
71  T apply_first_deriv(const T& x) const noexcept;
72  template <typename T>
73  T apply_second_deriv(const T& x) const noexcept;
74  template <typename T>
75  T apply_third_deriv(const T& x) const noexcept;
76 
77  double power_{};
78 };
79 
80 bool operator!=(const PowX& lhs, const PowX& rhs) noexcept;
81 
82 } // namespace MathFunctions
Definition: PowX.hpp:28
Definition: MathFunction.hpp:27
double third_deriv(const double &x) const noexcept override
Returns the third derivative at &#39;x&#39;.
Definition: PowX.cpp:34
Defines classes and functions for making classes creatable from input files.
Defines macros to allow serialization of abstract template base classes.
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
double operator()(const double &x) const noexcept override
Returns the function value at the coordinate &#39;x&#39;.
Definition: PowX.cpp:13
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
Holds classes implementing MathFunction (functions ).
Definition: Gaussian.cpp:11
Defines base-class MathFunction.
Power of X .
Definition: PowX.hpp:26
Stores a collection of function values.
Definition: DataVector.hpp:46
Wraps the template metaprogramming library used (brigand)
double first_deriv(const double &x) const noexcept override
Returns the first derivative at &#39;x&#39;.
Definition: PowX.cpp:20
double second_deriv(const double &x) const noexcept override
Returns the second derivative at &#39;x&#39;.
Definition: PowX.cpp:27