Skip to content

Commit

Permalink
Add variables
Browse files Browse the repository at this point in the history
  • Loading branch information
oberbichler committed Jun 9, 2020
1 parent abb7d13 commit 98b2669
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions include/hyperjet/detail/space.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ struct Space<0, TScalar, TSize> {
return value;
}

template <index TOffset, index TSize>
HYPERJET_INLINE static Eigen::Matrix<Scalar, 1, TSize> variables(Eigen::Matrix<TScalar, 1, TSize> value)
{
static_assert(-1 <= TSize);

Eigen::Matrix<Scalar, 1, TSize> 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;
Expand Down Expand Up @@ -114,6 +128,20 @@ struct Space<1, TScalar, TSize> {
return result;
}

template <index TOffset, index TSize>
HYPERJET_INLINE static Eigen::Matrix<Scalar, 1, TSize> variables(Eigen::Matrix<TScalar, 1, TSize> value)
{
static_assert(-1 <= TSize);

Eigen::Matrix<Scalar, 1, TSize> 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();
Expand Down Expand Up @@ -187,6 +215,20 @@ struct Space<2, TScalar, TSize> {
return result;
}

template <index TOffset, index TSize>
HYPERJET_INLINE static Eigen::Matrix<Scalar, 1, TSize> variables(Eigen::Matrix<TScalar, 1, TSize> value)
{
static_assert(-1 <= TSize);

Eigen::Matrix<Scalar, 1, TSize> 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();
Expand Down

0 comments on commit 98b2669

Please sign in to comment.