| 1 | #!/usr/bin/sh |
| 2 | echo '* Am creating a new file '$4 |
| 3 | exec $psys/psl $* <<%EOP |
| 4 | (OFF ECHO) |
| 5 | |
| 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7 | %% Copyright (C) 1996 Joergen Backelin |
| 8 | %% |
| 9 | %% Bergman is distributed in the hope that it will be useful, |
| 10 | %% but WITHOUT ANY WARRANTY. No author or distributor |
| 11 | %% accepts responsibility to anyone for the consequences of using it |
| 12 | %% or for whether it serves any particular purpose or works at all, |
| 13 | %% unless (s)he says so in writing. Refer to the Bergman General |
| 14 | %% Public License for full details. |
| 15 | |
| 16 | %% Everyone is granted permission to copy, modify and redistribute |
| 17 | %% bergman, but only under the conditions described in the |
| 18 | %% Bergman General Public License. A copy of this license is |
| 19 | %% supposed to have been given to you along with bergman so you |
| 20 | %% can know your rights and responsibilities. It should be in a |
| 21 | %% file named copyright. Among other things, the copyright notice |
| 22 | %% and this notice must be preserved on all copies. |
| 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 24 | |
| 25 | % For debugging: |
| 26 | % (LOAD addr2id) |
| 27 | (OFF RAISE) |
| 28 | (ON EOLINSTRINGOK) |
| 29 | (GLOBAL '(Prime PrPrime HalfPrime Composit!* MPFError Arguments |
| 30 | &*ASKSTRONG &*NEWNUMBER PRIMLIST |
| 31 | FIRSTPRIMROOT EXPVECT LOGVECT OutFile)) |
| 32 | (PRIN2T "** Executing:") (PRIN2T "$*") |
| 33 | %%(SETQ Arguments (GETUNIXARGS)) |
| 34 | %(SETQ Prime (GETV UNIXARGS* 1)) |
| 35 | (PROGN |
| 36 | (SETQ Prime $1) |
| 37 | (SETQ PrPrime (SUB1 Prime)) |
| 38 | (SETQ HalfPrime (QUOTIENT Prime 2)) |
| 39 | %(SETQ Composit!* (GETV UNIXARGS* 2)) |
| 40 | (SETQ Composit!* $2) |
| 41 | %(SETQ MPFError!* (GETV UNIXARGS* 3)) |
| 42 | (SETQ MPFError!* $3) |
| 43 | % (SETQ PrimeFilePreAmble "/usr/local/matte/bergman/domains/P") |
| 44 | % (SETQ PrimeFilePreAmble $4) |
| 45 | (TERPRI) (PRIN2T "** Before (LOAD ""$5"").") |
| 46 | (LOAD "$5") |
| 47 | (TERPRI) (PRIN2T "** After (LOAD ""$5"").") |
| 48 | (DSKIN "$bmdomains/PRL") |
| 49 | (SETQ PL (PENULTIMA PRIMLIST)) |
| 50 | (COND ((EQ (DECIDE1 Prime) 'COMPOSITE) |
| 51 | (EXIT-WITH-STATUS Composite!*))) |
| 52 | % (SETQ OutFile (APPENDNUMBERTOSTRING Prime PrimeFilePreAmble)) |
| 53 | (SETQ OutFile "$4") |
| 54 | |
| 55 | % Doing the job |
| 56 | |
| 57 | (SETQ FIRSTPRIMROOT (FirstPrimitiveRoot)) |
| 58 | (SETQ EXPVECT (MKVECT (TIMES2 2 Prime))) |
| 59 | (SETQ LOGVECT (MKVECT (TIMES2 2 Prime))) |
| 60 | (MakeEXP!&LOGVECTs (TIMES2 2 Prime)) |
| 61 | |
| 62 | % For debugging: |
| 63 | (PRINT EXPVECT) (PRINT LOGVECT) (INTERPBACKTRACE) (PRINT OutFile) |
| 64 | |
| 65 | % Saving the result on OutFile |
| 66 | |
| 67 | (WRS (OPEN OutFile 'OUTPUT)) |
| 68 | (PRIN2 "% Preparation file for modulus calculation, |
| 69 | % with the prime modulus ") |
| 70 | (PRINT Prime) |
| 71 | (PRIN2 "% The exponents and logarithms are calculated |
| 72 | % with the base ") (PRINT FIRSTPRIMROOT) |
| 73 | (TERPRI) |
| 74 | |
| 75 | |
| 76 | (WRITEVECTPROG 'EXPVECT (TIMES2 PrPrime 2)) |
| 77 | (TERPRI) |
| 78 | (TERPRI) |
| 79 | |
| 80 | (WRITEVECTPROG 'LOGVECT (TIMES2 PrPrime 2)) |
| 81 | (TERPRI) |
| 82 | |
| 83 | (CLOSE (WRS NIL)) |
| 84 | |
| 85 | (PRIN2 "* Now the file $4 should exist") (TERPRI) |
| 86 | ) |
| 87 | (EXIT-WITH-STATUS 0) |
| 88 | %EOP |