<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
symv.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_SYMV_HH
12#define TLAPACK_LEGACY_SYMV_HH
13
14#include "tlapack/blas/symv.hpp"
17
18namespace tlapack {
19namespace legacy {
20
72 template <typename TA, typename TX, typename TY>
73 void symv(Layout layout,
74 Uplo uplo,
75 idx_t n,
77 TA const* A,
78 idx_t lda,
79 TX const* x,
80 int_t incx,
82 TY* y,
83 int_t incy)
84 {
85 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);
96
97 // quick return
98 if (n == 0 || ((alpha == scalar_t(0)) && (beta == scalar_t(1)))) return;
99
100 // for row major, swap lower <=> upper
101 if (layout == Layout::RowMajor) {
102 uplo = (uplo == Uplo::Lower ? Uplo::Upper : Uplo::Lower);
103 }
104
105 // Views
106 const auto A_ = create_matrix<TA>((TA*)A, n, n, lda);
107
108 if (alpha == scalar_t(0)) {
110 y_, TY, n, y, incy,
111 if (beta == scalar_t(0)) for (idx_t i = 0; i < n; ++i) y_[i] =
112 TY(0);
113 else for (idx_t i = 0; i < n; ++i) y_[i] *= beta);
114 }
115 else {
117 x_, TX, n, x, incx, y_, TY, n, y, incy,
118 if (beta == scalar_t(0)) return symv(uplo, alpha, A_, x_, y_);
119 else return symv(uplo, alpha, A_, x_, beta, y_));
120 }
121 }
122
123} // namespace legacy
124} // namespace tlapack
125
126#endif // #ifndef TLAPACK_LEGACY_SYMV_HH
constexpr Layout layout
Layout of a matrix or vector.
Definition arrayTraits.hpp:232
Uplo
Definition types.hpp:45
Layout
Definition types.hpp:24
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
void symv(Layout layout, Uplo uplo, idx_t n, scalar_type< TA, TX, TY > alpha, TA const *A, idx_t lda, TX const *x, int_t incx, scalar_type< TA, TX, TY > beta, TY *y, int_t incy)
Symmetric matrix-vector multiply:
Definition symv.hpp:73
#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
#define tlapack_expr_with_2vectors(x, TX, n, X, incx, y, TY, m, Y, incy, expr)
Creates two vector objects and executes an expression with them.
Definition utils.hpp:33
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