Skip to content

Commit 37e2797

Browse files
committed
comment on final correction in montMul64()
1 parent ef1832b commit 37e2797

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/main/java/de/tilman_neumann/jml/factor/ecm/TinyEcm64.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ public static long montMul64(long a, long b, long N, long Nhat) {
10931093
// Since R=2^64, "x / R" just means to get the high part of x.
10941094
long r = ab.add_getHigh(Uint128.mul64(t, N));
10951095
// If the correct result is c, then now r==c or r==c+N.
1096-
r = r<N ? r : r-N; // required at ecm
1096+
r = r<N ? r : r-N; // improves performance for N >= 50 bit, degrades it for smaller N
10971097

10981098
if (DEBUG) {
10991099
//LOG.debug(a + " * " + b + " = " + r);

src/main/java/de/tilman_neumann/jml/factor/ecm/TinyEcm64MH.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ public static long montMul64(long a, long b, long N, long Nhat) {
11041104
// Since R=2^64, "x / R" just means to get the high part of x.
11051105
long r = ab.add_getHigh(Uint128.mul64SignedMH(t, N));
11061106
// If the correct result is c, then now r==c or r==c+N.
1107-
r = r<N ? r : r-N; // required at ecm
1107+
r = r<N ? r : r-N; // improves performance for N >= 55 bit, degrades it for smaller N
11081108

11091109
if (DEBUG) {
11101110
//LOG.debug(a + " * " + b + " = " + r);

src/main/java/de/tilman_neumann/jml/factor/ecm/TinyEcm64MHInlined.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ public static long montMul64(long a, long b, long N, long Nhat) {
11121112
long high = abHigh + tNHigh;
11131113
long r = (low+Long.MIN_VALUE < abLow+Long.MIN_VALUE) ? high + 1 : high;
11141114
// If the correct result is c, then now r==c or r==c+N.
1115-
r = r<N ? r : r-N; // required only for N>=62 bit; for smaller N dropping this instruction means a speed gain
1115+
r = r<N ? r : r-N; // improves performance for N >= 55 bit, degrades it for smaller N
11161116

11171117
if (DEBUG) {
11181118
//LOG.debug(a + " * " + b + " = " + r);

src/main/java/de/tilman_neumann/jml/factor/pollardRho/PollardRhoBrentMontgomery64MHInlined.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public static long montMul64(long a, long b, long N, long Nhat) {
184184
// Since R=2^64, "x / R" just means to get the high part of x.
185185
long low = abLow + tNLow;
186186
long high = abHigh + tNHigh;
187-
long r = (low+Long.MIN_VALUE < abLow+Long.MIN_VALUE) ? high + 1 : high;
187+
long r = (low+Long.MIN_VALUE < abLow+Long.MIN_VALUE) ? high + 1 : high; // this adjustment is very important here
188188
// If the correct result is c, then now r==c or r==c+N.
189189
// This is fine for this factoring algorithm, because r will
190190
// * either be subjected to another Montgomery multiplication mod N,

0 commit comments

Comments
 (0)