<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
types.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_TYPES_HH
12#define TLAPACK_TYPES_HH
13
14#include <vector>
15
18
19namespace tlapack {
20
21// -----------------------------------------------------------------------------
22// Layouts
23
24enum class Layout : char {
25 Strided = 'S',
27 ColMajor = 'C',
29 RowMajor = 'R',
31 Unspecified = 0
32};
33inline std::ostream& operator<<(std::ostream& out, const Layout v)
34{
35 if (v == Layout::Unspecified) return out << "Unspecified";
36 if (v == Layout::ColMajor) return out << "ColMajor";
37 if (v == Layout::RowMajor) return out << "RowMajor";
38 if (v == Layout::Strided) return out << "Strided";
39 return out << "<Invalid>";
40}
41
42// -----------------------------------------------------------------------------
43// Upper or Lower access
44
45enum class Uplo : char {
46 General = 'G',
47 Upper = 'U',
48 Lower = 'L',
49 UpperHessenberg = 'H',
50 LowerHessenberg = 4,
51 StrictUpper = 'S',
52 StrictLower = 6,
53};
54inline std::ostream& operator<<(std::ostream& out, const Uplo v)
55{
56 if (v == Uplo::Upper) return out << "Upper";
57 if (v == Uplo::Lower) return out << "Lower";
58 if (v == Uplo::General) return out << "General";
59 if (v == Uplo::UpperHessenberg) return out << "UpperHessenberg";
60 if (v == Uplo::LowerHessenberg) return out << "LowerHessenberg";
61 if (v == Uplo::StrictUpper) return out << "StrictUpper";
62 if (v == Uplo::StrictLower) return out << "StrictLower";
63 return out << "<Invalid>";
64}
65
66namespace internal {
78 constexpr operator Uplo() const noexcept { return Uplo::General; }
79 };
80
92 constexpr operator Uplo() const noexcept { return Uplo::Upper; }
93 };
94
106 constexpr operator Uplo() const noexcept { return Uplo::Lower; }
107 };
108
120 constexpr operator Uplo() const noexcept
121 {
122 return Uplo::UpperHessenberg;
123 }
124 };
125
137 constexpr operator Uplo() const noexcept
138 {
139 return Uplo::LowerHessenberg;
140 }
141 };
142
153 struct StrictUpper {
154 constexpr operator Uplo() const noexcept { return Uplo::StrictUpper; }
155 };
156
167 struct StrictLower {
168 constexpr operator Uplo() const noexcept { return Uplo::StrictLower; }
169 };
170} // namespace internal
171
172// constant expressions for upper/lower access
173
188
189// -----------------------------------------------------------------------------
190// Information about the main diagonal
191
192enum class Diag : char {
193 NonUnit = 'N',
194 Unit = 'U'
195};
196inline std::ostream& operator<<(std::ostream& out, const Diag v)
197{
198 if (v == Diag::NonUnit) return out << "NonUnit";
199 if (v == Diag::Unit) return out << "Unit";
200 return out << "<Invalid>";
201}
202
203namespace internal {
205 constexpr operator Diag() const noexcept { return Diag::NonUnit; }
206 };
208 constexpr operator Diag() const noexcept { return Diag::Unit; }
209 };
210} // namespace internal
211
212// constant expressions about the main diagonal
213
218
219// -----------------------------------------------------------------------------
220// Operations over data
221
222enum class Op : char {
223 NoTrans = 'N',
224 Trans = 'T',
225 ConjTrans = 'C',
226 Conj = 3
227};
228inline std::ostream& operator<<(std::ostream& out, const Op v)
229{
230 if (v == Op::NoTrans) return out << "NoTrans";
231 if (v == Op::Trans) return out << "Trans";
232 if (v == Op::ConjTrans) return out << "ConjTrans";
233 if (v == Op::Conj) return out << "Conj";
234 return out << "<Invalid>";
235}
236
237namespace internal {
238 struct NoTranspose {
239 constexpr operator Op() const noexcept { return Op::NoTrans; }
240 };
241 struct Transpose {
242 constexpr operator Op() const noexcept { return Op::Trans; }
243 };
245 constexpr operator Op() const noexcept { return Op::ConjTrans; }
246 };
247 struct Conjugate {
248 constexpr operator Op() const noexcept { return Op::Conj; }
249 };
250} // namespace internal
251
252// Constant expressions for operations over data
253
262
263// -----------------------------------------------------------------------------
264// Sides
265
266enum class Side : char {
267 Left = 'L',
268 Right = 'R'
269};
270inline std::ostream& operator<<(std::ostream& out, const Side v)
271{
272 if (v == Side::Left) return out << "Left";
273 if (v == Side::Right) return out << "Right";
274 return out << "<Invalid>";
275}
276
277namespace internal {
278 struct LeftSide {
279 constexpr operator Side() const noexcept { return Side::Left; }
280 };
281 struct RightSide {
282 constexpr operator Side() const noexcept { return Side::Right; }
283 };
284} // namespace internal
285
286// Constant expressions for sides
287
292
293// -----------------------------------------------------------------------------
294// Norm types
295
296enum class Norm : char {
297 One = '1',
298 Two = '2',
299 Inf = 'I',
300 Fro = 'F',
301 Max = 'M',
302};
303inline std::ostream& operator<<(std::ostream& out, const Norm v)
304{
305 if (v == Norm::One) return out << "One";
306 if (v == Norm::Two) return out << "Two";
307 if (v == Norm::Inf) return out << "Inf";
308 if (v == Norm::Fro) return out << "Fro";
309 if (v == Norm::Max) return out << "Max";
310 return out << "<Invalid>";
311}
312
313namespace internal {
314 struct MaxNorm {
315 constexpr operator Norm() const noexcept { return Norm::Max; }
316 };
317 struct OneNorm {
318 constexpr operator Norm() const noexcept { return Norm::One; }
319 };
320 struct TwoNorm {
321 constexpr operator Norm() const noexcept { return Norm::Two; }
322 };
323 struct InfNorm {
324 constexpr operator Norm() const noexcept { return Norm::Inf; }
325 };
326 struct FrobNorm {
327 constexpr operator Norm() const noexcept { return Norm::Fro; }
328 };
329} // namespace internal
330
331// Constant expressions for norm types
332
343
344// -----------------------------------------------------------------------------
345// Directions
346
347enum class Direction : char {
348 Forward = 'F',
349 Backward = 'B',
350};
351inline std::ostream& operator<<(std::ostream& out, const Direction v)
352{
353 if (v == Direction::Forward) return out << "Forward";
354 if (v == Direction::Backward) return out << "Backward";
355 return out << "<Invalid>";
356}
357
358namespace internal {
359 struct Forward {
360 constexpr operator Direction() const noexcept
361 {
362 return Direction::Forward;
363 }
364 };
365 struct Backward {
366 constexpr operator Direction() const noexcept
367 {
368 return Direction::Backward;
369 }
370 };
371} // namespace internal
372
373// Constant expressions for directions
374
379
380// -----------------------------------------------------------------------------
381// Storage types
382
383enum class StoreV : char {
384 Columnwise = 'C',
385 Rowwise = 'R',
386};
387inline std::ostream& operator<<(std::ostream& out, const StoreV v)
388{
389 if (v == StoreV::Columnwise) return out << "Columnwise";
390 if (v == StoreV::Rowwise) return out << "Rowwise";
391 return out << "<Invalid>";
392}
393
394namespace internal {
396 constexpr operator StoreV() const noexcept
397 {
398 return StoreV::Columnwise;
399 }
400 };
402 constexpr operator StoreV() const noexcept { return StoreV::Rowwise; }
403 };
404} // namespace internal
405
406// Constant expressions for storage types
407
412
413// -----------------------------------------------------------------------------
414// Band access
415
428 std::size_t lower_bandwidth;
429 std::size_t upper_bandwidth;
430};
431
432// -----------------------------------------------------------------------------
433// Legacy matrix and vector structures
434
435namespace legacy {
442 template <class T, class idx_t>
443 struct Matrix {
444 Layout layout;
445 idx_t m;
446 idx_t n;
447 T* ptr;
448 idx_t ldim;
449 };
450
457 template <class T, class idx_t>
458 struct Vector {
459 idx_t n;
460 T* ptr;
461 idx_t inc;
462 };
463} // namespace legacy
464} // namespace tlapack
465
466#endif // TLAPACK_TYPES_HH
constexpr internal::MaxNorm MAX_NORM
max norm
Definition types.hpp:334
constexpr internal::UpperHessenberg UPPER_HESSENBERG
Upper Hessenberg access.
Definition types.hpp:177
constexpr internal::FrobNorm FROB_NORM
Frobenius norm of matrices.
Definition types.hpp:342
constexpr internal::LowerTriangle LOWER_TRIANGLE
Lower Triangle access.
Definition types.hpp:183
constexpr internal::UpperTriangle UPPER_TRIANGLE
Upper Triangle access.
Definition types.hpp:181
Diag
Definition types.hpp:192
@ Unit
The main diagonal is assumed to consist of 1's.
@ NonUnit
The main diagonal is not assumed to consist of 1's.
constexpr internal::OneNorm ONE_NORM
one norm
Definition types.hpp:336
Side
Definition types.hpp:266
@ Right
right side
@ Left
left side
constexpr internal::Backward BACKWARD
Backward direction.
Definition types.hpp:378
constexpr internal::RightSide RIGHT_SIDE
right side
Definition types.hpp:291
constexpr internal::TwoNorm TWO_NORM
two norm
Definition types.hpp:338
constexpr internal::RowwiseStorage ROWWISE_STORAGE
Rowwise storage.
Definition types.hpp:411
constexpr internal::StrictUpper STRICT_UPPER
Strict Upper Triangle access.
Definition types.hpp:185
constexpr internal::Forward FORWARD
Forward direction.
Definition types.hpp:376
constexpr internal::Transpose TRANSPOSE
transpose
Definition types.hpp:257
constexpr internal::UnitDiagonal UNIT_DIAG
The main diagonal is assumed to consist of 1's.
Definition types.hpp:217
constexpr internal::StrictLower STRICT_LOWER
Strict Lower Triangle access.
Definition types.hpp:187
constexpr internal::GeneralAccess GENERAL
General access.
Definition types.hpp:175
constexpr internal::NonUnitDiagonal NON_UNIT_DIAG
The main diagonal is not assumed to consist of 1's.
Definition types.hpp:215
constexpr internal::Conjugate CONJUGATE
non-transpose conjugate
Definition types.hpp:261
Direction
Definition types.hpp:347
@ Forward
Forward direction.
@ Backward
Backward direction.
Op
Definition types.hpp:222
@ Trans
transpose
@ NoTrans
no transpose
@ Conj
non-transpose conjugate
@ ConjTrans
conjugate transpose
constexpr internal::ConjTranspose CONJ_TRANS
conjugate transpose
Definition types.hpp:259
constexpr internal::ColumnwiseStorage COLUMNWISE_STORAGE
Columnwise storage.
Definition types.hpp:409
StoreV
Definition types.hpp:383
@ Rowwise
Rowwise storage.
@ Columnwise
Columnwise storage.
constexpr internal::LowerHessenberg LOWER_HESSENBERG
Lower Hessenberg access.
Definition types.hpp:179
Uplo
Definition types.hpp:45
@ General
0 <= i <= m, 0 <= j <= n.
@ Upper
0 <= i <= j, 0 <= j <= n.
@ StrictLower
0 <= i <= m, 0 <= j <= i-1.
@ Lower
0 <= i <= m, 0 <= j <= i.
@ StrictUpper
0 <= i <= j-1, 0 <= j <= n.
@ UpperHessenberg
0 <= i <= j+1, 0 <= j <= n.
@ LowerHessenberg
0 <= i <= m, 0 <= j <= i+1.
constexpr internal::NoTranspose NO_TRANS
no transpose
Definition types.hpp:255
constexpr internal::InfNorm INF_NORM
infinity norm of matrices
Definition types.hpp:340
Norm
Definition types.hpp:296
@ Inf
infinity norm of matrices
@ One
one norm
@ Max
max norm
@ Two
two norm
@ Fro
Frobenius norm of matrices.
constexpr internal::LeftSide LEFT_SIDE
left side
Definition types.hpp:289
Layout
Definition types.hpp:24
@ Unspecified
Used on all other data structures.
@ ColMajor
Column-major layout.
@ Strided
Strided layout.
@ RowMajor
Row-major layout.
Concept for types that represent tlapack::Diag.
Concept for types that represent tlapack::Direction.
Concept for types that represent tlapack::Norm.
Concept for types that represent tlapack::Op.
Concept for types that represent tlapack::Side.
Concept for types that represent tlapack::StoreV.
Concept for types that represent tlapack::Uplo.
Band access.
Definition types.hpp:427
std::size_t lower_bandwidth
Number of subdiagonals.
Definition types.hpp:428
std::size_t upper_bandwidth
Number of superdiagonals.
Definition types.hpp:429
Definition types.hpp:365
Definition types.hpp:395
Definition types.hpp:244
Definition types.hpp:247
Definition types.hpp:359
Definition types.hpp:326
General access.
Definition types.hpp:77
Definition types.hpp:323
Definition types.hpp:278
Lower Hessenberg access.
Definition types.hpp:136
Lower Triangle access.
Definition types.hpp:105
Definition types.hpp:314
Definition types.hpp:238
Definition types.hpp:204
Definition types.hpp:317
Definition types.hpp:281
Definition types.hpp:401
Strict Lower Triangle access.
Definition types.hpp:167
Strict Upper Triangle access.
Definition types.hpp:153
Definition types.hpp:241
Definition types.hpp:320
Definition types.hpp:207
Upper Hessenberg access.
Definition types.hpp:119
Upper Triangle access.
Definition types.hpp:91
Describes a row- or column-major matrix.
Definition types.hpp:443
Describes a strided vector.
Definition types.hpp:458