Skip to content

Commit

Permalink
Latest from jml
Browse files Browse the repository at this point in the history
  • Loading branch information
axkr committed Dec 26, 2020
1 parent 9cb4b48 commit d8be1f1
Show file tree
Hide file tree
Showing 29 changed files with 294 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ private static void test3nPlus1DroppingSequence() {
LOG.info(
"record lengths = "
+ recordLengths); // A217934 = (0,) 1, 6, 11, 96, 132, 171, 220, 267, 269, 282, 287,
// 298, 365, 401, 468, 476, 486, 502, 613
// 298, 365, 401, 468, 476, 486, 502, 613
LOG.info(
"N(record lengths)= "
+ recordLengthsN); // A060412 = (1,) 2, 3, 7, 27, 703, 10087, 35655, 270271, 362343,
// 381727, 626331, 1027431, 1126015, 8088063, 13421671, 20638335,
// 26716671, 56924955, 63728127
// 381727, 626331, 1027431, 1126015, 8088063, 13421671, 20638335,
// 26716671, 56924955, 63728127

analyzeNStartSequences(length2NStartList);
analyzeProgressions(progressionToMaxLength);
Expand Down Expand Up @@ -186,11 +186,11 @@ private static void test3nPlus1RepeatSequence() {
LOG.info(
"record lengths = "
+ recordLengths); // not on OEIS: 0, 1, 6, 10, 95, 132, 219, 262, 269, 271, 297, 305,
// 343, 357, 400, 468, 485
// 343, 357, 400, 468, 485
LOG.info(
"N(record lengths)= "
+ recordLengthsN); // not on OEIS: 1, 2, 3, 7, 27, 703, 35655, 270271, 362343, 401151,
// 1027431, 1327743, 1394431, 6206655, 8088063, 13421671, 26716671
// 1027431, 1327743, 1394431, 6206655, 8088063, 13421671, 26716671

analyzeNStartSequences(length2NStartList);
analyzeProgressions(progressionToMaxLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import de.tilman_neumann.jml.factor.siqs.sieve.Sieve03gU;
import de.tilman_neumann.jml.factor.siqs.tdiv.TDiv_QS_1Large_UBI;
import de.tilman_neumann.jml.factor.siqs.tdiv.TDiv_QS_2Large_UBI;
import de.tilman_neumann.jml.factor.tdiv.TDiv31Inverse;
import de.tilman_neumann.jml.factor.tdiv.TDiv31Barrett;
import de.tilman_neumann.util.ConfigUtil;
import de.tilman_neumann.util.SortedMultiset;
import de.tilman_neumann.util.TimeUtil;
Expand All @@ -55,7 +55,7 @@ public class CombinedFactorAlgorithm extends FactorAlgorithm {
@SuppressWarnings("unused")
private static final Logger LOG = Logger.getLogger(CombinedFactorAlgorithm.class);

private TDiv31Inverse tDiv31 = new TDiv31Inverse();
private TDiv31Barrett tDiv31 = new TDiv31Barrett();
private Hart_TDiv_Race hart = new Hart_TDiv_Race();
private PollardRhoBrentMontgomeryR64Mul63 pollardRhoR64Mul63 =
new PollardRhoBrentMontgomeryR64Mul63();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ public void factor(BigInteger N, SortedMultiset<BigInteger> primeFactors) {
if (lsb > 0) {
primeFactors.add(I_2, lsb);
N = N.shiftRight(lsb);
}
if (N.equals(I_1)) {
// N was a power of 2
return;
if (N.equals(I_1)) {
// N was a power of 2
return;
}
}

// N contains larger factors...
Expand Down Expand Up @@ -187,8 +187,7 @@ public void factor(BigInteger N, SortedMultiset<BigInteger> primeFactors) {
// resolve untested factors
while (untestedFactors.size() > 0) {
BigInteger untestedFactor = untestedFactors.firstKey();
int exp = untestedFactors.get(untestedFactor);
untestedFactors.removeAll(untestedFactor);
int exp = untestedFactors.removeAll(untestedFactor);
if (bpsw.isProbablePrime(untestedFactor)) {
// The untestedFactor is probable prime. In exceptional cases this prediction may be
// wrong and untestedFactor composite
Expand All @@ -215,7 +214,7 @@ public void factor(BigInteger N, SortedMultiset<BigInteger> primeFactors) {
break;
}

BigInteger compositeFactor = factorResult.compositeFactors.keySet().iterator().next();
BigInteger compositeFactor = factorResult.compositeFactors.firstKey();
int exp = factorResult.compositeFactors.removeAll(compositeFactor);

FactorArguments args = new FactorArguments(compositeFactor, exp, smallestPossibleFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void testForFactor(Set<AQPair> aqPairs) throws FactorException {
for (long factor : totalQ_factors.keySet()) {
if (factor == -1)
continue; // sqrt(Q-product) can be positive or negative, but we want the positive solution
// -> skip sign
// -> skip sign
int exp = totalQ_factors.get(factor);
if ((exp & 1) == 1) {
// non-square "solution" -> early exit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ public BigInteger findSingleFactor(BigInteger N) {
floor_sqrt_kN =
(long)
Math.sqrt(
kN
.doubleValue()); // faster than BigInteger sqrt; but the type conversion may
// give ceil(sqrt(kN)) for some N >= 54 bit
kN.doubleValue()); // faster than BigInteger sqrt; but the type conversion may
// give ceil(sqrt(kN)) for some N >= 54 bit
BigInteger sqrt_kN_big = BigInteger.valueOf(floor_sqrt_kN);
long diff = kN.subtract(sqrt_kN_big.multiply(sqrt_kN_big)).longValue();
if (diff == 0) return N.gcd(sqrt_kN_big);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ private void prac(int n, int[] x, int[] z, int[] xT, int[] zT, int[] xT2, int[]
}
/* do the first line of Table 4 whose condition qualifies */
if (4 * d <= 5 * e && ((d + e) % 3) == 0) {
/* condition 1 */
/* condition 1 */
r = (2 * d - e) / 3;
e = (2 * e - d) / 3;
d = r;
Expand All @@ -745,12 +745,12 @@ private void prac(int n, int[] x, int[] z, int[] xT, int[] zT, int[] xT2, int[]
zA = zT2;
zT2 = t; /* swap A and T2 */
} else if (4 * d <= 5 * e && (d - e) % 6 == 0) {
/* condition 2 */
/* condition 2 */
d = (d - e) / 2;
add3(xB, zB, xA, zA, xB, zB, xC, zC); /* B = f(A,B,C) */
duplicate(xA, zA, xA, zA, AA); /* A = 2*A */
} else if (d <= (4 * e)) {
/* condition 3 */
/* condition 3 */
d -= e;
add3(xT, zT, xB, zB, xA, zA, xC, zC); /* T = f(B,A,C) */
t = xB;
Expand All @@ -762,17 +762,17 @@ private void prac(int n, int[] x, int[] z, int[] xT, int[] zT, int[] xT2, int[]
zT = zC;
zC = t; /* circular permutation (B,T,C) */
} else if ((d + e) % 2 == 0) {
/* condition 4 */
/* condition 4 */
d = (d - e) / 2;
add3(xB, zB, xB, zB, xA, zA, xC, zC); /* B = f(B,A,C) */
duplicate(xA, zA, xA, zA, AA); /* A = 2*A */
} else if (d % 2 == 0) {
/* condition 5 */
/* condition 5 */
d /= 2;
add3(xC, zC, xC, zC, xA, zA, xB, zB); /* C = f(C,A,B) */
duplicate(xA, zA, xA, zA, AA); /* A = 2*A */
} else if (d % 3 == 0) {
/* condition 6 */
/* condition 6 */
d = d / 3 - e;
duplicate(xT, zT, xA, zA, AA); /* T1 = 2*A */
add3(xT2, zT2, xA, zA, xB, zB, xC, zC); /* T2 = f(A,B,C) */
Expand All @@ -787,14 +787,14 @@ private void prac(int n, int[] x, int[] z, int[] xT, int[] zT, int[] xT2, int[]
zB = zT;
zT = t; /* circular permutation (C,B,T) */
} else if ((d + e) % 3 == 0) {
/* condition 7 */
/* condition 7 */
d = (d - 2 * e) / 3;
add3(xT, zT, xA, zA, xB, zB, xC, zC); /* T1 = f(A,B,C) */
add3(xB, zB, xT, zT, xA, zA, xB, zB); /* B = f(T1,A,B) */
duplicate(xT, zT, xA, zA, AA);
add3(xA, zA, xA, zA, xT, zT, xA, zA); /* A = 3*A */
} else if ((d - e) % 3 == 0) {
/* condition 8 */
/* condition 8 */
d = (d - e) / 3;
add3(xT, zT, xA, zA, xB, zB, xC, zC); /* T1 = f(A,B,C) */
add3(xC, zC, xC, zC, xA, zA, xB, zB); /* C = f(A,C,B) */
Expand All @@ -807,7 +807,7 @@ private void prac(int n, int[] x, int[] z, int[] xT, int[] zT, int[] xT2, int[]
duplicate(xT, zT, xA, zA, AA);
add3(xA, zA, xA, zA, xT, zT, xA, zA); /* A = 3*A */
} else if (e % 2 == 0) {
/* condition 9 */
/* condition 9 */
e /= 2;
add3(xC, zC, xC, zC, xB, zB, xA, zA); /* C = f(C,B,A) */
duplicate(xB, zB, xB, zB, AA); /* B = 2*B */
Expand All @@ -834,41 +834,41 @@ private static int lucas_cost(int n, double v) {
e = r;
}
if (4 * d <= 5 * e && ((d + e) % 3) == 0) {
/* condition 1 */
/* condition 1 */
r = (2 * d - e) / 3;
e = (2 * e - d) / 3;
d = r;
c += 3 * ADD; /* 3 additions */
} else if (4 * d <= 5 * e && (d - e) % 6 == 0) {
/* condition 2 */
/* condition 2 */
d = (d - e) / 2;
c += ADD + DUP; /* one addition, one duplicate */
} else if (d <= (4 * e)) {
/* condition 3 */
/* condition 3 */
d -= e;
c += ADD; /* one addition */
} else if ((d + e) % 2 == 0) {
/* condition 4 */
/* condition 4 */
d = (d - e) / 2;
c += ADD + DUP; /* one addition, one duplicate */
} else if (d % 2 == 0) {
/* condition 5 */
/* condition 5 */
d /= 2;
c += ADD + DUP; /* one addition, one duplicate */
} else if (d % 3 == 0) {
/* condition 6 */
/* condition 6 */
d = d / 3 - e;
c += 3 * ADD + DUP; /* three additions, one duplicate */
} else if ((d + e) % 3 == 0) {
/* condition 7 */
/* condition 7 */
d = (d - 2 * e) / 3;
c += 3 * ADD + DUP; /* three additions, one duplicate */
} else if ((d - e) % 3 == 0) {
/* condition 8 */
/* condition 8 */
d = (d - e) / 3;
c += 3 * ADD + DUP; /* three additions, one duplicate */
} else if (e % 2 == 0) {
/* condition 9 */
/* condition 9 */
e /= 2;
c += ADD + DUP; /* one addition, one duplicate */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public long findSingleFactor(long N) {
aLimit += adjust1 < adjust2 ? adjust1 : adjust2;
aStep =
4; // stepping over both adjusts with step width 16 would be more exact but is not
// faster
// faster
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public long findSingleFactor(long N) {
aLimit += adjust1 < adjust2 ? adjust1 : adjust2;
aStep =
4; // stepping over both adjusts with step width 16 would be more exact but is not
// faster
// faster
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public long findSingleFactor(long N) {
aLimit += adjust1 < adjust2 ? adjust1 : adjust2;
aStep =
4; // stepping over both adjusts with step width 16 would be more exact but is not
// faster
// faster
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void findSingleFactor(long N, Progression progression) {
aLimit += adjust1 < adjust2 ? adjust1 : adjust2;
aStep =
4; // XXX true step widths may be bigger, like 4, 28, 4, 28, ... But computations
// are too costly.
// are too costly.
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void findSingleFactor(long N, Progression progression) {
aLimit += adjust1 < adjust2 ? adjust1 : adjust2;
aStep =
4; // XXX true step widths may be bigger, like 4, 28, 4, 28, ... But computations
// are too costly.
// are too costly.
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public long findSingleFactor(long N) {
aLimit += adjust1 < adjust2 ? adjust1 : adjust2;
aStep =
4; // stepping over both adjusts with step width 16 would be more exact but is not
// faster
// faster
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,8 @@ private long test(
aStep = 8;
aLimit += ((kPlusN - aLimit) & 7);
} else {
aStep =
4; // stepping over both adjusts with step width 16 would be more exact but is not
// faster
aStep = 4; // stepping over both adjusts with step width 16 would be more exact but is not
// faster
final long adjust1 = (kPlusN - aLimit) & 15;
final long adjust2 = (-kPlusN - aLimit) & 15;
aLimit += adjust1 < adjust2 ? adjust1 : adjust2;
Expand Down
Loading

0 comments on commit d8be1f1

Please sign in to comment.