<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
trsv.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2017-2021, University of Tennessee. All rights reserved.
5// Copyright (c) 2025, 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_TRSV_HH
12#define TLAPACK_LEGACY_TRSV_HH
13
14#include "tlapack/blas/trsv.hpp"
17
18namespace tlapack {
19namespace legacy {
20
79 template <typename TA, typename TX>
81 Uplo uplo,
82 Op trans,
83 Diag diag,
84 idx_t n,
85 TA const* A,
86 idx_t lda,
87 TX* x,
88 int_t incx)
89 {
90 using internal::create_matrix;
91
92 // check arguments
102
103 // quick return
104 if (n == 0) return;
105
106 // for row major, swap lower <=> upper and
107 // A => A^T; A^T => A; A^H => A & doConj
108 bool doConj = false;
109 if (layout == Layout::RowMajor) {
111 if (trans == Op::NoTrans)
113 else {
114 if (trans == Op::ConjTrans) doConj = true;
116 }
117 }
118
119 // Conjugate if A is row-major and initially trans is Op::ConjTrans
120 if (doConj) {
121 for (idx_t i = 0; i < n; ++i)
122 x[i * abs(incx)] = conj(x[i * abs(incx)]);
123 }
124
125 // Matrix views
126 const auto A_ = create_matrix<TA>((TA*)A, n, n, lda);
127
129 trsv(uplo, trans, diag, A_, x_));
130
131 // Conjugate if A is row-major and initially trans is Op::ConjTrans
132 if (doConj) {
133 for (idx_t i = 0; i < n; ++i)
134 x[i * abs(incx)] = conj(x[i * abs(incx)]);
135 }
136 }
137
138} // namespace legacy
139} // namespace tlapack
140
141#endif // #ifndef TLAPACK_LEGACY_TRSV_HH
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
void trsv(Layout layout, Uplo uplo, Op trans, Diag diag, idx_t n, TA const *A, idx_t lda, TX *x, int_t incx)
Solve the triangular matrix-vector equation.
Definition trsv.hpp:80
#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
Sort the numbers in D in increasing order (if ID = 'I') or in decreasing order (if ID = 'D' ).
Definition arrayTraits.hpp:15
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
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
Diag
Definition types.hpp:197
@ Unit
The main diagonal is assumed to consist of 1's.
@ NonUnit
The main diagonal is not assumed to consist of 1's.
constexpr auto diag(T &A, int diagIdx=0) noexcept
Get the Diagonal of an Eigen Matrix.
Definition eigen.hpp:576
Op
Definition types.hpp:227
@ Trans
transpose
@ NoTrans
no transpose
@ ConjTrans
conjugate transpose
Uplo
Definition types.hpp:50
@ Upper
0 <= i <= j, 0 <= j <= n.
@ Lower
0 <= i <= m, 0 <= j <= i.
constexpr Layout layout
Layout of a matrix or vector.
Definition arrayTraits.hpp:232
Layout
Definition types.hpp:29
@ ColMajor
Column-major layout.
@ RowMajor
Row-major layout.