Changeset 8e1c4e in git


Ignore:
Timestamp:
Jan 31, 2008, 5:13:55 PM (16 years ago)
Author:
Oliver Wienand <wienand@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd25190065115c859833252500a64cfb7b11e3a50')
Children:
31e857fefc0db942580fac2470cb89c397ef32a8
Parents:
73c6d21631d8e2c06ed5fa2c6e5dd9c80ce49f14
Message:
kutil.cc:
extendedspoly fehler

pp_Mult_nn__T.cc:
nIsZero

rmodulon.cc:
gcd/lcm ringspezifisch, umsortiert


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

Legend:

Unmodified
Added
Removed
  • kernel/kutil.cc

    r73c6d21 r8e1c4e  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.75 2008-01-30 18:56:36 wienand Exp $ */
     4/* $Id: kutil.cc,v 1.76 2008-01-31 16:13:54 wienand Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    26512651      }
    26522652#endif
    2653       poly tmp = p_ISet((long) ((p)->coef), currRing);
     2653      poly tmp = pInit();
     2654      pSetCoeff0(tmp, pGetCoeff(p));
    26542655      for (int i = 1; i <= currRing->N; i++)
    26552656      {
     
    26572658      }
    26582659      p_Setm(tmp, currRing);
     2660      pSetCoeff0(p, NULL);
    26592661      p = p_LmDeleteAndNext(p, strat->tailRing);
    26602662      pNext(tmp) = p;
     
    44204422  if ((strat->sl>=0)
    44214423#ifdef HAVE_RINGS
    4422        && nIsUnit(pGetCoeff(strat->L[strat->Ll].p))
     4424       && nIsUnit(pGetCoeff(strat->S[0]))
    44234425#endif
    44244426       && pIsConstant(strat->S[0]))
  • kernel/pp_Mult_nn__T.cc

    r73c6d21 r8e1c4e  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: pp_Mult_nn__T.cc,v 1.6 2007-05-10 08:12:43 wienand Exp $
     9 *  Version: $Id: pp_Mult_nn__T.cc,v 1.7 2008-01-31 16:13:55 wienand Exp $
    1010 *******************************************************************/
    1111
     
    3737    number nc = pGetCoeff(p);
    3838    number tmp = n_Mult(n, nc, r);
    39     if (tmp != NULL)
     39    if (nIsZero(tmp))
    4040    {
    4141      p_AllocBin(pNext(q), bin, r);
  • kernel/rmodulon.cc

    r73c6d21 r8e1c4e  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: rmodulon.cc,v 1.12 2008-01-30 19:10:46 wienand Exp $ */
     4/* $Id: rmodulon.cc,v 1.13 2008-01-31 16:13:55 wienand Exp $ */
    55/*
    66* ABSTRACT: numbers modulo n
     
    2929unsigned long long nrnBase = 0;
    3030
     31
     32/*
     33 * create a number from int
     34 */
     35number nrnInit (int i)
     36{
     37  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     38  mpz_init_set_si(erg, i);
     39  mpz_mod(erg, erg, nrnModul);
     40  return (number) erg;
     41}
     42
     43void nrnDelete(number *a, const ring r)
     44{
     45  mpz_clear((int_number) *a);
     46  omFree((ADDRESS) *a);
     47}
     48
     49/*
     50 * convert a number to int (-p/2 .. p/2)
     51 */
     52int nrnInt(number &n)
     53{
     54  return (int) mpz_get_si( (int_number) &n);
     55}
     56
    3157/*
    3258 * Multiply two numbers
     
    4167}
    4268
     69void nrnPower (number a, int i, number * result)
     70{
     71  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     72  mpz_init(erg);
     73  mpz_powm_ui(erg, (int_number) a, i, nrnModul);
     74  *result = (number) erg;
     75}
     76
     77number nrnAdd (number a, number b)
     78{
     79  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     80  mpz_init(erg);
     81  mpz_add(erg, (int_number) a, (int_number) b);
     82  mpz_mod(erg, erg, nrnModul);
     83  return (number) erg;
     84}
     85
     86number nrnSub (number a, number b)
     87{
     88  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     89  mpz_init(erg);
     90  mpz_sub(erg, (int_number) a, (int_number) b);
     91  mpz_mod(erg, erg, nrnModul);
     92  return (number) erg;
     93}
     94
     95number nrnNeg (number c)
     96{
     97  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     98  mpz_init(erg);
     99  mpz_sub(erg, nrnModul, (int_number) c);
     100  return (number) erg;
     101}
     102
     103number  nrnInvers (number c)
     104{
     105  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     106  mpz_init(erg);
     107  mpz_invert(erg, (int_number) c, nrnModul);
     108  return (number) erg;
     109}
     110
    43111/*
    44112 * Give the smallest non unit k, such that a * x = k = b * y has a solution
     113 * TODO: lcm(gcd,gcd) besser als gcd(lcm) ?
    45114 */
    46115number nrnLcm (number a,number b,ring r)
    47116{
    48   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    49   mpz_init(erg);
    50   mpz_lcm(erg, (int_number) a, (int_number) b);
    51   mpz_mod(erg, erg, nrnModul);
     117  number erg = nrnGcd(NULL, a, NULL);
     118  number tmp = nrnGcd(NULL, b, NULL);
     119  mpz_lcm((int_number) erg, (int_number) erg, (int_number) tmp);
     120  nrnDelete(&tmp, NULL);
    52121  return (number) erg;
    53122}
     
    64133  if (b == NULL) b = (number) nrnModul;
    65134  mpz_gcd(erg, (int_number) a, (int_number) b);
    66   return (number) erg;
    67 }
    68 
     135  mpz_gcd(erg, erg, nrnModul);
     136  return (number) erg;
     137}
     138
     139/* Not needed any more, but may have room for improvement
    69140number nrnGcd3 (number a,number b, number c,ring r)
    70141{
     
    76147  mpz_gcd(erg, (int_number) a, (int_number) b);
    77148  mpz_gcd(erg, erg, (int_number) c);
    78   return (number) erg;
    79 }
    80 
     149  mpz_gcd(erg, erg, nrnModul);
     150  return (number) erg;
     151}
     152*/
    81153
    82154/*
     
    93165  mpz_init(bt);
    94166  mpz_gcdext(erg, bs, bt, (int_number) a, (int_number) b);
     167  mpz_mod(bs, bs, nrnModul);
     168  mpz_mod(bt, bt, nrnModul);
    95169  *s = (number) bs;
    96170  *t = (number) bt;
     
    98172}
    99173
    100 void nrnPower (number a, int i, number * result)
    101 {
    102   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    103   mpz_init(erg);
    104   mpz_powm_ui(erg, (int_number) a, i, nrnModul);
    105   *result = (number) erg;
    106 }
    107 
    108 /*
    109  * create a number from int
    110  */
    111 number nrnInit (int i)
    112 {
    113   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    114   mpz_init_set_si(erg, i);
    115   mpz_mod(erg, erg, nrnModul);
    116   return (number) erg;
    117 }
    118 
    119 void nrnDelete(number *a, const ring r)
    120 {
    121   mpz_clear((int_number) *a);
    122   omFree((ADDRESS) *a);
    123 }
    124 
    125 /*
    126  * convert a number to int (-p/2 .. p/2)
    127  */
    128 int nrnInt(number &n)
    129 {
    130   return (int) mpz_get_si( (int_number) &n);
    131 }
    132 
    133 number nrnAdd (number a, number b)
    134 {
    135   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    136   mpz_init(erg);
    137   mpz_add(erg, (int_number) a, (int_number) b);
    138   mpz_mod(erg, erg, nrnModul);
    139   return (number) erg;
    140 }
    141 
    142 number nrnSub (number a, number b)
    143 {
    144   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    145   mpz_init(erg);
    146   mpz_sub(erg, (int_number) a, (int_number) b);
    147   mpz_mod(erg, erg, nrnModul);
    148   return (number) erg;
     174BOOLEAN nrnIsZero (number  a)
     175{
     176  return 0 == mpz_cmpabs_ui((int_number) a, 0);
     177}
     178
     179BOOLEAN nrnIsOne (number a)
     180{
     181  return 0 == mpz_cmp_si((int_number) a, 1);
     182}
     183
     184BOOLEAN nrnIsMOne (number a)
     185{
     186  return 0 == mpz_cmp((int_number) a, nrnMinusOne);
     187}
     188
     189BOOLEAN nrnEqual (number a,number b)
     190{
     191  return 0 == mpz_cmp((int_number) a, (int_number) b);
     192}
     193
     194BOOLEAN nrnGreater (number a,number b)
     195{
     196  return 0 < mpz_cmp((int_number) a, (int_number) b);
     197}
     198
     199BOOLEAN nrnGreaterZero (number k)
     200{
     201  return 0 <= mpz_cmp_si((int_number) k, 0);
     202}
     203
     204BOOLEAN nrnIsUnit (number a)
     205{
     206  number tmp = nrnGcd(a, (number) nrnModul, NULL);
     207  bool res = nrnIsOne(tmp);
     208  nrnDelete(&tmp, NULL);
     209  return res;
    149210}
    150211
     
    171232}
    172233
    173 BOOLEAN nrnIsUnit (number a)
    174 {
    175   number tmp = nrnGcd(a, (number) nrnModul, NULL);
    176   bool res = nrnIsOne(tmp);
    177   nrnDelete(&tmp, NULL);
     234BOOLEAN nrnDivBy (number a,number b)
     235{
     236  number bs = nrnIntDiv(b, nrnGcd(a, b, NULL));
     237  bool res = nrnIsUnit(bs);
     238  nrnDelete(&bs, NULL);
    178239  return res;
    179 }
    180 
    181 BOOLEAN nrnIsZero (number  a)
    182 {
    183   return 0 == mpz_cmpabs_ui((int_number) a, 0);
    184 }
    185 
    186 BOOLEAN nrnIsOne (number a)
    187 {
    188   return 0 == mpz_cmp_si((int_number) a, 1);
    189 }
    190 
    191 BOOLEAN nrnIsMOne (number a)
    192 {
    193   return 0 == mpz_cmp((int_number) a, nrnMinusOne);
    194 }
    195 
    196 BOOLEAN nrnEqual (number a,number b)
    197 {
    198   return 0 == mpz_cmp((int_number) a, (int_number) b);
    199 }
    200 
    201 BOOLEAN nrnGreater (number a,number b)
    202 {
    203   return 0 < mpz_cmp((int_number) a, (int_number) b);
    204 }
    205 
    206 BOOLEAN nrnGreaterZero (number k)
    207 {
    208   return 0 <= mpz_cmp_si((int_number) k, 0);
    209240}
    210241
     
    215246  if (nrnDivBy(b, a)) return 1;
    216247  return 2;
    217 }
    218 
    219 BOOLEAN nrnDivBy (number a,number b)
    220 {
    221   number bs = nrnIntDiv(b, nrnGcd(a, b, NULL));
    222   bool res = nrnIsUnit(bs);
    223   nrnDelete(&bs, NULL);
    224   return res;
    225248}
    226249
     
    273296}
    274297
    275 number  nrnInvers (number c)
    276 {
    277   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    278   mpz_init(erg);
    279   mpz_invert(erg, (int_number) c, nrnModul);
    280   return (number) erg;
    281 }
    282 
    283 number nrnNeg (number c)
    284 {
    285   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    286   mpz_init(erg);
    287   mpz_sub(erg, nrnModul, (int_number) c);
    288   return (number) erg;
    289 }
    290 
    291298nMapFunc nrnSetMap(ring src, ring dst)
    292299{
    293300  return NULL;      /* default */
    294301}
    295 
    296302
    297303/*
Note: See TracChangeset for help on using the changeset viewer.