8#include <KokkosBlas2_gemv.hpp>
9#include <Kokkos_Core.hpp>
28template <KokkosViewRank<1> SourceType, KokkosViewRank<1> OffsType,
29 KokkosArray AxisType,
int_t dim = AxisType::size()>
32 AxisType &activeAxis) {
34 Kokkos::Array<fp_t, dim> distances;
35 for (
int_t axis = 0; axis < dim; ++axis) {
36 if (!activeAxis[axis]) {
40 auto min_max_pair =
RbfPumMinMax(offs, [=](
const int &i,
const int &j) {
41 return src(i)[axis] < src(j)[axis];
43 const fp_t dist = Kokkos::abs(src(min_max_pair.second)[axis] -
44 src(min_max_pair.first)[axis]);
45 distances[axis] = dist;
49 for (
int_t axis = 0; axis < dim; ++axis) {
50 if (distances[axis] < min) {
51 min = distances[axis];
55 activeAxis[min_i] =
false;
70template <KokkosViewRank<2> PViewType, KokkosViewRank<1> XViewType,
71 KokkosViewRank<1> OffsViewType, KokkosArray AxisType,
72 int_t dim = AxisType::size()>
74 const OffsViewType &XOffs,
75 AxisType &activeAxis) {
76 const int_t N = P.extent_int(0);
77 int_t active_count = 0;
78 int_t active_index[dim];
79 for (
int_t j = 0; j < dim; ++j) {
81 active_index[active_count++] = j;
84 for (
int_t i = 0; i < N; ++i) {
86 const auto x = X(XOffs(i));
87 for (
int_t k = 0; k < active_count; ++k) {
88 const int_t j = active_index[k];
108template <KokkosViewRank<2> QViewType, KokkosViewRank<1> XViewType,
109 KokkosViewRank<1> XOffsType, KokkosViewRank<1> WViewType,
110 KokkosArray AxisType,
int_t dim = AxisType::size()>
112 const XOffsType &XOffs,
114 AxisType &activeAxis) {
115 using ExecSpace =
typename QViewType::execution_space;
116 int_t poly_vals = dim + 1;
118 Kokkos::Array<fp_t, dim + 1> scratch_data;
119 for (
int i = 0; i < dim + 1; ++i) {
122 Kokkos::View<fp_t *, ExecSpace> scratch(scratch_data.data(), dim + 1);
126 auto S = Kokkos::subview(scratch, Kokkos::make_pair(0, poly_vals));
128 const fp_t condition =
130 if (condition > 1.0e5) {
137 }
while (poly_vals > 1);
149template <KokkosViewRank<2> AViewType, KokkosViewRank<1> BViewType,
150 KokkosViewRank<1> OutViewType>
151KOKKOS_FORCEINLINE_FUNCTION
void
153 namespace KB = KokkosBlas;
155 KB::SerialGemv<KB::Trans::NoTranspose, KB::Algo::Gemv::Unblocked>;
164template <KokkosViewRank<1> UViewType, KokkosViewRank<1> VViewType>
166 const VViewType &V) {
167 const int_t N = U.extent_int(0);
168 for (
int_t i = 0; i < N; ++i) {
178template <KokkosViewRank<1> UViewType, KokkosViewRank<1> VViewType>
180 const VViewType &V) {
181 const int_t N = U.extent_int(0);
182 for (
int_t i = 0; i < N; ++i) {
KOKKOS_FORCEINLINE_FUNCTION void SerialVecVecSub(UViewType &U, const VViewType &V)
Perform an inplace difference of 2 vectors such as U = U - V.
typename std::remove_cv< typename std::remove_reference< T >::type >::type base_type
Returns a type without reference or const/volatile modifiers.
KOKKOS_FORCEINLINE_FUNCTION int_t SerialFillQ(QViewType &Q, const XViewType &X, const XOffsType &XOffs, WViewType &W, AxisType &activeAxis)
Fill the polynomial augmentation matrix Q and sets activeAxis accordingly to the deactivated axis in ...
KOKKOS_FORCEINLINE_FUNCTION void SerialSVD(AViewType &A, SViewType &S, WViewType &W)
Perform a partial SVD decomposition, to fetch only the singular values of A.
KOKKOS_FUNCTION void SerialFillPoly(PViewType &P, const XViewType &X, const OffsViewType &XOffs, AxisType &activeAxis)
Fill the polynomial augmentation matrix accordingly to the activated axis in activeAxis.
KOKKOS_INLINE_FUNCTION auto RbfPumMinMax(const ViewType &v, const Comparator &op)
A reimplementation of Kokkos::MinMax which works on any backend.
KOKKOS_FORCEINLINE_FUNCTION void SerialMulMatVec(const AViewType &A, const BViewType &B, OutViewType &out)
Perform: out = Ab.
KOKKOS_FORCEINLINE_FUNCTION void SerialVecVecAdd(UViewType &U, const VViewType &V)
Perform an inplace addition of 2 vectors such as U = U + V.
KOKKOS_INLINE_FUNCTION int_t SerialDeactivateOneAxis(const SourceType &src, const OffsType &offs, AxisType &activeAxis)
Deactivate one axis, the one with the smallest range of values and returns the index of this deactiva...
KOKKOS_INLINE_FUNCTION consteval fp_t zero(void)
KOKKOS_INLINE_FUNCTION consteval fp_t epsilon(void)
KOKKOS_INLINE_FUNCTION fp_t max(void)
KOKKOS_INLINE_FUNCTION consteval fp_t one(void)