File: test.pp1

package info (click to toggle)
gmp-ecm 7.0.4+ds-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,728 kB
  • sloc: asm: 36,431; ansic: 34,057; xml: 885; python: 799; sh: 698; makefile: 348
file content (193 lines) | stat: -rwxr-xr-x 7,584 bytes parent folder | download | duplicates (2)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/sh

# test file for P+1 method
#
# Copyright 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2012, 2016
# Paul Zimmermann, Alexander Kruppa, Dave Newman, Jim Fougeron, David Cleaver
#
# 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 3 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, see
# http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

PP1="${1:-./ecm} -pp1"

GMPECM_DATADIR=${GMPECM_DATADIR:-.}

# Call with "checkcode $? n" to check that return code is n
# (see test.pm1 for the explanation of the different return codes)

checkcode () {
  if [ $1 != $2 ]
  then
    echo "############### ERROR ###############"
    echo "Expected return code $2 but got $1"
    exit 1
  fi
}

checkcode2 () {
  if [ $1 != $2 ]
  then
    if [ $1 != $3 ]
    then
      echo "############### ERROR ###############"
      echo "Expected return code $2 or $3 but got $1"
      exit 1
    fi
  fi
}

# P+1 requires that sigma^2-4 is a quadratic non-residue mod p

echo 328006342451 | $PP1 -x0 5 120 7043; checkcode $? 8

# check rational seed
echo 328006342451 | $PP1 -x0 1/5 120 7043; checkcode $? 8

# try primes < d in stage 2
echo 2050449218179969792522461197 | $PP1 -x0 6 -k 1 20 0-1e6; checkcode $? 14

echo 6215074747201 | $PP1 -x0 5 630 199729; checkcode $? 8

# bug in 6.1.3
echo 6215074747201 | $PP1 -power 2 -x0 5 630 199729; checkcode $? 8
echo 6215074747201 | $PP1 -dickson 3 -x0 5 630 199729; checkcode $? 8

echo 8857714771093 | $PP1 -x0 3 23251 49207; checkcode $? 8

echo 236344687097 | $PP1 -x0 3 619 55001; checkcode $? 8

echo 87251820842149 | $PP1 -x0 5 3691 170249; checkcode $? 8

echo 719571227339189 | $PP1 -x0 4 41039 57679; checkcode $? 8

echo 5468575720021 | $PP1 -x0 6 1439 175759; checkcode $? 8

echo 49804972211 | $PP1 -x0 5 15443 268757; checkcode $? 8

echo 329573417220613 | $PP1 -x0 3 5279 101573; checkcode $? 8

echo 4866979762781 | $PP1 -x0 4 7309 97609; checkcode $? 8

echo 187333846633 | $PP1 -x0 3 2063 9851; checkcode $? 8

echo 332526664667473 | $PP1 -x0 3 65993 111919; checkcode $? 8

echo 265043186297 | $PP1 -x0 3 8761 152791; checkcode $? 8

echo 207734163253 | $PP1 -x0 3 1877 4211; checkcode $? 8

echo 225974065503889 | $PP1 -x0 5 -k 5 7867 8243; checkcode $? 8

echo 660198074631409 | $PP1 -x0 5 22541 115679; checkcode $? 8

echo 563215815517 | $PP1 -x0 3 3469 109849; checkcode $? 8

# test B2min-B2
echo 563215815517 | $PP1 -x0 3 3469 109849-109849; checkcode $? 8

echo 409100738617 | $PP1 -x0 3 19 19; checkcode $? 8

# p37 from 45^123+1 found by Peter Montgomery with B1=30M
echo 2277189375098448170118558775447117254551111605543304035536750762506158547102293199086726265869065639109 | $PP1 -x0 3 2337233 132554351
checkcode $? 14

# test -save/-resume
echo 2277189375098448170118558775447117254551111605543304035536750762506158547102293199086726265869065639109 | $PP1 -x0 3 -save test.pp1.save 1000000 0
checkcode $? 0
$PP1 -resume test.pp1.save 2337233 132554351
C=$?
checkcode $C 14
/bin/rm -f test.pp1.save

