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

Function p_DivRem

kernel/polys.cc:314–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314poly p_DivRem(poly p, poly q, poly &rest, const ring r)
315{
316 assume(q!=NULL);
317 rest=NULL;
318 if (q==NULL)
319 {
320 WerrorS("div. by 0");
321 return NULL;
322 }
323 if (p==NULL)
324 {
325 p_Delete(&q,r);
326 return NULL;
327 }
328 if(p_GetComp(p,r)==0)
329 {
330 if((rFieldType(r)==n_transExt)
331 &&(convSingTrP(p,r))
332 &&(convSingTrP(q,r))
333 &&(!rIsNCRing(r)))
334 {
335 poly res=singclap_pdivide(p, q, r);
336 rest=singclap_pmod(p,q,r);
337 p_Delete(&p,r);
338 p_Delete(&q,r);
339 return res;
340 }
341 else if ((r->cf->convSingNFactoryN!=ndConvSingNFactoryN)
342 &&(!rField_is_Ring(r))
343 &&(!rIsNCRing(r)))
344 {
345 poly res=singclap_pdivide(p, q, r);
346 rest=singclap_pmod(p,q,r);
347 p_Delete(&p,r);
348 p_Delete(&q,r);
349 return res;
350 }
351 else
352 {
353 ideal vi=idInit(1,1); vi->m[0]=q;
354 ideal ui=idInit(1,1); ui->m[0]=p;
355 ideal R; matrix U;
356 ring save_ring=currRing;
357 if (r!=currRing) rChangeCurrRing(r);
358 int save_opt;
359 SI_SAVE_OPT1(save_opt);
360 si_opt_1 &= ~(Sy_bit(OPT_PROT));
361 ideal m = idLift(vi,ui,&R, FALSE,TRUE,TRUE,&U);
362 SI_RESTORE_OPT1(save_opt);
363 if (r!=save_ring) rChangeCurrRing(save_ring);
364 p=m->m[0]; m->m[0]=NULL;
365 id_Delete(&m,r);
366 p_SetCompP(p,0,r);
367 rest=R->m[0]; R->m[0]=NULL;
368 id_Delete(&R,r);
369 p_SetCompP(rest,0,r);
370 id_Delete((ideal *)&U,r);
371 //vi->m[0]=NULL; ui->m[0]=NULL;

Callers 1

jjEXTENDED_SYSTEMFunction · 0.85

Calls 12

WerrorSFunction · 0.85
p_DeleteFunction · 0.85
rFieldTypeFunction · 0.85
convSingTrPFunction · 0.85
rIsNCRingFunction · 0.85
singclap_pdivideFunction · 0.85
singclap_pmodFunction · 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