ITADN

Square root trait and implementation cleanups

#1082Openandrewwhitehead 创建于 2026-01-06
A
andrewwhiteheadcommented
Some potential cleanups for the traits and implementation: - [ ] Add a `CheckedSquareRoot` trait which could be implemented by `Int` (returning none for negative inputs). This could be a supertrait of SquareRoot. - [ ] Rename the `SquareRoot` trait for clarity, perhaps `UintSquareRoot` or `FloorSquareRoot`. - ~~[ ] Implement the square root trait(s) for Montgomery forms (this makes `FloorSquareRoot` a less desirable name)~~. - [ ] Rename `Uint::sqrt/sqrt_vartime` to `isqrt` or `sqrt_unchecked` to reflect the inexact nature of the result (and corresponding trait updates to match). - [ ] Implement square root traits and methods for `OddUint` for consistency. This would require changing the return type, but it seems reasonable to add an Output type to the trait(s). - [ ] Support nth roots based on algorithm 1.14 from the same source (Brent & Zimmermann, Modern Computer Arithmetic, v0.5.9). Should this be a separate trait?
1 条评论