Changeset 12ea9d in git


Ignore:
Timestamp:
Jan 30, 2008, 5:14:25 PM (16 years ago)
Author:
Oliver Wienand <wienand@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'a69e2b93742879ecc5ec70006f5f272874f94e7e')
Children:
af378f726d1e5204f8934b4281bd84a2d50ab8ed
Parents:
122981d0e106581ee4b7623ee3c76393fef4568a
Message:
numbers.cc:
n^m ringtyp

ring.cc:
ringausgabe für long long okay

ring.h, structs.h:
ull für base

rmodulon.cc:
init, set für llu


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

Legend:

Unmodified
Added
Removed
  • kernel/numbers.cc

    r122981 r12ea9d  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: numbers.cc,v 1.11 2007-07-03 14:45:57 Singular Exp $ */
     4/* $Id: numbers.cc,v 1.12 2008-01-30 16:14:24 wienand Exp $ */
    55
    66/*
     
    147147  /*----------------------ring Z / n----------------*/
    148148  else if (rField_is_Ring_ModN(r))
     149  {
     150    nrnSetExp(c, r);
     151  }
     152#endif
     153#ifdef HAVE_RINGMODN
     154  /*----------------------ring Z / n----------------*/
     155  else if (rField_is_Ring_PtoM(r))
    149156  {
    150157    nrnSetExp(c, r);
     
    370377#ifdef HAVE_RINGMODN
    371378  /* -------------- Z/n ----------------------- */
    372   else if (rField_is_Ring_ModN(r))
     379  else if (rField_is_Ring_ModN(r) || rField_is_Ring_PtoM(r)
     380  )
    373381  {
    374382     nrnInitExp(c,r);
  • kernel/ring.cc

    r122981 r12ea9d  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.71 2008-01-30 09:01:38 wienand Exp $ */
     4/* $Id: ring.cc,v 1.72 2008-01-30 16:14:24 wienand Exp $ */
    55
    66/*
     
    277277#endif
    278278#ifdef HAVE_RINGMODN
    279     if (rField_is_Ring_ModN(r)) Print("Z/%d\n", r->ringflaga);
     279    if (rField_is_Ring_ModN(r)) Print("Z/%llu\n", r->ringflaga);
    280280#endif
    281281#ifdef HAVE_RING2TOM
    282     if (rField_is_Ring_2toM(r)) Print("Z/2^%d\n", r->ringflagb);
     282    if (rField_is_Ring_2toM(r)) Print("Z/2^%llu\n", r->ringflagb);
    283283#endif
    284 #ifdef HAVE_RINGPTOM
    285     if (rField_is_Ring_PtoM(r)) Print("Z/%d^%d\n", r->ringflaga, r->ringflagb);
     284#ifdef HAVE_RINGMODN
     285    if (rField_is_Ring_PtoM(r)) Print("Z/%llu^%u\n", r->ringflaga, r->ringflagb);
    286286#endif
    287287  }
  • kernel/ring.h

    r122981 r12ea9d  
    77* ABSTRACT - the interpreter related ring operations
    88*/
    9 /* $Id: ring.h,v 1.23 2007-07-19 11:54:50 Singular Exp $ */
     9/* $Id: ring.h,v 1.24 2008-01-30 16:14:25 wienand Exp $ */
    1010
    1111/* includes */
     
    9898inline BOOLEAN rField_is_Ring_ModN(ring r=currRing)
    9999{ return (r->ringtype == 2); }
    100 #endif
    101 
    102 #ifdef HAVE_RINGPTOM
     100
    103101inline BOOLEAN rField_is_Ring_PtoM(ring r=currRing)
    104102{ return (r->ringtype == 3); }
  • kernel/rmodulon.cc

    r122981 r12ea9d  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: rmodulon.cc,v 1.9 2008-01-30 13:03:41 wienand Exp $ */
     4/* $Id: rmodulon.cc,v 1.10 2008-01-30 16:14:25 wienand Exp $ */
    55/*
    66* ABSTRACT: numbers modulo n
     
    2424typedef MP_INT *int_number;
    2525
    26 int_number nrnModul;
    27 int_number nrnMinusOne;
    28 
    29 // int_number nrnModul;
    30 // int_number nrnMinusOne;
     26int_number nrnModul = NULL;
     27int_number nrnMinusOne = NULL;
     28unsigned long nrnExponent = 0;
     29unsigned long long nrnBase = 0;
    3130
    3231/*
     
    9089  mpz_pow_ui(erg, (int_number) a, i);
    9190  mpz_mod(erg, erg, nrnModul);
     91//  int_number tmp = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     92//  mpz_init(tmp);
     93//  mpz_clear(erg);
     94//  omFree(erg);
     95//  erg = tmp;
    9296  *result = (number) erg;
    9397}
     
    205209    if (!nrnIsUnit((number) erg))
    206210    {
    207       WarnS("Division by non divisible element.");
     211      WarnS("Division not possible, even by cancelling zero divisors.");
    208212      WarnS("Result is zero.");
     213      mpz_set_ui(erg, 0);
     214      mpz_clear(gcd);
     215      omFree(gcd);
     216      return (number) erg;
    209217    }
    210     gcd = (int_number) nrnInvers((number) erg);
     218    int_number tmp = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     219    mpz_init(tmp);
     220    tmp = (int_number) nrnInvers((number) erg);
    211221    mpz_divexact(erg, (int_number) a, gcd);
    212     mpz_mul(erg, erg, gcd);
     222    mpz_mul(erg, erg, tmp);
    213223    mpz_clear(gcd);
    214224    omFree(gcd);
     225    mpz_clear(tmp);
     226    omFree(tmp);
    215227    mpz_mod(erg, erg, nrnModul);
    216228    return (number) erg;
     
    228240number  nrnInvers (number c)
    229241{
    230   number s;
    231   number t;
    232   number k;
    233 /*
    234  * Give the largest non unit k, such that a = x * k, b = y * k has
    235  * a solution and r, s, s.t. k = s*a + t*b
    236  */
    237   k = nrnExtGcd((number) nrnModul, c, &s, &t);
    238   if (!nrnIsOne((number) k))
    239   {
    240     WarnS("Non invertible element.");
    241     return nrnInit(0);                                   //TODO
    242   }
    243   mpz_clear((int_number) k);
    244   omFree((ADDRESS) k);
    245   mpz_clear((int_number) s);
    246   omFree((ADDRESS) s);
    247   return (number) t;
     242  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     243  mpz_init(erg);
     244  mpz_invert(erg, (int_number) c, nrnModul);
     245  return (number) erg;
    248246}
    249247
     
    266264 */
    267265
     266void mpz_set_ull(int_number res, unsigned long long xx)
     267{
     268  unsigned long h = xx >> 32;
     269  mpz_set_ui (res, h);
     270  mpz_mul_2exp (res, res, 32);
     271  mpz_add_ui (res, res, (unsigned long) xx);
     272}
     273
    268274void nrnSetExp(int m, ring r)
    269275{
    270   nrnModul = (int_number) nrnInit(m);
     276  if ((nrnBase == r->ringflaga) && (nrnExponent == r->ringflagb)) return;
     277  nrnBase = r->ringflaga;
     278  nrnExponent = r->ringflagb;
     279  if (nrnModul != NULL)
     280  {
     281    mpz_clear(nrnModul);
     282    omFree(nrnModul);
     283    mpz_clear(nrnMinusOne);
     284    omFree(nrnMinusOne);
     285  }
     286  nrnModul = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     287  mpz_init(nrnModul);
     288  mpz_set_ull(nrnModul, nrnBase);
     289  mpz_pow_ui(nrnModul, nrnModul, nrnExponent);
     290
    271291  nrnMinusOne = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    272292  mpz_init(nrnMinusOne);
    273293  mpz_sub_ui(nrnMinusOne, nrnModul, 1);
    274 
    275 //  PrintS("Modul: ");
    276 //  Print("%d\n", nrnModul);
    277294}
    278295
    279296void nrnInitExp(int m, ring r)
    280297{
    281   nrnModul = (int_number) nrnInit(m);
    282   nrnMinusOne = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    283   mpz_init(nrnMinusOne);
    284   mpz_sub_ui(nrnMinusOne, nrnModul, 1);
    285   if (m < 2)
     298  nrnSetExp(m, r);
     299  if (mpz_cmp_ui(nrnModul,2) <= 0)
    286300  {
    287301    WarnS("nInitChar failed");
  • kernel/structs.h

    r122981 r12ea9d  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: structs.h,v 1.41 2007-11-09 11:29:44 Singular Exp $ */
     6/* $Id: structs.h,v 1.42 2008-01-30 16:14:25 wienand Exp $ */
    77/*
    88* ABSTRACT
     
    550550#ifdef HAVE_RINGS
    551551  unsigned int ringtype;  /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */
    552   unsigned long ringflaga;
    553   unsigned int ringflagb;
     552  unsigned long long ringflaga;
     553  unsigned long ringflagb;
    554554#endif
    555555  int        ref; /* reference counter to the ring */
Note: See TracChangeset for help on using the changeset viewer.