<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
trmv.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2017-2021, University of Tennessee. All rights reserved.
5// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
6//
7// This file is part of <T>LAPACK.
8// <T>LAPACK is free software: you can redistribute it and/or modify it under
9// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
10
11#ifndef TLAPACK_LEGACY_TRMV_HH
12#define TLAPACK_LEGACY_TRMV_HH
13
14#include "tlapack/blas/trmv.hpp"
17
18namespace tlapack {
19namespace legacy {
20
75 template <typename TA, typename TX>
76 void trmv(Layout layout,
77 Uplo uplo,
78 Op trans,
79 Diag diag,
80 idx_t n,
81 TA const* A,
82 idx_t lda,
83 TX* x,
84 int_t incx)
85 {
86 using internal::create_matrix;
87
88 // check arguments
89 tlapack_check_false(layout != Layout::ColMajor &&
90 layout != Layout::RowMajor);
91 tlapack_check_false(uplo != Uplo::Lower && uplo != Uplo::Upper);
92 tlapack_check_false(trans != Op::NoTrans && trans != Op::Trans &&
93 trans != Op::ConjTrans);
94 tlapack_check_false(diag != Diag::NonUnit && diag != Diag::Unit);
98
99 // quick return
100 if (n == 0) return;
101
102 // for row major, swap lower <=> upper and
103 // A => A^T; A^T => A; A^H => A & doConj
104 bool doConj = false;
105 if (layout == Layout::RowMajor) {
106 uplo = (uplo == Uplo::Lower ? Uplo::Upper : Uplo::Lower);
107 if (trans == Op::NoTrans)
108 trans = Op::Trans;
109 else {
110 if (trans == Op::ConjTrans) doConj = true;
111 trans = Op::NoTrans;
112 }
113 }
114
115 // Conjugate if A is row-major and initially trans is Op::ConjTrans
116 if (doConj) {
117 for (idx_t i = 0; i < n; ++i)
118 x[i * abs(incx)] = conj(x[i * abs(incx)]);
119 }
120
121 // Matrix views
122 const auto A_ = create_matrix<TA>((TA*)A, n, n, lda);
123
125 trmv(uplo, trans, diag, A_, x_));
126
127 // Conjugate if A is row-major and initially trans is Op::ConjTrans
128 if (doConj) {
129 for (idx_t i = 0; i < n; ++i)
130 x[i * abs(incx)] = conj(x[i * abs(incx)]);
131 }
132 }
133
134} // namespace legacy
135} // namespace tlapack
136
137#endif // #ifndef TLAPACK_LEGACY_TRMV_HH
constexpr Layout layout
Layout of a matrix or vector.
Definition arrayTraits.hpp:232
Diag
Definition types.hpp:192
Op
Definition types.hpp:222
Uplo
Definition types.hpp:45
Layout
Definition types.hpp:24
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
constexpr auto diag(T &A, int diagIdx=0) noexcept
Get the Diagonal of an Eigen Matrix.
Definition eigen.hpp:576
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
void trmv(Layout layout, Uplo uplo, Op trans, Diag diag, idx_t n, TA const *A, idx_t lda, TX *x, int_t incx)
Triangular matrix-vector multiply:
Definition trmv.hpp:76
#define tlapack_expr_with_vector(x, TX, n, X, incx, expr)
Creates a vector object and executes an expression with it.
Definition utils.hpp:68
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113