My Project
simpleideals.h
Go to the documentation of this file.
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 
46 {
47  ideal_list next;
48  ideal d;
49 #ifdef KDEBUG
50  int nr;
51 #endif
52 };
53 
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 int idElem(const ideal F);
68 #define id_Elem(F,R) idElem(F)
69 
70 /// normialize all polys in id
71 void id_Normalize(ideal id, const ring r);
72 
73 int id_MinDegW(ideal M,intvec *w, const ring r);
74 
75 #ifdef PDEBUG
76 void id_DBTest(ideal h1, int level, const char *f,const int l, const ring lR, const ring tR );
77 void id_DBLmTest(ideal h1, int level, const char *f,const int l, const ring r);
78 #define id_Test(A, lR) id_DBTest(A, PDEBUG, __FILE__,__LINE__, lR, lR)
79 #define id_LmTest(A, lR) id_DBLmTest(A, PDEBUG, __FILE__,__LINE__, lR)
80 #else
81 #define id_Test(A, lR) do {} while (0)
82 #define id_LmTest(A, lR) do {} while (0)
83 #endif
84 
85 ideal id_Copy (ideal h1,const ring r);
86 
87  /*adds two ideals without simplifying the result*/
88 ideal id_SimpleAdd (ideal h1,ideal h2, const ring r);
89  /*adds the quotient ideal*/
90 ideal id_Add (ideal h1,ideal h2,const ring r);
91  /* h1 + h2 */
92 
93 ideal id_Power(ideal given,int exp, const ring r);
94 BOOLEAN idIs0 (ideal h);
95 
96 long id_RankFreeModule(ideal m, ring lmRing, ring tailRing);
97 static inline long id_RankFreeModule(ideal m, ring r)
98 {return id_RankFreeModule(m, r, r);}
99 
100 ideal id_FreeModule (int i, const ring r);
101 int idElem(const ideal F);
102 int id_PosConstant(ideal id, const ring r);
103 ideal id_Head(ideal h,const ring r);
104 ideal id_MaxIdeal (const ring r);
105 ideal id_MaxIdeal(int deg, const ring r);
106 ideal id_CopyFirstK (const ideal ide, const int k,const ring r);
107 void id_DelMultiples(ideal id, const ring r);
108 void id_Norm(ideal id, const ring r);
109 void id_DelEquals(ideal id, const ring r);
110 void id_DelLmEquals(ideal id, const ring r);
111 void id_DelDiv(ideal id, const ring r);
112 void id_DelDiv_Sorted(ideal id, const ring r);
113 BOOLEAN id_IsConstant(ideal id, const ring r);
114 
115 /// sorts the ideal w.r.t. the actual ringordering
116 /// uses lex-ordering when nolex = FALSE
117 intvec *id_Sort(const ideal id, const BOOLEAN nolex, const ring r);
118 
119 /// transpose a module
120 ideal id_Transp(ideal a, const ring rRing);
121 
122 void id_Compactify(ideal id, const ring r);
123 ideal id_Mult (ideal h1,ideal h2, const ring r);
124 ideal id_Homogen(ideal h, int varnum,const ring r);
125 BOOLEAN id_HomIdeal (ideal id, ideal Q, const ring r);
126 BOOLEAN id_HomIdealW (ideal id, ideal Q, const intvec *w, const ring r);
127 BOOLEAN id_HomModuleW (ideal id, ideal Q, const intvec *w, const intvec *module_w, const ring r);
128 BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R);
129 BOOLEAN id_IsZeroDim(ideal I, const ring r);
130 ideal id_Jet(const ideal i,int d, const ring R);
131 ideal id_JetW(const ideal i,int d, intvec * iv, const ring R);
132 ideal id_Subst(ideal id, int n, poly e, const ring r);
133 matrix id_Module2Matrix(ideal mod, const ring R);
134 matrix id_Module2formatedMatrix(ideal mod,int rows, int cols, const ring R);
135 ideal id_ResizeModule(ideal mod,int rows, int cols, const ring R);
136 ideal id_Matrix2Module(matrix mat, const ring R);
137 ideal id_Vec2Ideal(poly vec, const ring R);
138 
139 int id_ReadOutPivot(ideal arg, int* comp, const ring r);
140 
141 int binom (int n,int r);
142 
143  /*- verschiebt die Indizes der Modulerzeugenden um i -*/
144 void idInitChoise (int r,int beg,int end,BOOLEAN *endch,int * choise);
145 void idGetNextChoise (int r,int end,BOOLEAN *endch,int * choise);
146 int idGetNumberOfChoise(int t, int d, int begin, int end, int * choise);
147 
148 #ifdef PDEBUG
149 void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint = 0);
150 #define id_Print(id, lR, tR) idShow(id, lR, tR)
151 #else
152 #define id_Print(A, lR, tR) do {} while (0)
153 #endif
154 
155 
156 
157 /// insert h2 into h1 depending on the two boolean parameters:
158 /// - if zeroOk is true, then h2 will also be inserted when it is zero
159 /// - if duplicateOk is true, then h2 will also be inserted when it is
160 /// already present in h1
161 /// return TRUE iff h2 was indeed inserted
162 BOOLEAN id_InsertPolyWithTests (ideal h1, const int validEntries,
163  const poly h2, const bool zeroOk,
164  const bool duplicateOk, const ring r);
165 
166 
167 intvec * id_QHomWeight(ideal id, const ring r);
168 
169 
170 ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r);
171 
172 void id_Shift(ideal M, int s, const ring r);
173 ideal id_Delete_Pos(const ideal I, const int pos, const ring r);
174 
175 /// for julia: convert an array of poly to vector
176 poly id_Array2Vector(poly *m, unsigned n, const ring R);
177 #endif
int BOOLEAN
Definition: auxiliary.h:87
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
int level(const CanonicalForm &f)
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
FILE * f
Definition: checklibs.c:9
Definition: intvec.h:23
const CanonicalForm int s
Definition: facAbsFact.cc:51
const CanonicalForm & w
Definition: facAbsFact.cc:51
fq_nmod_poly_t * vec
Definition: facHensel.cc:108
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#define EXTERN_VAR
Definition: globaldefs.h:6
STATIC_VAR Poly * h
Definition: janet.cc:971
STATIC_VAR jList * Q
Definition: janet.cc:30
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
omBin_t * omBin
Definition: omStructs.h:12
ideal idInit(int size, int rank=1)
creates an ideal / module
Definition: simpleideals.cc:35
void id_DBLmTest(ideal h1, int level, const char *f, const int l, const ring r)
Internal verification for ideals/modules and dense matrices!
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
ideal id_Vec2Ideal(poly vec, const ring R)
int id_PosConstant(ideal id, const ring r)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: simpleideals.cc:80
int binom(int n, int r)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
poly id_Array2Vector(poly *m, unsigned n, const ring R)
for julia: convert an array of poly to vector
ideal_list next
Definition: simpleideals.h:47
void id_DelDiv_Sorted(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) (j>i)
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint=0)
Definition: simpleideals.cc:57
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
intvec * id_QHomWeight(ideal id, const ring r)
BOOLEAN id_HomModuleW(ideal id, ideal Q, const intvec *w, const intvec *module_w, const ring r)
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
ideal id_Transp(ideal a, const ring rRing)
transpose a module
ideal id_FreeModule(int i, const ring r)
the free module of rank i
BOOLEAN id_IsZeroDim(ideal I, const ring r)
ideal id_Homogen(ideal h, int varnum, const ring r)
ideal id_Power(ideal given, int exp, const ring r)
matrix id_Module2Matrix(ideal mod, const ring R)
void id_Normalize(ideal id, const ring r)
normialize all polys in id
int idElem(const ideal F)
number of non-zero polys in F
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
ideal id_Copy(ideal h1, const ring r)
copy an ideal
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
BOOLEAN id_HomIdealW(ideal id, ideal Q, const intvec *w, const ring r)
int id_ReadOutPivot(ideal arg, int *comp, const ring r)
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
Definition: simpleideals.cc:98
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
int id_MinDegW(ideal M, intvec *w, const ring r)
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
void id_ShallowDelete(ideal *h, ring r)
Shallowdeletes an ideal/matrix.
BOOLEAN id_InsertPolyWithTests(ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk, const ring r)
insert h2 into h1 depending on the two boolean parameters:
poly * m
Definition: simpleideals.h:19
void id_DBTest(ideal h1, int level, const char *f, const int l, const ring lR, const ring tR)
Internal verification for ideals/modules and dense matrices!
ideal id_CopyFirstK(const ideal ide, const int k, const ring r)
copies the first k (>= 1) entries of the given ideal/module and returns these as a new ideal/module (...
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
ideal id_ResizeModule(ideal mod, int rows, int cols, const ring R)
poly * m
Definition: simpleideals.h:34
EXTERN_VAR omBin sip_sideal_bin
Definition: simpleideals.h:54
char * preimage
Definition: simpleideals.h:35
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
ideal id_Jet(const ideal i, int d, const ring R)
ideal id_Mult(ideal h1, ideal h2, const ring r)
h1 * h2 one h_i must be an ideal (with at least one column) the other h_i may be a module (with no co...
ideal id_Delete_Pos(const ideal I, const int pos, const ring r)
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
ideal id_JetW(const ideal i, int d, intvec *iv, const ring R)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void id_Shift(ideal M, int s, const ring r)
int idGetNumberOfChoise(int t, int d, int begin, int end, int *choise)
intvec * id_Sort(const ideal id, const BOOLEAN nolex, const ring r)
sorts the ideal w.r.t. the actual ringordering uses lex-ordering when nolex = FALSE
long id_RankFreeModule(ideal m, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
ideal id_SimpleAdd(ideal h1, ideal h2, const ring r)
concat the lists h1 and h2 without zeros
void id_Compactify(ideal id, const ring r)
BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R)
ideal id_Subst(ideal id, int n, poly e, const ring r)
The following sip_sideal structure has many different uses thoughout Singular. Basic use-cases for it...
Definition: simpleideals.h:18
#define R
Definition: sirandom.c:27
#define M
Definition: sirandom.c:25