PACMAN 0.1.0
Portable Algorithms for Coupling, Mapping, and Adaptive iNterpolation
Loading...
Searching...
No Matches
serial_solve.hpp
Go to the documentation of this file.
1//
2// This file is subject to the terms and conditions defined in
3// file 'LICENSE', which is part of this source code package.
4//
5
6#pragma once
7
8#include <KokkosBatched_ApplyQ_Decl.hpp>
9#include <KokkosBatched_Copy_Decl.hpp>
10#include <KokkosBatched_LU_Decl.hpp>
11#include <KokkosBatched_QR_Decl.hpp>
12#include <KokkosBatched_SVD_Decl.hpp>
13#include <KokkosBatched_SolveLU_Decl.hpp>
14#include <KokkosBatched_Trsv_Decl.hpp>
15#include <Kokkos_Core.hpp>
16
17#include "common/concepts.hpp"
18#include "common/types.hpp"
19
20namespace PACMAN {
21
22namespace RbfPum {
23
46template <KokkosViewRank<2> AViewType, KokkosViewRank<2> BViewType,
47 KokkosViewRank<1> TViewType, KokkosViewRank<2> XViewType,
48 KokkosViewRank<1> WViewType>
51 WViewType &W) {
52 namespace KB = KokkosBatched;
53 using QR = KB::SerialQR<KB::Algo::QR::Unblocked>;
54 using ApplyQ = KB::SerialApplyQ<KB::Side::Left, KB::Trans::Transpose,
55 KB::Algo::ApplyQ::Unblocked>;
56 using CopyVector = KB::SerialCopy<KB::Trans::NoTranspose>;
57 using Trsv = KB::SerialTrsv<KB::Uplo::Upper, KB::Trans::NoTranspose,
58 KB::Diag::NonUnit, KB::Algo::Trsv::Unblocked>;
59
60 QR::invoke(A, T, W);
61 CopyVector::invoke(B, X);
62 ApplyQ::invoke(A, T, X, W);
63 const int_t M = A.extent_int(1);
64 auto x = Kokkos::subview(X, Kokkos::make_pair(0, M), 0);
65 auto R = Kokkos::subview(A, Kokkos::make_pair(0, M), Kokkos::make_pair(0, M));
66 Trsv::invoke(fp_consts::one(), R, x);
67}
68
76template <KokkosViewRank<2> AViewType, KokkosViewRank<1> BViewType>
78 namespace KB = KokkosBatched;
79 using LU = KB::SerialLU<KB::Algo::LU::Unblocked>;
80 using SolveLU =
81 KB::SerialSolveLU<KB::Trans::NoTranspose, KB::Algo::SolveLU::Unblocked>;
82 LU::invoke(A);
83 SolveLU::invoke(A, B);
84}
85
100template <KokkosViewRank<2> AViewType, KokkosViewRank<1> SViewType,
101 KokkosViewRank<1> WViewType>
103 WViewType &W) {
104 namespace KB = KokkosBatched;
105 using SVD = KB::SerialSVD;
106
107 constexpr fp_t tol = fp_consts::epsilon();
108 constexpr int_t max_iters = 10000000;
109 SVD::invoke(KB::SVD_S_Tag{}, A, S, W, tol, max_iters);
110}
111
112} // namespace RbfPum
113} // namespace PACMAN
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_FORCEINLINE_FUNCTION void SerialSolveLU(AViewType &A, BViewType &B)
Solves AX=B for X using a LU factorization on A.
KOKKOS_FORCEINLINE_FUNCTION auto SerialSolveQR(AViewType &A, const BViewType &B, TViewType &T, XViewType &X, WViewType &W)
Solves AX=B for X using a QR factorization on A.
KOKKOS_INLINE_FUNCTION consteval fp_t epsilon(void)
Definition types.hpp:98
KOKKOS_INLINE_FUNCTION consteval fp_t one(void)
Definition types.hpp:95