20template <
class T>
constexpr double eps() {
return std::numeric_limits<float_t<T>>::epsilon() * 0.5; }
23inline double nanmax(
double a,
double b) {
24 if (std::isnan(a) || std::isnan(b))
return std::numeric_limits<double>::quiet_NaN();
66 else return std::is_same_v<T, float> ?
"float" :
"double";
89inline void record(
const char* kind,
const char* dtype,
int n,
double value,
double b,
double factor,
const char* reason) {
91 static std::string open_path;
92 static std::FILE* f =
nullptr;
93 std::lock_guard<std::mutex> lock(mu);
94 const char* path = std::getenv(
"BATCHLAS_VERIFY_RECORD");
95 if (!path || !*path) {
96 if (f) std::fclose(f);
101 if (!f || open_path != path) {
102 if (f) std::fclose(f);
103 f = std::fopen(path,
"a");
107 std::string r(reason);
109 if (std::isspace(
static_cast<unsigned char>(c))) c =
'_';
110 std::fprintf(f,
"%s %s %d %.17g %.17g %.17g %s\n", kind, dtype, n, value, b, factor, r.c_str());
118 const double f = kind ==
Check::blas ? double(n < 0 ? 0 : n) + 2.0 : double(n < 1 ? 1 : n);
129template <
class T>
bool within(
Check kind,
int n,
double value) {
return !std::isnan(value) && value <= bound<T>(kind, n); }
132 return !std::isnan(value) && value <= bound<T>(kind, n, slack);
137template <
class T>
bool pass(
Check kind,
int n,
double value) {
The call violates the API contract.
Enumerations, scalar traits and scalar concepts shared by every public header.
The BatchLAS exception hierarchy.
constexpr bool is_std_complex_v
Value of is_std_complex<T>.
typename base_type< T >::type float_t
Shorthand for base_type<T>::type: the precision of T (tolerances, norms, eigenvalues).
const char * kind_name(Check kind)
void record(const char *kind, const char *dtype, int n, double value, double b, double factor, const char *reason)
void check_slack(const Slack &s)
double coefficient(Check kind)
constexpr const char * dtype_name()
bool within(Check kind, int n, double value)
pass without recording: for predicates evaluated on results expected to be wrong.
constexpr double eps()
Unit roundoff of T's real type: 2^-24 for float, 2^-53 for double.
Check
orthogonality: Q from Householder reflectors or a direct orthogonalization (geqrf,...
@ orthogonality_rotations
double nanmax(double a, double b)
max(a, b), NaN if either is NaN (std::max drops a NaN second argument, so a poisoned value would pass...
double pivot_ratio_bound()
Bound of pivot_ratio: 1 + 64 eps<T>() (32 machine epsilons), the slack of a cabs1 comparison in T.
double bound(Check kind, int n)
c(kind) * f(n) * eps<T>(): f(n) = n (below 1 counts as 1), except blas, f(k) = k + 2 (k below 0 count...
bool pass(Check kind, int n, double value)
True when value is not NaN and within bound<T>(kind, n).
A per-site factor on a kind's bound, in either direction.