Changeset 73659a in git


Ignore:
Timestamp:
Mar 17, 2011, 11:52:44 AM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
9e7acfedffee3f0611f161393bb68d69c175bfff
Parents:
a513d10db695283b0b6578322ae02304f8cf82d2
Message:
valid_for reorganized, ZERODIVISOR added

git-svn-id: file:///usr/local/Singular/svn/trunk@14000 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    ra513d10 r73659a  
    7676#include <kernel/timer.h>
    7777
     78// defaults for all commands: NO_PLURAL | NO_RING | ALLOW_ZERODIVISOR
     79
    7880#ifdef HAVE_PLURAL
    7981  #include <kernel/gring.h>
     
    9294#ifdef HAVE_RINGS
    9395  #define RING_MASK        4
     96  #define ZERODIVISOR_MASK 8
    9497#else
    9598  #define RING_MASK        0
     99  #define ZERODIVISOR_MASK 0
    96100#endif
    97101#define ALLOW_RING       4
    98102#define NO_RING          0
     103#define NO_ZERODIVISOR   8
     104#define ALLOW_ZERODIVISOR  0
     105
     106static BOOLEAN check_valid(const int p, const int op);
    99107
    100108/*=============== types =====================*/
     
    201209
    202210#define ii_div_by_0 "div. by 0"
    203 #define ii_not_for_plural "not implemented for non-commutative rings"
    204 #define ii_not_for_ring "not implemented for rings with rings as coeffients"
    205211
    206212int iiOp; /* the current operation*/
     
    17791785    /* drop degree zero generator from vv (if any) */
    17801786    if (i != -1) pDelete(&vv->m[i]);
    1781     long d = (long)scDimInt(vv, ww);   
     1787    long d = (long)scDimInt(vv, ww);
    17821788    if (rField_is_Ring_Z(origR) && (i == -1)) d++;
    17831789    res->data = (char *)d;
     
    36523658    /* drop degree zero generator from vv (if any) */
    36533659    if (i != -1) pDelete(&vv->m[i]);
    3654     long d = (long)scDimInt(vv, currQuotient);   
     3660    long d = (long)scDimInt(vv, currQuotient);
    36553661    if (rField_is_Ring_Z(origR) && (i == -1)) d++;
    36563662    res->data = (char *)d;
     
    41864192  tmp = syMinimize(tmp); // enrich itself!
    41874193
    4188   res->data=(char *)tmp; 
    4189  
     4194  res->data=(char *)tmp;
     4195
    41904196  if (weights!=NULL)
    41914197    atSet(res, omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
     
    69046910  /* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
    69056911     see a detailed documentation in /kernel/linearAlgebra.h
    6906      
     6912
    69076913     valid argument lists:
    69086914     - (poly h, int d),
     
    69186924     - list with the two factors f and g such that
    69196925       h(x,y) = f(x,y)*g(x,y) mod x^(d+1)   */
    6920  
     6926
    69216927  poly h      = NULL;
    69226928  int  d      =    1;
     
    69256931  int  xIndex =    1;   /* default index if none provided */
    69266932  int  yIndex =    2;   /* default index if none provided */
    6927  
     6933
    69286934  leftv u = v; int factorsGiven = 0;
    69296935  if ((u == NULL) || (u->Typ() != POLY_CMD))
     
    69756981    return TRUE;
    69766982  }
    6977  
     6983
    69786984  /* checks for provided arguments */
    69796985  if (pIsConstant(h) || (factorsGiven && (pIsConstant(f0) || pIsConstant(g0))))
     
    69987004    return TRUE;
    69997005  }
    7000  
     7006
    70017007  /* computation of f0 and g0 if missing */
    70027008  if (factorsGiven == 0)
     
    70127018
    70137019    idTest(i);
    7014    
     7020
    70157021    if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
    70167022    {
     
    70267032#endif
    70277033  }
    7028  
     7034
    70297035  poly f; poly g;
    70307036  henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
     
    72597265        if (currRing!=NULL)
    72607266        {
    7261           #ifdef HAVE_PLURAL
    7262           if (rIsPluralRing(currRing))
    7263           {
    7264             if ((dArith2[i].valid_for & PLURAL_MASK)==0 /*NO_PLURAL*/)
    7265             {
    7266               WerrorS(ii_not_for_plural);
    7267               break;
    7268             }
    7269             else if ((dArith2[i].valid_for & PLURAL_MASK)==2 /*, COMM_PLURAL */)
    7270             {
    7271               Warn("assume commutative subalgebra for cmd `%s`",Tok2Cmdname(i));
    7272             }
    7273             /* else, ALLOW_PLURAL */
    7274           }
    7275           #endif
    7276           #ifdef HAVE_RINGS
    7277           if (rField_is_Ring(currRing))
    7278           {
    7279             if ((dArith2[i].valid_for & RING_MASK)==0 /*NO_RING*/)
    7280             {
    7281               WerrorS(ii_not_for_ring);
    7282               break;
    7283             }
    7284             /* else ALLOW_RING */
    7285           }
    7286           #endif
     7267          if (check_valid(dArith2[i].valid_for,op)) break;
    72877268        }
    72887269        if (TEST_V_ALLWARN)
     
    73187299            if (currRing!=NULL)
    73197300            {
    7320               #ifdef HAVE_PLURAL
    7321               if (rIsPluralRing(currRing))
    7322               {
    7323                 if ((dArith2[i].valid_for & PLURAL_MASK)==0 /*NO_PLURAL*/)
    7324                 {
    7325                   WerrorS(ii_not_for_plural);
    7326                   break;
    7327                 }
    7328                 else if ((dArith2[i].valid_for &PLURAL_MASK)==2 /*, COMM_PLURAL */)
    7329                 {
    7330                   Warn("assume commutative subalgebra for cmd `%s`",
    7331                         Tok2Cmdname(i));
    7332                 }
    7333                 /* else, ALLOW_PLURAL */
    7334               }
    7335               #endif
    7336               #ifdef HAVE_RINGS
    7337               if (rField_is_Ring(currRing))
    7338               {
    7339                 if ((dArith2[i].valid_for & RING_MASK)==0 /*NO_RING*/)
    7340                 {
    7341                   WerrorS(ii_not_for_ring);
    7342                   break;
    7343                 }
    7344                 /* else ALLOW_RING */
    7345               }
    7346               #endif
     7301              if (check_valid(dArith2[i].valid_for,op)) break;
    73477302            }
    73487303            if (TEST_V_ALLWARN)
     
    74777432        if (currRing!=NULL)
    74787433        {
    7479           #ifdef HAVE_PLURAL
    7480           if ((currRing!=NULL) && (rIsPluralRing(currRing)))
    7481           {
    7482             if ((dArith1[i].valid_for &PLURAL_MASK)==0 /*NO_PLURAL*/)
    7483             {
    7484               WerrorS(ii_not_for_plural);
    7485               break;
    7486             }
    7487             else if ((dArith1[i].valid_for &PLURAL_MASK)==2 /*, COMM_PLURAL */)
    7488             {
    7489               Warn("assume commutative subalgebra for cmd `%s`",Tok2Cmdname(i));
    7490             }
    7491             /* else, ALLOW_PLURAL */
    7492           }
    7493           #endif
    7494           #ifdef HAVE_RINGS
    7495           if (rField_is_Ring(currRing))
    7496           {
    7497             if ((dArith1[i].valid_for & RING_MASK)==0 /*NO_RING*/)
    7498             {
    7499               WerrorS(ii_not_for_ring);
    7500               break;
    7501             }
    7502             /* else ALLOW_RING */
    7503           }
    7504           #endif
     7434          if (check_valid(dArith1[i].valid_for,op)) break;
    75057435        }
    75067436        if (TEST_V_ALLWARN)
     
    75427472        {
    75437473          int r=res->rtyp=dArith1[i].res;
    7544           #ifdef HAVE_PLURAL
    7545           if ((currRing!=NULL) && (rIsPluralRing(currRing)))
     7474          if (currRing!=NULL)
    75467475          {
    7547             if ((dArith1[i].valid_for &PLURAL_MASK)==0 /*NO_PLURAL*/)
    7548             {
    7549               WerrorS(ii_not_for_plural);
    7550               break;
    7551             }
    7552             else if ((dArith1[i].valid_for &PLURAL_MASK)==2 /*, COMM_PLURAL */)
    7553             {
    7554               Warn("assume commutative subalgebra for cmd `%s`",Tok2Cmdname(i));
    7555             }
    7556             /* else, ALLOW_PLURAL */
     7476            if (check_valid(dArith1[i].valid_for,op)) break;
    75577477          }
    7558           #endif
    75597478          if (r<0)
    75607479          {
     
    76857604        if (currRing!=NULL)
    76867605        {
    7687           #ifdef HAVE_PLURAL
    7688           if (rIsPluralRing(currRing))
    7689           {
    7690             if ((dArith3[i].valid_for &PLURAL_MASK)==0 /*NO_PLURAL*/)
    7691             {
    7692               WerrorS(ii_not_for_plural);
    7693               break;
    7694             }
    7695             else if ((dArith3[i].valid_for &PLURAL_MASK)==2 /*, COMM_PLURAL */)
    7696             {
    7697               Warn("assume commutative subalgebra for cmd `%s`",Tok2Cmdname(i));
    7698             }
    7699             /* else, ALLOW_PLURAL */
    7700           }
    7701           #endif
    7702           #ifdef HAVE_RINGS
    7703           if (rField_is_Ring(currRing))
    7704           {
    7705             if ((dArith3[i].valid_for & RING_MASK)==0 /*NO_RING*/)
    7706             {
    7707               WerrorS(ii_not_for_ring);
    7708               break;
    7709             }
    7710             /* else ALLOW_RING */
    7711           }
    7712           #endif
     7606          if (check_valid(dArith3[i].valid_for,op)) break;
    77137607        }
    77147608        if (TEST_V_ALLWARN)
     
    77457639            {
    77467640              res->rtyp=dArith3[i].res;
    7747               #ifdef HAVE_PLURAL
    7748               if ((currRing!=NULL)
    7749               && (rIsPluralRing(currRing)))
     7641              if (currRing!=NULL)
    77507642              {
    7751                 if ((dArith3[i].valid_for &PLURAL_MASK)==0 /*NO_PLURAL*/)
    7752                 {
    7753                    WerrorS(ii_not_for_plural);
    7754                    break;
    7755                  }
    7756                  else if ((dArith3[i].valid_for &PLURAL_MASK)==2 /*, COMM_PLURAL */)
    7757                  {
    7758                    Warn("assume commutative subalgebra for cmd `%s`",Tok2Cmdname(i));
    7759                  }
    7760                  /* else, ALLOW_PLURAL */
     7643                if (check_valid(dArith3[i].valid_for,op)) break;
    77617644              }
    7762               #endif
    77637645              if (TEST_V_ALLWARN)
    77647646                Print("call %s(%s,%s,%s)\n",
     
    79427824        if (currRing!=NULL)
    79437825        {
    7944           #ifdef HAVE_PLURAL
    7945           if (rIsPluralRing(currRing))
    7946           {
    7947             if ((dArithM[i].valid_for &PLURAL_MASK)==0 /*NO_PLURAL*/)
    7948             {
    7949               WerrorS(ii_not_for_plural);
    7950               break;
    7951             }
    7952             else if ((dArithM[i].valid_for &PLURAL_MASK)==2 /*, COMM_PLURAL */)
    7953             {
    7954               Warn("assume commutative subalgebra for cmd `%s`",Tok2Cmdname(i));
    7955             }
    7956             /* else ALLOW_PLURAL */
    7957           }
    7958           #endif
    7959           #ifdef HAVE_RINGS
    7960           if (rField_is_Ring(currRing))
    7961           {
    7962             if ((dArithM[i].valid_for & RING_MASK)==0 /*NO_RING*/)
    7963             {
    7964               WerrorS(ii_not_for_ring);
    7965               break;
    7966             }
    7967             /* else ALLOW_RING */
    7968           }
    7969           #endif
     7826          if (check_valid(dArithM[i].valid_for,op)) break;
    79707827        }
    79717828        if (TEST_V_ALLWARN)
     
    84288285  return 0;
    84298286}
     8287
     8288static BOOLEAN check_valid(const int p, const int op)
     8289{
     8290  #ifdef HAVE_PLURAL
     8291  if (rIsPluralRing(currRing))
     8292  {
     8293    if ((p & PLURAL_MASK)==0 /*NO_PLURAL*/)
     8294    {
     8295      WerrorS("not implemented for non-commutative rings");
     8296      return TRUE;
     8297    }
     8298    else if ((p & PLURAL_MASK)==2 /*, COMM_PLURAL */)
     8299    {
     8300      Warn("assume commutative subalgebra for cmd `%s`",Tok2Cmdname(op));
     8301      return FALSE;
     8302    }
     8303    /* else, ALLOW_PLURAL */
     8304  }
     8305  #endif
     8306  #ifdef HAVE_RINGS
     8307  if (rField_is_Ring(currRing))
     8308  {
     8309    if ((p & RING_MASK)==0 /*NO_RING*/)
     8310    {
     8311      WerrorS("not implemented for rings with rings as coeffients");
     8312      return TRUE;
     8313    }
     8314    /* else ALLOW_RING */
     8315    else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
     8316    &&(!rField_is_Domain(currRing)))
     8317    {
     8318      WerrorS("domain required as coeffients");
     8319      return TRUE;
     8320    }
     8321    /* else ALLOW_ZERODIVISOR */
     8322  }
     8323  #endif
     8324  return FALSE;
     8325}
Note: See TracChangeset for help on using the changeset viewer.