Return named structs from the normalization functions - #253
Merged
Conversation
`normalization_and_jacobian` and its Hessian variant returned std::tuple, so every caller had to remember that element 1 was the Jacobian and reach for std::get<1> to pull it out. They now return NormalizationAndJacobian and NormalizationAndJacobianAndHessian, which name the fields. Existing structured-binding call sites are unaffected -- the structs are aggregates, so `const auto [xhat, J] = ...` still works. The Python bindings convert to a tuple explicitly so `ipctk` keeps its current return type. BREAKING: C++ callers that named std::tuple or used std::get must switch to the .normalized/.jacobian/.hessian members. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
=======================================
Coverage 96.70% 96.70%
=======================================
Files 191 191
Lines 17292 17292
Branches 928 928
=======================================
Hits 16722 16722
Misses 570 570
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
normalization_and_jacobianandnormalization_and_jacobian_and_hessianreturnedstd::tuple, so callers had to remember that element 1 was the Jacobian and reach forstd::get<1>to pull it out. They now return named aggregates.NormalizationAndJacobian<T, dim, max_dim>—.normalized,.jacobianNormalizationAndJacobianAndHessian<T, dim, max_dim>— the above plus.hessianmax_dimso the fixed-size (Eigen::Vector<T, dim>) and dynamic (VectorMax3<T>) return paths are one type rather than two unrelated tuple spellings.The accessor helpers read directly off the field now —
normalization_jacobianreturns...(x).jacobianinstead ofstd::get<1>(...), andnormalization_hessianreturns.hessianinstead ofstd::get<2>(...).API changes
math.cpp,smooth_contact/primitives/point3.cpp,edge3.cpp) andtest_barrier.cppare unchanged: the structs are aggregates, so existingconst auto [xhat, J] = ...structured bindings keep working as-is.normalization_jacobianandnormalization_hessianare unchanged in signature and behavior.ipctk.normalization_and_jacobianandipctk.normalization_and_jacobian_and_hessianreturn exactly what they returned before.💥 Breaking changes
C++ callers that name
std::tupleexplicitly, or usestd::get<N>, must move to the.normalized/.jacobian/.hessianmembers. Structured-binding callers need no change. There is no deprecation path — the return type changes outright.How Has This Been Tested?
[normal] [barrier] [angle]— 24 test cases, 16,790 assertions, all passing. Includes the autodiff cross-check intest_barrier.cpp, which compares the returned Jacobian and Hessian againstADHessian<3>derivatives.ipc_toolkit,ipc_toolkit_tests, andipctkall build clean.normalization_jacobian/normalization_hessianreturn the same shapes as before.Test Configuration:
CMAKE_BUILD_TYPE=Release,IPC_TOOLKIT_BUILD_TESTS=ON,IPC_TOOLKIT_WITH_CUDA=OFFChecklist