Skip to content

Commit

Permalink
add more division overloads to support mccormick atan etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkichler committed Aug 22, 2024
1 parent 72cade8 commit 37c7791
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/mccormick/mccormick.cu
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ constexpr auto f(auto x, auto y)
// auto a = log(x);
// auto a = recip(x);
// auto a = cos(x);
auto a = tanh(x);
// auto a = tanh(x);
auto a = atan(x);
// auto a = asin(x);
// auto a = acos(x);
// auto a = pown(x, 3);
// auto a = pown(x, 4);
// auto a = pow(x, 4);
Expand Down
24 changes: 24 additions & 0 deletions include/cutangent/arithmetic/basic.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,30 @@ fn tangent<T> operator/(tangent<T> a, tangent<T> b)
return { a.v / b.v, (a.d * b.v - a.v * b.d) / (b.v * b.v) };
}

template<typename T>
fn tangent<T> operator/(T a, tangent<T> b)
{
return { a / b.v, (-a * b.d) / (b.v * b.v) };
}

template<typename T>
fn tangent<T> operator/(tangent<T> a, T b)
{
return { a.v / b, a.d / b };
}

template<typename T>
fn tangent<T> operator/(std::integral auto a, tangent<T> b)
{
return { a / b.v, (-a * b.d) / (b.v * b.v) };
}

template<typename T>
fn tangent<T> operator/(tangent<T> a, std::integral auto b)
{
return { a.v / b, a.d / b };
}

template<typename T>
fn tangent<T> max(tangent<T> a, tangent<T> b)
{
Expand Down

0 comments on commit 37c7791

Please sign in to comment.