Changeset 750069 in git


Ignore:
Timestamp:
Sep 22, 2016, 3:41:32 PM (8 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
4ef909357cd2764e39044e78dc5f8f271de19c21
Parents:
c4ea0bb97e0fcd6d7e4ea58106ce9935683b32de6c086a438d710cf8f1f5eac494377370eacf969c
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2016-09-22 15:41:32+02:00
git-committer:
GitHub <noreply@github.com>2016-09-22 15:41:32+02:00
Message:
Merge pull request #789 from adipopescu/Reduce_Bound

Reduce bound
Files:
1 added
52 edited

Legend:

Unmodified
Added
Removed
  • README.md

    r6c086a4 r750069  
    2626
    2727* [Developer and Reference Manual:](@ref main_page)
    28    <http://www.mathematik.uni-kl.de/~motsak/dox/html>
     28   <http://www.singular.uni-kl.de/dox/html>
    2929
  • Singular/LIB/classify_aeq.lib

    r6c086a4 r750069  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="version classify_aeq.lib 4.0.0.0 Jun_2013 "; // $Id$
     2version="version classify_aeq.lib 4.0.3.2 Sep_2016 "; // $Id$
    33category="Singularities";
    44info="
     
    2525  [5] Ishikawa,G; Janeczko,S.: The Complex Symplectic Moduli Spaces of Unimodal Parametric Plane Curve  NEU Singularities. Insitute of Mathematics of the Polish Academy of Sciences,Preprint 664(2006)
    2626PROCEDURES:
    27           sagbiAlg(G);    Compute the Sagbi-basis of the Algebra.
    28           sagbiMod(I,A);  Compute the Sagbi- basis of the Module.
    29           semiGroup(G);   Compute the Semi-Group of the Algebra provided the input is Sagbi Bases of the Algebra.
    30           semiMod(I,A);   Compute the Semi-Module provided that the input are the Sagbi Bases of the Algebra resp.Module.
    31           planeCur(I);    Compute the type of the Simple Plane Curve singularity.
    32           spaceCur(I);    Compute the type of the simple Space Curve singularity.
     27  sagbiAlg(G);    Compute the Sagbi-basis of the Algebra.
     28  sagbiMod(I,A);  Compute the Sagbi- basis of the Module.
     29  semiGroup(G);   Compute the Semi-Group of the Algebra provided the input is Sagbi Bases of the Algebra.
     30  semiMod(I,A);   Compute the Semi-Module provided that the input are the Sagbi Bases of the Algebra resp.Module.
     31  planeCur(I);    Compute the type of the Simple Plane Curve singularity.
     32  spaceCur(I);    Compute the type of the simple Space Curve singularity.
     33  inVar(I);       computes for the parametrization defined by Is
     34                  semi group, semi module of differentials,
     35                  Zariski number and moduli
     36  normalForm(I);  computes for the parametrization defined by I
     37                  normal form, semi group, semi module of differentials,
     38                  Zariski number and moduli
    3339";
    3440LIB "algebra.lib";
     
    19211927   return(K);
    19221928}
     1929
     1930proc inVar(ideal I)
     1931"USAGE:   inVar(I);  I=ideal, I=<x(t),y(t)>, ord(x(t))=n<ord(y(t))=m,
     1932          n does not divide m
     1933COMPUTE:  for the parametrization defined by I semi group, semi module
     1934          of differentials, Zariski number and moduli
     1935RETURN:  a list L with 5 entries
     1936   L[1] the semi group Gamma
     1937   L[2] the semi module Lambda
     1938   L[3] 0 if Lambda=Gamma or lambda=min(Lambda-Gamma) -n, the Zariski number
     1939   L[4] the integers i, i>lambda, i+n not in Lambda, 0 if this set is empty
     1940   L[5] 0 or the smallest integer i, i not in Gamma, i+m-n not in Gamma
     1941        i-lambda not in Gamma but i+n in Lambda
     1942EXAMPLE:  example inVar; shows an example"
     1943{
     1944   ideal G=sagbiAlg(I);
     1945   ideal M=diff(I,t);
     1946   ideal K=sagbiMod(M,G);
     1947   list L=semiMod(K,G);
     1948   intvec v=L[3];   //semi group Gamma
     1949   intvec w=L[6]+1;
     1950   w=0,w;           //semin module Lambda
     1951   intvec mo;
     1952   int i,l,k;
     1953   l=-1;
     1954   int n=ord(G[1]);
     1955   int m=ord(G[2]);
     1956   for(i=1;i<=size(w);i++)
     1957   {
     1958      if(v[i]!=w[i])
     1959      {
     1960         l=w[i]-v[2];  //lambda
     1961         break;
     1962      }
     1963   }
     1964   if(i==size(w)+1)
     1965   {
     1966      for(k=i;k<=size(v);k++)
     1967      {
     1968         if(v[k]!=w[i-1]+k-i+1)
     1969         {
     1970            l=w[i-1]+k-i+1-v[2];  //lambda
     1971            break;
     1972         }
     1973      }
     1974   }
     1975
     1976   if(l==-1){return(-1);}
     1977   for(i=l+1;i<=w[size(w)]-n;i++)
     1978   {
     1979       if(!ivec(i+n,w))
     1980       {
     1981          mo=mo,i;       //i+n not in Lambda
     1982       }
     1983   }
     1984   if(size(mo)>1){mo=mo[2..size(mo)];}
     1985   for(i=l+1;i<=v[size(v)]-1;i++)
     1986   {
     1987       if(!ivec(i,v)&&!ivec(i+n-m,v)&&ivec(i+n,w)&&(i<mo[size(mo)]))
     1988       {
     1989          return(list(v,w,l,mo,i));
     1990       }
     1991   }
     1992   return(list(v,w,l,mo,0));
     1993}
     1994example
     1995{
     1996 "EXAMPLE"; echo=2;
     1997  ring r=0,t,Ds;
     1998  ideal I=t6+3t7,t8+t13+t19;
     1999  inVar(I);
     2000}
     2001
     2002static proc ivec(int a, intvec v)
     2003{
     2004   int i;
     2005   if(a>=v[size(v)]){return(a);}
     2006   for(i=1;i<=size(v);i++)
     2007   {
     2008      if(a==v[i]){return(i);}
     2009   }
     2010   return(0);
     2011}
     2012
     2013proc normalMap(ideal I, int bound)
     2014{
     2015// returns (t^n,h) A-equivalent to I modulo <t>^bound+1
     2016
     2017   I=jet(I,bound);
     2018   def R=basering;
     2019   map phi;
     2020   poly p;
     2021   if(ord(I[1])>ord(I[2])){p=I[1];I[1]=I[2];I[2]=p;}
     2022   I[1]=simplify(I[1],1);
     2023   int n=ord(I[1]);
     2024   phi=R,var(1)-1/number(n)*I[1][2]/var(1)^(n-1);
     2025   I=phi(I);
     2026   while(size(I[1])>1)
     2027   {
     2028      phi=R,var(1)-1/number(n)*I[1][2]/var(1)^(n-1);
     2029
     2030      I=jet(phi(I),bound);
     2031   }
     2032   I[2]=simplify(I[2],1);
     2033   p=lead(I[2])+reduc(I[2]-lead(I[2]),I,bound);
     2034   I[2]=p;
     2035   return(I);
     2036}
     2037
     2038static proc reduc(poly f,ideal I, int b)
     2039{
     2040// computes the normal form of f with respect to the algebra generated by I
     2041   list L=1;
     2042   map psi;
     2043   f=jet(f,b);
     2044   if(f==0){return(f);}
     2045   while((f!=0) && (L[1]!=0))
     2046   {
     2047     L= algebra_containment(lead(f),lead(I),1);
     2048     if (L[1]==1)
     2049     {
     2050        def S= L[2];
     2051        psi= S,maxideal(1),I;
     2052        f=jet(f-psi(check),b);
     2053        kill S;
     2054     }
     2055   }
     2056   return (lead(f)+reduc(f-lead(f),I,b));
     2057}
     2058
     2059proc normalForm(ideal I, list #)
     2060"USAGE:   normalForm(I), I=<x(t),y(t)> an ideal, # optional, a bound for the
     2061          conductor
     2062COMPUTE:  computes the Hefez-Hernandez normal form of the ideal I=<x(t),y(t)>
     2063RETURN:  a list L with 5 entries
     2064   L[1] the Hefei-Hernandez normal form of the ideal I=<x(t),y(t)>
     2065   L[2] the semi group Gamma
     2066   L[3] the semi module Lambda
     2067   L[4] 0 if Lambda=Gamma or lambda=min(Lambda-Gamma) -n, the Zariski number
     2068   L[5] the integers i, i>lambda, i+n not in Lambda, 0 if this set is empty
     2069EXAMPLE:  example normalForm; shows an example"
     2070{
     2071   int b,i,l,k;
     2072   poly p;
     2073   map phi;
     2074   def R=basering;
     2075   if(size(#)>0)
     2076   {
     2077      b=#[1];
     2078      ideal G=sagbiAlg(I,b);
     2079   }
     2080   else
     2081   {
     2082      ideal G=sagbiAlg(I);
     2083   }
     2084   ideal M=diff(I,t);
     2085   ideal K=sagbiMod(M,G);
     2086   list L=semiMod(K,G);
     2087   intvec v=L[3];   //semi group Gamma
     2088   intvec w=L[6]+1;
     2089   w=0,w;           //semi module Lambda
     2090   b=v[size(v)]+1;
     2091   I=normalMap(I,b);
     2092   int n=ord(I[1]);
     2093   int m=ord(I[2]);
     2094   poly g;
     2095   if(v==w){return(list(ideal(var(1)^n,var(1)^m),v,w,0,0));}
     2096   for(i=1;i<=size(w);i++)
     2097   {
     2098      if(v[i]!=w[i])
     2099      {
     2100         l=w[i]-v[2];  //lambda
     2101         break;
     2102      }
     2103   }
     2104   if(i==size(w)+1)
     2105   {
     2106      for(k=i;k<=size(v);k++)
     2107      {
     2108         if(v[k]!=w[i-1]+k-i+1)
     2109         {
     2110            l=w[i-1]+k-i+1-v[2];  //lambda
     2111            break;
     2112         }
     2113      }
     2114   }
     2115   intvec moduli;
     2116   for(i=l+1;i<=w[size(w)]-n;i++)
     2117   {
     2118       if(!ivec(i+n,w))
     2119       {
     2120          moduli=moduli,i;       //i+n not in Lambda
     2121       }
     2122   }
     2123   if(size(moduli)>1){moduli=moduli[2..size(moduli)];}
     2124   int momax=moduli[size(moduli)];
     2125   if(momax==0){momax=l;}
     2126   b=momax;
     2127   i=1;
     2128   while(i<b)
     2129   {
     2130      i++;
     2131      k=ord(I[2][i]);
     2132      if(k==-1){break;}
     2133      if(k==l){i++;k=ord(I[2][i]);}
     2134      if(k>b){return(list(jet(I,b),v,w,l,moduli));}
     2135      if(ivec(k,v))                //k is in Gamma
     2136      {
     2137        I[2]=lead(I[2])+reduc(I[2]-lead(I[2]),G,b);
     2138        i--;
     2139      }
     2140      else
     2141      {
     2142         if(ivec(k+n-m,v))         //k+n-m is in Gamma
     2143         {
     2144            phi=R,var(1)-1/number(m)*I[2][i]/var(1)^(m-1);
     2145            I=phi(I);
     2146            I[1]=lead(I[1])+reduc(I[1]-lead(I[1]),G,b);
     2147            I=normalMap(I,b);
     2148            i--;
     2149         }
     2150         else
     2151         {
     2152            if(ivec(k+n,w))         //k+n is in Lambda
     2153            {
     2154               g=findTrafo(I,i);
     2155               g=jet(g,b-m+1);
     2156               phi=R,g;
     2157               I=phi(I);
     2158               I[1]=lead(I[1])+reduc(I[1]-lead(I[1]),G,b);
     2159               I[2]=lead(I[2])+reduc(I[2]-lead(I[2]),G,b);
     2160               I=normalMap(I,b);
     2161               i--;
     2162            }
     2163         }
     2164      }
     2165      G=sagbiAlg(I,b);
     2166   }
     2167   return(list(I,v,w,l,moduli));
     2168}
     2169example
     2170{
     2171 "EXAMPLE"; echo=2;
     2172  ring r=0,t,Ds;
     2173  ideal I=t6+3t7,t8+t13+t19;
     2174  normalForm(I);
     2175}
     2176
     2177static proc findTrafo(ideal I, int i)
     2178{
     2179//I[2][i]=a*t^k, I[1]=x{t}=t^n, I[2]=y(t)=t^m+c*t^lambda+...+a*t^k+...
     2180//find the map to kill the term a*t^k of y(t) for k+n in Lambda
     2181//find g,h such that a*t^k*x'(t)=h(x(t),y(t))*x'(t)-g(x(t),y(t))*y'(t) mod t^(k+n)
     2182//return the map t---> t+g(x(t),y(t))/x'(t) mod t^(k+1)
     2183
     2184   def R0=basering;
     2185   int p=char(R0);
     2186   int k=ord(I[2][i]);
     2187   int n=ord(I[1]);
     2188   int m=ord(I[2]);
     2189   poly f=I[2][i]*diff(I[1],var(1));
     2190   ring R=p,var(1),dp;
     2191   ideal I=imap(R0,I);
     2192   poly f=imap(R0,f);
     2193   ideal Q=std(ideal(var(1)*f));
     2194   qring T=Q;
     2195   ideal I=imap(R,I);
     2196   poly f=imap(R,f);
     2197   ring S=p,(@z,@u,@v,@x,@y),(dp(1),dp(2),dp(2));
     2198   setring T;
     2199   map psi=S,f,diff(I[1],var(1)),diff(I[2],var(1)),I[1],I[2];
     2200   setring S;
     2201   ideal J=kernel(T,psi);
     2202   option(redSB);
     2203   J=std(J);
     2204   //we look for an element @z-@u*h(@x,@y)-@v*g(@x,@y) in J
     2205   for(i=1;i<=ncols(J);i++)
     2206   {
     2207      if((@z*diff(J[i],@z)+@u*diff(J[i],@u)+@v*diff(J[i],@v)==J[i])&&(deg(diff(J[i],@z))==0))
     2208      {
     2209         poly f=J[i]/(-diff(J[i],@z)); //the element is in the standard basis
     2210         break;
     2211      }
     2212   }
     2213   poly g;
     2214   if(i==ncols(J)+1)
     2215   {
     2216      //the last element in the standard basis is of type @z-@u*h(@x,@y)-@v*g(@x,@y)+k(@x,@y)
     2217      //we have to kill k(@x,@y) using the other standard basis elements
     2218      poly f=J[i-1];
     2219      ideal K;
     2220      for(i=1;i<ncols(J);i++)
     2221      {
     2222          g=lead(J[i]);
     2223          if(((g==diff(g,@u)*@u)&&(diff(g,@v)==0))||((g==diff(g,@v)*@v)&&(diff(g,@u)==0)))
     2224          {
     2225             K[size(K)+1]=J[i];
     2226          }
     2227      }
     2228      ring S1=p,(@z,@u,@v,@x,@y),(a(-1,-1,-1,0,0),dp(1),dp(2),dp(2));
     2229      ideal K=imap(S,K);
     2230      attrib(K,"isSB",1);
     2231      poly f=imap(S,f);
     2232      f=reduce(f,K);
     2233      setring S;
     2234      f=imap(S1,f);
     2235      f=f/(-diff(f,@z));  //f=@z-@u*h(@x,@y)-@v*g(@x,@y)
     2236   }
     2237   matrix M=coef(f,@v);
     2238   g=M[2,1];
     2239   setring T;
     2240   poly g=psi(g);
     2241   setring R0;
     2242   poly g=imap(T,g);
     2243   g=g/diff(I[1],var(1));
     2244   return(var(1)-g);
     2245}
     2246
     2247//============================ Examples========================
     2248/*
     2249  ring r=0,t,(c,ds);
     2250  ideal I=t4+t7,t6+t7;
     2251  normalForm(I);
     2252
     2253  ring r=0,t,(c,ds);
     2254  ideal I=t4+t7+t9,t6+t11;
     2255  normalForm(I);
     2256
     2257  ring r=0,t,(c,ds);
     2258  ideal I=t4+t5,t9+t10;
     2259  normalForm(I);
     2260
     2261  ring r=0,t,Ds;
     2262  ideal I=t6+3t7,t8+t13+t19;
     2263  normalForm(I);
     2264
     2265  ring r=32003,t,Ds;
     2266  ideal I=t8,t12+3t15+7t19;
     2267  normalForm(I);
     2268*/
    19232269////////////////////////////////////////////////////////////////////////////////
    19242270/*
  • Singular/LIB/surf.lib

    r6c086a4 r750069  
    11////////////////////////////////////////////////////////////////////////////
    2 version="version surf.lib 4.0.3.2 Jun_2016 "; // $Id$
     2version="version surf.lib 4.0.3.3 Sep_2016 "; // $Id$
    33category="Visualization";
    44info="
     
    360360      + " (The shell returned the error code " + string(i) + "." + newline
    361361      + "But since we are on Mac OS X, let us try to open SURFER.app instead..." + newline
    362       + "Appropriate SURFER.app is available for instance at http://www.mathematik.uni-kl.de/~motsak/files/SURFER.dmg";
     362      + "Appropriate SURFER.app is available for instance at ftp://www.mathematik.uni-kl.de/pub/Math/Singular/utils/SURFER.dmg";
    363363
    364364      // fallback, will only work if SURFER.app is available (e.g. in /Applications)
  • Singular/dyn_modules/syzextra/syzextra.cc

    r6c086a4 r750069  
    166166    pNext(s) = NULL;
    167167
    168     if( !n_IsZero( p_GetCoeff(s, R), R) )
     168    if( !n_IsZero( pGetCoeff(s), R->cf) )
    169169    {
    170170      const int i = p_GetComp(s, R) - 1;
     
    480480
    481481    poly m = p_LmInit(p, r);
    482     p_SetCoeff0(m, n_Copy(p_GetCoeff(p, r), r), r);
     482    p_SetCoeff0(m, n_Copy(pGetCoeff(p), r->cf), r);
    483483
    484484    if( bSetZeroComp )
     
    647647      {
    648648        poly ss = p_LmInit(t, r);
    649         p_SetCoeff0(ss, n_Init(1, r), r); // for delete & printout only!...
     649        p_SetCoeff0(ss, n_Init(1, r->cf), r); // for delete & printout only!...
    650650        p_SetComp(ss, (*vit)->label() + 1, r); // coeff?
    651651        p_Setm(ss, r);
     
    16401640       p_Test(multiplier, r);
    16411641
    1642        if( !n_Equal( pGetCoeff(multiplier), pGetCoeff(itr->first), r) ) // normalize coeffs!?
     1642       if( !n_Equal( pGetCoeff(multiplier), pGetCoeff(itr->first), r->cf) ) // normalize coeffs!?
    16431643       {
    1644          number n = n_Div( pGetCoeff(multiplier), pGetCoeff(itr->first), r); // new number
     1644         number n = n_Div( pGetCoeff(multiplier), pGetCoeff(itr->first), r->cf); // new number
    16451645
    16461646         if( UNLIKELY( OPT__TREEOUTPUT ) )
    16471647         {
    16481648           StringSetS("");
    1649            n_Write(n, r);
     1649           n_Write(n, r->cf);
    16501650           char* s = StringEndS();
    16511651           Print("\"recale\": \"%s\", ", s);
     
    16561656
    16571657         p = p_Mult_nn(p, n, r); // !
    1658          n_Delete(&n, r);
     1658         n_Delete(&n, r->cf);
    16591659       } else
    16601660         if( UNLIKELY( OPT__PROT ) ) ++ m_stat[6]; // PrintS("l"); // lookup no rescale
     
    22162216//  assume ( !n_IsZero( p_GetCoeff(product, r), r ) );
    22172217
    2218   assume ( !n_IsZero( p_GetCoeff(lt(), r), r ) );
     2218  assume ( !n_IsZero( pGetCoeff(lt()), r->cf ) );
    22192219  assume( sev() == p_GetShortExpVector(lt(), r) );
    22202220
     
    22382238bool CLeadingTerm::DivisibilityCheck(const poly m, const poly t, const unsigned long not_sev, const ring r) const
    22392239{
    2240   assume ( !n_IsZero( p_GetCoeff(lt(), r), r ) );
     2240  assume ( !n_IsZero( pGetCoeff(lt()), r->cf ) );
    22412241  assume( sev() == p_GetShortExpVector(lt(), r) );
    22422242
    22432243  assume( m != NULL );
    22442244  assume( t != NULL );
    2245   assume ( !n_IsZero( p_GetCoeff(m, r), r ) );
    2246   assume ( !n_IsZero( p_GetCoeff(t, r), r ) );
     2245  assume ( !n_IsZero( pGetCoeff(m), r->cf ) );
     2246  assume ( !n_IsZero( pGetCoeff(t), r->cf ) );
    22472247
    22482248// assume( p_GetComp(m, r) == 0 );
     
    25212521      assume( m != NULL );
    25222522      assume( t != NULL );
    2523       assume ( !n_IsZero( p_GetCoeff(m, m_rBaseRing), m_rBaseRing ) );
    2524       assume ( !n_IsZero( p_GetCoeff(t, m_rBaseRing), m_rBaseRing ) );
     2523      assume ( !n_IsZero( pGetCoeff(m), m_rBaseRing->cf ) );
     2524      assume ( !n_IsZero( pGetCoeff(t), m_rBaseRing->cf ) );
    25252525
    25262526      p_Test(m, m_rBaseRing);
     
    27052705    }
    27062706
    2707     number n = n_Mult( p_GetCoeff(multiplier, r), p_GetCoeff(t, r), r);
     2707    number n = n_Mult( pGetCoeff(multiplier), pGetCoeff(t), r->cf);
    27082708
    27092709#if NODIVISION
    27102710    // we assume all leading coeffs to be 1!
    2711     assume( n_IsOne(p_GetCoeff(p, r), r->cf) );
     2711    assume( n_IsOne(pGetCoeff(p), r->cf) );
    27122712#else
    2713     if( !n_IsOne( p_GetCoeff(p, r), r ) )
    2714       n = n_Div(n, p_GetCoeff(p, r), r);
    2715 #endif
    2716 
    2717     p_SetCoeff0(q, n_InpNeg(n, r), r);
     2713    if( !n_IsOne( pGetCoeff(p), r ) )
     2714      n = n_Div(n, pGetCoeff(p), r->cf);
     2715#endif
     2716
     2717    p_SetCoeff0(q, n_InpNeg(n, r->cf), r);
    27182718//    n_Delete(&n, r);
    27192719
     
    29212921#if NODIVISION
    29222922    assume( n_IsOne(p_GetCoeff(p, r), r->cf) );
    2923     p_SetCoeff0(q, n_InpNeg( n_Copy(p_GetCoeff(product, r), r), r), r);
     2923    p_SetCoeff0(q, n_InpNeg( n_Copy(pGetCoeff(product), r->cf), r->cf), r);
    29242924#else
    2925     p_SetCoeff0(q, n_InpNeg( n_Div( p_GetCoeff(product, r), p_GetCoeff(p, r), r), r), r);
     2925    p_SetCoeff0(q, n_InpNeg( n_Div( pGetCoeff(product), p_GetCoeff(p), r->cf), r->cf), r);
    29262926#endif
    29272927
  • Singular/extra.cc

    rc4ea0bb r750069  
    31913191      }
    31923192      else
    3193   /*==================== RatSpoly, noncomm rational coeffs =================*/
     3193        /*==================== RatSpoly, noncomm rational coeffs =================*/
    31943194      if (strcmp(sys_cmd, "ratSpoly") == 0)
    31953195      {
     
    38253825    }
    38263826    else
     3827    /*========reduce procedure like the global one but with jet bounds=================*/
     3828        if(strcmp(sys_cmd,"reduce_bound")==0)
     3829        {
     3830          poly p;
     3831          ideal pid;
     3832          ideal q;
     3833          int bound;
     3834          int htype;
     3835          if(h!= NULL && (h->Typ() == POLY_CMD) ||  (h->Typ() == VECTOR_CMD)
     3836                      || (h->Typ() == IDEAL_CMD) || (h->Typ() == MODUL_CMD))
     3837          {
     3838            if(h->Typ() == POLY_CMD)
     3839            {
     3840              p = (poly)h->CopyD();
     3841              htype = POLY_CMD;
     3842            }
     3843            if(h->Typ() == VECTOR_CMD)
     3844            {
     3845              p = (poly)h->CopyD();
     3846              htype = VECTOR_CMD;
     3847            }
     3848            if(h->Typ() == IDEAL_CMD)
     3849            {
     3850              pid = (ideal)h->CopyD();
     3851              htype = IDEAL_CMD;
     3852            }
     3853            if(h->Typ() == MODUL_CMD)
     3854            {
     3855              pid = (ideal)h->CopyD();
     3856              htype = MODUL_CMD;
     3857            }
     3858            h=h->next;
     3859          }
     3860          else return TRUE;
     3861          if(h!= NULL && (h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD) )
     3862          {
     3863            q = (ideal)h->CopyD();
     3864            h=h->next;
     3865          }
     3866          else return TRUE;
     3867          if(h!= NULL && h->Typ() == INT_CMD)
     3868          {
     3869            bound = (long)h->CopyD();
     3870          }
     3871          else return TRUE;
     3872          res->rtyp = htype;
     3873          if(htype == POLY_CMD || htype == VECTOR_CMD)
     3874            res->data = (char *)kNFBound(q,currRing->qideal,p,bound);
     3875          if(htype == IDEAL_CMD || htype == MODUL_CMD)
     3876            res->data = (char *)kNFBound(q,currRing->qideal,pid,bound);
     3877          return FALSE;
     3878        }
     3879        else
    38273880/*==================== Error =================*/
    38283881      Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
  • Singular/iparith.cc

    r6c086a4 r750069  
    2727#include <polys/matpol.h>
    2828#include <polys/monomials/maps.h>
    29 #include <polys/coeffrings.h>
    3029#include <polys/sparsmat.h>
    3130#include <polys/weight.h>
     
    38093808{
    38103809  number n = reinterpret_cast<number>(v->Data());
    3811   res->data = reinterpret_cast<void*>(n_GetDenom(n, currRing));
     3810  res->data = reinterpret_cast<void*>(n_GetDenom(n, currRing->cf));
    38123811  return FALSE;
    38133812}
     
    38183817{
    38193818  number n = reinterpret_cast<number>(v->Data());
    3820   res->data = reinterpret_cast<void*>(n_GetNumerator(n, currRing));
     3819  res->data = reinterpret_cast<void*>(n_GetNumerator(n, currRing->cf));
    38213820  return FALSE;
    38223821}
     
    46084607{
    46094608  number nn=(number)v->Data();
    4610   res->data = (char *)(long)n_ParDeg(nn, currRing);
     4609  res->data = (char *)(long)n_ParDeg(nn, currRing->cf);
    46114610  return FALSE;
    46124611}
  • Singular/ipassign.cc

    r6c086a4 r750069  
    230230  if (n_IsZero(p, currRing->cf))
    231231  {
    232     n_Delete(&p, currRing);
     232    n_Delete(&p, currRing->cf);
    233233    if( nCoeff_is_transExt(currRing->cf) )
    234234    {
  • Singular/ipprint.cc

    r6c086a4 r750069  
    204204  }
    205205  else PrintS("field");
    206   if (r->OrdSgn==1) PrintS(", global"); else PrintS(", local/mixed");
     206  if (r->OrdSgn==1)          PrintS(", global");
     207  else if (r->MixedOrder==1) PrintS(", mixed");
     208  else                       PrintS(", local");
    207209  PrintS(" ordering\n");
    208210  rWrite(r, TRUE);
  • Singular/links/silink.cc

    r6c086a4 r750069  
    192192
    193193//--------------------------------------------------------------------------
    194 BOOLEAN slSetRingDummy(si_link, ring r, BOOLEAN send)
     194BOOLEAN slSetRingDummy(si_link, ring r, BOOLEAN)
    195195{
    196196  if (currRing!=r) rChangeCurrRing(r);
  • Singular/maps_ip.cc

    r6c086a4 r750069  
    281281      memset(v,0,sizeof(sleftv));
    282282
    283       number d = n_GetDenom(p_GetCoeff(p, currRing), currRing);
     283      number d = n_GetDenom(pGetCoeff(p), currRing->cf);
    284284      p_Test((poly)NUM((fraction)d), R);
    285285
    286286      if ( n_IsOne (d, currRing->cf) )
    287287      {
    288         n_Delete(&d, currRing); d = NULL;
     288        n_Delete(&d, currRing->cf); d = NULL;
    289289      }
    290290      else if (!p_IsConstant((poly)NUM((fraction)d), R))
    291291      {
    292292        WarnS("ignoring denominators of coefficients...");
    293         n_Delete(&d, currRing); d = NULL;
    294       }
    295 
    296       number num = n_GetNumerator(p_GetCoeff(p, currRing), currRing);
     293        n_Delete(&d, currRing->cf); d = NULL;
     294      }
     295
     296      number num = n_GetNumerator(pGetCoeff(p), currRing->cf);
    297297      memset(&tmpW,0,sizeof(sleftv));
    298298      tmpW.rtyp = POLY_CMD;
     
    307307        v->data=NULL;
    308308      }
    309       n_Delete(&num, currRing);
     309      n_Delete(&num, currRing->cf);
    310310      //TODO check for memory leaks
    311311      poly pp = pHead(p);
     
    314314      {
    315315        pSetCoeff(pp, n_Invers(d, currRing->cf));
    316         n_Delete(&d, currRing); // d = NULL;
     316        n_Delete(&d, currRing->cf); // d = NULL;
    317317      }
    318318      else
     
    332332      memset(v,0,sizeof(sleftv));
    333333
    334       number num = n_GetNumerator(p_GetCoeff(p, currRing), currRing);
     334      number num = n_GetNumerator(pGetCoeff(p), currRing->cf);
    335335      memset(&tmpW,0,sizeof(sleftv));
    336336      tmpW.rtyp = POLY_CMD;
     
    346346        v->data=NULL;
    347347      }
    348       if (num!=(number)R->qideal->m[0]) n_Delete(&num, currRing);
     348      if (num!=(number)R->qideal->m[0]) n_Delete(&num, currRing->cf);
    349349      //TODO check for memory leaks
    350350      poly pp = pHead(p);
    351351      //PrintS("map:");pWrite(pp);
    352       pSetCoeff(pp,n_Init(1,currRing));
     352      pSetCoeff(pp,n_Init(1,currRing->cf));
    353353      //PrintS("cf->");pWrite((poly)(v->data));
    354354      poly ppp = pMult((poly)(v->data),pp);
  • Singular/newstruct.cc

    r6c086a4 r750069  
    638638}
    639639
    640 BOOLEAN newstruct_deserialize(blackbox **b, void **d, si_link f)
    641 {
    642   // newstruct is serialiazed as analog to a list,
     640BOOLEAN newstruct_deserialize(blackbox **, void **d, si_link f)
     641{
     642  // newstruct is serialized as analog to a list,
    643643  // just read a list and take data,
    644644  // rtyp must be set correctly (to the blackbox id) by routine calling
  • Singular/singular-libs

    r6c086a4 r750069  
    5252        schubert.lib tasks.lib tropical.lib hdepth.lib gradedModules.lib \
    5353        arr.lib brillnoether.lib chern.lib cimonom.lib GND.lib \
    54         graal.lib hess.lib modwalk.lib rwalk.lib swalk.lib
     54        graal.lib hess.lib modwalk.lib rwalk.lib swalk.lib \
     55        classifyMapGerms.lib
    5556
    5657PLIBS = bimodules.lib bfun.lib central.lib dmod.lib dmodapp.lib dmodvar.lib\
  • Singular/subexpr.cc

    r6c086a4 r750069  
    564564    {
    565565      number n=(number)d;
    566       n_Delete(&n,r);
     566      n_Delete(&n,r->cf);
    567567      break;
    568568    }
  • Singular/walk.cc

    r6c086a4 r750069  
    9696BOOLEAN Overflow_Error =  FALSE;
    9797
     98#ifdef TIME_TEST
    9899clock_t xtif, xtstd, xtlift, xtred, xtnw;
    99100clock_t xftostd, xtextra, xftinput, to;
     101#endif
    100102
    101103/****************************
     
    16201622
    16211623  intvec* result = new intvec(niv);
    1622   intvec* result1 = new intvec(niv);
    16231624  BOOLEAN nflow = FALSE;
    16241625
     
    17671768  int nG = IDELEMS(G);
    17681769  int n = nG-1;
    1769   Print("\n//** Ideal %s besteht aus %d Polynomen mit ", Ch, nG);
     1770  Print("\n// ** Ideal %s besteht aus %d Polynomen mit ", Ch, nG);
    17701771
    17711772  for(i=0; i<nG; i++)
     
    17841785  }
    17851786  PrintS(" Monomen.\n");
    1786   Print("//** %s besitzt %d Monome.", Ch, nmon);
     1787  Print("// ** %s besitzt %d Monome.", Ch, nmon);
    17871788  PrintLn();
    17881789}
     
    29072908{
    29082909  ring r = rCopy0(currRing,FALSE,FALSE);
    2909   int i, nv = currRing->N;
     2910  int nv = currRing->N;
    29102911
    29112912  int nb = rBlocks(currRing) + 1;
     
    29472948static void DefRingPar(intvec* va)
    29482949{
    2949   int i, nv = currRing->N;
     2950  int nv = currRing->N;
    29502951  int nb = rBlocks(currRing) + 1;
    29512952
     
    29552956  res->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
    29562957  res->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));
    2957   for(i=0; i<nv; i++)
     2958  for(int i=0; i<nv; i++)
    29582959    res->wvhdl[0][i] = (*va)[i];
    29592960
     
    29962997static void DefRingParlp(void)
    29972998{
    2998   int i, nv = currRing->N;
     2999  int nv = currRing->N;
    29993000
    30003001  ring r=rCopy0(currRing,FALSE,FALSE);
     
    30323033//     r->cf->extRing->names=(char **)omAlloc(l*sizeof(char_ptr));
    30333034//
    3034 //     for(i=l-1;i>=0;i--)
     3035//     for(int i=l-1;i>=0;i--)
    30353036//     {
    30363037//       rParameter(r)[i]=omStrDup(rParameter(currRing)[i]);
     
    32163217    nwalk++;
    32173218    nstep++;
     3219#ifdef TIME_TEST
    32183220    to=clock();
     3221#endif
    32193222   // compute a next weight vector
    32203223    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     3224#ifdef TIME_TEST
    32213225    xtnw=xtnw+clock()-to;
     3226#endif
    32223227
    32233228#ifdef PRINT_VECTORS
     
    32623267    }
    32633268    oldRing = currRing;
     3269#ifdef TIME_TEST
    32643270    to=clock();
     3271#endif
    32653272    // compute an initial form ideal of <G> w.r.t. "curr_vector"
    32663273    Gomega = MwalkInitialForm(G, curr_weight);
     3274#ifdef TIME_TEST
    32673275    xtif=xtif+clock()-to;
     3276#endif
    32683277
    32693278#ifdef ENDWALKS
     
    33023311    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    33033312
     3313#ifdef TIME_TEST
    33043314    to=clock();
     3315#endif
    33053316    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
    33063317#ifdef  BUCHBERGER_ALG
     
    33103321    delete hilb_func;
    33113322#endif // BUCHBERGER_ALG
     3323#ifdef TIME_TEST
    33123324    xtstd=xtstd+clock()-to;
     3325#endif
    33133326    /* change the ring to oldRing */
    33143327    rChangeCurrRing(oldRing);
     
    33163329    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    33173330
     3331#ifdef TIME_TEST
    33183332    to=clock();
     3333#endif
    33193334    /* compute a reduced Groebner basis of <G> w.r.t. "newRing" */
    33203335    F = MLifttwoIdeal(Gomega2, M1, G);
     3336#ifdef TIME_TEST
    33213337    xtlift=xtlift+clock()-to;
     3338#endif
    33223339
    33233340    idDelete(&M1);
     
    33283345    F1 = idrMoveR(F, oldRing,currRing);
    33293346
     3347#ifdef TIME_TEST
    33303348    to=clock();
     3349#endif
    33313350    /* reduce the Groebner basis <G> w.r.t. new ring */
    33323351    G = kInterRedCC(F1, NULL);
     3352#ifdef TIME_TEST
    33333353    xtred=xtred+clock()-to;
     3354#endif
    33343355    idDelete(&F1);
    33353356
     
    39263947  // BOOLEAN nOverflow_Error = FALSE;
    39273948
     3949#ifdef TIME_TEST
    39283950  clock_t tproc=0;
    39293951  clock_t tinput = clock();
     3952#endif
    39303953
    39313954  int i,  nV = currRing->N;
     
    40194042      goto FIRST_STEP;
    40204043    }
     4044#ifdef TIME_TEST
    40214045    to=clock();
     4046#endif
    40224047    // compute an initial form ideal of <G> w.r.t. "curr_vector"
    40234048    Gomega = MwalkInitialForm(G, curr_weight);
     4049#ifdef TIME_TEST
    40244050    xtif=xtif+clock()-to;
     4051#endif
    40254052
    40264053#ifndef  BUCHBERGER_ALG
     
    40484075    newRing = currRing;
    40494076    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
     4077#ifdef TIME_TEST
    40504078    to=clock();
     4079#endif
    40514080    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    40524081#ifdef  BUCHBERGER_ALG
     
    40564085    delete hilb_func;
    40574086#endif // BUCHBERGER_ALG
     4087#ifdef TIME_TEST
    40584088    xtstd=xtstd+clock()-to;
     4089#endif
    40594090    // change the ring to oldRing
    40604091    rChangeCurrRing(oldRing);
     
    40624093    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    40634094
     4095#ifdef TIME_TEST
    40644096     to=clock();
     4097#endif
    40654098    // compute a reduced Groebner basis of <G> w.r.t. "newRing" by the lifting process
    40664099    F = MLifttwoIdeal(Gomega2, M1, G);
     4100#ifdef TIME_TEST
    40674101    xtlift=xtlift+clock()-to;
     4102#endif
    40684103    idDelete(&M1);
    40694104    idDelete(&Gomega2);
     
    40744109    F1 = idrMoveR(F, oldRing,currRing);
    40754110
     4111#ifdef TIME_TEST
    40764112    to=clock();
     4113#endif
    40774114    // reduce the Groebner basis <G> w.r.t. new ring
    40784115    G = kInterRedCC(F1, NULL);
     4116#ifdef TIME_TEST
    40794117    xtred=xtred+clock()-to;
     4118#endif
    40804119    idDelete(&F1);
    40814120
     
    40854124    }
    40864125  FIRST_STEP:
     4126#ifdef TIME_TEST
    40874127    to=clock();
     4128#endif
    40884129    Overflow_Error = FALSE;
    40894130    // compute a next weight vector
    40904131    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     4132#ifdef TIME_TEST
    40914133    xtnw=xtnw+clock()-to;
     4134#endif
    40924135#ifdef PRINT_VECTORS
    40934136    MivString(curr_weight, target_weight, next_weight);
     
    41264169        // REC_LAST_GB_ALT2:
    41274170        //nOverflow_Error = Overflow_Error;
     4171#ifdef TIME_TEST
    41284172        tproc=tproc+clock()-tinput;
     4173#endif
    41294174
    41304175        /*Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):",
     
    41654210      // nOverflow_Error = Overflow_Error;
    41664211      //Print("\n//  takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);
     4212#ifdef TIME_TEST
    41674213      tproc=tproc+clock()-tinput;
     4214#endif
    41684215      F1 = Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
    41694216    }
     
    41984245        F1 = G;
    41994246      }
     4247#ifdef TIME_TEST
    42004248      to=clock();
     4249#endif
    42014250      // Print("\n// apply the Buchberger's alg in ring = %s",rString(currRing));
    42024251      // idElements(F1, "F1");
    42034252      G = MstdCC(F1);
     4253#ifdef TIME_TEST
    42044254      xtextra=xtextra+clock()-to;
     4255#endif
    42054256
    42064257
     
    44944545  intvec* next_weight1 = MkInterRedNextWeight(curr_weight,target_weight,G);
    44954546  intvec* next_weight2 = new intvec(nV);
    4496   intvec* next_weight22 = new intvec(nV);
    44974547  intvec* result = new intvec(nV);
    44984548  intvec* curr_weight1;
     
    47584808    }
    47594809    //Print("\n//REC_GB_Mwalk: Entering the %d-th step in the %d-th recursive:\n",nwalk,tp_deg);
     4810#ifdef TIME_TEST
    47604811    to = clock();
     4812#endif
    47614813    // compute an initial form ideal of <G> w.r.t. "curr_vector"
    47624814    Gomega = MwalkInitialForm(G, curr_weight);
     4815#ifdef TIME_TEST
    47634816    xtif = xtif + clock()-to;
     4817#endif
    47644818
    47654819#ifndef  BUCHBERGER_ALG
     
    47884842    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    47894843
     4844#ifdef TIME_TEST
    47904845    to = clock();
     4846#endif
    47914847    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    47924848#ifdef  BUCHBERGER_ALG
     
    47964852    delete hilb_func;
    47974853#endif
     4854#ifdef TIME_TEST
    47984855    xtstd = xtstd + clock() - to;
     4856#endif
    47994857
    48004858    // change the ring to oldRing
     
    48044862    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    48054863
     4864#ifdef TIME_TEST
    48064865    to = clock();
     4866#endif
    48074867    F = MLifttwoIdeal(Gomega2, M1, G);
     4868#ifdef TIME_TEST
    48084869    xtlift = xtlift + clock() -to;
     4870#endif
    48094871
    48104872    idDelete(&M1);
     
    48174879    F1 = idrMoveR(F, oldRing,currRing);
    48184880
     4881#ifdef TIME_TEST
    48194882    to = clock();
     4883#endif
    48204884    // reduce the Groebner basis <G> w.r.t. new ring
    48214885    G = kInterRedCC(F1, NULL);
     4886#ifdef TIME_TEST
    48224887    xtred = xtred + clock() -to;
     4888#endif
    48234889
    48244890    idDelete(&F1);
     
    48294895    }
    48304896  NEXT_STEP:
     4897#ifdef TIME_TEST
    48314898    to = clock();
     4899#endif
    48324900    // compute a next weight vector
    48334901    intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    48344902
    48354903
     4904#ifdef TIME_TEST
    48364905    xtnw = xtnw + clock() - to;
     4906#endif
    48374907
    48384908#ifdef PRINT_VECTORS
     
    49345004        F1 = G;
    49355005      }
     5006#ifdef TIME_TEST
    49365007      to=clock();
     5008#endif
    49375009      // apply Buchberger alg to compute a red. GB of F1
    49385010      G = MstdCC(F1);
     5011#ifdef TIME_TEST
    49395012      xtextra=clock()-to;
     5013#endif
    49405014      idDelete(&F1);
    49415015      newRing = currRing;
     
    49665040  //Print("// pSetm_Error = (%d)", ErrorCheck());
    49675041
     5042#ifdef TIME_TEST
    49685043  clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
    4969   xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
    49705044  tinput = clock();
    49715045  clock_t tim;
     5046  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
     5047#endif
    49725048  nstep=0;
    49735049  int i;
     
    49965072  ring XXRing = currRing;
    49975073
     5074#ifdef TIME_TEST
    49985075  to = clock();
     5076#endif
    49995077  // the monomial ordering of this current ring would be "dp"
    50005078  G = MstdCC(Go);
     5079#ifdef TIME_TEST
    50015080  tostd = clock()-to;
     5081#endif
    50025082
    50035083  if(currRing->order[0] == ringorder_a)
     
    50085088    nwalk ++;
    50095089    nstep ++;
     5090#ifdef TIME_TEST
    50105091    to = clock();
     5092#endif
    50115093    // compute an initial form ideal of <G> w.r.t. "curr_vector"
    50125094    Gomega = MwalkInitialForm(G, curr_weight);
     5095#ifdef TIME_TEST
    50135096    tif = tif + clock()-to;
     5097#endif
    50145098    oldRing = currRing;
    50155099
     
    50185102      /* compute a reduced Groebner basis of Gomega w.r.t. >>_cw by
    50195103         the recursive changed perturbation walk alg. */
     5104#ifdef TIME_TEST
    50205105      tim = clock();
     5106#endif
    50215107#ifdef CHECK_IDEAL_MWALK
    50225108        Print("\n// **** Groebnerwalk took %d steps and ", nwalk);
     
    50415127#endif
    50425128*/
     5129#ifdef TIME_TEST
    50435130      to = clock();
     5131#endif
    50445132      F = MLifttwoIdeal(Gomega, M, G);
     5133#ifdef TIME_TEST
    50455134      xtlift = xtlift + clock() - to;
     5135#endif
    50465136
    50475137      idDelete(&Gomega);
     
    50895179      Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    50905180
     5181#ifdef TIME_TEST
    50915182      to = clock();
     5183#endif
    50925184      // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    50935185#ifdef  BUCHBERGER_ALG
     
    50975189      delete hilb_func;
    50985190#endif
     5191#ifdef TIME_TEST
    50995192      tstd = tstd + clock() - to;
     5193#endif
    51005194
    51015195      // change the ring to oldRing
     
    51045198      Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    51055199
     5200#ifdef TIME_TEST
    51065201      to = clock();
     5202#endif
    51075203      // compute a representation of the generators of submod (M) with respect
    51085204      // to those of mod (Gomega).
    51095205      // Gomega is a reduced Groebner basis w.r.t. the current ring.
    51105206      F = MLifttwoIdeal(Gomega2, M1, G);
     5207#ifdef TIME_TEST
    51115208      tlift = tlift + clock() - to;
     5209#endif
    51125210
    51135211      idDelete(&M1);
     
    51205218    }
    51215219
     5220#ifdef TIME_TEST
    51225221    to = clock();
     5222#endif
    51235223    // reduce the Groebner basis <G> w.r.t. new ring
    51245224    G = kInterRedCC(F1, NULL);
     5225#ifdef TIME_TEST
    51255226    if(endwalks != 1)
    51265227    {
     
    51315232      xtred = xtred + clock() - to;
    51325233    }
     5234#endif
    51335235    idDelete(&F1);
    51345236    if(endwalks == 1)
     
    51375239    }
    51385240  NEXT_VECTOR:
     5241#ifdef TIME_TEST
    51395242    to = clock();
     5243#endif
    51405244    // compute a next weight vector
    51415245    intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
     5246#ifdef TIME_TEST
    51425247    tnw = tnw + clock() - to;
     5248#endif
    51435249#ifdef PRINT_VECTORS
    51445250    MivString(curr_weight, target_weight, next_weight);
     
    55165622  Set_Error(FALSE);
    55175623  Overflow_Error = FALSE;
    5518   BOOLEAN endwalks = FALSE;
    55195624#ifdef TIME_TEST
    55205625  clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
     
    60756180#endif
    60766181#ifdef ENDWALKS
     6182#ifdef TIME_TEST
    60776183      if(printout > 1)
    60786184      {
     
    60806186            ((double) clock())/1000000 -((double)tim) /1000000);
    60816187      }
     6188#endif
    60826189#endif
    60836190    }
     
    62276334      }
    62286335      // LastGB is "better" than the kStd subroutine
     6336#ifdef TIME_TEST
    62296337      to=clock();
     6338#endif
    62306339      ideal eF1;
    62316340      if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1){
     
    62416350        F2=NULL;
    62426351      }
     6352#ifdef TIME_TEST
    62436353      xtextra=clock()-to;
     6354#endif
    62446355      ring exTargetRing = currRing;
    62456356
     
    66356746    to = clock();
    66366747#endif
    6637     next_weight = next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     6748    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    66386749#ifdef TIME_TEST
    66396750    tnw = tnw + clock() - to;
     
    68586969  ring new_ring, testring;
    68596970  //ring extoRing;
    6860   ideal Gomega, Gomega1, Gomega2, FF, F, F1, Gresult, Gresult1, G1, Gt;
     6971  ideal Gomega, Gomega1, Gomega2, FF, F, Gresult, Gresult1, G1, Gt;
    68616972  int nwalks = 0;
    68626973  intvec* Mwlp;
     
    73327443    G = idrMoveR(F,oRing,currRing);
    73337444/*
    7334     F1 = idrMoveR(F, oRing,currRing);
     7445    ideal F1 = idrMoveR(F, oRing,currRing);
    73357446#ifdef TIME_TEST
    73367447    to=clock();
     
    73587469  ring new_ring, testring;
    73597470  //ring extoRing;
    7360   ideal Gomega, Gomega1, Gomega2, F, FF, F1, Gresult, Gresult1, G1, Gt;
     7471  ideal Gomega, Gomega1, Gomega2, F, FF, Gresult, Gresult1, G1, Gt;
     7472#ifdef TIME_TEST
     7473  ideal F1;
     7474#endif
    73617475  intvec* Mwlp;
    73627476#ifndef BUCHBERGER_ALG
     
    82998413  //Print("\n// ring ro = %s;", rString(currRing));
    83008414
     8415#ifdef TIME_TEST
    83018416  clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
    8302 #ifdef TIME_TEST
    83038417  clock_t tinput = clock();
    83048418#endif
     
    83158429  //ideal  H1;
    83168430  ideal H2, Glp;
    8317   int nGB, endwalks = 0,  nwalkpert=0,  npertstep=0;
     8431  int nGB, endwalks = 0,  nwalkpert=0;
    83188432  intvec* Mlp =  MivMatrixOrderlp(nV);
    83198433  intvec* vector_tmp = new intvec(nV);
     
    83358449  newRing = currRing;
    83368450
     8451#ifdef TIME_TEST
    83378452  to=clock();
     8453#endif
    83388454  // compute a red. GB w.r.t. the help ring
    83398455  if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) = "dp"
     
    83498465    G = MstdCC(G);
    83508466  }
     8467#ifdef TIME_TEST
    83518468  tostd=clock()-to;
     8469#endif
    83528470
    83538471#ifdef REPRESENTATION_OF_SIGMA
     
    83728490    else
    83738491      rChangeCurrRing(VMrDefault(curr_weight));
     8492#ifdef TIME_TEST
    83748493    to=clock();
     8494#endif
    83758495    Gw = idrMoveR(G, exring,currRing);
    83768496    G = MstdCC(Gw);
    83778497    Gw = NULL;
     8498#ifdef TIME_TEST
    83788499    tostd=tostd+clock()-to;
     8500#endif
    83798501    //ivString(curr_weight,"rep. sigma");
    83808502    goto COMPUTE_NEW_VECTOR;
     
    83888510  while(1)
    83898511  {
     8512#ifdef TIME_TEST
    83908513    to=clock();
     8514#endif
    83918515    /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
    83928516    Gomega = MwalkInitialForm(G, curr_weight);
     8517#ifdef TIME_TEST
    83938518    tif=tif+clock()-to;
     8519#endif
    83948520
    83958521#ifndef  BUCHBERGER_ALG
     
    84118537    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    84128538
     8539#ifdef TIME_TEST
    84138540    to=clock();
     8541#endif
    84148542    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
    84158543#ifdef  BUCHBERGER_ALG
     
    84198547    delete hilb_func;
    84208548#endif // BUCHBERGER_ALG
     8549#ifdef TIME_TEST
    84218550    tstd=tstd+clock()-to;
     8551#endif
    84228552
    84238553    /* change the ring to oldRing */
     
    84268556    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    84278557
     8558#ifdef TIME_TEST
    84288559    to=clock();
     8560#endif
    84298561    /* compute a representation of the generators of submod (M)
    84308562       with respect to those of mod (Gomega).
    84318563       Gomega is a reduced Groebner basis w.r.t. the current ring */
    84328564    F = MLifttwoIdeal(Gomega2, M1, G);
     8565#ifdef TIME_TEST
    84338566    tlift=tlift+clock()-to;
     8567#endif
    84348568
    84358569    idDelete(&M1);
     
    84418575    F1 = idrMoveR(F, oldRing,currRing);
    84428576
     8577#ifdef TIME_TEST
    84438578    to=clock();
     8579#endif
    84448580    /* reduce the Groebner basis <G> w.r.t. new ring */
    84458581    G = kInterRedCC(F1, NULL);
     8582#ifdef TIME_TEST
    84468583    tred=tred+clock()-to;
     8584#endif
    84478585    idDelete(&F1);
    84488586
     
    84528590    nwalk++;
    84538591    nwalkpert++;
     8592#ifdef TIME_TEST
    84548593    to=clock();
     8594#endif
    84558595    // compute a next weight vector
    84568596    next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
     8597#ifdef TIME_TEST
    84578598    tnw=tnw+clock()-to;
     8599#endif
    84588600#ifdef PRINT_VECTORS
    84598601    MivString(curr_weight, target_weight, next_weight);
     
    84958637      G1 = idrMoveR(G, newRing,currRing);
    84968638
     8639#ifdef TIME_TEST
    84978640      to=clock();
     8641#endif
    84988642      /*apply kStd or LastGB to compute  a lex. red. Groebner basis of <G>*/
    84998643      if(nP == 0 || MivSame(target_tmp, iv_lp) == 0){
     
    85118655        G = idrMoveR(G, newRing,currRing);
    85128656      }
     8657#ifdef TIME_TEST
    85138658      textra=clock()-to;
     8659#endif
    85148660      npert[endwalks]=nwalk-npert_tmp;
    85158661      npert_tmp = nwalk;
     
    86308776
    86318777
    8632       npertstep = nwalk;
    86338778      nwalkpert = 1;
    86348779      nsteppert ++;
     
    86988843  //Print("\n// ring ro = %s;", rString(currRing));
    86998844
     8845#ifdef TIME_TEST
    87008846  clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
    8701 #ifdef TIME_TEST
    87028847  clock_t tinput = clock();
    87038848#endif
     
    87378882  newRing = currRing;
    87388883
     8884#ifdef TIME_TEST
    87398885  to=clock();
     8886#endif
    87408887  // compute a red. GB w.r.t. the help ring
    87418888  if(MivComp(curr_weight, iv_dp) == 1)
     
    87588905    G = MstdCC(G);
    87598906  }
     8907#ifdef TIME_TEST
    87608908  tostd=clock()-to;
     8909#endif
    87618910
    87628911#ifdef REPRESENTATION_OF_SIGMA
     
    87888937      rChangeCurrRing(VMrDefault(curr_weight));
    87898938    }
     8939#ifdef TIME_TEST
    87908940    to=clock();
     8941#endif
    87918942    Gw = idrMoveR(G, exring,currRing);
    87928943    G = MstdCC(Gw);
    87938944    Gw = NULL;
     8945#ifdef TIME_TEST
    87948946    tostd=tostd+clock()-to;
     8947#endif
    87958948    //ivString(curr_weight,"rep. sigma");
    87968949    goto COMPUTE_NEW_VECTOR;
     
    88048957  while(1)
    88058958  {
     8959#ifdef TIME_TEST
    88068960    to=clock();
     8961#endif
    88078962    // compute an initial form ideal of <G> w.r.t. "curr_vector"
    88088963    Gomega = MwalkInitialForm(G, curr_weight);
     8964#ifdef TIME_TEST
    88098965    tif=tif+clock()-to;
     8966#endif
    88108967
    88118968#ifndef  BUCHBERGER_ALG
     
    88348991    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    88358992
     8993#ifdef TIME_TEST
    88368994    to=clock();
     8995#endif
    88378996    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    88388997#ifdef  BUCHBERGER_ALG
     
    88429001    delete hilb_func;
    88439002#endif
     9003#ifdef TIME_TEST
    88449004    tstd=tstd+clock()-to;
     9005#endif
    88459006
    88469007    // change the ring to oldRing
     
    88499010    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    88509011
     9012#ifdef TIME_TEST
    88519013    to=clock();
     9014#endif
    88529015    // compute a representation of the generators of submod (M) with respect to those of mod (Gomega).
    88539016    // Gomega is a reduced Groebner basis w.r.t. the current ring
    88549017    F = MLifttwoIdeal(Gomega2, M1, G);
     9018#ifdef TIME_TEST
    88559019    tlift=tlift+clock()-to;
     9020#endif
    88569021
    88579022    idDelete(&M1);
     
    88639028    F1 = idrMoveR(F, oldRing,currRing);
    88649029
     9030#ifdef TIME_TEST
    88659031    to=clock();
     9032#endif
    88669033    // reduce the Groebner basis <G> w.r.t. new ring
    88679034    G = kInterRedCC(F1, NULL);
     9035#ifdef TIME_TEST
    88689036    tred=tred+clock()-to;
     9037#endif
    88699038    idDelete(&F1);
    88709039
     
    88739042    nwalk++;
    88749043    nwalkpert++;
     9044#ifdef TIME_TEST
    88759045    to=clock();
     9046#endif
    88769047    // compute a next weight vector
    88779048    //next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
     
    89539124    }*/
    89549125
     9126#ifdef TIME_TEST
    89559127    tnw=tnw+clock()-to;
     9128#endif
    89569129#ifdef PRINT_VECTORS
    89579130    MivString(curr_weight, target_weight, next_weight);
     
    90049177      G1 = idrMoveR(G, newRing,currRing);
    90059178
     9179#ifdef TIME_TEST
    90069180      to=clock();
     9181#endif
    90079182      // apply kStd or LastGB to compute  a lex. red. Groebner basis of <G>
    90089183      if(nP == 0 || MivSame(target_tmp, iv_lp) == 0)
     
    90229197        G = idrMoveR(G, newRing,currRing);
    90239198      }
     9199#ifdef TIME_TEST
    90249200      textra=clock()-to;
     9201#endif
    90259202      npert[endwalks]=nwalk-npert_tmp;
    90269203      npert_tmp = nwalk;
     
    92119388  Overflow_Error = FALSE;
    92129389 // BOOLEAN nOverflow_Error = FALSE;
     9390#ifdef TIME_TEST
    92139391  clock_t tproc=0;
    92149392  clock_t tinput=clock();
     9393#endif
    92159394  int i, nV = currRing->N;
    92169395
     
    93019480      goto FIRST_STEP;
    93029481    }
     9482#ifdef TIME_TEST
    93039483    to=clock();
     9484#endif
    93049485    // compute an initial form ideal of <G> w.r.t. "curr_vector"
    93059486    Gomega = MwalkInitialForm(G, curr_weight);
     9487#ifdef TIME_TEST
    93069488    xtif=xtif+clock()-to;
     9489#endif
    93079490
    93089491#ifndef  BUCHBERGER_ALG
     
    93369519#endif
    93379520*/
     9521#ifdef TIME_TEST
    93389522    to=clock();
     9523#endif
    93399524    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    93409525#ifdef  BUCHBERGER_ALG
     
    93449529    delete hilb_func;
    93459530#endif // BUCHBERGER_ALG
     9531#ifdef TIME_TEST
    93469532    xtstd=xtstd+clock()-to;
     9533#endif
    93479534
    93489535    // change the ring to oldRing
     
    93509537    M1 =  idrMoveR(M, newRing,currRing);
    93519538    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
     9539#ifdef TIME_TEST
    93529540    to=clock();
     9541#endif
    93539542
    93549543    // if(endwalks == 1){PrintS("\n//  Lifting is still working:");}
     
    93569545    // compute a reduced Groebner basis of <G> w.r.t. "newRing" by the lifting process
    93579546    F = MLifttwoIdeal(Gomega2, M1, G);
     9547#ifdef TIME_TEST
    93589548    xtlift=xtlift+clock()-to;
     9549#endif
    93599550
    93609551    idDelete(&M1);
     
    93659556    rChangeCurrRing(newRing);
    93669557    F1 = idrMoveR(F, oldRing,currRing);
     9558#ifdef TIME_TEST
    93679559    to=clock();
     9560#endif
    93689561    //if(endwalks == 1){ PrintS("\n//  InterRed is still working:");}
    93699562    // reduce the Groebner basis <G> w.r.t. the new ring
    93709563    G = kInterRedCC(F1, NULL);
     9564#ifdef TIME_TEST
    93719565    xtred=xtred+clock()-to;
     9566#endif
    93729567    idDelete(&F1);
    93739568
     
    93779572  FIRST_STEP:
    93789573    Overflow_Error=FALSE;
     9574#ifdef TIME_TEST
    93799575    to=clock();
     9576#endif
    93809577    // compute a next weight vector
    93819578    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     9579#ifdef TIME_TEST
    93829580    xtnw=xtnw+clock()-to;
     9581#endif
    93839582#ifdef PRINT_VECTORS
    93849583    MivString(curr_weight, target_weight, next_weight);
     
    93909589      if(tp_deg > 1){
    93919590        //nOverflow_Error = Overflow_Error;
     9591#ifdef TIME_TEST
    93929592        tproc = tproc+clock()-tinput;
     9593#endif
    93939594        //Print("\n// A subroutine takes %d steps and calls \"Mpwalk\" (1,%d):", nwalk, tp_deg-1);
    93949595        G1 = Mpwalk_MAltwalk1(G, curr_weight, tp_deg-1);
     
    94399640    {
    94409641      //Print("\n// subroutine takes %d steps and applys \"std\"", nwalk);
     9642#ifdef TIME_TEST
    94419643      to=clock();
     9644#endif
    94429645      ideal G2 = MstdCC(G1);
     9646#ifdef TIME_TEST
    94439647      xtextra=xtextra+clock()-to;
     9648#endif
    94449649      idDelete(&G1);
    94459650      G1 = G2;
     
    94499654    {
    94509655      //nOverflow_Error = Overflow_Error;
     9656#ifdef TIME_TEST
    94519657      tproc = tproc+clock()-tinput;
     9658#endif
    94529659      // Print("\n// B subroutine takes %d steps and calls \"Mpwalk\" (1,%d) :", nwalk,  tp_deg-1);
    94539660      G1 = Mpwalk_MAltwalk1(G1, curr_weight, tp_deg-1);
     
    94819688  // Print("// pSetm_Error = (%d)", ErrorCheck());
    94829689
     9690#ifdef TIME_TEST
    94839691  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
    94849692  xftinput = clock();
    94859693  clock_t tostd, tproc;
     9694#endif
    94869695
    94879696  nstep = 0;
     
    95129721  ring XXRing = currRing;
    95139722
     9723#ifdef TIME_TEST
    95149724  to=clock();
     9725#endif
    95159726  /* compute a pertubed weight vector of the original weight vector.
    95169727     The perturbation degree is recursive decrease until that vector
     
    95699780    op_deg --;
    95709781  }
     9782#ifdef TIME_TEST
    95719783  tostd=clock()-to;
     9784#endif
    95729785
    95739786  if(op_tmp != 1 )
     
    95839796    nstep ++;
    95849797
     9798#ifdef TIME_TEST
    95859799    to = clock();
     9800#endif
    95869801    // compute an initial form ideal of <G> w.r.t. "curr_vector"
    95879802    Gomega = MwalkInitialForm(G, curr_weight);
     9803#ifdef TIME_TEST
    95889804    xtif=xtif+clock()-to;
     9805#endif
    95899806#if 0
    95909807    if(Overflow_Error == TRUE)
     
    96239840    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    96249841
     9842#ifdef TIME_TEST
    96259843    to=clock();
     9844#endif
    96269845    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    96279846#ifdef  BUCHBERGER_ALG
     
    96319850    delete hilb_func;
    96329851#endif // BUCHBERGER_ALG
     9852#ifdef TIME_TEST
    96339853    xtstd=xtstd+clock()-to;
     9854#endif
    96349855
    96359856    // change the ring to oldRing
     
    96389859    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    96399860
     9861#ifdef TIME_TEST
    96409862    to=clock();
     9863#endif
    96419864    // compute a reduced Groebner basis of <G> w.r.t. "newRing" by the lifting process
    96429865    F = MLifttwoIdeal(Gomega2, M1, G);
     9866#ifdef TIME_TEST
    96439867    xtlift=xtlift+clock()-to;
     9868#endif
    96449869
    96459870    idDelete(&M1);
     
    96539878    oldRing=NULL;
    96549879
     9880#ifdef TIME_TEST
    96559881    to=clock();
     9882#endif
    96569883    // reduce the Groebner basis <G> w.r.t. new ring
    96579884    G = kInterRedCC(F1, NULL);
     9885#ifdef TIME_TEST
    96589886    xtred=xtred+clock()-to;
     9887#endif
    96599888    idDelete(&F1);
    96609889
     
    96649893    }
    96659894  NEXT_VECTOR:
     9895#ifdef TIME_TEST
    96669896    to=clock();
     9897#endif
    96679898    // compute a next weight vector
    96689899    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     9900#ifdef TIME_TEST
    96699901    xtnw=xtnw+clock()-to;
     9902#endif
    96709903#ifdef PRINT_VECTORS
    96719904    MivString(curr_weight, target_weight, next_weight);
     
    97089941#ifdef TIME_TEST
    97099942        nOverflow_Error = Overflow_Error;
    9710 #endif
    97119943        tproc = clock()-xftinput;
     9944#endif
    97129945
    97139946        //Print("\n//  main routine takes %d steps and calls \"Mpwalk\" (1,%d):", nwalk,  tp_deg);
  • doc/NEWS.texi

    r6c086a4 r750069  
    2424New libraries:
    2525@itemize
     26@item new library: classifyMapGerms.lib: standard basis of the tangent space at the orbit of an algebraic group action (@nref{classifyMapGerms_lib})
    2627@item new library: ffmodstd.lib:  Groebner bases of ideals in polynomial rings over algebraic function fields(@nref{ffmodstd_lib})
    2728@item new library: nfmodsyz.lib: syzygy modules of submodules of free modules
     
    3132Changed libraries:
    3233@itemize
     34@item classify_aeq.lib: new procedures (@nref{classify_aeq_lib})
    3335@item ncfactor.lib: factorization in some noncommuative algebras (@nref{ncfactor_lib}) with new routine ncfactor (@nref{ncfactor})
    3436@item primdec.lib: new option "subsystem" (@nref{primdec_lib})
  • doc/changes_in_singular4.texi

    r6c086a4 r750069  
    183183
    184184In particular we have separated everything related to coeffcient rings into a separate library @code{libcoeffs}.
    185 Dependency tree between restructured packages is show at @uref{http://www.mathematik.uni-kl.de/~motsak/dox/singular.png}
     185Dependency tree between restructured packages is show at @uref{http://www.singular.uni-kl.de/dox/singular.png}
    186186
    187187In order to use @code{libSingular} as a C++ library, see @ref{libSingular}.
  • factory/cfGcdAlgExt.cc

    r6c086a4 r750069  
    953953
    954954#ifndef HAVE_NTL
    955 static void tryExtgcd( const CanonicalForm & F, const CanonicalForm & G, const CanonicalForm & M, CanonicalForm & result, CanonicalForm & s, CanonicalForm & t, bool & fail )
     955void tryExtgcd( const CanonicalForm & F, const CanonicalForm & G, const CanonicalForm & M, CanonicalForm & result, CanonicalForm & s, CanonicalForm & t, bool & fail )
    956956{ // F, G are univariate polynomials (i.e. they have exactly one polynomial variable)
    957957  // F and G must have the same level AND level > 0
  • kernel/GBEngine/kInline.h

    rc4ea0bb r750069  
    11011101}
    11021102
     1103KINLINE poly redtailBbaBound (poly p,int pos,kStrategy strat,int bound,BOOLEAN normalize)
     1104{
     1105  LObject L(p, currRing, strat->tailRing);
     1106  return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);
     1107}
     1108
    11031109#ifdef HAVE_RINGS
    11041110KINLINE poly redtailBba_Z (poly p,int pos,kStrategy strat)
  • kernel/GBEngine/kspoly.cc

    rc4ea0bb r750069  
    137137  {
    138138    if (coef != NULL) *coef = n_Init(1, tailRing->cf);
     139  }
     140
     141
     142  // and finally,
     143  PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     144  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
     145  PR->LmDeleteAndIter();
     146
     147  // the following is commented out: shrinking
     148#ifdef HAVE_SHIFTBBA_NONEXISTENT
     149  if ( (currRing->isLPring) && (!strat->homog) )
     150  {
     151    // assume? h->p in currRing
     152    PR->GetP();
     153    poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
     154    PR->Clear(); // does the right things
     155    PR->p = qq;
     156    PR->t_p = NULL;
     157    PR->SetShortExpVector();
     158  }
     159#endif
     160
     161#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
     162  if (TEST_OPT_DEBUG)
     163  {
     164    Print(" to: "); PR->wrp(); Print("\n");
     165    //printf("\nt^%i ", PR->ecart);pWrite(pHead(PR->p));
     166  }
     167#endif
     168  return ret;
     169}
     170
     171int ksReducePolyBound(LObject* PR,
     172                 TObject* PW,
     173                 int bound,
     174                 poly spNoether,
     175                 number *coef,
     176                 kStrategy strat)
     177{
     178#ifdef KDEBUG
     179  red_count++;
     180#ifdef TEST_OPT_DEBUG_RED
     181  if (TEST_OPT_DEBUG)
     182  {
     183    Print("Red %d:", red_count); PR->wrp(); Print(" with:");
     184    PW->wrp();
     185    //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
     186    //pWrite(PR->p);
     187  }
     188#endif
     189#endif
     190  int ret = 0;
     191  ring tailRing = PR->tailRing;
     192  kTest_L(PR);
     193  kTest_T(PW);
     194
     195  poly p1 = PR->GetLmTailRing();   // p2 | p1
     196  poly p2 = PW->GetLmTailRing();   // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
     197  poly t2 = pNext(p2), lm = p1;    // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
     198  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
     199  p_CheckPolyRing(p1, tailRing);
     200  p_CheckPolyRing(p2, tailRing);
     201
     202  pAssume1(p2 != NULL && p1 != NULL &&
     203           p_DivisibleBy(p2,  p1, tailRing));
     204
     205  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
     206           (p_GetComp(p2, tailRing) == 0 &&
     207            p_MaxComp(pNext(p2),tailRing) == 0));
     208
     209#ifdef HAVE_PLURAL
     210  if (rIsPluralRing(currRing))
     211  {
     212    // for the time being: we know currRing==strat->tailRing
     213    // no exp-bound checking needed
     214    // (only needed if exp-bound(tailring)<exp-b(currRing))
     215    if (PR->bucket!=NULL)  nc_kBucketPolyRed(PR->bucket, p2,coef);
     216    else
     217    {
     218      poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
     219      assume(_p != NULL);
     220      nc_PolyPolyRed(_p, p2,coef, currRing);
     221      if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
     222      PR->pLength=0; // usually not used, GetpLength re-computes it if needed
     223    }
     224    return 0;
     225  }
     226#endif
     227
     228  if (t2==NULL)           // Divisor is just one term, therefore it will
     229  {                       // just cancel the leading term
     230    PR->LmDeleteAndIter();
     231    if (coef != NULL) *coef = n_Init(1, tailRing);
     232    return 0;
     233  }
     234
     235  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
     236
     237  if (tailRing != currRing)
     238  {
     239    // check that reduction does not violate exp bound
     240    while (PW->max != NULL && !p_LmExpVectorAddIsOk(lm, PW->max, tailRing))
     241    {
     242      // undo changes of lm
     243      p_ExpVectorAdd(lm, p2, tailRing);
     244      if (strat == NULL) return 2;
     245      if (! kStratChangeTailRing(strat, PR, PW)) return -1;
     246      tailRing = strat->tailRing;
     247      p1 = PR->GetLmTailRing();
     248      p2 = PW->GetLmTailRing();
     249      t2 = pNext(p2);
     250      lm = p1;
     251      p_ExpVectorSub(lm, p2, tailRing);
     252      ret = 1;
     253    }
     254  }
     255
     256  // take care of coef buisness
     257  if (! n_IsOne(pGetCoeff(p2), tailRing))
     258  {
     259    number bn = pGetCoeff(lm);
     260    number an = pGetCoeff(p2);
     261    int ct = ksCheckCoeff(&an, &bn, tailRing->cf);    // Calculate special LC
     262    p_SetCoeff(lm, bn, tailRing);
     263    if ((ct == 0) || (ct == 2))
     264      PR->Tail_Mult_nn(an);
     265    if (coef != NULL) *coef = an;
     266    else n_Delete(&an, tailRing);
     267  }
     268  else
     269  {
     270    if (coef != NULL) *coef = n_Init(1, tailRing);
    139271  }
    140272
     
    806938}
    807939
     940int ksReducePolyTailBound(LObject* PR, TObject* PW, int bound, poly Current, poly spNoether)
     941{
     942  BOOLEAN ret;
     943  number coef;
     944  poly Lp =     PR->GetLmCurrRing();
     945  poly Save =   PW->GetLmCurrRing();
     946
     947  kTest_L(PR);
     948  kTest_T(PW);
     949  pAssume(pIsMonomOf(Lp, Current));
     950
     951  assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
     952  assume(PR->bucket == NULL);
     953
     954  LObject Red(pNext(Current), PR->tailRing);
     955  TObject With(PW, Lp == Save);
     956
     957  pAssume(!pHaveCommonMonoms(Red.p, With.p));
     958  ret = ksReducePolyBound(&Red, &With,bound, spNoether, &coef);
     959
     960  if (!ret)
     961  {
     962    if (! n_IsOne(coef, currRing))
     963    {
     964      pNext(Current) = NULL;
     965      if (Current == PR->p && PR->t_p != NULL)
     966        pNext(PR->t_p) = NULL;
     967      PR->Mult_nn(coef);
     968    }
     969
     970    n_Delete(&coef, currRing);
     971    pNext(Current) = Red.GetLmTailRing();
     972    if (Current == PR->p && PR->t_p != NULL)
     973      pNext(PR->t_p) = pNext(Current);
     974  }
     975
     976  if (Lp == Save)
     977    With.Delete();
     978
     979  // the following is commented out: shrinking
     980#ifdef HAVE_SHIFTBBA_NONEXISTENT
     981  if (currRing->isLPring)
     982  {
     983    // assume? h->p in currRing
     984    PR->GetP();
     985    poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
     986    PR->Clear(); // does the right things
     987    PR->p = qq;
     988    PR->t_p = NULL;
     989    PR->SetShortExpVector();
     990  }
     991#endif
     992
     993  return ret;
     994}
     995
    808996/***************************************************************
    809997 *
  • kernel/GBEngine/kstd1.cc

    rc4ea0bb r750069  
    30153015}
    30163016
     3017poly kNFBound(ideal F, ideal Q, poly p,int bound,int syzComp, int lazyReduce)
     3018{
     3019  if (p==NULL)
     3020     return NULL;
     3021
     3022  poly pp = p;
     3023
     3024#ifdef HAVE_PLURAL
     3025  if(rIsSCA(currRing))
     3026  {
     3027    const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
     3028    const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
     3029    pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing);
     3030
     3031    if(Q == currRing->qideal)
     3032      Q = SCAQuotient(currRing);
     3033  }
     3034#endif
     3035
     3036  if ((idIs0(F))&&(Q==NULL))
     3037  {
     3038#ifdef HAVE_PLURAL
     3039    if(p != pp)
     3040      return pp;
     3041#endif
     3042    return pCopy(p); /*F+Q=0*/
     3043  }
     3044
     3045  kStrategy strat=new skStrategy;
     3046  strat->syzComp = syzComp;
     3047  strat->ak = si_max(id_RankFreeModule(F,currRing),pMaxComp(p));
     3048  poly res;
     3049  res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce);
     3050  delete(strat);
     3051
     3052#ifdef HAVE_PLURAL
     3053  if(pp != p)
     3054    p_Delete(&pp, currRing);
     3055#endif
     3056  return res;
     3057}
     3058
    30173059ideal kNF(ideal F, ideal Q, ideal p,int syzComp,int lazyReduce)
    30183060{
     
    30593101  else
    30603102    res=kNF2(F,Q,pp,strat,lazyReduce);
     3103  delete(strat);
     3104
     3105#ifdef HAVE_PLURAL
     3106  if(pp != p)
     3107    id_Delete(&pp, currRing);
     3108#endif
     3109
     3110  return res;
     3111}
     3112
     3113ideal kNFBound(ideal F, ideal Q, ideal p,int bound,int syzComp,int lazyReduce)
     3114{
     3115  ideal res;
     3116  if (TEST_OPT_PROT)
     3117  {
     3118    Print("(S:%d)",IDELEMS(p));mflush();
     3119  }
     3120  if (idIs0(p))
     3121    return idInit(IDELEMS(p),si_max(p->rank,F->rank));
     3122
     3123  ideal pp = p;
     3124#ifdef HAVE_PLURAL
     3125  if(rIsSCA(currRing))
     3126  {
     3127    const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
     3128    const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
     3129    pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing, false);
     3130
     3131    if(Q == currRing->qideal)
     3132      Q = SCAQuotient(currRing);
     3133  }
     3134#endif
     3135
     3136  if ((idIs0(F))&&(Q==NULL))
     3137  {
     3138#ifdef HAVE_PLURAL
     3139    if(p != pp)
     3140      return pp;
     3141#endif
     3142    return idCopy(p); /*F+Q=0*/
     3143  }
     3144
     3145  kStrategy strat=new skStrategy;
     3146  strat->syzComp = syzComp;
     3147  strat->ak = si_max(id_RankFreeModule(F,currRing),id_RankFreeModule(p,currRing));
     3148  if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst
     3149  {
     3150    strat->ak = si_max(strat->ak,(int)F->rank);
     3151  }
     3152
     3153  res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce);
    30613154  delete(strat);
    30623155
  • kernel/GBEngine/kstd1.h

    rc4ea0bb r750069  
    2727poly kNF (ideal F, ideal Q, poly p,int syzComp=0, int lazyReduce=0);
    2828ideal kNF(ideal F, ideal Q, ideal p,int syzComp=0, int lazyReduce=0);
     29
     30poly kNFBound (ideal F, ideal Q, poly p,int bound,int syzComp=0, int lazyReduce=0);
     31ideal kNFBound (ideal F, ideal Q, ideal p,int bound,int syzComp=0, int lazyReduce=0);
    2932
    3033/// NOTE: this is just a wrapper which sets currRing for the actual kNF call
  • kernel/GBEngine/kstd2.cc

    rc4ea0bb r750069  
    17391739        number coef;
    17401740        coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether);
     1741        nDelete(&coef);
     1742      }
     1743      h = kBucketGetLm(P.bucket);   // FRAGE OLIVER
     1744      if (h==NULL)
     1745      {
     1746        kBucketDestroy(&P.bucket);
     1747
     1748#ifdef KDEBUG
     1749//        if (TEST_OPT_DEBUG)
     1750//        {
     1751//          PrintS("redNF: starting S:\n");
     1752//          for( j = 0; j <= max_ind; j++ )
     1753//          {
     1754//            Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
     1755//            pWrite(strat->S[j]);
     1756//          }
     1757//        };
     1758#endif
     1759
     1760        return NULL;
     1761      }
     1762      kbTest(P.bucket);
     1763      P.p=h;
     1764      P.t_p=NULL;
     1765      P.SetShortExpVector();
     1766#ifdef KDEBUG
     1767      if (TEST_OPT_DEBUG)
     1768      {
     1769        PrintS("\nto:");
     1770        wrp(h);
     1771        PrintLn();
     1772      }
     1773#endif
     1774    }
     1775    else
     1776    {
     1777      P.p=kBucketClear(P.bucket);
     1778      kBucketDestroy(&P.bucket);
     1779      pNormalize(P.p);
     1780
     1781#ifdef KDEBUG
     1782//      if (TEST_OPT_DEBUG)
     1783//      {
     1784//        PrintS("redNF: starting S:\n");
     1785//        for( j = 0; j <= max_ind; j++ )
     1786//        {
     1787//          Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
     1788//          pWrite(strat->S[j]);
     1789//        }
     1790//      };
     1791#endif
     1792
     1793      return P.p;
     1794    }
     1795  }
     1796}
     1797
     1798/*2
     1799*  reduction procedure from global case but with jet bound
     1800*/
     1801
     1802poly redNFBound (poly h,int &max_ind,int nonorm,kStrategy strat,int bound)
     1803{
     1804  h = pJet(h,bound);
     1805  if (h==NULL) return NULL;
     1806  int j;
     1807  max_ind=strat->sl;
     1808
     1809  if (0 > strat->sl)
     1810  {
     1811    return h;
     1812  }
     1813  LObject P(h);
     1814  P.SetShortExpVector();
     1815  P.bucket = kBucketCreate(currRing);
     1816  kBucketInit(P.bucket,P.p,pLength(P.p));
     1817  kbTest(P.bucket);
     1818#ifdef HAVE_RINGS
     1819  BOOLEAN is_ring = rField_is_Ring(currRing);
     1820#endif
     1821#ifdef KDEBUG
     1822//  if (TEST_OPT_DEBUG)
     1823//  {
     1824//    PrintS("redNF: starting S:\n");
     1825//    for( j = 0; j <= max_ind; j++ )
     1826//    {
     1827//      Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
     1828//      pWrite(strat->S[j]);
     1829//    }
     1830//  };
     1831#endif
     1832
     1833  loop
     1834  {
     1835    j=kFindDivisibleByInS(strat,&max_ind,&P);
     1836    if (j>=0)
     1837    {
     1838#ifdef HAVE_RINGS
     1839      if (!is_ring)
     1840      {
     1841#endif
     1842        int sl=pSize(strat->S[j]);
     1843        int jj=j;
     1844        loop
     1845        {
     1846          int sll;
     1847          jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
     1848          if (jj<0) break;
     1849          sll=pSize(strat->S[jj]);
     1850          if (sll<sl)
     1851          {
     1852            #ifdef KDEBUG
     1853            if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
     1854            #endif
     1855            //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
     1856            j=jj;
     1857            sl=sll;
     1858          }
     1859        }
     1860        if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
     1861        {
     1862          pNorm(strat->S[j]);
     1863          //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
     1864        }
     1865#ifdef HAVE_RINGS
     1866      }
     1867#endif
     1868      nNormalize(pGetCoeff(P.p));
     1869#ifdef KDEBUG
     1870      if (TEST_OPT_DEBUG)
     1871      {
     1872        PrintS("red:");
     1873        wrp(h);
     1874        PrintS(" with ");
     1875        wrp(strat->S[j]);
     1876      }
     1877#endif
     1878#ifdef HAVE_PLURAL
     1879      if (rIsPluralRing(currRing))
     1880      {
     1881        number coef;
     1882        nc_kBucketPolyRed(P.bucket,strat->S[j],&coef);
     1883        nDelete(&coef);
     1884      }
     1885      else
     1886#endif
     1887      {
     1888        number coef;
     1889        coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether);
     1890        P.p = kBucketClear(P.bucket);
     1891        P.p = pJet(P.p,bound);
     1892        if(!P.IsNull())
     1893        {
     1894          kBucketDestroy(&P.bucket);
     1895          P.SetShortExpVector();
     1896          P.bucket = kBucketCreate(currRing);
     1897          kBucketInit(P.bucket,P.p,pLength(P.p));
     1898        }
    17411899        nDelete(&coef);
    17421900      }
     
    32713429}
    32723430
     3431poly kNF2Bound (ideal F,ideal Q,poly q,int bound,kStrategy strat, int lazyReduce)
     3432{
     3433  assume(q!=NULL);
     3434  assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
     3435
     3436// lazy_reduce flags: can be combined by |
     3437//#define KSTD_NF_LAZY   1
     3438  // do only a reduction of the leading term
     3439//#define KSTD_NF_NONORM 4
     3440  // only global: avoid normalization, return a multiply of NF
     3441  poly   p;
     3442
     3443  //if ((idIs0(F))&&(Q==NULL))
     3444  //  return pCopy(q); /*F=0*/
     3445  //strat->ak = idRankFreeModule(F);
     3446  /*- creating temp data structures------------------- -*/
     3447  BITSET save1;
     3448  SI_SAVE_OPT1(save1);
     3449  si_opt_1|=Sy_bit(OPT_REDTAIL);
     3450  initBuchMoraCrit(strat);
     3451  strat->initEcart = initEcartBBA;
     3452  strat->enterS = enterSBba;
     3453#ifndef NO_BUCKETS
     3454  strat->use_buckets = (!TEST_OPT_NOT_BUCKETS) && (!rIsPluralRing(currRing));
     3455#endif
     3456  /*- set S -*/
     3457  strat->sl = -1;
     3458  /*- init local data struct.---------------------------------------- -*/
     3459  /*Shdl=*/initS(F,Q,strat);
     3460  /*- compute------------------------------------------------------- -*/
     3461  //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
     3462  //{
     3463  //  for (i=strat->sl;i>=0;i--)
     3464  //    pNorm(strat->S[i]);
     3465  //}
     3466  kTest(strat);
     3467  if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
     3468  if (BVERBOSE(23)) kDebugPrint(strat);
     3469  int max_ind;
     3470  p = redNFBound(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
     3471  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
     3472  {
     3473    if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
     3474    if (rField_is_Ring(currRing))
     3475    {
     3476      p = redtailBba_Z(p,max_ind,strat);
     3477    }
     3478    else
     3479    {
     3480      si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
     3481      p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
     3482      //p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
     3483    }
     3484  }
     3485  /*- release temp data------------------------------- -*/
     3486  assume(strat->L==NULL); /* strat->L unused */
     3487  assume(strat->B==NULL); /* strat->B unused */
     3488  omFree(strat->sevS);
     3489  omFree(strat->ecartS);
     3490  assume(strat->T==NULL);//omfree(strat->T);
     3491  assume(strat->sevT==NULL);//omfree(strat->sevT);
     3492  assume(strat->R==NULL);//omfree(strat->R);
     3493  omfree(strat->S_2_R);
     3494  omfree(strat->fromQ);
     3495  idDelete(&strat->Shdl);
     3496  SI_RESTORE_OPT1(save1);
     3497  if (TEST_OPT_PROT) PrintLn();
     3498  return p;
     3499}
     3500
    32733501ideal kNF2 (ideal F,ideal Q,ideal q,kStrategy strat, int lazyReduce)
    32743502{
     
    33233551        {
    33243552          p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
     3553        }
     3554      }
     3555      res->m[i]=p;
     3556    }
     3557    //else
     3558    //  res->m[i]=NULL;
     3559  }
     3560  /*- release temp data------------------------------- -*/
     3561  assume(strat->L==NULL); /* strat->L unused */
     3562  assume(strat->B==NULL); /* strat->B unused */
     3563  omFree(strat->sevS);
     3564  omFree(strat->ecartS);
     3565  assume(strat->T==NULL);//omfree(strat->T);
     3566  assume(strat->sevT==NULL);//omfree(strat->sevT);
     3567  assume(strat->R==NULL);//omfree(strat->R);
     3568  omfree(strat->S_2_R);
     3569  omfree(strat->fromQ);
     3570  idDelete(&strat->Shdl);
     3571  SI_RESTORE_OPT1(save1);
     3572  if (TEST_OPT_PROT) PrintLn();
     3573  return res;
     3574}
     3575
     3576ideal kNF2Bound (ideal F,ideal Q,ideal q,int bound,kStrategy strat, int lazyReduce)
     3577{
     3578  assume(!idIs0(q));
     3579  assume(!(idIs0(F)&&(Q==NULL)));
     3580// lazy_reduce flags: can be combined by |
     3581//#define KSTD_NF_LAZY   1
     3582  // do only a reduction of the leading term
     3583//#define KSTD_NF_NONORM 4
     3584  // only global: avoid normalization, return a multiply of NF
     3585  poly   p;
     3586  int   i;
     3587  ideal res;
     3588  int max_ind;
     3589
     3590  //if (idIs0(q))
     3591  //  return idInit(IDELEMS(q),si_max(q->rank,F->rank));
     3592  //if ((idIs0(F))&&(Q==NULL))
     3593  //  return idCopy(q); /*F=0*/
     3594  //strat->ak = idRankFreeModule(F);
     3595  /*- creating temp data structures------------------- -*/
     3596  BITSET save1;
     3597  SI_SAVE_OPT1(save1);
     3598  si_opt_1|=Sy_bit(OPT_REDTAIL);
     3599  initBuchMoraCrit(strat);
     3600  strat->initEcart = initEcartBBA;
     3601  strat->enterS = enterSBba;
     3602  /*- set S -*/
     3603  strat->sl = -1;
     3604#ifndef NO_BUCKETS
     3605  strat->use_buckets = (!TEST_OPT_NOT_BUCKETS) && (!rIsPluralRing(currRing));
     3606#endif
     3607  /*- init local data struct.---------------------------------------- -*/
     3608  /*Shdl=*/initS(F,Q,strat);
     3609  /*- compute------------------------------------------------------- -*/
     3610  res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
     3611  si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
     3612  for (i=IDELEMS(q)-1; i>=0; i--)
     3613  {
     3614    if (q->m[i]!=NULL)
     3615    {
     3616      if (TEST_OPT_PROT) { PrintS("r");mflush(); }
     3617      p = redNFBound(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
     3618      if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
     3619      {
     3620        if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
     3621        if (rField_is_Ring(currRing))
     3622        {
     3623          p = redtailBba_Z(p,max_ind,strat);
     3624        }
     3625        else
     3626        {
     3627          p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
    33253628        }
    33263629      }
  • kernel/GBEngine/kutil.cc

    rc4ea0bb r750069  
    76657665      }
    76667666      if (Ln.IsNull()) goto all_done;
     7667      if (! withT) With_s.Init(currRing);
     7668    }
     7669    pNext(h) = Ln.LmExtractAndIter();
     7670    pIter(h);
     7671    pNormalize(h);
     7672    L->pLength++;
     7673  }
     7674
     7675  all_done:
     7676  Ln.Delete();
     7677  if (L->p != NULL) pNext(L->p) = pNext(p);
     7678
     7679  if (strat->redTailChange)
     7680  {
     7681    L->length = 0;
     7682    L->pLength = 0;
     7683  }
     7684
     7685  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
     7686  //L->Normalize(); // HANNES: should have a test
     7687  kTest_L(L);
     7688  return L->GetLmCurrRing();
     7689}
     7690
     7691poly redtailBbaBound (LObject* L, int pos, kStrategy strat, int bound, BOOLEAN withT, BOOLEAN normalize)
     7692{
     7693#define REDTAIL_CANONICALIZE 100
     7694  strat->redTailChange=FALSE;
     7695  if (strat->noTailReduction) return L->GetLmCurrRing();
     7696  poly h, p;
     7697  p = h = L->GetLmTailRing();
     7698  if ((h==NULL) || (pNext(h)==NULL))
     7699    return L->GetLmCurrRing();
     7700
     7701  TObject* With;
     7702  // placeholder in case strat->tl < 0
     7703  TObject  With_s(strat->tailRing);
     7704
     7705  LObject Ln(pNext(h), strat->tailRing);
     7706  Ln.pLength = L->GetpLength() - 1;
     7707
     7708  pNext(h) = NULL;
     7709  if (L->p != NULL) pNext(L->p) = NULL;
     7710  L->pLength = 1;
     7711
     7712  Ln.PrepareRed(strat->use_buckets);
     7713
     7714  int cnt=REDTAIL_CANONICALIZE;
     7715  while(!Ln.IsNull())
     7716  {
     7717    loop
     7718    {
     7719      if (TEST_OPT_IDLIFT)
     7720      {
     7721        if (Ln.p!=NULL)
     7722        {
     7723          if (p_GetComp(Ln.p,currRing)> strat->syzComp) break;
     7724        }
     7725        else
     7726        {
     7727          if (p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
     7728        }
     7729      }
     7730      Ln.SetShortExpVector();
     7731      if (withT)
     7732      {
     7733        int j;
     7734        j = kFindDivisibleByInT(strat, &Ln);
     7735        if (j < 0) break;
     7736        With = &(strat->T[j]);
     7737      }
     7738      else
     7739      {
     7740        With = kFindDivisibleByInS(strat, pos, &Ln, &With_s);
     7741        if (With == NULL) break;
     7742      }
     7743      cnt--;
     7744      if (cnt==0)
     7745      {
     7746        cnt=REDTAIL_CANONICALIZE;
     7747        /*poly tmp=*/Ln.CanonicalizeP();
     7748        if (normalize)
     7749        {
     7750          Ln.Normalize();
     7751          //pNormalize(tmp);
     7752          //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
     7753        }
     7754      }
     7755      if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
     7756      {
     7757        With->pNorm();
     7758      }
     7759      strat->redTailChange=TRUE;
     7760      if (ksReducePolyTail(L, With, &Ln))
     7761      {
     7762        // reducing the tail would violate the exp bound
     7763        //  set a flag and hope for a retry (in bba)
     7764        strat->completeReduce_retry=TRUE;
     7765        if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
     7766        do
     7767        {
     7768          pNext(h) = Ln.LmExtractAndIter();
     7769          pIter(h);
     7770          L->pLength++;
     7771        } while (!Ln.IsNull());
     7772        goto all_done;
     7773      }
     7774      if(!Ln.IsNull())
     7775      {
     7776        Ln.GetP();
     7777        Ln.p = pJet(Ln.p,bound);
     7778      }
     7779      if (Ln.IsNull())
     7780      { 
     7781        goto all_done;
     7782      } 
    76677783      if (! withT) With_s.Init(currRing);
    76687784    }
  • kernel/GBEngine/kutil.h

    rc4ea0bb r750069  
    487487             LObject* L,const kStrategy strat);
    488488KINLINE poly redtailBba (poly p,int pos,kStrategy strat,BOOLEAN normalize=FALSE);
     489KINLINE poly redtailBbaBound (poly p,int pos,kStrategy strat,int bound,BOOLEAN normalize=FALSE);
    489490#ifdef HAVE_RINGS
    490491KINLINE poly redtailBba_Z (poly p,int pos,kStrategy strat);
     
    492493#endif
    493494poly redtailBba (LObject *L, int pos,kStrategy strat,
     495                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
     496poly redtailBbaBound (LObject *L, int pos,kStrategy strat,int bound,
    494497                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
    495498poly redtailSba (LObject *L, int pos,kStrategy strat,
     
    667670poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce);
    668671ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce);
     672poly kNF2Bound (ideal F, ideal Q, poly q,int bound, kStrategy strat, int lazyReduce);
     673ideal kNF2Bound (ideal F,ideal Q,ideal q,int bound, kStrategy strat, int lazyReduce);
    669674void initBba(kStrategy strat);
    670675void initSba(ideal F,kStrategy strat);
     
    696701                 number *coef = NULL,
    697702                 kStrategy strat = NULL);
     703                 
     704int ksReducePolyBound(LObject* PR,
     705                 TObject* PW,
     706                 int bound,
     707                 poly spNoether = NULL,
     708                 number *coef = NULL,
     709                 kStrategy strat = NULL);
    698710
    699711// Reduces PR with PW
  • kernel/GBEngine/tgb.cc

    r6c086a4 r750069  
    8383  else
    8484  {
    85     return n_Size (n, r);
     85    return n_Size (n, r->cf);
    8686  }
    8787}
     
    143143{
    144144  poly rc = p_Init_Special (r);
    145   pSetCoeff0 (rc, n_Init (1, r));
     145  pSetCoeff0 (rc, n_Init (1, r->cf));
    146146  return rc;
    147147}
  • kernel/GBEngine/tgbgauss.cc

    r6c086a4 r750069  
    510510    {
    511511      StringSetS("");
    512       n_Write(n[i][j],currRing);
     512      n_Write(n[i][j],currRing->cf);
    513513      char *s=StringEndS();
    514514      PrintS(s);
     
    711711      StringSetS("");
    712712      number n=get(i,j);
    713       n_Write(n,currRing);
     713      n_Write(n,currRing->cf);
    714714      char *s=StringEndS();
    715715      PrintS(s);
     
    842842      if (currRing==r) {nTest(m->coef);}
    843843      #endif
    844       n_Normalize(m->coef,r);
     844      n_Normalize(m->coef,r->cf);
    845845      m=m->next;
    846846    }
  • kernel/combinatorics/hilb.cc

    r6c086a4 r750069  
    229229//!!!!!!!!!!!!!!!!!!!!! Just for Monomial Ideals !!!!!!!!!!!!!!!!!!!!!!!!!!!!
    230230
    231 //returns the degree of the monomial
    232 static int DegMon(poly p)
    233 {
    234     #if 1
    235     int i,deg;
    236     deg = 0;
    237     for(i=1;i<=currRing->N;i++)
    238     {
    239         deg = deg + p_GetExp(p, i, currRing);
    240     }
    241     return(deg);
    242     #else
    243     return(p_Deg(p, currRing));
    244     #endif
    245 }
    246 
    247231//Tests if the ideal is sorted by degree
    248232static bool idDegSortTest(ideal I)
     
    254238    for(int i = 0; i<IDELEMS(I)-1; i++)
    255239    {
    256         if(DegMon(I->m[i])>DegMon(I->m[i+1]))
     240        if(p_Totaldegree(I->m[i],currRing)>p_Totaldegree(I->m[i+1],currRing))
    257241        {
    258242            idPrint(I);
     
    277261    idSkipZeroes(I);
    278262    #if 1
    279     for(i = 0; (i<IDELEMS(I)) && (DegMon(I->m[i])<=DegMon(p)); i++)
     263    for(i = 0; (i<IDELEMS(I)) && (p_Totaldegree(I->m[i],currRing)<=p_Totaldegree(p,currRing)); i++)
    280264    {
    281265        if(p_DivisibleBy( I->m[i],p, currRing))
     
    284268        }
    285269    }
    286     for(i = IDELEMS(I)-1; (i>=0) && (DegMon(I->m[i])>=DegMon(p)); i--)
     270    for(i = IDELEMS(I)-1; (i>=0) && (p_Totaldegree(I->m[i],currRing)>=p_Totaldegree(p,currRing)); i--)
    287271    {
    288272        if(p_DivisibleBy(p,I->m[i], currRing))
     
    300284    idSkipZeroes(I);
    301285    //First I take the case when all generators have the same degree
    302     if(DegMon(I->m[0]) == DegMon(I->m[IDELEMS(I)-1]))
    303     {
    304         if(DegMon(p)<DegMon(I->m[0]))
     286    if(p_Totaldegree(I->m[0],currRing) == p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
     287    {
     288        if(p_Totaldegree(p,currRing)<p_Totaldegree(I->m[0],currRing))
    305289        {
    306290            idInsertPoly(I,p);
     
    313297            return(I);
    314298        }
    315         if(DegMon(p)>=DegMon(I->m[IDELEMS(I)-1]))
     299        if(p_Totaldegree(p,currRing)>=p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
    316300        {
    317301            idInsertPoly(I,p);
     
    320304        }
    321305    }
    322     if(DegMon(p)<=DegMon(I->m[0]))
     306    if(p_Totaldegree(p,currRing)<=p_Totaldegree(I->m[0],currRing))
    323307    {
    324308        idInsertPoly(I,p);
     
    331315        return(I);
    332316    }
    333     if(DegMon(p)>=DegMon(I->m[IDELEMS(I)-1]))
     317    if(p_Totaldegree(p,currRing)>=p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
    334318    {
    335319        idInsertPoly(I,p);
     
    339323    for(i = IDELEMS(I)-2; ;)
    340324    {
    341         if(DegMon(p)==DegMon(I->m[i]))
     325        if(p_Totaldegree(p,currRing)==p_Totaldegree(I->m[i],currRing))
    342326        {
    343327            idInsertPoly(I,p);
     
    350334            return(I);
    351335        }
    352         if(DegMon(p)>DegMon(I->m[i]))
     336        if(p_Totaldegree(p,currRing)>p_Totaldegree(I->m[i],currRing))
    353337        {
    354338            idInsertPoly(I,p);
     
    424408        }
    425409        p_Setm(res->m[i], currRing);
    426         if(DegMon(res->m[i]) == DegMon(I->m[i]))
     410        if(p_Totaldegree(res->m[i],currRing) == p_Totaldegree(I->m[i],currRing))
    427411        {
    428412            res->m[i] = NULL; // pDelete
     
    749733    int i,j,exp;
    750734    poly res;
    751     if(DegMon(I->m[IDELEMS(I)-1])<=1)
     735    if(p_Totaldegree(I->m[IDELEMS(I)-1],currRing)<=1)
    752736    {
    753737        res = ChoosePVar(I);
     
    793777    return(TRUE);
    794778    #else
    795     if(DegMon(I->m[IDELEMS(I)-1])>1)
     779    if(p_Totaldegree(I->m[IDELEMS(I)-1],currRing)>1)
    796780    {
    797781        return(FALSE);
     
    849833    bool flag=TRUE;
    850834    poly notsqrfree = NULL;
    851     if(DegMon(I->m[IDELEMS(I)-1])<=1)
     835    if(p_Totaldegree(I->m[IDELEMS(I)-1],currRing)<=1)
    852836    {
    853837        return(notsqrfree);
     
    10431027                mpz_set(  &hilbertcoef[NNN], ec);
    10441028                mpz_clear(ec);
    1045                 hilbpower[NNN] = DegMon(q);
     1029                hilbpower[NNN] = p_Totaldegree(q,currRing);
    10461030                NNN++;
    10471031            }
     
    10491033        {
    10501034            //I look if the power appears already
    1051             for(i = 0;(i<NNN)&&(flag == FALSE)&&(DegMon(q)>=hilbpower[i]);i++)
    1052             {
    1053                 if((hilbpower[i]) == (DegMon(q)))
     1035            for(i = 0;(i<NNN)&&(flag == FALSE)&&(p_Totaldegree(q,currRing)>=hilbpower[i]);i++)
     1036            {
     1037                if((hilbpower[i]) == (p_Totaldegree(q,currRing)))
    10541038                {
    10551039                    flag = TRUE;
     
    10691053                mpz_set(  &hilbertcoef[i], ec);
    10701054                mpz_clear(ec);
    1071                 hilbpower[i] = DegMon(q);
     1055                hilbpower[i] = p_Totaldegree(q,currRing);
    10721056                NNN++;
    10731057            }
  • kernel/fglm/fglmcomb.cc

    r6c086a4 r750069  
    114114
    115115        number temp = nDiv( n1, n2 );
    116         n_Normalize( temp, currRing );
     116        n_Normalize( temp, currRing->cf );
    117117        nDelete( & n1 );
    118118        n1= temp;
  • kernel/fglm/fglmzero.cc

    r6c086a4 r750069  
    154154    maFindPerm( source->names, source->N, NULL, 0, currRing->names,
    155155                currRing->N, NULL, 0, perm, NULL , currRing->cf->type);
    156     nMapFunc nMap=n_SetMap( source, currRing);
     156    nMapFunc nMap=n_SetMap( source->cf, currRing->cf);
    157157
    158158    matHeader ** temp = (matHeader **)omAlloc( _nfunc*sizeof( matHeader * ));
  • kernel/linear_algebra/linear_algebra.dox

    r6c086a4 r750069  
    22
    33 This sub-package of kernel (\ref kernel_page) contains
    4  Linar algebra related algorithms.
     4 Linear algebra related algorithms.
    55
    66 TODO: list those algorithms... and corresponding interpreter functions...?
  • kernel/maps/find_perm.cc

    r6c086a4 r750069  
    2727    {
    2828      if((pNext(image->m[i])==NULL)
    29       && (n_IsOne(pGetCoeff(image->m[i]),image_r)))
     29      && (n_IsOne(pGetCoeff(image->m[i]),image_r->cf)))
    3030      {
    3131        int v=p_IsUnivariate(image->m[i],image_r);
  • kernel/maps/gen_maps.cc

    r6c086a4 r750069  
    2525    {
    2626      if ((pNext(image->m[i])==NULL)
    27       && (n_IsOne(pGetCoeff(image->m[i]),image_r)))
     27      && (n_IsOne(pGetCoeff(image->m[i]),image_r->cf)))
    2828      {
    2929        v=p_IsUnivariate(image->m[i],image_r);
  • libpolys/coeffs/gnumpfl.cc

    r6c086a4 r750069  
    438438}
    439439
     440static char* ngfCoeffName(const coeffs r)
     441{
     442  static char ngfCoeffName_buf[27];
     443#ifdef SINGULAR_4_1
     444  snprintf(ngfCoeffName_buf,27,"real,%d,%d",r->float_len,r->float_len2);
     445#else
     446  snprintf(ngfCoeffName_buf,27,"RR(%d,%d)",r->float_len,r->float_len2);
     447#endif
     448  return ngfCoeffName_buf;
     449}
     450
    440451BOOLEAN ngfInitChar(coeffs n, void *parameter)
    441452{
     
    451462  n->ch = 0;
    452463  n->cfCoeffString=ngfCoeffString;
     464  n->cfCoeffName=ngfCoeffName;
    453465
    454466  n->cfDelete  = ngfDelete;
  • libpolys/coeffs/longrat.cc

    r6c086a4 r750069  
    468468  dest = res->z;
    469469
     470  void* (*allocfunc) (size_t);
     471  mp_get_memory_functions (&allocfunc,NULL, NULL);
    470472  if (e<0)
    471473  {
    472474    al = dest->_mp_size = size;
    473475    if (al<2) al = 2;
    474     dd = (mp_ptr)omAlloc(sizeof(mp_limb_t)*al);
     476    dd = (mp_ptr)allocfunc(sizeof(mp_limb_t)*al);
    475477    for (i=0;i<size;i++) dd[i] = qp[i];
    476478    bl = 1-e;
    477     nn = (mp_ptr)omAlloc0(sizeof(mp_limb_t)*bl);
     479    nn = (mp_ptr)allocfunc(sizeof(mp_limb_t)*bl);
    478480    nn[bl-1] = 1;
    479481    ndest = res->n;
     
    486488    al = dest->_mp_size = size+e;
    487489    if (al<2) al = 2;
    488     dd = (mp_ptr)omAlloc(sizeof(mp_limb_t)*al);
     490    dd = (mp_ptr)allocfunc(sizeof(mp_limb_t)*al);
    489491    for (i=0;i<size;i++) dd[i+e] = qp[i];
    490492    for (i=0;i<e;i++) dd[i] = 0;
  • libpolys/coeffs/mpr_complex.cc

    r6c086a4 r750069  
    453453      else
    454454      {
    455         if ( num->s == 0 )
     455        if ( num->s != 3 )
    456456        {
    457           nlNormalize( num, src ); // FIXME? TODO? // extern void     nlNormalize(number &x, const coeffs r); // FIXME
    458         }
    459         if (SR_HDL(num) & SR_INT)
    460         {
    461           r = gmp_float(SR_TO_INT(num));
     457          r= gmp_float(num->z);
     458          r/= gmp_float(num->n);
    462459        }
    463460        else
    464461        {
    465           if ( num->s != 3 )
    466           {
    467             r= num->z;
    468             r/= (gmp_float)num->n;
    469           }
    470           else
    471           {
    472             r= num->z;
    473           }
     462          r= num->z;
    474463        }
    475464      }
  • libpolys/polys/ext_fields/algext.cc

    r6c086a4 r750069  
    15081508#ifndef SINGULAR_4_1
    15091509BOOLEAN n2pInitChar(coeffs cf, void * infoStruct)
    1510 {}
     1510{ return 1; }
    15111511#endif
    15121512#ifdef SINGULAR_4_1
  • libpolys/polys/ext_fields/algext.h

    r6c086a4 r750069  
    6565
    6666char* naCoeffString(const coeffs r); // will be reused in tranext.cc...
     67char* naCoeffName(const coeffs r);
    6768#endif
    6869/* ALGEXT_H */
  • libpolys/polys/ext_fields/transext.cc

    r6c086a4 r750069  
    25652565
    25662566  cf->cfCoeffString = naCoeffString; // FIXME? TODO? // extern char* naCoeffString(const coeffs r);
     2567  cf->cfCoeffName =  naCoeffName; // FIXME? TODO? // extern char* naCoeffString(const coeffs r);
    25672568
    25682569  cf->cfGreaterZero  = ntGreaterZero;
  • libpolys/polys/matpol.cc

    r6c086a4 r750069  
    3232#include "monomials/p_polys.h"
    3333
    34 #include "coeffrings.h"
    3534#include "simpleideals.h"
    3635#include "matpol.h"
  • libpolys/polys/monomials/p_polys.cc

    r6c086a4 r750069  
    5252#endif
    5353
    54 #include "coeffrings.h"
    5554#include "clapsing.h"
    5655
     
    124123      }
    125124      else
    126         x[j]=n_Init(0, R);
     125        x[j]=n_Init(0, R->cf);
    127126    }
    128127    number n=n_ChineseRemainderSym(x,q,rl,TRUE,inv_cache,R->cf);
     
    131130      x[j]=NULL; // n_Init(0...) takes no memory
    132131    }
    133     if (n_IsZero(n,R)) p_Delete(&h,R);
     132    if (n_IsZero(n,R->cf)) p_Delete(&h,R);
    134133    else
    135134    {
     
    25412540  }
    25422541  else
    2543     s=n_Size(d,r);
     2542    s=n_Size(d,r->cf);
    25442543  number d2=d;
    25452544  loop
     
    25712570    else
    25722571    {
    2573       int ns=n_Size(pGetCoeff(ph),r);
     2572      int ns=n_Size(pGetCoeff(ph),r->cf);
    25742573      if (ns<=3)
    25752574      {
     
    43994398  if (rField_is_Ring(r))
    44004399  {
    4401     if (!n_DivBy(p_GetCoeff(p1, r), p_GetCoeff(p2, r), r)) return FALSE;
     4400    if (!n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf)) return FALSE;
    44024401  }
    44034402  #endif
    4404   n=n_Div(p_GetCoeff(p1,r),p_GetCoeff(p2,r),r);
     4403  n=n_Div(pGetCoeff(p1),pGetCoeff(p2),r->cf);
    44054404  while ((p1 != NULL) /*&& (p2 != NULL)*/)
    44064405  {
    44074406    if ( ! p_LmEqual(p1, p2,r))
    44084407    {
    4409         n_Delete(&n, r);
     4408        n_Delete(&n, r->cf);
    44104409        return FALSE;
    44114410    }
    4412     if (!n_Equal(p_GetCoeff(p1, r), nn = n_Mult(p_GetCoeff(p2, r),n, r->cf), r->cf))
    4413     {
    4414       n_Delete(&n, r);
    4415       n_Delete(&nn, r);
     4411    if (!n_Equal(pGetCoeff(p1), nn = n_Mult(pGetCoeff(p2),n, r->cf), r->cf))
     4412    {
     4413      n_Delete(&n, r->cf);
     4414      n_Delete(&nn, r->cf);
    44164415      return FALSE;
    44174416    }
    4418     n_Delete(&nn, r);
     4417    n_Delete(&nn, r->cf);
    44194418    pIter(p1);
    44204419    pIter(p2);
    44214420  }
    4422   n_Delete(&n, r);
     4421  n_Delete(&n, r->cf);
    44234422  return TRUE;
    44244423}
  • libpolys/polys/monomials/p_polys.h

    r6c086a4 r750069  
    12731273  pAssume1(d_r->N <= s_r->N);
    12741274  poly d_p = p_Init(d_r, d_bin);
    1275   for (int i=d_r->N; i>0; i--)
     1275  for (unsigned i=d_r->N; i!=0; i--)
    12761276  {
    12771277    p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
     
    14151415  p_LmCheckPolyRing1(p2, r);
    14161416
    1417   int i = r->ExpL_Size;
     1417  unsigned i = r->ExpL_Size;
    14181418  unsigned long *ep = p1->exp;
    14191419  unsigned long *eq = p2->exp;
     
    14241424    if (ep[i] != eq[i]) return FALSE;
    14251425  }
    1426   while (i);
     1426  while (i!=0);
    14271427  return TRUE;
    14281428}
     
    14341434                                     r,
    14351435                                     r->ExpPerLong);
    1436   for (int i=r->VarL_Size-1; i>0; i--)
     1436  for (unsigned i=r->VarL_Size-1; i!=0; i--)
    14371437  {
    14381438    s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r,r->ExpPerLong);
     
    14441444{
    14451445  p_LmCheckPolyRing1(p, r);
    1446   for (int j = r->N; j; j--)
     1446  for (unsigned j = r->N; j!=0; j--)
    14471447      ev[j] = p_GetExp(p, j, r);
    14481448
     
    14521452{
    14531453  p_LmCheckPolyRing1(p, r);
    1454   for (int j = r->N; j; j--)
     1454  for (unsigned j = r->N; j!=0; j--)
    14551455      p_SetExp(p, j, ev[j], r);
    14561456
  • libpolys/polys/monomials/ring.cc

    r6c086a4 r750069  
    13421342
    13431343  res->N=rVar(r);      /* number of vars */
    1344   res->OrdSgn=r->OrdSgn; /* 1 for polynomial rings, -1 otherwise */
     1344  //res->OrdSgn=r->OrdSgn; /* 1 for polynomial rings, -1 otherwise */
    13451345
    13461346  res->firstBlockEnds=r->firstBlockEnds;
     
    13571357  res->ShortOut=r->ShortOut;
    13581358  res->CanShortOut=r->CanShortOut;
    1359   res->LexOrder=r->LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
    1360   res->MixedOrder=r->MixedOrder; // TRUE for mixed (global/local) ordering, FALSE otherwise,
    13611359  // 2 for diffenerent signs within one block
    13621360  res->ComponentOrder=r->ComponentOrder;
     
    14001398  if (copy_ordering == TRUE)
    14011399  {
     1400    res->LexOrder=r->LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
     1401    res->MixedOrder=r->MixedOrder; // TRUE for mixed (global/local) ordering, FALSE otherwise,
    14021402    i=rBlocks(r);
    14031403    res->wvhdl   = (int **)omAlloc(i * sizeof(int *));
     
    14651465  if (r == NULL) return NULL;
    14661466  int i,j;
    1467   ring res=(ring)omAllocBin(sip_sring_bin);
    1468   memset(res,0,sizeof(ip_sring));
     1467  ring res=(ring)omAlloc0Bin(sip_sring_bin);
    14691468  //memcpy(res,r,sizeof(ip_sring));
    14701469  //memset: res->idroot=NULL; /* local objects */
     
    14841483
    14851484  res->N=rVar(r);      /* number of vars */
    1486   res->OrdSgn=r->OrdSgn; /* 1 for polynomial rings, -1 otherwise */
     1485  //res->OrdSgn=r->OrdSgn; /* 1 for polynomial rings, -1 otherwise */
    14871486
    14881487  res->firstBlockEnds=r->firstBlockEnds;
  • libpolys/polys/nc/ncSACache.cc

    r6c086a4 r750069  
    3737
    3838#include <coeffs/numbers.h>
    39 #include "coeffrings.h"
    4039
    4140#include "nc/ncSACache.h" // for CCacheHash etc classes
  • libpolys/polys/nc/ncSAFormula.cc

    r6c086a4 r750069  
    3636
    3737#include <coeffs/numbers.h>
    38 #include "coeffrings.h"
    3938
    4039#include "nc/ncSAFormula.h"
     
    117116    const number q = p_GetCoeff(GetC(r, i, j), r);
    118117
    119     if( !n_IsOne(q, r) )
     118    if( !n_IsOne(q, r->cf) )
    120119      return FALSE;
    121120  }
     
    146145
    147146  const poly c = GetC(r, i, j);
    148   const number q = p_GetCoeff(c, r);
     147  const number q = pGetCoeff(c);
    149148  const poly d = GetD(r, i, j);
    150149
     
    159158  {
    160159
    161     if( n_IsOne(q, r) ) // commutative
     160    if( n_IsOne(q, r->cf) ) // commutative
    162161      return _ncSA_1xy0x0y0;
    163162
    164     if( n_IsMOne(q, r) ) // anti-commutative
     163    if( n_IsMOne(q, r->cf) ) // anti-commutative
    165164      return _ncSA_Mxy0x0y0;
    166165
     
    168167  } else
    169168  {
    170     if( n_IsOne(q, r) ) // "Lie" case
     169    if( n_IsOne(q, r->cf) ) // "Lie" case
    171170    {
    172171      if( pNext(d) == NULL ) // Our Main Special Case: d is only a term!
     
    194193            if (AreCommutingVariables(r, k, i/*, &qi*/) && AreCommutingVariables(r, k, j/*, &qj*/) ) // [x, t] = [Dx, t] = 0?
    195194            {
    196               const number g = p_GetCoeff(d, r);
    197 
    198               if (n_IsOne(g, r))
     195              const number g = pGetCoeff(d);
     196
     197              if (n_IsOne(g, r->cf))
    199198                return _ncSA_1xy0x0yT2; // save k!?, G = LC(d) == qi == qj == 1!!!
    200199            }
     
    306305    min = n;
    307306    max = m;
    308   } else
     307  }
     308  else
    309309  {
    310310    min = m;
     
    315315
    316316  if( max == 1 )
    317     qN = n_Copy(m_q, r);
     317    qN = n_Copy(m_q, r->cf);
    318318  else
    319319  {
    320320    number t;
    321     n_Power(m_q, max, &t, r);
     321    n_Power(m_q, max, &t, r->cf);
    322322
    323323    if( min > 1 )
    324324    {
    325       n_Power(t, min, &qN, r);
    326       n_Delete(&t, r);
     325      n_Power(t, min, &qN, r->cf);
     326      n_Delete(&t, r->cf);
    327327    }
    328328    else
     
    346346#if OUTPUT
    347347  Print("ncSA_1xy0x0yG(var(%d)^{%d}, var(%d)^{%d}, G, r)!\n", j, m, i, n);
    348   number t = n_Copy(m_g, r);
    349   PrintS("Parameter G: "); n_Write(t, r);
    350   n_Delete(&t, r);
     348  number t = n_Copy(m_g, r->cf);
     349  PrintS("Parameter G: "); n_Write(t, r->cf);
     350  n_Delete(&t, r->cf);
    351351#endif
    352352
     
    354354  int km = m;
    355355
    356   number c = n_Init(1, r);
     356  number c = n_Init(1, r->cf);
    357357
    358358  poly p = p_One( r);
     
    373373  for(; k < min; k++ )
    374374  {
    375     number t = n_Init(km + 1, r);
    376     n_InpMult(t, m_g, r); // t = ((m - k) + 1) * gamma
    377     n_InpMult(c, t, r);   // c = c'* ((m - k) + 1) * gamma
    378     n_Delete(&t, r);
    379 
    380     t = n_Init(kn + 1, r);
    381     n_InpMult(c, t, r);   // c = (c'* ((m - k) + 1) * gamma) * ((n - k) + 1)
    382     n_Delete(&t, r);
    383 
    384     t = n_Init(k, r);
    385     c = n_Div(c, t, r);
    386     n_Delete(&t, r);
    387 
    388 //    n_Normalize(c, r);
    389 
    390     t = n_Copy(c, r); // not the last!
     375    number t = n_Init(km + 1, r->cf);
     376    n_InpMult(t, m_g, r->cf); // t = ((m - k) + 1) * gamma
     377    n_InpMult(c, t, r->cf);   // c = c'* ((m - k) + 1) * gamma
     378    n_Delete(&t, r->cf);
     379
     380    t = n_Init(kn + 1, r->cf);
     381    n_InpMult(c, t, r->cf);   // c = (c'* ((m - k) + 1) * gamma) * ((n - k) + 1)
     382    n_Delete(&t, r->cf);
     383
     384    t = n_Init(k, r->cf);
     385    c = n_Div(c, t, r->cf);
     386    n_Delete(&t, r->cf);
     387
     388//    n_Normalize(c, r->cf);
     389
     390    t = n_Copy(c, r->cf); // not the last!
    391391
    392392    p = p_NSet(t, r);
     
    405405
    406406  {
    407     n_InpMult(c, m_g, r);   // c = c'* gamma
     407    n_InpMult(c, m_g, r->cf);   // c = c'* gamma
    408408
    409409    if( km > 0 )
    410410    {
    411       number t = n_Init(km + 1, r);
    412       n_InpMult(c, t, r);   // c = (c'* gamma) * (m - k + 1)
    413       n_Delete(&t, r);
     411      number t = n_Init(km + 1, r->cf);
     412      n_InpMult(c, t, r->cf);   // c = (c'* gamma) * (m - k + 1)
     413      n_Delete(&t, r->cf);
    414414    }
    415415
    416416    if( kn > 0 )
    417417    {
    418       number t = n_Init(kn + 1, r);
    419       n_InpMult(c, t, r);   // c = (c'* gamma) * (n - k + 1)
    420       n_Delete(&t, r);
     418      number t = n_Init(kn + 1, r->cf);
     419      n_InpMult(c, t, r->cf);   // c = (c'* gamma) * (n - k + 1)
     420      n_Delete(&t, r->cf);
    421421    }
    422422
    423     number t = n_Init(k, r); // c = ((c'* gamma) * ((n - k + 1) * (m - k + 1))) / k;
    424     c = n_Div(c, t, r);
    425     n_Delete(&t, r);
     423    number t = n_Init(k, r->cf); // c = ((c'* gamma) * ((n - k + 1) * (m - k + 1))) / k;
     424    c = n_Div(c, t, r->cf);
     425    n_Delete(&t, r->cf);
    426426  }
    427427
     
    451451
    452452  // k == 0!
    453   number c = n_Init(1, r);
     453  number c = n_Init(1, r->cf);
    454454
    455455  poly p = p_One( r );
     
    471471  for(; k < min; k++ )
    472472  {
    473     number t = n_Init(km + 1, r);
    474 //    n_InpMult(t, m_g, r); // t = ((m - k) + 1) * gamma
    475     n_InpMult(c, t, r);   // c = c'* ((m - k) + 1) * gamma
    476     n_Delete(&t, r);
    477 
    478     t = n_Init(kn + 1, r);
    479     n_InpMult(c, t, r);   // c = (c'* ((m - k) + 1) * gamma) * ((n - k) + 1)
    480     n_Delete(&t, r);
    481 
    482     t = n_Init(k, r);
    483     c = n_Div(c, t, r);
    484     n_Delete(&t, r);
     473    number t = n_Init(km + 1, r->cf);
     474//    n_InpMult(t, m_g, r->cf); // t = ((m - k) + 1) * gamma
     475    n_InpMult(c, t, r->cf);   // c = c'* ((m - k) + 1) * gamma
     476    n_Delete(&t, r->cf);
     477
     478    t = n_Init(kn + 1, r->cf);
     479    n_InpMult(c, t, r->cf);   // c = (c'* ((m - k) + 1) * gamma) * ((n - k) + 1)
     480    n_Delete(&t, r->cf);
     481
     482    t = n_Init(k, r->cf);
     483    c = n_Div(c, t, r->cf);
     484    n_Delete(&t, r->cf);
    485485
    486486// //    n_Normalize(c, r);
    487487
    488     t = n_Copy(c, r); // not the last!
     488    t = n_Copy(c, r->cf); // not the last!
    489489
    490490    p = p_NSet(t, r);
     
    509509    if( km > 0 )
    510510    {
    511       number t = n_Init(km + 1, r);
    512       n_InpMult(c, t, r);   // c = (c'* gamma) * (m - k + 1)
    513       n_Delete(&t, r);
     511      number t = n_Init(km + 1, r->cf);
     512      n_InpMult(c, t, r->cf);   // c = (c'* gamma) * (m - k + 1)
     513      n_Delete(&t, r->cf);
    514514    }
    515515
    516516    if( kn > 0 )
    517517    {
    518       number t = n_Init(kn + 1, r);
    519       n_InpMult(c, t, r);   // c = (c'* gamma) * (n - k + 1)
    520       n_Delete(&t, r);
     518      number t = n_Init(kn + 1, r->cf);
     519      n_InpMult(c, t, r->cf);   // c = (c'* gamma) * (n - k + 1)
     520      n_Delete(&t, r->cf);
    521521    }
    522522
    523     number t = n_Init(k, r); // c = ((c'* gamma) * ((n - k + 1) * (m - k + 1))) / k;
    524     c = n_Div(c, t, r);
    525     n_Delete(&t, r);
     523    number t = n_Init(k, r->cf); // c = ((c'* gamma) * ((n - k + 1) * (m - k + 1))) / k;
     524    c = n_Div(c, t, r->cf);
     525    n_Delete(&t, r->cf);
    526526  }
    527527
     
    552552  int k = m; // to 0
    553553
    554   number c = n_Init(1, r); // k = m, C_k = 1
     554  number c = n_Init(1, r->cf); // k = m, C_k = 1
    555555  poly p = p_One( r);
    556556
     
    564564  poly pLast = p;
    565565
    566   number nn =  n_Init(n, r); // number(n)!
    567   n_InpMult(nn, m_shiftCoef, r); // nn = (alpha*n)
     566  number nn =  n_Init(n, r->cf); // number(n)!
     567  n_InpMult(nn, m_shiftCoef, r->cf); // nn = (alpha*n)
    568568
    569569  --k;
     
    573573  for(; k > 0; k-- )
    574574  {
    575     number t = n_Init(k + 1, r);  // t = k+1
    576     n_InpMult(c, t, r);           // c = c' * (k+1)
    577     n_InpMult(c, nn, r);          // c = (c' * (k+1)) * (alpha * n)
    578 
    579     n_Delete(&t, r);
    580     t = n_Init(mk++, r);
    581     c = n_Div(c, t, r);           // c = ((c' * (k+1))  * (alpha * n)) / (m-k);
    582     n_Delete(&t, r);
    583 
    584 //    n_Normalize(c, r);
    585 
    586     t = n_Copy(c, r); // not the last!
     575    number t = n_Init(k + 1, r->cf);  // t = k+1
     576    n_InpMult(c, t, r->cf);           // c = c' * (k+1)
     577    n_InpMult(c, nn, r->cf);          // c = (c' * (k+1)) * (alpha * n)
     578
     579    n_Delete(&t, r->cf);
     580    t = n_Init(mk++, r->cf);
     581    c = n_Div(c, t, r->cf);           // c = ((c' * (k+1))  * (alpha * n)) / (m-k);
     582    n_Delete(&t, r->cf);
     583
     584//    n_Normalize(c, r->cf);
     585
     586    t = n_Copy(c, r->cf); // not the last!
    587587
    588588    p = p_NSet(t, r);
     
    600600
    601601  {
    602     n_InpMult(c, nn, r);          // c = (c' * (0+1)) * (alpha * n)
    603 
    604     number t = n_Init(m, r);
    605     c = n_Div(c, t, r);           // c = ((c' * (0+1))  * (alpha * n)) / (m-0);
    606     n_Delete(&t, r);
    607   }
    608 
    609   n_Delete(&nn, r);
     602    n_InpMult(c, nn, r->cf);          // c = (c' * (0+1)) * (alpha * n)
     603
     604    number t = n_Init(m, r->cf);
     605    c = n_Div(c, t, r->cf);           // c = ((c' * (0+1))  * (alpha * n)) / (m-0);
     606    n_Delete(&t, r->cf);
     607  }
     608
     609  n_Delete(&nn, r->cf);
    610610
    611611  p = p_NSet(c, r);
  • libpolys/polys/nc/ncSAMult.cc

    r6c086a4 r750069  
    3838#include <misc/options.h>
    3939#include <coeffs/numbers.h>
    40 #include "coeffrings.h"
    4140
    4241
  • libpolys/polys/nc/ncSAMult.h

    r6c086a4 r750069  
    1616#include <polys/operations/p_Mult_q.h>
    1717
    18 #include <polys/coeffrings.h>
    19 
    2018//#include <polys/nc/ncSACache.h> // for CCacheHash etc classes
    2119#include <polys/nc/ncSAFormula.h> // for CFormulaPowerMultiplier and enum Enum_ncSAType
     
    4543    {
    4644      poly pMonom = p_LmInit(pTerm, r);
    47       pSetCoeff0(pMonom, n_Init(i, r));
     45      pSetCoeff0(pMonom, n_Init(i, r->cf));
    4846      return pMonom;
    4947    }
  • libpolys/polys/nc/old.gring.cc

    r6c086a4 r750069  
    3232
    3333#include <coeffs/numbers.h>
    34 #include <polys/coeffrings.h>
    3534
    3635// #include <polys/febase.h>
     
    6362// #endif
    6463
    65 static poly NF_Proc_Dummy(ideal, ideal, poly, int, int, const ring _currRing)
     64static poly NF_Proc_Dummy(ideal, ideal, poly, int, int, const ring)
    6665{ WerrorS("nc_NF not defined"); return NULL; }
    67 static ideal BBA_Proc_Dummy (const ideal, const ideal, const intvec *, const intvec *, kStrategy strat, const ring)
     66static ideal BBA_Proc_Dummy (const ideal, const ideal, const intvec *, const intvec *, kStrategy, const ring)
    6867{ WerrorS("nc_NF not defined"); return NULL; }
    6968
     
    424423    }
    425424    p_GetExpV(p,P,r);
    426     cP=p_GetCoeff(p,r);
    427     cOut=n_Mult(cP,cM,r);
     425    cP=pGetCoeff(p);
     426    cOut=n_Mult(cP,cM,r->cf);
    428427    if (side==1)
    429428    {
     
    435434    }
    436435    v = p_Mult_nn(v,cOut,r);
    437     n_Delete(&cOut,r);
     436    n_Delete(&cOut,r->cf);
    438437    p_SetCompP(v,expOut,r);
    439438
     
    518517  }
    519518
    520   number cff=n_Init(1,r);
     519  number cff=n_Init(1,r->cf);
    521520  number tmp_num=NULL;
    522521  int cpower=0;
     
    540539        }
    541540      }
    542       cff = n_Copy(p_GetCoeff(MATELEM(r->GetNC()->COM,1,2),r),r);
    543       n_Power(cff,tpower,&tmp_num, r);
    544       n_Delete(&cff,r);
     541      cff = n_Copy(pGetCoeff(MATELEM(r->GetNC()->COM,1,2)),r->cf);
     542      n_Power(cff,tpower,&tmp_num, r->cf);
     543      n_Delete(&cff,r->cf);
    545544      cff = tmp_num;
    546545    }
    547546    else /* skew commutative with nonequal coeffs */
    548547    {
    549       number totcff=n_Init(1,r);
     548      number totcff=n_Init(1,r->cf);
    550549      for(j=jG; j<=iG; j++)
    551550      {
     
    558557            {
    559558              cpower = F[i]*G[j]; // bug! overflow danger!!!
    560               cff = n_Copy(p_GetCoeff(MATELEM(r->GetNC()->COM,j,i),r),r);
    561               n_Power(cff,cpower,&tmp_num, r);
    562               cff = n_Mult(totcff,tmp_num, r);
    563               n_Delete(&totcff, r);
    564               n_Delete(&tmp_num, r);
    565               totcff = n_Copy(cff,r);
    566               n_Delete(&cff,r);
     559              cff = n_Copy(pGetCoeff(MATELEM(r->GetNC()->COM,j,i)),r->cf);
     560              n_Power(cff,cpower,&tmp_num, r->cf);
     561              cff = n_Mult(totcff,tmp_num, r->cf);
     562              n_Delete(&totcff, r->cf);
     563              n_Delete(&tmp_num, r->cf);
     564              totcff = n_Copy(cff,r->cf);
     565              n_Delete(&cff,r->cf);
    567566            }
    568567          } /* end 2nd for */
     
    633632  poly Rout=NULL;
    634633  number *c=(number *)omAlloc0((rN+1)*sizeof(number));
    635   c[0]=n_Init(1,r);
     634  c[0]=n_Init(1,r->cf);
    636635
    637636  int *Op=Nxt;
     
    654653
    655654     w=gnc_mm_Mult_uu(Op,t,On[t],r);
    656      c[cnt]=n_Mult(c[cnt-1],p_GetCoeff(w,r),r);
     655     c[cnt]=n_Mult(c[cnt-1],pGetCoeff(w),r->cf);
    657656     D = pNext(w);  /* getting coef and rest D */
    658657     p_LmDelete(&w,r);
     
    869868  poly Rout=NULL;
    870869  number *c=(number *)omAlloc0((cnt+2)*sizeof(number));
    871   c[cnt+1]=n_Init(1,r);
     870  c[cnt+1]=n_Init(1,r->cf);
    872871  i=cnt+2;         /* later in freeN */
    873872  int *Op=Nxt;
     
    898897
    899898     poly w=gnc_uu_Mult_ww(t,Op[t],jG,bG,r);
    900      c[cnt]=n_Copy(p_GetCoeff(w,r),r);
     899     c[cnt]=n_Copy(pGetCoeff(w),r->cf);
    901900     D = pNext(w);  /* getting coef and rest D */
    902901     p_LmDelete(&w,r);
     
    943942#endif
    944943     p_Delete(&Pp,r);
    945      num=n_Mult(c[cnt+1],c[cnt],r);
    946      n_Delete(&c[cnt],r);
     944     num=n_Mult(c[cnt+1],c[cnt],r->cf);
     945     n_Delete(&c[cnt],r->cf);
    947946     c[cnt]=num;
    948947     Rout=p_Mult_nn(Rout,c[cnt+1],r); /* Rest is ready */
     
    11191118    p_AddExp(out,j,b,r);
    11201119    p_Setm(out,r);
    1121     if (n_IsOne(p_GetCoeff(MATELEM(r->GetNC()->COM,j,i),r),r)) /* commutative case */
     1120    if (n_IsOne(pGetCoeff(MATELEM(r->GetNC()->COM,j,i)),r->cf)) /* commutative case */
    11221121    {
    11231122      return(out);
     
    11251124    else
    11261125    {
    1127       number tmp_number=p_GetCoeff(MATELEM(r->GetNC()->COM,j,i),r); /* quasicommutative case */
    1128       n_Power(tmp_number,a*b,&tmp_number, r); // BUG! ;-(
     1126      number tmp_number=pGetCoeff(MATELEM(r->GetNC()->COM,j,i)); /* quasicommutative case */
     1127      n_Power(tmp_number,a*b,&tmp_number, r->cf); // BUG! ;-(
    11291128      p_SetCoeff(out,tmp_number,r);
    11301129      return(out);
     
    14241423  /* GCD stuff */
    14251424  number cG = n_SubringGcd(C, cF, r->cf);
    1426   if ( !n_IsOne(cG,r) )
    1427   {
    1428     cF = n_Div(cF, cG, r); n_Normalize(cF, r);
    1429     C  = n_Div(C,  cG, r); n_Normalize(C, r);
     1425  if ( !n_IsOne(cG,r->cf) )
     1426  {
     1427    cF = n_Div(cF, cG, r->cf); n_Normalize(cF, r->cf);
     1428    C  = n_Div(C,  cG, r->cf); n_Normalize(C, r->cf);
    14301429  }
    14311430  else
    14321431  {
    1433     cF = n_Copy(cF, r);
    1434     C  = n_Copy(C, r);
    1435   }
    1436   n_Delete(&cG,r);
     1432    cF = n_Copy(cF, r->cf);
     1433    C  = n_Copy(C, r->cf);
     1434  }
     1435  n_Delete(&cG,r->cf);
    14371436  p2 = p_Mult_nn(p2, C, r);
    14381437  poly out = nc_mm_Mult_pp(m, pNext(p1), r);
     
    14401439  p_Test(p2,r);
    14411440  p_Test(N,r);
    1442   if (!n_IsMOne(cF,r))
    1443   {
    1444     cF = n_InpNeg(cF,r);
     1441  if (!n_IsMOne(cF,r->cf))
     1442  {
     1443    cF = n_InpNeg(cF,r->cf);
    14451444    N  = p_Mult_nn(N, cF, r);
    14461445    p_Test(N,r);
     
    14501449  if ( out!=NULL ) p_Content(out,r);
    14511450  p_Delete(&m,r);
    1452   n_Delete(&cF,r);
    1453   n_Delete(&C,r);
     1451  n_Delete(&cF,r->cf);
     1452  n_Delete(&C,r->cf);
    14541453  return(out);
    14551454}
     
    14861485  number cG = n_SubringGcd(C, cF, r->cf);
    14871486
    1488   if (!n_IsOne(cG, r))
    1489   {
    1490     cF = n_Div(cF, cG, r); n_Normalize(cF, r);
    1491     C  = n_Div(C,  cG, r); n_Normalize(C, r);
     1487  if (!n_IsOne(cG, r->cf))
     1488  {
     1489    cF = n_Div(cF, cG, r->cf); n_Normalize(cF, r->cf);
     1490    C  = n_Div(C,  cG, r->cf); n_Normalize(C, r->cf);
    14921491  }
    14931492  else
    14941493  {
    1495     cF = n_Copy(cF, r);
    1496     C  = n_Copy(C, r);
    1497   }
    1498   n_Delete(&cG,r);
     1494    cF = n_Copy(cF, r->cf);
     1495    C  = n_Copy(C, r->cf);
     1496  }
     1497  n_Delete(&cG,r->cf);
    14991498
    15001499  p2 = p_Mult_nn(p2, C, r); // p2 !!!
    15011500  p_Test(p2,r);
    1502   n_Delete(&C,r);
    1503   n_Delete(&cG,r);
     1501  n_Delete(&C,r->cf);
     1502  n_Delete(&cG,r->cf);
    15041503
    15051504  poly out = nc_mm_Mult_pp(m, pNext(p1), r);
     
    15091508  p_Test(N,r);
    15101509
    1511   if (!n_IsMOne(cF,r)) // ???
    1512   {
    1513     cF = n_InpNeg(cF,r);
     1510  if (!n_IsMOne(cF,r->cf)) // ???
     1511  {
     1512    cF = n_InpNeg(cF,r->cf);
    15141513    N  = p_Mult_nn(N, cF, r);
    15151514    p_Test(N,r);
    15161515  }
    1517   n_Delete(&cF,r);
     1516  n_Delete(&cF,r->cf);
    15181517
    15191518  out = p_Add_q(p2,N,r); // delete N, p2
     
    15711570  /* GCD stuff */
    15721571  number C = n_SubringGcd(C1,C2,r->cf);
    1573   if (!n_IsOne(C,r))
    1574   {
    1575     C1=n_Div(C1,C, r);n_Normalize(C1,r);
    1576     C2=n_Div(C2,C, r);n_Normalize(C2,r);
     1572  if (!n_IsOne(C,r->cf))
     1573  {
     1574    C1=n_Div(C1,C, r->cf);n_Normalize(C1,r->cf);
     1575    C2=n_Div(C2,C, r->cf);n_Normalize(C2,r->cf);
    15771576  }
    15781577  else
    15791578  {
    1580     C1=n_Copy(C1, r);
    1581     C2=n_Copy(C2, r);
    1582   }
    1583   n_Delete(&C,r);
     1579    C1=n_Copy(C1, r->cf);
     1580    C2=n_Copy(C2, r->cf);
     1581  }
     1582  n_Delete(&C,r->cf);
    15841583  M1=p_Mult_nn(M1,C2,r);
    15851584  p_SetCoeff(m1,C2,r);
    1586   if (n_IsMOne(C1,r))
     1585  if (n_IsMOne(C1,r->cf))
    15871586  {
    15881587    M2=p_Add_q(M1,M2,r);
     
    15901589  else
    15911590  {
    1592     C1=n_InpNeg(C1,r);
     1591    C1=n_InpNeg(C1,r->cf);
    15931592    M2=p_Mult_nn(M2,C1,r);
    15941593    M2=p_Add_q(M1,M2,r);
     
    17541753  number C = n_SubringGcd(C1, C2, r->cf);           // C = gcd(C1, C2)
    17551754
    1756   if (!n_IsOne(C, r))                              // if C != 1
    1757   {
    1758     C1=n_Div(C1, C, r);n_Normalize(C1,r);            // C1 = C1 / C
    1759     C2=n_Div(C2, C, r);n_Normalize(C2,r);            // C2 = C2 / C
     1755  if (!n_IsOne(C, r->cf))                              // if C != 1
     1756  {
     1757    C1=n_Div(C1, C, r->cf);n_Normalize(C1,r->cf);            // C1 = C1 / C
     1758    C2=n_Div(C2, C, r->cf);n_Normalize(C2,r->cf);            // C2 = C2 / C
    17601759  }
    17611760  else
    17621761  {
    1763     C1=n_Copy(C1,r);
    1764     C2=n_Copy(C2,r);
    1765   }
    1766 
    1767   n_Delete(&C,r); // destroy the number C
    1768 
    1769   C1=n_InpNeg(C1,r);
     1762    C1=n_Copy(C1,r->cf);
     1763    C2=n_Copy(C2,r->cf);
     1764  }
     1765
     1766  n_Delete(&C,r->cf); // destroy the number C
     1767
     1768  C1=n_InpNeg(C1,r->cf);
    17701769
    17711770//   number MinusOne=n_Init(-1,r);
     
    19151914  M=p_Add_q(M,nc_mm_Mult_p(m,p_LmDeleteAndNext(p_Copy(p1,r),r),r),r); // _pp?
    19161915  q=p_Mult_nn(q,C,r);
    1917   number MinusOne=n_Init(-1,r);
    1918   if (!n_Equal(cQ,MinusOne,r))
     1916  number MinusOne=n_Init(-1,r->cf);
     1917  if (!n_Equal(cQ,MinusOne,r->cf))
    19191918  {
    19201919    cQ=nInpNeg(cQ);
     
    19251924
    19261925  p_Delete(&m,r);
    1927   n_Delete(&C,r);
    1928   n_Delete(&cQ,r);
    1929   n_Delete(&MinusOne,r);
     1926  n_Delete(&C,r->cf);
     1927  n_Delete(&cQ,r->cf);
     1928  n_Delete(&MinusOne,r->cf);
    19301929  /*  return(q); */
    19311930}
     
    19681967  }
    19691968
    1970 //  n_Delete(&p_GetCoeff(m, r), r);
     1969//  n_Delete(&p_GetCoeff(m, r), r->cf);
    19711970//  pSetCoeff0(m, NULL);
    19721971
     
    19831982  // b will not be multiplied by any constant in this impl.
    19841983  // ==> *c=1
    1985   if (c!=NULL) *c=n_Init(1, r);
     1984  if (c!=NULL) *c=n_Init(1, r->cf);
    19861985  poly m=p_One(r);
    19871986  p_ExpVectorDiff(m,kBucketGetLm(b),p, r);
     
    19931992  assume(pp!=NULL);
    19941993  p_Delete(&m, r);
    1995   number n=p_GetCoeff(pp, r);
     1994  number n=pGetCoeff(pp);
    19961995  number nn;
    1997   if (!n_IsMOne(n, r))
    1998   {
    1999     nn=n_InpNeg(n_Invers(n, r), r);
    2000     n= n_Mult(nn,p_GetCoeff(kBucketGetLm(b), r), r);
    2001     n_Delete(&nn, r);
     1996  if (!n_IsMOne(n, r->cf))
     1997  {
     1998    nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
     1999    n= n_Mult(nn,pGetCoeff(kBucketGetLm(b)), r->cf);
     2000    n_Delete(&nn, r->cf);
    20022001    pp=p_Mult_nn(pp,n,r);
    2003     n_Delete(&n, r);
     2002    n_Delete(&n, r->cf);
    20042003  }
    20052004  else
     
    20312030  // b will not be multiplied by any constant in this impl.
    20322031  // ==> *c=1
    2033   if (c!=NULL) *c=n_Init(1, r);
     2032  if (c!=NULL) *c=n_Init(1, r->cf);
    20342033  poly m = p_One(r);
    20352034  const poly pLmB = kBucketGetLm(b); // no new copy!
     
    20592058
    20602059  assume( pp != NULL );
    2061   const number n = p_GetCoeff(pp, r); // bug!
    2062 
    2063   if (!n_IsMOne(n, r) ) // does this improve performance??!? also see below... // TODO: check later on.
     2060  const number n = pGetCoeff(pp); // bug!
     2061
     2062  if (!n_IsMOne(n, r->cf) ) // does this improve performance??!? also see below... // TODO: check later on.
    20642063  // if n == -1 => nn = 1 and -1/n
    20652064  {
    2066     number nn=n_InpNeg(n_Invers(n, r), r);
    2067     number t = n_Mult(nn,p_GetCoeff(pLmB, r), r);
    2068     n_Delete(&nn, r);
     2065    number nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
     2066    number t = n_Mult(nn,pGetCoeff(pLmB), r->cf);
     2067    n_Delete(&nn, r->cf);
    20692068    pp = p_Mult_nn(pp,t,r);
    2070     n_Delete(&t, r);
     2069    n_Delete(&t, r->cf);
    20712070  }
    20722071  else
     
    21162115    //cc=*c;
    21172116    //*c=nMult(*c,c2);
    2118     n_Delete(&c2, r);
     2117    n_Delete(&c2, r->cf);
    21192118    //nDelete(&cc);
    21202119    p_Delete(&pp, r);
    21212120  }
    21222121  if (c!=NULL) *c=ctmp;
    2123   else n_Delete(&ctmp, r);
     2122  else n_Delete(&ctmp, r->cf);
    21242123}
    21252124
     
    21502149    //cc=*c;
    21512150    //*c=nMult(*c,c2);
    2152     n_Delete(&c2, r);
     2151    n_Delete(&c2, r->cf);
    21532152    //nDelete(&cc);
    21542153    p_Delete(&pp, r);
    21552154  }
    21562155  if (c!=NULL) *c=ctmp;
    2157   else n_Delete(&ctmp, r);
     2156  else n_Delete(&ctmp, r->cf);
    21582157}
    21592158
     
    21642163  // b will not by multiplied by any constant in this impl.
    21652164  // ==> *c=1
    2166   if (c!=NULL) *c=n_Init(1, r);
     2165  if (c!=NULL) *c=n_Init(1, r->cf);
    21672166  poly m=p_One(r);
    21682167  p_ExpVectorDiff(m,p_Head(b, r),p, r);
     
    21752174
    21762175  p_Delete(&m, r);
    2177   number n=p_GetCoeff(pp, r);
     2176  number n=pGetCoeff(pp);
    21782177  number nn;
    2179   if (!n_IsMOne(n, r))
    2180   {
    2181     nn=n_InpNeg(n_Invers(n, r), r);
    2182     n =n_Mult(nn,p_GetCoeff(b, r), r);
    2183     n_Delete(&nn, r);
     2178  if (!n_IsMOne(n, r->cf))
     2179  {
     2180    nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
     2181    n =n_Mult(nn,pGetCoeff(b), r->cf);
     2182    n_Delete(&nn, r->cf);
    21842183    pp=p_Mult_nn(pp,n,r);
    2185     n_Delete(&n, r);
     2184    n_Delete(&n, r->cf);
    21862185  }
    21872186  else
     
    22112210  // b will not by multiplied by any constant in this impl.
    22122211  // ==> *c=1
    2213   if (c!=NULL) *c=n_Init(1, r);
     2212  if (c!=NULL) *c=n_Init(1, r->cf);
    22142213
    22152214  poly pp = NULL;
     
    22712270  assume(pp != NULL);
    22722271
    2273   const number n = p_GetCoeff(pp, r); // no new copy
     2272  const number n = pGetCoeff(pp); // no new copy
    22742273
    22752274  number nn;
    22762275
    2277   if (!n_IsMOne(n, r)) // TODO: as above.
    2278   {
    2279     nn=n_InpNeg(n_Invers(n, r), r);
    2280     number t = n_Mult(nn, p_GetCoeff(b, r), r);
    2281     n_Delete(&nn, r);
     2276  if (!n_IsMOne(n, r->cf)) // TODO: as above.
     2277  {
     2278    nn=n_InpNeg(n_Invers(n, r->cf), r->cf);
     2279    number t = n_Mult(nn, pGetCoeff(b), r->cf);
     2280    n_Delete(&nn, r->cf);
    22822281    pp=p_Mult_nn(pp, t, r);
    2283     n_Delete(&t, r);
     2282    n_Delete(&t, r->cf);
    22842283  }
    22852284  else
     
    23322331      if (pres!=NULL)
    23332332      {
    2334         coef = n_Mult(p_GetCoeff(p, r),p_GetCoeff(Q, r), r);
     2333        coef = n_Mult(pGetCoeff(p),pGetCoeff(Q), r->cf);
    23352334        pres = p_Mult_nn(pres,coef,r);
    23362335
    23372336        sum += pres;
    2338         n_Delete(&coef, r);
     2337        n_Delete(&coef, r->cf);
    23392338      }
    23402339      pIter(Q);
     
    23782377          /* compute [ x_j^M1[j],x_i^M2[i] ] */
    23792378          if (i<j) {nMax=j;  nMin=i;} else {nMax=i;  nMin=j;}
    2380           if ( (i==j) || ((MATELEM(r->GetNC()->COM,nMin,nMax)!=NULL) && n_IsOne(p_GetCoeff(MATELEM(r->GetNC()->C,nMin,nMax), r), r) )) /* not (the same exp. or commuting exps)*/
     2379          if ( (i==j) || ((MATELEM(r->GetNC()->COM,nMin,nMax)!=NULL) && n_IsOne(pGetCoeff(MATELEM(r->GetNC()->C,nMin,nMax)), r->cf) )) /* not (the same exp. or commuting exps)*/
    23812380          { bres=NULL; }
    23822381          else
     
    23842383            if (i<j) { bres=gnc_uu_Mult_ww(j,M1[j],i,M2[i], r); }
    23852384            else bres=gnc_uu_Mult_ww(i,M2[i],j,M1[j], r);
    2386             if (n_IsOne(p_GetCoeff(bres, r), r))
     2385            if (n_IsOne(pGetCoeff(bres), r->cf))
    23872386            {
    23882387              bres=p_LmDeleteAndNext(bres, r);
     
    23902389            else
    23912390            {
    2392               nTmp=n_Sub(p_GetCoeff(bres, r),n_Init(1, r), r);
     2391              nTmp=n_Sub(pGetCoeff(bres),n_Init(1, r->cf), r->cf);
    23932392              p_SetCoeff(bres,nTmp, r); /* only lc ! */
    23942393            }
     
    25112510            pIter(p);
    25122511          }
    2513           number ntd = n_Init(totdeg, r);
    2514           number nln = n_Init(length, r);
    2515           number nres= n_Div(ntd,nln, r);
    2516           n_Delete(&ntd, r);
    2517           n_Delete(&nln, r);
     2512          number ntd = n_Init(totdeg, r->cf);
     2513          number nln = n_Init(length, r->cf);
     2514          number nres= n_Div(ntd,nln, r->cf);
     2515          n_Delete(&ntd, r->cf);
     2516          n_Delete(&nln, r->cf);
    25182517          MATELEM(res,s,t)=p_NSet(nres,r);
    25192518        }
     
    28842883    assume(p_IsConstant(CN,curr));
    28852884
    2886     nN = p_GetCoeff(CN, curr);
    2887     if (n_IsZero(nN, curr))
     2885    nN = pGetCoeff(CN);
     2886    if (n_IsZero(nN, curr->cf))
    28882887    {
    28892888      WerrorS("Incorrect input : zero coefficients are not allowed");
     
    28942893    }
    28952894
    2896     if (n_IsOne(nN, curr))
     2895    if (n_IsOne(nN, curr->cf))
    28972896      nctype = nc_lie;
    28982897    else
     
    29682967    IsSkewConstant = tmpIsSkewConstant;
    29692968
    2970     if ( tmpIsSkewConstant && n_IsOne(pN, curr) )
     2969    if ( tmpIsSkewConstant && n_IsOne(pN, curr->cf) )
    29712970      nctype = nc_lie;
    29722971    else
     
    31543153      p = p_One(r);
    31553154      if (MATELEM(r->GetNC()->C,i,j)!=NULL)
    3156         p_SetCoeff(p,n_Copy(pGetCoeff(MATELEM(r->GetNC()->C,i,j)),r),r);
     3155        p_SetCoeff(p,n_Copy(pGetCoeff(MATELEM(r->GetNC()->C,i,j)),r->cf),r);
    31573156      p_SetExp(p,i,1,r);
    31583157      p_SetExp(p,j,1,r);
  • libpolys/polys/nc/sca.cc

    r6c086a4 r750069  
    3636
    3737#include <coeffs/numbers.h>
    38 #include <polys/coeffrings.h>
    39 
    4038
    4139// #include <polys/febase.h>
     
    186184
    187185    if( (tpower) != 0 ) // degree is odd => negate coeff.
    188       nCoeffM = n_InpNeg(nCoeffM, rRing); // negate nCoeff (will destroy the original number)
     186      nCoeffM = n_InpNeg(nCoeffM, rRing->cf); // negate nCoeff (will destroy the original number)
    189187
    190188    const number nCoeffMM = p_GetCoeff(pMonomMM, rRing); // no new copy!
    191189
    192     number nCoeff = n_Mult(nCoeffM, nCoeffMM, rRing); // new number!
     190    number nCoeff = n_Mult(nCoeffM, nCoeffMM, rRing->cf); // new number!
    193191
    194192    p_SetCoeff(pMonomM, nCoeff, rRing); // delete lc(pMonomM) and set lc(pMonomM) = nCoeff
     
    250248
    251249    if( (tpower) != 0 ) // degree is odd => negate coeff.
    252       nCoeffM = n_InpNeg(nCoeffM, rRing); // negate nCoeff (will destroy the original number), creates new number!
     250      nCoeffM = n_InpNeg(nCoeffM, rRing->cf); // negate nCoeff (will destroy the original number), creates new number!
    253251
    254252    const number nCoeffMM = p_GetCoeff(pMonomMM, rRing); // no new copy!
    255253
    256     number nCoeff = n_Mult(nCoeffM, nCoeffMM, rRing); // new number!
     254    number nCoeff = n_Mult(nCoeffM, nCoeffMM, rRing->cf); // new number!
    257255
    258256    p_SetCoeff(pMonomM, nCoeff, rRing); // delete lc(pMonomM) and set lc(pMonomM) = nCoeff
     
    318316    const number nCoeff2 = p_GetCoeff(pMonom2, rRing); // no new copy!
    319317
    320     number nCoeff = n_Mult(nCoeff1, nCoeff2, rRing); // new number!
     318    number nCoeff = n_Mult(nCoeff1, nCoeff2, rRing->cf); // new number!
    321319
    322320    if( (tpower) != 0 ) // degree is odd => negate coeff.
    323       nCoeff = n_InpNeg(nCoeff, rRing); // negate nCoeff (will destroy the original number)
     321      nCoeff = n_InpNeg(nCoeff, rRing->cf); // negate nCoeff (will destroy the original number)
    324322
    325323    p_SetCoeff0(pResult, nCoeff, rRing); // set lc(pResult) = nCoeff, no destruction!
     
    363361    p_Setm(pResult, rRing);         // addjust degree after previous step!
    364362
    365     number nCoeff = n_Copy(p_GetCoeff(pMonom, rRing), rRing); // new number!
     363    number nCoeff = n_Copy(pGetCoeff(pMonom), rRing->cf); // new number!
    366364
    367365    if( cpower != 0 ) // degree is odd => negate coeff.
    368       nCoeff = n_InpNeg(nCoeff, rRing); // negate nCoeff (will destroy the original number)
     366      nCoeff = n_InpNeg(nCoeff, rRing->cf); // negate nCoeff (will destroy the original number)
    369367
    370368    p_SetCoeff0(pResult, nCoeff, rRing); // set lc(pResult) = nCoeff, no destruction!
     
    791789  p_Delete(&pL,r);
    792790
    793   number C1  = n_Copy(p_GetCoeff(p1,r),r);      // C1 = lc(p1)
    794   number C2  = n_Copy(p_GetCoeff(p2,r),r);      // C2 = lc(p2)
    795 
    796   number C = n_Gcd(C1,C2,r);                     // C = gcd(C1, C2)
    797 
    798   if (!n_IsOne(C, r))                              // if C != 1
    799   {
    800     C1=n_Div(C1, C, r);                              // C1 = C1 / C
    801     C2=n_Div(C2, C, r);                              // C2 = C2 / C
    802   }
    803 
    804   n_Delete(&C,r); // destroy the number C
     791  number C1  = n_Copy(pGetCoeff(p1),r->cf);      // C1 = lc(p1)
     792  number C2  = n_Copy(pGetCoeff(p2),r->cf);      // C2 = lc(p2)
     793
     794  number C = n_Gcd(C1,C2,r->cf);                     // C = gcd(C1, C2)
     795
     796  if (!n_IsOne(C, r->cf))                              // if C != 1
     797  {
     798    C1=n_Div(C1, C, r->cf);                              // C1 = C1 / C
     799    C2=n_Div(C2, C, r->cf);                              // C2 = C2 / C
     800  }
     801
     802  n_Delete(&C,r->cf); // destroy the number C
    805803
    806804  const int iSignSum = sca_Sign_mm_Mult_mm (m1, p1, r) + sca_Sign_mm_Mult_mm (m2, p2, r);
     
    810808
    811809  if( iSignSum != 0 ) // the same sign!
    812     C2=n_InpNeg (C2, r);
     810    C2=n_InpNeg (C2, r->cf);
    813811
    814812  p_SetCoeff(m1, C2, r);                           // lc(m1) = C2!!!
     
    865863#endif
    866864
    867   number C1 = n_Copy( p_GetCoeff(p1, r), r);
    868   number C2 = n_Copy( p_GetCoeff(p2, r), r);
     865  number C1 = n_Copy( pGetCoeff(p1), r->cf);
     866  number C2 = n_Copy( pGetCoeff(p2), r->cf);
    869867
    870868  /* GCD stuff */
    871   number C = n_Gcd(C1, C2, r);
    872 
    873   if (!n_IsOne(C, r))
    874   {
    875     C1 = n_Div(C1, C, r);
    876     C2 = n_Div(C2, C, r);
    877   }
    878   n_Delete(&C,r);
     869  number C = n_Gcd(C1, C2, r->cf);
     870
     871  if (!n_IsOne(C, r->cf))
     872  {
     873    C1 = n_Div(C1, C, r->cf);
     874    C2 = n_Div(C2, C, r->cf);
     875  }
     876  n_Delete(&C,r->cf);
    879877
    880878  const int iSign = sca_Sign_mm_Mult_mm( m, p1, r );
    881879
    882880  if(iSign == 1)
    883     C2 = n_InpNeg(C2,r);
     881    C2 = n_InpNeg(C2,r->cf);
    884882
    885883  p_SetCoeff(m, C2, r);
     
    892890
    893891  p2 = p_Mult_nn(p2, C1, r); // p2 !!!
    894   n_Delete(&C1,r);
     892  n_Delete(&C1,r->cf);
    895893
    896894  poly T = nc_mm_Mult_pp(m, pNext(p1), r);
     
    10071005      number c = p_GetCoeff(MATELEM(C,i,j), rBase);
    10081006
    1009       if( n_IsMOne(c, rBase) ) // !!!???
     1007      if( n_IsMOne(c, rBase->cf) ) // !!!???
    10101008      {
    10111009        if( i < iAltVarStart)
     
    10161014      } else
    10171015      {
    1018         if( !n_IsOne(c, rBase) )
     1016        if( !n_IsOne(c, rBase->cf) )
    10191017        {
    10201018#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
     
    10451043      if( (iAltVarStart <= i) && (j <= iAltVarEnd) ) // S <= i < j <= E
    10461044      { // anticommutative part
    1047         if( !n_IsMOne(c, rBase) )
     1045        if( !n_IsMOne(c, rBase->cf) )
    10481046        {
    10491047#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
     
    10521050          return false;
    10531051        }
    1054       } else
     1052      }
     1053      else
    10551054      { // should commute
    1056         if( !n_IsOne(c, rBase) )
     1055        if( !n_IsOne(c, rBase->cf) )
    10571056        {
    10581057#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
  • libpolys/polys/sparsmat.cc

    r6c086a4 r750069  
    2121
    2222#include <coeffs/numbers.h>
    23 #include "coeffrings.h"
    2423
    2524#include "monomials/ring.h"
     
    27512750        {
    27522751          ap->n = a->n;
    2753           a->m = n_InpNeg(a->m,_R);
     2752          a->m = n_InpNeg(a->m,_R->cf);
    27542753          b = b->n = a;
    27552754          b->pos = i;
     
    27612760    {
    27622761      m_act[i] = a->n;
    2763       a->m = n_InpNeg(a->m,_R);
     2762      a->m = n_InpNeg(a->m,_R->cf);
    27642763      b = b->n = a;
    27652764      b->pos = i;
  • omalloc/omAllocDecl.h

    r6c086a4 r750069  
    111111
    112112#if !defined(OM_T_FREE2)
    113 #define omFreeSize(addr,size)   _omDebugFree(addr,(void*)(size),OM_FSIZE|_OM_FKEEP,OM_CFL)
    114 #define omfreeSize(addr,size)   _omDebugFree(addr,(void*)(size),OM_FSIZE|OM_FSLOPPY|_OM_FKEEP,OM_CFL)
     113#define omFreeSize(addr,size)   _omDebugFree(addr,(void*)(long)(size),OM_FSIZE|_OM_FKEEP,OM_CFL)
     114#define omfreeSize(addr,size)   _omDebugFree(addr,(void*)(long)(size),OM_FSIZE|OM_FSLOPPY|_OM_FKEEP,OM_CFL)
    115115#else
    116116#define omFreeSize(addr,size)   __omFreeSize(addr,size)
  • omalloc/omBinPage.c

    r6c086a4 r750069  
    348348{
    349349  unsigned long index_diff = high_index - low_index;
    350   long i;
    351350  omAssume(low_index <= high_index &&
    352351           (high_index > om_MaxBinPageIndex || low_index < om_MinBinPageIndex));
     
    354353  if (om_BinPageIndicies == NULL)
    355354  {
     355    unsigned long i;
    356356    om_BinPageIndicies = (unsigned long*) omAllocFromSystem((index_diff + 1)*SIZEOF_LONG);
    357357    om_Info.InternalUsedBytesMalloc+=(index_diff + 1)*SIZEOF_LONG;
     
    371371    if (low_index < om_MinBinPageIndex)
    372372    {
     373      long i;
    373374      unsigned long offset = new_length - old_length;
    374375      for (i=old_length - 1; i >= 0; i--) om_BinPageIndicies[i+offset] = om_BinPageIndicies[i];
    375       for (i=0; i<offset; i++)  om_BinPageIndicies[i] = 0;
     376      for (i=offset-1; i>=0; i--)  om_BinPageIndicies[i] = 0;
    376377      om_MinBinPageIndex = low_index;
    377378    }
    378379    else
    379380    {
     381      unsigned long i;
    380382      for (i=old_length; i<new_length; i++) om_BinPageIndicies[i] = 0;
    381383      om_MaxBinPageIndex = high_index;
Note: See TracChangeset for help on using the changeset viewer.