Changeset e20910 in git


Ignore:
Timestamp:
Sep 14, 2011, 7:00:07 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '98550b669234b32be762076c32b3be2c35188ac4')
Children:
8b87135f40450a46d90d5e08617044b9d4b56918
Parents:
a55ef037cdd445d3fc4149a3d95a4ebaecf3c2f5
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-09-14 19:00:07+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 16:12:49+01:00
Message:
FIX: ring declaration / building via rInit now actually supports parameters
ADD: initial support for building towers of rings/qrings, e.g. ring r = OldRing, (VARs), (ORDSTR);
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/ipshell.cc

    ra55ef0 re20910  
    49324932ring rInit(sleftv* pn, sleftv* rv, sleftv* ord)
    49334933{
    4934   int ch;
    49354934#ifdef HAVE_RINGS
    49364935  unsigned int ringtype = 0;
     
    49494948  int numberOfAllocatedBlocks;
    49504949 
    4951   coeffs cf=NULL;
    49524950  // allocated ring
    49534951  R = (ring) omAlloc0Bin(sip_sring_bin);
    49544952
     4953  coeffs cf = NULL;
     4954
     4955  assume( pn != NULL );
     4956  const int P = pn->listLength();
     4957 
    49554958  if (pn->Typ()==INT_CMD)
    49564959  {
    4957     ch=(int)(long)pn->Data();
    4958     if (pn->next==NULL)
    4959       cf=nInitChar(ch==0 ? n_Q : n_Zp, (void*)(long)ch);
     4960    const int ch = (int)(long)pn->Data();
     4961   
     4962    /* parameter? -------------------------------------------------------*/
     4963    pn = pn->next;
     4964   
     4965    if (pn == NULL) // no params!?
     4966      cf = nInitChar(ch==0 ? n_Q : n_Zp, (void*)(long)ch);
    49604967    else
    49614968    {
    4962       if ((ch!=0) && (ch!=IsPrime(ch)))
     4969      const int pars = pn->listLength();
     4970
     4971      assume( pars > 0 );
     4972
     4973      // predefined finite field: (p^k, a)
     4974      if ((ch!=0) && (ch!=IsPrime(ch)) && (pars == 1))
    49634975      {
    49644976        GFInfo param;
    49654977         
    49664978        param.GFChar = ch;
    4967         param.GFDegree = 1;
    4968          
    4969         param.GFPar_name=pn->name;
    4970         cf=nInitChar(n_GF,&param);
     4979        param.GFDegree = 1;     
     4980        param.GFPar_name = pn->name;
    49714981       
    4972         if (cf==NULL) goto rInitError;
    4973         else ffChar=TRUE;
     4982        cf = nInitChar(n_GF, &param);       
     4983      }
     4984      else // (0/p, a, b, ..., z)
     4985      {
     4986        assume( (ch == 0) || (ch==IsPrime(ch)) );
     4987
     4988//         if ((pars > 1) && (ffChar))
     4989//         {
     4990//           WerrorS("too many parameters");
     4991//           goto rInitError;
     4992//         }
    49744993       
    4975       }
    4976       /* parameter -------------------------------------------------------*/
    4977       pn=pn->next;
    4978       if (cf==NULL) cf=nInitChar(n_transExt,NULL);
    4979       if (cf==NULL) goto rInitError;
    4980       R->cf=cf;
    4981       if (pn!=NULL)
    4982       {
    4983         int pars=pn->listLength();
    4984         if (!ffChar) R->cf->extRing->N=pars;
    4985         if ((pars > 1) && (ffChar))
    4986         {
    4987           WerrorS("too many parameters");
    4988           goto rInitError;
    4989         }
    4990         if (!ffChar) R->cf->extRing->names=(char**)omAlloc0(rPar(R)*sizeof(char_ptr));
    4991         if (rSleftvList2StringArray(pn, R->cf->extRing->names))
     4994        char ** names = (char**)omAlloc0(pars * sizeof(char_ptr));
     4995
     4996        if (rSleftvList2StringArray(pn, names))
    49924997        {
    49934998          WerrorS("parameter expected");
    49944999          goto rInitError;
    49955000        }
    4996       }
    4997     }
     5001
     5002        TransExtInfo extParam;
     5003       
     5004        extParam.r = rDefault( ch, pars, names); // Q/Zp [ p_1, ... p_pars ]
     5005       
     5006        cf = nInitChar(n_transExt, &extParam);
     5007      }
     5008    }
     5009   
     5010//    if (cf==NULL) goto rInitError;
     5011    assume( cf != NULL );
    49985012  }
    49995013  else if ((pn->name != NULL)
     
    50015015  {
    50025016    BOOLEAN complex_flag=(strcmp(pn->name,"complex")==0);
    5003     ch=0;
     5017    const int ch=0;
    50045018    if ((pn->next!=NULL) && (pn->next->Typ()==INT_CMD))
    50055019    {
     
    50235037      WarnS("not implemented: name for i (complex)");
    50245038    cf=nInitChar(complex_flag ? n_long_C: n_long_R,NULL);
     5039
     5040    assume( cf != NULL );
    50255041  }
    50265042#ifdef HAVE_RINGS
     
    50465062    else
    50475063      cf=nInitChar(n_Z,NULL);
     5064   
    50485065    if ((mpz_cmp_ui(modBase, 1) == 0) && (mpz_cmp_ui(modBase, 0) < 0))
    50495066    {
     
    50605077    if (modExponent > 1)
    50615078    {
    5062       ch = modExponent;
     5079      const int ch = modExponent;
    50635080      if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(NATNUMBER)))
    50645081      {
     
    50785095    {
    50795096      ringtype = 2;
    5080       ch = mpz_get_ui(modBase);
    5081       cf=nInitChar(n_Zn,(void*)(long)modBase);
    5082     }
     5097      const int ch = mpz_get_ui(modBase);
     5098      cf=nInitChar(n_Zn,(void*)(long)ch);
     5099    }
     5100    assume( cf != NULL );
    50835101  }
    50845102#endif
     5103  // ring NEW = OLD, (), (); where OLD is a polynomial ring...
     5104  else if ((pn->Typ()==RING_CMD) && (P == 1))
     5105  {
     5106    TransExtInfo extParam;
     5107    extParam.r = (ring)pn->Data();
     5108    cf = nInitChar(n_transExt, &extParam);
     5109  }
     5110  else if ((pn->Typ()==QRING_CMD) && (P == 1)) // same for qrings - which should be fields!?
     5111  {
     5112    AlgExtInfo extParam;
     5113    extParam.r = (ring)pn->Data();
     5114    extParam.i = (extParam.r->qideal);
     5115   
     5116    cf = nInitChar(n_algExt, &extParam);   // Q[a]/<minideal>
     5117  }
    50855118  else
    50865119  {
    5087     Werror("Wrong ground field specification");
     5120    sleftv* p = pn;
     5121    Werror("Wrong or unknown ground field specification");
     5122#ifndef NDEBUG
     5123    while (p != NULL)
     5124    {
     5125      Print( "pn[%p]: type: %d [%s]: %p, name: %s", p, p->Typ(), Tok2Cmdname(p->Typ()), p->Data(), (p->name == NULL? "NULL" : p->name) );
     5126      PrintLn();
     5127      p = p->next;
     5128    }
     5129#endif   
    50885130    goto rInitError;
    50895131  }
    5090   pn=pn->next;
     5132//  pn=pn->next;
    50915133
    50925134  int l, last;
     
    51085150  if (cf==NULL)
    51095151  {
    5110     Warn("%d is invalid characteristic of ground field. 32003 is used.", ch);
    5111     ch=32003;
     5152    const int ch=32003;
     5153    Warn("Invalid ground field specification: using the default field: Z_{%d}", ch);
    51125154    cf=nInitChar(n_Zp, (void*)(long)ch);
    51135155  }
    5114   R->cf=cf;
     5156
     5157  assume( R != NULL );
     5158 
     5159  R->cf = cf;
     5160 
    51155161#ifdef HAVE_RINGS
    5116   R->cf->ringtype = ringtype;
    5117   R->cf->modBase = modBase;
    5118   R->cf->modExponent = modExponent;
     5162  // the following should have beed set already into cf, right?!
     5163//  R->cf->ringtype = ringtype;
     5164//  R->cf->modBase = modBase;
     5165//  R->cf->modExponent = modExponent;
    51195166#endif
    51205167
Note: See TracChangeset for help on using the changeset viewer.