This commit is contained in:
2024-11-13 01:31:51 -06:00
parent e47540ea4d
commit 2fc47b2554
8 changed files with 888 additions and 99 deletions

View File

@@ -62,10 +62,15 @@ template <typename T> struct DormandPrince {
90730570.0 / 29380423.0, -8293050.0 / 29380423.0}}};
};
template <typename T> struct scalar_type {
template <typename T, typename = void> struct scalar_type {
using type = T;
};
template <typename T>
struct scalar_type<T, std::void_t<typename T::value_type>> {
using type = typename T::value_type;
};
template <typename T, std::size_t N> struct scalar_type<T[N]> {
using type = T;
};
@@ -269,10 +274,6 @@ inline std::floating_point auto inf_norm(std::floating_point auto v) {
return std::abs(v);
}
template <typename T> inline auto inf_norm(const OdeVector<T> &v) {
return inf_norm(static_cast<const T &>(v));
}
template <typename E> inline E inf_norm(const Vec2<E> &v) {
return std::max(std::abs(v.x), std::abs(v.y));
}
@@ -281,6 +282,10 @@ template <typename E> inline E inf_norm(const Vec3<E> &v) {
return std::max({std::abs(v.x), std::abs(v.y), std::abs(v.z)});
}
template <typename T> inline auto inf_norm(const OdeVector<T> &v) {
return inf_norm(static_cast<const T &>(v));
}
} // namespace func
template <typename Vector, typename Scalar = scalar_type_t<Vector>,