trsm.hpp
Go to the documentation of this file.
1/*!
2 *
3 *
4 * \brief Triangular solve kernel for matrix epressions.
5 *
6 * \author O. Krause
7 * \date 2012
8 *
9 *
10 * \par Copyright 1995-2015 Shark Development Team
11 *
12 * <BR><HR>
13 * This file is part of Shark.
14 * <http://image.diku.dk/shark/>
15 *
16 * Shark is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Lesser General Public License as published
18 * by the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * Shark is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public License
27 * along with Shark. If not, see <http://www.gnu.org/licenses/>.
28 *
29 */
30
31#ifndef REMORA_KERNELS_TRSM_HPP
32#define REMORA_KERNELS_TRSM_HPP
33
34#include <type_traits> //std::false_type marker for unoptimized
35#ifdef REMORA_USE_CBLAS
36#include "cblas/trsm.hpp"
37#else
38// if no bindings are included, we have to provide the default has_optimized_gemv
39// otherwise the binding will take care of this
40namespace remora{ namespace bindings{
41template<class M1, class M2>
42struct has_optimized_trsm
43: public std::false_type{};
44}}
45#endif
46
47#include "default/trsm.hpp"
48
49namespace remora{namespace kernels{
50
51///\brief Implements the TRiangular Solver for Vectors.
52///
53/// It solves Systems of the form Ax = b where A is a square lower or upper triangular matrix.
54/// It can optionally assume that the diagonal is 1 and won't access the diagonal elements.
55template <class Triangular,class Side, typename MatA, typename MatB>
56void trsm(
57 matrix_expression<MatA, cpu_tag> const &A,
58 matrix_expression<MatB, cpu_tag> &B
59){
60 REMORA_SIZE_CHECK(A().size1() == A().size2());
61 REMORA_SIZE_CHECK(!Side::is_left || A().size2() == B().size1());
62 REMORA_SIZE_CHECK(Side::is_left || A().size2() == B().size2());
63
64 bindings::trsm<Triangular, Side>(A,B,typename bindings::has_optimized_trsm<MatA, MatB>::type());
65}
66
67}}
68
69#ifdef REMORA_USE_CLBLAST
70#include "clBlast/trsm.hpp"
71#elif defined REMORA_USE_GPU
72#include "gpu/trsm.hpp"
73#endif
74
75#endif