#/bin/bash ########################################################################## # This script is based on work developed by Max0526 on mersenneforum.org. # It is designed to refine polynomials in a manner to increase their # Murphy_E score by running them through size and root optimizations. # # After the first pass through CADO-NFS sopt and ropt, Msieve's root opt # function is run on a select few and then CADO-NFS is rerun. The Msieve # and second CADO-NFS runs are optional. # # Note: Currently, the composite must be available within the polynomial # input file. It is only needed once and should be placed as the very # first line (e.g. n: ). # # To use this script, create a directory within your cado-nfs folder, # e.g. "polyspin" and place this script and your file containing the # polynomials within that folder. Then make appropriate changes to the # settings just below this introduction. # # You can then use: # bash polyspin.sh # Or, you can simply use: # bash polyspin.sh # and enter the poly filename when prompted. # # Multiple polynomials can be listed in the poly file. Only the first # one needs the composite (n: ). Separate all polys with a single # blank line. # # Note: Mixed polynomial formats can be used, but the degrees must all # be the same. ################################################20211018################### # ========================================== # ** Set the following to your own values ** # ========================================== # CADO-NFS folder within the build directory - change as needed bfolder=$HOSTNAME #set relative location for msieve msieverl="../../msieve/" # keep final intermediate files - "no" removes all int files at end keepintfiles=yes # Adjust the number of threads to use - current setting is all threads=$(nproc) # choose whether to run ropt 100 for the initial phase runr100i=no # choose whether to run ropt 100 for the final phase runr100f=yes # choose whether to run Msieve size optimization runMsieves=no # ***Not currently working*** # choose whether to run Msieve root optimization runMsiever=no # choose whether to add coefficient multipliers to CADO-NFS operations # **NOTE: Pari-gp must be installed for multipliers operation** multiC=yes # CADO-NFS multipliers to run multipliersC="2 4 6 8 9 16 25 36" # choose whether to add coefficient multipliers to Msieve operations multiM=no # Msieve multipliers to run multipliersM="3 7" # choose whether to run second CADO-NFS optimization runCADO2=no # Choose maximum number of scores to keep when culling rawset cullnum=5 # Choose whether to check cownoise scores (I-net connection required) checkcownoise="yes" # Initialize several variables multiarrC=($multipliersC) multiarrM=($multipliersM) rm stderr.list 2>/dev/null inpolys=$1 n="" c5="" c6="" c7="" c8="" SECONDS=0 # Check number of polynomials in rawset function checkrawset { rcount=0 exec <"rawset" while read line do case $line in "Y1"*) let rcount=${rcount}+1 ;; esac done # printf "\nrawset has $rcount polynomials\n" # debugging line } # Remove duplicate polynomials from rawset function remdupsrs { declare -a singlec3 count=0 duplicates=0 exec <"rawset" while read liners do case $liners in "n:"*) n=$liners ;; "sk"*) skew=$liners ;; "c0"*) c0=$liners ;; "c1"*) c1=$liners ;; "c2"*) c2=$liners ;; "c3"*) c3=$liners ;; "c4"*) c4=$liners ;; "c5"*) c5=$liners ;; "c6"*) c6=$liners ;; "c7"*) c7=$liners ;; "c8"*) c8=$liners ;; "Y0"*) Y0=$liners ;; "Y1"*) Y1=$liners ;; *) case "${singlec3[*]}" in *"$c3"*) let duplicates=${duplicates}+1 ;; *) echo "$n" >>rawsetd echo "$skew" >>rawsetd echo "$c0" >>rawsetd echo "$c1" >>rawsetd echo "$c2" >>rawsetd echo "$c3" >>rawsetd echo "$c4" >>rawsetd if [ ${#c5} -gt 0 ] then echo "$c5" >>rawsetd fi if [ ${#c6} -gt 0 ] then echo "$c6" >>rawsetd fi if [ ${#c7} -gt 0 ] then echo "$c7" >>rawsetd fi if [ ${#c8} -gt 0 ] then echo "$c8" >>rawsetd fi echo "$Y0" >>rawsetd echo "$Y1" >>rawsetd echo "" >>rawsetd singlec3[$count]="$c3" let count=${count}+1 ;; esac ;; esac done # echo "$duplicates duplicates found!" # debugging line unset singlec3 rm rawset 2>>stderr.list mv rawsetd rawset } # Convert seconds to [[hh:]mm:]ss function times2c { tempsec=$(($SECONDS-$tempsec)) let hr=${tempsec}/3600 let tempsec=${tempsec}%3600 let mn=${tempsec}/60 let se=${tempsec}%60 if [ $hr -gt 0 ] then printf "%d:%02d:%02d" $hr $mn $se else if [ $mn -gt 0 ] then printf "%d:%02d" $mn $se else printf "%d seconds" $se fi fi } # Add Msieve's root opt best poly to rawset function mharvest { exec <"msieve.fb" while read line do case $line in "N"*) echo "n: ${line:2}" >>rawset ;; "R0"*) echo "Y0: ${line:3}" >>rawset ;; "R1"*) echo "Y1: ${line:3}" >>rawset ;; "A0"*) echo "c0: ${line:3}" >>rawset ;; "A1"*) echo "c1: ${line:3}" >>rawset ;; "A2"*) echo "c2: ${line:3}" >>rawset ;; "A3"*) echo "c3: ${line:3}" >>rawset ;; "A4"*) echo "c4: ${line:3}" >>rawset ;; "A5"*) echo "c5: ${line:3}" >>rawset ;; "A6"*) echo "c6: ${line:3}" >>rawset ;; "A7"*) echo "c7: ${line:3}" >>rawset ;; "A8"*) echo "c8: ${line:3}" >>rawset ;; esac done echo "" >>rawset } # Run root optimization on rawset at effort 0, 0.01, 1, 2, 10, 100 function rootopt { rm roptset 2>>stderr.list printf "Running rootopt 0 " tempsec=$SECONDS ../build/$bfolder/polyselect/polyselect_ropt -t $threads -inputpolys rawset -area 1.00e+16 -Bf 10000000 -Bg 5000000 -v -ropteffort 0 >> roptset 2>>stderr.list printf "\rrootopt 0 took " times2c printf "\n" let cullnum=${cullnum}*10 harvestME let cullnum=${cullnum}/10 printf "Running rootopt 0.01 " tempsec=$SECONDS ../build/$bfolder/polyselect/polyselect_ropt -t $threads -inputpolys rawset -area 1.00e+16 -Bf 10000000 -Bg 5000000 -v -ropteffort 0.01 >> roptset 2>>stderr.list printf "\rrootopt 0.01 took " times2c printf "\n" harvestME for r in 1 2 10 do rm roptset 2>>stderr.list printf "Running rootopt $r " tempsec=$SECONDS ../build/$bfolder/polyselect/polyselect_ropt -t $threads -inputpolys rawset -area 1.00e+16 -Bf 10000000 -Bg 5000000 -v -ropteffort $r >> roptset 2>>stderr.list printf "\rrootopt $r took " times2c printf "\n" checkrawset harvestME if [ $r -lt 10 ] then sizeopt fi done if [ ${runr100i:0:1} == "y" ] then rm roptset 2>>stderr.list printf "Running rootopt 100 " tempsec=$SECONDS ../build/$bfolder/polyselect/polyselect_ropt -t $threads -inputpolys rawset -area 1.00e+16 -Bf 10000000 -Bg 5000000 -v -ropteffort 100 >> roptset 2>>stderr.list printf "\rrootopt 100 took " times2c printf "\n" harvestME fi } # Filter root optimized polys and add uniques to rawset with negations function harvestME { rm temp2neg 2>>stderr.list MurphyEs="" exec <"roptset" while read line do check=0 case $line in "n: "*) n=$line ;; "Y0: "*) Y0=$line ;; "Y1: "*) Y1=$line ;; "c0: "*) c0=$line ;; "c1: "*) c1=$line ;; "c2: "*) c2=$line ;; "c3: "*) c3=$line ;; "c4: "*) c4=$line ;; "c5: "*) c5=$line ;; "c6: "*) c6=$line ;; "c7: "*) c7=$line ;; "c8: "*) c8=$line ;; "skew: "*) skew=$line ;; "# MurphyE("*) MurphyE=${line##*=} case $MurphyEs in *"$MurphyE"*) check=1 ;; esac if [ $check -eq 0 ] then MurphyEs="${MurphyEs} ${MurphyE}" echo "$n" >>temp2neg echo "$skew" >>temp2neg echo "$c0" >>temp2neg echo "$c1" >>temp2neg echo "$c2" >>temp2neg echo "$c3" >>temp2neg echo "$c4" >>temp2neg if [ ${#c5} -gt 0 ] then echo "$c5" >>temp2neg fi if [ ${#c6} -gt 0 ] then echo "$c6" >>temp2neg fi if [ ${#c7} -gt 0 ] then echo "$c7" >>temp2neg fi if [ ${#c8} -gt 0 ] then echo "$c8" >>temp2neg fi echo "$Y0" >>temp2neg echo "$Y1" >>temp2neg echo "" >>temp2neg fi ;; esac done if [ -e temp2neg ] then negatecs cat temp2neg >>rawset cat tempneg >>rawset fi remdupsrs checkrawset if [ $rcount -gt $cullnum ] then cullrawset remdupsrs fi printf " Current list of Murphy_E scores: " echo $MurphyEs # checkrawset # debugging line - must also set output in function harvestBP } # Cull rawset to number of scores set in cullnum function cullrawset { printf " Culling to top $cullnum scores. . .\r" cullset=($MurphyEs) IFS=$'\n' cullset=($(sort <<<"${cullset[*]}")) unset IFS arrcount=${#cullset[*]} checkcs=${cullset[0]:7} acount=0 tcount=0 while [ $acount -lt $arrcount ] do if [ ${cullset[${acount}]:7} -gt $checkcs ] then tempME[$tcount]=${cullset[${acount}]} let tcount=${tcount}+1 fi let acount=${acount}+1 done acount=0 while [ $acount -lt $arrcount ] do if [ ${cullset[${acount}]:7} -eq $checkcs ] then tempME[$tcount]=${cullset[${acount}]} let tcount=${tcount}+1 fi let acount=${acount}+1 done unset cullset let tcount=${arrcount}-${cullnum} acount=0 while [ $acount -lt $tcount ] do unset 'tempME[$acount]' let acount=${acount}+1 done MurphyEs="${tempME[*]}" unset tempME rm temp2neg 2>>stderr.list exec <"roptset" checkr=0 while read line do case $line in "n: "*) n=$line ;; "Y0: "*) Y0=$line ;; "Y1: "*) Y1=$line ;; "c0: "*) c0=$line ;; "c1: "*) c1=$line ;; "c2: "*) c2=$line ;; "c3: "*) c3=$line ;; "c4: "*) c4=$line ;; "c5: "*) c5=$line ;; "c6: "*) c6=$line ;; "c7: "*) c7=$line ;; "c8: "*) c8=$line ;; "skew: "*) skew=$line ;; "# MurphyE("*) MurphyE=${line##*=} case $MurphyEs in *"$MurphyE"*) echo "$n" >>temp2neg echo "$skew" >>temp2neg echo "$c0" >>temp2neg echo "$c1" >>temp2neg echo "$c2" >>temp2neg echo "$c3" >>temp2neg echo "$c4" >>temp2neg if [ ${#c5} -gt 0 ] then echo "$c5" >>temp2neg fi if [ ${#c6} -gt 0 ] then echo "$c6" >>temp2neg fi if [ ${#c7} -gt 0 ] then echo "$c7" >>temp2neg fi if [ ${#c8} -gt 0 ] then echo "$c8" >>temp2neg fi echo "$Y0" >>temp2neg echo "$Y1" >>temp2neg echo "" >>temp2neg let checkr=${checkr}+1 ;; esac esac done if [ -e temp2neg ] then negatecs cat temp2neg >rawset cat tempneg >>rawset fi remdupsrs checkrawset } # Get cownoise values for Best Poly function cownoise { wget "http://myfactorcollection.cownoise.com:8090/cgi-bin/showskew?c8=$c8&c7=$c7&c6=$c6&c5=$c5&c4=$c4&c3=$c3&c2=$c2&c1=$c1&c0=$c0&Y1=$Y1&Y0=$Y0" -q -O cn.html exec <"cn.html" while read line do case "$line" in "
"*) ind=$(echo `expr index "$line" g`) cn=${line:${ind}+6} ind=$(echo `expr index "$cn" s`) cn=${cn:0:${ind}-3} ;; esac done } # Read values of input polyfile into rawset function buildRaw { rm rawset 2>>stderr.list # Adds blank line to end of polys file, if not already present exec <"$inpolys" while read line do temp=$line done if [ ${#temp} -gt 0 ] then echo "" >>$inpolys fi exec <"$inpolys" while read line do case $line in "n: "*) n=${line:3} ;; "Y0: "*) Y0=${line:4} ;; "Y1: "*) Y1=${line:4} ;; "c0: "*) c0=${line:4} ;; "c1: "*) c1=${line:4} ;; "c2: "*) c2=${line:4} ;; "c3: "*) c3=${line:4} ;; "c4: "*) c4=${line:4} ;; "c5: "*) c5=${line:4} ;; "c6: "*) c6=${line:4} ;; "c7: "*) c7=${line:4} ;; "c8: "*) c8=${line:4} ;; "skew: "*) skew=${line:6} ;; "N "*) n=${line:2} ;; "R0 "*) Y0=${line:3} ;; "R1 "*) Y1=${line:3} ;; "A0 "*) c0=${line:3} ;; "A1 "*) c1=${line:3} ;; "A2 "*) c2=${line:3} ;; "A3 "*) c3=${line:3} ;; "A4 "*) c4=${line:3} ;; "A5 "*) c5=${line:3} ;; "A6 "*) c6=${line:3} ;; "A7 "*) c7=${line:3} ;; "A8 "*) c8=${line:3} ;; "SKEW "*) skew=${line:5} ;; "N: "*) n=${line:3} ;; "R0: "*) Y0=${line:4} ;; "R1: "*) Y1=${line:4} ;; "A0: "*) c0=${line:4} ;; "A1: "*) c1=${line:4} ;; "A2: "*) c2=${line:4} ;; "A3: "*) c3=${line:4} ;; "A4: "*) c4=${line:4} ;; "A5: "*) c5=${line:4} ;; "A6: "*) c6=${line:4} ;; "A7: "*) c7=${line:4} ;; "A8: "*) c8=${line:4} ;; "SKEW: "*) skew=${line:6} ;; *) if [ ${#line} -lt 1 ] then echo "n: $n" >> rawset echo "skew: $skew" >> rawset echo "c0: $c0" >> rawset echo "c1: $c1" >> rawset echo "c2: $c2" >> rawset echo "c3: $c3" >> rawset echo "c4: $c4" >> rawset if [ ${#c5} -gt 0 ] then echo "c5: $c5" >> rawset fi if [ ${#c6} -gt 0 ] then echo "c6: $c6" >> rawset fi if [ ${#c7} -gt 0 ] then echo "c7: $c7" >> rawset fi if [ ${#c8} -gt 0 ] then echo "c8: $c8" >> rawset fi echo "Y0: $Y0" >> rawset echo "Y1: $Y1" >> rawset echo "" >> rawset fi ;; esac done if [ ${#n} -lt 1 ] then echo "No composite found! Please add n: to input poly file." fi if [ ${multiC:0:1} == "y" ] then addMultsC fi } # Build multiplier lines for polys fed to CADO-NFS function addMultsC { printf "Adding in multipliers. . . \r" rm rawset.adds* 2>>stderr.list exec <"rawset" while read line do for am in "${multiarrC[@]}" do case $line in "c"*) beg=${line:0:4} rest=${line:3} ans=$(echo "print($rest*$am)" | gp -q -f) echo "${beg}${ans}" >>rawset.adds$am ;; *) echo "${line}" >>rawset.adds$am ;; esac done done cat rawset.adds* >>rawset } # Build multiplier lines for polys fed to msieve function addMultsM { printf "Adding in multipliers. . . \r" rm msieve.dat.ms.adds 2>>stderr.list exec <"msieve.dat.ms" while read line do for am in "${multiarrM[@]}" do count=0 mul="" temparray=($line) coeffs=${#temparray[*]} let coeffs=${coeffs}-2 while [ $count -lt $coeffs ] do ans=$(echo "print(${temparray[$count]}*$am)" | gp -q -f) let count=${count}+1 mul="$mul $ans" done mul="$mul ${temparray[-2]} ${temparray[-1]}" echo "$mul" >>msieve.dat.ms.adds done done cat msieve.dat.ms.adds >>msieve.dat.ms } # Build Msieve .ms file function buildms { printf "Building msieve.dat.ms file. . .\r" rm msieve.dat.ms 2>>stderr.list exec <"rawset" while read line do case $line in "n: "*) n=${line:3} ;; "Y0: "*) Y0=${line:4} ;; "Y1: "*) Y1=${line:4} ;; "c0: "*) c0=${line:4} ;; "c1: "*) c1=${line:4} ;; "c2: "*) c2=${line:4} ;; "c3: "*) c3=${line:4} ;; "c4: "*) c4=${line:4} ;; "c5: "*) c5=${line:4} ;; "c6: "*) c6=${line:4} ;; "c7: "*) c7=${line:4} ;; "c8: "*) c8=${line:4} ;; *) if [ ${#line} -lt 1 ] then if [ ${#c8} -gt 0 ] then printf "%s " $c8 >>msieve.dat.ms fi if [ ${#c7} -gt 0 ] then printf "%s " $c7 >>msieve.dat.ms fi if [ ${#c6} -gt 0 ] then printf "%s " $c6 >>msieve.dat.ms fi if [ ${#c5} -gt 0 ] then printf "%s " $c5 >>msieve.dat.ms fi echo "$c4 $c3 $c2 $c1 $c0 $Y1 $Y0" >>msieve.dat.ms fi ;; esac done if [ ${multiM:0:1} == "y" ] then addMultsM fi } # Build Msieve .m file function buildm { printf "Building msieve.dat.m file. . .\r" rm msieve.dat.m* 2>>stderr.list exec <"rawset" while read line do case $line in "Y0: "*) Y0=${line:4} if [ ${Y0:0:1} == "-" ] then Y0=${Y0:1} fi ;; "Y1: "*) Y1=${line:4} if [ ${Y1:0:1} == "-" ] then Y1=${Y1:1} fi ;; "c4: "*) c4=${line:4} ;; "c5: "*) c5=${line:4} ;; "c6: "*) c6=${line:4} ;; "c7: "*) c7=${line:4} ;; "c8: "*) c8=${line:4} ;; *) if [ ${#line} -lt 1 ] then if [ ${#c8} -gt 0 ] then printf "%s " $c8 >>msieve.dat.m elif [ ${#c7} -gt 0 ] then printf "%s " $c7 >>msieve.dat.m elif [ ${#c6} -gt 0 ] then printf "%s " $c6 >>msieve.dat.m elif [ ${#c5} -gt 0 ] then printf "%s " $c5 >>msieve.dat.m elif [ ${#c4} -gt 0 ] then printf "%s " $c4 >>msieve.dat.m fi echo "$Y1 $Y0" >>msieve.dat.m fi ;; esac done # addMultsM } function readValues { exec <"$polyfile" while read line do case $line in "n: "*) n=${line:3} ;; "Y0: "*) Y0=${line:4} ;; "Y1: "*) Y1=${line:4} ;; "c0: "*) c0=${line:4} ;; "c1: "*) c1=${line:4} ;; "c2: "*) c2=${line:4} ;; "c3: "*) c3=${line:4} ;; "c4: "*) c4=${line:4} ;; "c5: "*) c5=${line:4} ;; "c6: "*) c6=${line:4} ;; "c7: "*) c7=${line:4} ;; "c8: "*) c8=${line:4} ;; "skew: "*) skew=${line:6} ;; esac done } # Create tempneg file with negated c values function negatecs { rm tempneg 2>>stderr.list exec <"temp2neg" while read line do case $line in "n: "*) echo $line >> tempneg ;; "skew: "*) echo $line >> tempneg ;; "Y0: "*) echo $line >> tempneg ;; "Y1: "*) echo $line >> tempneg echo "" >> tempneg ;; "c"*) test=${line:4} if [[ $test = -* ]] then echo ${line:0:4}${line:5} >> tempneg else echo ${line:0:4}-${line:4} >> tempneg fi ;; esac done } # Extract best polynomial function harvestBP { rm BestPoly 2>>stderr.list exec <"roptset" while read line do case $line in "# n: "*) n=$line ;; "# Y0: "*) Y0=$line ;; "# Y1: "*) Y1=$line ;; "# c0: "*) c0=$line ;; "# c1: "*) c1=$line ;; "# c2: "*) c2=$line ;; "# c3: "*) c3=$line ;; "# c4: "*) c4=$line ;; "# c5: "*) c5=$line ;; "# c6: "*) c6=$line ;; "# c7: "*) c7=$line ;; "# c8: "*) c8=$line ;; "# skew: "*) skew=$line ;; "# # lognorm "*) lognorm=$line ;; "# # MurphyE("*) MurphyE=$line ;; esac done printf " Best Murphy_E found so far: " tempbME=${MurphyE:46} meind=$(echo `expr index "$tempbME" =`) printf "\033[1;97m\033[40m${tempbME:${meind}}\033[0m\n" echo "${n:2}" >>BestPoly echo "${Y0:2}">>BestPoly echo "${Y1:2}" >>BestPoly echo "${c0:2}" >>BestPoly echo "${c1:2}" >>BestPoly echo "${c2:2}" >>BestPoly echo "${c3:2}" >>BestPoly echo "${c4:2}" >>BestPoly if [ ${#c5} -gt 0 ] then echo "${c5:2}" >>BestPoly fi if [ ${#c6} -gt 0 ] then echo "${c6:2}" >>BestPoly fi if [ ${#c7} -gt 0 ] then echo "${c7:2}" >>BestPoly fi if [ ${#c8} -gt 0 ] then echo "${c8:2}" >>BestPoly fi echo "${skew:2}" >>BestPoly echo "${lognorm:2}" >>BestPoly echo "${MurphyE:2}" >>BestPoly echo "" >>BestPoly cat BestPoly >>$BPl } # Run size optimization at effort 0, 1, 10, 100 function sizeopt { rm soptset 2>>stderr.list expEs="" for s in 0 1 10 100 do printf " running sizeopt at %s\r" $s ../build/$bfolder/polyselect/sopt -inputpolys rawset -sopteffort $s -v >> soptset done # Add size optimized polys to rawset with negations rm temp2neg 2>>stderr.list exec <"soptset" while read line do checkss=0 case $line in "n: "*) n=$line ;; "Y0: "*) Y0=$line ;; "Y1: "*) Y1=$line ;; "c0: "*) c0=$line ;; "c1: "*) c1=$line ;; "c2: "*) c2=$line ;; "c3: "*) c3=$line ;; "c4: "*) c4=$line ;; "c5: "*) c5=$line ;; "c6: "*) c6=$line ;; "c7: "*) c7=$line ;; "c8: "*) c8=$line ;; "skew: "*) skew=$line ;; "# lognorm "*) expE=${line:23:5} case $expEs in *"$expE"*) checkss=1 ;; esac if [ $checkss -eq 0 ] then expEs="${expEs}${expE} " fi echo "$n" >>temp2neg echo "$skew" >>temp2neg echo "$c0" >>temp2neg echo "$c1" >>temp2neg echo "$c2" >>temp2neg echo "$c3" >>temp2neg echo "$c4" >>temp2neg if [ ${#c5} -gt 0 ] then echo "$c5" >>temp2neg fi if [ ${#c6} -gt 0 ] then echo "$c6" >>temp2neg fi if [ ${#c7} -gt 0 ] then echo "$c7" >>temp2neg fi if [ ${#c8} -gt 0 ] then echo "$c8" >>temp2neg fi echo "$Y0" >>temp2neg echo "$Y1" >>temp2neg echo "" >>temp2neg ;; esac done expEset=($expEs) IFS=$'\n' expEset=($(sort <<<"${expEset[*]}")) unset IFS printf "Current exp_E list from sopteffort 0, 1, 10, 100: " echo "${expEset[*]}" if [ -e temp2neg ] then negatecs cat temp2neg >>rawset cat tempneg >>rawset remdupsrs fi } # Accept input for polyfile, if not provided on command line if [ ${#inpolys} -lt 1 ] then printf "polys file: " read inpolys in fi # Insist on valid name while [ ! -e $inpolys ] do printf "$inpolys not found!\nEnter valid name: " read inpolys in done # Create rawset to use for rest of script buildRaw if [ -e rawset ] then checkrawset fi # If all seems well, run major portion of script if [ ${#n} -gt 0 ] && [ ${#rcount} -gt 0 ] && [ -e rawset ] then # Set Best Poly listing name based on first five digits of n BPl="BestPoly${n:0:5}.list" rm temp2neg 2>>stderr.list # Create set of polys to negate c values cp rawset temp2neg # Negate polys negatecs # Append tempneg to rawset cat tempneg >> rawset # Run initial size/root optimizations echo "Running initial CADO-NFS size optimizations:" sizeopt echo "Running initial CADO-NFS root optimizations:" rootopt # Run Msieve size/root optimizations rm msieve* 2>>stderr.list echo "${n}" >worktodo.ini if [ "${runMsieves:0:1}" == "y" ] then buildm printf "Running Msieve size optimization: " tempsec=$SECONDS ${msieverl}msieve -t $threads -nps >stderr.list printf "\rMsieve size optimization took " times2c printf "\n" fi if [ "${runMsiever:0:1}" == "y" ] then if [ ! -e msieve.dat.m ] then buildms fi printf "Running Msieve root optimization: " tempsec=$SECONDS ${msieverl}msieve -t $threads -npr >stderr.list printf "\rMsieve root optimization took " times2c printf "\n" mharvest rm temp2neg 2>>stderr.list # Create set of polys to negate c values cp rawset temp2neg # negate polys negatecs # Append tempneg to rawset cat tempneg >> rawset remdupsrs fi # Run final CADO-NFS size/root optimizations if [ "${runCADO2:0:1}" == "y" ] then echo "Running CADO-NFS size optimizations:" sizeopt echo "Running final CADO-NFS root optimizations:" if [ ${runr100f:0:1} == "y" ] then runr100i=yes fi rootopt fi # Display Best Polynomial echo " Best poly found:" cat BestPoly polyfile="BestPoly" readValues if [ ${checkcownoise:0:1} == "y" ] then cownoise if [ ${#cn} -gt 10 ] then echo "Best poly cownoise values: $cn" else echo "cownoise.com appears to be unavailable!" fi fi # Remove intermediate files if "keep" setting is (n)o if [ ${keepintfiles:0:1} == "n" ] then rm rawset* 2>>stderr.list rm soptset 2>>stderr.list rm roptset 2>>stderr.list rm tempneg 2>>stderr.list rm msieve* 2>>stderr.list rm cn.html 2>>stderr.list rm temp2neg 2>>stderr.list rm worktodo.ini 2>>stderr.list fi # print time taken to run entire process let hr=${SECONDS}/3600 let SECONDS=${SECONDS}%3600 let mn=${SECONDS}/60 let se=${SECONDS}%60 printf "Full run time: %d:%02d:%02d\n" $hr $mn $se else echo "There was a problem processing the \"${inpolys}\" file!!" echo "Ensure the following:" echo "- the composite is (at least) on the first line in the file" echo "- there is a blank line between all polynomials" fi