Tarik Moussa
1442de9c8d
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 >
2026-05-18 23:31:40 +02:00
Tarik Moussa
7edf699ac2
test/docs: Scalability Smoke Tests + Komplexitätsdokumentation
...
C++ Tests / test-fast (push) Successful in 2m37s
C++ Tests / test-cgal (push) Has been skipped
test_scalability_smoke.cpp (3 neue Tests → 176 CGAL-Tests gesamt):
SmokeEuclidean.CatHead_SmallOpen — V=131, Newton 3 iter, <1ms
SmokeEuclidean.Brezel_LargeGenus2 — V=6910, Newton 3 iter, 69ms (Apple M)
SmokeEuclidean.Brezel2_Genus2_CutGraph — V=2622, Cut Graph 10ms, 4 Nähte
- Korrektheit-Assertions (iter<30, ||G||<1e-8), kein Timing-Assert (CI-stabil)
- Informative Ausgabe: iter, Residuum, Laufzeit als stdout-Print
- Korrektur: brezel.obj ist Genus-2 (χ=−2), nicht Genus-1 (Namensgebung
aus Java-Original übernommen, nicht topologisch)
- Perturbation x0=−0.05 damit Newton tatsächlich iteriert
doc/math/complexity.md (neu):
- O()-Analyse aller Pipeline-Schritte tabellarisch
- Gemessene Timings auf echten Meshes (Apple M, Release, Single-Thread)
- HyperIdeal-FD-Hessian als bekannter Bottleneck dokumentiert
- Skalierungsprojektion bis V=100K
- Speicherverbrauch-Tabelle
- Reproduzierbare Messanleitung
README.md + CLAUDE.md: Testzähler 173→176, complexity.md verlinkt
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-18 23:05:22 +02:00
Tarik Moussa
de3a35ad4f
test: Java-Konvergenz- + Homologie-Tests portiert — 173 CGAL-Tests
...
C++ Tests / test-fast (push) Successful in 2m0s
C++ Tests / test-cgal (push) Has been skipped
Mesh-Dateien aus Java-Referenzimplementierung übernommen:
code/data/obj/cathead.obj — offenes Mesh (Java: cathead.obj)
code/data/obj/tetraflat.obj — flaches Tetraeder (Java: tetraflat.obj)
code/data/obj/brezel.obj — Genus-1-Brezel (Java: brezel.obj)
code/data/obj/brezel2.obj — Genus-2-Brezel, V=2622 F=5248 χ=−2 (Java: brezel2.obj)
code/.gitignore: !data/**/*.obj — Mesh-Daten von *.obj-Regel ausgenommen.
Neue Tests in test_geometry_utils.cpp:
HomologyGenerators.Genus2_FourCutEdges [vorher: GTEST_SKIP]
Java: HomologyTest.testHomology — brezel2.obj, expects paths.size()==4
C++: compute_cut_graph(brezel2) → cut_edge_indices.size()==4, genus==2
EuclideanLayout.DoLayout_TetraFlat_EdgeLengthsPreserved [neu]
Java: EuclideanLayoutTest.testDoLayout — tetraflat.obj, u=0, l3D==lUV (1e-11)
C++: euclidean_layout(tetraflat, x=0) → alle UV-Kantenlängen == 3D (1e-10)
EuclideanLayout.CatHead_NewtonConverges_AngleSumsTwoPi [neu]
Java: EuclideanLayoutTest.testLayout02 + EuclideanCyclicConvergenceTest
C++: newton_euclidean(cathead) konvergiert, Gradientenreste < 1e-6
SphericalLayout.SphericalTetrahedron_NewtonConverges_AngleSumsTwoPi [neu]
Java: SphericalConvergenceTest.testSphericalConvergence
C++: newton_spherical(sph_tetrahedron) konvergiert, Winkeldefekte < 1e-6
CMakeLists.txt: CONFORMALLAB_DATA_DIR=${CMAKE_SOURCE_DIR}/data als Compile-Def.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-18 01:33:21 +02:00
Tarik Moussa
a4438c9a1a
test: Java-Geometrie-Utility-Tests portiert (Tests 1–6) + Genus-2-TODO-Stub
...
C++ Tests / test-fast (push) Successful in 2m4s
C++ Tests / test-cgal (push) Has been skipped
Portiert aus CuttinUtilityTest, UnwrapUtilityTest, ConvergenceUtilityTests
und HomologyTest (Java-Quelldatei unifgeo/test). Jetzt 170 CGAL-Tests.
Neue Suiten in test_geometry_utils.cpp:
CuttingUtility — point_in_triangle_2d (3 Tests, Java-Test 1–2)
UnwrapUtility — Eckwinkel law-of-cosines (2 Tests, Java-Test 3)
ConvergenceUtility — circumradius + scale-invariant R_f/sqrt(A) (6 Tests, Java-Test 4–6)
HomologyGenerators — GTEST_SKIP-Stub für Genus-2 (Java-Test 7, Phase 8)
Der Stub dokumentiert genau was fehlt (Genus-2-Mesh), welcher Code nötig ist
(compute_cut_graph → 4 cut edges) und die Java-Herkunft.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-14 11:09:27 +02:00
Tarik Moussa
e7dfaed56c
feat(phase7): Java-parity layout — priority BFS, halfedge_uv, Möbius holonomy, period matrix, fundamental domain — 158 tests
...
Phase 7 adds seven features ported from the original Java ConformalLab:
layout.hpp
- Priority BFS (min-heap on BFS depth) replaces FIFO queue, minimising
trilateration error accumulation from the root face outward.
- MobiusMap struct: T(z)=(az+b)/(cz+d), identity/inverse/compose,
from_three (3×3 complex least-squares fit), apply(Vector2d).
- halfedge_uv[h.idx()] = UV of source(h) in face(h); seam halfedges
carry the virtual unfolded position, enabling proper GPU texture atlases.
- Hyperbolic holonomy stored as MobiusMap per cut edge (SU(1,1) isometry).
- best_root_face: largest 3-D area face, 1.5× interior bonus.
- normalise_euclidean also transforms halfedge_uv (centroid + PCA).
- Face-area-weighted iterative Möbius centering (Fréchet mean, Phase 7).
period_matrix.hpp (new)
- PeriodData: lattice generators ω_i as complex numbers, τ = ω₂/ω₁ ∈ ℍ.
- reduce_to_fundamental_domain: SL(2,ℤ) reduction via alternating S/T steps.
- is_in_fundamental_domain, compute_period_matrix.
- NOTE: Siegel matrix Ω for genus g>1 intentionally deferred.
fundamental_domain.hpp (new)
- FundamentalDomain: CCW parallelogram {0, ω₁, ω₁+ω₂, ω₂} for genus 1.
- edge_identifications, generators stored.
- 4g-polygon boundary-walk for g>1 marked TODO(Phase 8) with full algorithm
outline and literature references.
- tiling_copy / tiling_neighbourhood for universal cover visualisation.
Tests: 121 → 158 (+37 Phase 7 tests covering all new features).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-13 07:57:13 +02:00
Tarik Moussa
4fc48b39f0
feat(phase6): exact hyperbolic layout, Gauss–Bonnet, cut graph, normalisation — 121 tests
...
New files:
- gauss_bonnet.hpp: euler_characteristic, genus, Σ(2π-Θ_v) sum/rhs/deficit,
check_gauss_bonnet (throws), enforce_gauss_bonnet (correct sign: Δ=(lhs-rhs)/V)
- cut_graph.hpp: CutGraph struct + compute_cut_graph (tree-cotree, Erickson–Whittlesey
2005); boundary edges correctly excluded from cut set
- test_phase6.cpp: 26 new tests (GaussBonnet ×8, CutGraph ×6, HyperbolicTrilateration
×4, Normalisation ×4 — all pass)
layout.hpp (Phase 6 rewrite):
- detail::trilaterate_hyp: exact Möbius + hyperbolic law of cosines replacing old tanh(d/2)
- detail::center_poincare_disk: Möbius centering for hyperbolic normalisation
- normalise_euclidean: centroid → origin + PCA major-axis rotation
- normalise_hyperbolic: Möbius centering in the Poincaré disk
- normalise_spherical: Rodrigues rotation → north pole
- euclidean_layout / hyper_ideal_layout: optional CutGraph* + HolonomyData* + normalise
Bug fixes caught by new tests:
- gauss_bonnet.hpp: enforce_gauss_bonnet had wrong sign for delta
- cut_graph.hpp: boundary edges were incorrectly marked as cut edges
121 tests pass, 2 skipped (Hessian stubs).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-13 01:15:41 +02:00
Tarik Moussa
b7593e3f6d
feat(phase5): Layout, CLI, JSON/XML serialisation — 95 tests
...
Phase 5 complete:
layout.hpp
- euclidean_layout(): BFS unfolding in ℝ² using trilaterate_2d
- spherical_layout(): BFS on S² using trilaterate_sph (spherical law of cosines)
- hyper_ideal_layout(): BFS in Poincaré disk (tanh(d/2) Euclidean approx)
- save_layout_off(): convenience OFF writer for 2-D and 3-D layouts
serialization.hpp
- save/load_result_json(): nlohmann/json; stores DOF vector + uv/pos layout
- save/load_result_xml(): hand-written writer/parser; same schema
conformallab_cli.cpp (rewritten)
- CLI11 interface: -i/-o/-g/-j/-x/-s/-v
- Dispatches to euclidean / spherical / hyper_ideal pipeline
- Runs Newton, computes layout, saves OFF + JSON + XML
examples/example_layout.cpp
- Full round-trip demo: solve → layout → JSON/XML → reload → verify
tests/cgal/test_layout.cpp (8 tests)
- Euclidean_PreservesEdgeLengths, CorrectVertexCount, TriangleIsNonDegenerate
- Spherical_PreservesArcLengths, PositionsOnUnitSphere
- HyperIdeal_SuccessAndFinitePositions
- Serialization.JSON_RoundTrip, XML_RoundTrip
All 95 CGAL tests pass (2 skipped — Hessian stubs unchanged).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-13 00:53:47 +02:00
Tarik Moussa
3f124eb071
feat(phase4): HyperIdeal Newton solver, SparseQR fallback, examples, docs
...
Phase 4 complete — 87 CGAL tests pass, 2 skipped.
Newton solver (phase4a):
- hyper_ideal_hessian.hpp: symmetric FD Hessian (O(ε²), PSD by convexity)
- newton_hyper_ideal(): Newton + backtracking for the HyperIdeal functional
- detail::solve_with_fallback(): optional bool* fallback_used parameter
- solve_linear_system(): public API exposing LDLT→SparseQR fallback
SparseQR fallback tests (SparseQRFallback.*):
- FullRankSystem_CorrectSolution: LDLT path, fallback_used=false
- SingularMatrix_FallbackActivated: zero-pivot → QR activated, fallback_used=true
- Euclidean_ClosedMeshNoPinConverges: gauge-mode null space handled via QR
HyperIdeal Newton tests (NewtonSolver.HyperIdeal_*):
- ConvergesTriangleAllVariable, ResultFieldsConsistent,
ConvergesTetrahedron, SparseQRFallbackNoCrash
- Natural-target base point (b=1.0, a=0.5) — x=0 is degenerate in log-space
Pipeline tests (test_pipeline.cpp):
- End-to-end: all three geometries, mesh I/O round-trip, solve+export
Example programs (code/examples/):
- example_euclidean.cpp: headless Euclidean pipeline
- example_hyper_ideal.cpp: headless HyperIdeal pipeline
- example_viewer.cpp: interactive libigl viewer with jet colour map
README:
- Mathematical scope table: C++ vs Java original (18 rows)
- "For mathematicians" section: mental model, step-by-step new-functional
guide, half-edge traversal snippets, recommended reading
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-13 00:11:25 +02:00
Tarik Moussa
e70689d29f
feat(phase4a+4b): Newton solver + CGAL mesh I/O
...
Phase 4a — newton_solver.hpp:
- newton_euclidean(): SimplicialLDLT on H (PSD); solves H·Δx = −G
- newton_spherical(): SimplicialLDLT on −H (NSD→PSD); solves (−H)·Δx = G
- Backtracking line search (halving α up to 20×) for global convergence
- NewtonResult struct: x, iterations, grad_inf_norm, converged
- 7 tests: 4 spherical (convergence, few iters, large perturbation,
field consistency) + 3 Euclidean (triangle pinned, quad pinned,
mixed pinned — all with natural-theta equilibrium at x=0)
Phase 4b — mesh_io.hpp:
- read_mesh() / write_mesh(): CGAL::IO::read/write_polygon_mesh wrappers
- load_mesh() / save_mesh(): throwing convenience versions
- Supports OFF, OBJ, PLY (format detected by file extension)
- 6 tests: OFF round-trip (tet + quad), OBJ round-trip, missing-file throw,
vertex-position preservation, save/load convenience wrappers
All 75 cgal tests pass (3 skipped as before).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-05-12 17:35:00 +02:00
Tarik Moussa
194effba97
feat(phase3f+3g): analytical Hessians + PI consolidation
...
Phase 3g — constants.hpp:
- Introduce conformallab::PI and TWO_PI in a single constants.hpp
- Remove scattered local PI/pi definitions from hyper_ideal_geometry.hpp,
hyper_ideal_utility.hpp, euclidean_functional.hpp, mesh_builder.hpp,
spherical_geometry.hpp (backward-compatible PI_SPHER alias kept)
Phase 3f — Euclidean Hessian (euclidean_hessian.hpp):
- Cotangent-Laplace operator (Pinkall–Polthier 1993)
- euclidean_cot_weights() helper + euclidean_hessian() + hessian_check_euclidean()
- Correct Pinkall–Polthier 1/2 normalization factor
- 8 tests: cot weights, symmetry, null-space (H·1=0), PSD, FD × 4 meshes
Phase 3f — Spherical Hessian (spherical_hessian.hpp):
- Derives ∂α_i/∂u_j directly from the spherical law of cosines:
∂α1/∂l_opp = sin(l_opp) / [sin(l_a)·sin(l_b)·sin(α1)]
∂α1/∂l_adj = [cot(l_adj)·cos(α1) − cot(l_other)] / sin(α1)
then chains with ∂l/∂λ = tan(l/2)
- spherical_cot_weights() kept as a standalone helper (tested separately)
- 8 tests: cot weights, symmetry, correct null-space & sign-convention
(H·1 ≠ 0; H is NSD at equilibrium), FD × 3 meshes
All 62 cgal tests pass (3 skipped as before).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-05-12 17:22:28 +02:00
Tarik Moussa
8c353bb884
feat(phase3d+3e): port EuclideanCyclicFunctional + add SphericalFunctional gauge-fix
...
Phase 3d — EuclideanCyclicFunctional:
• euclidean_geometry.hpp: t-value / atan2 corner-angle formula with
centering trick (μ = (Λ̃₁₂+Λ̃₂₃+Λ̃₃₁)/6) for numerical stability
• euclidean_functional.hpp: EuclideanMaps bundle, gradient (G_v = Θ_v − Σα_v,
G_e = α_opp⁺ + α_opp⁻ − φ_e), 10-point GL path-integral energy,
gradient_check_euclidean — identical halfedge convention to SphericalFunctional
• test_euclidean_functional.cpp: 11 tests (1 skip) covering angle formula,
right-isosceles triangle, angle sum = π, degenerate detection, gradient
checks on triangle/quad-strip/tetrahedron/fan-5/mixed-pinned, NaN check
Phase 3e — Spherical gauge-fix:
• spherical_gauge_shift(): Newton + backtracking line search to find t*
where ΣG_v(x + t·1) = 0 (maximises E along the global scale direction);
bisection used when sign change is detectable, Newton+backtrack otherwise
• apply_spherical_gauge(): in-place wrapper
• 3 new tests: GaugeFix_SpherTetVertexZerosSumGv, GaugeFix_ApplyInPlace,
GaugeFix_AlreadyAtGaugeReturnsTNearZero
Total: 45 cgal tests pass, 3 skipped (@Ignore Hessian stubs, one per functional)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-12 07:39:14 +02:00
Tarik Moussa
a4c2a89e7e
feat(phase3c): port SphericalFunctional onto ConformalMesh; update README
...
New headers:
- spherical_geometry.hpp: spherical arc length l(λ) and half-angle formula
for interior angles of a spherical triangle (SphericalFaceAngles struct)
- spherical_functional.hpp: SphericalMaps bundle, setup/assign DOF helpers,
compute_lambda0_from_mesh(), gradient (Θ_v − Σα_v; Schläfli edge formula),
energy via 10-point Gauss-Legendre path integral, gradient_check_spherical()
Updated:
- mesh_builder.hpp: add make_spherical_tetrahedron() (vertices on unit sphere)
and make_octahedron_face() (single right-angled spherical triangle)
- tests/cgal/CMakeLists.txt: enable test_spherical_functional.cpp
- README.md: rewrite for CGAL-package goal, two test targets, all headers,
updated project tree, Phase progress table, key design decisions
Tests (cgal.SphericalFunctional.*): 8 active + 1 skip
- OctaFaceAnglesAreRightAngles, SpherTetAngleSumExceedsPi
- GradientCheck_{OctaFaceVertex, SpherTetVertex, SpherTetAllDofs,
SpherFan4Vertex, MixedPinnedVertices}
- AnglesFiniteAtKnownPoint
All 30 cgal.* tests pass (2 @Ignore skips).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-12 00:01:24 +02:00
Tarik Moussa
516ac89bd8
feat(phase3b): port HyperIdealFunctional energy + gradient onto ConformalMesh
...
Implements the hyper-ideal discrete conformal map functional on
CGAL::Surface_mesh. The energy and analytic gradient are ported directly
from HyperIdealFunctional.java; correctness is verified via a
finite-difference gradient check (same eps=1E-5 / tol=1E-4 as Java).
New files:
include/hyper_ideal_geometry.hpp — ζ, ζ₁₃, ζ₁₄, ζ₁₅, lij, αij, σi, σij
include/hyper_ideal_functional.hpp — HyperIdealMaps, evaluate_hyper_ideal,
gradient_check
tests/cgal/test_hyper_ideal_functional.cpp — 6 tests (1 skipped @Ignore)
Test results (local, -DWITH_CGAL=ON):
conformallab_cgal_tests: 21 registered | 20 passed | 1 skipped | 0 failed
- GradientCheck_AllHyperIdealTriangle ✓
- GradientCheck_ExtendedDomain ✓
- GradientCheck_TetrahedronAllVariable ✓
- EnergyFiniteAtTestPoint ✓
- GradientCheck_MixedIdealHyperIdeal ✓
- GradientCheck_Fan6AllVariable ✓
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-11 23:10:23 +02:00
Tarik Moussa
bf9c323d60
feat(phase3a): introduce CGAL Surface_mesh as ConformalMesh foundation
...
Replaces the Java CoHDS with CGAL::Surface_mesh<Point3> (Simple_cartesian
kernel). Adds domain-specific property maps for lambda/theta/idx/alpha and
face geometry type — the direct C++ equivalent of CoVertex/CoEdge adapters.
New files:
include/conformal_mesh.hpp — ConformalMesh type + property-map helpers
include/mesh_builder.hpp — mesh factories (triangle, tetrahedron,
quad-strip, fan) for tests and examples
tests/cgal/ — second test executable (conformallab_cgal_tests)
built only with -DWITH_CGAL=ON
Test results (local, -DWITH_CGAL=ON):
conformallab_tests: 36 registered | 23 passed | 13 skipped | 0 failed
conformallab_cgal_tests: 14 registered | 14 passed | 0 skipped | 0 failed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-11 18:36:21 +02:00