trmv.hpp
Go to the documentation of this file.
1//===========================================================================
2/*!
3 *
4 *
5 * \brief -
6 *
7 * \author O. Krause
8 * \date 2010
9 *
10 *
11 * \par Copyright 1995-2015 Shark Development Team
12 *
13 * <BR><HR>
14 * This file is part of Shark.
15 * <http://image.diku.dk/shark/>
16 *
17 * Shark is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Lesser General Public License as published
19 * by the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * Shark is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public License
28 * along with Shark. If not, see <http://www.gnu.org/licenses/>.
29 *
30 */
31//===========================================================================
32#ifndef REMORA_KERNELS_CBLAS_TRMV_HPP
33#define REMORA_KERNELS_CBLAS_TRMV_HPP
34
35#include "cblas_inc.hpp"
36#include <type_traits>
37
38namespace remora{namespace bindings {
39
40inline void trmv(
41 CBLAS_ORDER const Order,
42 CBLAS_UPLO const uplo,
43 CBLAS_TRANSPOSE const transA,
44 CBLAS_DIAG const unit,
45 int const N,
46 float const *A, int const lda,
47 float* X, int const incX
48) {
49 cblas_strmv(Order, uplo, transA, unit, N,
50 A, lda,
51 X, incX
52 );
53}
54
55inline void trmv(
56 CBLAS_ORDER const Order,
57 CBLAS_UPLO const uplo,
58 CBLAS_TRANSPOSE const transA,
59 CBLAS_DIAG const unit,
60 int const N,
61 double const *A, int const lda,
62 double* X, int const incX
63) {
64 cblas_dtrmv(Order, uplo, transA, unit, N,
65 A, lda,
66 X, incX
67 );
68}
69
70
71inline void trmv(
72 CBLAS_ORDER const Order,
73 CBLAS_UPLO const uplo,
74 CBLAS_TRANSPOSE const transA,
75 CBLAS_DIAG const unit,
76 int const N,
77 std::complex<float> const *A, int const lda,
78 std::complex<float>* X, int const incX
79) {
80 cblas_ctrmv(Order, uplo, transA, unit, N,
81 reinterpret_cast<cblas_float_complex_type const *>(A), lda,
82 reinterpret_cast<cblas_float_complex_type *>(X), incX
83 );
84}
85
86inline void trmv(
87 CBLAS_ORDER const Order,
88 CBLAS_UPLO const uplo,
89 CBLAS_TRANSPOSE const transA,
90 CBLAS_DIAG const unit,
91 int const N,
92 std::complex<double> const *A, int const lda,
93 std::complex<double>* X, int const incX
94) {
95 cblas_ztrmv(Order, uplo, transA, unit, N,
96 reinterpret_cast<cblas_double_complex_type const *>(A), lda,
97 reinterpret_cast<cblas_double_complex_type *>(X), incX
98 );
99}
100
101template <bool upper, bool unit, typename MatA, typename VectorX>
102void trmv(
103 matrix_expression<MatA, cpu_tag> const& A,
104 vector_expression<VectorX, cpu_tag> &x,
105 std::true_type
106){
107 REMORA_SIZE_CHECK(x().size() == A().size2());
108 REMORA_SIZE_CHECK(A().size2() == A().size1());
109 std::size_t n = A().size1();
110 CBLAS_DIAG cblasUnit = unit?CblasUnit:CblasNonUnit;
111 CBLAS_UPLO cblasUplo = upper?CblasUpper:CblasLower;
112 CBLAS_ORDER stor_ord= (CBLAS_ORDER)storage_order<typename MatA::orientation>::value;
113
114 auto storageA = A().raw_storage();
115 auto storagex = x().raw_storage();
116 trmv(stor_ord, cblasUplo, CblasNoTrans, cblasUnit, (int)n,
117 storageA.values,
118 storageA.leading_dimension,
119 storagex.values,
120 storagex.stride
121 );
122}
123
124
125template<class M, class V>
126struct has_optimized_trmv: std::integral_constant<bool,
127 allowed_cblas_type<typename M::value_type>::type::value
128 && std::is_same<typename M::value_type, typename V::value_type>::value
129 && std::is_base_of<dense_tag, typename M::storage_type::storage_tag>::value
130 && std::is_base_of<dense_tag, typename V::storage_type::storage_tag>::value
131>{};
132
133}}
134#endif