static void MAXREL_f64(const long long size, const byte* const __restrict__ recon, const byte* const __restrict__ orig, const int paramc, const double paramv [])
{
using type_f = double;
using type_i = long long;
assert(sizeof(type_f) == sizeof(type_i));
if ((size % sizeof(type_f)) != 0) {fprintf(stderr, "ERROR: MAXREL_f64 requires data to be a multiple of %ld bytes long\n", sizeof(type_f)); throw std::runtime_error("LC error");}
if (paramc != 1) {fprintf(stderr, "ERROR: MAXREL_f64 requires one parameter that specifies the maximum allowed relative error\n"); throw std::runtime_error("LC error");}
const type_f errorbound = paramv[0];
if (errorbound <= 0) {fprintf(stderr, "ERROR: MAXREL_f64 requires the maximum allowed relative error to be greater than zero\n"); throw std::runtime_error("LC error");}
const type_f* const orig_f = (type_f*)orig;
const type_f* const recon_f = (type_f*)recon;
const long long len = size / sizeof(type_f);
for (long long i = 0; i < len; i++) {
if ((orig_f[i] == 0) || (recon_f[i] == 0)) { if (orig_f[i] != recon_f[i]) {
fprintf(stderr, "MAXREL_f64 ERROR: relative error bound of %e exceeded at position %lld: value is '%e' vs '%e'\n\n", errorbound, i, recon_f[i], orig_f[i]);
throw std::runtime_error("LC error");
}
} else if (!std::isfinite(orig_f[i]) || !std::isfinite(recon_f[i])) { if (recon_f[i] != orig_f[i]) {
if (!std::isnan(orig_f[i]) || !std::isnan(recon_f[i])) { fprintf(stderr, "MAXREL_f64 ERROR: relative error bound of %e exceeded at position %lld: value is '%e' vs '%e'\n\n", errorbound, i, recon_f[i], orig_f[i]);
throw std::runtime_error("LC error");
}
}
} else {
const type_f abs_orig_f = std::abs(orig_f[i]);
const type_f abs_recon_f = std::abs(recon_f[i]);
const type_f lower = abs_orig_f / (1 + errorbound);
const type_f upper = abs_orig_f * (1 + errorbound);
if ((std::signbit(orig_f[i]) != std::signbit(recon_f[i])) || (abs_recon_f < lower) || (abs_recon_f > upper)) {
fprintf(stderr, "MAXREL_f64 ERROR: relative error bound of %e exceeded at position %lld: value is '%e' vs '%e'\n\n", errorbound, i, recon_f[i], orig_f[i]);
throw std::runtime_error("LC error");
}
}
}
printf("MAXREL_f64 verification passed\n");
}