Debian Codegraph @

packages/kokkos-kernels/batched/dense/impl/KokkosBatched_Pbtrs_Serial_Internal.hpp

raw
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16
17 #ifndef KOKKOSBATCHED_PBTRS_SERIAL_INTERNAL_HPP_
18 #define KOKKOSBATCHED_PBTRS_SERIAL_INTERNAL_HPP_
19
20 #include "KokkosBatched_Util.hpp"
21 #include "KokkosBatched_Tbsv_Serial_Internal.hpp"
22
23 namespace KokkosBatched {
24 namespace Impl {
25
26 ///
27 /// Serial Internal Impl
28 /// ====================
29
30 ///
31 /// Lower
32 ///
33
34 template <typename AlgoType>
35 struct SerialPbtrsInternalLower {
36 template <typename ValueType>
37 KOKKOS_INLINE_FUNCTION static int invoke(const int an, const ValueType *KOKKOS_RESTRICT A, const int as0,
38 const int as1,
39 /**/ ValueType *KOKKOS_RESTRICT x, const int xs0, const int kd);
40 };
41
42 template <>
43 template <typename ValueType>
44 KOKKOS_INLINE_FUNCTION int SerialPbtrsInternalLower<Algo::Pbtrs::Unblocked>::invoke(const int an,
45 const ValueType *KOKKOS_RESTRICT A,
46 const int as0, const int as1,
47 /**/ ValueType *KOKKOS_RESTRICT x,
48 const int xs0, const int kd) {
49 // Solve L*X = B, overwriting B with X.
50 SerialTbsvInternalLower<Algo::Tbsv::Unblocked>::invoke(false, an, A, as0, as1, x, xs0, kd);
51
52 // Solve L**T *X = B, overwriting B with X.
53 constexpr bool do_conj = Kokkos::ArithTraits<ValueType>::is_complex;
54 SerialTbsvInternalLowerTranspose<Algo::Tbsv::Unblocked>::invoke(false, do_conj, an, A, as0, as1, x, xs0, kd);
55
56 return 0;
57 }
58
59 ///
60 /// Upper
61 ///
62
63 template <typename AlgoType>
64 struct SerialPbtrsInternalUpper {
65 template <typename ValueType>
66 KOKKOS_INLINE_FUNCTION static int invoke(const int an, const ValueType *KOKKOS_RESTRICT A, const int as0,
67 const int as1,
68 /**/ ValueType *KOKKOS_RESTRICT x, const int xs0, const int kd);
69 };
70
71 template <>
72 template <typename ValueType>
73 KOKKOS_INLINE_FUNCTION int SerialPbtrsInternalUpper<Algo::Pbtrs::Unblocked>::invoke(const int an,
74 const ValueType *KOKKOS_RESTRICT A,
75 const int as0, const int as1,
76 /**/ ValueType *KOKKOS_RESTRICT x,
77 const int xs0, const int kd) {
78 // Solve U**T *X = B, overwriting B with X.
79 constexpr bool do_conj = Kokkos::ArithTraits<ValueType>::is_complex;
80 SerialTbsvInternalUpperTranspose<Algo::Tbsv::Unblocked>::invoke(false, do_conj, an, A, as0, as1, x, xs0, kd);
81
82 // Solve U*X = B, overwriting B with X.
83 SerialTbsvInternalUpper<Algo::Tbsv::Unblocked>::invoke(false, an, A, as0, as1, x, xs0, kd);
84
85 return 0;
86 }
87
88 } // namespace Impl
89 } // namespace KokkosBatched
90
91 #endif // KOKKOSBATCHED_PBTRS_SERIAL_INTERNAL_HPP_