Alexandria  2.22.0
Please provide a description of the project.
Polynomial.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef MATHUTILS_POLYNOMIAL_H
26 #define MATHUTILS_POLYNOMIAL_H
27 
28 #include <vector>
29 
30 #include "ElementsKernel/Export.h"
31 
34 
35 namespace Euclid {
36 namespace MathUtils {
37 
43 class ELEMENTS_API Polynomial final : public Differentiable {
44 
45 public:
53  explicit Polynomial(std::vector<double> coefficients);
54 
56  virtual ~Polynomial() = default;
57 
59  const std::vector<double>& getCoefficients() const;
60 
62  double operator()(const double) const override;
63 
65  void operator()(const std::vector<double>& xs, std::vector<double>& out) const override;
66 
68  std::unique_ptr<Function> clone() const override;
69 
71  std::shared_ptr<Function> derivative() const override;
72 
74  std::shared_ptr<Function> indefiniteIntegral() const override;
75 
76 private:
80  mutable std::shared_ptr<Function> m_derivative{};
82  mutable std::shared_ptr<Function> m_indefIntegral{};
83 
84 }; // End of Polynomial
85 
86 } // namespace MathUtils
87 } // end of namespace Euclid
88 
89 #endif /* MATHUTILS_POLYNOMIAL_H */
Interface representing a differentiable function.
Represents a polynomial function.
Definition: Polynomial.h:43
std::vector< double > m_coef
The vector where the polynomial coefficients are stored.
Definition: Polynomial.h:78
virtual ~Polynomial()=default
Default destructor.
#define ELEMENTS_API
double derivative(const Function &f, const double x)