My Project
Loading...
Searching...
No Matches
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 147 of file ringgb.cc.

148{
149 if (rside == NULL) return -1;
150 int i;
151// int iO2rside = indexOf2(pGetCoeff(rside));
152 for (i = 0; i < IDELEMS(G); i++)
153 {
154 if // (indexOf2(pGetCoeff(G->m[i])) <= iO2rside && / should not be necessary any more
155 (p_LmDivisibleBy(G->m[i], rside, r))
156 {
157 return i;
158 }
159 }
160 return -1;
161}
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:1907
#define IDELEMS(i)

◆ indexOf2()

int indexOf2 ( number n)

Definition at line 37 of file ringgb.cc.

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

◆ plain_spoly()

poly plain_spoly ( poly f,
poly g )

Definition at line 163 of file ringgb.cc.

164{
165 number cf = nCopy(pGetCoeff(f)), cg = nCopy(pGetCoeff(g));
166 (void)ksCheckCoeff(&cf, &cg, currRing->cf); // gcd and zero divisors
167 poly fm, gm;
168 k_GetLeadTerms(f, g, currRing, fm, gm, currRing);
169 pSetCoeff0(fm, cg);
170 pSetCoeff0(gm, cf); // and now, m1 * LT(p1) == m2 * LT(p2)
171 poly sp = pSub(ppMult_mm(f, fm), ppMult_mm(g, gm));
172 pDelete(&fm);
173 pDelete(&gm);
174 return(sp);
175}
g
Definition cfModGcd.cc:4098
CanonicalForm cf
Definition cfModGcd.cc:4091
CanonicalForm cg
Definition cfModGcd.cc:4091
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:1015
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:187
#define ppMult_mm(p, m)
Definition polys.h:202
#define pSub(a, b)
Definition polys.h:288

◆ plain_zero_spoly()

poly plain_zero_spoly ( poly h)

Definition at line 180 of file ringgb.cc.

181{
182 poly p = NULL;
183 number zero=n_Init(0,currRing->cf);
184 number gcd = n_Gcd(zero, pGetCoeff(h), currRing->cf);
185 if (!n_IsOne( gcd, currRing->cf ))
186 {
187 number tmp=n_Ann(gcd,currRing->cf);
188 p = p_Copy(h->next, currRing);
189 p = __p_Mult_nn(p, tmp, currRing);
190 n_Delete(&tmp,currRing->cf);
191 }
192 n_Delete(&zero,currRing->cf);
193 return p;
194}
int p
Definition cfModGcd.cc:4086
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:665
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:680
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
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:539
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:472
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:848
#define __p_Mult_nn(p, n, r)
Definition p_polys.h:973
int gcd(int a, int b)

◆ printPolyMsg()

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

Definition at line 95 of file ringgb.cc.

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

◆ reduce_poly_fct()

poly reduce_poly_fct ( poly p,
ring r )

Definition at line 28 of file ringgb.cc.

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

◆ 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 56 of file ringgb.cc.

58{
59 int i;
60 int x;
61 m1 = p_Init(m_r);
62 m2 = p_Init(m_r);
63
64 for (i = p_r->N; i; i--)
65 {
66 x = p_GetExpDiff(p1, p2, i, p_r);
67 if (x > 0)
68 {
69 p_SetExp(m2,i,x, m_r);
70 p_SetExp(m1,i,0, m_r);
71 }
72 else
73 {
74 p_SetExp(m1,i,-x, m_r);
75 p_SetExp(m2,i,0, m_r);
76 }
77 }
78 p_Setm(m1, m_r);
79 p_Setm(m2, m_r);
80 long cp1 = (long) pGetCoeff(p1);
81 long cp2 = (long) pGetCoeff(p2);
82 if (cp1 != 0 && cp2 != 0)
83 {
84 while (cp1%2 == 0 && cp2%2 == 0)
85 {
86 cp1 = cp1 / 2;
87 cp2 = cp2 / 2;
88 }
89 }
90 p_SetCoeff(m1, (number) cp2, m_r);
91 p_SetCoeff(m2, (number) cp1, m_r);
92 return TRUE;
93}
#define TRUE
Definition auxiliary.h:101
Variable x
Definition cfModGcd.cc:4090
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition p_polys.h:637
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:490
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1336

◆ ringNF()

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

Definition at line 196 of file ringgb.cc.

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

◆ ringRedNF()

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

Definition at line 116 of file ringgb.cc.

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

◆ spolyRing2toM()

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

Definition at line 102 of file ringgb.cc.

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

◆ testGB()

int testGB ( ideal I,
ideal GI )

Definition at line 223 of file ringgb.cc.

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