My Project
Loading...
Searching...
No Matches
Macros | Functions
ringgb.cc File Reference
#include "kernel/mod2.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/structs.h"
#include "kernel/polys.h"
#include "polys/monomials/p_polys.h"
#include "kernel/ideals.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/khstd.h"
#include "polys/kbuckets.h"
#include "polys/weight.h"
#include "misc/intvec.h"
#include "polys/nc/nc.h"
#include "kernel/GBEngine/ringgb.h"

Go to the source code of this file.

Macros

#define NO_BUCKETS
 

Functions

poly reduce_poly_fct (poly p, ring r)
 
int indexOf2 (number n)
 
BOOLEAN ring2toM_GetLeadTerms (const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
 
void printPolyMsg (const char *start, poly f, const char *end)
 
poly spolyRing2toM (poly f, poly g, ring r)
 
poly ringRedNF (poly f, ideal G, ring r)
 
int findRingSolver (poly rside, ideal G, ring r)
 
poly plain_spoly (poly f, poly g)
 
poly plain_zero_spoly (poly h)
 
poly ringNF (poly f, ideal G, ring r)
 
int testGB (ideal I, ideal GI)
 

Macro Definition Documentation

◆ NO_BUCKETS

#define NO_BUCKETS

Definition at line 8 of file ringgb.cc.

Function Documentation

◆ findRingSolver()

int findRingSolver ( poly  rside,
ideal  G,
ring  r 
)

Definition at line 152 of file ringgb.cc.

153{
154 if (rside == NULL) return -1;
155 int i;
156// int iO2rside = indexOf2(pGetCoeff(rside));
157 for (i = 0; i < IDELEMS(G); i++)
158 {
159 if // (indexOf2(pGetCoeff(G->m[i])) <= iO2rside && / should not be necessary any more
160 (p_LmDivisibleBy(G->m[i], rside, r))
161 {
162 return i;
163 }
164 }
165 return -1;
166}
int i
Definition: cfEzgcd.cc:132
STATIC_VAR TreeM * G
Definition: janet.cc:31
#define NULL
Definition: omList.c:12
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1889
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ indexOf2()

int indexOf2 ( number  n)

Definition at line 38 of file ringgb.cc.

39{
40 long test = (long) n;
41 int i = 0;
42 while (test%2 == 0)
43 {
44 i++;
45 test = test / 2;
46 }
47 return i;
48}
CanonicalForm test
Definition: cfModGcd.cc:4096

◆ plain_spoly()

poly plain_spoly ( poly  f,
poly  g 
)

Definition at line 168 of file ringgb.cc.

169{
170 number cf = nCopy(pGetCoeff(f)), cg = nCopy(pGetCoeff(g));
171 (void)ksCheckCoeff(&cf, &cg, currRing->cf); // gcd and zero divisors
172 poly fm, gm;
173 k_GetLeadTerms(f, g, currRing, fm, gm, currRing);
174 pSetCoeff0(fm, cg);
175 pSetCoeff0(gm, cf); // and now, m1 * LT(p1) == m2 * LT(p2)
176 poly sp = pSub(ppMult_mm(f, fm), ppMult_mm(g, gm));
177 pDelete(&fm);
178 pDelete(&gm);
179 return(sp);
180}
g
Definition: cfModGcd.cc:4090
CanonicalForm cf
Definition: cfModGcd.cc:4083
CanonicalForm cg
Definition: cfModGcd.cc:4083
FILE * f
Definition: checklibs.c:9
KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
Definition: kInline.h:1018
int ksCheckCoeff(number *a, number *b, const coeffs r)
Definition: kbuckets.cc:1504
#define pSetCoeff0(p, n)
Definition: monomials.h:59
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
#define nCopy(n)
Definition: numbers.h:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define pDelete(p_ptr)
Definition: polys.h:186
#define ppMult_mm(p, m)
Definition: polys.h:201
#define pSub(a, b)
Definition: polys.h:287

◆ plain_zero_spoly()

poly plain_zero_spoly ( poly  h)

Definition at line 185 of file ringgb.cc.

186{
187 poly p = NULL;
188 number zero=n_Init(0,currRing->cf);
189 number gcd = n_Gcd(zero, pGetCoeff(h), currRing->cf);
190 if (!n_IsOne( gcd, currRing->cf ))
191 {
192 number tmp=n_Ann(gcd,currRing->cf);
193 p = p_Copy(h->next, currRing);
194 p = __p_Mult_nn(p, tmp, currRing);
195 n_Delete(&tmp,currRing->cf);
196 }
197 n_Delete(&zero,currRing->cf);
198 return p;
199}
int p
Definition: cfModGcd.cc:4078
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition: coeffs.h:661
static FORCE_INLINE number n_Ann(number a, const coeffs r)
if r is a ring with zero divisors, return an annihilator!=0 of b otherwise return NULL
Definition: coeffs.h:676
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:535
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:465
STATIC_VAR Poly * h
Definition: janet.cc:971
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:844
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:969
int gcd(int a, int b)
Definition: walkSupport.cc:836

◆ printPolyMsg()

void printPolyMsg ( const char *  start,
poly  f,
const char *  end 
)

Definition at line 96 of file ringgb.cc.

97{
98 PrintS(start);
99 wrp(f);
100 PrintS(end);
101}
void wrp(poly p)
Definition: polys.h:310
void PrintS(const char *s)
Definition: reporter.cc:284

◆ reduce_poly_fct()

poly reduce_poly_fct ( poly  p,
ring  r 
)

Definition at line 29 of file ringgb.cc.

30{
31 return kFindZeroPoly(p, r, r);
32}
poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing)
Definition: kstd2.cc:569

