From 98b26696fa78261a0de756ece167224102b2172e Mon Sep 17 00:00:00 2001 From: Thomas Oberbichler Date: Tue, 9 Jun 2020 21:47:54 +0200 Subject: [PATCH] Add variables --- include/hyperjet/detail/space.h | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/hyperjet/detail/space.h b/include/hyperjet/detail/space.h index ff7d210..3e488e1 100644 --- a/include/hyperjet/detail/space.h +++ b/include/hyperjet/detail/space.h @@ -47,6 +47,20 @@ struct Space<0, TScalar, TSize> { return value; } + template + HYPERJET_INLINE static Eigen::Matrix variables(Eigen::Matrix value) + { + static_assert(-1 <= TSize); + + Eigen::Matrix result; + + for (index i = 0; i < TSize; i++) { + result(i) = variable(TOffset + i, value(i)); + } + + return result; + } + static TScalar f(const Scalar& variable) { return variable; @@ -114,6 +128,20 @@ struct Space<1, TScalar, TSize> { return result; } + template + HYPERJET_INLINE static Eigen::Matrix variables(Eigen::Matrix value) + { + static_assert(-1 <= TSize); + + Eigen::Matrix result; + + for (index i = 0; i < TSize; i++) { + result(i) = variable(TOffset + i, value(i)); + } + + return result; + } + static TScalar f(const Scalar& variable) { return variable.f(); @@ -187,6 +215,20 @@ struct Space<2, TScalar, TSize> { return result; } + template + HYPERJET_INLINE static Eigen::Matrix variables(Eigen::Matrix value) + { + static_assert(-1 <= TSize); + + Eigen::Matrix result; + + for (index i = 0; i < TSize; i++) { + result(i) = variable(TOffset + i, value(i)); + } + + return result; + } + static TScalar f(const Scalar& variable) { return variable.f();