| 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_HESSENBERG_FORM_Q_SERIAL_INTERNAL_HPP |
| 17 |
#define KOKKOSBATCHED_HESSENBERG_FORM_Q_SERIAL_INTERNAL_HPP |
| 18 |
|
| 19 |
/// \author Kyungjoo Kim ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Util.hpp" |
| 22 |
#include "KokkosBlas1_set_impl.hpp" |
| 23 |
#include "KokkosBatched_SetIdentity_Internal.hpp" |
| 24 |
#include "KokkosBatched_ApplyQ_Serial_Internal.hpp" |
| 25 |
|
| 26 |
namespace KokkosBatched { |
| 27 |
|
| 28 |
/// |
| 29 |
/// Serial Internal Impl |
| 30 |
/// ==================== |
| 31 |
/// |
| 32 |
/// this impl follows the flame interface of householder transformation |
| 33 |
/// |
| 34 |
struct SerialHessenbergFormQInternal { |
| 35 |
template <typename ValueType> |
| 36 |
KOKKOS_INLINE_FUNCTION static int invoke(const int m, const int k, |
| 37 |
/* */ ValueType* A, const int as0, const int as1, |
| 38 |
/* */ ValueType* t, const int ts, |
| 39 |
/* */ ValueType* Q, const int qs0, const int qs1, |
| 40 |
/* */ ValueType* w, const bool is_Q_zero = false) { |
| 41 |
typedef ValueType value_type; |
| 42 |
|
| 43 |
/// Given a matrix A that includes Hessenberg factorization |
| 44 |
/// it forms a unitary matrix Q |
| 45 |
/// B = Q = (H0 H1 H2 H3 ... H(k-2)) I |
| 46 |
/// where |
| 47 |
/// A is m x k (holding H0, H1 ... H(k-2) |
| 48 |
/// t is k x 1 |
| 49 |
/// B is m x m |
| 50 |
// set identity |
| 51 |
if (is_Q_zero) |
| 52 |
KokkosBlas::Impl::SerialSetInternal::invoke(m, value_type(1), Q, qs0 + qs1); |
| 53 |
else |
| 54 |
SerialSetIdentityInternal::invoke(m, Q, qs0, qs1); |
| 55 |
|
| 56 |
return SerialApplyQ_LeftNoTransForwardInternal ::invoke(m - 1, m - 1, k - 1, A + as0, as0, as1, t, ts, |
| 57 |
Q + qs0 + qs1, qs1, qs0, w); |
| 58 |
} |
| 59 |
}; |
| 60 |
|
| 61 |
} // end namespace KokkosBatched |
| 62 |
|
| 63 |
#endif |