Changeset c81a40 in git for Singular/ipshell.cc


Ignore:
Timestamp:
Jul 16, 2008, 2:41:33 PM (16 years ago)
Author:
Oliver Wienand <wienand@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
c88c2ba361f5b914ed9b192a055274f0a74cdf04
Parents:
e3164c057b351ebc7de36b8955221b4cb648bdbe
Message:
Maps für Bigint
Modul bei Z/m wird nun als GMP gespeichert


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

Legend:

Unmodified
Added
Removed
  • Singular/ipshell.cc

    re3164c rc81a40  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ipshell.cc,v 1.186 2008-07-07 12:21:43 wienand Exp $ */
     4/* $Id: ipshell.cc,v 1.187 2008-07-16 12:41:32 wienand Exp $ */
    55/*
    66* ABSTRACT:
     
    16081608}
    16091609
     1610#ifdef HAVE_RINGS
     1611void rDecomposeRing(leftv h,const ring R)
     1612/* field is R or C */
     1613{
     1614  lists L=(lists)omAlloc0Bin(slists_bin);
     1615  if (rField_is_Ring_Z(R)) L->Init(1);
     1616  else                L->Init(2);
     1617  h->rtyp=LIST_CMD;
     1618  h->data=(void *)L;
     1619  // 0: char/ cf - ring
     1620  // 1: list (module)
     1621  // ----------------------------------------
     1622  // 0: char/ cf - ring
     1623  L->m[0].rtyp=STRING_CMD;
     1624  L->m[0].data=(void *)omStrDup("integer");
     1625  // ----------------------------------------
     1626  // 1: module
     1627  if (rField_is_Ring_Z(R)) return;
     1628  lists LL=(lists)omAlloc0Bin(slists_bin);
     1629  LL->Init(2);
     1630  LL->m[0].rtyp=BIGINT_CMD;
     1631  LL->m[0].data=nlMapGMP((number) R->ringflaga);
     1632  LL->m[1].rtyp=INT_CMD;
     1633  LL->m[1].data=(void *) R->ringflagb;
     1634  L->m[1].rtyp=LIST_CMD;
     1635  L->m[1].data=(void *)LL;
     1636}
     1637#endif
     1638
     1639
    16101640lists rDecompose(const ring r)
    16111641{
     
    16401670    rDecomposeC(&(L->m[0]),r);
    16411671  }
     1672#ifdef HAVE_RINGS
     1673  else if (rField_is_Ring(r))
     1674  {
     1675    rDecomposeRing(&(L->m[0]),r);
     1676  }
     1677#endif
    16421678  else if (rIsExtension(r))
    16431679  {
     
    44564492#ifdef HAVE_RINGS
    44574493  unsigned int ringtype = 0;
    4458   unsigned long long ringflaga = 0;
    4459   unsigned int ringflagb = 0;
     4494  int_number ringflaga = (int_number) omAlloc(sizeof(MP_INT));
     4495  mpz_init_set_si(ringflaga, 0);
     4496  unsigned int ringflagb = 1;
    44604497#endif
    44614498  int float_len=0;
     
    45014538    if ((pn->next!=NULL) && (pn->next->Typ()==INT_CMD))
    45024539    {
    4503       ringflaga = (unsigned long long) pn->next->Data();
     4540      mpz_set_ui(ringflaga, (unsigned int) pn->next->Data());
    45044541      pn=pn->next;
    4505       ringflagb = 1;
    45064542      if ((pn->next!=NULL) && (pn->next->Typ()==INT_CMD))
    45074543      {
    4508         ringflagb = (unsigned int) (unsigned long) pn->next->Data();
     4544        ringflagb = (unsigned int) pn->next->Data();
    45094545        pn=pn->next;
    45104546      }
    45114547      while ((pn->next!=NULL) && (pn->next->Typ()==INT_CMD))
    45124548      {
    4513         ringflaga *= (unsigned long long) pn->next->Data();
     4549        mpz_mul_ui(ringflaga, ringflaga, (unsigned int) pn->next->Data());
    45144550        pn=pn->next;
    45154551      }
    4516       if (ringflaga < 2)
    4517       {
    4518         Werror("Wrong ground ring specification (module smallet than 2)");
    4519         goto rInitError;
    4520       }
    4521       if (ringflagb < 1)
    4522       {
    4523         Werror("Wrong ground ring specification (exponent smaller than 1");
    4524         goto rInitError;
    4525       }
    4526       if (ringflagb > 1)
    4527       {
    4528         ch = ringflagb;
    4529         if ((ringflaga == 2) && (ringflagb + 2 <= 8*sizeof(NATNUMBER)))
    4530         {
    4531           ringtype = 1;       // Use Z/2^ch
    4532         }
    4533         else
    4534         {
    4535           ringtype = 3;
    4536         }
    4537       }
    4538       else
    4539       {
    4540         ringtype = 2;
    4541         ch = ringflaga;
    4542       }
    4543     }
    4544     else
     4552    }
     4553    if ((mpz_cmp_ui(ringflaga, 1) == 0) && (mpz_cmp_ui(ringflaga, 0) < 0))
     4554    {
     4555      Werror("Wrong ground ring specification (module is 1)");
     4556      goto rInitError;
     4557    }
     4558    if (ringflagb < 1)
     4559    {
     4560      Werror("Wrong ground ring specification (exponent smaller than 1");
     4561      goto rInitError;
     4562    }
     4563    // module is 0 ---> integers
     4564    if (mpz_cmp_ui(ringflaga, 0) == 0)
    45454565    {
    45464566      ch = 0;
    45474567      ringtype = 4;
     4568    }
     4569    // we have an exponent
     4570    else if (ringflagb > 1)
     4571    {
     4572      ch = ringflagb;
     4573      if ((mpz_cmp_ui(ringflaga, 2) == 0) && (ringflagb + 2 <= 8*sizeof(NATNUMBER)))
     4574      {
     4575        ringtype = 1;       // Use Z/2^ch
     4576      }
     4577      else
     4578      {
     4579        ringtype = 3;
     4580      }
     4581    }
     4582    // just a module m > 1
     4583    else
     4584    {
     4585      ringtype = 2;
     4586      ch = mpz_get_ui(ringflaga);
    45484587    }
    45494588  }
Note: See TracChangeset for help on using the changeset viewer.