MCPcopy Create free account
hub / github.com/Singular/Singular / p_Divide

Function p_Divide

kernel/polys.cc:31–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31poly p_Divide(poly p, poly q, const ring r)
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)||rIsPluralRing(r))
45 { /* This means that q != 0 consists of at least two terms*/
46 if(p_GetComp(p,r)==0)
47 {
48 if((rFieldType(r)==n_transExt)
49 &&(convSingTrP(p,r))
50 &&(convSingTrP(q,r))
51 &&(!rIsNCRing(r)))
52 {
53 poly res=singclap_pdivide(p, q, r);
54 p_Delete(&p,r);
55 p_Delete(&q,r);
56 return res;
57 }
58 else if ((r->cf->convSingNFactoryN!=ndConvSingNFactoryN)
59 &&(!rField_is_Ring(r))
60 &&(!rIsNCRing(r)))
61 {
62 poly res=singclap_pdivide(p, q, r);
63 p_Delete(&p,r);
64 p_Delete(&q,r);
65 return res;
66 }
67 else
68 {
69 ideal vi=idInit(1,1); vi->m[0]=q;
70 ideal ui=idInit(1,1); ui->m[0]=p;
71 ideal R; matrix U;
72 ring save_ring=currRing;
73 if (r!=currRing) rChangeCurrRing(r);
74 int save_opt;
75 SI_SAVE_OPT1(save_opt);
76 si_opt_1 &= ~(Sy_bit(OPT_PROT));
77 ideal m = idLift(vi,ui,&R, FALSE,TRUE,TRUE,&U);
78 SI_RESTORE_OPT1(save_opt);
79 if (r!=save_ring) rChangeCurrRing(save_ring);
80 p=m->m[0]; m->m[0]=NULL;
81 id_Delete(&m,r);
82 p_SetCompP(p,0,r);
83 id_Delete((ideal *)&U,r);
84 id_Delete(&R,r);
85 //vi->m[0]=NULL; ui->m[0]=NULL;
86 id_Delete(&vi,r);
87 id_Delete(&ui,r);
88 return p;

Callers 1

singclap_gcdFunction · 0.85

Calls 15

WerrorSFunction · 0.85
p_DeleteFunction · 0.85
rIsPluralRingFunction · 0.85
rFieldTypeFunction · 0.85
convSingTrPFunction · 0.85
rIsNCRingFunction · 0.85
singclap_pdivideFunction · 0.85
idInitFunction · 0.85
rChangeCurrRingFunction · 0.85
idLiftFunction · 0.85
id_DeleteFunction · 0.85
p_SetCompPFunction · 0.85

Tested by

no test coverage detected