25KOKKOS_INLINE_FUNCTION T
28 return x >= 0.0 ? 1.0 : -1.0;
39KOKKOS_INLINE_FUNCTION
const T *
40find(
const T & target,
const T *
const begin,
const T *
const end)
50 auto mid = left + (right - left) / 2;
54 else if (*mid < target)
71KOKKOS_INLINE_FUNCTION
void
72choleskySolve(Real *
const A, Real *
const x, Real *
const b,
const unsigned int n)
74 for (
unsigned int i = 0; i < n; ++i)
76 for (
unsigned int j = 0; j <= i; ++j)
78 Real sum = A[j + n * i];
80 for (
unsigned int k = 0; k < j; ++k)
81 sum -= A[k + n * i] * A[k + n * j];
84 A[j + n * i] = ::Kokkos::sqrt(sum);
86 A[j + n * i] = sum / A[j + n * j];
90 for (
unsigned int i = 0; i < n; ++i)
94 for (
unsigned int j = 0; j < i; ++j)
95 sum -= A[j + n * i] * b[j];
97 b[i] = sum / A[i + n * i];
100 for (
int i = n - 1; i >= 0; --i)
104 for (
unsigned int j = i + 1; j < n; ++j)
105 sum -= A[i + n * j] * x[j];
107 x[i] = sum / A[i + n * i];
KOKKOS_INLINE_FUNCTION void choleskySolve(Real *const A, Real *const x, Real *const b, const unsigned int n)
Perform an in-place linear solve using Cholesky decomposition Matrix and right-hand-side vector are m...
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
KOKKOS_INLINE_FUNCTION T sign(T x)
Returns the sign of a value.