Port GradientCheck_Hessian tests: replace GTEST_SKIP stubs with real cross-module checks

Implements the two GTEST_SKIP stubs that tracked the missing analytic
Hessian gradient checks (Java @Ignore ports). Both are now replaced with
live cross-module consistency tests that verify euclidean_gradient() ↔
euclidean_hessian() and spherical_gradient() ↔ spherical_hessian() via
finite-difference comparison.

Result: 176 tests from 35 test suites — 176 PASSED, 0 SKIPPED.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-05-18 23:31:40 +02:00
parent 3c973fc3f1
commit 1442de9c8d
2 changed files with 44 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
//
// Test map (Java → C++)
// ──────────────────────
// testHessian (Ignored) → GradientCheck_Hessian (SKIPPED)
// testHessian (Ignored) → GradientCheck_Hessian (ported)
// testGradientWithHyperIdeal… → GradientCheck_OctaFaceVertex (ported)
// testGradientInExtendedDomain → GradientCheck_SpherTetVertex (ported)
// testGradientWithHyperelliptic → GradientCheck_SpherTetAllDofs (ported)
@@ -23,6 +23,7 @@
#include "conformal_mesh.hpp"
#include "mesh_builder.hpp"
#include "spherical_functional.hpp"
#include "spherical_hessian.hpp"
#include <gtest/gtest.h>
#include <cmath>
#include <vector>
@@ -30,12 +31,29 @@
using namespace conformallab;
// ════════════════════════════════════════════════════════════════════════════
// @Ignore in Java: no Hessian implemented
// Cross-module Hessian check: spherical_gradient() ↔ spherical_hessian()
//
// Java @Ignore reason: "no Hessian implemented" — the Java functional test
// was written before the Hessian existed. In C++ the analytic spherical
// Hessian (spherical_hessian.hpp, Phase 3f) is complete.
//
// This test verifies cross-module consistency between the functional and
// the Hessian module. The spherical Hessian is NSD (negative semi-definite)
// because the spherical energy is concave — hessian_check_spherical() uses
// the sign-corrected FD check appropriate for the spherical case.
// ════════════════════════════════════════════════════════════════════════════
TEST(SphericalFunctional, GradientCheck_Hessian)
{
GTEST_SKIP() << "@Ignore in Java Hessian not implemented";
auto mesh = make_spherical_tetrahedron();
auto maps = setup_spherical_maps(mesh);
compute_lambda0_from_mesh(mesh, maps);
int n = assign_vertex_dof_indices(mesh, maps);
std::vector<double> x(static_cast<std::size_t>(n), -0.2);
EXPECT_TRUE(hessian_check_spherical(mesh, x, maps))
<< "Cross-module: spherical_gradient() and spherical_hessian() are inconsistent";
}
// ════════════════════════════════════════════════════════════════════════════