1 #include "def.h"
2 #include "macro.h"
3 /* AK  291288 */
4 typedef struct node {
5     char * _key; /* dies enthaelt ein object */
6     struct node * _l, * _r;
7     char _rtag;
8 } Node;
9 
10 #define KEY(p) ((p) -> _key)
11 #define LINKS(p) ((p) -> _l)
12 #define RECHTS(p) ((p) -> _r)
13 #define RTAG(p) ((p) -> _rtag)
14 
15 
16 /* TSEARCH(3C) */
17 typedef enum {
18     preorder, postorder, endorder, leaf }
19 VISIT;
20 
21 
22 static INT AK_twalk();
23 static void AK_tfree();
24 static char ** AK_tsearch();
25 static char ** AK_tdelete();
26 static char ** AK_tfind();
27 static void walk();
28 static void freeself_bintree_action();
29 static void fprint_bintree_action();
30 static void insert_bt_bt_action();
31 static void copy_bintree_action();
32 static void t_BINTREE_LIST_action();
33 static void t_BINTREE_SCHUR_action();
34 static void t_BINTREE_POLYNOM_action();
35 static void t_BINTREE_HOMSYM_action();
36 static void t_BINTREE_ELMSYM_action();
37 static void t_BINTREE_POWSYM_action();
38 static void t_BINTREE_MONOMIAL_action();
39 static void t_BINTREE_SCHUBERT_action();
40 static void t_BINTREE_GRAL_action();
41 static void t_BINTREE_SCHUR_action_apply();
42 static void t_BINTREE_POLYNOM_action_apply();
43 static void t_BINTREE_HOMSYM_action_apply();
44 static void t_BINTREE_POWSYM_action_apply();
45 static void t_BINTREE_MONOMIAL_action_apply();
46 static void t_BINTREE_ELMSYM_action_apply();
47 
48 static char *_bt_p1, *_bt_p2, *_bt_p3; /* fur twalk */
49 #define TWALK(a,b) AK_twalk((Node *)a,b)
50 #define TSEARCH AK_tsearch
51 #define TFIND(a,b,c) AK_tfind((char*)a,(Node **) b,c)
52 #define TDELETE AK_tdelete
53 
54 #ifdef BINTREETRUE
freeself_bintree_action(a,type)55 static void freeself_bintree_action(a,type) OP *a; VISIT type;
56 /* AK 210891 V1.3 */
57 {
58     if ((type==postorder) ||  (type==leaf))
59         freeall(*a);
60 }
61 
62 
freeself_bintree(a)63 INT freeself_bintree(a) OP a;
64 /* AK 050891 V1.3 */
65 {
66     OBJECTSELF d ;
67     d = S_O_S(a);
68     AK_tfree(& d.ob_charpointer,freeself_bintree_action,NULL,NULL,NULL);
69     C_O_K(a,EMPTY);
70     return OK; /* AK 050891 */
71 }
72 
73 
74 
75 
init_bintree(a)76 INT init_bintree(a) OP a;
77 /* AK 050891 V1.3 */
78 {
79     OBJECTSELF d;
80     C_O_K(a,BINTREE);
81     d.ob_charpointer = (char *) NULL;
82     C_O_S(a,d);
83     return(OK);
84 }
85 
86 
87 
length_bintree_action(a,type,l)88 static void length_bintree_action(a,type,l) OP *a;VISIT type;INT l;
89 /* AK 210891 V1.3 */
90 {
91     OP p1 = (OP ) _bt_p1;
92     if ((type==postorder)||  (type==leaf))
93     {
94         inc(p1);
95     }
96 }
97 
fprint_bintree_action(a,type,l)98 static void fprint_bintree_action(a,type,l) OP *a;VISIT type;INT l;
99 /* AK 210891 V1.3 */
100 {
101     FILE *p1 = (FILE *) _bt_p1;
102     if ((type==postorder)||  (type==leaf))
103     {
104         fprint(p1,*a);
105         fprintf(p1," ");
106         if (p1==stdout)
107             {
108             zeilenposition++;
109             if (zeilenposition >70L) {
110                 fprintf(p1,"\n");
111                 zeilenposition=0L; }
112             }
113     }
114 }
115 
116 
117 
118 
length_bintree(a,b)119 INT length_bintree(a,b) OP a,b;
120 /* AK 211097 */
121 {
122     void length_bintree_action();
123     OBJECTSELF d;
124     m_i_i(0,b);
125     d = S_O_S(a);
126     if (d.ob_charpointer == NULL)
127         {
128         }
129     else
130         {
131         _bt_p1 = (char *) b;
132         TWALK(d.ob_charpointer,length_bintree_action);
133         }
134     return OK;
135 }
136 
fprint_bintree(fp,a)137 INT fprint_bintree(fp,a) FILE *fp; OP a;
138 /* AK 050891 V1.3 */
139 /* gibt einen bintree aus */
140 {
141     void fprint_bintree_action();
142     OBJECTSELF d;
143     d = S_O_S(a);
144     if (d.ob_charpointer == NULL)
145         {
146         fprintf(fp,"empty tree");
147         if (fp == stdout) zeilenposition += 10L;
148         }
149     else
150         {
151         _bt_p1 = (char *) fp;
152         _bt_p2 = (char *) NULL;
153         _bt_p3 =(char *)  NULL;
154         TWALK(d.ob_charpointer,fprint_bintree_action);
155         }
156     return OK;
157 }
158 
159 
160 
insert_bintree(a,bt,eh,cf)161 INT insert_bintree(a,bt,eh,cf) OP a,bt; INT (*cf)(), (*eh)();
162 /* fuegt a in bintree bt ein */
163 /* cf ist die vergleichsfunktion
164        eh gibt die operation bei schon vorhandenem
165        gleichen eintrag an */
166 /* AK 040189 */ /* AK 210891 V1.3 */
167 {
168     INT erg = OK;
169     char ** result;
170 
171     if (S_O_K(a) == BINTREE)
172         {
173         OBJECTSELF d;
174         d = S_O_S(a);
175         if (d.ob_charpointer == NULL) /* AK 300997 */
176             {
177             freeall(a);
178             return INSERTOK;
179             }
180         d = S_O_S(bt);
181                 if (d.ob_charpointer == NULL) /* AK 300997 */
182                         {
183                         swap(a,bt);
184             freeall(a);
185                         return INSERTOK;
186                         }
187         return insert_bt_bt(a,bt,eh,cf);
188         }
189     else if ( LISTP(a) )
190         {
191         OP z;
192         z = a;
193         if (S_L_S(z) != NULL)
194             while (z != NULL)
195                 {
196                 insert_bintree(S_L_S(z),bt,eh,cf);
197                 C_L_S(z,NULL);
198                 z = S_L_N(z);
199                 }
200         FREEALL(a);
201         return INSERTOK;
202         }
203 
204     if (cf == NULL) cf = comp;
205     /* default wert */
206 
207     result = TSEARCH(a, &((S_O_S(bt)).ob_charpointer) ,cf);
208     if (*result == (char *)a)
209         return INSERTOK;
210                 /* d.h. das element wurde eingefuegt */
211     else             /* d.h. es wurde ein gleiches element festgestelt
212                 und result ist ein pointer darauf */
213         {
214         if (eh != NULL)
215             (*eh)(a,*result);
216         if (EMPTYP((OP)*result)) /* eq-handle hat geloescht */
217             {
218             OP z = (OP)*result;
219             *z = *a;
220             TDELETE(a,&((S_O_S(bt)).ob_charpointer) ,cf);
221             C_O_K(z,EMPTY);
222             FREEALL(z);
223             }
224         FREEALL(a);
225 
226         return INSERTEQ;
227         }
228     ENDR("insert_bintree");
229 }
230 
231 
232 
insert_bt_bt(a,bt,eh,cf)233 INT insert_bt_bt(a,bt,eh,cf) OP a,bt; INT (*cf)(), (*eh)();
234 /* fuegt a was auch bintree ist in bintree bt ein */
235 /* cf ist die vergleichsfunktion
236        eh gibt die operation bei schon vorhandenem
237        gleichen eintrag an */
238 /* AK 090189 */ /* AK 210891 V1.3 */
239 {
240     OBJECTSELF d;
241     INT erg = OK;
242     CTO(BINTREE,"insert_bt_bt(1)",a);
243     CTO(BINTREE,"insert_bt_bt(2)",bt);
244 
245     d = S_O_S(a);
246     AK_tfree(&d.ob_charpointer,insert_bt_bt_action,bt,eh,cf);
247     C_O_K(a,EMPTY); /* leer setzen */
248     erg += freeall(a);
249     ENDR("insert_bt_bt");
250 }
251 
252 
253 
insert_bt_bt_action(a,type,bt,eh,cf)254 static void insert_bt_bt_action(a,type,bt,eh,cf)OP *a,bt; VISIT type;
255         INT (*eh)(),(*cf)();
256 /* AK 210891 V1.3 */
257 {
258     INT insert_erg;
259 
260     if ((type==postorder)||  (type==leaf))
261     {
262         insert_erg = insert_bintree(*a,bt,eh,cf);
263     }
264 }
265 
266 
267 
copy_bintree(a,b)268 INT copy_bintree(a,b) OP a,b;
269 /* AK 210891 V1.3 */
270 {
271     OBJECTSELF d;
272 
273     init(BINTREE,b);
274     d = S_O_S(a);
275         _bt_p1 = (char *) b;
276         _bt_p2 = (char *) NULL;
277         _bt_p3 = (char *) NULL;
278     TWALK(d.ob_charpointer,copy_bintree_action);
279     return OK;
280 }
281 
copy_bintree_action(a,type,l)282 static void copy_bintree_action(a,type,l) OP *a; VISIT type; INT l;
283 /* AK 210891 V1.3 */
284 {
285     OP bt = (OP) _bt_p1;
286     if ((type==postorder)||  (type==leaf))
287     {
288         OP c=callocobject();
289         copy(*a,c);
290         insert_bintree(c,bt,NULL,NULL);
291     }
292 }
293 
294 
find_user_bintree(a,b,f)295 OP find_user_bintree(a,b,f) OP a,b; INT (*f)();
296 {
297     char ** result;
298     result = TFIND(a, &((S_O_S(b)).ob_charpointer) ,f);
299     if (result == NULL) return NULL;
300     return (OP) *result;
301 }
302 
find_bintree(a,b)303 OP find_bintree(a,b) OP a,b;
304 /* test ob a in b */
305 /* AK 050396 */
306 {
307     char ** result;
308     result = TFIND(a, &((S_O_S(b)).ob_charpointer) ,comp);
309     if (result == NULL) return NULL;
310     return (OP) *result;
311 
312 }
313 
314 
315 
bi_find(k,rootp,compar,parent,c)316 static Node ** bi_find(k,rootp,compar, parent, c) char *k;
317     register Node ** rootp; INT (*compar)();
318     Node ** parent; INT *c;
319 /* AK 210891 V1.3 */
320 {
321     *parent = (Node *) 0;
322     if (rootp && *rootp)
323         for (;;)
324         {
325             if ((*c = (*compar) (k,KEY(*rootp))) == 0L)
326                 break;
327             *parent = *rootp;
328             if( *c < 0L)
329             {
330                 rootp = & LINKS(*parent);
331                 if (! *rootp) break;
332             }
333             else {
334                 rootp = & RECHTS(*parent);
335                 if (RTAG(*parent)) break;
336             }
337         }
338 
339     return (rootp);
340 }
341 
342 
AK_tfind(k,rootp,compar)343 static char ** AK_tfind(k,rootp,compar) char *k;
344     register Node ** rootp;
345     INT (*compar)();
346 {
347     Node * parent;
348         INT c;
349     if ((rootp = bi_find(k,rootp,compar, &parent, &c)))
350                 if (*rootp && (c == 0))
351                         return (&KEY(*rootp));
352     return NULL;
353 }
354 
355 
AK_tdelete(k,rootp,compar)356 static char ** AK_tdelete(k,rootp,compar) char *k;
357         register Node ** rootp;
358         INT (*compar)();
359 {
360 /* Schreiner: UNIX Sprechstude p.248 */
361     register Node *p;
362     char **result;
363     Node * parent; INT c;
364 
365     if (! (rootp = bi_find(k,rootp,compar,&parent, &c))
366         || ! * rootp || c)
367             return (char **) 0;
368 
369     result = ! parent ? & KEY (*rootp): & KEY(parent);
370 
371     if (!RTAG(*rootp)) {
372         Node * R = RECHTS(*rootp);
373         if (!LINKS(*rootp)) {
374             p = *rootp, *rootp=R, SYM_free(p);
375             return result;
376             }
377         if (! LINKS(R))
378             LINKS(R) = LINKS(*rootp), SYM_free(*rootp), *rootp = R;
379         else    {
380             p = R;
381             while(LINKS(LINKS(p)))    p = LINKS(p);
382             LINKS(LINKS(p)) = LINKS(*rootp);
383             SYM_free(*rootp), *rootp = LINKS(p);
384             LINKS(p) = RTAG(LINKS(p))? (Node *)0: RECHTS(LINKS(p));
385             RECHTS(*rootp) = R, RTAG(*rootp)=0;
386             }
387         if ((p = LINKS(*rootp))) {
388             while (! RTAG(p)) p = RECHTS(p);
389             RECHTS(p) = *rootp, RTAG(p)=1;
390             }
391         }
392     else if ((p=LINKS(*rootp))) {
393         while(! RTAG(p)) p = RECHTS(p);
394         RECHTS(p) = RECHTS(*rootp), RTAG(p)=1;
395         p = *rootp, *rootp = LINKS(p), SYM_free(p);
396         }
397     else if (parent && RECHTS(parent) == *rootp) {
398         p = *rootp;
399         RECHTS(parent) = RECHTS(p), RTAG(parent) = 1;
400         SYM_free(p);
401         }
402     else
403         SYM_free(*rootp), *rootp = (Node *)0;
404 
405     return result;
406 }
407 
AK_tsearch(k,rootp,compar)408 static char ** AK_tsearch(k,rootp,compar) char *k;
409     register Node ** rootp;
410     INT (*compar)();
411 /* AK 210891 V1.3 */
412 {
413     register Node *p;
414     Node * parent;
415     INT c;
416 
417     if ((rootp = bi_find(k,rootp,compar, &parent, &c)))
418         if (*rootp && c == 0)
419             return (&KEY(*rootp));
420         else if ((p = (Node *) SYM_malloc(sizeof(Node))))
421         {
422             KEY(p) =k;
423             LINKS(p) = (Node *) 0;
424             if (parent && c>0)
425             {
426                 RECHTS(p) = RECHTS(parent);
427                 RECHTS(parent) = p, RTAG(parent)= 0;
428             }
429             else
430             {
431                 RECHTS(p) = parent;
432                 * rootp = p;
433             }
434             RTAG(p) = 1;
435             return (&KEY(p));
436         }
437     return ((char**) 0);
438 }
439 
440 
walk(root,action,l)441 static void walk(root,action,l) register Node *root;
442     void (*action) ();
443     INT l;
444 /* fuer parameter bei action */
445 
446 /* AK 210891 V1.3 */
447 {
448     if (! LINKS(root) && RTAG(root))
449         (*action) (&KEY(root), leaf, l);
450     else
451     {
452         (*action) (&KEY(root), preorder, l);
453         if (LINKS(root))
454             walk(LINKS(root), action, l+1L);
455         (*action) (&KEY(root), postorder, l);
456         if (! RTAG(root))
457             walk(RECHTS(root), action, l+1L);
458         (*action) (&KEY(root), endorder, l);
459 
460     }
461 }
462 
AK_twalk(root,action)463 static INT AK_twalk(root,action) Node *root;
464     void (*action) ();
465 /* AK 210891 V1.3 */
466 {
467     if (root)
468         walk(root,action,0L);
469     return OK;
470 }
471 
472 
AK_tfree(rootp,a,bt,eh,cf)473 static void AK_tfree(rootp,a,bt,eh,cf) Node **rootp; void (*a)();
474     OP bt; INT (*eh)(); INT (*cf)();
475 /* AK 210891 V1.3 */
476 {
477     register Node *root,*p;
478 
479     if (!rootp || ! (root = *rootp))
480         return;
481     * rootp = (Node *)0;
482     for (;;)
483     {
484         while ((p = LINKS(root)))
485             root = p;
486         if (RTAG(root))
487         {
488             if (a)
489                 (* a)(&KEY(root), leaf,bt,eh,cf);
490             do
491             {
492                 p=RECHTS(root),SYM_free(root),root=p;
493                 if (! root)
494                     return;
495                 if (a)
496                     (* a)(&KEY(root),postorder,bt,eh,cf);
497             } while(RTAG(root));
498         }
499         else
500         {
501             if (a)
502                 (* a)(&KEY(root),postorder,bt,eh,cf);
503         }
504         p=RECHTS(root),SYM_free(root),root=p;
505     }
506 }
507 
508 
t_BINTREE_VECTOR(a,b)509 INT t_BINTREE_VECTOR(a,b) OP a,b;
510 /* input: BINTREE object a
511    output: sorted VECTOR object b with copy of the objects in a as content */
512 /* a and b may be equal */
513 /* AK V2.0 170298 */
514 {
515     INT erg = OK;
516     OP c;
517     CTO(BINTREE,"t_BINTREE_VECTOR",a);
518     c = callocobject();
519     erg += t_BINTREE_LIST(a,c);
520     erg += t_LIST_VECTOR(c,b);
521     erg += freeall(c);
522     ENDR("t_BINTREE_VECTOR");
523 }
524 
t_BINTREE_LIST(a,b)525 INT t_BINTREE_LIST(a,b) OP a,b;
526 /* wandelt einen BINTREE in ein LIST object um */
527 /* die liste ist nach den gleichen vergleich sortiert */
528 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
529 {
530     void t_BINTREE_LIST_action();
531     INT erg = OK; /* AK 170392 */
532     OP h, *h2;
533     OBJECTSELF d;
534 
535     CTO(BINTREE,"t_BINTREE_LIST",a);
536     CE2(a,b,t_BINTREE_LIST);
537 
538     d = S_O_S(a);
539     if (d.ob_charpointer == NULL)
540         {
541         erg += init(LIST,b);
542         goto endr_ende;
543         }
544 
545     h = callocobject();
546     erg += b_sn_l(NULL,NULL,h);
547 
548     h2 = &S_L_N(h);
549         _bt_p1 = (char *)&h2;
550         _bt_p2 = (char *)NULL;
551         _bt_p3 = (char *)NULL;
552     erg += TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_LIST_action);
553 
554     if (S_L_N(h) != NULL)
555         *b = *S_L_N(h);
556     else
557         erg += b_sn_l(NULL,NULL,b);
558 
559     C_O_K(S_L_N(h),EMPTY);
560     freeall(S_L_N(h));
561     C_L_N(h,NULL);
562     erg += freeall(h);
563     ENDR("t_BINTREE_LIST");
564 }
565 
566 
567 
t_BINTREE_LIST_action(a,type,l)568 static void t_BINTREE_LIST_action(a,type,l)OP *a;VISIT type;INT l;
569 /* AK 210891 V1.3 */
570 {
571     if ((type==postorder) ||  (type==leaf))
572         {
573         **(OP **)_bt_p1 = callocobject();
574         b_sn_l(callocobject(),NULL,**(OP **)_bt_p1);
575         copy(*a,S_L_S(**(OP **)_bt_p1));
576         *(OP **)_bt_p1 = & S_L_N(**(OP **)_bt_p1);
577         }
578 }
579 
580 
581 #ifdef SCHURTRUE
t_BINTREE_SCHUR_apply(a)582 INT t_BINTREE_SCHUR_apply(a) OP a;
583 /* AK 010198 V2.0 */
584 {
585     OP b;
586     void t_BINTREE_SCHUR_action_apply();
587     OP *h2,h;
588     OBJECTSELF d;
589     INT erg = OK;
590     b = CALLOCOBJECT();
591 
592     d = S_O_S(a);
593         if (d.ob_charpointer == NULL)
594                 {
595                 erg += init(SCHUR,a);
596                 goto endr_ende;
597                 }
598 
599         h = CALLOCOBJECT();
600         erg += b_sn_s(NULL,NULL,h);
601 
602         h2 = &S_L_N(h);
603                 _bt_p1 = (char *)&h2;
604                 _bt_p2 = (char *)NULL;
605                 _bt_p3 = (char *)NULL;
606         TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_SCHUR_action_apply);
607 
608         if (S_L_N(h) != NULL)
609                 *b = *S_L_N(h);
610         else
611                 {
612         erg += b_sn_s(NULL,NULL,b);
613                 }
614 
615         C_O_K(S_L_N(h),EMPTY);
616         FREEALL(S_L_N(h));
617         C_L_N(h,NULL);
618         FREEALL(h);
619 
620     erg += swap(b,a);
621     FREEALL(b);
622 
623 
624     ENDR("t_BINTREE_SCHUR_apply");
625 }
626 
t_BINTREE_SCHUR(a,b)627 INT t_BINTREE_SCHUR(a,b) OP a,b;
628 /* wandelt einen BINTREE in ein SCHUR object um */
629 /* die liste ist nach den gleichen vergleich sortiert */
630 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
631 {
632     void t_BINTREE_SCHUR_action();
633     OP *h2,h;
634     INT erg = OK;
635     OBJECTSELF d;
636 
637     CTO(BINTREE,"t_BINTREE_SCHUR(1)",a);
638 
639     if (a == b) {
640         erg += t_BINTREE_SCHUR_apply(a);
641         goto endr_ende;
642         }
643 
644     d = S_O_S(a);
645     if (d.ob_charpointer == NULL)
646         {
647         erg += init(SCHUR,b);
648         goto endr_ende;
649         }
650 
651     h = CALLOCOBJECT();
652     erg += b_sn_l(NULL,NULL,h);
653     C_O_K(h,SCHUR);
654 
655     h2 = &S_L_N(h);
656         _bt_p1 = (char *)&h2;
657         _bt_p2 = (char *)NULL;
658         _bt_p3 = (char *)NULL;
659     TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_SCHUR_action);
660 
661     if (S_L_N(h) != NULL)
662         *b = *S_L_N(h);
663     else
664         {
665         erg += b_sn_l(NULL,NULL,b);
666         C_O_K(b,SCHUR);
667         }
668 
669     C_O_K(S_L_N(h),EMPTY);
670     erg += freeall(S_L_N(h));
671     C_L_N(h,NULL);
672     FREEALL(h);
673     ENDR("t_BINTREE_SCHUR");
674 }
675 
676 
677 
t_BINTREE_SCHUR_action(a,type,l)678 static void t_BINTREE_SCHUR_action(a,type,l)OP *a;VISIT type;INT l;
679 /* AK 210891 V1.3 */
680 {
681     if ((type==postorder)||  (type==leaf))
682         {
683         **(OP**)_bt_p1 = CALLOCOBJECT();
684         b_sn_s(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
685         copy_monom(*a,S_L_S(**(OP**)_bt_p1));
686         *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
687         }
688 }
689 
t_BINTREE_SCHUR_action_apply(a,type,l)690 static void t_BINTREE_SCHUR_action_apply(a,type,l)OP *a;VISIT type;INT l;
691 /* AK 080199 V2.0 */
692 {
693         if ((type==postorder)||  (type==leaf))
694                 {
695                 **(OP**)_bt_p1 = CALLOCOBJECT();
696                 b_sn_s(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
697                 swap(*a,S_L_S(**(OP**)_bt_p1));
698                 *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
699                 }
700 }
701 
t_BINTREE_POWSYM_apply(a)702 INT t_BINTREE_POWSYM_apply(a) OP a;
703 /* AK 010198 V2.0 */
704 {
705     OP b;
706     void t_BINTREE_POWSYM_action_apply();
707     OP *h2,h;
708     OBJECTSELF d;
709     INT erg = OK;
710     CTO(BINTREE,"t_BINTREE_POWSYM_apply(1)",a);
711 
712     b = CALLOCOBJECT();
713 
714     d = S_O_S(a);
715         if (d.ob_charpointer == NULL)
716                 {
717                 erg += init(POWSYM,a);
718                 goto endr_ende;
719                 }
720 
721         h = CALLOCOBJECT();
722         erg += b_sn_l(NULL,NULL,h);
723         C_O_K(h,POWSYM);
724 
725         h2 = &S_L_N(h);
726                 _bt_p1 = (char *)&h2;
727                 _bt_p2 = (char *)NULL;
728                 _bt_p3 = (char *)NULL;
729         TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_POWSYM_action_apply);
730 
731         if (S_L_N(h) != NULL)
732                 *b = *S_L_N(h);
733         else
734                 {
735         erg += b_sn_l(NULL,NULL,b);
736                 C_O_K(b,POWSYM);
737                 }
738 
739         C_O_K(S_L_N(h),EMPTY);
740         erg += freeall(S_L_N(h));
741         C_L_N(h,NULL);
742         erg += freeall(h);
743 
744     erg += swap(b,a);
745     erg += freeall(b);
746 
747 
748     ENDR("t_BINTREE_POWSYM_apply");
749 }
750 
t_BINTREE_POWSYM(a,b)751 INT t_BINTREE_POWSYM(a,b) OP a,b;
752 /* wandelt einen BINTREE in ein POWSYM object um */
753 /* die liste ist nach den gleichen vergleich sortiert */
754 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
755 {
756     void t_BINTREE_POWSYM_action();
757     OP *h2,h;
758     INT erg = OK;
759     OBJECTSELF d;
760     CTO(BINTREE,"t_BINTREE_POWSYM(1)",a);
761 
762     if (a == b) {
763         erg += t_BINTREE_POWSYM_apply(a);
764         goto endr_ende;
765         }
766 
767     d = S_O_S(a);
768     if (d.ob_charpointer == NULL)
769         {
770         erg += init(POWSYM,b);
771         goto endr_ende;
772         }
773 
774     h = CALLOCOBJECT();
775     erg += b_sn_l(NULL,NULL,h);
776     C_O_K(h,POWSYM);
777 
778     h2 = &S_L_N(h);
779         _bt_p1 = (char *)&h2;
780         _bt_p2 = (char *)NULL;
781         _bt_p3 = (char *)NULL;
782     TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_POWSYM_action);
783 
784     if (S_L_N(h) != NULL)
785         *b = *S_L_N(h);
786     else
787         {
788         erg += b_sn_l(NULL,NULL,b);
789         C_O_K(b,POWSYM);
790         }
791 
792     C_O_K(S_L_N(h),EMPTY);
793     erg += freeall(S_L_N(h));
794     C_L_N(h,NULL);
795     erg += freeall(h);
796     ENDR("t_BINTREE_POWSYM");
797 }
798 
799 
800 
t_BINTREE_POWSYM_action(a,type,l)801 static void t_BINTREE_POWSYM_action(a,type,l)OP *a;VISIT type;INT l;
802 /* AK 210891 V1.3 */
803 {
804     if ((type==postorder)||  (type==leaf))
805         {
806         **(OP**)_bt_p1 = CALLOCOBJECT();
807         b_sn_l(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
808         C_O_K(**(OP**)_bt_p1,POWSYM);
809         copy_monom(*a,S_L_S(**(OP**)_bt_p1));
810         *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
811         }
812 }
t_BINTREE_POWSYM_action_apply(a,type,l)813 static void t_BINTREE_POWSYM_action_apply(a,type,l)OP *a;VISIT type;INT l;
814 /* AK 080199 V2.0 */
815 {
816         if ((type==postorder)||  (type==leaf))
817                 {
818                 **(OP**)_bt_p1 = CALLOCOBJECT();
819                 b_sn_l(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
820                 C_O_K(**(OP**)_bt_p1,POWSYM);
821                 swap(*a,S_L_S(**(OP**)_bt_p1));
822                 *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
823                 }
824 }
825 
t_BINTREE_ELMSYM_apply(a)826 INT t_BINTREE_ELMSYM_apply(a) OP a;
827 /* AK 010198 V2.0 */
828 {
829     OP b;
830     void t_BINTREE_ELMSYM_action_apply();
831     OP *h2,h;
832     OBJECTSELF d;
833     INT erg = OK;
834     CTO(BINTREE,"t_BINTREE_ELMSYM_apply(1)",a);
835     b = CALLOCOBJECT();
836 
837     d = S_O_S(a);
838         if (d.ob_charpointer == NULL)
839                 {
840                 erg += init(ELMSYM,a);
841                 goto endr_ende;
842                 }
843 
844         h = CALLOCOBJECT();
845         erg += b_sn_l(NULL,NULL,h);
846         C_O_K(h,ELMSYM);
847 
848         h2 = &S_L_N(h);
849                 _bt_p1 = (char *)&h2;
850                 _bt_p2 = (char *)NULL;
851                 _bt_p3 = (char *)NULL;
852         TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_ELMSYM_action_apply);
853 
854         if (S_L_N(h) != NULL)
855                 *b = *S_L_N(h);
856         else
857                 {
858         erg += b_sn_l(NULL,NULL,b);
859                 C_O_K(b,ELMSYM);
860                 }
861 
862         C_O_K(S_L_N(h),EMPTY);
863         erg += freeall(S_L_N(h));
864         C_L_N(h,NULL);
865         erg += freeall(h);
866 
867     erg += swap(b,a);
868     erg += freeall(b);
869 
870 
871     ENDR("t_BINTREE_ELMSYM_apply");
872 }
873 
t_BINTREE_ELMSYM(a,b)874 INT t_BINTREE_ELMSYM(a,b) OP a,b;
875 /* wandelt einen BINTREE in ein ELMSYM object um */
876 /* die liste ist nach den gleichen vergleich sortiert */
877 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
878 {
879     void t_BINTREE_ELMSYM_action();
880     OP *h2,h;
881     INT erg = OK;
882     OBJECTSELF d;
883     CTO(BINTREE,"t_BINTREE_ELMSYM(1)",a);
884 
885     if (a == b) {
886         erg += t_BINTREE_ELMSYM_apply(a);
887         goto endr_ende;
888         }
889 
890     d = S_O_S(a);
891     if (d.ob_charpointer == NULL)
892         {
893         erg += init(ELMSYM,b);
894         goto endr_ende;
895         }
896 
897     h = CALLOCOBJECT();
898     erg += b_sn_l(NULL,NULL,h);
899     C_O_K(h,ELMSYM);
900 
901     h2 = &S_L_N(h);
902         _bt_p1 = (char *)&h2;
903         _bt_p2 = (char *)NULL;
904         _bt_p3 = (char *)NULL;
905     TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_ELMSYM_action);
906 
907     if (S_L_N(h) != NULL)
908         *b = *S_L_N(h);
909     else
910         {
911         erg += b_sn_l(NULL,NULL,b);
912         C_O_K(b,ELMSYM);
913         }
914 
915     C_O_K(S_L_N(h),EMPTY);
916     erg += freeall(S_L_N(h));
917     C_L_N(h,NULL);
918     erg += freeall(h);
919     ENDR("t_BINTREE_ELMSYM");
920 }
921 
922 
923 
t_BINTREE_ELMSYM_action(a,type,l)924 static void t_BINTREE_ELMSYM_action(a,type,l)OP *a;VISIT type;INT l;
925 /* AK 210891 V1.3 */
926 {
927     if ((type==postorder)||  (type==leaf))
928         {
929         **(OP**)_bt_p1 = CALLOCOBJECT();
930         b_sn_l(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
931         C_O_K(**(OP**)_bt_p1,ELMSYM);
932         copy_monom(*a,S_L_S(**(OP**)_bt_p1));
933         *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
934         }
935 }
t_BINTREE_ELMSYM_action_apply(a,type,l)936 static void t_BINTREE_ELMSYM_action_apply(a,type,l)OP *a;VISIT type;INT l;
937 /* AK 080199 V2.0 */
938 {
939         if ((type==postorder)||  (type==leaf))
940                 {
941                 **(OP**)_bt_p1 = CALLOCOBJECT();
942                 b_sn_l(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
943                 C_O_K(**(OP**)_bt_p1,ELMSYM);
944                 swap(*a,S_L_S(**(OP**)_bt_p1));
945                 *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
946                 }
947 }
948 
t_BINTREE_HOMSYM_apply(a)949 INT t_BINTREE_HOMSYM_apply(a) OP a;
950 /* AK 010198 V2.0 */
951 {
952     OP b;
953     void t_BINTREE_HOMSYM_action_apply();
954     OP *h2,h;
955     OBJECTSELF d;
956     INT erg = OK;
957     CTO(BINTREE,"t_BINTREE_HOMSYM_apply(1)",a);
958     b = CALLOCOBJECT();
959 
960     d = S_O_S(a);
961         if (d.ob_charpointer == NULL)
962                 {
963                 erg += init(HOMSYM,a);
964                 goto endr_ende;
965                 }
966 
967         h = CALLOCOBJECT();
968         erg += b_sn_l(NULL,NULL,h);
969         C_O_K(h,HOMSYM);
970 
971         h2 = &S_L_N(h);
972                 _bt_p1 = (char *)&h2;
973                 _bt_p2 = (char *)NULL;
974                 _bt_p3 = (char *)NULL;
975         TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_HOMSYM_action_apply);
976 
977         if (S_L_N(h) != NULL)
978                 *b = *S_L_N(h);
979         else
980                 {
981         erg += b_sn_l(NULL,NULL,b);
982                 C_O_K(b,HOMSYM);
983                 }
984 
985         C_O_K(S_L_N(h),EMPTY);
986         erg += freeall(S_L_N(h));
987         C_L_N(h,NULL);
988         erg += freeall(h);
989 
990     erg += swap(b,a);
991     erg += freeall(b);
992 
993 
994     ENDR("t_BINTREE_HOMSYM_apply");
995 }
996 
t_BINTREE_HOMSYM(a,b)997 INT t_BINTREE_HOMSYM(a,b) OP a,b;
998 /* wandelt einen BINTREE in ein HOMSYM object um */
999 /* die liste ist nach den gleichen vergleich sortiert */
1000 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
1001 {
1002     void t_BINTREE_HOMSYM_action();
1003     OP *h2,h;
1004     INT erg = OK;
1005     OBJECTSELF d;
1006     CTO(BINTREE,"t_BINTREE_HOMSYM(1)",a);
1007 
1008     if (a == b) {
1009         erg += t_BINTREE_HOMSYM_apply(a);
1010         goto endr_ende;
1011         }
1012 
1013     d = S_O_S(a);
1014     if (d.ob_charpointer == NULL)
1015         {
1016         erg += init(HOMSYM,b);
1017         goto endr_ende;
1018         }
1019 
1020     h = CALLOCOBJECT();
1021     erg += b_sn_l(NULL,NULL,h);
1022     C_O_K(h,HOMSYM);
1023 
1024     h2 = &S_L_N(h);
1025         _bt_p1 = (char *)&h2;
1026         _bt_p2 = (char *)NULL;
1027         _bt_p3 = (char *)NULL;
1028     TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_HOMSYM_action);
1029 
1030     if (S_L_N(h) != NULL)
1031         *b = *S_L_N(h);
1032     else
1033         {
1034         erg += b_sn_l(NULL,NULL,b);
1035         C_O_K(b,HOMSYM);
1036         }
1037 
1038     C_O_K(S_L_N(h),EMPTY);
1039     erg += freeall(S_L_N(h));
1040     C_L_N(h,NULL);
1041     erg += freeall(h);
1042     ENDR("t_BINTREE_HOMSYM");
1043 }
1044 
1045 
1046 
t_BINTREE_HOMSYM_action(a,type,l)1047 static void t_BINTREE_HOMSYM_action(a,type,l)OP *a;VISIT type;INT l;
1048 /* AK 210891 V1.3 */
1049 {
1050     if ((type==postorder)||  (type==leaf))
1051         {
1052         **(OP**)_bt_p1 = CALLOCOBJECT();
1053         b_sn_l(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
1054         C_O_K(**(OP**)_bt_p1,HOMSYM);
1055         copy_monom(*a,S_L_S(**(OP**)_bt_p1));
1056         *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
1057         }
1058 }
t_BINTREE_HOMSYM_action_apply(a,type,l)1059 static void t_BINTREE_HOMSYM_action_apply(a,type,l)OP *a;VISIT type;INT l;
1060 /* AK 080199 V2.0 */
1061 {
1062         if ((type==postorder)||  (type==leaf))
1063                 {
1064                 **(OP**)_bt_p1 = CALLOCOBJECT();
1065                 b_sn_l(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
1066                 C_O_K(**(OP**)_bt_p1,HOMSYM);
1067                 swap(*a,S_L_S(**(OP**)_bt_p1));
1068                 *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
1069                 }
1070 }
1071 
1072 #endif /* SCHURTRUE */
1073 
1074 #ifdef SCHUBERTTRUE
t_BINTREE_SCHUBERT(a,b)1075 INT t_BINTREE_SCHUBERT(a,b) OP a,b;
1076 /* wandelt einen BINTREE in ein SCHUBERT object um */
1077 /* die liste ist nach den gleichen vergleich sortiert */
1078 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
1079 {
1080     void t_BINTREE_SCHUBERT_action();
1081     OP *h2,h;
1082     INT erg = OK;
1083     OBJECTSELF d;
1084     CTO(BINTREE,"t_BINTREE_SCHUBERT(1)",a);
1085 
1086     CE2(a,b,t_BINTREE_SCHUBERT);
1087 
1088         d = S_O_S(a);
1089         if (d.ob_charpointer == NULL)
1090                 {
1091                 erg += init(SCHUBERT,b);
1092                 goto endr_ende;
1093                 }
1094 
1095         h = callocobject();
1096         erg += b_sn_l(NULL,NULL,h);
1097         C_O_K(h,SCHUBERT);
1098 
1099         h2 = &S_L_N(h);
1100                 _bt_p1 = (char *)&h2;
1101                 _bt_p2 = (char *)NULL;
1102                 _bt_p3 = (char *)NULL;
1103         TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_SCHUBERT_action);
1104 
1105         if (S_L_N(h) != NULL)
1106                 *b = *S_L_N(h);
1107         else
1108                 {
1109                 erg += b_sn_l(NULL,NULL,b);
1110                 C_O_K(b,SCHUBERT);
1111                 }
1112 
1113         C_O_K(S_L_N(h),EMPTY);
1114         erg += freeall(S_L_N(h));
1115         C_L_N(h,NULL);
1116         erg += freeall(h);
1117         ENDR("t_BINTREE_SCHUBERT");
1118 }
1119 
1120 
1121 
t_BINTREE_SCHUBERT_action(a,type,l)1122 static void t_BINTREE_SCHUBERT_action(a,type,l)OP *a;VISIT type;INT l;
1123 /* AK 210891 V1.3 */
1124 {
1125         if ((type==postorder)||  (type==leaf))
1126                 {
1127                 **(OP**)_bt_p1 = callocobject();
1128                 b_sn_l(callocobject(),NULL,**(OP**)_bt_p1);
1129                 C_O_K(**(OP**)_bt_p1,SCHUBERT);
1130                 copy_monom(*a,S_L_S(**(OP**)_bt_p1));
1131                 *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
1132                 }
1133 }
1134 
1135 #endif /* SCHUBERTTRUE */
t_BINTREE_GRAL_action(a,type,l)1136 static void t_BINTREE_GRAL_action(a,type,l)OP *a;VISIT type;INT l;
1137 /* AK 210891 V1.3 */
1138 {
1139         if ((type==postorder)||  (type==leaf))
1140                 {
1141                 **(OP**)_bt_p1 = callocobject();
1142                 b_sn_l(callocobject(),NULL,**(OP**)_bt_p1);
1143                 C_O_K(**(OP**)_bt_p1,GRAL);
1144                 copy_monom(*a,S_L_S(**(OP**)_bt_p1));
1145                 *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
1146                 }
1147 }
1148 
t_BINTREE_GRAL(a,b)1149 INT t_BINTREE_GRAL(a,b) OP a,b;
1150 /* wandelt einen BINTREE in ein GRAL object um */
1151 /* die liste ist nach den gleichen vergleich sortiert */
1152 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
1153 {
1154         void t_BINTREE_GRAL_action();
1155         OP *h2,h;
1156         INT erg = OK;
1157         OBJECTSELF d;
1158 
1159         CE2(a,b,t_BINTREE_GRAL);
1160 
1161         d = S_O_S(a);
1162         if (d.ob_charpointer == NULL)
1163                 {
1164                 erg += init(GRAL,b);
1165                 goto endr_ende;
1166                 }
1167 
1168         h = callocobject();
1169         erg += b_sn_l(NULL,NULL,h);
1170         C_O_K(h,GRAL);
1171 
1172         h2 = &S_L_N(h);
1173                 _bt_p1 = (char *)&h2;
1174                 _bt_p2 = (char *)NULL;
1175                 _bt_p3 = (char *)NULL;
1176         TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_GRAL_action);
1177 
1178         if (S_L_N(h) != NULL)
1179                 *b = *S_L_N(h);
1180         else
1181                 {
1182                 erg += b_sn_l(NULL,NULL,b);
1183                 C_O_K(b,GRAL);
1184                 }
1185 
1186         C_O_K(S_L_N(h),EMPTY);
1187         erg += freeall(S_L_N(h));
1188         C_L_N(h,NULL);
1189         erg += freeall(h);
1190         ENDR("t_BINTREE_GRAL");
1191 }
1192 
1193 
test_bintree()1194 INT test_bintree()
1195 {
1196     OP a,b,c;
1197     a = callocobject();
1198     b = callocobject();
1199     c = callocobject();
1200     printeingabe("test_bintree:init(BINTREE,a) ");
1201     init(BINTREE,a); println(a);
1202     printeingabe("test_bintree:insert(5L,a) ");
1203     m_i_i(5L,b);insert(b,a,NULL,NULL); println(a);
1204     printeingabe("test_bintree:insert(7L,a) ");
1205     b = callocobject();
1206     m_i_i(7L,b);
1207     insert(b,a,NULL,NULL);  println(a);
1208     printeingabe("test_bintree:copy(a,c) ");
1209     copy(a,c); println(c);
1210     printeingabe("test_bintree:insert(9L,c) ");
1211     b = callocobject();
1212     m_i_i(9L,b);
1213     insert(b,c,NULL,NULL);
1214     println(c);
1215     freeall(a);
1216     freeall(c);
1217     return OK;
1218 }
1219 
t_BINTREE_MONOMIAL_apply(a)1220 INT t_BINTREE_MONOMIAL_apply(a) OP a;
1221 /* AK 010198 V2.0 */
1222 {
1223     OP b;
1224     void t_BINTREE_MONOMIAL_action_apply();
1225         OP *h2,h;
1226     OBJECTSELF d;
1227     INT erg = OK;
1228     b = callocobject();
1229 
1230     d = S_O_S(a);
1231         if (d.ob_charpointer == NULL)
1232                 {
1233                 erg += init(MONOMIAL,a);
1234                 goto endr_ende;
1235                 }
1236 
1237         h = callocobject();
1238         erg += b_sn_l(NULL,NULL,h);
1239         C_O_K(h,MONOMIAL);
1240 
1241         h2 = &S_L_N(h);
1242                 _bt_p1 = (char *)&h2;
1243                 _bt_p2 = (char *)NULL;
1244                 _bt_p3 = (char *)NULL;
1245         TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_MONOMIAL_action_apply);
1246 
1247         if (S_L_N(h) != NULL)
1248                 *b = *S_L_N(h);
1249         else
1250                 {
1251         erg += b_sn_l(NULL,NULL,b);
1252                 C_O_K(b,MONOMIAL);
1253                 }
1254 
1255         C_O_K(S_L_N(h),EMPTY);
1256         erg += freeall(S_L_N(h));
1257         C_L_N(h,NULL);
1258         erg += freeall(h);
1259 
1260     erg += swap(b,a);
1261     erg += freeall(b);
1262 
1263 
1264     ENDR("t_BINTREE_MONOMIAL_apply");
1265 }
1266 
t_BINTREE_MONOMIAL(a,b)1267 INT t_BINTREE_MONOMIAL(a,b) OP a,b;
1268 /* wandelt einen BINTREE in ein MONOMIAL object um */
1269 /* die liste ist nach den gleichen vergleich sortiert */
1270 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
1271 {
1272     void t_BINTREE_MONOMIAL_action();
1273     OP *h2,h;
1274     INT erg = OK;
1275     OBJECTSELF d;
1276 
1277     if (a == b) {
1278         erg += t_BINTREE_MONOMIAL_apply(a);
1279         goto endr_ende;
1280         }
1281 
1282     d = S_O_S(a);
1283     if (d.ob_charpointer == NULL)
1284         {
1285         erg += init(MONOMIAL,b);
1286         goto endr_ende;
1287         }
1288 
1289     h = callocobject();
1290     erg += b_sn_l(NULL,NULL,h);
1291     C_O_K(h,MONOMIAL);
1292 
1293     h2 = &S_L_N(h);
1294         _bt_p1 = (char *)&h2;
1295         _bt_p2 = (char *)NULL;
1296         _bt_p3 = (char *)NULL;
1297     TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_MONOMIAL_action);
1298 
1299     if (S_L_N(h) != NULL)
1300         *b = *S_L_N(h);
1301     else
1302         {
1303         erg += b_sn_l(NULL,NULL,b);
1304         C_O_K(b,MONOMIAL);
1305         }
1306 
1307     C_O_K(S_L_N(h),EMPTY);
1308     erg += freeall(S_L_N(h));
1309     C_L_N(h,NULL);
1310     erg += freeall(h);
1311     ENDR("t_BINTREE_MONOMIAL");
1312 }
1313 
1314 
1315 
t_BINTREE_MONOMIAL_action(a,type,l)1316 static void t_BINTREE_MONOMIAL_action(a,type,l)OP *a;VISIT type;INT l;
1317 /* AK 210891 V1.3 */
1318 {
1319     if ((type==postorder)||  (type==leaf))
1320         {
1321         **(OP**)_bt_p1 = callocobject();
1322         b_sn_l(callocobject(),NULL,**(OP**)_bt_p1);
1323         C_O_K(**(OP**)_bt_p1,MONOMIAL);
1324         copy_monom(*a,S_L_S(**(OP**)_bt_p1));
1325         *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
1326         }
1327 }
t_BINTREE_MONOMIAL_action_apply(a,type,l)1328 static void t_BINTREE_MONOMIAL_action_apply(a,type,l)OP *a;VISIT type;INT l;
1329 /* AK 080199 V2.0 */
1330 {
1331         if ((type==postorder)||  (type==leaf))
1332                 {
1333                 **(OP**)_bt_p1 = callocobject();
1334                 b_sn_l(callocobject(),NULL,**(OP**)_bt_p1);
1335                 C_O_K(**(OP**)_bt_p1,MONOMIAL);
1336                 swap(*a,S_L_S(**(OP**)_bt_p1));
1337                 *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
1338                 }
1339 }
1340 
1341 #endif /* BINTREETRUE */
1342 #ifdef BINTREETRUE
t_BINTREE_POLYNOM_apply(a)1343 INT t_BINTREE_POLYNOM_apply(a) OP a;
1344 /* AK 010198 V2.0 */
1345 {
1346     OP b;
1347     void t_BINTREE_POLYNOM_action_apply();
1348     OP *h2,h;
1349     OBJECTSELF d;
1350     INT erg = OK;
1351     b = CALLOCOBJECT();
1352 
1353     d = S_O_S(a);
1354         if (d.ob_charpointer == NULL)
1355                 {
1356                 erg += init(POLYNOM,a);
1357                 goto endr_ende;
1358                 }
1359 
1360         h = CALLOCOBJECT();
1361         erg += b_sn_s(NULL,NULL,h);
1362 
1363         h2 = &S_L_N(h);
1364                 _bt_p1 = (char *)&h2;
1365                 _bt_p2 = (char *)NULL;
1366                 _bt_p3 = (char *)NULL;
1367         TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_POLYNOM_action_apply);
1368 
1369         if (S_L_N(h) != NULL)
1370                 *b = *S_L_N(h);
1371         else
1372                 erg += b_sn_po(NULL,NULL,b);
1373 
1374         C_O_K(S_L_N(h),EMPTY);
1375         FREEALL(S_L_N(h));
1376         C_L_N(h,NULL);
1377         FREEALL(h);
1378 
1379     erg += swap(b,a);
1380     FREEALL(b);
1381 
1382 
1383     ENDR("t_BINTREE_POLYNOM_apply");
1384 }
1385 
t_BINTREE_POLYNOM(a,b)1386 INT t_BINTREE_POLYNOM(a,b) OP a,b;
1387 /* wandelt einen BINTREE in ein POLYNOM object um */
1388 /* die liste ist nach den gleichen vergleich sortiert */
1389 /* AK 070390 V1.1 */ /* AK 050891 V1.3 */
1390 {
1391     void t_BINTREE_POLYNOM_action();
1392     OP *h2,h;
1393     INT erg = OK;
1394     OBJECTSELF d;
1395 
1396     CTO(BINTREE,"t_BINTREE_POLYNOM(1)",a);
1397 
1398     if (a == b) {
1399         erg += t_BINTREE_POLYNOM_apply(a);
1400         goto endr_ende;
1401         }
1402 
1403     d = S_O_S(a);
1404     if (d.ob_charpointer == NULL)
1405         {
1406         erg += init(POLYNOM,b);
1407         goto endr_ende;
1408         }
1409 
1410     h = CALLOCOBJECT();
1411     erg += b_sn_l(NULL,NULL,h);
1412     C_O_K(h,POLYNOM);
1413 
1414     h2 = &S_L_N(h);
1415         _bt_p1 = (char *)&h2;
1416         _bt_p2 = (char *)NULL;
1417         _bt_p3 = (char *)NULL;
1418     TWALK((S_O_S(a)).ob_charpointer,t_BINTREE_POLYNOM_action);
1419 
1420     if (S_L_N(h) != NULL)
1421         *b = *S_L_N(h);
1422     else
1423         {
1424         erg += b_sn_l(NULL,NULL,b);
1425         C_O_K(b,POLYNOM);
1426         }
1427 
1428     C_O_K(S_L_N(h),EMPTY);
1429     erg += freeall(S_L_N(h));
1430     C_L_N(h,NULL);
1431     FREEALL(h);
1432     ENDR("t_BINTREE_POLYNOM");
1433 }
1434 
1435 
1436 
t_BINTREE_POLYNOM_action(a,type,l)1437 static void t_BINTREE_POLYNOM_action(a,type,l)OP *a;VISIT type;INT l;
1438 /* AK 210891 V1.3 */
1439 {
1440     if ((type==postorder)||  (type==leaf))
1441         {
1442         **(OP**)_bt_p1 = CALLOCOBJECT();
1443         b_sn_po(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
1444         copy_monom(*a,S_L_S(**(OP**)_bt_p1));
1445         *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
1446         }
1447 }
1448 
t_BINTREE_POLYNOM_action_apply(a,type,l)1449 static void t_BINTREE_POLYNOM_action_apply(a,type,l)OP *a;VISIT type;INT l;
1450 /* AK 080199 V2.0 */
1451 {
1452         if ((type==postorder)||  (type==leaf))
1453                 {
1454                 **(OP**)_bt_p1 = CALLOCOBJECT();
1455                 b_sn_po(CALLOCOBJECT(),NULL,**(OP**)_bt_p1);
1456                 swap(*a,S_L_S(**(OP**)_bt_p1));
1457                 *(OP**)_bt_p1 = & S_L_N(**(OP**)_bt_p1);
1458                 }
1459 }
1460 
1461 #endif /* BINTREETRUE */
1462 
1463