My Project  debian-1:4.1.1-p2+ds-4build2
Functions | Variables
polys.cc File Reference
#include "kernel/mod2.h"
#include "omalloc/omalloc.h"
#include "misc/options.h"
#include "polys.h"
#include "kernel/ideals.h"
#include "polys/clapsing.h"

Go to the source code of this file.

Functions

void rChangeCurrRing (ring r)
 
poly p_Divide (poly p, poly q, const ring r)
 polynomial division, ignoring the rest via singclap_pdiive resp. idLift destroyes a,b More...
 

Variables

ring currRing = NULL
 Widely used global variable which specifies the current polynomial ring for Singular interpreter and legacy implementatins. @Note: one should avoid using it in newer designs, for example due to possible problems in parallelization with threads. More...
 

Function Documentation

◆ p_Divide()

poly p_Divide ( poly  p,
poly  q,
const ring  r 
)

polynomial division, ignoring the rest via singclap_pdiive resp. idLift destroyes a,b

Definition at line 31 of file polys.cc.

32 {
33  assume(q!=NULL);
34  if (q==NULL)
35  {
36  WerrorS("div. by 0");
37  return NULL;
38  }
39  if (p==NULL)
40  {
41  p_Delete(&q,r);
42  return NULL;
43  }
44  if (pNext(q)!=NULL)
45  { /* This means that q != 0 consists of at least two terms*/
46  if(p_GetComp(p,r)==0)
47  {
48  if ((r->cf->convSingNFactoryN!=ndConvSingNFactoryN)
49  &&(!rField_is_Ring(r)))
50  {
51  poly res=singclap_pdivide(p, q, r);
52  p_Delete(&p,r);
53  p_Delete(&q,r);
54  return res;
55  }
56  else
57  {
58  ideal vi=idInit(1,1); vi->m[0]=q;
59  ideal ui=idInit(1,1); ui->m[0]=p;
60  ideal R; matrix U;
61  ring save_ring=currRing;
62  if (r!=currRing) rChangeCurrRing(r);
63  int save_opt;
64  SI_SAVE_OPT1(save_opt);
65  si_opt_1 &= ~(Sy_bit(OPT_PROT));
66  ideal m = idLift(vi,ui,&R, FALSE,TRUE,TRUE,&U);
67  SI_RESTORE_OPT1(save_opt);
68  if (r!=save_ring) rChangeCurrRing(save_ring);
70  p=MATELEM(T,1,1); MATELEM(T,1,1)=NULL;
71  id_Delete((ideal *)&T,r);
72  id_Delete((ideal *)&U,r);
73  id_Delete(&R,r);
74  //vi->m[0]=NULL; ui->m[0]=NULL;
75  id_Delete(&vi,r);
76  id_Delete(&ui,r);
77  return p;
78  }
79  }
80  else
81  {
82  int comps=p_MaxComp(p,r);
83  ideal I=idInit(comps,1);
84  poly h;
85  int i;
86  // conversion to a list of polys:
87  while (p!=NULL)
88  {
89  i=p_GetComp(p,r)-1;
90  h=pNext(p);
91  pNext(p)=NULL;
92  p_SetComp(p,0,r);
93  I->m[i]=p_Add_q(I->m[i],p,r);
94  p=h;
95  }
96  // division and conversion to vector:
97  h=NULL;
98  p=NULL;
99  for(i=comps-1;i>=0;i--)
100  {
101  if (I->m[i]!=NULL)
102  {
103  if ((r->cf->convSingNFactoryN!=ndConvSingNFactoryN)
104  &&(!rField_is_Ring(r)))
105  h=singclap_pdivide(I->m[i],q,r);
106  else
107  {
108  ideal vi=idInit(1,1); vi->m[0]=q;
109  ideal ui=idInit(1,1); ui->m[0]=I->m[i];
110  ideal R; matrix U;
111  ring save_ring=currRing;
112  if (r!=currRing) rChangeCurrRing(r);
113  int save_opt;
114  SI_SAVE_OPT1(save_opt);
115  si_opt_1 &= ~(Sy_bit(OPT_PROT));
116  ideal m = idLift(vi,ui,&R, FALSE,TRUE,TRUE,&U);
117  SI_RESTORE_OPT1(save_opt);
118  if (r!=save_ring) rChangeCurrRing(save_ring);
120  h=MATELEM(T,1,1); MATELEM(T,1,1)=NULL;
121  id_Delete((ideal*)&T,r);
122  id_Delete((ideal*)&U,r);
123  id_Delete(&R,r);
124  vi->m[0]=NULL; ui->m[0]=NULL;
125  id_Delete(&vi,r);
126  id_Delete(&ui,r);
127  }
128  p_SetCompP(h,i+1,r);
129  p=p_Add_q(p,h,r);
130  }
131  }
132  id_Delete(&I,r);
133  p_Delete(&q,r);
134  return p;
135  }
136  }
137  else
138  { /* This means that q != 0 consists of just one term,
139  or that currRing is over a coefficient ring. */
140 #ifdef HAVE_RINGS
142  {
143  WerrorS("division only defined over coefficient domains");
144  return NULL;
145  }
146  if (pNext(q)!=NULL)
147  {
148  WerrorS("division over a coefficient domain only implemented for terms");
149  return NULL;
150  }
151 #endif
152  return p_DivideM(p,q,r);
153  }
154  return FALSE;
155 }

