-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactor spline interpolation in Spline2D class
- Loading branch information
Showing
2 changed files
with
51 additions
and
36 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/pyinterp/core/include/pyinterp/detail/interpolation/factory_1d.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
#include <stdexcept> | ||
|
||
#include "pyinterp/detail/interpolation/akima.hpp" | ||
#include "pyinterp/detail/interpolation/akima_periodic.hpp" | ||
#include "pyinterp/detail/interpolation/cspline.hpp" | ||
#include "pyinterp/detail/interpolation/cspline_periodic.hpp" | ||
#include "pyinterp/detail/interpolation/linear.hpp" | ||
#include "pyinterp/detail/interpolation/polynomial.hpp" | ||
#include "pyinterp/detail/interpolation/steffen.hpp" | ||
|
||
namespace pyinterp::detail::interpolation { | ||
|
||
template <typename T> | ||
static inline auto factory_1d(const std::string &kind) | ||
-> std::unique_ptr<Interpolator1D<T>> { | ||
if (kind == "linear") { | ||
return std::make_unique<Linear<T>>(); | ||
} | ||
if (kind == "polynomial") { | ||
return std::make_unique<Polynomial<T>>(); | ||
} | ||
if (kind == "c_spline") { | ||
return std::make_unique<CSpline<T>>(); | ||
} | ||
if (kind == "c_spline_periodic") { | ||
return std::make_unique<CSplinePeriodic<T>>(); | ||
} | ||
if (kind == "akima") { | ||
return std::make_unique<Akima<T>>(); | ||
} | ||
if (kind == "akima_periodic") { | ||
return std::make_unique<AkimaPeriodic<T>>(); | ||
} | ||
if (kind == "steffen") { | ||
return std::make_unique<Steffen<T>>(); | ||
} | ||
throw std::invalid_argument("Invalid interpolation type: " + kind); | ||
} | ||
|
||
} // namespace pyinterp::detail::interpolation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters