Skip to content

Commit 4dbbee0

Browse files
committed
test both mod computation branches
1 parent fcbb144 commit 4dbbee0

File tree

6 files changed

+81
-81
lines changed

6 files changed

+81
-81
lines changed

src/main/java/de/tilman_neumann/jml/factor/siqs/tdiv/TDiv_QS_2LP.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,15 @@ private AQPair test(BigInteger A, BigInteger QRest0, int x) {
253253
final long q = ( ( ((long)x) * m) >>> 32); // first argument long optimizes register usage
254254
xModP = (int) ( ((long)x) - q * p);
255255
if (xModP<0) xModP += p;
256-
if (DEBUG) {
257-
// 0 <= xModP < p
258-
Ensure.ensureSmallerEquals(0, xModP);
259-
Ensure.ensureSmaller(xModP, p);
260-
261-
int correctMod = correctMod(x, p);
262-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
263-
Ensure.ensureEquals(correctMod, xModP);
264-
}
256+
}
257+
if (DEBUG) {
258+
// 0 <= xModP < p
259+
Ensure.ensureSmallerEquals(0, xModP);
260+
Ensure.ensureSmaller(xModP, p);
261+
// compare with correct but slower mod computation
262+
int correctMod = correctMod(x, p);
263+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
264+
Ensure.ensureEquals(correctMod, xModP);
265265
}
266266
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
267267
pass2Primes[pass2Count] = primes[pIndex];
@@ -290,15 +290,15 @@ private AQPair test(BigInteger A, BigInteger QRest0, int x) {
290290
final long q = ( ( ((long)x) * m) >>> 32); // first argument long optimizes register usage
291291
xModP = (int) ( ((long)x) - q * p);
292292
if (xModP>=p) xModP -= p;
293-
if (DEBUG) {
294-
// 0 <= xModP < p
295-
Ensure.ensureSmallerEquals(0, xModP);
296-
Ensure.ensureSmaller(xModP, p);
297-
298-
int correctMod = correctMod(x, p);
299-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
300-
Ensure.ensureEquals(correctMod, xModP);
301-
}
293+
}
294+
if (DEBUG) {
295+
// 0 <= xModP < p
296+
Ensure.ensureSmallerEquals(0, xModP);
297+
Ensure.ensureSmaller(xModP, p);
298+
// compare with correct but slower mod computation
299+
int correctMod = correctMod(x, p);
300+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
301+
Ensure.ensureEquals(correctMod, xModP);
302302
}
303303
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
304304
pass2Primes[pass2Count] = primes[pIndex];

src/main/java/de/tilman_neumann/jml/factor/siqs/tdiv/TDiv_QS_2LP_Full.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ private AQPair test(BigInteger A, BigInteger Q, int x) {
232232
xModP = (int) ( ((long)x) - q * p);
233233
if (xModP<0) xModP += p;
234234
else if (xModP>=p) xModP -= p;
235-
if (DEBUG) {
236-
// 0 <= xModP < p
237-
Ensure.ensureSmallerEquals(0, xModP);
238-
Ensure.ensureSmaller(xModP, p);
239-
240-
int correctMod = correctMod(x, p);
241-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
242-
Ensure.ensureEquals(correctMod, xModP);
243-
}
235+
}
236+
if (DEBUG) {
237+
// 0 <= xModP < p
238+
Ensure.ensureSmallerEquals(0, xModP);
239+
Ensure.ensureSmaller(xModP, p);
240+
// compare with correct but slower mod computation
241+
int correctMod = correctMod(x, p);
242+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
243+
Ensure.ensureEquals(correctMod, xModP);
244244
}
245245
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
246246
pass2Primes[pass2Count] = primes[pIndex];

src/main/java/de/tilman_neumann/jml/factor/siqs/tdiv/TDiv_QS_3LP.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ private AQPair test(BigInteger A, BigInteger QRest0, int x) {
256256
final long q = ( ( ((long)x) * m) >>> 32); // first argument long optimizes register usage
257257
xModP = (int) ( ((long)x) - q * p);
258258
if (xModP<0) xModP += p;
259-
if (DEBUG) {
260-
// 0 <= xModP < p
261-
Ensure.ensureSmallerEquals(0, xModP);
262-
Ensure.ensureSmaller(xModP, p);
263-
264-
int correctMod = correctMod(x, p);
265-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
266-
Ensure.ensureEquals(correctMod, xModP);
267-
}
259+
}
260+
if (DEBUG) {
261+
// 0 <= xModP < p
262+
Ensure.ensureSmallerEquals(0, xModP);
263+
Ensure.ensureSmaller(xModP, p);
264+
// compare with correct but slower mod computation
265+
int correctMod = correctMod(x, p);
266+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
267+
Ensure.ensureEquals(correctMod, xModP);
268268
}
269269
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
270270
pass2Primes[pass2Count] = primes[pIndex];
@@ -293,15 +293,15 @@ private AQPair test(BigInteger A, BigInteger QRest0, int x) {
293293
final long q = ( ( ((long)x) * m) >>> 32); // first argument long optimizes register usage
294294
xModP = (int) ( ((long)x) - q * p);
295295
if (xModP>=p) xModP -= p;
296-
if (DEBUG) {
297-
// 0 <= xModP < p
298-
Ensure.ensureSmallerEquals(0, xModP);
299-
Ensure.ensureSmaller(xModP, p);
300-
301-
int correctMod = correctMod(x, p);
302-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
303-
Ensure.ensureEquals(correctMod, xModP);
304-
}
296+
}
297+
if (DEBUG) {
298+
// 0 <= xModP < p
299+
Ensure.ensureSmallerEquals(0, xModP);
300+
Ensure.ensureSmaller(xModP, p);
301+
// compare with correct but slower mod computation
302+
int correctMod = correctMod(x, p);
303+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
304+
Ensure.ensureEquals(correctMod, xModP);
305305
}
306306
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
307307
pass2Primes[pass2Count] = primes[pIndex];