# test -chkpnt
echo "chkpnt"
echo 2277189375098448170118558775447117254551111605543304035536750762506158547102293199086726265869065639109 | $PP1 -x0 3 -chkpnt test.pp1.chk 1000000 0
checkcode $? 0
$PP1 -resume test.pp1.chk 2337233 132554351
C=$?
/bin/rm -f test.pp1.chk
checkcode $C 14

# bug in ecm-5.0 (overflow in fin_diff_coeff)
echo 630503947831861669 | $PP1 -x0 5 7 9007199254740000-9007199254741000; checkcode $? 8

# bug in ecm-6.0.1 on 64-bit machines. The error message "Error, maximal
# step1 bound for P+1 is ..." on 32-bit machines is normal.
$PP1 -printconfig | grep "GMP_NUMB_BITS = 64"
if [ $? -eq 0 ]; then

echo 8589934621 | $PP1 -x0 10 4294967310-4294967311 1; checkcode2 $? 1 8

fi

# 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 "6054018161*10^400+417727253109" | $PP1 -x0 4 2e3 2e6; checkcode $? 14

# Bug reported by Andreas Schickel: on 32 bit systems, the code in lucas.c
# for generating Lucas chains is prone to causing integer overflows, giving
# incorrect chains for some primes. This test exhibits the bug on 32 bit 
# systems but works on 64 bit

echo 154618728587 | $PP1 -x0 3 -go 36 4294957296-4294967295 1; checkcode $? 8

echo 18446744073709551337 | $PP1 -pp1 -x0 2 70823 714487; checkcode $? 8

# exercise pp1fs2_memory_use with -no-ntt
$PP1 -maxmem 1 -no-ntt 5e3 < ${GMPECM_DATADIR}/c155; checkcode $? 0

# exercise onepass pp1fs2_memory_use with -ntt
$PP1 -maxmem 1 -ntt 5e3 < ${GMPECM_DATADIR}/c155; checkcode $? 0

# exercise even number factor found in step one
echo 1234 | $PP1 5e3; checkcode $? 14

# exercise "Using lmax = 512 with one pass NTT which takes about 0MB of memory" message
$PP1 -maxmem 1 -ntt -v 5e3 < ${GMPECM_DATADIR}/c155; checkcode $? 0

# exercise "Using lmax = 436 without NTT which takes about 0MB of memory" message
$PP1 -maxmem 1 -no-ntt -v 5e3 < ${GMPECM_DATADIR}/c155; checkcode $? 0

# exercise "Error: cannot choose suitable P value for your stage 2 parameters." error message
$PP1 5e3 1e6-1e20 < ${GMPECM_DATADIR}/c155; checkcode $? 1

# check -v option
echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PP1 -v 1e5; checkcode $? 0

# check -v -v option
echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PP1 -v -v 1e5; checkcode $? 0

# check -v -v -v option
echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PP1 -v -v -v 1e5; checkcode $? 0

# check -v -v -v -v option
echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PP1 -v -v -v -v 1e5 > /dev/null

# exercise -x0 0 option
echo 18446744073709551653 | $PP1 -x0 0 257687 141775993; checkcode $? 8

# exercise bug (Segmentation fault) in ecm 7.0.x for x <= 3
echo 1000039 | $PP1 -x0 4 23 1087; checkcode $? 8
echo 10001779 | $PP1 -x0 4 23 1279; checkcode $? 8
echo 100002941 | $PP1 -x0 4 23 1093; checkcode $? 8
echo 1000024339 | $PP1 -x0 4 49 1249; checkcode $? 8
echo 10000098767 | $PP1 -x0 3 41 937; checkcode $? 8
echo 100000049993 | $PP1 -x0 3 43 1061; checkcode $? 8
echo 1000008849503 | $PP1 -x0 3 47 859; checkcode $? 8

echo "All P+1 tests are ok."