Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Make lerp usable on device #352

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions include/cuda/std/detail/libcxx/include/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT

#if _LIBCUDACXX_STD_VER > 17
template <typename _Fp>
constexpr
_Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
_LIBCUDACXX_INLINE_VISIBILITY
constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
return __t * __b + (1 - __t) * __a;

Expand All @@ -670,12 +670,15 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
return __x < __b ? __x : __b;
}

_LIBCUDACXX_INLINE_VISIBILITY
constexpr float
lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); }

_LIBCUDACXX_INLINE_VISIBILITY
constexpr double
lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }

_LIBCUDACXX_INLINE_VISIBILITY
constexpr long double
lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }

Expand Down