1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
#!/bin/sh
# test file for P-1 method
#
# Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Paul Zimmermann, Alexander Kruppa and Dave Newman.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
PM1="$1 -pm1"
# Call with "checkcode $? n" to check that return code is n
# the return code is (see ecm-ecm.h):
# 0: no factor found
# 1: error (for example out of memory)
# 2: composite factor found with composite cofactor
# 6: prime factor found with composite cofactor
# 8: input number found
# 10: composite factor found with prime cofactor
# 14: prime factor found with prime cofactor
checkcode () {
if [ $1 != $2 ]
then
echo "############### ERROR ###############"
echo "Expected return code $2 but got $1"
exit 1
fi
}
### bug in ecm-5.0 found by Jay Berg (overflow in i0*d)
echo 441995541378330835457 | $PM1 -x0 3 157080 7e9-72e8; checkcode $? 8
### stage 2 less than 10^9. Input is prime factor of 2^731-1 ###
echo 335203548019575991076297 | $PM1 -x0 2 23 31; checkcode $? 8
### stage 2 of length 1 ###
echo 335203548019575991076297 | $PM1 -x0 3 31 58766400424189339249-58766400424189339249; checkcode $? 8
# try primes < d in stage 2
echo 2050449353925555290706354283 | $PM1 -k 1 20 0-1e6; checkcode $? 14
# This factor was missed by an early development version of stage 2
echo 67872792749091946529 | $PM1 -x0 3 8467 11004397; checkcode $? 8
echo 5735039483399104015346944564789 | $PM1 1277209 9247741; checkcode $? 8
echo 620224739362954187513 | $PM1 -x0 3 668093 65087177; checkcode $? 8
echo 1405929742229533753 | $PM1 1123483 75240667; checkcode $? 8
echo 16811052664235873 | $PM1 -x0 3 19110 178253039; checkcode $? 8
echo 9110965748024759967611 | $PM1 1193119 316014211; checkcode $? 8
echo 563796628294674772855559264041716715663 | $PM1 4031563 14334623; checkcode $? 8
echo 188879386195169498836498369376071664143 | $PM1 3026227 99836987; checkcode $? 8
# factor of 909*9^909+1 found by Paul Leyland on 15 Nov 2002
echo 474476178924594486566271953891 | $PM1 9594209 519569569; checkcode $? 8
### stage 2 less than 10^10 ###
echo 2124306045220073929294177 | $PM1 290021 1193749003; checkcode $? 8
### Try saving and resuming
echo 25591172394760497166702530699464321 | $PM1 -save test.pm1.save 100000
checkcode $? 0
$PM1 -resume test.pm1.save 120557 2007301
C=$?
/bin/rm -f test.pm1.save
checkcode $C 8
# bug in ecm-5.0 (overflow in fin_diff_coeff)
echo 504403158265489337 | $PM1 -k 4 8 9007199254740700-9007199254740900; checkcode $? 8
# check that primes near B2min are covered
echo 6857 | $PM1 840 857; checkcode $? 8
# A test with a larger input number to test modular arithmetic routines not
# in mulredc*.asm. This input has 1363 bits so it has 22 64 bit words
# (43 32 bit words) and cannot use mulredc which handles only up to 20 limbs
echo "10090030271*10^400+696212088699" | $PM1 2e3 2e6; checkcode $? 14
# check bug fixed in revision 1378
echo "2^(64*2)-1" | $PM1 -redc -x0 -1 2 1; checkcode $? 8
echo "All P-1 tests are ok."
echo ""
|