aboutsummaryrefslogtreecommitdiff
path: root/src/Util/ZUtil/Definitions.v
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2017-06-13 15:57:01 -0400
committerGravatar Jason Gross <jgross@mit.edu>2017-06-13 15:57:03 -0400
commita322632f339e2c0fbd6053547c1bfaa89afb1d2d (patch)
tree2eb9014901109b4ce5226c02b4672484a8d2bebd /src/Util/ZUtil/Definitions.v
parent0f44fb2bf78bad0e4b330a9047087927a35ec3c1 (diff)
Add mul_split_at_bitwidth, define things in terms of that
This will make it easier on the reflective machinery, because it won't have to carry around such large constants.
Diffstat (limited to 'src/Util/ZUtil/Definitions.v')
-rw-r--r--src/Util/ZUtil/Definitions.v6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Util/ZUtil/Definitions.v b/src/Util/ZUtil/Definitions.v
index ff15dc83c..fb7754a7a 100644
--- a/src/Util/ZUtil/Definitions.v
+++ b/src/Util/ZUtil/Definitions.v
@@ -35,6 +35,10 @@ Module Z.
then add_get_carry (Z.log2 bound) x y
else ((x + y) mod bound, (x + y) / bound).
+ Definition mul_split_at_bitwidth (bitwidth : Z) (x y : Z) : Z * Z
+ := ((x * y) mod 2^bitwidth, (x * y) / 2^bitwidth).
Definition mul_split (s x y : Z) : Z * Z
- := ((x * y) mod s, (x * y) / s).
+ := if s =? 2^Z.log2 s
+ then mul_split_at_bitwidth (Z.log2 s) x y
+ else ((x * y) mod s, (x * y) / s).
End Z.