source: git/libpolys/polys/simpleideals.h

spielwiese
Last change on this file was 4e6b32, checked in by Hans Schoenemann <hannes@…>, 3 months ago
opt: moved id_ReadOutPivot to kernel/ideals.cc
  • Property mode set to 100644
File size: 6.2 KB
Line 
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
17struct 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
32struct sip_smap
33{
34  poly *m;
35  char *preimage;
36  int nrows;
37  int ncols;
38};
39
40//typedef struct sip_smap *         map;
41
42struct sideal_list;
43typedef struct sideal_list *      ideal_list;
44
45struct sideal_list
46{
47  ideal_list next;
48  ideal      d;
49#ifdef KDEBUG
50  int nr;
51#endif
52};
53
54EXTERN_VAR omBin sip_sideal_bin;
55
56/// creates an ideal / module
57ideal idInit (int size, int rank=1);
58#define id_Init(s,r,R) idInit(s,r)
59
60/*- deletes an ideal -*/
61void id_Delete (ideal* h, ring r);
62void id_Delete0 (ideal* h, ring r);
63void id_ShallowDelete (ideal* h, ring r);
64void idSkipZeroes (ideal ide);
65int idSkipZeroes0 (ideal ide);
66  /*gives an ideal the minimal possible size*/
67
68/// number of non-zero polys in F
69static inline int idElem(const ideal F)
70{
71  int i=0;
72  for(int j=IDELEMS(F)-1;j>=0;j--)
73  {
74    if ((F->m)[j]!=NULL) i++;
75  }
76  return i;
77}
78
79#define id_Elem(F,R) idElem(F)
80
81/// normialize all polys in id
82void    id_Normalize(ideal id, const ring r);
83
84int id_MinDegW(ideal M,intvec *w, const ring r);
85
86#ifdef PDEBUG
87void id_DBTest(ideal h1, int level, const char *f,const int l, const ring lR, const ring tR );
88void id_DBLmTest(ideal h1, int level, const char *f,const int l, const ring r);
89#define id_Test(A, lR) id_DBTest(A, PDEBUG, __FILE__,__LINE__, lR, lR)
90#define id_LmTest(A, lR) id_DBLmTest(A, PDEBUG, __FILE__,__LINE__, lR)
91#else
92#define id_Test(A, lR) do {} while (0)
93#define id_LmTest(A, lR) do {} while (0)
94#endif
95
96ideal id_Copy (ideal h1,const ring r);
97
98  /*adds two ideals without simplifying the result*/
99ideal id_SimpleAdd (ideal h1,ideal h2, const ring r);
100  /*adds the quotient ideal*/
101ideal id_Add (ideal h1,ideal h2,const ring r);
102  /* h1 + h2 */
103
104ideal id_Power(ideal given,int exp, const ring r);
105BOOLEAN idIs0 (ideal h);
106
107long id_RankFreeModule(ideal m, ring lmRing, ring tailRing);
108static inline long id_RankFreeModule(ideal m, ring r)
109{return id_RankFreeModule(m, r, r);}
110
111ideal   id_FreeModule (int i, const ring r);
112int     idElem(const ideal F);
113int id_PosConstant(ideal id, const ring r);
114ideal id_Head(ideal h,const ring r);
115ideal id_MaxIdeal (const ring r);
116ideal id_MaxIdeal(int deg, const ring r);
117ideal id_CopyFirstK (const ideal ide, const int k,const ring r);
118void id_DelMultiples(ideal id, const ring r);
119void id_Norm(ideal id, const ring r);
120void id_DelEquals(ideal id, const ring r);
121void id_DelLmEquals(ideal id, const ring r);
122void id_DelDiv(ideal id, const ring r);
123BOOLEAN id_IsConstant(ideal id, const ring r);
124
125/// sorts the ideal w.r.t. the actual ringordering
126/// uses lex-ordering when nolex = FALSE
127intvec *id_Sort(const ideal id, const BOOLEAN nolex, const ring r);
128
129/// transpose a module
130ideal id_Transp(ideal a, const ring rRing);
131
132void id_Compactify(ideal id, const ring r);
133ideal  id_Mult (ideal h1,ideal  h2, const ring r);
134ideal id_Homogen(ideal h, int varnum,const ring r);
135BOOLEAN id_HomIdeal (ideal id, ideal Q, const ring r);
136BOOLEAN id_HomIdealW (ideal id, ideal Q,  const intvec *w, const ring r);
137BOOLEAN id_HomModuleW (ideal id, ideal Q,  const intvec *w, const intvec *module_w, const ring r);
138BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R);
139BOOLEAN id_IsZeroDim(ideal I, const ring r);
140ideal id_Jet(const ideal i,int d, const ring R);
141ideal id_Jet0(const ideal i, const ring R);/*id_Jet(i,0,R)*/
142ideal id_JetW(const ideal i,int d, intvec * iv, const ring R);
143ideal  id_Subst(ideal id, int n, poly e, const ring r);
144matrix id_Module2Matrix(ideal mod, const ring R);
145matrix id_Module2formatedMatrix(ideal mod,int rows, int cols, const ring R);
146ideal id_ResizeModule(ideal mod,int rows, int cols, const ring R);
147ideal id_Matrix2Module(matrix mat, const ring R);
148ideal id_Vec2Ideal(poly vec, const ring R);
149
150int     binom (int n,int r);
151
152  /*- verschiebt die Indizes der Modulerzeugenden um i -*/
153void    idInitChoise (int r,int beg,int end,BOOLEAN *endch,int * choise);
154void    idGetNextChoise (int r,int end,BOOLEAN *endch,int * choise);
155int     idGetNumberOfChoise(int t, int d, int begin, int end, int * choise);
156
157#ifdef PDEBUG
158void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint = 0);
159#define id_Print(id, lR, tR) idShow(id, lR, tR)
160#else
161#define id_Print(A, lR, tR) do {} while (0)
162#endif
163
164
165
166/// insert h2 into h1 depending on the two boolean parameters:
167/// - if zeroOk is true, then h2 will also be inserted when it is zero
168/// - if duplicateOk is true, then h2 will also be inserted when it is
169///   already present in h1
170/// return TRUE iff h2 was indeed inserted
171BOOLEAN id_InsertPolyWithTests (ideal h1, const int validEntries,
172                                const poly h2, const bool zeroOk,
173                                const bool duplicateOk, const ring r);
174
175
176intvec * id_QHomWeight(ideal id, const ring r);
177
178
179ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r);
180
181void id_Shift(ideal M, int s, const ring r);
182ideal id_Delete_Pos(const ideal I, const int pos, const ring r);
183
184/// for julia: convert an array of poly to vector
185poly id_Array2Vector(poly *m, unsigned n, const ring R);
186
187/// mapping ideals/matrices to other rings
188ideal id_PermIdeal(ideal I,int R, int C,const int *perm, const ring src,
189   const ring dst, nMapFunc nMap, const int *par_perm, int P, BOOLEAN use_mult);
190#endif
Note: See TracBrowser for help on using the repository browser.