<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
infnorm_colmajor.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_INFNORM_COLMAJOR_HH
11#define TLAPACK_INFNORM_COLMAJOR_HH
12
14
15namespace tlapack {
16
25template <class T, TLAPACK_MATRIX matrix_t>
27{
28 return WorkInfo(nrows(A));
29}
30
39template <TLAPACK_MATRIX matrix_t, TLAPACK_WORKSPACE work_t>
41{
42 using T = type_t<matrix_t>;
43 using real_t = real_type<T>;
44 using idx_t = size_type<matrix_t>;
46
47 // constants
48 const idx_t m = nrows(A);
49 const idx_t n = ncols(A);
50
51 // quick return
52 if (m == 0 || n == 0) return real_t(0);
53
54 // Vector w
55 auto [w, work1] = reshape(work, m);
56
57 // Norm value
58 real_t norm(0);
59
60 for (idx_t i = 0; i < m; ++i)
61 w[i] = abs(A(i, 0));
62
63 for (idx_t j = 1; j < n; ++j)
64 for (idx_t i = 0; i < m; ++i)
65 w[i] += abs(A(i, j));
66
67 for (idx_t i = 0; i < m; ++i) {
68 real_t temp = w[i];
69
70 if (temp > norm)
71 norm = temp;
72 else {
73 if (isnan(temp)) return temp;
74 }
75 }
76
77 return norm;
78}
79
91template <TLAPACK_MATRIX matrix_t>
93{
94 using T = type_t<matrix_t>;
95 using real_t = real_type<T>;
96 using idx_t = size_type<matrix_t>;
97
98 // constants
99 const idx_t m = nrows(A);
100 const idx_t n = ncols(A);
101
102 // quick return
103 if (m == 0 || n == 0) return real_t(0);
104
105 // Allocates workspace
107 std::vector<T> work_;
108 auto work = new_matrix(work_, workinfo.m, workinfo.n);
109
111}
112
113} // namespace tlapack
114
115#endif // TLAPACK_INFNORM_COLMAJOR_HH
constexpr bool isnan(const T &x) noexcept
Extends std::isnan() to complex numbers.
Definition utils.hpp:125
auto infnorm_colmajor(const matrix_t &A)
Calculates the infinity norm of a column-major matrix.
Definition infnorm_colmajor.hpp:92
auto infnorm_colmajor_work(const matrix_t &A, work_t &work)
Calculates the infinity norm of a column-major matrix. Workspace is provided as an argument.
Definition infnorm_colmajor.hpp:40
constexpr WorkInfo infnorm_colmajor_worksize(const matrix_t &A)
Worspace query of infnorm_colmajor()
Definition infnorm_colmajor.hpp:26
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
Output information in the workspace query.
Definition workspace.hpp:16