<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
LegacyBandedMatrix.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_BANDED_HH
11#define TLAPACK_LEGACY_BANDED_HH
12
13#include <cassert>
14
16
17namespace tlapack {
18
29template <typename T, class idx_t = std::size_t>
31 idx_t m, n, kl, ku;
32 T* ptr;
33
42 constexpr const T& operator()(idx_t i, idx_t j) const noexcept
43 {
44 assert(i >= 0);
45 assert(i < m);
46 assert(j >= 0);
47 assert(j < n);
48 assert(j <= i + ku);
49 assert(i <= j + kl);
50 return ptr[(ku + i) + j * (ku + kl)];
51 }
52
53 constexpr T& operator()(idx_t i, idx_t j) noexcept
54 {
55 assert(i >= 0);
56 assert(i < m);
57 assert(j >= 0);
58 assert(j < n);
59 assert(j <= i + ku);
60 assert(i <= j + kl);
61 return ptr[(ku + i) + j * (ku + kl)];
62 }
63
64 constexpr LegacyBandedMatrix(idx_t m, idx_t n, idx_t kl, idx_t ku, T* ptr)
65 : m(m), n(n), kl(kl), ku(ku), ptr(ptr)
66 {
67 tlapack_check(m >= 0);
68 tlapack_check(n >= 0);
69 tlapack_check((kl + 1 <= m || m == 0) && (ku + 1 <= n || n == 0));
70 }
71};
72
73} // namespace tlapack
74
75#endif // TLAPACK_LEGACY_BANDED_HH
#define tlapack_check(cond)
Throw an error if cond is false.
Definition exceptionHandling.hpp:98
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
Legacy banded matrix.
Definition LegacyBandedMatrix.hpp:30
constexpr const T & operator()(idx_t i, idx_t j) const noexcept
Access A(i,j) = ptr[ (ku+(i-j)) + j*(ku+kl+1) ].
Definition LegacyBandedMatrix.hpp:42
idx_t ku
Sizes.
Definition LegacyBandedMatrix.hpp:31
T * ptr
Pointer to array in memory.
Definition LegacyBandedMatrix.hpp:32