src/main/java/de/tilman_neumann/jml/factor/siqs/tdiv/TDiv_QS_Small.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ private AQPair test(BigInteger A, BigInteger Q, int x) {
208208
xModP = (int) ( ((long)x) - q * p);
209209
if (xModP<0) xModP += p;
210210
else if (xModP>=p) xModP -= p;
211-
if (DEBUG) {
212-
// 0 <= xModP < p
213-
Ensure.ensureSmallerEquals(0, xModP);
214-
Ensure.ensureSmaller(xModP, p);
215-
216-
int correctMod = correctMod(x, p);
217-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
218-
Ensure.ensureEquals(correctMod, xModP);
219-
}
211+
}
212+
if (DEBUG) {
213+
// 0 <= xModP < p
214+
Ensure.ensureSmallerEquals(0, xModP);
215+
Ensure.ensureSmaller(xModP, p);
216+
// compare with correct but slower mod computation
217+
int correctMod = correctMod(x, p);
218+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
219+
Ensure.ensureEquals(correctMod, xModP);
220220
}
221221
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
222222
pass2Primes[pass2Count] = primes[pIndex];

src/main/java/de/tilman_neumann/jml/factor/siqs/tdiv/TDiv_QS_nLP.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,15 @@ private AQPair test(BigInteger A, BigInteger QRest0, int x) {
255255
final long q = ( ( ((long)x) * m) >>> 32); // first argument long optimizes register usage
256256
xModP = (int) ( ((long)x) - q * p);
257257
if (xModP<0) xModP += p;
258-
if (DEBUG) {
259-
// 0 <= xModP < p
260-
Ensure.ensureSmallerEquals(0, xModP);
261-
Ensure.ensureSmaller(xModP, p);
262-
263-
int correctMod = correctMod(x, p);
264-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
265-
Ensure.ensureEquals(correctMod, xModP);
266-
}
258+
}
259+
if (DEBUG) {
260+
// 0 <= xModP < p
261+
Ensure.ensureSmallerEquals(0, xModP);
262+
Ensure.ensureSmaller(xModP, p);
263+
// compare with correct but slower mod computation
264+
int correctMod = correctMod(x, p);
265+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
266+
Ensure.ensureEquals(correctMod, xModP);
267267
}
268268
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
269269
pass2Primes[pass2Count] = primes[pIndex];
@@ -292,15 +292,15 @@ private AQPair test(BigInteger A, BigInteger QRest0, int x) {
292292
final long q = ( ( ((long)x) * m) >>> 32); // first argument long optimizes register usage
293293
xModP = (int) ( ((long)x) - q * p);
294294
if (xModP>=p) xModP -= p;
295-
if (DEBUG) {
296-
// 0 <= xModP < p
297-
Ensure.ensureSmallerEquals(0, xModP);
298-
Ensure.ensureSmaller(xModP, p);
299-
300-
int correctMod = correctMod(x, p);
301-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
302-
Ensure.ensureEquals(correctMod, xModP);
303-
}
295+
}
296+
if (DEBUG) {
297+
// 0 <= xModP < p
298+
Ensure.ensureSmallerEquals(0, xModP);
299+
Ensure.ensureSmaller(xModP, p);
300+
// compare with correct but slower mod computation
301+
int correctMod = correctMod(x, p);
302+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
303+
Ensure.ensureEquals(correctMod, xModP);
304304
}
305305
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
306306
pass2Primes[pass2Count] = primes[pIndex];

src/main/java/de/tilman_neumann/jml/factor/siqs/tdiv/TDiv_QS_nLP_Full.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ private AQPair test(BigInteger A, BigInteger Q, int x) {
234234
xModP = (int) ( ((long)x) - q * p);
235235
if (xModP<0) xModP += p;
236236
else if (xModP>=p) xModP -= p;
237-
if (DEBUG) {
238-
// 0 <= xModP < p
239-
Ensure.ensureSmallerEquals(0, xModP);
240-
Ensure.ensureSmaller(xModP, p);
241-
242-
int correctMod = correctMod(x, p);
243-
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
244-
Ensure.ensureEquals(correctMod, xModP);
245-
}
237+
}
238+
if (DEBUG) {
239+
// 0 <= xModP < p
240+
Ensure.ensureSmallerEquals(0, xModP);
241+
Ensure.ensureSmaller(xModP, p);
242+
// compare with correct but slower mod computation
243+
int correctMod = correctMod(x, p);
244+
if (xModP != correctMod) LOG.debug("x=" + x + ", p=" + p + ": xModP=" + xModP + ", but correctMod=" + correctMod);
245+
Ensure.ensureEquals(correctMod, xModP);
246246
}
247247
if (xModP==x1Array[pIndex] || xModP==x2Array[pIndex]) {
248248
pass2Primes[pass2Count] = primes[pIndex];

0 commit comments

Comments
 (0)