Debian Codegraph @

tests/prep/0206tests/tmpexport/cvsaninterf.sl

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % Implementation of initial the Anick resolution routines.
4 %
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 %% Copyright (C) 1996
9 %% Alexander Podoplelov (and Joergen Backelin ?)
10 %%
11 %% Bergman and Anick are distributed in the hope that they will be
12 %% useful, but WITHOUT ANY WARRANTY. No author or distributor
13 %% accepts responsibility to anyone for the consequences of using them
14 %% or for whether they serve any particular purpose or work at all,
15 %% unless (s)he says so in writing. Refer to the Bergman General
16 %% Public License for full details.
17
18 %% Everyone is granted permission to copy, modify and redistribute
19 %% bergman, but only under the conditions described in the
20 %% Bergman General Public License. A copy of this license is
21 %% supposed to have been given to you along with bergman so you
22 %% can know your rights and responsibilities. It should be in a
23 %% file named copyright. Among other things, the copyright notice
24 %% and this notice must be preserved on all copies.
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26
27
28 (OFF RAISE)
29
30 % anOutChan
31 % This variable contains the output channel handler for
32 % printing Anick related information into the result file.
33 %
34 % anDIFFTIME
35 % After the Anick resolution is calculated it contain the time
36 % consumed by calculations for differentials in milliseconds.
37 %
38 % anBETTITIME
39 % After Anick resolution is calculated it contain the time
40 % consumed by calculations for Betti numbers.
41 %
42 % anBETTINUMS
43 % This variable is a list of Betti numbers. Each Betti number
44 % is of the structure ((order:int . degree:int) . value:int)
45 %
46 % ANICKRESOLUTIONOUTPUTFILE
47 % Is equal to the name of output file. In case it equals to NIL,
48 % the output channel will be associated with the file name
49 % "andifres.txt".
50 %
51 % anLASTCALCULATEDDEGREE
52 % Equals the last degree for which the anifResolutionFixDegree
53 % procedure was called.
54 (GLOBAL '(anCHAINS anNEWCHAINS anOutChan cGBasis GBasis cDeg !*PBSERIES
55 !*CALCBETTI !*ONFLYBETTI anDIFFTIME anBETTITIME
56 anBETTINUMS ANICKRESOLUTIONOUTPUTFILE
57 anLASTCALCULATEDDEGREE
58 SObeg SOmid SOend btMacMx
59 anPrintSDPMode !*anchPrintEdgeString anchEdgeString!*
60 ModeProperties!*))
61
62 (COPYD 'anPRT2 'PRIN2)
63
64 (PUT ModeProperties!* '!*CALCBETTI (FUNCTION (LAMBDA (v a) (CALCBETTI a))))
65 (PUT ModeProperties!* '!*ONFLYBETTI (FUNCTION (LAMBDA (v a) (ONFLYBETTI a))))
66
67 % SETTENSPOLPRTSTRINGS (strings:lstr) : lstr ;
68 % The list strings should consist of 3 strings which are
69 % used to print tensor product. First string is printed
70 % at the beginning, second - as a tensor multiplication sign
71 % and the third - as the ending of thensor monomial.
72 % The list of 3 strings of old settings is returned.
73 (DF SETTENSPOLPRTSTRINGS (lstr)
74 (PROG (rt)
75 (COND ( (NOT (AND (LISTP lstr) (EQ (LENGTH lstr) 3)
76 (OR (STRINGP (CAR lstr)) (IDP (CAR lstr)))
77 (OR (STRINGP (CADR lstr)) (IDP (CADR lstr)))
78 (OR (STRINGP (CADDR lstr)) (IDP (CADDR lstr)))))
79 (ERROR 2000 "Bad argument to SETTENSPOLPRTSTRING")
80 )
81 )
82 (SETQ rt (GETTENSPOLPRTSTRINGS))
83 (SETQ SObeg (CAR lstr))
84 (SETQ SOmid (CADR lstr))
85 (SETQ SOend (CADDR lstr))
86 (RETURN rt)
87 )
88 )
89
90 % GETTENSPOLPRTSTRINGS () : lstr ;
91 % Returns a list of 3 strings which are used when tensor
92 % monomials are printed as beginning, middle and ending
93 % strings.
94 (DE GETTENSPOLPRTSTRINGS () (LIST SObeg SOmid SOend) )
95
96
97 % This procedure is called from "Bergman" application once.
98 % Purpose : initialization for the Anick resolution moduls.
99 % ResolutionInit () : - ;
100 % This procedure initializes all the variables concerned with
101 % the Anick resolution. It needs information about Groebner
102 % basis generators, therefore, it should be called after the
103 % system has them.
104 (DE ResolutionInit ()
105 (PROGN
106 (PRIN2 "The Anick resolution initialization...")
107 (TERPRI)
108
109 (COND ((NOT ANICKRESOLUTIONOUTPUTFILE)
110 (SETQ ANICKRESOLUTIONOUTPUTFILE "andifres.txt")))
111 (SETQ anOutChan (OPEN ANICKRESOLUTIONOUTPUTFILE 'OUTPUT))
112 % (ON PRINTEDGESTRING)
113 % (SETEDGESTRING "*")
114 (anCONSTRUCTZEROCHAINS)
115 (SETQ anLASTCALCULATEDDEGREE 1)
116 (SETQ anDIFFTIME 0)
117 (SETQ anBETTITIME 0)
118 (SETQ SObeg "")
119 (SETQ SOmid ".")
120 (SETQ SOend "")
121 (anBETTIINIT)
122 (COND ( (AND !*CALCBETTI !*ONFLYBETTI)
123 (SETQ anBETTITIME (TIME))
124 (anBETTI (CAR anCHAINS))
125 (SETQ anBETTITIME (DIFFERENCE (TIME) anBETTITIME))
126 (PRINTBETTI)
127 ))
128 (PRIN2 "The Anick resolution initialization done.")
129 (TERPRI)
130 )
131 )
132
133 % CALCBETTI (flag:bool) : - ;
134 % Depending on whether flag is non-NIL or not, switches on/off
135 % the calculation of Betti numbers. It sets corresponding flags.
136 % flag is a boolean T or NIL
137 (DE CALCBETTI (flag)
138 (PROGN
139 (COND ( (NULL flag)
140 (OFF CALCBETTI)
141 (OFF ONFLYBETTI)
142 )
143 (T
144 (ON CALCBETTI)
145 )
146 )%COND
147 )
148 )
149
150 % ONFLYBETTI (flag:bool) : - ;
151 % Depending on whether flag is non-NIL or not, switches on/off
152 % the calculation of Betti numbers. Also, the feature of
153 % calculating and printing them while Groebner basis is being
154 % calculated degree by degree. It sets corresponding flags.
155 (DE ONFLYBETTI (flag)
156 (PROGN
157 (COND ( (NULL flag)
158 (OFF ONFLYBETTI)
159 )
160 (T
161 (ON CALCBETTI)
162 (ON ONFLYBETTI)
163 )
164 )%COND
165 )
166 )
167
168
169 % GETBETTINUMS () : lbtnum;
170 % Returns the list of Betti numbers.
171 (DE GETBETTINUMS () (COPY anBETTINUMS))
172
173
174 % GETBTORDER (btnumber:btnum) : int ;
175 % Returns the order of Betti number btnumber.
176 (DE GETBTORDER (btnum) (CAAR btnum))
177
178 % GETBTDEGREE (btnumber:btnum) : int ;
179 % Returns the degree of Betti number btnumber.
180 (DE GETBTDEGREE (btnum) (CDAR btnum))
181
182 % GETBTVALUE (btnumber:btnum) : int ;
183 % Returns the value of Betti number btnumber.
184 (DE GETBTVALUE (btnum) (CDR btnum))
185
186
187 % anifResolutionFixDegree (dgr:int) : - ;
188 % For a given degree it calculates chains and the Anick
189 % resolution differentials, and prints them into the result
190 % file. It also updates related variables.
191 (DE anifResolutionFixDegree (dgr)
192 (PROG (chp dd t1)
193 (PRIN2 "Calculating the Anick resolution in degree ")
194 (PRIN2 dgr)
195 (PRIN2 "...")
196 (TERPRI)
197
198 (UNSIGNLC!'S cGBasis)
199 (SETQ anNEWCHAINS
200 (COND ((EQN dgr cDeg)
201 (CONS cDeg (MAPCAR (CDR cGBasis)
202 (FUNCTION anNEWGBELM2CHAIN)))
203 )
204 (T
205 (NCONS dgr)
206 )
207 )%COND
208 )
209
210 (SETQ chp (CDR anCHAINS))
211 L1 (COND
212 ( chp
213 (SETQ dd (DIFFERENCE dgr (CAAR chp)))
214 (MAPC (CDAR chp) (FUNCTION (LAMBDA (u) (anCONSTRUCTNEWCHAINS u dd ))))
215 (SETQ chp (CDR chp))
216 (GO L1)
217 )
218 )%COND
219
220 (SETQ t1 (TIME))
221 (MAPC (CDR anNEWCHAINS) (FUNCTION anDIFF))
222 (SETQ anDIFFTIME (PLUS2 anDIFFTIME (DIFFERENCE (TIME) t1)))
223 % (PRINTNEWCHAINSDIFF anOutChan)
224 % (FlushChannel anOutChan)
225 (COND ( (CDR anNEWCHAINS)
226 (NCONC anCHAINS (NCONS anNEWCHAINS))))
227
228 %%%%%%%% Betti numbers calculation should be called from this point %%%%%%%
229 (COND ( (AND !*CALCBETTI !*ONFLYBETTI)
230 (SETQ t1 (TIME))
231 (anBETTI anNEWCHAINS)
232 (SETQ anBETTITIME (PLUS2 anBETTITIME (DIFFERENCE (TIME) t1)))
233 (PRINTBETTI)
234 (MACBETTIPRINT)
235 ))
236
237 (PRIN2 "end of Calculations.")
238 (TERPRI)
239 )
240 )
241
242 % PRINTNEWCHAINSDIFF (chan:genint) : - ;
243 % Prints differentials for the new generated chains
244 % to the channel chan
245 (DE PRINTNEWCHAINSDIFF (chan)
246 (PROG (OldChan oldLL)
247 (SETQ OldChan (WRS chan))
248 (SETQ oldLL (LINELENGTH 1024))
249 (MAPC (CDR anNEWCHAINS)
250 (FUNCTION (LAMBDA (u)
251 (MAPC (CDR u)
252 (FUNCTION PRTCHNDIFF)))
253 )
254 )
255 (WRS OldChan)
256 (LINELENGTH oldLL)
257 )
258 )
259
260 % PRINTCHAINSDIFF (chan:genint) : - ;
261 % Prints differentials for the all generated chains
262 % to the channel chan
263 (DE PRINTCHAINSDIFF (chan)
264 (PROG (OldChan oldLL)
265 (SETQ OldChan (WRS chan))
266 (SETQ oldLL (LINELENGTH 1024))
267 (MAPC anCHAINS
268 (FUNCTION (LAMBDA (u)
269 (MAPC (CDR u)
270 (FUNCTION PRTCHNDIFF)))
271 )
272 )
273 (WRS OldChan)
274 (LINELENGTH oldLL)
275 )
276 )
277
278
279 % PRTCHNDIFF (inchain:chn) : - ;
280 % Prints differential for the chain inchain in form
281 % D (chain length, chain) = differential
282 (DE PRTCHNDIFF (chn)
283 (PROG (diff)
284 (PRIN2 "D(")
285 (PRIN2 (anChn2Length chn))
286 (PRIN2 ", ")
287 (PRINTCHAIN chn)
288 (PRIN2 ")=")
289 (COND ( (NULL (SETQ diff (anChn2Diff chn))) (PRIN2 "Nil"))
290 (T (PRETTYPRINTSDP diff))
291 )
292 (TERPRI)
293 )
294 )
295
296
297
298
299 % ResolutionFixcDegEnd () : - ;
300 % Applies the procedure anifResolutionFixDegree for
301 % all the degrees which has to be fixed in anifResolutionFixDegree
302 % sense.
303 (DE ResolutionFixcDegEnd ()
304 (PROG ()
305 Ml (COND ((LESSP anLASTCALCULATEDDEGREE cDeg)
306 (SETQ anLASTCALCULATEDDEGREE (ADD1 anLASTCALCULATEDDEGREE))
307 (anifResolutionFixDegree anLASTCALCULATEDDEGREE)
308 (GO Ml)
309 )
310 )
311 )
312 )
313
314 % ResolutionDone () : - ;
315 % Closes the output stream used in Anick related procedures.
316 %%% Wind up procedure, closes all the streams
317 (DE ResolutionDone()
318 (PROG (OldChan)
319 (COND ( (NOT (NULL anOutChan))
320 (PRIN2 "Closing the streams.")
321 (CLOSE anOutChan)
322 (SETQ anOutChan NIL)
323 )
324 )
325 )
326 )
327
328
329 % ResolutionClear () : - ;
330 % Cleans up all the Anick related variables including Betti
331 % numbers.
332 (DE ResolutionClear ()
333 (PROGN (PRIN2 "Cleaning the varibles") (TERPRI)
334 (SETQ anLASTCALCULATEDDEGREE NIL)
335 (SETQ anCHAINS NIL)
336 (SETQ anNEWCHAINS NIL)
337 (SETQ anBETTINUMS (NCONS NIL))
338 (SETQ btMacMx NIL)
339 (SETQ anDIFFTIME 0)
340 (SETQ anBETTITIME 0)
341 )
342 )
343
344 % CLEARRESOLUTION () : - ;
345 % Calls ResolutionDone and ResolutionClear procedures.
346 (DE CLEARRESOLUTION ()
347 (PROGN
348 (ResolutionDone)
349 (ResolutionClear)
350 )
351 )
352
353
354 % ANICKDISPLAY () : - ;
355 % Prints the Betti numbers into the result file.
356 (DE ANICKDISPLAY ()
357 (PROG (OldChan oldLL)
358 (COND ( (BETTICALC)
359 (PRIN2 "Printing the results ...")
360 (TERPRI)
361 (SETQ OldChan (WRS anOutChan))
362 (SETQ oldLL (LINELENGTH 1024))
363 (MAPC anCHAINS
364 (FUNCTION (LAMBDA (u)
365 (MAPC (CDR u)
366 (FUNCTION PRTCHNDIFF)))
367 )
368 )
369 (PRINTBETTI)
370 (MACBETTIPRINT)
371 (WRS OldChan)
372 (PRIN2 "Printing is done.")
373 (TERPRI)
374 (LINELENGTH oldLL)
375 )
376 )
377 )
378 )
379
380 % BETTICALC () : bool ;
381 % Returns true if the system is configured to calculate Betti numbers.
382 (DE BETTICALC ()
383 (COND ( (AND !*CALCBETTI (NOT !*ONFLYBETTI))
384 (anALLBETTI) T)
385 ( T
386 !*CALCBETTI)
387 )
388 )
389
390 % CALCULATEANICKRESOLUTIONTOLIMIT (limdeg:int) : - ;
391 % Countinues the process of Anick resolution calculation up to
392 % the degree limdeg. It maybe called after the Groebner basis is
393 % calculated, in case it is finite and calculations stopped
394 % at a lower degree than thatonto which the Anick resolution
395 % should be calculated.
396 (DE CALCULATEANICKRESOLUTIONTOLIMIT (limdeg)
397 (PROG ()
398 (COND ((OR (NOT GBasis) (NOT !*PBSERIES))
399 (ERROR 1001 "You cannot call CALCULATEANICKRESOLUTIONTOLIMIT now")
400 )
401 ((NOT anLASTCALCULATEDDEGREE)
402 (ResolutionInit)
403 )
404 )
405 Ml (COND ((LESSP anLASTCALCULATEDDEGREE limdeg)
406 (SETQ anLASTCALCULATEDDEGREE (ADD1 anLASTCALCULATEDDEGREE))
407 (anifResolutionFixDegree anLASTCALCULATEDDEGREE)
408 (GO Ml)
409 )
410 )
411 )
412 )
413
414
415 % Mode settings.
416
417 % ExtractAnickModes () : lmodestate ;
418 % Returns the list of modestates.
419 (DE ExtractAnickModes ()
420 (MAPCAN '(anExtractTPModes anExtractChnModes anExtractBettiModes)
421 (FUNCTION (LAMBDA (u) (APPLY u NIL)))))
422
423 % RestoreAnickModes (modeinfo:lmodestate) : - ;
424 % Restores modestates supplied by modeinfo.
425 (DE RestoreAnickModes (modeinfo)
426 (PROG (modes dp fn)
427 (SETQ modes '( (TENSPOL!-PRINTMODE . anPrintSDPMode)
428 (TENSTERM!-PRINTMODE . TENSTERM!-PRINTMODE)
429 (EDGE!-STRING . (GETEDGESTRING))
430 (EDGE!-STRING!-PRINTING . (GETEDGESTRINGPRINTING))
431 (BETTI . !*CALCBETTI)
432 (BETTI-FOREACHDEGREE . !*ONFLYBETTI)
433 )
434 )
435 % (CheckModes (modeinfo))
436 L1 (COND ( (NULL modeinfo) (RETURN NIL) )
437 ( T
438 (SETQ dp (ASSOC (CAAR modeinfo) modes))
439 (COND ( (NULL dp)
440 (PRIN2 "Variable name ")
441 (PRIN2 (CAAR modeinfo))
442 (PRIN2 " is not valid, skipping it.")
443 (TERPRI)
444 )
445 (T
446 (SETQ fn (GET ModeProperties!* (CDR dp)))
447 (COND ( (NULL fn)
448 % Direct assignment
449 (SET (CDR dp) (CADAR modeinfo))
450 )
451 (T
452 % Invoking property function
453 (APPLY fn (LIST (CDR dp) (CADAR modeinfo)))
454 )
455 )%COND
456
457 )
458 )%COND
459 )
460 )%COND
461 (SETQ modeinfo (CDR modeinfo))
462 (GO L1)
463 )
464 )
465
466 (ON RAISE)
467