Skip to content

Fix: address potential negative value of denom in Pearson correlation calculation#707

Merged
ashvardanian merged 5 commits intounum-cloud:main-devfrom
huahaiy:main
Jan 27, 2026
Merged

Fix: address potential negative value of denom in Pearson correlation calculation#707
ashvardanian merged 5 commits intounum-cloud:main-devfrom
huahaiy:main

Conversation

@huahaiy
Copy link
Copy Markdown
Contributor

@huahaiy huahaiy commented Jan 23, 2026

For small dimensions, e.g. 2, it is possible to get negative value due to numerical issues in calculating result_t denom = (dim * a_sq_sum - a_sum * a_sum) * (dim * b_sq_sum - b_sum * b_sum);

Then std:sqrt(demon) will return NaN, leading to infinite loop in search algorithm, e.g. (-candidate.distance) > radius will always be false, leading to system hang.

@huahaiy huahaiy changed the title address potential negative value of denom in Pearson correlation calculation FIX: address potential negative value of denom in Pearson correlation calculation Jan 23, 2026
@huahaiy huahaiy changed the title FIX: address potential negative value of denom in Pearson correlation calculation Fix: address potential negative value of denom in Pearson correlation calculation Jan 23, 2026
@ashvardanian ashvardanian changed the base branch from main to main-dev January 27, 2026 17:00
@ashvardanian ashvardanian merged commit 34d5b8c into unum-cloud:main-dev Jan 27, 2026
@ashvardanian
Copy link
Copy Markdown
Contributor

Thank you, @huahaiy!

ashvardanian pushed a commit that referenced this pull request Feb 16, 2026
### Minor

- Add: GetHandle and GetConfig to give access to the C handle in Golang (#705) (dec24b8)

### Patch

- Make: Bump SimSIMD (2be3bbb)
- Fix: `mmap` flags for FreeBSD (#711) (3ad2485)
- Fix: Compilation errors in Qt environment (#706) (20cb742)
- Fix: Negative denominator in Pearson correlation (#707) (34d5b8c)
- Docs: Fix broken links (#708) (453290d)
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