You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix numerical stability issues in SVD implementation (#73)
* Fix numerical stability issues in SVD implementation
- Add EPSILON constant for safe numerical comparisons
- Guard Vector#normalize against zero/near-zero magnitude
- Guard SVD angle calculation against division by zero
- Guard SVD singular value sqrt against negative values
- Guard content_node weighted_total against division by zero
- Add nil checks in LSI build_index for edge cases
- Add tests for zero vectors, near-singular matrices, edge cases
Fixes#63
* Fix RuboCop offenses in SVD implementation
* Address code review feedback
- Move EPSILON constant to Vector::EPSILON to avoid polluting global namespace
- Use Vector::EPSILON in content_node.rb for consistency
- Remove unrelated .claude/settings.local.json from PR
- Add .claude/ to .gitignore
* Address additional code review feedback
- Change normalize guard from `< EPSILON` to `<= 0.0` - only return zero
vector for actual zero magnitude, not near-zero values
- Use `val.abs` with EPSILON threshold for singular values to handle
small negative values from floating point errors more robustly
- Update test to reflect correct behavior: near-zero vectors normalize
to unit vectors, only true zero vectors return zero
* Fix RuboCop: add empty line before assertions
* Address third round of code review feedback
- Rename test to test_normalize_near_zero_vector_normalizes_correctly
- Simplify singular value sqrt to [val, 0.0].max for uniform handling
- Preserve sign relationship in content_node divisor fallback
* Remove redundant comments
* Use Vector::EPSILON in test for maintainability
* Flatten nested conditional in content_node divisor logic
0 commit comments