1 | #ifndef SIMPLEIDEALS_H |
---|
2 | #define SIMPLEIDEALS_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* |
---|
7 | * ABSTRACT - all basic methods to manipulate ideals |
---|
8 | */ |
---|
9 | #include "polys/monomials/ring.h" |
---|
10 | #include "polys/matpol.h" |
---|
11 | |
---|
12 | /// The following sip_sideal structure has many different uses |
---|
13 | /// thoughout Singular. Basic use-cases for it are: |
---|
14 | /// * ideal/module: nrows = 1, ncols >=0 and rank:1 for ideals, rank>=0 for modules |
---|
15 | /// * matrix: nrows, ncols >=0, rank == nrows! see mp_* procedures |
---|
16 | /// NOTE: the m member point to memory chunk of size (ncols*nrows*sizeof(poly)) or is NULL |
---|
17 | struct sip_sideal |
---|
18 | { |
---|
19 | poly* m; |
---|
20 | long rank; |
---|
21 | int nrows; |
---|
22 | int ncols; |
---|
23 | #define IDELEMS(i) ((i)->ncols) |
---|
24 | }; |
---|
25 | /* the settings of rank, nrows, ncols, m , entries: |
---|
26 | * for IDEAL_CMD: 1 1 n size n poly (n>=0) |
---|
27 | * for MODUL_CMD: r 1 n size n vector of rank<=r (n>=0, r>=0) |
---|
28 | * for MATRIX_CMD r r c size r*c poly (r>=0, c>=0) |
---|
29 | * for MAP_CMD: char* 1 n size n poly (n>=0) |
---|
30 | */ |
---|
31 | |
---|
32 | struct sip_smap |
---|
33 | { |
---|
34 | poly *m; |
---|
35 | char *preimage; |
---|
36 | int nrows; |
---|
37 | int ncols; |
---|
38 | }; |
---|
39 | |
---|
40 | //typedef struct sip_smap * map; |
---|
41 | |
---|
42 | struct sideal_list; |
---|
43 | typedef struct sideal_list * ideal_list; |
---|
44 | |
---|
45 | struct sideal_list |
---|
46 | { |
---|
47 | ideal_list next; |
---|
48 | ideal d; |
---|
49 | #ifdef KDEBUG |
---|
50 | int nr; |
---|
51 | #endif |
---|
52 | }; |
---|
53 | |
---|
54 | EXTERN_VAR omBin sip_sideal_bin; |
---|
55 | |
---|
56 | /// creates an ideal / module |
---|
57 | ideal idInit (int size, int rank=1); |
---|
58 | #define id_Init(s,r,R) idInit(s,r) |
---|
59 | |
---|
60 | /*- deletes an ideal -*/ |
---|
61 | void id_Delete (ideal* h, ring r); |
---|
62 | void id_ShallowDelete (ideal* h, ring r); |
---|
63 | void idSkipZeroes (ideal ide); |
---|
64 | /*gives an ideal the minimal possible size*/ |
---|
65 | |
---|
66 | /// number of non-zero polys in F |
---|
67 | static inline int idElem(const ideal F) |
---|
68 | { |
---|
69 | int i=0; |
---|
70 | for(int j=IDELEMS(F)-1;j>=0;j--) |
---|
71 | { |
---|
72 | if ((F->m)[j]!=NULL) i++; |
---|
73 | } |
---|
74 | return i; |
---|
75 | } |
---|
76 | |
---|
77 | #define id_Elem(F,R) idElem(F) |
---|
78 | |
---|
79 | /// normialize all polys in id |
---|
80 | void id_Normalize(ideal id, const ring r); |
---|
81 | |
---|
82 | int id_MinDegW(ideal M,intvec *w, const ring r); |
---|
83 | |
---|
84 | #ifdef PDEBUG |
---|
85 | void id_DBTest(ideal h1, int level, const char *f,const int l, const ring lR, const ring tR ); |
---|
86 | void id_DBLmTest(ideal h1, int level, const char *f,const int l, const ring r); |
---|
87 | #define id_Test(A, lR) id_DBTest(A, PDEBUG, __FILE__,__LINE__, lR, lR) |
---|
88 | #define id_LmTest(A, lR) id_DBLmTest(A, PDEBUG, __FILE__,__LINE__, lR) |
---|
89 | #else |
---|
90 | #define id_Test(A, lR) do {} while (0) |
---|
91 | #define id_LmTest(A, lR) do {} while (0) |
---|
92 | #endif |
---|
93 | |
---|
94 | ideal id_Copy (ideal h1,const ring r); |
---|
95 | |
---|
96 | /*adds two ideals without simplifying the result*/ |
---|
97 | ideal id_SimpleAdd (ideal h1,ideal h2, const ring r); |
---|
98 | /*adds the quotient ideal*/ |
---|
99 | ideal id_Add (ideal h1,ideal h2,const ring r); |
---|
100 | /* h1 + h2 */ |
---|
101 | |
---|
102 | ideal id_Power(ideal given,int exp, const ring r); |
---|
103 | BOOLEAN idIs0 (ideal h); |
---|
104 | |
---|
105 | long id_RankFreeModule(ideal m, ring lmRing, ring tailRing); |
---|
106 | static inline long id_RankFreeModule(ideal m, ring r) |
---|
107 | {return id_RankFreeModule(m, r, r);} |
---|
108 | |
---|
109 | ideal id_FreeModule (int i, const ring r); |
---|
110 | int idElem(const ideal F); |
---|
111 | int id_PosConstant(ideal id, const ring r); |
---|
112 | ideal id_Head(ideal h,const ring r); |
---|
113 | ideal id_MaxIdeal (const ring r); |
---|
114 | ideal id_MaxIdeal(int deg, const ring r); |
---|
115 | ideal id_CopyFirstK (const ideal ide, const int k,const ring r); |
---|
116 | void id_DelMultiples(ideal id, const ring r); |
---|
117 | void id_Norm(ideal id, const ring r); |
---|
118 | void id_DelEquals(ideal id, const ring r); |
---|
119 | void id_DelLmEquals(ideal id, const ring r); |
---|
120 | void id_DelDiv(ideal id, const ring r); |
---|
121 | BOOLEAN id_IsConstant(ideal id, const ring r); |
---|
122 | |
---|
123 | /// sorts the ideal w.r.t. the actual ringordering |
---|
124 | /// uses lex-ordering when nolex = FALSE |
---|
125 | intvec *id_Sort(const ideal id, const BOOLEAN nolex, const ring r); |
---|
126 | |
---|
127 | /// transpose a module |
---|
128 | ideal id_Transp(ideal a, const ring rRing); |
---|
129 | |
---|
130 | void id_Compactify(ideal id, const ring r); |
---|
131 | ideal id_Mult (ideal h1,ideal h2, const ring r); |
---|
132 | ideal id_Homogen(ideal h, int varnum,const ring r); |
---|
133 | BOOLEAN id_HomIdeal (ideal id, ideal Q, const ring r); |
---|
134 | BOOLEAN id_HomIdealW (ideal id, ideal Q, const intvec *w, const ring r); |
---|
135 | BOOLEAN id_HomModuleW (ideal id, ideal Q, const intvec *w, const intvec *module_w, const ring r); |
---|
136 | BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R); |
---|
137 | BOOLEAN id_IsZeroDim(ideal I, const ring r); |
---|
138 | ideal id_Jet(const ideal i,int d, const ring R); |
---|
139 | ideal id_JetW(const ideal i,int d, intvec * iv, const ring R); |
---|
140 | ideal id_Subst(ideal id, int n, poly e, const ring r); |
---|
141 | matrix id_Module2Matrix(ideal mod, const ring R); |
---|
142 | matrix id_Module2formatedMatrix(ideal mod,int rows, int cols, const ring R); |
---|
143 | ideal id_ResizeModule(ideal mod,int rows, int cols, const ring R); |
---|
144 | ideal id_Matrix2Module(matrix mat, const ring R); |
---|
145 | ideal id_Vec2Ideal(poly vec, const ring R); |
---|
146 | |
---|
147 | int id_ReadOutPivot(ideal arg, int* comp, const ring r); |
---|
148 | |
---|
149 | int binom (int n,int r); |
---|
150 | |
---|
151 | /*- verschiebt die Indizes der Modulerzeugenden um i -*/ |
---|
152 | void idInitChoise (int r,int beg,int end,BOOLEAN *endch,int * choise); |
---|
153 | void idGetNextChoise (int r,int end,BOOLEAN *endch,int * choise); |
---|
154 | int idGetNumberOfChoise(int t, int d, int begin, int end, int * choise); |
---|
155 | |
---|
156 | #ifdef PDEBUG |
---|
157 | void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint = 0); |
---|
158 | #define id_Print(id, lR, tR) idShow(id, lR, tR) |
---|
159 | #else |
---|
160 | #define id_Print(A, lR, tR) do {} while (0) |
---|
161 | #endif |
---|
162 | |
---|
163 | |
---|
164 | |
---|
165 | /// insert h2 into h1 depending on the two boolean parameters: |
---|
166 | /// - if zeroOk is true, then h2 will also be inserted when it is zero |
---|
167 | /// - if duplicateOk is true, then h2 will also be inserted when it is |
---|
168 | /// already present in h1 |
---|
169 | /// return TRUE iff h2 was indeed inserted |
---|
170 | BOOLEAN id_InsertPolyWithTests (ideal h1, const int validEntries, |
---|
171 | const poly h2, const bool zeroOk, |
---|
172 | const bool duplicateOk, const ring r); |
---|
173 | |
---|
174 | |
---|
175 | intvec * id_QHomWeight(ideal id, const ring r); |
---|
176 | |
---|
177 | |
---|
178 | ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r); |
---|
179 | |
---|
180 | void id_Shift(ideal M, int s, const ring r); |
---|
181 | ideal id_Delete_Pos(const ideal I, const int pos, const ring r); |
---|
182 | |
---|
183 | /// for julia: convert an array of poly to vector |
---|
184 | poly id_Array2Vector(poly *m, unsigned n, const ring R); |
---|
185 | #endif |
---|