Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random failures of sqmatrix_assert_hermitian due to hard-coded error threshold #161

Open
oskooi opened this issue Nov 18, 2023 · 2 comments

Comments

@oskooi
Copy link
Collaborator

oskooi commented Nov 18, 2023

The check in sqmatrix_assert_hermitian to verify the Hermitian property of the Maxwell operator occasionally fails CI due to a larger than expected error of the hard-coded value of 1e-10 from this line:

CHECK(err < 1e-10, "sqmatrix_assert_hermitian failed");

Since it is difficult to find a reproducible test case, there are two possible workarounds:

  1. Increase the threshold error value of 1e-10. Choosing an appropriate value may involve outputting the actual error which caused the test to fail otherwise we choose some arbitrary value.
  2. Disable this test entirely since it is not that useful.
@stevengj
Copy link
Collaborator

Since it is a debugging assertion, it could be enabled only in debug mode, i.e. surround it with #ifdef DEBUG

@oskooi oskooi changed the title Random failures of sqmatric_assert_hermitian due to hard-coded error threshold Random failures of sqmatrix_assert_hermitian due to hard-coded error threshold Nov 27, 2023
@oskooi
Copy link
Collaborator Author

oskooi commented Jan 2, 2024

Since it is a debugging assertion, it could be enabled only in debug mode, i.e. surround it with #ifdef DEBUG

It turns out that this check is surrounded by #ifdef DEBUG. We should therefore probably just increase the error threshold since 1e-10 is too small.

#ifdef DEBUG
double err = 0, maxsq = 0;
int i, j, p = A.p;
for (i = 0; i < p; ++i)
for (j = 0; j < p; ++j)
maxsq = max2(maxsq, SCALAR_NORMSQR(A.data[i*p + j]));
for (i = 0; i < p; ++i) {
err = max2(err, (SCALAR_IM(A.data[i*p + i]) *
SCALAR_IM(A.data[i*p + i])) / maxsq);
for (j = i + 1; j < p; ++j) {
scalar x;
ASSIGN_CONJ(x, A.data[i*p + j]);
ACCUMULATE_DIFF(x, A.data[j*p + i]);
err = max2(err, SCALAR_NORMSQR(x) / maxsq);
}
}
CHECK(err < 1e-10, "sqmatrix_assert_hermitian failed");
#else
(void) A; /* unused */
#endif

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

No branches or pull requests

2 participants