KokkosBlas::axpy ################ Defined in header: :code:`KokkosBlas1_axpby.hpp` .. code:: c++ template void axpy(const execution_space& space, const AV& a, const XMV& X, const YMV& Y) template void axpy(const AV& a, const XMV& X, const YMV& Y) Add entries of :code:`X` scaled by coefficient :code:`a` to entries of :code:`Y`: ``Y += a*X`` 1. iterate over the entries of ``Y`` and add the corresponding entries of ``X`` scaled by ``a`` using the resources of ``space`` 2. iterate over the entries of ``Y`` and add the corresponding entries of ``X`` scaled by ``a`` using the resources of the default instance of ``typename XMV::execution_space`` ``a`` may each be any of the following: - a scalar value - a rank-0 host-accessible ``Kokkos::View`` - a rank-0 device-accessible ``Kokkos::View`` - a rank-1 device-accessible ``Kokkos::View`` with extent 1 (the coefficient will be applied to all columns) - a rank-1 device-accessible ``Kokkos::View`` with extent ``Y.extent(1)`` (one coefficient per column) The function will throw a runtime exception if any of the following conditions are **not** met: - ``Y.extent(0) == X.extent(0) && Y.extent(1) == X.extent(1)`` If ``a`` is a rank-1 ``View``: - ``a.extent(0) != 1 && a.extent(0) != X.extent(1)`` Parameters ========== :space: execution space instance :a: scaling factor :X, Y: vector(s) of input and output values respectively Type Requirements ----------------- - `execution_space` must be a Kokkos `execution space `_ - `XMV` must be a Kokkos `View `_ of rank 1 or 2 that satisfies - ``Kokkos::SpaceAccessibility::accessible == true`` - `YMV` must be a Kokkos `View `_ that satisfies - ``YMV::rank == XMV::rank`` - ``std::is_same_v == true`` - ``Kokkos::SpaceAccessibility::accessible == true`` - `AV` must be a scalar or a Kokkos `View `_ that satisfies one of the following: - ``AV::rank == 0`` - ``AV::rank == 1 && Kokkos::SpaceAccessibility::accessible`` Example ======= .. literalinclude:: ../../../../example/wiki/blas/KokkosBlas1_wiki_axpy.cpp :language: c++ output: .. code:: Sum: 65, Expected: 65, Diff: 0