Changeset e10683 in git


Ignore:
Timestamp:
Nov 30, 2000, 5:46:09 PM (24 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c7af8613769b29c741d6c338945669719f1fc4f8')
Children:
379305282702a4d34d62437d3dfe5bf09925c710
Parents:
50268a871f223956bed4c2b84352e38f543a574b
Message:
*hannes: pmInit stuff


git-svn-id: file:///usr/local/Singular/svn/trunk@4782 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/polys.cc

    r50268a re10683  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys.cc,v 1.68 2000-11-09 16:32:53 obachman Exp $ */
     4/* $Id: polys.cc,v 1.69 2000-11-30 16:46:09 Singular Exp $ */
    55
    66/*
     
    5555  pLDeg=r->pLDeg;
    5656  pLexOrder=r->LexOrder;
    57  
     57
    5858  if (complete)
    5959  {
     
    140140* convert monomial given as string to poly, e.g. 1x3y5z
    141141*/
    142 poly pmInit(char *st, BOOLEAN &ok)
     142char * p_Read(char *st, poly &rc, ring r)
    143143{
    144144  int i,j;
    145   ok=FALSE;
    146   BOOLEAN b=FALSE;
    147   poly rc = pInit();
    148   char *s = nRead(st,&(rc->coef));
     145  rc = p_Init(r);
     146  char *s = r->cf->nRead(st,&(rc->coef));
    149147  if (s==st)
    150148  /* i.e. it does not start with a coeff: test if it is a ringvar*/
     
    154152    {
    155153      pIncrExp(rc,1+j);
     154      while (*s!='\0') s++;
    156155      goto done;
    157156    }
    158157  }
    159   else
    160     b=TRUE;
    161158  while (*s!='\0')
    162159  {
     
    164161    ss[0] = *s++;
    165162    ss[1] = '\0';
    166     j = rIsRingVar(ss);
     163    j = r_IsRingVar(ss,r);
    167164    if (j >= 0)
    168165    {
    169166      s = eati(s,&i);
    170       pAddExp(rc,1+j, (Exponent_t)i);
     167      p_AddExp(rc,1+j, (Exponent_t)i, r);
    171168    }
    172169    else
    173170    {
    174       if ((s!=st)&&isdigit(st[0]))
    175       {
    176         errorreported=TRUE;
    177       }
    178       pDelete(&rc);
    179       return NULL;
     171      s--;
     172      return s;
    180173    }
    181174  }
    182175done:
     176  if (r->cf->nIsZero(pGetCoeff(rc))) p_DeleteLm(&rc,r);
     177  else
     178  {
     179    p_Setm(rc,r);
     180  }
     181  return s;
     182}
     183
     184poly pmInit(char *st, BOOLEAN &ok)
     185{
     186  poly p;
     187  char *s=p_Read(st,p,currRing);
     188  if (*s!='\0')
     189  {
     190    if ((s!=st)&&isdigit(st[0]))
     191    {
     192      errorreported=TRUE;
     193    }
     194    ok=FALSE;
     195    pDelete(&p);
     196    return NULL;
     197  }
    183198  ok=!errorreported;
    184   if (nIsZero(pGetCoeff(rc))) pDeleteLm(&rc);
    185   else
    186   {
    187     pSetm(rc);
    188   }
    189   return rc;
     199  return p;
    190200}
    191201
     
    229239  return q;
    230240}
    231 
    232241
    233242/*2
  • Singular/polys.h

    r50268a re10683  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: polys.h,v 1.47 2000-11-23 17:40:02 Singular Exp $ */
     6/* $Id: polys.h,v 1.48 2000-11-30 16:46:08 Singular Exp $ */
    77/*
    88* ABSTRACT - all basic methods to manipulate polynomials of the
     
    2020          - debugging only if PDEBUG >= 2
    2121          - normally inlined, unless PDEBUG >= 2 || NO_INLINE2
    22  Level 1: operations on monomials with time proportional to length 
     22 Level 1: operations on monomials with time proportional to length
    2323          - implemented in: pInline1.h
    2424          - debugging only if PDEBUG >= 1
    25           - normally inlined, unless PDEBUG >= 1 || NO_INLINE1 
     25          - normally inlined, unless PDEBUG >= 1 || NO_INLINE1
    2626 Level 0: short operations on polynomials with time proportional to
    2727          length of poly
     
    3131            #define DO_PINLINE0
    3232            #include "pInline0.h"
    33  Misc   : operations on polynomials which do not fit in any of the 
     33 Misc   : operations on polynomials which do not fit in any of the
    3434          above categories
    3535          - implemented in: polys*.cc
     
    4242 However, PDEBUG will only be in effect, if !NDEBUG.
    4343
    44  All p_* operations take as last argument a ring 
    45  and are ring independent. Their corresponding p* operations are usually 
     44 All p_* operations take as last argument a ring
     45 and are ring independent. Their corresponding p* operations are usually
    4646 just macros to the respective p_*(..,currRing).
    4747
     
    6262#define pSetOrder(p, o)     p_SetOrder(p, o, currRing)
    6363
    64 // Component 
     64// Component
    6565#define pGetComp(p)         _p_GetComp(p, currRing)
    6666#define pSetComp(p,v)       p_SetComp(p,v, currRing)
     
    8383/***************************************************************
    8484 *
    85  * Allocation/Initalization/Deletion 
     85 * Allocation/Initalization/Deletion
    8686 * except for pDeleteLm and pHead, all polys must be != NULL
    8787 *
     
    9191// allocates a new monomial and initializes everything to 0
    9292#define pInit()         p_Init(currRing)
    93 // like pInit, except that expvector is initialized to that of p, 
     93// like pInit, except that expvector is initialized to that of p,
    9494// p must be != NULL
    9595#define pLmInit(p)  p_LmInit(p, currRing)
    96 // returns newly allocated copy of Lm(p), coef is copied, next=NULL, 
     96// returns newly allocated copy of Lm(p), coef is copied, next=NULL,
    9797// p might be NULL
    9898#define pHead(p)        p_Head(p, currRing)
    99 // if *p_ptr != NULL, delete p_ptr->coef, *p_ptr, and set *p_ptr to 
     99// if *p_ptr != NULL, delete p_ptr->coef, *p_ptr, and set *p_ptr to
    100100// pNext(*p_ptr)
    101101static inline void pDeleteLm(poly *p) {p_DeleteLm(p, currRing);}
     
    155155#define pCmp(p1, p2)    p_Cmp(p1, p2, currRing)
    156156
    157  
    158 /***************************************************************
    159  *
    160  * Divisiblity tests, args must be != NULL, except for 
     157
     158/***************************************************************
     159 *
     160 * Divisiblity tests, args must be != NULL, except for
    161161 * pDivisbleBy
    162162 *
    163163 ***************************************************************/
    164164// returns TRUE, if leading monom of a divides leading monom of b
    165 // i.e., if there exists a expvector c > 0, s.t. b = a + c; 
     165// i.e., if there exists a expvector c > 0, s.t. b = a + c;
    166166#define pDivisibleBy(a, b)  p_DivisibleBy(a,b,currRing)
    167167// like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
     
    282282
    283283
    284 poly      pmInit(char *s, BOOLEAN &ok);   /* monom -> poly */
     284poly      pmInit(char *s, BOOLEAN &ok);     /* monom -> poly, interpreter */
     285char *    p_Read(char *s, poly &p, ring r); /* monom -> poly */
    285286void      ppDelete(poly * a, ring r);
    286287
     
    301302int pMaxCompProc(poly p);
    302303
    303 #define   pOneComp(p)       p_OneComp(p, currRing) 
     304#define   pOneComp(p)       p_OneComp(p, currRing)
    304305#define   pSetCompP(a,i)    p_SetCompP(a, i, currRing)
    305306
Note: See TracChangeset for help on using the changeset viewer.