Changeset d3af55 in git for kernel


Ignore:
Timestamp:
Aug 28, 2017, 3:53:02 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
639345cb183019a538568be59dbe1acb10fa6e52
Parents:
c796c8c22e0eb1646288441d49b98e3bed9b7086
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2017-08-28 15:53:02+02:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2017-08-28 15:59:15+02:00
Message:
add: new p_Divide(a,b,r): a/b, ignoring the rest
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/polys.cc

    rc796c8 rd3af55  
    55
    66#include "polys.h"
     7#include "kernel/ideals.h"
     8#include "kernel/ideals.h"
     9#include "polys/clapsing.h"
    710
    811/// Widely used global variable which specifies the current polynomial ring for Singular interpreter and legacy implementatins.
     
    3639  }
    3740}
    38 /*
    39 /// internally changes the gloabl ring and resets the relevant
    40 /// global variables:
    41 /// SHOULD BE DEPRECATED NOW...?
    42 void rChangeCurrRing(ring r)
     41
     42poly p_Divide(poly p, poly q, const ring r)
    4343{
    44  // if (!rMinpolyIsNULL(currRing))
    45  // {
    46  //   omCheckAddr(currRing->cf->minpoly);
    47  // }
    48   //------------ set global ring vars --------------------------------
    49   //currRing = r;
    50   if (r != NULL)
    51   {
    52     rTest(r);
    53     //------------ set global ring vars --------------------------------
    54 
    55     //------------ global variables related to coefficients ------------
    56     nSetChar(r->cf);
    57 
    58     //------------ global variables related to polys -------------------
    59     p_SetGlobals(r);
    60     //------------ global variables related to factory -----------------
     44  assume(q!=NULL);
     45  if (p==NULL) return NULL;
     46  if (pNext(q)!=NULL)
     47  { /* This means that q != 0 consists of at least two terms*/
     48    if(p_GetComp(p,r)==0)
     49    {
     50      if ((r->cf->convSingNFactoryN!=ndConvSingNFactoryN)
     51      &&(!rField_is_Ring(r)))
     52        return singclap_pdivide(p, q, r);
     53      else
     54      {
     55        ideal vi=idInit(1,1); vi->m[0]=q;
     56        ideal ui=idInit(1,1); ui->m[0]=p;
     57        ideal R; matrix U;
     58        if (r!=currRing)
     59        {
     60          WerrorS("internal error: idLift not in currRing");
     61          return NULL;
     62        }
     63        ideal m = idLift(vi,ui,&R, FALSE,TRUE,TRUE,&U);
     64        matrix T = id_Module2formatedMatrix(m,1,1,currRing);
     65        p=MATELEM(T,1,1); MATELEM(T,1,1)=NULL;
     66        id_Delete((ideal *)&T,r);
     67        id_Delete((ideal *)&U,r);
     68        id_Delete(&R,r);
     69        vi->m[0]=NULL; ui->m[0]=NULL;
     70        id_Delete(&vi,r);
     71        id_Delete(&ui,r);
     72        return p;
     73      }
     74    }
     75    else
     76    {
     77      int comps=p_MaxComp(p,r);
     78      ideal I=idInit(comps,1);
     79      p=p_Copy(p,r);
     80      poly h;
     81      int i;
     82      // conversion to a list of polys:
     83      while (p!=NULL)
     84      {
     85        i=p_GetComp(p,r)-1;
     86        h=pNext(p);
     87        pNext(p)=NULL;
     88        p_SetComp(p,0,r);
     89        I->m[i]=p_Add_q(I->m[i],p,r);
     90        p=h;
     91      }
     92      // division and conversion to vector:
     93      h=NULL;
     94      p=NULL;
     95      for(i=comps-1;i>=0;i--)
     96      {
     97        if (I->m[i]!=NULL)
     98        {
     99          if ((r->cf->convSingNFactoryN!=ndConvSingNFactoryN)
     100          &&(!rField_is_Ring(r)))
     101            h=singclap_pdivide(I->m[i],q,r);
     102          else
     103          {
     104            ideal vi=idInit(1,1); vi->m[0]=q;
     105            ideal ui=idInit(1,1); ui->m[0]=I->m[i];
     106            ideal R; matrix U;
     107            if (r!=currRing)
     108            {
     109              WerrorS("internal error: idLift not in currRing");
     110              return NULL;
     111            }
     112            ideal m = idLift(vi,ui,&R, FALSE,TRUE,TRUE,&U);
     113            matrix T = id_Module2formatedMatrix(m,1,1,currRing);
     114            h=MATELEM(T,1,1); MATELEM(T,1,1)=NULL;
     115            id_Delete((ideal*)&T,r);
     116            id_Delete((ideal*)&U,r);
     117            id_Delete(&R,r);
     118            vi->m[0]=NULL; ui->m[0]=NULL;
     119            id_Delete(&vi,r);
     120            id_Delete(&ui,r);
     121          }
     122          p_SetCompP(h,i+1,r);
     123          p=p_Add_q(p,h,r);
     124        }
     125      }
     126      id_Delete(&I,r);
     127      return p;
     128    }
    61129  }
     130  else
     131  { /* This means that q != 0 consists of just one term,
     132       or that currRing is over a coefficient ring. */
     133#ifdef HAVE_RINGS
     134    if (!rField_is_Domain(currRing))
     135    {
     136      WerrorS("division only defined over coefficient domains");
     137      return NULL;
     138    }
     139    if (pNext(q)!=NULL)
     140    {
     141      WerrorS("division over a coefficient domain only implemented for terms");
     142      return NULL;
     143    }
     144#endif
     145    return p_DivideM(p_Copy(p,r),p_Head(q,r),r);
     146  }
     147  return FALSE;
    62148}
    63 */
  • kernel/polys.h

    rc796c8 rd3af55  
    160160#endif
    161161
     162/// polynomial division, ignoring the rest
     163/// via singclap_pdiive resp. idLift
     164poly p_Divide(poly a, poly b, const ring r);
    162165/***************************************************************
    163166 *
Note: See TracChangeset for help on using the changeset viewer.