Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 0 additions & 22 deletions .github/workflows/clang-format-check.yml

This file was deleted.

2 changes: 2 additions & 0 deletions include/a2dcore.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef A2D_CORE_H
#define A2D_CORE_H

#include "a2ddefs.h"

// Key objects

#include "ad/a2dmat.h"
Expand Down
77 changes: 70 additions & 7 deletions include/a2ddefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,29 @@ A2D_FUNCTION T sin(T val) {
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T asin(T val) {
A2D_FUNCTION T cos(T val) {
#ifndef __CUDACC__
return std::asin(val);
return std::cos(val);
#else
return cuda::std::asin(val);
return cuda::std::cos(val);
#endif
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T cos(T val) {
A2D_FUNCTION T tan(T val) {
#ifndef __CUDACC__
return std::cos(val);
return std::tan(val);
#else
return cuda::std::cos(val);
return cuda::std::tan(val);
#endif
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T asin(T val) {
#ifndef __CUDACC__
return std::asin(val);
#else
return cuda::std::asin(val);
#endif
}

Expand Down Expand Up @@ -364,8 +373,62 @@ A2D_FUNCTION T atan2(T y, T x) {
#endif
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T sinh(T val) {
#ifndef __CUDACC__
return std::sinh(val);
#else
return cuda::std::sinh(val);
#endif
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T cosh(T val) {
#ifndef __CUDACC__
return std::cosh(val);
#else
return cuda::std::cosh(val);
#endif
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T tanh(T val) {
#ifndef __CUDACC__
return std::tanh(val);
#else
return cuda::std::tanh(val);
#endif
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T asinh(T val) {
#ifndef __CUDACC__
return std::asinh(val);
#else
return cuda::std::asinh(val);
#endif
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T acosh(T val) {
#ifndef __CUDACC__
return std::acosh(val);
#else
return cuda::std::acosh(val);
#endif
}

template <typename T, std::enable_if_t<is_scalar_type<T>::value, bool> = true>
A2D_FUNCTION T atanh(T val) {
#ifndef __CUDACC__
return std::atanh(val);
#else
return cuda::std::atanh(val);
#endif
}

template <class ForwardIt, class T>
A2D_FUNCTION void fill(ForwardIt first, ForwardIt last, const T &value) {
A2D_FUNCTION void fill(ForwardIt first, ForwardIt last, const T& value) {
#ifdef __CUDACC__
thrust::fill(first, last, value);
#else
Expand Down
44 changes: 22 additions & 22 deletions include/ad/a2dhadamard.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace A2D {

template <typename T, int N>
A2D_FUNCTION void VecHadamard(const Vec<T, N> &x, const Vec<T, N> &y,
Vec<T, N> &z) {
A2D_FUNCTION void VecHadamard(const Vec<T, N>& x, const Vec<T, N>& y,
Vec<T, N>& z) {
VecHadamardCore<T, N>(get_data(x), get_data(y), get_data(z));
}

Expand All @@ -34,7 +34,7 @@ class VecHadamardExpr {
static_assert((N == M && M == K), "Vector sizes must agree");

A2D_FUNCTION
VecHadamardExpr(xtype &x, ytype &y, ztype &z) : x(x), y(y), z(z) {}
VecHadamardExpr(xtype& x, ytype& y, ztype& z) : x(x), y(y), z(z) {}

A2D_FUNCTION void eval() {
VecHadamardCore<T, N>(get_data(x), get_data(y), get_data(z));
Expand Down Expand Up @@ -93,44 +93,44 @@ class VecHadamardExpr {
}
}

xtype &x;
ytype &y;
ztype &z;
xtype& x;
ytype& y;
ztype& z;
};

template <class xtype, class ytype, class ztype>
A2D_FUNCTION auto VecHadamard(ADObj<xtype> &x, ADObj<ytype> &y,
ADObj<ztype> &z) {
A2D_FUNCTION auto VecHadamard(ADObj<xtype>& x, ADObj<ytype>& y,
ADObj<ztype>& z) {
return VecHadamardExpr<ADObj<xtype>, ADObj<ytype>, ADObj<ztype>>(x, y, z);
}

template <class xtype, class ytype, class ztype>
A2D_FUNCTION auto VecHadamard(A2DObj<xtype> &x, A2DObj<ytype> &y,
A2DObj<ztype> &z) {
A2D_FUNCTION auto VecHadamard(A2DObj<xtype>& x, A2DObj<ytype>& y,
A2DObj<ztype>& z) {
return VecHadamardExpr<A2DObj<xtype>, A2DObj<ytype>, A2DObj<ztype>>(x, y, z);
}

template <class xtype, class ytype, class ztype>
A2D_FUNCTION auto VecHadamard(const xtype &x, ADObj<ytype> &y,
ADObj<ztype> &z) {
A2D_FUNCTION auto VecHadamard(const xtype& x, ADObj<ytype>& y,
ADObj<ztype>& z) {
return VecHadamardExpr<const xtype, ADObj<ytype>, ADObj<ztype>>(x, y, z);
}

template <class xtype, class ytype, class ztype>
A2D_FUNCTION auto VecHadamard(const xtype &x, A2DObj<ytype> &y,
A2DObj<ztype> &z) {
A2D_FUNCTION auto VecHadamard(const xtype& x, A2DObj<ytype>& y,
A2DObj<ztype>& z) {
return VecHadamardExpr<const xtype, A2DObj<ytype>, A2DObj<ztype>>(x, y, z);
}

template <class xtype, class ytype, class ztype>
A2D_FUNCTION auto VecHadamard(ADObj<xtype> &x, const ytype &y,
ADObj<ztype> &z) {
A2D_FUNCTION auto VecHadamard(ADObj<xtype>& x, const ytype& y,
ADObj<ztype>& z) {
return VecHadamardExpr<ADObj<xtype>, const ytype, ADObj<ztype>>(x, y, z);
}

template <class xtype, class ytype, class ztype>
A2D_FUNCTION auto VecHadamard(A2DObj<xtype> &x, const ytype &y,
A2DObj<ztype> &z) {
A2D_FUNCTION auto VecHadamard(A2DObj<xtype>& x, const ytype& y,
A2DObj<ztype>& z) {
return VecHadamardExpr<A2DObj<xtype>, const ytype, A2DObj<ztype>>(x, y, z);
}

Expand All @@ -150,15 +150,15 @@ class VecHadamardTest : public A2DTest<T, Vec<T, N>, Vec<T, N>, Vec<T, N>> {
}

// Evaluate the operation
Output eval(const Input &x) {
Output eval(const Input& x) {
Vec<T, N> A, B, C;
x.get_values(A, B);
VecHadamard(A, B, C);
return MakeVarTuple<T>(C);
}

// Compute the derivative
void deriv(const Output &seed, const Input &x, Input &g) {
void deriv(const Output& seed, const Input& x, Input& g) {
ADObj<Vec<T, N>> A, B, C;
x.get_values(A.value(), B.value());
auto stack = MakeStack(VecHadamard(A, B, C));
Expand All @@ -168,8 +168,8 @@ class VecHadamardTest : public A2DTest<T, Vec<T, N>, Vec<T, N>, Vec<T, N>> {
}

// Compute the second-derivative
void hprod(const Output &seed, const Output &hval, const Input &x,
const Input &p, Input &h) {
void hprod(const Output& seed, const Output& hval, const Input& x,
const Input& p, Input& h) {
A2DObj<Vec<T, N>> A, B, C;
x.get_values(A.value(), B.value());
p.get_values(A.pvalue(), B.pvalue());
Expand Down
22 changes: 11 additions & 11 deletions include/ad/a2dmatinv.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ namespace A2D {
*/

template <typename T, int N>
A2D_FUNCTION void MatInv(const Mat<T, N, N> &A, Mat<T, N, N> &Ainv) {
A2D_FUNCTION void MatInv(const Mat<T, N, N>& A, Mat<T, N, N>& Ainv) {
MatInvCore<T, N>(get_data(A), get_data(Ainv));
}
template <typename T, int N>
A2D_FUNCTION void MatInv(const SymMat<T, N> &S, SymMat<T, N> &Sinv) {
A2D_FUNCTION void MatInv(const SymMat<T, N>& S, SymMat<T, N>& Sinv) {
SymMatInvCore<T, N>(get_data(S), get_data(Sinv));
}

Expand Down Expand Up @@ -56,7 +56,7 @@ class MatInvExpr {
static constexpr MatOp NORMAL = MatOp::NORMAL;
static constexpr MatOp TRANSPOSE = MatOp::TRANSPOSE;

A2D_FUNCTION MatInvExpr(Atype &A, Btype &Ainv) : A(A), Ainv(Ainv) {}
A2D_FUNCTION MatInvExpr(Atype& A, Btype& Ainv) : A(A), Ainv(Ainv) {}

A2D_FUNCTION void eval() { MatInvCore<T, N>(get_data(A), get_data(Ainv)); }

Expand Down Expand Up @@ -120,17 +120,17 @@ class MatInvExpr {
T(-1.0), temp, get_data(Ainv), GetSeed<ADseed::h>::get_data(A));
}

Atype &A;
Btype &Ainv;
Atype& A;
Btype& Ainv;
};

template <class Atype, class Btype>
A2D_FUNCTION auto MatInv(ADObj<Atype> &A, ADObj<Btype> &Ainv) {
A2D_FUNCTION auto MatInv(ADObj<Atype>& A, ADObj<Btype>& Ainv) {
return MatInvExpr<ADObj<Atype>, ADObj<Btype>>(A, Ainv);
}

template <class Atype, class Btype>
A2D_FUNCTION auto MatInv(A2DObj<Atype> &A, A2DObj<Btype> &Ainv) {
A2D_FUNCTION auto MatInv(A2DObj<Atype>& A, A2DObj<Btype>& Ainv) {
return MatInvExpr<A2DObj<Atype>, A2DObj<Btype>>(A, Ainv);
}

Expand All @@ -150,7 +150,7 @@ class MatInvTest : public A2DTest<T, Mat<T, N, N>, Mat<T, N, N>> {
}

// Evaluate the matrix-matrix product
Output eval(const Input &x) {
Output eval(const Input& x) {
Mat<T, N, N> A;
Mat<T, N, N> B;
x.get_values(A);
Expand All @@ -159,7 +159,7 @@ class MatInvTest : public A2DTest<T, Mat<T, N, N>, Mat<T, N, N>> {
}

// Compute the derivative
void deriv(const Output &seed, const Input &x, Input &g) {
void deriv(const Output& seed, const Input& x, Input& g) {
ADObj<Mat<T, N, N>> A;
ADObj<Mat<T, N, N>> B;

Expand All @@ -171,8 +171,8 @@ class MatInvTest : public A2DTest<T, Mat<T, N, N>, Mat<T, N, N>> {
}

// Compute the second-derivative
void hprod(const Output &seed, const Output &hval, const Input &x,
const Input &p, Input &h) {
void hprod(const Output& seed, const Output& hval, const Input& x,
const Input& p, Input& h) {
A2DObj<Mat<T, N, N>> A;
A2DObj<Mat<T, N, N>> B;

Expand Down
Loading
Loading