Debian Codegraph @

packages/kokkos-kernels/batched/dense/src/KokkosBatched_SVD_Decl.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 #ifndef KOKKOSBATCHED_SVD_DECL_HPP
17 #define KOKKOSBATCHED_SVD_DECL_HPP
18
19 /// \author Brian Kelley ([email protected])
20
21 #include "KokkosBatched_Util.hpp"
22 #include "KokkosBatched_Vector.hpp"
23
24 namespace KokkosBatched {
25
26 /// Given a general matrix A (m x n), compute the full singular value
27 /// decomposition (SVD): U * diag(s) * V^T = A. U/V are orthogonal and s
28 /// contains nonnegative values in descending order.
29 ///
30 /// Currently only supports real-valued matrices.
31 ///
32 /// Parameters:
33 /// [in] A
34 /// General matrix (rank 2 view), m x n.
35 /// The contents of A are overwritten and undefined after calling this
36 /// function.
37 /// [out] U
38 /// m left singular vectors (in columns). Dimensions m*m.
39 /// [out] Vt
40 /// n right singular vectors (in rows). Dimensions n*n.
41 /// [out] s
42 /// min(m, n) singular values.
43 /// [in] W
44 /// 1D contiguous workspace. The required size is max(m, n).
45 ///
46 /// Preconditions:
47 /// m == A.extent(0) == U.extent(0) == U.extent(1)
48 /// n == A.extent(1) == V.extent(0) == V.extent(1)
49 /// min(m, n) == s.extent(0)
50 /// W.extent(0) >= max(m, n)
51 /// W.stride(0) == 1 (contiguous)
52
53 struct SVD_USV_Tag {};
54 struct SVD_S_Tag {};
55 // Note: Could easily add SV or US tags later if needed
56
57 struct SerialSVD {
58 // Version to compute full factorization: A == U * diag(s) * Vt
59 template <typename AViewType, typename UViewType, typename VtViewType, typename SViewType, typename WViewType>
60 KOKKOS_INLINE_FUNCTION static int invoke(
61 SVD_USV_Tag, const AViewType &A, const UViewType &U, const SViewType &s, const VtViewType &Vt, const WViewType &W,
62 typename AViewType::const_value_type tol = Kokkos::ArithTraits<typename AViewType::value_type>::zero());
63
64 // Version which computes only singular values
65 template <typename AViewType, typename SViewType, typename WViewType>
66 KOKKOS_INLINE_FUNCTION static int invoke(
67 SVD_S_Tag, const AViewType &A, const SViewType &s, const WViewType &W,
68 typename AViewType::const_value_type tol = Kokkos::ArithTraits<typename AViewType::value_type>::zero());
69 };
70
71 } // namespace KokkosBatched
72
73 #include "KokkosBatched_SVD_Serial_Impl.hpp"
74
75 #endif