Skip to content

Verify that input metric has strictly positive eigenvalues#320

Open
corentin-prigent wants to merge 6 commits intoMmgTools:developfrom
corentin-prigent:feature/negative-eigenvalue
Open

Verify that input metric has strictly positive eigenvalues#320
corentin-prigent wants to merge 6 commits intoMmgTools:developfrom
corentin-prigent:feature/negative-eigenvalue

Conversation

@corentin-prigent
Copy link
Contributor

This update adds a computation of input metric eigenvalues after loading it to verify that they are strictly positive. If not, exit the code.
This is done for mmg3d, mmg2d and mmgs, for both versions of the API functions:
MMG[3D/2D/S]_loadSol()
and
MMG[3D/2D/S]_loadAllSols()

Tests have been made to ensure validity of the checks.

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.27%. Comparing base (c48f68d) to head (66da499).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #320      +/-   ##
===========================================
- Coverage    50.30%   50.27%   -0.03%     
===========================================
  Files          177      177              
  Lines        47857    47892      +35     
  Branches     10355    10376      +21     
===========================================
+ Hits         24075    24079       +4     
- Misses       16050    16060      +10     
- Partials      7732     7753      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@taupalosaurus taupalosaurus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please:

  1. get rid of pointer arithmetic
  2. factorize the changes ?

if ( sol->size == 3 ) {
for (k=1; k<=sol->np; k++) {
double lambda[2],vp[2][2];
MMG5_eigensym(sol->m+3*k,lambda,vp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MMG5_eigensym(sol->m+3*k,lambda,vp);
MMG5_eigensym(&sol->m[3*k],lambda,vp);


/* For anisotropic metric, check that eigenvalues are stricly positive*/
for ( j=0; j<nsols; j++ ) {
psl = *sol+j;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
psl = *sol+j;
psl = &all_sols[j];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where

MMG5_Sol *all_sols;
all_sols = *sol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants