-
Notifications
You must be signed in to change notification settings - Fork 0
/
grgproc.sl
890 lines (765 loc) · 27 KB
/
grgproc.sl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
%==========================================================================%
% GRGproc.sl Forms and Vectors Processor %
%==========================================================================%
% GRG 3.2 Standard Lisp Source Code (C) 1988-96 Vadim V. Zhytnikov %
%==========================================================================%
% This file is distributed without any warranty. You may modify it but you %
% are not allowed to remove author's name and/or distribute modified file. %
%==========================================================================%
%---- Main algebraic simplification functionS -----------------------------
(de eval!> (w)
(cond (!*aeval (reval (aeval w)) )
(t (reval w) ) ))
(de raeval!> (w) (reval (aeval w)))
%---------- Algebraic Simplification --------------------------------------
% Algebraic simplification with NIL return ...
(de evalalg!> (w)
(cond ((or (null w) (eqn w 0)) nil)
(t (zn!>(eval!> w)))))
% Alg or Alg Equation simplification ...
(de evalalgx!> (w)
(cond ((and (pairp w) (eq (car w) 'equal))
(equationa!> (cadr w) (caddr w)))
(t (evalalg!> w))))
%---------- Form Simplification -------------------------------------------
% Form simplification ...
(de evalform!> (lst)
(cond ((null lst) nil)
(t (proc (wa wb wc)
(while!> lst
(setq wa (eval!> (caar lst)))
(cond ((not(or (eqn wa 0) (null wa)))
(setq wc (cons (cons wa (cdar lst)) wc)) ))
(setq lst (cdr lst)))
(return (reversip wc))))))
% Alg or Alg Equation simplification ...
(de evalformx!> (w)
(cond ((and (pairp w) (eq (car w) 'equal))
(equationf!> (cadr w) (caddr w)))
(t (evalform!> w))))
% Form simplification with AEVAL ...
(de aevalform!> (lst)
(cond((null lst)nil)
(t(proc(wa wb wc)
(while!> lst
(setq wa(aeval(caar lst)))
(cond((not(or(eqn wa 0)(null wa)))
(setq wc(cons(cons wa(cdar lst))wc)) ))
(setq lst(cdr lst)))
(return(reversip wc))))))
%---------- 0 <-> nil -----------------------------------------------------
(de nz!> (w) (cond (w w) (t 0))) % alg -> alg0
(de zn!> (w) (cond ((eqn w 0) nil)(t w))) % alg0 -> alg
%-------- Multiplication ------------------------------------------------
% Times W * Alg ...
(de multa!> (w wa)
(cond ((or (null w) (null wa)) nil)
((eqn w 1) wa )
(t (list 'times w wa))))
% Times W * Alg or Alg Equation ...
(de multax!> (w wa)
(cond ((and (pairp wa) (eq (car wa) 'equal))
(equation!> (multa!> w (cadr wa)) (multa!> w (caddr wa))))
(t (multa!> w wa))))
% Times W * Form ...
(de multf!> (w wa)
(cond ((or (null w) (null wa)) nil)
((eqn w 1) wa )
(t (fndfpr!> w wa))))
% Times W * Form or Form Equation ...
(de multfx!> (w wa)
(cond ((and (pairp wa) (eq (car wa) 'equal))
(equation!> (multf!> w (cadr wa)) (multf!> w (caddr wa))))
(t (multf!> w wa))))
%-------- Summatuon --------------------------------------------------------
% Sum list of Alg ...
(de summa!> (w)
(cond ((null w) nil)
(t (evalalg!> (cons 'plus w)))))
% Sum list of Alg or Alg Equations ...
(de summax!> (w)
(cond ((not(equationp!> w)) (summa!> w))
(t (equation!> (summa!> (mapcar w 'eqleft!>))
(summa!> (mapcar w 'eqright!>))))))
% Sum list of Forms ...
(de summf!> (w)
(cond ((null w) nil)
(t (evalform!> (dfsum!> w)))))
% Sum list of Forms or Forms Equations ...
(de summfx!> (w)
(cond ((not(equationp!> w)) (summf!> w))
(t (equation!> (summf!> (mapcar w 'eqleft!>))
(summf!> (mapcar w 'eqright!>))))))
(de eqleft!> (w) (cond ((pairp w) (cadr w)) (t nil)))
(de eqright!> (w) (cond ((pairp w) (caddr w)) (t nil)))
(de equationp!> (w)
(cond ((null w) nil)
((null(car w)) (equationp!>(cdr w)))
((pairp(car w)) (eq (caar w) 'equal))
(t nil)))
% Summation ...
(de algsum!> (w)
(progn
(setq w (algsum1!> w))
(cond ((null w) w)
((null(cdr w)) (car w))
(t (cons 'plus w)))))
(de algsum1!> (w)
(cond ((null w) nil)
((null(car w)) (algsum1!>(cdr w)))
(t (cons (car w) (algsum1!>(cdr w))))))
%-------- Equations building functions -------------------------------------
(de equation!> (wl wr) % makes (equal wl wr) or nil if both null ...
(cond ((and (null wl) (null wr)) nil)
(t (list 'equal wl wr))))
(de equationf!> (w1 w2) % form=form with eval ...
(cond((and(null(setq w1(evalform!> w1)))
(null(setq w2(evalform!> w2)))) nil)
(t(list3 'equal w1 w2))))
(de equationf1!> (w1 w2) % form=form -> form-form=0 with eval ...
(cond((null(setq w1
(evalform!>(dfsum!>(list w1 (chsign!> t w2))))))
nil)
(t(list3 'equal w1 nil))))
(de equationa!> (w1 w2) % alg=alg with eval ...
(cond((and(or(null(setq w1(eval!> w1)))(eqn w1 0))
(or(null(setq w2(eval!> w2)))(eqn w2 0)) ) nil)
(t(list3 'equal (zn!> w1) (zn!> w2)))))
(de equationa1!> (w1 w2) % alg=alg -> alg-alg=0 with eval ...
(cond((or(null(setq w1(eval!>(list3 'difference w1 w2))))(eqn w1 0))
nil)
(t(list3 'equal (zn!> w1) nil))))
%------ Forms <-> Reduce matrix conversion support -------------------------
% (LIST of 1-forms) -> Reduce matrix ... 05.96
(de mkmtetr!> (lst)
(cons 'mat
(foreach!> a in (dimlist!> 0) collect
(foreach!> b in (dimlist!> 0) collect
(getfdx!> (getel1!> lst a) b)))))
% Reduce matrix -> tetrad (LIST of 1-forms) ... 05.96
(de mktetrm!> (w ww)
(prog(wa wb wc) (setq wa 0)
(foreach!> x in w do (progn
(setq wa(add1 wa))
(setq wc nil) (setq wb -1)
(foreach!> y in x do (progn (setq wb(add1 wb))
(setq wc(dfsum!>(list2 wc(fndfpr!>(zn!>(eval!> y))(mkdx!> wb)))))))
(putel1!> (evalform!> wc) ww (sub1 wa))))
(return t)))
%----- Matrix Reduce <-> GRG conversion support ----------------------------
(de mat!> (lst) % 05.96 GRG -> Reduce
(cons 'mat
(foreach!> i in (dimlist!> 0) collect
(foreach!> j in (dimlist!> 0) collect
(getel!> lst (list2 i j))))))
(de mats!> (lst) % 05.96 GRG -> Reduce
(cons 'mat
(foreach!> i in (dimlist!> 0) collect
(foreach!> j in (dimlist!> 0) collect
(getel2s!> lst i j)))))
(de matsf!> (fun) % 05.96 GRG -> Reduce
(cons 'mat
(foreach!> i in (dimlist!> 0) collect
(foreach!> j in (dimlist!> 0) collect
(eval (list fun i j))))))
(de rmat!> (lst wm) % 05.96 Reduce -> GRG
(prog (w)
(fordim!> i do (progn
(setq wm (cdr wm))
(setq w (car wm))
(fordim!> j do (progn
(putel!> (zn!>(eval!>(car w))) lst (list2 i j))
(setq w (cdr w))))))))
(de rmats!> (lst wm) % 05.96 Reduce -> GRG
(prog (w)
(fordim!> i do (progn
(setq wm (cdr wm))
(setq w (car wm))
(fordim!> j do (progn
(cond((leq i j)
(putel!> (zn!>(eval!>(car w))) lst (list2 i j))))
(setq w (cdr w))))))))
%---------- Sign Changing --------------------------------------------------
(de chsignf!> (w) (chsign!> t w)) % form
(de chsigna!> (w) (chsign!> nil w)) % alg expression
% Sign changing ... BOOL=T - Form, BOOL=NIL - Alg
(de chsign!> (bool lst)
(cond((null lst) nil)
(bool(mapcar lst 'chsign1!>))
(t(chsign2!> lst))))
(de chsignx!> (wt w)
(cond ((and (pairp w) (eq (car w) 'equal))
(equation!> (chsign!> wt (cadr w)) (chsign!> wt (caddr w))))
(t (chsign!> wt w))))
(de chsign1!> (w)
(cond((and(pairp(car w))(eq(caar w) 'minus))
(cons (cadar w) (cdr w)))
((numberp(car w))
(cons (minus(car w)) (cdr w)))
(t(cons (list2 'minus(car w)) (cdr w)))))
(de chsign2!> (w)
(cond((and(pairp w)(eq(car w) 'minus)) (cadr w))
((numberp w) (minus w))
(t (list2 'minus w))))
%---------- Exterior Forms Processor. 10.01.91 ---------------------------
% Exterior forms summation ...
(de dfsum!> (lst)
(cond
((null lst)nil)
((null(cdr lst))(car lst))
(t(proc (w ww wt wn wr wx)
(setq w (flcopy!> lst))
(setq ww w)
(loop!>
(setq wn nil)
(setq w ww)
(while!> w
(cond((car w)
(cond((null wn) (setq wn (cadaar w)))
((lessp(cadaar w)wn) (setq wn (cadaar w))))))
(setq w (cdr w)))
(exitif(null wn))
(setq w ww)
(setq wt nil)
(while!> w
(cond((car w)
(cond((eqn wn (cadaar w))
(progn
(setq wx (cdaar w))
(setq wt (cons (caaar w) wt))
(rplaca w (cdar w)) )))))
(setq w (cdr w)))
(cond((cdr wt)(setq wt (cons (cons 'plus wt) wx)))
(t (setq wt (cons (car wt) wx))))
(setq wr (cons wt wr)) )
(return(reversip wr)) ))))
(de flcopy!> (w)
(cond((null w) nil)
(t(cons (car w) (flcopy!> (cdr w))))))
% alg * form or vector multiplication ...
(de fndfpr!> (alg form)
(cond((or(null form)(zerop alg)(null alg))nil)
((eqn alg 1) form)
((eqn alg -1) (chsign!> t form))
(t(proc(wa)
(while!> form
(setq wa
(cons (cons (list 'times alg (caar form)) (cdar form))
wa))
(setq form(cdr form)))
(return(reversip wa))))))
% Exterior product ...
(de dfprod!> (lst)
(cond ((memq nil lst) nil)
((null(cdr lst)) (car lst))
(t (dfprod2!> (car lst) (dfprod!>(cdr lst))))))
% Exterior product form1/\form2 ...
(de dfprod2!> (frm1 frm2)
(cond((null(and frm1 frm2))nil)
(t(proc (x y wa wb wc w res sgn)
(setq w t)
(while!> frm1
(setq wa frm2)
(while!> frm2
(setq sgn t)
(setq x(cddar frm1))
(setq y(cddar frm2))
(while!> (and x y (null(and(caar x)(caar y)))
(prog2 (and (null(cdr y)) (setq w(not(cdar y))))
t))
(setq wb(cons(cons(or(caar x)(caar y))
(eq(cdar x)(cdar y)))
wb))
(cond((and(caar x)(not(cdar y)))
(setq sgn(not sgn)) ))
(setq x(cdr x))
(setq y(cdr y)) )
(tohead (and x y (caar x) (caar y)
(progn (setq wb nil) (setq frm2(cdr frm2)) t)))
(while!> x
(setq wb(cons(cons(caar x)
(cond((caar wb)(not(cdar wb)))
(t(cdar wb))))
wb))
(cond((and(caar wb)(null w))
(setq sgn(not sgn))))
(setq x(cdr x)))
(while!> y
(setq wb(cons(cons(caar y)
(cond((caar wb)(not(cdar wb)))
(t(cdar wb))))
wb))
(setq y(cdr y)))
(setq x(list3(quote times)(caar frm1)(caar frm2)))
(cond((null sgn)(setq x(list2(quote minus)x))))
(setq y(cons x(cons
(plus(cadar frm1)(cadar frm2))
(reversip wb))))
(setq wc(cons y wc))
(setq wb nil)
(setq frm2(cdr frm2)))
(setq frm1(cdr frm1))
(setq frm2 wa)
(cond(wc(prog2(setq res(cons(reversip wc)res))
(setq wc nil)))) )
(return(dfsum!> res)) )) ))
(de dfsum2!> (wa wb) (dfsum!> (list2 wa wb)))
% Exterior differential d form ...
(de dex!> (frm) (dex1!> frm ![umod!]))
(de dex1!> (frm wm)
(cond ((null frm) nil) (t
(prog(w)
(foreach!> x in frm do (prog2
(setq w (cons (dfprod2!> (dfun1!> (car x) wm)
(ncons (cons 1 (cdr x))) )
w))
(cond (wm (setq w (cons (fndfpr!> (car x) (dexxb!>(cdr x)))
w))))
))
(return (dfsum!> w))))))
(de dexxb!> (w) % with d(b/\...) accumulation
(proc (wc wr ww)
(setq ww (car w))
(cond ((setq wc (assoc (car w) ![dbas!])) (return(cdr wc)))
(t (setq w (cdr w))))
(setq wc -1)
(while!> w
(setq wc (add1 wc))
(cond ((caar w) (setq wr (cons (getel1!> !#!b wc) wr))))
(setq w (cdr w)))
(setq wr (evalform!>(nbform!>(dex1!>(dfprod!>(reversip wr))nil))))
(setq ![dbas!] (cons (cons ww wr) ![dbas!]))
(return wr)))
%(de dexxb!> (w) % without d(b/\...) accumulation
% (proc (wc wr)
% (setq w (cdr w))
% (setq wc -1)
% (while!> w
% (setq wc (add1 wc))
% (cond((caar w)(setq wr(cons(getel1!> !#!b wc)wr))))
% (setq w (cdr w)))
% (return(nbform!>(dex1!>(dfprod!>(reversip wr))nil)))))
% Exterior differential d Alg ...
(de dfun!> (lst) (dfun1!> lst ![umod!]))
(de dfun1!> (lst wm)
(cond((null lst) nil) (t
(proc (wb wc wd)
(foreach!> x in ![cord!] do (prog2
(setq wd (mkdf!> lst x wm))
(cond (wd
(setq wb
(cons (cons wd (cdar (mkdx!> (get x '!=cord))))
wb))))))
(return(reversip wb)))) ))
(de mkdf!> (lst id wm)
(evalalg!> (cond (wm (bfun!> (getel1!> !#!e (get id '!=cord)) lst))
(t (list3 'df lst id)))))
(de bfun!> (wb lst)
(cond((null lst) nil)
(t(proc (w wn wc)
(while!> wb
(setq wn (cadar wb))
(setq wc -1)
(while!> (not(eqn wn 1))
(setq wn (quotient wn 2))
(setq wc (add1 wc)) )
(setq w(cons(list 'times (caar wb)
(list 'df lst (getel1!> ![cord!] wc)))
w))
(setq wb(cdr wb)))
(return(cond((null w) nil)
((null(cdr w)) (car w))
(t(cons 'plus w))))))))
%---------- Vectors processor. 08.01.91 ---------------------------------
% Vec _| 1-form ...
(de vform1!> (wv wf)
(cond((or (null wv)(null wf)) nil)
(t(proc (w wa)
(setq wa wf)
(while!> wv
(setq wf wa)(setq wa nil)
(while!> wf
(cond((eqn(cadar wf)(cadar wv))
(setq w(cons(list 'times(caar wf)(caar wv))w)))
(t(setq wa(cons(car wf)wa))))
(setq wf(cdr wf)))
(setq wv(cdr wv)))
(return(cond((null w) nil)
((null(cdr w)) (car w))
(t(cons 'plus w))))))))
% Vec | Alg ...
(de vfun!> (wv wf)
(cond ((or (null wv) (null wf)) nil)
(t (vfun1!> wv wf ![umod!]))))
%(de vfun0!> (wv wf)
% (cond((or(null wv)(null wf)) nil)
% (t(vfun1!> wv wf nil))))
(de vfun1!> (wv wf wm)
(proc (wb wa x cord)
(setq cord ![cord!])
(while!> (and cord wv)
(setq x (car cord))
(setq cord (cdr cord))
(cond
((eqn (expt 2 (add1(get x '!=cord))) (cadar wv))
(progn
(setq wa (mkdf!> wf x wm))
(cond(wa
(setq wb
(cons (list 'times (caar wv) wa)
wb))))
(setq wv (cdr wv)) ))))
(return (cond ((null wb) nil)
((null (cdr wb)) (car wb))
(t (cons 'plus wb))) )))
% Vecr _| n-form for n>1 ...
(de vform!> (wv wf)
(cond((or(null wv)(null wf)) nil)
(t(proc(w wl wa wb wc wss)
(while!> wv
(setq wl wf)
(while!> wl
(setq wa(cddar wv))
(setq wb(cddar wl))
(setq wc nil)
(while!> (and wa wb)
(exitif (and(caar wa)(caar wb)))
(setq wc(cons(car wb)wc))
(setq wa(cdr wa))
(setq wb(cdr wb)))
(cond((and wa wb) (progn
(setq wss(cdar wb))
(setq wc(cons(cons nil(cdar wb))wc))
(setq wb(cdr wb))
(while!> wb
(setq wc(cons(cons(caar wb)(not(cdar wb)))wc))
(setq wb(cdr wb)))
(setq w (cons(ncons(append(list
(list 'times(caar wv)
(cond(wss(caar wl))
(t(list 'minus(caar wl)))))
(difference(cadar wl)(cadar wv)) )
(rever!> wc))) w)) )))
(setq wl(cdr wl)))
(setq wv(cdr wv)))
(return(cond(w(dfsum!> w))
(t nil)))))))
(de rever!>(wc)
(proc(w wss)
(while!> wc
(cond((and(null wss)(null(caar wc))) nil)
(t(prog2(setq wss t)(setq w(cons(car wc)w)))))
(setq wc(cdr wc)))
(return w)))
% [ vec1 , vec2 ] ...
(de vbrack!> (w1 w2)
(cond((and w1 w2)
(dfsum!> (list2 (vcvc!> w1 w2 ![umod!])
(chsign!> t (vcvc!> w2 w1 ![umod!])))))
(t nil)))
(de vcvc!> (w1 w2 wm)
(proc (w wc ww wa)
(while!> w2
(setq wc (vfun1!> w1 (caar w2) wm))
(cond (wc (setq w (cons (cons wc (cdar w2)) w))))
(cond (wm
(cond ((setq wa (vcb!> w1 (sub1(log2!>(cadar w2)))))
(setq ww (cons (fndfpr!> (caar w2) wa) ww))))))
(setq w2 (cdr w2)))
(return (cond ((and wm ww) (dfsum!> (cons (reversip w) ww)))
(t (reversip w))))))
(de vcb!> (w1 we)
(cond ((null w1) nil)
(t(proc (wa w)
(setq we (getel1!> !#!e we))
(while!> w1
(setq wa (vcvc!> (getel1!> !#!e (sub1(log2!>(cadar w1))))
we nil))
(cond (wa
(setq w (cons (fndfpr!> (caar w1) (nbvec!> wa)) w))))
(setq w1 (cdr w1)))
(return (cond (w (dfsum!> w))
(t nil)))))))
%---------- Complex conjugation. 25.12.90 --------------------------------
(de coexpr!> (wt w) % wt - type, 0 alg, n form, -1 vector
(cond ((eqn wt 0) (coalg!> w))
((eqn wt -1) (covec!> w))
(t (coform!> w))))
(de coexprx!> (wt w)
(cond ((and (pairp w) (eq (car w) 'equal))
(equation!> (coexpr!> wt (cadr w))
(coexpr!> wt (caddr w))))
(t (coexpr!> wt w))))
% Conjugation of Alg ...
(de coalg!> (w)
(cond ((atom w)
(cond ((or (eq w '!*sq) (eq w 'taylor!*))
(err!> 9999)) % *sq form !!!
((eq w 'i) '(minus i)) % i -> -i
((get w '!=conj) (get w '!=conj)) % x~ -> x, x -> x~
(t w))) % y -> y
(t (mapcar w 'coalg!>))))
% Conjugation of Form ...
(de coform!> (wf) (cofv!> wf ![ccb!]))
% Conjugation of Vector ...
(de covec!> (wf) (cofv!> wf ![ccbi!]))
(de cofv!> (wf wb)
(cond ((null wf) nil)
(t(proc (w wa wp wx wn)
(while!> wf
(setq wa (coalg!>(caar wf)))
(setq wx (cddar wf)) % wx = d x/\d y ...
(setq wp nil)
(setq wn -1)
(while!> wx
(setq wn (add1 wn))
(cond((caar wx)
(setq wp (cons
(cond (![umod!] (getel1!> wb wn))
(t (mkdx!>
(get (coalg!>(getel1!> ![cord!] wn)) '!=cord))))
wp))))
(setq wx (cdr wx)))
(setq wp (dfprod!>(reversip wp))) % wp = (d x/\d y ...)~
(setq w (cons (fndfpr!> wa wp) w))
(setq wf (cdr wf)))
(return(evalform!>(dfsum!> w)))))))
%---------- Vector Product 09.96 -------------------------------------------
% vec.vec Need !#G !#T
(de vprod!> (wa wb)
(prog (w wx wy)
(fordim!> m do (progn
(setq wx (vform1!> wa (getframe!> m)))
(setq wy (vform1!> wb (getlo!> !#!T m)))
(cond ((and wx wy) (setq w (cons (list 'times wx wy) w))))))
(return (cond (w (cons 'plus w)) (t nil)))))
% frm1.frm1 Need !#D !#GI
(de fprod!> (wa wb)
(prog (w wx wy)
(fordim!> m do (progn
(setq wx (vform1!> (getiframe!> m) wa))
(setq wy (vform1!> (getup!> !#!D m) wb))
(cond ((and wx wy) (setq w (cons (list 'times wx wy) w))))))
(return (cond (w (cons 'plus w)) (t nil)))))
%---------- Dualisation 05.96 ----------------------------------------------
% Dualisation #(alg) -> dim-form ...
% Use: !#VOL
(de dual0!> (w)
(cond ((null w) nil)
(t (fndfpr!> w (car !#!V!O!L)))))
% Dualisation #(dim-form) -> alg ...
% Use: !#VOL
(de duald!> (w)
(cond ((null w) nil)
(t (list 'times (invsvol!>) (caar w)))))
% version for spinorial regime only = - i #
(de dualdi!> (w)
(cond ((null w) nil)
(t (list 'times (invsvoli!>) (caar w)))))
(de invsvol!> nil
(cond ((null(car !#!V!O!L)) 0)
(t (list 'quotient ![sigprod!] (caaar !#!V!O!L)))))
(de invsvoli!> nil
(cond ((null(car !#!V!O!L)) 0)
(t (list 'quotient 'i (caaar !#!V!O!L)))))
% Defines P of the P-form ...
(de pformq!> (w)
(proc (wp)
(cond ((null w) (return 0)))
(setq wp 0)
(setq w (cddar w))
(while!> w
(cond ((caar w) (setq wp (add1 wp))))
(setq w (cdr w)))
(return wp)))
% Dualisation #(p-form) -> (dim-p)-form ...
% Use: !#sdetG !#G !#T !#VOL
(de dual!> (w)
(cond ((null w) nil)
(t(proc (wp wdp wr wl wf wc)
(setq wp (pformq!> w)) % We are dualizing p-form=wp
(cond ((eqn wp ![dim!]) (return (duald!> w))))
(setq wdp (difference ![dim!] wp)) % to (dim-p)-form
(setq ![tlow!] % List of T_a (lower index a)
(foreach!> x in (dimlist!> 0) collect (getlo!> !#!T x)))
(setq wl (mklambda!> wdp ![dim!])) % All T_a/\... (dim-p)-forms
(setq wf (invsvol!>)) % The coefficient
(while!> wl
(setq wc (dfprod2!> (cdar wl) w))
(cond (wc (setq wr (cons (fndfpr!> (list 'times wf (caar wc))
(tprod!> (caar wl)))
wr))))
(setq wl (cdr wl)))
(return (dfsum!> wr)) ))))
(de mklambda!> (wp wd)
(proc (wr ww wc wn wi wa)
(setq wr (mklist!> (sub1 wp) (sub1 wd)))
(setq wr (mapcar wr 'lform1!>))
(setq wi (sub1 wp))
(while!> (greaterp wi 0)
(setq ww nil)
(while!> wr
(setq wc (car wr))
(setq wn (mklist!> (sub1 wi) (sub1(caar wc))))
(while!> wn
(setq wa (car wn))
(setq ww (cons (cons (cons wa (car wc))
(dfprod2!> (getel1!> ![tlow!] wa)
(cdr wc)))
ww))
(setq wn (cdr wn)))
(setq wr (cdr wr)))
(setq wr (reversip ww))
(setq wi (sub1 wi)))
(return wr)))
(de lform1!> (w) (cons (ncons w) (getel1!> ![tlow!] w)))
(de tprod!> (w)
(cond ((null(cdr w)) (getframe!> (car w)))
(t (dfprod2!> (getframe!> (car w))
(tprod!> (cdr w))))))
(de mklist!> (wa wb)
(cond ((greaterp wa wb) nil)
(t (cons wa (mklist!> (add1 wa) wb)))))
%---------- Limits ---------------------------------------------------------
% Limits 6.03.94 ...
%(de lima!> (wx wl wt lst)
% (cond((null lst) nil)
% ((eq wt 'p) (list 'limit!+ lst wx wl))
% ((eq wt 'm) (list 'limit!- lst wx wl))
% (t (list 'limit lst wx wl))))
%
%(de limf!> (wx wl wt lst)
% (cond((null lst) nil)
% (t(proc (wr)
% (while!> lst
% (setq wr (cons (cons (lima!> wx wl wt (caar lst))
% (cdar lst)) wr))
% (setq lst (cdr lst)))
% (return(reversip wr))))))
%---------- SUBstitutions 7.03.94 -----------------------------------------
(de subalg!> (wl lst)
(cond((null lst) nil)
(t(cons 'sub (append wl (ncons lst))))))
(de subdf!> (wl lst)
(cond((null lst) nil)
(t(proc (wr)
(while!> lst
(setq wr (cons (cons (subalg!> wl(caar lst))
(cdar lst)) wr))
(setq lst (cdr lst)))
(return(reversip wr))))))
%-------- Anholonomic Mode 04.03.91, 05.96 --------------------------------
% Anholonomic/Holonomic command ...
(de turnbg!> (wm)
(prog2
(setq wm (errorset!> (list 'turnbg0!> wm) ![erst1!] ![erst2!]))
(cond ((atom wm) (erm!> wm) (erm!> 8803) (msg!> 88033) !!er!!)
(t (car wm))) ))
(de turnbg0!> (wm)
(proc (w)
(cond((eq wm ![umod!]) (progn % current mode ?
(prin2 "Current Basis is ")
(cond(![umod!](prin2 "an")))
(prin2 "holonomic already.")(terpri)
(return t))))
(setq ![chain!] nil)
(setq w (request!> '!#!b)) % basis ?
(cond((eq w !!er!!) (return w))
((null w) (trsf!> '!#!b)(setq ![er!] 6046)(return !!er!!)))
(setq ![chain!] nil)
(setq w (request!> '!#!e)) % inverse basis ?
(cond((eq w !!er!!) (return w))
((null w) (trsf!> '!#!b)(setq ![er!] 6046)(return !!er!!)))
(setq w (evalform!>(dfprod!> !#!b))) % singular basis ?
(cond ((null w) (prog2 (setq ![er!] 8400) (return !!er!!))))
(setq w (evalform!>(dfprod!> !#!e))) % singilar inverse basis ?
(cond ((null w) (prog2 (setq ![er!] 8401) (return !!er!!))))
(cond (wm (mktables!>))
(t (prog2 (setq ![xf!] !#!b) % b = d x
(setq ![xv!] !#!e)))) % e = @ x
(setq ![xb!] nil)
(setq w (altdata!>(alldata!>)))
(while!> w % converting all data to new basis ...
(cond ((or (memq (car w) '( ![cord!] ![const!] ![fun!] ![apar!]
!#!b !#!e))
(zerop (gettype!> (car w)))) nil)
(t (set (car w)
(allcoll!> (eval(car w)) (car w) nil
(cond((get (car w) '!=idxl)(get (car w) '!=idxl))
(t '(0)))
(function nbel!>))) ))
(setq w (cdr w)))
(setq ![umod!] wm)
(cond ((null wm) (progn
(setq ![ccb!] nil)
(setq ![ccbi!] nil)
(setq ![xv!] nil)
(setq ![xf!] nil))))
(ftype!>)
(fitype!>)
(done!>)
(return t)))
% New basis for element ...
(de nbel!> (lst wi wn)
(cond ((null lst) nil)
((and (eqn (gettype!> wn) -1) (not (flagp wn '!+equ))) % vec
(nbvec!> lst))
((not (flagp wn '!+equ)) % form
(nbform!> lst))
((eqn (gettype!> wn) -1) % eq vec
(equation!> (nbvec!>(cadr lst)) (nbvec!>(caddr lst))))
(t % eq form
(equation!> (nbform!>(cadr lst)) (nbform!>(caddr lst))))
))
% New basis for form ...
(de nbform!> (w)
(cond ((null w) w)
(t (evalform!> (dfsum!> (mapcar w (function nbform1!>)))))))
(de nbform1!> (w)
(fndfpr!> (car w)
(nbxb!> (cdr w))))
% New basis for d X/\d Y/\...
(de nbxb!> (w)
(cond
((assoc (car w) ![xb!]) (cadr (assoc (car w) ![xb!])))
(t (progn
(setq ![xb!] (cons (list2 (car w) (evalform!> (mkbxb!>(cdr w) )))
![xb!]))
(cadar ![xb!])))))
(de mkbxb!> (w)
(proc (wa wn)
(setq wn 0)
(while!> w
(cond ((caar w)
(setq wa (cons (getel1!> ![xf!] wn) wa))))
(setq wn (add1 wn))
(setq w (cdr w)))
(return (evalform!> (dfprod!>(reverse wa))))))
(de mktables!> nil
(prog (w)
(setq ![xf!] (mkt!> 1))
(setq w (aeval (list 'quotient 1 (mkmtetr!> !#!b))))
(mktetrm!> (cdr w) ![xf!]) % d x = b
(setq ![xv!] (mkt!> 1))
(setq w (aeval (list 'tp (mkmtetr!> !#!b))))
(mktetrm!> (cdr w) ![xv!]) % @ x = e
(setq ![ccb!] % ~ b
(mapcar (mapcar !#!b 'coform!>) (function nbform!>)))
(setq ![ccbi!] % ~ e
(mapcar (mapcar !#!e 'coform!>) (function nbvec!>)))
))
% New basis for vector ...
(de nbvec!> (w)
(cond ((null w) w)
(t (evalform!> (dfsum!> (mapcar w (function nbvec1!>)))))))
(de nbvec1!> (w)
(fndfpr!> (car w)
(nbxv!> (cadr w))))
(de nbxv!> (w)
(proc (wc)
(setq wc -1)
(while!> (not (eqn w 1))
(setq w (quotient w 2))
(setq wc (add1 wc)) )
(return (getel1!> ![xv!] wc)) ))
%========= End of GRGproc.sl ==============================================%