| 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_UTV_TEAMVECTOR_INTERNAL_HPP |
| 17 |
#define KOKKOSBATCHED_UTV_TEAMVECTOR_INTERNAL_HPP |
| 18 |
|
| 19 |
/// \author Kyungjoo Kim ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Util.hpp" |
| 22 |
|
| 23 |
#include "KokkosBatched_SetTriangular_Internal.hpp" |
| 24 |
#include "KokkosBatched_QR_TeamVector_Internal.hpp" |
| 25 |
#include "KokkosBatched_QR_WithColumnPivoting_TeamVector_Internal.hpp" |
| 26 |
#include "KokkosBatched_QR_FormQ_TeamVector_Internal.hpp" |
| 27 |
|
| 28 |
namespace KokkosBatched { |
| 29 |
|
| 30 |
/// |
| 31 |
/// TeamVector Internal |
| 32 |
/// =================== |
| 33 |
struct TeamVectorUTV_Internal { |
| 34 |
template <typename MemberType, typename ValueType, typename IntType> |
| 35 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const int m, |
| 36 |
const int n, // m = NumRows(A), n = NumCols(A) |
| 37 |
/* */ ValueType *A, const int as0, const int as1, |
| 38 |
/* */ IntType *p, const int ps0, |
| 39 |
/* */ ValueType *U, const int us0, const int us1, |
| 40 |
/* */ ValueType *V, const int vs0, const int vs1, |
| 41 |
/* */ ValueType *w, // 3*m, tau, norm, householder workspace |
| 42 |
/* */ int &matrix_rank) { |
| 43 |
typedef ValueType value_type; |
| 44 |
// typedef IntType int_type; |
| 45 |
|
| 46 |
value_type *t = w; |
| 47 |
w += m; |
| 48 |
const int ts0(1); |
| 49 |
|
| 50 |
value_type *work = w; |
| 51 |
|
| 52 |
matrix_rank = -1; |
| 53 |
TeamVectorQR_WithColumnPivotingInternal ::invoke(member, m, n, A, as0, as1, t, ts0, p, ps0, work, matrix_rank); |
| 54 |
|
| 55 |
TeamVectorQR_FormQ_Internal ::invoke(member, m, matrix_rank, matrix_rank, A, as0, as1, t, ts0, U, us0, us1, work); |
| 56 |
member.team_barrier(); |
| 57 |
|
| 58 |
/// for rank deficient matrix |
| 59 |
if (matrix_rank < n) { |
| 60 |
const value_type zero(0); |
| 61 |
TeamVectorSetLowerTriangularInternal ::invoke(member, matrix_rank, matrix_rank, 1, zero, A, as0, as1); |
| 62 |
|
| 63 |
TeamVectorQR_Internal ::invoke(member, n, matrix_rank, A, as1, as0, t, ts0, work); |
| 64 |
|
| 65 |
TeamVectorQR_FormQ_Internal ::invoke(member, n, matrix_rank, matrix_rank, A, as1, as0, t, ts0, V, vs1, vs0, work); |
| 66 |
} |
| 67 |
|
| 68 |
return 0; |
| 69 |
} |
| 70 |
}; |
| 71 |
|
| 72 |
} // end namespace KokkosBatched |
| 73 |
|
| 74 |
#endif |