Commit graph

5 commits

Author SHA1 Message Date
Said Kadrioski
062dc9473e Add EGCD.
Fix some comments in GCD.

Make ml_kem use lcm and egcd from std/math.

Fix name.

Add egcd function.

Don't destructure.

Use binary gcd and make overflow safe.

Force inlining, use ctz to reduce dependency in loop.

Avoid integer overflow for temporary value.

Add test against previous overflow capability.

More optimization friendly expression.

Fix egcd for even numbers.

Minvalue causes crash.

Remove helper function. Fix casting issues.

Use shift instead division (to support i2) and avoid overflow of temp results.
2025-11-25 08:08:22 +01:00
Said Kadrioski
ed88533fcf Microptimization.
Fix range obscurity and compile error.

Revert change for converting comptime int.
2025-11-25 08:04:28 +01:00
Fri3dNstuff
b2c53eb0d7
std.math: change gcd's implementation to use Stein's algorithm instead of Euclid's (#21077) 2024-09-23 17:15:57 -07:00
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Chris Boesch
9c99a88796
std.math: add "Greatest common divisor" (gcd) 2022-09-29 21:42:56 +03:00