KokkosBlas::trsm¶
Defined in header: KokkosBlas3_trsm.hpp
// Version 1: Takes execution_space as argument
template <class execution_space, class AViewType, class BViewType>
void trsm(const execution_space& space, const char side[], const char uplo[],
const char trans[], const char diag[],
typename BViewType::const_value_type& alpha,
const AViewType& A, const BViewType& B);
// Version 2: Infers execution_space from AViewType
template <class AViewType, class BViewType>
void trsm(const char side[], const char uplo[], const char trans[], const char diag[],
typename BViewType::const_value_type& alpha, const AViewType& A,
const BViewType& B);
Solve a triangular matrix system of the form
where A is a triangular matrix and X and B are vectors or matrices. The solution X is stored back in B
Implementation¶
Version 1: check input control parameters, solve the triangular system of equations using the resources of
spaceVersion 2: check input control parameters, solve the triangular system of equations using the resources of the default instance of
typename AViewType::execution_space
Parameters¶
- space:
execution space instance.
- side:
control parameter specifying on which side the solver is applied, supported values are
L, lfor left side andR, rfor right side.- uplo:
control parameter specifying if the triangular matrix is upper or lower triangular, supported values are
U, ufor upper andL, lfor lower.- trans:
control parameter specifying what operation on the entires of
Ashould be performed. Supported values areN, nfor nothing,T, tfor transpose mode andC, cfor conjugate transpose mode.- diag:
control parameter specifying if the diagonal entries of
Aare equal to one, in which case these entries will be ignored. Supported values areU, ufor unit diagonal andN, nfor non-unit diagonal.- alpha:
a scaling factor applied while solving the
Atriangular system.- A:
triangular system of size
kequal to:A.extent(0)whensideisLorl,A.extent(1)whensideisRorr.
With
uploset asUoruonly leadingkbykupper triangular entries are considered, withuploset asLorlonly the leadingkbyklower triangular entries are considered. Furthermore ifdiagis set toUoruthen the diagonal entries are also ignored. Note thatAdoes not have to actually be triangular, only the triangular part of interest (based on the value ofuplo) will be used.- B:
a dense matrix representing the right hand side of the system on entry and overwritten with the solution of the system on output.
Type Requirements¶
Example¶
#include <Kokkos_Core.hpp>
#include <Kokkos_Random.hpp>
#include <KokkosBlas3_trsm.hpp>
int main(int argc, char* argv[]) {
Kokkos::initialize();
{
int M = atoi(argv[1]);
int N = atoi(argv[2]);
int K = N;
using ViewType = Kokkos::View<double**>;
using Scalar = typename ViewType::value_type;
ViewType A("A",K,K);
ViewType B("B",M,N);
Kokkos::Random_XorShift64_Pool<typename ViewType::device_type::execution_space> rand_pool(13718);
Kokkos::fill_random(A,rand_pool,Scalar(10));
Kokkos::fill_random(B,rand_pool,Scalar(10));
const Scalar alpha = 1.0;
KokkosBlas::trsm("R","L","T","N",alpha,A,B);
}
Kokkos::finalize();
}