| 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_EIGENDECOMPOSITION_SERIAL_IMPL_HPP |
| 17 |
#define KOKKOSBATCHED_EIGENDECOMPOSITION_SERIAL_IMPL_HPP |
| 18 |
|
| 19 |
/// \author Kyungjoo Kim ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Util.hpp" |
| 22 |
#include "KokkosBatched_Eigendecomposition_Serial_Internal.hpp" |
| 23 |
|
| 24 |
namespace KokkosBatched { |
| 25 |
|
| 26 |
/// |
| 27 |
/// Serial Impl |
| 28 |
/// =========== |
| 29 |
template <typename AViewType, typename EViewType, typename UViewType, typename WViewType> |
| 30 |
KOKKOS_INLINE_FUNCTION int SerialEigendecomposition::invoke(const AViewType &A, const EViewType &er, |
| 31 |
const EViewType &ei, const UViewType &UL, |
| 32 |
const UViewType &UR, const WViewType &W) { |
| 33 |
/// view checking |
| 34 |
const int m = A.extent(0); |
| 35 |
assert(m == int(A.extent(1)) && "Eigendecomposition: A is not square"); |
| 36 |
assert(m == int(er.extent(0)) && "Eigendecomposition: Length of er does not match to A's dimension"); |
| 37 |
assert(m == int(ei.extent(0)) && "Eigendecomposition: Length of ei does not match to A's dimension"); |
| 38 |
assert(m == int(UL.extent(0)) && "Eigendecomposition: Length of UL does not match to A's dimension"); |
| 39 |
assert(m == int(UL.extent(1)) && "Eigendecomposition: Width of UL does not match to A's dimension"); |
| 40 |
assert(m == int(UR.extent(0)) && "Eigendecomposition: Length of UR does not match to A's dimension"); |
| 41 |
assert(m == int(UR.extent(1)) && "Eigendecomposition: Width of UR does not match to A's dimension"); |
| 42 |
// assert(int(W.extent(0)) >= int(2*m*m+5*m) && "Eigendecomposition: workspace |
| 43 |
// size is too small"); |
| 44 |
assert(int(W.stride(0)) == int(1) && "Eigendecomposition: Provided workspace is not contiguous"); |
| 45 |
|
| 46 |
/// static assert A,er,ei,UL,UR,W has the same value_type |
| 47 |
/// static assert all views have the same memory space |
| 48 |
return m ? SerialEigendecompositionInternal ::invoke( |
| 49 |
A.extent(0), A.data(), A.stride(0), A.stride(1), er.data(), er.stride(0), ei.data(), ei.stride(0), |
| 50 |
UL.data(), UL.stride(0), UL.stride(1), UR.data(), UR.stride(0), UR.stride(1), W.data(), W.extent(0)) |
| 51 |
: 0; |
| 52 |
} |
| 53 |
|
| 54 |
} // namespace KokkosBatched |
| 55 |
|
| 56 |
#endif |