◆ rChangeCurrRing()

void rChangeCurrRing ( ring  r)

Definition at line 15 of file polys.cc.

16 {
17  //------------ set global ring vars --------------------------------
18  currRing = r;
19  if( r != NULL )
20  {
21  rTest(r);
22  //------------ global variables related to coefficients ------------
23  assume( r->cf!= NULL );
24  nSetChar(r->cf);
25  //------------ global variables related to polys
26  p_SetGlobals(r); // also setting TEST_RINGDEP_OPTS
27  //------------ global variables related to factory -----------------
28  }
29 }

Variable Documentation

◆ currRing

ring currRing = NULL

Widely used global variable which specifies the current polynomial ring for Singular interpreter and legacy implementatins. @Note: one should avoid using it in newer designs, for example due to possible problems in parallelization with threads.

Definition at line 13 of file polys.cc.

FALSE
#define FALSE
Definition: auxiliary.h:94
idLift
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
Definition: ideals.cc:1113
p_GetComp
#define p_GetComp(p, r)
Definition: monomials.h:71
ip_smatrix
Definition: matpol.h:14
nSetChar
static FORCE_INLINE void nSetChar(const coeffs r)
initialisations after each ring change
Definition: coeffs.h:437
MATELEM
#define MATELEM(mat, i, j)
Definition: matpol.h:30
rField_is_Domain
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:480
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition: polys.cc:15
p_SetCompP
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:254
singclap_pdivide
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:577
SI_SAVE_OPT1
#define SI_SAVE_OPT1(A)
Definition: options.h:22
rTest
#define rTest(r)
Definition: ring.h:777
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:114
res
CanonicalForm res
Definition: facAbsFact.cc:64
Sy_bit
#define Sy_bit(x)
Definition: options.h:32
p_SetGlobals
void p_SetGlobals(const ring r, BOOLEAN complete)
set all properties of a new ring - also called by rComplete
Definition: ring.cc:3316
T
static jList * T
Definition: janet.cc:31
rField_is_Ring
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
p_DivideM
poly p_DivideM(poly a, poly b, const ring r)
Definition: p_polys.cc:1540
h
static Poly * h
Definition: janet.cc:972
p_Delete
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
m
int m
Definition: cfEzgcd.cc:121
assume
#define assume(x)
Definition: mod2.h:390
NULL
#define NULL
Definition: omList.c:10
p_SetComp
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
R
#define R
Definition: sirandom.c:26
p
int p
Definition: cfModGcd.cc:4019
ndConvSingNFactoryN
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition: numbers.cc:272
SI_RESTORE_OPT1
#define SI_RESTORE_OPT1(A)
Definition: options.h:25
id_Module2formatedMatrix
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
Definition: simpleideals.cc:1247
p_MaxComp
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:292
pNext
#define pNext(p)
Definition: monomials.h:43
OPT_PROT
#define OPT_PROT
Definition: options.h:74
si_opt_1
unsigned si_opt_1
Definition: options.c:5