Changeset 0486a3 in git for libpolys/coeffs


Ignore:
Timestamp:
Dec 14, 2012, 4:47:41 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
2e85a17b690d4918b676bac33fbbe5a019e58dad
Parents:
f489beab9ee2066d042d018e9e5db927bdfe99a4
Message:
fix: init of Z/n^m
- now takes a ZnmInfo with modBase=n and modExponent=m
Location:
libpolys/coeffs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/rmodulon.cc

    rf489bea r0486a3  
    2525/// Our Type!
    2626static const n_coeffType ID = n_Zn;
     27static const n_coeffType ID2 = n_Znm;
    2728
    2829extern omBin gmp_nrz_bin;
     
    3233  long l = (long)mpz_sizeinbase(r->modBase, 10) + 2;
    3334  char* s = (char*) omAlloc(l);
    34   if (nCoeff_is_Ring_ModN(r)) Print("//  Z/%s\n", s);
    35   else if (nCoeff_is_Ring_PtoM(r)) Print("//  Z/%s^%lu\n", s, r->modExponent);
     35  s= mpz_get_str (s, 10, r->modBase);
     36  if (nCoeff_is_Ring_ModN(r)) Print("//   coeff. ring is : Z/%s\n", s);
     37  else if (nCoeff_is_Ring_PtoM(r)) Print("//   coeff. ring is : Z/%s^%lu\n", s, r->modExponent);
    3638  omFreeSize((ADDRESS)s, l);
    3739}
     
    4749BOOLEAN nrnInitChar (coeffs r, void* p)
    4850{
    49   assume( getCoeffType(r) == ID );
    50   nrnInitExp((int)(long)(p), r);
    51   r->ringtype = 2;
    52 
     51  assume( (getCoeffType(r) == ID) || (getCoeffType (r) == ID2) );
     52  ZnmInfo * info= (ZnmInfo *) p;
     53  r->modBase = (int_number) omAlloc(sizeof(mpz_t));
     54  mpz_init_set (r->modBase, info->base);
     55
     56  nrnInitExp (info->exp, r);
     57
     58  if (info->exp > 1)
     59    r->ringtype= 3;
     60  else
     61    r->ringtype= 2;
    5362  /* next computation may yield wrong characteristic as r->modNumber
    5463     is a GMP number */
     
    564573 */
    565574
    566 void nrnSetExp(int m, coeffs r)
     575void nrnSetExp(unsigned long m, coeffs r)
    567576{
    568577  /* clean up former stuff */
    569   if (r->modBase   != NULL) mpz_clear(r->modBase);
     578  //if (r->modBase   != NULL) mpz_clear(r->modBase);
    570579  if (r->modNumber != NULL) mpz_clear(r->modNumber);
    571580
     581  r->modExponent= m;
    572582  /* this is Z/m = Z/(m^1), hence set modBase = m, modExponent = 1: */
    573   r->modBase = (int_number)omAllocBin(gmp_nrz_bin);
    574   mpz_init(r->modBase);
    575   mpz_set_ui(r->modBase, (unsigned long)m);
    576   r->modExponent = 1;
     583  //r->modBase = (int_number)omAllocBin(gmp_nrz_bin);
     584  //mpz_init(r->modBase);
     585  //mpz_set_ui(r->modBase, (unsigned long)m);
    577586  r->modNumber = (int_number)omAllocBin(gmp_nrz_bin);
    578   mpz_init(r->modNumber);
    579   mpz_set(r->modNumber, r->modBase);
    580   /* mpz_pow_ui(r->modNumber, r->modNumber, r->modExponent); */
    581 }
    582 
    583 /* We expect this ring to be Z/m for some m > 2 which is not a prime. */
    584 void nrnInitExp(int m, coeffs r)
    585 {
    586   if (m <= 2) WarnS("nrnInitExp failed (m in Z/m too small)");
     587  mpz_init_set (r->modNumber, r->modBase);
     588  mpz_pow_ui (r->modNumber, r->modNumber, m);
     589}
     590
     591/* We expect this ring to be Z/n^m for some m > 0 and for some n > 2 which is not a prime. */
     592void nrnInitExp(unsigned long m, coeffs r)
     593{
    587594  nrnSetExp(m, r);
     595  assume (r->modNumber != NULL);
     596  if (mpz_cmp_ui(r->modNumber,2) <= 0)
     597    WarnS("nrnInitExp failed (m in Z/m too small)");
    588598}
    589599
  • libpolys/coeffs/rmodulon.h

    rf489bea r0486a3  
    1414#define NATNUMBER unsigned long
    1515#endif
     16
     17typedef struct { int_number base; NATNUMBER exp; } ZnmInfo;
    1618
    1719BOOLEAN nrnInitChar    (coeffs r, void*);
     
    5052BOOLEAN nrnDBTest      (number a, const char *f, const int l, const coeffs r);
    5153#endif
    52 void    nrnSetExp(int c, const coeffs r);
    53 void    nrnInitExp(int c, const coeffs r);
     54void    nrnSetExp(unsigned long c, const coeffs r);
     55void    nrnInitExp(unsigned long c, const coeffs r);
    5456
    5557#endif
Note: See TracChangeset for help on using the changeset viewer.