Changeset 6bb9d9 in git


Ignore:
Timestamp:
Dec 14, 2012, 4:52:05 PM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'cdfcdb8287f66bc6070028082cbbc6eff10e609b')
Children:
8c6bd4d4de4c46d6d974085a44f6e1530d956d5a
Parents:
2e85a17b690d4918b676bac33fbbe5a019e58dad
Message:
fix: rComposeRing due to fixed Z/n^m init
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/ipshell.cc

    r2e85a1 r6bb9d9  
    20182018  // 0: string: integer
    20192019  // no further entries --> Z
    2020   R->cf->modBase = (int_number) omAlloc(sizeof(mpz_t));
     2020  int_number modBase = NULL;
     2021  unsigned int modExponent = 1;
     2022
     2023  modBase = (int_number) omAlloc(sizeof(mpz_t));
    20212024  if (L->nr == 0)
    20222025  {
    2023     mpz_init_set_ui(R->cf->modBase,0);
    2024     R->cf->modExponent = 1;
     2026    mpz_init_set_ui(modBase,0);
     2027    modExponent = 1;
    20252028  }
    20262029  // ----------------------------------------
     
    20302033    if (L->m[1].rtyp!=LIST_CMD) Werror("invald data, expecting list of numbers");
    20312034    lists LL=(lists)L->m[1].data;
    2032     mpz_init(R->cf->modBase);
    20332035    if ((LL->nr >= 0) && LL->m[0].rtyp == BIGINT_CMD)
    20342036    {
    2035       number modBase = (number) LL->m[0].data;
    2036       nlGMP(modBase, (number) R->cf->modBase, R->cf);
    2037       LL->m[0].data = (void *)modBase;
    2038     }
    2039     else if ((LL->nr >= 0) && LL->m[0].rtyp == INT_CMD)
    2040     {
    2041       mpz_set_ui(R->cf->modBase,(unsigned long) LL->m[0].data);
     2037      number tmp= (number) LL->m[0].data;
     2038      n_MPZ (modBase, tmp, coeffs_BIGINT);
     2039    }
     2040    else if (LL->nr >= 0 && LL->m[0].rtyp == INT_CMD)
     2041    {
     2042      mpz_init_set_ui(modBase,(unsigned long) LL->m[0].data);
    20422043    }
    20432044    else
    20442045    {
    2045       mpz_set_ui(R->cf->modBase,0);
     2046      mpz_init_set_ui(modBase,0);
    20462047    }
    20472048    if (LL->nr >= 1)
    20482049    {
    2049       R->cf->modExponent = (unsigned long) LL->m[1].data;
     2050      modExponent = (unsigned long) LL->m[1].data;
    20502051    }
    20512052    else
    20522053    {
    2053       R->cf->modExponent = 1;
     2054      modExponent = 1;
    20542055    }
    20552056  }
    20562057  // ----------------------------------------
    2057   if ((mpz_cmp_ui(R->cf->modBase, 1) == 0) && (mpz_cmp_ui(R->cf->modBase, 0) < 0))
     2058  if ((mpz_cmp_ui(modBase, 1) == 0) && (mpz_cmp_ui(modBase, 0) < 0))
    20582059  {
    20592060    Werror("Wrong ground ring specification (module is 1)");
    20602061    return;
    20612062  }
    2062   if (R->cf->modExponent < 1)
     2063  if (modExponent < 1)
    20632064  {
    20642065    Werror("Wrong ground ring specification (exponent smaller than 1");
     
    20662067  }
    20672068  // module is 0 ---> integers
    2068   if (mpz_cmp_ui(R->cf->modBase, 0) == 0)
    2069   {
    2070     R->cf->ch = 0;
    2071     R->cf->ringtype = 4;
     2069  if (mpz_cmp_ui(modBase, 0) == 0)
     2070  {
     2071    R->cf=nInitChar(n_Z,NULL);
    20722072  }
    20732073  // we have an exponent
    2074   else if (R->cf->modExponent > 1)
    2075   {
    2076     R->cf->ch = R->cf->modExponent;
    2077     if ((mpz_cmp_ui(R->cf->modBase, 2) == 0) && (R->cf->modExponent <= 8*sizeof(NATNUMBER)))
     2074  else if (modExponent > 1)
     2075  {
     2076    //R->cf->ch = R->cf->modExponent;
     2077    if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(NATNUMBER)))
    20782078    {
    20792079      /* this branch should be active for modExponent = 2..32 resp. 2..64,
    20802080           depending on the size of a long on the respective platform */
    2081       R->cf->ringtype = 1;       // Use Z/2^ch
     2081      R->cf=nInitChar(n_Z2m,(void*)(long)modExponent);       // Use Z/2^ch
    20822082    }
    20832083    else
    20842084    {
    2085       R->cf->ringtype = 3;
     2085      //ringtype 3
     2086      ZnmInfo info;
     2087      info.base= modBase;
     2088      info.exp= modExponent;
     2089      R->cf=nInitChar(n_Znm,(void*) &info);
    20862090    }
    20872091  }
     
    20892093  else
    20902094  {
    2091     R->cf->ringtype = 2;
    2092     R->cf->ch = mpz_get_ui(R->cf->modBase);
     2095    //ringtype = 2;
     2096    //const int ch = mpz_get_ui(modBase);
     2097    ZnmInfo info;
     2098    info.base= modBase;
     2099    info.exp= modExponent;
     2100    R->cf=nInitChar(n_Zn,(void*) &info);
    20932101  }
    20942102}
Note: See TracChangeset for help on using the changeset viewer.