<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
swap.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_BLAS_SWAP_HH
12#define TLAPACK_BLAS_SWAP_HH
13
15
16namespace tlapack {
17
26template <
27 TLAPACK_VECTOR vectorX_t,
28 TLAPACK_VECTOR vectorY_t,
29 class T = type_t<vectorY_t>,
30 disable_if_allow_optblas_t<pair<vectorX_t, T>, pair<vectorY_t, T> > = 0>
32{
33 using idx_t = size_type<vectorY_t>;
34 using TX = type_t<vectorX_t>;
35
36 // constants
37 const idx_t n = size(x);
38
39 // check arguments
40 tlapack_check_false(size(y) != n);
41
42 for (idx_t i = 0; i < n; ++i) {
43 const TX aux = x[i];
44 x[i] = y[i];
45 y[i] = aux;
46 }
47}
48
49#ifdef TLAPACK_USE_LAPACKPP
50
51template <
52 TLAPACK_LEGACY_VECTOR vectorX_t,
53 TLAPACK_LEGACY_VECTOR vectorY_t,
54 class T = type_t<vectorY_t>,
55 enable_if_allow_optblas_t<pair<vectorX_t, T>, pair<vectorY_t, T> > = 0>
56void swap(vectorX_t& x, vectorY_t& y)
57{
58 // Legacy objects
59 auto x_ = legacy_vector(x);
60 auto y_ = legacy_vector(y);
61
62 // Constants to forward
63 const auto& n = x_.n;
64
65 return ::blas::swap(n, x_.ptr, x_.inc, y_.ptr, y_.inc);
66}
67
68#endif
69
83template <TLAPACK_VECTOR vector_t>
85{
87}
88
89} // namespace tlapack
90
91#endif // #ifndef TLAPACK_BLAS_SWAP_HH
#define TLAPACK_LEGACY_VECTOR
Macro for tlapack::concepts::LegacyVector compatible with C++17.
Definition concepts.hpp:954
#define TLAPACK_VECTOR
Macro for tlapack::concepts::Vector compatible with C++17.
Definition concepts.hpp:906
void swap(vectorX_t &x, vectorY_t &y)
Swap vectors, .
Definition swap.hpp:31
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
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