Skip to content

BLAS 2::syr2

Luc Berger edited this page Apr 23, 2024 · 1 revision

KokkosBlas::syr2()

Header File: KokkosBlas2_syr2.hpp

Usage: KokkosBlas::syr2 (space, mode, uplo, alpha, x, y, A);

Matrix symmetric Rank 2 update: A = A + alpha * (x * y^{T,H} + y * x^{T,H})

Interface

template <class ExecutionSpace,
          class XViewType,
          class YViewType,
          class AViewType>
void ger(const ExecutionSpace& space,
         const char trans[],
         const char uplo[],
         const typename AViewType::const_value_type& alpha,
         const XViewType& x,
         const YViewType& y,
         const AViewType& A)

template <class XViewType,
          class YViewType,
          class AViewType>
void ger(const char trans[],
         const char uplo[],
         const typename AViewType::const_value_type& alpha,
         const XViewType& x,
         const YViewType& y,
         const AViewType& A)

Template Parameters:

  • ExecutionSpace: A Kokkos execution space
  • XViewType: A rank-1 Kokkos::View
  • YViewType: A rank-1 Kokkos::View
  • AViewType: A rank-2 Kokkos::View

Arguments:

  • trans [in] "T" for transpose, "H" for conjugate transpose. All characters after the first are ignored. This works just like the BLAS routines.
  • uplo [in] "U" or "u" for upper portion, "L" or "l" for lower portion. Only the first character is taken into account.
  • alpha [in] Input scaling factor for the rank update
  • x [in] Input vector, as a 1-D Kokkos::View
  • y [in] Input vector, as a 1-D Kokkos::View
  • A [in/out] Output matrix, as a nonconst 2-D Kokkos::View

Requirements:

  • x is a rank-1 views
  • y is a rank-1 views
  • A is a rank-2 view
  • x, y and A have memory space accessible from ExecutionSpace
  • A.extent(0) == A.extent(1) && A.extent(0) == x.extent(0) && A.extent(0) == y.extent(0)

Example

#include <Kokkos_Core.hpp>
#include <KokkosBlas2_syr2.hpp>

int main(int argc, char* argv[]) {
  Kokkos::initialize(argc, argv);
  {
    constexpr int M = 5;

    Kokkos::View<double**> A("A", M, M);
    Kokkos::View<double*> x("X", M);
    Kokkos::View<double*> y("Y", M);

    Kokkos::deep_copy(A, 1.0);
    Kokkos::deep_copy(x, 3.0);
    Kokkos::deep_copy(y, 1.3);

    const double alpha = double(1.0);

    KokkosBlas::syr2("T", "U", alpha, x, y, A);
  }
  Kokkos::finalize();
}
Clone this wiki locally