Repository navigation
MDEV-41639 VEC_DISTANCE_COSINE returns 0 for small-magnitude vectors - #5933
Open
Omar-Abdo1 wants to merge 2 commits into
Open
Omar-Abdo1 wants to merge 2 commits into
Omar-Abdo1 wants to merge 2 commits into
Conversation
calc_distance_cosine() multiplied float operands in float precision, so squares of components below ~1e-23 underflowed to 0, and the result became NaN. Convert the operands to double before multiplying.
Author
|
buildbot/amd64-windows-packages failed in the “MTR - HashiCorp Vault” step with Could not parse mysqld --help: thread-p before any test ran. This looks like a worker/infrastructure problem, unrelated to this change. |
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.
https://jira.mariadb.org/browse/MDEV-41639
calc_distance_cosine()multipliedfloatoperands, so squares of componentsbelow ~1e-23 underflowed to 0 in float precision before being accumulated
into the
doublevariables. The result became 0/0 = NaN.Fix: convert the operands to
doublebefore multiplying.A test with small orthogonal, opposite and identical vectors is added in
mysql-test/main/vector_small_cosine.test.