Files
FESADev/tests/reference/reference_tolerance_policy.h
T

81 lines
2.0 KiB
C++

#ifndef FESA_TESTS_REFERENCE_REFERENCE_TOLERANCE_POLICY_H_
#define FESA_TESTS_REFERENCE_REFERENCE_TOLERANCE_POLICY_H_
#include <cstddef>
#include <string>
#include <vector>
namespace fesa::test {
enum class ReferenceToleranceBranch {
kNearZero,
kRelative,
kZeroScaleExact,
};
struct ReferenceToleranceRow {
double fesa_value;
double reference_value;
};
struct ReferenceToleranceFamily {
std::string identity;
std::vector<std::string> components;
bool blocking;
std::vector<ReferenceToleranceRow> rows;
};
struct ReferenceToleranceRowDecision {
double absolute_error;
double threshold;
double relative_error;
bool relative_error_applicable;
ReferenceToleranceBranch branch;
bool passed;
};
struct ReferenceToleranceFamilyDecision {
std::string identity;
std::vector<std::string> components;
bool blocking;
double reference_scale;
double near_zero_band;
std::size_t near_zero_count;
double relative_rms;
double maximum_absolute_error;
std::size_t worst_row;
bool rms_passed;
bool passed;
std::string diagnostic_code;
std::vector<ReferenceToleranceRowDecision> rows;
std::size_t row_count{};
};
struct ReferenceToleranceEvaluation {
bool valid;
std::string diagnostic_code;
bool passed;
std::vector<ReferenceToleranceFamilyDecision> families;
};
class ReferenceTolerancePolicy {
public:
static constexpr double kNearZeroRatio = 0.01;
static constexpr double kRelativeTolerance = 0.05;
static constexpr double kRelativeRmsTolerance = 0.01;
static constexpr const char* kMitc4EigenFirstImplementationPolicyId =
"mitc4-eigen-first-implementation";
static ReferenceToleranceEvaluation Evaluate(
const std::vector<ReferenceToleranceFamily>& families);
/// @brief Applies the approved five-percent RMS limit to blocking singleton
/// Value families from the MITC4 eigen first implementation only.
static ReferenceToleranceEvaluation EvaluateMitc4EigenFirstImplementation(
const std::vector<ReferenceToleranceFamily>& families);
};
}
#endif