<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
constants.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_CONSTANTS_HH
11#define TLAPACK_CONSTANTS_HH
12
13#include <limits>
14#include <type_traits>
15
17
18namespace tlapack {
19
20// -----------------------------------------------------------------------------
21// Macros to compute scaling constants
22
31template <TLAPACK_REAL real_t>
32constexpr real_t ulp() noexcept
33{
34 return std::numeric_limits<real_t>::epsilon();
35}
36
50template <TLAPACK_REAL real_t>
52{
53 return ulp<real_t>() * std::numeric_limits<real_t>::round_error();
54}
55
63template <typename real_t>
65{
66 return std::numeric_limits<real_t>::digits;
67}
68
76template <TLAPACK_REAL real_t>
78{
79 const int fradix = std::numeric_limits<real_t>::radix;
80 const int expm = std::numeric_limits<real_t>::min_exponent;
81 const int expM = std::numeric_limits<real_t>::max_exponent;
82
83 return pow(fradix, real_t(max(expm - 1, 1 - expM)));
84}
85
92template <TLAPACK_REAL real_t>
94{
95 return real_t(1) / safe_min<real_t>();
96}
97
102template <TLAPACK_REAL real_t>
104{
105 const real_t half(0.5);
106 const int fradix = std::numeric_limits<real_t>::radix;
107 const int expm = std::numeric_limits<real_t>::min_exponent;
108
109 return pow(fradix, ceil(half * real_t(expm - 1)));
110}
111
116template <TLAPACK_REAL real_t>
118{
119 const real_t half(0.5);
120 const int fradix = std::numeric_limits<real_t>::radix;
121 const int expM = std::numeric_limits<real_t>::max_exponent;
122 const int t = digits<real_t>();
123
124 return pow(fradix, floor(half * real_t(expM - t + 1)));
125}
126
135template <TLAPACK_REAL real_t>
137{
138 const real_t half(0.5);
139 const int fradix = std::numeric_limits<real_t>::radix;
140 const int expm = std::numeric_limits<real_t>::min_exponent;
141 const int t = digits<real_t>();
142
143 return pow(fradix, -floor(half * real_t(expm - t)));
144}
145
150template <TLAPACK_REAL real_t>
152{
153 const real_t half(0.5);
154 const int fradix = std::numeric_limits<real_t>::radix;
155 const int expM = std::numeric_limits<real_t>::max_exponent;
156 const int t = digits<real_t>();
157
158 return pow(fradix, -ceil(half * real_t(expM + t - 1)));
159}
160
161} // namespace tlapack
162
163#endif // TLAPACK_CONSTANTS_HH
constexpr real_t uroundoff() noexcept
Unit roundoff.
Definition constants.hpp:51
int digits() noexcept
Digits.
Definition constants.hpp:64
constexpr real_t blue_min() noexcept
Blue's min constant b for the sum of squares.
Definition constants.hpp:103
constexpr real_t ulp() noexcept
Unit in the Last Place.
Definition constants.hpp:32
constexpr real_t blue_scalingMax() noexcept
Blue's scaling constant for numbers bigger than B.
Definition constants.hpp:151
constexpr real_t blue_scalingMin() noexcept
Blue's scaling constant for numbers smaller than b.
Definition constants.hpp:136
constexpr real_t safe_max() noexcept
Safe Maximum.
Definition constants.hpp:93
constexpr real_t blue_max() noexcept
Blue's max constant B for the sum of squares.
Definition constants.hpp:117
constexpr real_t safe_min() noexcept
Safe Minimum.
Definition constants.hpp:77
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