1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | /* $Id$ */ |
---|
3 | |
---|
4 | ftestSetNameOfGame( feval, `" |
---|
5 | Usage: feval [<options>] [<envSpec>] [expand=<n>] <f> |
---|
6 | evaluates canonical form <f>. |
---|
7 | |
---|
8 | In contrast to the other programs of the Factory Test |
---|
9 | Environment, <f> may span more than one argument. More |
---|
10 | precisely, all arguments are textually pasted together and are |
---|
11 | then evaluated as one canonical form. If there are not any |
---|
12 | arguments (except options), neither time nor status nor result |
---|
13 | nor data information is printed. |
---|
14 | |
---|
15 | The `-a' and `-c' options are ignored by `feval'. |
---|
16 | |
---|
17 | If the optional argument `expand' is given, <f> is printed |
---|
18 | in a format dependent on <n>: |
---|
19 | <n> = 0: print <f> in standard format (default) |
---|
20 | <n> = 1: print <f> in NTL format, i.e., as a dense vector of |
---|
21 | coefficients (for univariate polynomials only) |
---|
22 | "'`' ) |
---|
23 | dnl // the trailing quotes at the end of the second argument |
---|
24 | dnl // are for font-lock only (another font-lock-trick) |
---|
25 | |
---|
26 | //{{{ docu |
---|
27 | // |
---|
28 | // ftestAlgorithm.m4 - ftestAlgorithm test program. |
---|
29 | // |
---|
30 | // To create ftestAlgorithm.cc, run m4 using the ftest_util.m4 library in |
---|
31 | // the following way: |
---|
32 | // |
---|
33 | // m4 ftest_util.m4 ftestAlgorithm.m4 > ftestAlgorithm.cc |
---|
34 | // |
---|
35 | //}}} |
---|
36 | |
---|
37 | // necessary to paste the arguments together |
---|
38 | #include <string.h> |
---|
39 | |
---|
40 | ftestPreprocInit(); |
---|
41 | |
---|
42 | ftestGlobalInit(); |
---|
43 | |
---|
44 | // |
---|
45 | // - main program. |
---|
46 | // |
---|
47 | int |
---|
48 | main ( int argc, char ** argv ) |
---|
49 | { |
---|
50 | // initialization |
---|
51 | ftestMainInit(); |
---|
52 | check = Passed; |
---|
53 | |
---|
54 | // print long usage if called with exactly one argument `-?' |
---|
55 | if ( argc == 2 && strcmp( "-?", argv[1] ) == 0 ) { |
---|
56 | ftestUsagePrint( " |
---|
57 | |
---|
58 | Options common to all test programs |
---|
59 | of the Factory Test Environment: |
---|
60 | -------------------------------- |
---|
61 | |
---|
62 | |
---|
63 | Some examples first: |
---|
64 | |
---|
65 | feval /13/xy <f> |
---|
66 | |
---|
67 | Evaluates <f> in the finite field with 13 elements and |
---|
68 | with x < y. Prints result of evaluation. |
---|
69 | |
---|
70 | feval -oa /x,y,i=x^2+1/+SW_RATIONAL <f> |
---|
71 | |
---|
72 | Evaluates <f> in the field Q[i], where the algebraic element |
---|
73 | i has the minimal polynomial x^2+1. DO NOT FORGET TO SET |
---|
74 | `SW_RATIONAL' WHEN CALCULATING WITH ALGEBRAIC ELEMENTS OF |
---|
75 | CHARACTERISTIC 0. Variable ordering is as above. |
---|
76 | Prints result and the complete environment. |
---|
77 | |
---|
78 | feval /13^2,Z/x,y,a=x^2+Z^3 <f> |
---|
79 | |
---|
80 | Evaluate <f> over the field GF(13^2)[a], where GF(13^2) is |
---|
81 | generated by a primitive element Z and a has the minimal |
---|
82 | polynomial x^2+Z^3. DO NOT FORGET TO SPECIFY THE |
---|
83 | CHARACTERISTIC BEFORE YOU SPECIFY ANY MINIMAL POLYNOMIAL. |
---|
84 | Variable ordering is as above. |
---|
85 | |
---|
86 | |
---|
87 | Now for the detailed options: |
---|
88 | |
---|
89 | <options>: |
---|
90 | -a <time>: sets maximal running time (in seconds) |
---|
91 | -c <times>: sets number of runs |
---|
92 | -o <outputOptions>: specifies what information to |
---|
93 | print |
---|
94 | |
---|
95 | An option `--' may be used to terminate parsing |
---|
96 | of the options. This is especially useful if the |
---|
97 | some of the arguments start with a negative number. |
---|
98 | |
---|
99 | <outputOptions>: |
---|
100 | a: everything |
---|
101 | c: check r: result |
---|
102 | e: computing environment t: time |
---|
103 | |
---|
104 | Without any output options, prints the result only. |
---|
105 | |
---|
106 | <envSpec>: |
---|
107 | /<charSpec><envSpec> |
---|
108 | /<varSpec><envSpec> |
---|
109 | /<switchSpec><envSpec> |
---|
110 | /<randomSpec><envSpec> |
---|
111 | |
---|
112 | Sets the computing environment, e.g., the variable |
---|
113 | ordering, the characteristic, etc. |
---|
114 | |
---|
115 | <charSpec>: |
---|
116 | <n> |
---|
117 | where <n> is either zero or a prime number |
---|
118 | <p>^<d>[,<Z>] |
---|
119 | where <p> is a prime number and <d> an integer |
---|
120 | greater or equal 2. The optional <Z> should be |
---|
121 | a single character. |
---|
122 | |
---|
123 | Sets the characteristic to <charSpec>. With <n> = 0 |
---|
124 | calculations are done in characteristic zero. With |
---|
125 | <n> being a prime number, calculations are done over |
---|
126 | the finite field with <n> elements. With <p>^<d> |
---|
127 | calculations are done over the finite Galois field |
---|
128 | with <p>^<d> elements. The optional character <Z> |
---|
129 | specifies the symbol to print for the generator of |
---|
130 | that field. |
---|
131 | |
---|
132 | <varSpec>: |
---|
133 | <varName[=<minPoly>]>[,]<varSpec> |
---|
134 | where <varName> is a single character and the |
---|
135 | optional <minPoly> is an irreducible polynomial |
---|
136 | over the current domain. The `,' between |
---|
137 | variables may be omitted if there is no |
---|
138 | minimal polynomial specified. |
---|
139 | |
---|
140 | Defines variable ordering and algebraic elements. |
---|
141 | Variables occurring later in the list get higher |
---|
142 | level. If <minPoly> is specified, the corresponding |
---|
143 | variable is defined to be an algebraic variable with |
---|
144 | minimal polynomial <minPoly>. |
---|
145 | |
---|
146 | <switchSpec>: |
---|
147 | [+|-]<switchName> |
---|
148 | where <switchName> is one of the switches |
---|
149 | specified in `cf_defs.h'. |
---|
150 | |
---|
151 | Turns switch <switchName> on resp off. The most |
---|
152 | useful switches are: |
---|
153 | SW_RATIONAL: to calculate over the rational |
---|
154 | numbers instead of the rational integers; |
---|
155 | SW_SYMMETRIC_FF: to use symmetric |
---|
156 | representation of finite fields; |
---|
157 | SW_USE_EZGCD: to use EZ-GCD to compute the |
---|
158 | gcd of multivariate polynomials over the |
---|
159 | integers. |
---|
160 | |
---|
161 | <randomSpec>: |
---|
162 | @<n> |
---|
163 | where <n> is an integer |
---|
164 | |
---|
165 | Sets random generator seed to <n>. |
---|
166 | " ); |
---|
167 | exit( 0 ); |
---|
168 | } |
---|
169 | |
---|
170 | // declare input and output variables |
---|
171 | ftestInVar( int, expand ); |
---|
172 | ftestOutVar( CanonicalForm, f ); |
---|
173 | |
---|
174 | // process argument list and set environment |
---|
175 | ftestGetOpts(); |
---|
176 | ftestGetEnv(); |
---|
177 | ftestGetInVar( expand, 0, "expand" ); |
---|
178 | |
---|
179 | if ( argv[optind] ) { |
---|
180 | int i = optind; |
---|
181 | int len = 0; |
---|
182 | |
---|
183 | // get length of arguments |
---|
184 | while ( argv[i] ) { |
---|
185 | len += strlen( argv[i] ); |
---|
186 | i++; |
---|
187 | } |
---|
188 | |
---|
189 | // paste arguments together |
---|
190 | char * argString = new char[len+1]; |
---|
191 | argString[0] = '\0'; |
---|
192 | while ( optind < i ) { |
---|
193 | strcat( argString, argv[optind] ); |
---|
194 | optind++; |
---|
195 | } |
---|
196 | |
---|
197 | ftestReadString( argString, f ); |
---|
198 | delete [] argString; |
---|
199 | ftestOutput( "f", f ); |
---|
200 | } |
---|
201 | |
---|
202 | // clean up |
---|
203 | ftestMainExit(); |
---|
204 | } |
---|