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

Sanity check using absolute error. suggest using relative error #55

Open
philippdahm opened this issue Mar 21, 2023 · 0 comments
Open

Comments

@philippdahm
Copy link

Hey all,
seems that the sanity check is using absolute error (difference in results) in checking definition of the vectorspace. When using a large-valued vector, this error is sometimes not achievable due to machine precision.

In my example, the inner products are of the order of 1e8 with a 1e-9 absolute error. This causes the check to fail with the default tolerance of 1e-12.

To me, it makes sense to turn this into a check on relative error (ratio of results) rather than absolute (difference of results) as to avoid machine precision issues.

tol = 1e-12

# Check that the inner product of a vector is correct after scalar
# multiplication and vector addition.
vec_add_mult = test_vec * scale_factor + test_vec
if abs(
self.inner_product(vec_add_mult, vec_add_mult) -
vec_copy_mag_sq * (scale_factor + 1) ** 2) > tol:

@philippdahm philippdahm changed the title Sanity on check using absolute error Sanity check using absolute error. suggest using relative error Mar 21, 2023
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

1 participant