Skip to content

Commit

Permalink
Improve smooth absolute value function
Browse files Browse the repository at this point in the history
  • Loading branch information
fdevinc committed Feb 1, 2024
1 parent 97d4166 commit 496ed1e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/ungar/utils/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ namespace Concepts {

template <typename _ComposableVector>
concept ComposableVector = Ungar::Concepts::DenseMatrixExpression<_ComposableVector> ||
Ungar::Concepts::Scalar<std::remove_cvref_t<_ComposableVector>>;
Ungar::Concepts::Scalar<std::remove_cvref_t<_ComposableVector>>;

} // namespace Concepts

Expand Down Expand Up @@ -437,7 +437,9 @@ class ComposeImpl {
return composedVector;
}

auto ToDynamic() requires ALL_FIXED_SIZES {
auto ToDynamic()
requires ALL_FIXED_SIZES
{
VectorX<ScalarType> composedVector{COMPOSED_VECTOR_SIZE};
In(composedVector);
return composedVector;
Expand Down Expand Up @@ -1013,8 +1015,9 @@ inline _Scalar Abs(const _Scalar& a) {
}

template <Concepts::Scalar _Scalar>
inline _Scalar SmoothAbs(const _Scalar& a) {
return Utils::Sqrt(Utils::Pow(a, 2) + Eigen::NumTraits<_Scalar>::epsilon());
inline _Scalar SmoothAbs(const _Scalar& a,
const _Scalar& epsilon = Eigen::NumTraits<_Scalar>::epsilon()) {
return Utils::Sqrt(Utils::Pow(a, 2) + epsilon);
}

template <typename _Matrix> // clang-format off
Expand Down

0 comments on commit 496ed1e

Please sign in to comment.