Commit b8ddb04
committed
std.math: Add std.math.egcd to compute the extended GCD
This adds an iterative EGCD implementation to std.math.
The implementation is simple and conservative, returns Bézout
coefficients consistent with widely‐used implementations, and has
been formally verified correct for any value and type supported
by Zig up to u65534/i65534.
Its purpose is to make this API available to projects and other
parts of the standard library. Optimizations for specific types or
value ranges (e.g., using a binary method or approximations) can be
added later without any changes to existing applications.1 parent bebfdc3 commit b8ddb04
2 files changed
+425
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
398 | 399 | | |
399 | 400 | | |
400 | 401 | | |
| 402 | + | |
401 | 403 | | |
402 | 404 | | |
403 | 405 | | |
| |||
0 commit comments