Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
BilinearInterpolator.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2024 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // Reaktoro includes
21 #include <Reaktoro/Common/Types.hpp>
22 
23 namespace Reaktoro {
24 
27 {
28 public:
31 
37  const Vec<double>& xcoordinates,
38  const Vec<double>& ycoordinates,
39  const Vec<double>& data);
40 
46  const Vec<double>& xcoordinates,
47  const Vec<double>& ycoordinates,
48  const Vec<Vec<double>>& data);
49 
55  const Vec<double>& xcoordinates,
56  const Vec<double>& ycoordinates,
57  const Fn<double(double, double)>& function);
58 
60  auto setCoordinatesX(const Vec<double>& xcoordinates) -> void;
61 
63  auto setCoordinatesY(const Vec<double>& ycoordinates) -> void;
64 
66  auto setData(const Vec<double>& data) -> void;
67 
69  auto setData(const Vec<Vec<double>>& data) -> void;
70 
72  auto xCoordinates() const -> const Vec<double>&;
73 
75  auto yCoordinates() const -> const Vec<double>&;
76 
78  auto data() const -> const Vec<double>&;
79 
81  auto empty() const -> bool;
82 
87  auto operator()(real x, real y) const -> real;
88 
89 private:
91  Vec<double> m_xcoordinates, m_ycoordinates;
92 
94  Vec<double> m_data;
95 };
96 
98 auto operator<<(std::ostream& out, const BilinearInterpolator& interpolator) -> std::ostream&;
99 
100 } // namespace Reaktoro
A class used to calculate bilinear interpolation of data in two dimensions.
Definition: BilinearInterpolator.hpp:27
BilinearInterpolator(const Vec< double > &xcoordinates, const Vec< double > &ycoordinates, const Fn< double(double, double)> &function)
Construct a BilinearInterpolator instance with given function.
auto setCoordinatesY(const Vec< double > &ycoordinates) -> void
Set the y-coordinates of the interpolation.
BilinearInterpolator(const Vec< double > &xcoordinates, const Vec< double > &ycoordinates, const Vec< double > &data)
Construct a BilinearInterpolator instance with given data.
auto setCoordinatesX(const Vec< double > &xcoordinates) -> void
Set the x-coordinates of the interpolation.
auto empty() const -> bool
Check if the BilinearInterpolator instance is empty.
auto setData(const Vec< Vec< double >> &data) -> void
Set the data to be interpolated.
auto yCoordinates() const -> const Vec< double > &
Return the y-coordinates of the interpolation.
BilinearInterpolator()
Construct a default BilinearInterpolator instance.
BilinearInterpolator(const Vec< double > &xcoordinates, const Vec< double > &ycoordinates, const Vec< Vec< double >> &data)
Construct a BilinearInterpolator instance with given data.
auto xCoordinates() const -> const Vec< double > &
Return the x-coordinates of the interpolation.
auto data() const -> const Vec< double > &
Return the interpolation data.
auto setData(const Vec< double > &data) -> void
Set the data to be interpolated.
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
std::vector< T > Vec
Convenient alias for std::vector<T>.
Definition: Types.hpp:66
autodiff::real real
The number type used throughout the library.
Definition: Real.hpp:26
std::function< F > Fn
Convenient alias for std::function<R(Args...)>.
Definition: Types.hpp:110