Changeset f34215 in git for polys/monomials/p_polys.cc


Ignore:
Timestamp:
Nov 8, 2010, 4:57:06 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
fb4075bf0613cccede0552d05c1b4ee37a7f6530
Parents:
a04c5ec2b888d58e53a0701c12400ddca144d53e
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2010-11-08 16:57:06+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:55:35+01:00
Message:
moved some ring-indep. stuff to p_polys
File:
1 edited

Legend:

Unmodified
Added
Removed
  • polys/monomials/p_polys.cc

    ra04c5e rf34215  
    11341134}
    11351135
     1136void p_Split(poly p, poly *h)
     1137{
     1138  *h=pNext(p);
     1139  pNext(p)=NULL;
     1140}
     1141
     1142/*2
     1143* pair has no common factor ? or is no polynomial
     1144*/
     1145BOOLEAN p_HasNotCF(poly p1, poly p2, const ring r)
     1146{
     1147
     1148  if (p_GetComp(p1,r) > 0 || p_GetComp(p2,r) > 0)
     1149    return FALSE;
     1150  int i = rVar(r);
     1151  loop
     1152  {
     1153    if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0))
     1154      return FALSE;
     1155    i--;
     1156    if (i == 0)
     1157      return TRUE;
     1158  }
     1159}
     1160
     1161/*2
     1162* convert monomial given as string to poly, e.g. 1x3y5z
     1163*/
     1164const char * p_Read(const char *st, poly &rc, const ring r)
     1165{
     1166  if (r==NULL) { rc=NULL;return st;}
     1167  int i,j;
     1168  rc = p_Init(r);
     1169  const char *s = r->cf->nRead(st,&(rc->coef));
     1170  if (s==st)
     1171  /* i.e. it does not start with a coeff: test if it is a ringvar*/
     1172  {
     1173    j = r_IsRingVar(s,r);
     1174    if (j >= 0)
     1175    {
     1176      p_IncrExp(rc,1+j,r);
     1177      while (*s!='\0') s++;
     1178      goto done;
     1179    }
     1180  }
     1181  while (*s!='\0')
     1182  {
     1183    char ss[2];
     1184    ss[0] = *s++;
     1185    ss[1] = '\0';
     1186    j = r_IsRingVar(ss,r);
     1187    if (j >= 0)
     1188    {
     1189      const char *s_save=s;
     1190      s = eati(s,&i);
     1191      if (((unsigned long)i) >  r->bitmask)
     1192      {
     1193        // exponent to large: it is not a monomial
     1194        p_LmDelete(&rc,r);
     1195        return s_save;
     1196      }
     1197      p_AddExp(rc,1+j, (long)i, r);
     1198    }
     1199    else
     1200    {
     1201      // 1st char of is not a varname
     1202      p_LmDelete(&rc,r);
     1203      s--;
     1204      return s;
     1205    }
     1206  }
     1207done:
     1208  if (r->cf->nIsZero(pGetCoeff(rc))) p_LmDelete(&rc,r);
     1209  else
     1210  {
     1211#ifdef HAVE_PLURAL
     1212    // in super-commutative ring
     1213    // squares of anti-commutative variables are zeroes!
     1214    if(rIsSCA(r))
     1215    {
     1216      const unsigned int iFirstAltVar = scaFirstAltVar(r);
     1217      const unsigned int iLastAltVar  = scaLastAltVar(r);
     1218
     1219      assume(rc != NULL);
     1220
     1221      for(unsigned int k = iFirstAltVar; k <= iLastAltVar; k++)
     1222        if( p_GetExp(rc, k, r) > 1 )
     1223        {
     1224          p_LmDelete(&rc, r);
     1225          goto finish;
     1226        }
     1227    }
     1228#endif
     1229   
     1230    p_Setm(rc,r);
     1231  }
     1232finish: 
     1233  return s;
     1234}
     1235poly p_mInit(const char *st, BOOLEAN &ok, const ring r)
     1236{
     1237  poly p;
     1238  const char *s=p_Read(st,p,r);
     1239  if (*s!='\0')
     1240  {
     1241    if ((s!=st)&&isdigit(st[0]))
     1242    {
     1243      errorreported=TRUE;
     1244    }
     1245    ok=FALSE;
     1246    p_Delete(&p,r);
     1247    return NULL;
     1248  }
     1249  #ifdef PDEBUG
     1250  _p_Test(p,r,PDEBUG);
     1251  #endif
     1252  ok=!errorreported;
     1253  return p;
     1254}
     1255
    11361256/*2
    11371257* returns a polynomial representing the number n
Note: See TracChangeset for help on using the changeset viewer.