Skip to content

Commit 7e66fa0

Browse files
authored
Fix cube root derivative sign (#1166)
I had noticed the comment didn't match the code and updated the code not realizing it was the comment that was wrong ... Signed-off-by: Christopher Kulla <ckulla@gmail.com>
1 parent 0d198ef commit 7e66fa0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/include/OSL/dual.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,13 +1237,13 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P> inversesqrt (const Dual<T,P> &a)
12371237
return result;
12381238
}
12391239

1240-
// f(x) = cbrt(x), f'(x) = -1/(3*x^(2/3))
1240+
// f(x) = cbrt(x), f'(x) = 1/(3*x^(2/3))
12411241
template<class T, int P>
12421242
OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P> cbrt (const Dual<T,P> &a)
12431243
{
12441244
if (OSL_LIKELY(a.val() != T(0))) {
12451245
T f = std::cbrt(a.val());
1246-
T df = T(-1) / (T(3) * f * f);
1246+
T df = T(1) / (T(3) * f * f);
12471247
return dualfunc(a, f, df);
12481248
}
12491249
return Dual<T,P> (T(0));
@@ -1254,7 +1254,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P> fast_cbrt (const Dual<T,P> &a)
12541254
{
12551255
if (OSL_LIKELY(a.val() != T(0))) {
12561256
T f = OIIO::fast_cbrt(float(a.val())); // float version!
1257-
T df = T(-1) / (T(3) * f * f);
1257+
T df = T(1) / (T(3) * f * f);
12581258
return dualfunc(a, f, df);
12591259
}
12601260
return Dual<T,P> (T(0));

0 commit comments

Comments
 (0)