Metis 2.0.0
High-performance C++20 dual-mode numerical framework
Loading...
Searching...
No Matches
DiffTestHarness.hpp File Reference

GTest-free core for differentiability testing of dual-mode functions. More...

#include <Eigen/Dense>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>
#include <metis/core/Function.hpp>
#include <metis/core/MetisIO.hpp>
#include <metis/core/MetisTypes.hpp>
#include <metis/math/AutoDiff.hpp>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <vector>
Include dependency graph for DiffTestHarness.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  metis::diff_test::DiffTestOptions
 Options controlling differentiability test behavior. More...
struct  metis::diff_test::DualModeResult
 Result of a dual-mode (symbolic compilation + value match) check. More...
struct  metis::diff_test::DiffTestResult
 Result of a full differentiability check (dual-mode + Jacobian). More...

Namespaces

namespace  metis
namespace  metis::diff_test
namespace  metis::diff_test::detail

Functions

template<typename F, typename T>
constexpr int metis::diff_test::detail::detect_arity ()
 Detect the arity of a callable when invoked with arguments of type T.
template<typename Func, typename Scalar>
constexpr int metis::diff_test::detail::arity_of ()
 Get the detected arity of a callable for a given scalar type.
template<typename Func, typename Scalar>
auto metis::diff_test::detail::invoke (Func &&f, const std::vector< Scalar > &args)
 Invoke a callable with N arguments unpacked from a vector.
template<typename T>
Eigen::VectorXd metis::diff_test::detail::to_numeric_vector (const T &val)
 Normalize a scalar or vector return to Eigen::VectorXd.
template<typename T>
std::vector< SymbolicArgmetis::diff_test::detail::to_symbolic_output_args (const T &val)
 Normalize a symbolic scalar or vector return to a vector of SymbolicArg.
std::string metis::diff_test::detail::format_point (const std::vector< double > &point)
 Format a test point as a string for diagnostics.
std::string metis::diff_test::detail::format_matrix (const Eigen::MatrixXd &m)
 Format an Eigen matrix as a string for diagnostics.
template<typename Func>
DualModeResult metis::diff_test::verify_dual_mode_at_point (Func &&f, const std::vector< double > &point, const DiffTestOptions &opts={})
 Verify that a dual-mode function compiles symbolically and that symbolic evaluation matches numeric evaluation at a single point.
template<typename Func>
DualModeResult metis::diff_test::verify_dual_mode (Func &&f, const std::vector< std::vector< double > > &test_points, const DiffTestOptions &opts={})
 Verify dual-mode across multiple test points. Returns on first failure.
template<typename Func>
DiffTestResult metis::diff_test::verify_differentiable_at_point (Func &&f, const std::vector< double > &point, const DiffTestOptions &opts={})
 Verify differentiability at a single test point: dual-mode checks + AD Jacobian vs FD Jacobian.
template<typename Func>
DiffTestResult metis::diff_test::verify_differentiable (Func &&f, const std::vector< std::vector< double > > &test_points, const DiffTestOptions &opts={})
 Verify differentiability across multiple test points. Returns on first failure.

Detailed Description

GTest-free core for differentiability testing of dual-mode functions.

Provides utilities to verify that dual-mode (numeric/symbolic) functions: (a) compile in symbolic mode (b) produce matching numeric and symbolic outputs (c) have AD Jacobians that match finite-difference Jacobians

This header has NO GoogleTest dependency. See GTestDiffTest.hpp for GTest wrappers.

See also
GTestDiffTest.hpp, AutoDiff.hpp, FiniteDifference.hpp