Debian Codegraph @

domains/mkprimefile

raw
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 %%(SETQ Arguments (GETUNIXARGS))
33 %(SETQ Prime (GETV UNIXARGS* 1))
34 (PROGN
35 (SETQ Prime $1)
36 (SETQ PrPrime (SUB1 Prime))
37 (SETQ HalfPrime (QUOTIENT Prime 2))
38 %(SETQ Composit!* (GETV UNIXARGS* 2))
39 (SETQ Composit!* $2)
40 %(SETQ MPFError!* (GETV UNIXARGS* 3))
41 (SETQ MPFError!* $3)
42 % (SETQ PrimeFilePreAmble "/usr/local/matte/bergman/domains/P")
43 % (SETQ PrimeFilePreAmble $4)
44 (LOAD "$5")
45 (DSKIN "$bmdomains/PRL")
46 (SETQ PL (PENULTIMA PRIMLIST))
47 (COND ((EQ (DECIDE1 Prime) 'COMPOSITE)
48 (EXIT-WITH-STATUS Composite!*)))
49 % (SETQ OutFile (APPENDNUMBERTOSTRING Prime PrimeFilePreAmble))
50 (SETQ OutFile "$4")
51
52 % Doing the job
53
54 (SETQ FIRSTPRIMROOT (FirstPrimitiveRoot))
55 (SETQ EXPVECT (MKVECT (TIMES2 2 Prime)))
56 (SETQ LOGVECT (MKVECT (TIMES2 2 Prime)))
57 (MakeEXP!&LOGVECTs (TIMES2 2 Prime))
58
59 % For debugging:
60 % EXPVECT LOGVECT INTERPBACKTRACE
61
62 % Saving the result on OutFile
63
64 (WRS (OPEN OutFile 'OUTPUT))
65 (PRIN2 "% Preparation file for modulus calculation,
66 % with the prime modulus ")
67 (PRINT Prime)
68 (PRIN2 "% The exponents and logarithms are calculated
69 % with the base ") (PRINT FIRSTPRIMROOT)
70 (TERPRI)
71
72
73 (WRITEVECTPROG 'EXPVECT (TIMES2 PrPrime 2))
74 (TERPRI)
75 (TERPRI)
76
77 (WRITEVECTPROG 'LOGVECT (TIMES2 PrPrime 2))
78 (TERPRI)
79
80 (CLOSE (WRS NIL))
81
82 (PRIN2 "* Now the file $4 should exist") (TERPRI)
83 )
84 (EXIT-WITH-STATUS 0)
85 %EOP