◆ ring2toM_GetLeadTerms()

BOOLEAN ring2toM_GetLeadTerms ( const poly  p1,
const poly  p2,
const ring  p_r,
poly &  m1,
poly &  m2,
const ring  m_r 
)

Definition at line 57 of file ringgb.cc.

59{
60 int i;
61 int x;
62 m1 = p_Init(m_r);
63 m2 = p_Init(m_r);
64
65 for (i = p_r->N; i; i--)
66 {
67 x = p_GetExpDiff(p1, p2, i, p_r);
68 if (x > 0)
69 {
70 p_SetExp(m2,i,x, m_r);
71 p_SetExp(m1,i,0, m_r);
72 }
73 else
74 {
75 p_SetExp(m1,i,-x, m_r);
76 p_SetExp(m2,i,0, m_r);
77 }
78 }
79 p_Setm(m1, m_r);
80 p_Setm(m2, m_r);
81 long cp1 = (long) pGetCoeff(p1);
82 long cp2 = (long) pGetCoeff(p2);
83 if (cp1 != 0 && cp2 != 0)
84 {
85 while (cp1%2 == 0 && cp2%2 == 0)
86 {
87 cp1 = cp1 / 2;
88 cp2 = cp2 / 2;
89 }
90 }
91 p_SetCoeff(m1, (number) cp2, m_r);
92 p_SetCoeff(m2, (number) cp1, m_r);
93 return TRUE;
94}
#define TRUE
Definition: auxiliary.h:100
Variable x
Definition: cfModGcd.cc:4082
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:633
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:486
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:410
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1318

◆ ringNF()

poly ringNF ( poly  f,
ideal  G,
ring  r 
)

Definition at line 201 of file ringgb.cc.

202{
203 // If f = 0, then normal form is also 0
204 if (f == NULL) { return NULL; }
205 poly tmp = NULL;
206 poly h = pCopy(f);
207 int i = findRingSolver(h, G, r);
208 int c = 1;
209 while (h != NULL && i >= 0) {
210// Print("%d-step NF - h:", c);
211// wrp(h);
212// PrintS(" ");
213// PrintS("G->m[i]:");
214// wrp(G->m[i]);
215// PrintLn();
216 tmp = h;
217 h = plain_spoly(h, G->m[i]);
218 pDelete(&tmp);
219// PrintS("=> h=");
220// wrp(h);
221// PrintLn();
222 i = findRingSolver(h, G, r);
223 c++;
224 }
225 return h;
226}
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
int findRingSolver(poly rside, ideal G, ring r)
Definition: ringgb.cc:152
poly plain_spoly(poly f, poly g)
Definition: ringgb.cc:168

◆ ringRedNF()

