1 #include "def.h"
2 #include "macro.h"
3 
t_HOMSYM_MONOMIAL(a,b)4 INT t_HOMSYM_MONOMIAL(a,b) OP a,b;
5 /* AK 260901 */
6 /* faster using newmultiplication
7    h_n \times m_I = \sum c_n,I,J m_J
8 */
9 {
10     INT erg = OK;
11     OP m;
12     CTTTTO(HASHTABLE,INTEGER,PARTITION,HOMSYM,"t_HOMSYM_MONOMIAL",a);
13     TCE2(a,b,t_HOMSYM_MONOMIAL,MONOMIAL);
14 
15     m=CALLOCOBJECT();
16     erg += first_partition(cons_null,m);
17     erg += mult_homsym_monomial(a,m,b);
18     FREEALL(m);
19     ENDR("t_HOMSYM_MONOMIAL");
20 }
21 
22 static OP thm_sp = NULL;
23 
thm_ende()24 INT thm_ende()
25 {
26     INT erg = OK;
27     if (thm_sp!= NULL) {
28         FREEALL(thm_sp);
29         thm_sp=NULL;
30         }
31     ENDR("thm_ende");
32 }
33 
34 
thm2_co(a,b,c,f)35 static INT thm2_co(a,b,c,f) OP a,b,c,f;
36 {
37     OP m;
38     INT erg = OK;
39     m = CALLOCOBJECT();
40     b_sk_mo(CALLOCOBJECT(),CALLOCOBJECT(),m);
41     COPY(a,S_MO_S(m));
42     COPY(f,S_MO_K(m));
43     if (S_O_K(c) == HASHTABLE)
44         insert_scalar_hashtable(m,c,add_koeff,eq_monomsymfunc,hash_monompartition);
45     else
46         insert_list(m,c,add_koeff,comp_monommonomial);
47     ENDR("thm2_co");
48 }
49 
find_thm_integer(a)50 OP find_thm_integer(a) OP a;
51 {
52     INT erg = OK;
53     CTO(INTEGER,"find_thm_integer(1)",a);
54     SYMCHECK( (S_I_I(a) < 0) ,"find_thm_integer:parameter <0");
55     if (thm_sp==NULL){ thm_sp=CALLOCOBJECT();m_il_v(100,thm_sp);}
56     if (S_I_I(a)>S_V_LI(thm_sp)) { erg += inc_vector_co(S_I_I(a)-S_V_LI(thm_sp)+30);}
57     if (EMPTYP(S_V_I(thm_sp,S_I_I(a))))
58         {
59         OP c;
60         c = CALLOCOBJECT();
61         first_partition(a,c);
62         init_hashtable(S_V_I(thm_sp,S_I_I(a)));
63         do {
64             OP m;
65             m= CALLOCOBJECT();
66             b_sk_mo(CALLOCOBJECT(),CALLOCOBJECT(),m);
67             M_I_I(1,S_MO_K(m));
68             COPY(c,S_MO_S(m));
69             insert_scalar_hashtable(m,S_V_I(thm_sp,S_I_I(a)),NULL,eq_monomsymfunc,hash_monompartition);
70         } while (next_apply(c));
71 
72         FREEALL(c);
73         }
74 
75     return S_V_I(thm_sp,S_I_I(a));
76 
77     ENDO("find_thm_integer");
78 }
79 
thm_integer__faktor(a,b,f)80 INT thm_integer__faktor(a,b,f) OP a,b,f;
81 {
82     OP c;
83     INT erg = OK;
84     CTTO(HASHTABLE,MONOMIAL,"thm_integer__faktor(2)",b);
85     CTO(INTEGER,"thm_integer__faktor(1)",a);
86     SYMCHECK( (S_I_I(a) < 0) ,"thm_integer__faktor:parameter <0");
87 
88     if (thm_sp==NULL){ thm_sp=CALLOCOBJECT();m_il_v(100,thm_sp);}
89     if (S_I_I(a)>S_V_LI(thm_sp)) { erg += inc_vector_co(S_I_I(a)-S_V_LI(thm_sp)+30);}
90 
91     if (EMPTYP(S_V_I(thm_sp,S_I_I(a))))
92         {
93         c = CALLOCOBJECT();
94         first_partition(a,c);
95         init_hashtable(S_V_I(thm_sp,S_I_I(a)));
96         do {
97             OP m;
98             m= CALLOCOBJECT();
99             b_sk_mo(CALLOCOBJECT(),CALLOCOBJECT(),m);
100             M_I_I(1,S_MO_K(m));
101             COPY(c,S_MO_S(m));
102             insert_scalar_hashtable(m,S_V_I(thm_sp,S_I_I(a)),NULL,eq_monomsymfunc,hash_monompartition);
103         } while (next_apply(c));
104         FREEALL(c);
105         }
106 
107     erg += m_forall_monomials_in_a(S_V_I(thm_sp,S_I_I(a)),cons_eins,b,f,thm2_co);
108 
109     ENDR("thm_integer__factor");
110 }
111 
thm_partition__faktor(a,b,f)112 INT thm_partition__faktor(a,b,f) OP a,b,f;
113 {
114     OP c;
115     INT erg = OK;
116     CTTO(HASHTABLE,MONOMIAL,"thm_partition__faktor(2)",b);
117     CTO(PARTITION,"thm_partition__faktor(1)",a);
118 
119 
120     c = CALLOCOBJECT();
121     erg += first_partition(cons_null,c);
122     erg += mhm_partition__(a,c,b,f);
123     FREEALL(c);
124 
125     ENDR("thm_partition__factor");
126 }
127 
128