Skip to content

Commit

Permalink
rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
TilmanNeumann committed Dec 29, 2024
1 parent b8d01f5 commit ca7f634
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ public static void setup() {

@Test
public void testSomeInputs() {
testSingleNumber("8225267468394993133669189614204532935183709603155231863020477010700542265332938919716662623",
assertFactorizationSuccess("8225267468394993133669189614204532935183709603155231863020477010700542265332938919716662623",
"1234567891 * 1234567907 * 1234567913 * 1234567927 * 1234567949 * 1234567967 * 1234567981 * 1234568021 * 1234568029 * 1234568047");
testSingleNumber("101546450935661953908994991437690198927080333663460351836152986526126114727314353555755712261904130976988029406423152881932996637460315302992884162068350429",
assertFactorizationSuccess("101546450935661953908994991437690198927080333663460351836152986526126114727314353555755712261904130976988029406423152881932996637460315302992884162068350429",
"123456789012419 * 123456789012421 * 123456789012437 * 123456789012439 * 123456789012463 * 123456789012521 * 123456789012523 * 123456789012533 * 123456789012577 * 123456789012629 * 123456789012637");
testSingleNumber("1593332576170570774181606244493046197050984933692181475920784855223341",
assertFactorizationSuccess("1593332576170570774181606244493046197050984933692181475920784855223341",
"17 * 1210508704285703 * 2568160569265616473 * 30148619026320753545829271787156467");
testSingleNumber("856483652537814883803418179972154563054077",
assertFactorizationSuccess("856483652537814883803418179972154563054077",
"42665052615296697659 * 20074595014814065252903");
// very hard for ECM, better suited for SIQS
//testSingleNumber("1794577685365897117833870712928656282041295031283603412289229185967719140138841093599",
//assertFactorizationSuccess("1794577685365897117833870712928656282041295031283603412289229185967719140138841093599",
// "42181796536350966453737572957846241893933 * 42543889372264778301966140913837516662044603");
}

private void testSingleNumber(String oddNStr, String expectedPrimeFactorizationStr) {
private void assertFactorizationSuccess(String oddNStr, String expectedPrimeFactorizationStr) {
long t0, t1;
t0 = System.currentTimeMillis();
BigInteger N = new BigInteger(oddNStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,52 +38,52 @@ public static void setup() {

@Test
public void testSemiprimes() {
testFullFactorization(1234577*12345701L, "1234577 * 12345701");
assertFactorizationSuccess(1234577*12345701L, "1234577 * 12345701");
// Failures before map[] fix
testFullFactorization(1253586675305333L, "6030247 * 207883139");
testFullFactorization(1139151196120601L, "232987 * 4889333723");
testFullFactorization(1553712951089947L, "29184373 * 53237839");
testFullFactorization(2235885271339597L, "38826707 * 57586271");
testFullFactorization(1586929215386303L, "4605361 * 344583023");
assertFactorizationSuccess(1253586675305333L, "6030247 * 207883139");
assertFactorizationSuccess(1139151196120601L, "232987 * 4889333723");
assertFactorizationSuccess(1553712951089947L, "29184373 * 53237839");
assertFactorizationSuccess(2235885271339597L, "38826707 * 57586271");
assertFactorizationSuccess(1586929215386303L, "4605361 * 344583023");
// Failures before spRand() fix
testFullFactorization(930705057210221L, "25325941 * 36749081");
testFullFactorization(1067332898136023L, "26165441 * 40791703");
testFullFactorization(8311092540494299L, "67613999 * 122919701");
testFullFactorization(23603982383629381L, "118493549 * 199200569");
testFullFactorization(58725827789610857L, "103129121 * 569439817");
testFullFactorization(369313815090910177L, "354877001 * 1040681177");
assertFactorizationSuccess(930705057210221L, "25325941 * 36749081");
assertFactorizationSuccess(1067332898136023L, "26165441 * 40791703");
assertFactorizationSuccess(8311092540494299L, "67613999 * 122919701");
assertFactorizationSuccess(23603982383629381L, "118493549 * 199200569");
assertFactorizationSuccess(58725827789610857L, "103129121 * 569439817");
assertFactorizationSuccess(369313815090910177L, "354877001 * 1040681177");
// Failures before int to long cast fix
testFullFactorization(41382606407163353L, "69696377 * 593755489");
testFullFactorization(306358296309770459L, "209066843 * 1465360513");
assertFactorizationSuccess(41382606407163353L, "69696377 * 593755489");
assertFactorizationSuccess(306358296309770459L, "209066843 * 1465360513");
// Failures because #curves was too small
testFullFactorization(474315852287951L, "15390191 * 30819361");
testFullFactorization(9400170223537253L, "47701151 * 197063803");
testFullFactorization(35239016917581299L, "82794071 * 425622469");
testFullFactorization(37915240075398767L, "16632857 * 2279538631");
testFullFactorization(459926431465210403L, "631315747 * 728520449");
testFullFactorization(752882545886305349L, "460178669 * 1636065721");
testFullFactorization(179503729521451L, "7420397 * 24190583");
testFullFactorization(1059150637518581L, "22339673 * 47411197");
testFullFactorization(3209190314462729L, "24571021 * 130608749");
testFullFactorization(17586811742837503L, "105611027 * 166524389");
testFullFactorization(13745855671622359L, "50960113 * 269737543");
testFullFactorization(15727038894518533L, "55460939 * 283569647");
testFullFactorization(66804960995707271L, "125296429 * 533175299");
testFullFactorization(38704493646912997L, "31501721 * 1228646957");
testFullFactorization(56025872236672099L, "53839061 * 1040617559");
testFullFactorization(57675022504187287L, "172307477 * 334721531");
testFullFactorization(69916262762899909L, "72133751 * 969258659");
testFullFactorization(51113648728234999L, "49275467 * 1037304197");
testFullFactorization(55878279398722441L, "131149259 * 426066299");
assertFactorizationSuccess(474315852287951L, "15390191 * 30819361");
assertFactorizationSuccess(9400170223537253L, "47701151 * 197063803");
assertFactorizationSuccess(35239016917581299L, "82794071 * 425622469");
assertFactorizationSuccess(37915240075398767L, "16632857 * 2279538631");
assertFactorizationSuccess(459926431465210403L, "631315747 * 728520449");
assertFactorizationSuccess(752882545886305349L, "460178669 * 1636065721");
assertFactorizationSuccess(179503729521451L, "7420397 * 24190583");
assertFactorizationSuccess(1059150637518581L, "22339673 * 47411197");
assertFactorizationSuccess(3209190314462729L, "24571021 * 130608749");
assertFactorizationSuccess(17586811742837503L, "105611027 * 166524389");
assertFactorizationSuccess(13745855671622359L, "50960113 * 269737543");
assertFactorizationSuccess(15727038894518533L, "55460939 * 283569647");
assertFactorizationSuccess(66804960995707271L, "125296429 * 533175299");
assertFactorizationSuccess(38704493646912997L, "31501721 * 1228646957");
assertFactorizationSuccess(56025872236672099L, "53839061 * 1040617559");
assertFactorizationSuccess(57675022504187287L, "172307477 * 334721531");
assertFactorizationSuccess(69916262762899909L, "72133751 * 969258659");
assertFactorizationSuccess(51113648728234999L, "49275467 * 1037304197");
assertFactorizationSuccess(55878279398722441L, "131149259 * 426066299");
}

@Test
public void testNumbersWithManyFactors() {
testFullFactorization(1096954293075013905L, "3 * 5 * 7^2 * 169681 * 8795650783");
testFullFactorization(1100087778366101931L, "3 * 7 * 43 * 89 * 199 * 263 * 307 * 881 * 967"); // Fibonacci(88)
assertFactorizationSuccess(1096954293075013905L, "3 * 5 * 7^2 * 169681 * 8795650783");
assertFactorizationSuccess(1100087778366101931L, "3 * 7 * 43 * 89 * 199 * 263 * 307 * 881 * 967"); // Fibonacci(88)
}

private void testFullFactorization(long N, String expectedPrimeFactorizationStr) {
private void assertFactorizationSuccess(long N, String expectedPrimeFactorizationStr) {
SortedMultiset<BigInteger> factors = tinyEcm.factor(BigInteger.valueOf(N));
LOG.info(N + " = " + factors.toString("*", "^"));
assertEquals(expectedPrimeFactorizationStr, factors.toString("*", "^"));
Expand Down
72 changes: 36 additions & 36 deletions src/test/java/de/tilman_neumann/jml/factor/ecm/TinyEcm64MHTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,52 +38,52 @@ public static void setup() {

@Test
public void testSemiprimes() {
testFullFactorization(1234577*12345701L, "1234577 * 12345701");
assertFactorizationSuccess(1234577*12345701L, "1234577 * 12345701");
// Failures before map[] fix
testFullFactorization(1253586675305333L, "6030247 * 207883139");
testFullFactorization(1139151196120601L, "232987 * 4889333723");
testFullFactorization(1553712951089947L, "29184373 * 53237839");
testFullFactorization(2235885271339597L, "38826707 * 57586271");
testFullFactorization(1586929215386303L, "4605361 * 344583023");
assertFactorizationSuccess(1253586675305333L, "6030247 * 207883139");
assertFactorizationSuccess(1139151196120601L, "232987 * 4889333723");
assertFactorizationSuccess(1553712951089947L, "29184373 * 53237839");
assertFactorizationSuccess(2235885271339597L, "38826707 * 57586271");
assertFactorizationSuccess(1586929215386303L, "4605361 * 344583023");
// Failures before spRand() fix
testFullFactorization(930705057210221L, "25325941 * 36749081");
testFullFactorization(1067332898136023L, "26165441 * 40791703");
testFullFactorization(8311092540494299L, "67613999 * 122919701");
testFullFactorization(23603982383629381L, "118493549 * 199200569");
testFullFactorization(58725827789610857L, "103129121 * 569439817");
testFullFactorization(369313815090910177L, "354877001 * 1040681177");
assertFactorizationSuccess(930705057210221L, "25325941 * 36749081");
assertFactorizationSuccess(1067332898136023L, "26165441 * 40791703");
assertFactorizationSuccess(8311092540494299L, "67613999 * 122919701");
assertFactorizationSuccess(23603982383629381L, "118493549 * 199200569");
assertFactorizationSuccess(58725827789610857L, "103129121 * 569439817");
assertFactorizationSuccess(369313815090910177L, "354877001 * 1040681177");
// Failures before int to long cast fix
testFullFactorization(41382606407163353L, "69696377 * 593755489");
testFullFactorization(306358296309770459L, "209066843 * 1465360513");
assertFactorizationSuccess(41382606407163353L, "69696377 * 593755489");
assertFactorizationSuccess(306358296309770459L, "209066843 * 1465360513");
// Failures because #curves was too small
testFullFactorization(474315852287951L, "15390191 * 30819361");
testFullFactorization(9400170223537253L, "47701151 * 197063803");
testFullFactorization(35239016917581299L, "82794071 * 425622469");
testFullFactorization(37915240075398767L, "16632857 * 2279538631");
testFullFactorization(459926431465210403L, "631315747 * 728520449");
testFullFactorization(752882545886305349L, "460178669 * 1636065721");
testFullFactorization(179503729521451L, "7420397 * 24190583");
testFullFactorization(1059150637518581L, "22339673 * 47411197");
testFullFactorization(3209190314462729L, "24571021 * 130608749");
testFullFactorization(17586811742837503L, "105611027 * 166524389");
testFullFactorization(13745855671622359L, "50960113 * 269737543");
testFullFactorization(15727038894518533L, "55460939 * 283569647");
testFullFactorization(66804960995707271L, "125296429 * 533175299");
testFullFactorization(38704493646912997L, "31501721 * 1228646957");
testFullFactorization(56025872236672099L, "53839061 * 1040617559");
testFullFactorization(57675022504187287L, "172307477 * 334721531");
testFullFactorization(69916262762899909L, "72133751 * 969258659");
testFullFactorization(51113648728234999L, "49275467 * 1037304197");
testFullFactorization(55878279398722441L, "131149259 * 426066299");
assertFactorizationSuccess(474315852287951L, "15390191 * 30819361");
assertFactorizationSuccess(9400170223537253L, "47701151 * 197063803");
assertFactorizationSuccess(35239016917581299L, "82794071 * 425622469");
assertFactorizationSuccess(37915240075398767L, "16632857 * 2279538631");
assertFactorizationSuccess(459926431465210403L, "631315747 * 728520449");
assertFactorizationSuccess(752882545886305349L, "460178669 * 1636065721");
assertFactorizationSuccess(179503729521451L, "7420397 * 24190583");
assertFactorizationSuccess(1059150637518581L, "22339673 * 47411197");
assertFactorizationSuccess(3209190314462729L, "24571021 * 130608749");
assertFactorizationSuccess(17586811742837503L, "105611027 * 166524389");
assertFactorizationSuccess(13745855671622359L, "50960113 * 269737543");
assertFactorizationSuccess(15727038894518533L, "55460939 * 283569647");
assertFactorizationSuccess(66804960995707271L, "125296429 * 533175299");
assertFactorizationSuccess(38704493646912997L, "31501721 * 1228646957");
assertFactorizationSuccess(56025872236672099L, "53839061 * 1040617559");
assertFactorizationSuccess(57675022504187287L, "172307477 * 334721531");
assertFactorizationSuccess(69916262762899909L, "72133751 * 969258659");
assertFactorizationSuccess(51113648728234999L, "49275467 * 1037304197");
assertFactorizationSuccess(55878279398722441L, "131149259 * 426066299");
}

@Test
public void testNumbersWithManyFactors() {
testFullFactorization(1096954293075013905L, "3 * 5 * 7^2 * 169681 * 8795650783");
testFullFactorization(1100087778366101931L, "3 * 7 * 43 * 89 * 199 * 263 * 307 * 881 * 967"); // Fibonacci(88)
assertFactorizationSuccess(1096954293075013905L, "3 * 5 * 7^2 * 169681 * 8795650783");
assertFactorizationSuccess(1100087778366101931L, "3 * 7 * 43 * 89 * 199 * 263 * 307 * 881 * 967"); // Fibonacci(88)
}

private void testFullFactorization(long N, String expectedPrimeFactorizationStr) {
private void assertFactorizationSuccess(long N, String expectedPrimeFactorizationStr) {
SortedMultiset<BigInteger> factors = tinyEcm.factor(BigInteger.valueOf(N));
LOG.info(N + " = " + factors.toString("*", "^"));
assertEquals(expectedPrimeFactorizationStr, factors.toString("*", "^"));
Expand Down
72 changes: 36 additions & 36 deletions src/test/java/de/tilman_neumann/jml/factor/ecm/TinyEcm64Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,52 +38,52 @@ public static void setup() {

@Test
public void testSemiprimes() {
testFullFactorization(1234577*12345701L, "1234577 * 12345701");
assertFactorizationSuccess(1234577*12345701L, "1234577 * 12345701");
// Failures before map[] fix
testFullFactorization(1253586675305333L, "6030247 * 207883139");
testFullFactorization(1139151196120601L, "232987 * 4889333723");
testFullFactorization(1553712951089947L, "29184373 * 53237839");
testFullFactorization(2235885271339597L, "38826707 * 57586271");
testFullFactorization(1586929215386303L, "4605361 * 344583023");
assertFactorizationSuccess(1253586675305333L, "6030247 * 207883139");
assertFactorizationSuccess(1139151196120601L, "232987 * 4889333723");
assertFactorizationSuccess(1553712951089947L, "29184373 * 53237839");
assertFactorizationSuccess(2235885271339597L, "38826707 * 57586271");
assertFactorizationSuccess(1586929215386303L, "4605361 * 344583023");
// Failures before spRand() fix
testFullFactorization(930705057210221L, "25325941 * 36749081");
testFullFactorization(1067332898136023L, "26165441 * 40791703");
testFullFactorization(8311092540494299L, "67613999 * 122919701");
testFullFactorization(23603982383629381L, "118493549 * 199200569");
testFullFactorization(58725827789610857L, "103129121 * 569439817");
testFullFactorization(369313815090910177L, "354877001 * 1040681177");
assertFactorizationSuccess(930705057210221L, "25325941 * 36749081");
assertFactorizationSuccess(1067332898136023L, "26165441 * 40791703");
assertFactorizationSuccess(8311092540494299L, "67613999 * 122919701");
assertFactorizationSuccess(23603982383629381L, "118493549 * 199200569");
assertFactorizationSuccess(58725827789610857L, "103129121 * 569439817");
assertFactorizationSuccess(369313815090910177L, "354877001 * 1040681177");
// Failures before int to long cast fix
testFullFactorization(41382606407163353L, "69696377 * 593755489");
testFullFactorization(306358296309770459L, "209066843 * 1465360513");
assertFactorizationSuccess(41382606407163353L, "69696377 * 593755489");
assertFactorizationSuccess(306358296309770459L, "209066843 * 1465360513");
// Failures because #curves was too small
testFullFactorization(474315852287951L, "15390191 * 30819361");
testFullFactorization(9400170223537253L, "47701151 * 197063803");
testFullFactorization(35239016917581299L, "82794071 * 425622469");
testFullFactorization(37915240075398767L, "16632857 * 2279538631");
testFullFactorization(459926431465210403L, "631315747 * 728520449");
testFullFactorization(752882545886305349L, "460178669 * 1636065721");
testFullFactorization(179503729521451L, "7420397 * 24190583");
testFullFactorization(1059150637518581L, "22339673 * 47411197");
testFullFactorization(3209190314462729L, "24571021 * 130608749");
testFullFactorization(17586811742837503L, "105611027 * 166524389");
testFullFactorization(13745855671622359L, "50960113 * 269737543");
testFullFactorization(15727038894518533L, "55460939 * 283569647");
testFullFactorization(66804960995707271L, "125296429 * 533175299");
testFullFactorization(38704493646912997L, "31501721 * 1228646957");
testFullFactorization(56025872236672099L, "53839061 * 1040617559");
testFullFactorization(57675022504187287L, "172307477 * 334721531");
testFullFactorization(69916262762899909L, "72133751 * 969258659");
testFullFactorization(51113648728234999L, "49275467 * 1037304197");
testFullFactorization(55878279398722441L, "131149259 * 426066299");
assertFactorizationSuccess(474315852287951L, "15390191 * 30819361");
assertFactorizationSuccess(9400170223537253L, "47701151 * 197063803");
assertFactorizationSuccess(35239016917581299L, "82794071 * 425622469");
assertFactorizationSuccess(37915240075398767L, "16632857 * 2279538631");
assertFactorizationSuccess(459926431465210403L, "631315747 * 728520449");
assertFactorizationSuccess(752882545886305349L, "460178669 * 1636065721");
assertFactorizationSuccess(179503729521451L, "7420397 * 24190583");
assertFactorizationSuccess(1059150637518581L, "22339673 * 47411197");
assertFactorizationSuccess(3209190314462729L, "24571021 * 130608749");
assertFactorizationSuccess(17586811742837503L, "105611027 * 166524389");
assertFactorizationSuccess(13745855671622359L, "50960113 * 269737543");
assertFactorizationSuccess(15727038894518533L, "55460939 * 283569647");
assertFactorizationSuccess(66804960995707271L, "125296429 * 533175299");
assertFactorizationSuccess(38704493646912997L, "31501721 * 1228646957");
assertFactorizationSuccess(56025872236672099L, "53839061 * 1040617559");
assertFactorizationSuccess(57675022504187287L, "172307477 * 334721531");
assertFactorizationSuccess(69916262762899909L, "72133751 * 969258659");
assertFactorizationSuccess(51113648728234999L, "49275467 * 1037304197");
assertFactorizationSuccess(55878279398722441L, "131149259 * 426066299");
}

@Test
public void testNumbersWithManyFactors() {
testFullFactorization(1096954293075013905L, "3 * 5 * 7^2 * 169681 * 8795650783");
testFullFactorization(1100087778366101931L, "3 * 7 * 43 * 89 * 199 * 263 * 307 * 881 * 967"); // Fibonacci(88)
assertFactorizationSuccess(1096954293075013905L, "3 * 5 * 7^2 * 169681 * 8795650783");
assertFactorizationSuccess(1100087778366101931L, "3 * 7 * 43 * 89 * 199 * 263 * 307 * 881 * 967"); // Fibonacci(88)
}

private void testFullFactorization(long N, String expectedPrimeFactorizationStr) {
private void assertFactorizationSuccess(long N, String expectedPrimeFactorizationStr) {
SortedMultiset<BigInteger> factors = tinyEcm.factor(BigInteger.valueOf(N));
LOG.info(N + " = " + factors.toString("*", "^"));
assertEquals(expectedPrimeFactorizationStr, factors.toString("*", "^"));
Expand Down

0 comments on commit ca7f634

Please sign in to comment.