poly ringRedNF ( poly  f,
ideal  G,
ring  r 
)

Definition at line 117 of file ringgb.cc.

118{
119 // If f = 0, then normal form is also 0
120 if (f == NULL) { return NULL; }
121 poly h = NULL;
122 poly g = pCopy(f);
123 int c = 0;
124 while (g != NULL)
125 {
126 Print("%d-step RedNF - g=", c);
127 wrp(g);
128 PrintS(" | h=");
129 wrp(h);
130 PrintLn();
131 g = ringNF(g, G, r);
132 if (g != NULL) {
133 h = pAdd(h, pHead(g));
134 pLmDelete(&g);
135 }
136 c++;
137 }
138 return h;
139}
#define Print
Definition: emacs.cc:80
#define pAdd(p, q)
Definition: polys.h:203
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:67
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition: polys.h:76
void PrintLn()
Definition: reporter.cc:310
poly ringNF(poly f, ideal G, ring r)
Definition: ringgb.cc:201

◆ spolyRing2toM()

poly spolyRing2toM ( poly  f,
poly  g,
ring  r 
)

Definition at line 103 of file ringgb.cc.

104{
105 poly m1 = NULL;
106 poly m2 = NULL;
107 ring2toM_GetLeadTerms(f, g, r, m1, m2, r);
108 // printPolyMsg("spoly: m1=", m1, " | ");
109 // printPolyMsg("m2=", m2, "");
110 // PrintLn();
111 poly sp = pSub(p_Mult_mm(f, m1, r), pp_Mult_mm(g, m2, r));
112 pDelete(&m1);
113 pDelete(&m2);
114 return(sp);
115}
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1029
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1049
BOOLEAN ring2toM_GetLeadTerms(const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
Definition: ringgb.cc:57

◆ testGB()

int testGB ( ideal  I,
ideal  GI 
)

Definition at line 228 of file ringgb.cc.

228 {
229 poly f, g, h, nf;
230 int i = 0;
231 int j = 0;
232 PrintS("I included?");
233 for (i = 0; i < IDELEMS(I); i++) {
234 if (ringNF(I->m[i], GI, currRing) != NULL) {
235 PrintS("Not reduced to zero from I: ");
236 wrp(I->m[i]);
237 PrintS(" --> ");
238 wrp(ringNF(I->m[i], GI, currRing));
239 PrintLn();
240 return(0);
241 }
242 PrintS("-");
243 }
244 PrintS(" Yes!\nspoly --> 0?");
245 for (i = 0; i < IDELEMS(GI); i++)
246 {
247 for (j = i + 1; j < IDELEMS(GI); j++)
248 {
249 f = pCopy(GI->m[i]);
250 g = pCopy(GI->m[j]);
251 h = plain_spoly(f, g);
252 nf = ringNF(h, GI, currRing);
253 if (nf != NULL)
254 {
255 PrintS("spoly(");
256 wrp(GI->m[i]);
257 PrintS(", ");
258 wrp(GI->m[j]);
259 PrintS(") = ");
260 wrp(h);
261 PrintS(" --> ");
262 wrp(nf);
263 PrintLn();
264 return(0);
265 }
266 pDelete(&f);
267 pDelete(&g);
268 pDelete(&h);
269 pDelete(&nf);
270 PrintS("-");
271 }
272 }
274 {
275 PrintS(" Yes!\nzero-spoly --> 0?");
276 for (i = 0; i < IDELEMS(GI); i++)
277 {
278 f = plain_zero_spoly(GI->m[i]);
279 nf = ringNF(f, GI, currRing);
280 if (nf != NULL) {
281 PrintS("spoly(");
282 wrp(GI->m[i]);
283 PrintS(", ");
284 wrp(0);
285 PrintS(") = ");
286 wrp(h);
287 PrintS(" --> ");
288 wrp(nf);
289 PrintLn();
290 return(0);
291 }
292 pDelete(&f);
293 pDelete(&nf);
294 PrintS("-");
295 }
296 }
297 PrintS(" Yes!");
298 PrintLn();
299 return(1);
300}
int j
Definition: facHensel.cc:110
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:487
poly plain_zero_spoly(poly h)
Definition: ringgb.cc:185
Definition: gnumpfl.cc:25