<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
lascl.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
5//
6// This file is part of <T>LAPACK.
7// <T>LAPACK is free software: you can redistribute it and/or modify it under
8// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
9
10#ifndef TLAPACK_LEGACY_LASCL_HH
11#define TLAPACK_LEGACY_LASCL_HH
12
15
16namespace tlapack {
17namespace legacy {
18
60 template <class matrixtype_t, typename T>
62 idx_t kl,
63 idx_t ku,
64 const real_type<T>& b,
65 const real_type<T>& a,
66 idx_t m,
67 idx_t n,
68 T* A,
69 idx_t lda)
70 {
71 using internal::create_banded_matrix;
72 using internal::create_matrix;
73
74 // check arguments
75 tlapack_check_false((matrixtype != MatrixType::General) &&
76 (matrixtype != MatrixType::Lower) &&
77 (matrixtype != MatrixType::Upper) &&
78 (matrixtype != MatrixType::Hessenberg) &&
79 (matrixtype != MatrixType::LowerBand) &&
80 (matrixtype != MatrixType::UpperBand) &&
81 (matrixtype != MatrixType::Band));
82 tlapack_check_false(((matrixtype == MatrixType::LowerBand) ||
83 (matrixtype == MatrixType::UpperBand) ||
84 (matrixtype == MatrixType::Band)) &&
85 ((kl < 0) || (kl > max(m - 1, idx_t(0)))));
86 tlapack_check_false(((matrixtype == MatrixType::LowerBand) ||
87 (matrixtype == MatrixType::UpperBand) ||
88 (matrixtype == MatrixType::Band)) &&
89 ((ku < 0) || (ku > max(n - 1, idx_t(0)))));
90 tlapack_check_false(((matrixtype == MatrixType::LowerBand) ||
91 (matrixtype == MatrixType::UpperBand)) &&
92 (kl != ku));
95 ((matrixtype == MatrixType::General) ||
96 (matrixtype == MatrixType::Lower) ||
97 (matrixtype == MatrixType::Upper) ||
98 (matrixtype == MatrixType::Hessenberg)));
99 tlapack_check_false((matrixtype == MatrixType::LowerBand) &&
100 (lda < kl + 1));
101 tlapack_check_false((matrixtype == MatrixType::UpperBand) &&
102 (lda < ku + 1));
103 tlapack_check_false((matrixtype == MatrixType::Band) &&
104 (lda < 2 * kl + ku + 1));
105
106 if (matrixtype == MatrixType::LowerBand) {
107 auto A_ = create_banded_matrix<T>(A, m, n, kl, 0);
108 return lascl(BandAccess{size_t(kl), 0}, b, a, A_);
109 }
110 else if (matrixtype == MatrixType::UpperBand) {
111 auto A_ = create_banded_matrix<T>(A, m, n, 0, ku);
112 return lascl(BandAccess{0, size_t(ku)}, b, a, A_);
113 }
114 else if (matrixtype == MatrixType::Band) {
115 auto A_ = create_banded_matrix<T>(A, m, n, kl, ku);
116 return lascl(BandAccess{size_t(kl), size_t(ku)}, b, a, A_);
117 }
118 else {
119 auto A_ = create_matrix<T>(A, m, n, lda);
120
121 if (matrixtype == MatrixType::General) {
122 return lascl(GENERAL, b, a, A_);
123 }
124 else if (matrixtype == MatrixType::Lower) {
125 return lascl(LOWER_TRIANGLE, b, a, A_);
126 }
127 else if (matrixtype == MatrixType::Upper) {
128 return lascl(UPPER_TRIANGLE, b, a, A_);
129 }
130 else // if (matrixtype == MatrixType::Hessenberg)
131 {
132 return lascl(UPPER_HESSENBERG, b, a, A_);
133 }
134 }
135 }
136
137} // namespace legacy
138} // namespace tlapack
139
140#endif // TLAPACK_LEGACY_LASCL_HH
constexpr internal::UpperHessenberg UPPER_HESSENBERG
Upper Hessenberg access.
Definition types.hpp:177
constexpr internal::LowerTriangle LOWER_TRIANGLE
Lower Triangle access.
Definition types.hpp:183
constexpr internal::UpperTriangle UPPER_TRIANGLE
Upper Triangle access.
Definition types.hpp:181
constexpr internal::GeneralAccess GENERAL
General access.
Definition types.hpp:175
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
int lascl(matrixtype_t matrixtype, idx_t kl, idx_t ku, const real_type< T > &b, const real_type< T > &a, idx_t m, idx_t n, T *A, idx_t lda)
Multiplies a matrix A by the real scalar a/b.
Definition lascl.hpp:61
Multiplies a matrix by a scalar.
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
Band access.
Definition types.hpp:427