Changeset 797a9ff in git


Ignore:
Timestamp:
Oct 1, 2010, 1:53:08 PM (14 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
cd055e1dd6e77006ee3347c53932f782e97afc29
Parents:
f2de2ee419de0f638b6b86c0d38f82d6e481ae9e
Message:
primefactors usage fixed

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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/paraplanecurves.lib

    rf2de2e r797a9ff  
    18261826  bigint nn = n; if (nn < 0) { nn = -n; }
    18271827  list L = primefactors(nn);
    1828   if (L[1] != 1)
     1828  if (L[3] != 1)
    18291829  { "WARNING: command 'primefactors(.)' did not find all prime factors"; }
    18301830  int i; bigint m = bigint(1); int e; int j;
    1831   for (i = 1; i <= size(L[2]); i = i + 1)
     1831  for (i = 1; i <= size(L[1]); i++)
    18321832  {
    1833     e = L[3][i] / 2;
    1834     for (j = 1; j <= e; j = j + 1) { m = m * bigint(L[2][i]); }
     1833    e = L[2][i] / 2;
     1834    for (j = 1; j <= e; j++) { m = m * bigint(L[1][i]); }
    18351835  }
    18361836  return (m);
     
    18911891    /* For small p, we use a brute force approach: */
    18921892    int i;
    1893     for (i = 2; i < p; i = i + 1)
     1893    for (i = 2; i < p; i++)
    18941894    {
    18951895      if (((i*i) mod p) == r) { return (i); }
     
    19741974
    19751975  list L = primefactors(m);
    1976   if (L[1] != 1)
     1976  if ((L[3] != 1)||(L[3]!=-1))
    19771977 { "WARNING: command 'primefactors(.)' did not find all prime factors"; }
    19781978  int i;
    1979   for (i = 1; i <= size(L[2]); i = i + 1)
     1979  for (i = 1; i <= size(L[2]); i++)
    19801980  {
    1981     if (legendreSymbol(r, L[2][i]) == -1) { return (-1); }
     1981    if (legendreSymbol(r, L[1][i]) == -1) { return (-1); }
    19821982  }
    19831983  /* now we know that there is some x in {0, 1, m-1} with
     
    19961996    list roots;
    19971997    // 2.1):
    1998     for (i = 1; i <= size(L[2]); i = i + 1)
    1999     {
    2000       roots = insert(roots, rootModP(r mod L[2][i], L[2][i]), size(roots));
     1998    for (i = 1; i <= size(L[1]); i++)
     1999    {
     2000      roots = insert(roots, rootModP(r mod L[1][i], L[1][i]), size(roots));
    20012001    }
    20022002
    20032003    // 2.2):
    20042004    bigint c; bigint l; bigint temp; bigint pPower; int e;
    2005     for (i = 1; i <= size(roots); i = i + 1)
    2006     {
    2007       pPower = bigint(L[2][i]);
    2008       for (e = 2; e <= L[3][i]; e = e + 1)
     2005    for (i = 1; i <= size(roots); i++)
     2006    {
     2007      pPower = bigint(L[1][i]);
     2008      for (e = 2; e <= L[2][i]; e++)
    20092009      {
    20102010        c = bigint(roots[i]); l = pPower;
    20112011        temp = r - c * c; l = bigint(2) * c * l; c = temp;
    20122012        c = c div pPower; l = l div pPower;
    2013         c = c mod L[2][i]; l = l mod L[2][i];
    2014         c = (c * bigint(inverseModP(l, L[2][i]))) mod L[2][i];
     2013        c = c mod L[1][i]; l = l mod L[1][i];
     2014        c = (c * bigint(inverseModP(l, L[1][i]))) mod L[1][i];
    20152015        c = bigint(roots[i]) + c * pPower;
    2016         pPower = pPower * L[2][i]; roots[i] = c;
     2016        pPower = pPower * L[1][i]; roots[i] = c;
    20172017      }
    20182018    }
     
    20202020    // 2.3):
    20212021    list mm; bigint z; int j;
    2022     for (i = 1; i <= size(L[2]); i = i + 1)
    2023     {
    2024       z = bigint(L[2][i]);
    2025       for (j = 2; j <= L[3][i]; j = j + 1)
     2022    for (i = 1; i <= size(L[1]); i++)
     2023    {
     2024      z = bigint(L[1][i]);
     2025      for (j = 2; j <= L[2][i]; j++)
    20262026      {
    2027         z = z * bigint(L[2][i]);
     2027        z = z * bigint(L[1][i]);
    20282028      }
    20292029      mm = insert(mm, z, size(mm));
     
    20462046  bigint x = bigint(0); int i; bigint N; list l;
    20472047  bigint M = bigint(mm[1]);
    2048   for (i = 2; i <= size(mm); i = i + 1) { M = M * bigint(mm[i]); }
    2049   for (i = 1; i <= size(mm); i = i + 1)
     2048  for (i = 2; i <= size(mm); i++) { M = M * bigint(mm[i]); }
     2049  for (i = 1; i <= size(mm); i++)
    20502050  {
    20512051    N = M div mm[i];
Note: See TracChangeset for help on using the changeset viewer.