Changeset b68048 in git


Ignore:
Timestamp:
Feb 6, 2007, 10:59:01 AM (16 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
dd2855b23f2c258b52bab959b93ada5b684cd584
Parents:
028e0a9e9c0c1038f771ac643351540cd048cd26
Message:
+ noro


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

Legend:

Unmodified
Added
Removed
  • kernel/tgb.cc

    r028e0a rb68048  
    55*  Computer Algebra System SINGULAR     *
    66****************************************/
    7 /* $Id: tgb.cc,v 1.121 2007-01-31 23:21:55 motsak Exp $ */
     7/* $Id: tgb.cc,v 1.122 2007-02-06 09:59:00 bricken Exp $ */
    88/*
    99* ABSTRACT: slimgb and F4 implementation
     
    2626
    2727#include "longrat.h"
     28#include "modulop.h"
     29#include <stdlib.h>
     30#include <stdio.h>
    2831#define SR_HDL(A) ((long)(A))
    2932static const int bundle_size=1000;
     
    18191822  return TRUE;
    18201823}
    1821 
    1822 
     1824static int terms_sort_crit(const void* a, const void* b){
     1825  return -pLmCmp(*((poly*) a),*((poly*) b));
     1826}
     1827static void unify_terms(poly* terms,int & sum){
     1828  if (sum==0) return;
     1829  int last=0;
     1830  int curr=1;
     1831  while(curr<sum){
     1832    if (!(pLmEqual(terms[curr],terms[last]))){
     1833      terms[++last]=terms[curr];
     1834    }
     1835    ++curr;
     1836  }
     1837  sum=last+1;
     1838}
     1839static void export_mat(number* number_array,int pn, int tn,const char* format_str, int mat_nr){
     1840  char matname[20];
     1841  sprintf(matname,format_str,mat_nr);
     1842  FILE* out=fopen(matname,"w");
     1843  int i,j;
     1844  fprintf(out,"mat=[\n");
     1845  for(i=0;i<pn;i++){
     1846    fprintf(out,"[\n");
     1847    for(j=0;j<tn;j++){
     1848      if (j>0){
     1849        fprintf(out,", ");
     1850      }
     1851      fprintf(out,"%i",npInt(number_array[i*tn+j]));
     1852     
     1853    }
     1854    if (i<pn-1)
     1855      fprintf(out,"],\n");
     1856    else
     1857      fprintf(out,"],\n");
     1858  }
     1859  fprintf(out,"]\n");
     1860  fclose(out);
     1861}
     1862int modP_lastIndexRow(number* row,int ncols){
     1863  int lastIndex;
     1864  for(lastIndex=ncols-1;lastIndex>=0;lastIndex--){
     1865    if (!(npIsZero(row[lastIndex]))){
     1866      return lastIndex;
     1867    }
     1868  }
     1869  return -1;
     1870}
     1871class ModPMatrixProxyOnArray{
     1872public:
     1873  friend class ModPMatrixBackSubstProxOnArray;
     1874  int ncols,nrows;
     1875  ModPMatrixProxyOnArray(number* array, int nrows, int ncols){
     1876    this->ncols=ncols;
     1877    this->nrows=nrows;
     1878    rows=(number**) omalloc(nrows*sizeof(number*));
     1879    startIndices=(int*)omalloc(nrows*sizeof(int));
     1880    int i;
     1881    for(i=0;i<nrows;i++){
     1882      rows[i]=array+(i*ncols);
     1883      updateStartIndex(i,-1);
     1884    }
     1885  }
     1886  ~ModPMatrixProxyOnArray(){
     1887    omfree(rows);
     1888    omfree(startIndices);
     1889  }
     1890 
     1891  void permRows(int i, int j){
     1892    number* h=rows[i];
     1893    rows[i]=rows[j];
     1894    rows[j]=h;
     1895    int hs=startIndices[i];
     1896    startIndices[i]=startIndices[j];
     1897    startIndices[j]=hs;
     1898  }
     1899  void multiplyRow(int row, number coef){
     1900    int i;
     1901    number* row_array=rows[row];
     1902    for(i=startIndices[row];i<ncols;i++){
     1903      row_array[i]=npMult(row_array[i],coef);
     1904    }
     1905  }
     1906  void reduceOtherRowsForward(int r){
     1907   
     1908    //assume rows "under r" have bigger or equal start index
     1909    number* row_array=rows[r];
     1910 
     1911    int start=startIndices[r];
     1912    number coef=row_array[start];
     1913    assume(start<ncols);
     1914    int other_row;
     1915    assume(!(npIsZero(row_array[start])));
     1916    if (!(npIsOne(coef)))
     1917      multiplyRow(r,npInvers(coef));
     1918    int lastIndex=modP_lastIndexRow(row_array, ncols);
     1919    for (other_row=r+1;other_row<nrows;other_row++){
     1920      assume(startIndices[other_row]>=start);
     1921      if (startIndices[other_row]==start){
     1922        int i;
     1923        number* other_row_array=rows[other_row];
     1924        number coef2=npNeg(other_row_array[start]);
     1925        for(i=start;i<=lastIndex;i++){
     1926          other_row_array[i]=npAdd(npMult(coef2,row_array[i]),other_row_array[i]);
     1927        }
     1928        updateStartIndex(other_row,start);
     1929        assume(npIsZero(other_row_array[start]));
     1930      }
     1931    }
     1932  }
     1933  void updateStartIndex(int row,int lower_bound){
     1934    number* row_array=rows[row];
     1935    assume((lower_bound<0)||(npIsZero(row_array[lower_bound])));
     1936    int i;
     1937    for(i=lower_bound+1;i<ncols;i++){
     1938      if (!(npIsZero(row_array[i])))
     1939        break;
     1940    }
     1941    startIndices[row]=i;
     1942  }
     1943  int getStartIndex(int row){
     1944    return startIndices[row];
     1945  }
     1946  BOOLEAN findPivot(int &r, int &c){
     1947    //row>=r, col>=c
     1948   
     1949    while(c<ncols){
     1950      int i;
     1951      for(i=r;i<nrows;i++){
     1952        assume(startIndices[i]>=c);
     1953        if (startIndices[i]==c){
     1954          //r=i;
     1955          if (r!=i)
     1956            permRows(r,i);
     1957          return TRUE;
     1958        }
     1959      }
     1960      c++;
     1961    }
     1962    return FALSE;
     1963  }
     1964protected:
     1965  number** rows;
     1966  int* startIndices;
     1967};
     1968class ModPMatrixBackSubstProxOnArray{
     1969  int *startIndices;
     1970  number** rows;
     1971  int *lastReducibleIndices;
     1972  int ncols;
     1973  int nrows;
     1974  int nonZeroUntil;
     1975public:
     1976  void multiplyRow(int row, number coef){
     1977    int i;
     1978    number* row_array=rows[row];
     1979    for(i=startIndices[row];i<ncols;i++){
     1980      row_array[i]=npMult(row_array[i],coef);
     1981    }
     1982  }
     1983  ModPMatrixBackSubstProxOnArray(ModPMatrixProxyOnArray& p){
     1984//  (number* array, int nrows, int ncols, int* startIndices, number** rows){
     1985    //we borrow some parameters ;-)
     1986    //we assume, that nobody changes the order of the rows
     1987    this->startIndices=p.startIndices;
     1988    this->rows=p.rows;
     1989    this->ncols=p.ncols;
     1990    this->nrows=p.nrows;
     1991    lastReducibleIndices=(int*) omalloc(nrows*sizeof(int));
     1992    nonZeroUntil=0;
     1993    while(nonZeroUntil<nrows){
     1994      if (startIndices[nonZeroUntil]<ncols){
     1995       
     1996        nonZeroUntil++;
     1997      } else break;
     1998     
     1999    }
     2000    if (TEST_OPT_PROT)
     2001      Print("rank:%i\n",nonZeroUntil);
     2002    nonZeroUntil--;
     2003    int i;
     2004    for(i=0;i<=nonZeroUntil;i++){
     2005      assume(startIndices[i]<ncols);
     2006      assume(!(npIsZero(rows[i][startIndices[i]])));
     2007      assume(startIndices[i]>=i);
     2008      updateLastReducibleIndex(i,nonZeroUntil+1);
     2009    }
     2010  }
     2011  void updateLastReducibleIndex(int r, int upper_bound){
     2012    number* row_array=rows[r];
     2013    if (upper_bound>nonZeroUntil) upper_bound=nonZeroUntil+1;
     2014    int i;
     2015    for(i=upper_bound-1;i>r;i--){
     2016      int start=startIndices[i];
     2017      assume(start<ncols);
     2018      if (!(npIsZero(row_array[start]))){
     2019        lastReducibleIndices[r]=start;
     2020        return;
     2021      }
     2022    }
     2023    lastReducibleIndices[r]=-1;
     2024  }
     2025  void backwardSubstitute(int r){
     2026    int start=startIndices[r];
     2027    assume(start<ncols);
     2028   
     2029    number* row_array=rows[r];
     2030    assume((!(npIsZero(row_array[start]))));
     2031    assume(start<ncols);
     2032    int other_row;
     2033    if (!(nIsOne(row_array[r]))){
     2034      //it should be one, but this safety is not expensive
     2035      multiplyRow(r, npInvers(row_array[start]));
     2036    }
     2037    int lastIndex=modP_lastIndexRow(row_array, ncols);
     2038    assume(lastIndex<ncols);
     2039    assume(lastIndex>=0);
     2040    for(other_row=r-1;other_row>=0;other_row--){
     2041      assume(lastReducibleIndices[other_row]<=start);
     2042      if (lastReducibleIndices[other_row]==start){
     2043        number* other_row_array=rows[other_row];
     2044        number coef=npNeg(other_row_array[start]);
     2045        assume(!(npIsZero(coef)));
     2046        int i;
     2047        assume(start>startIndices[other_row]);
     2048        for(i=start;i<=lastIndex;i++){
     2049          other_row_array[i]=npAdd(npMult(coef,row_array[i]),other_row_array[i]);
     2050        }
     2051        updateLastReducibleIndex(other_row,r);
     2052      }
     2053    }
     2054  }
     2055  ~ModPMatrixBackSubstProxOnArray(){
     2056    omfree(lastReducibleIndices);
     2057  }
     2058  void backwardSubstitute(){
     2059    int i;
     2060    for(i=nonZeroUntil;i>0;i--){
     2061      backwardSubstitute(i);
     2062    }
     2063  }
     2064};
     2065static void simplest_gauss_modp(number* a, int nrows,int ncols){
     2066  //use memmoves for changing rows
     2067  if (TEST_OPT_PROT)
     2068    PrintS("StartGauss\n");
     2069  ModPMatrixProxyOnArray mat(a,nrows,ncols);
     2070 
     2071  int c=0;
     2072  int r=0;
     2073  while(mat.findPivot(r,c)){
     2074    //int pivot=find_pivot()
     2075      mat.reduceOtherRowsForward(r);
     2076    r++;
     2077    c++;
     2078  }
     2079  ModPMatrixBackSubstProxOnArray backmat(mat);
     2080  backmat.backwardSubstitute();
     2081  //backward substitutions
     2082  if (TEST_OPT_PROT)
     2083    PrintS("StopGauss\n");
     2084}
     2085static void linalg_step_modp(poly *p, poly* p_out, int&pn, poly* terms,int tn, slimgb_alg* c){
     2086  static int export_n=0;
     2087  assume(terms[tn-1]!=NULL);
     2088  assume(rField_is_Zp(c->r));
     2089  //I don't do deletes, copies of numbers ...
     2090  number zero=npInit(0);
     2091  int array_size=pn*tn;
     2092  number* number_array=(number*) omalloc(pn*tn*sizeof(number));
     2093  int i;
     2094  for(i=0;i<array_size;i++){
     2095    number_array[i]=zero;
     2096  }
     2097  for(i=0;i<pn;i++){
     2098    poly h=p[i];
     2099    int base=tn*i;
     2100    while(h!=NULL){
     2101      //Print("h:%i\n",h);
     2102      number coef=p_GetCoeff(h,c->r);
     2103      poly* ptr_to_h=(poly*) bsearch(&h,terms,tn,sizeof(poly),terms_sort_crit);
     2104      assume(ptr_to_h!=NULL);
     2105      int pos=ptr_to_h-terms;
     2106      number_array[base+pos]=coef;
     2107      pIter(h);
     2108    }
     2109    p_Delete(&h,c->r);
     2110  }
     2111#if 0
     2112  //export matrix
     2113  export_mat(number_array,pn,tn,"mat%i.py",++export_n);
     2114#endif
     2115  int rank=pn;
     2116  simplest_gauss_modp(number_array,rank,tn);
     2117  int act_row=0;
     2118  int p_pos=0;
     2119  for(i=0;i<pn;i++){
     2120    poly h=NULL;
     2121    int j;
     2122    int base=tn*i;
     2123    number* row=number_array+base;
     2124    for(j=tn-1;j>=0;j--){
     2125      if (!(npIsZero(row[j]))){
     2126        poly t=terms[j];
     2127        t=p_LmInit(t,c->r);
     2128        p_SetCoeff(t,row[j],c->r);
     2129        pNext(t)=h;
     2130        h=t;
     2131      }
     2132     
     2133    }
     2134   if (h!=NULL){
     2135     p_out[p_pos++]=h;
     2136   }
     2137  }
     2138  pn=p_pos;
     2139  //assert(p_pos==rank)
     2140  while(p_pos<pn){
     2141    p_out[p_pos++]=NULL;
     2142  }
     2143#if 0
     2144  export_mat(number_array,pn,tn,"mat%i.py",++export_n);
     2145#endif
     2146}
     2147static void mass_add(poly* p, int pn,slimgb_alg* c){
     2148    int j;
     2149    int* ibuf=(int*) omalloc(pn*sizeof(int));
     2150    sorted_pair_node*** sbuf=(sorted_pair_node***) omalloc(pn*sizeof(sorted_pair_node**));
     2151    for(j=0;j<pn;j++){
     2152      sbuf[j]=add_to_basis_ideal_quotient(p[j],c,ibuf+j);
     2153    }
     2154    int sum=0;
     2155    for(j=0;j<pn;j++){
     2156      sum+=ibuf[j];
     2157    }
     2158    sorted_pair_node** big_sbuf=(sorted_pair_node**) omalloc(sum*sizeof(sorted_pair_node*));
     2159    int partsum=0;
     2160    for(j=0;j<pn;j++)
     2161    {
     2162      memmove(big_sbuf+partsum, sbuf[j],ibuf[j]*sizeof(sorted_pair_node*));
     2163      omfree(sbuf[j]);
     2164      partsum+=ibuf[j];
     2165    }
     2166
     2167    qsort(big_sbuf,sum,sizeof(sorted_pair_node*),tgb_pair_better_gen2);
     2168    c->apairs=spn_merge(c->apairs,c->pair_top+1,big_sbuf,sum,c);
     2169    c->pair_top+=sum;
     2170    clean_top_of_pair_list(c);
     2171    omfree(big_sbuf);
     2172    omfree(sbuf);
     2173    omfree(ibuf);
     2174    //omfree(buf);
     2175  #ifdef TGB_DEBUG
     2176    int z;
     2177    for(z=1;z<=c->pair_top;z++)
     2178    {
     2179      assume(pair_better(c->apairs[z],c->apairs[z-1],c));
     2180    }
     2181  #endif
     2182   
     2183}
     2184static void noro_step(poly*p,int &pn,slimgb_alg* c){
     2185  poly* reduced=(poly*) omalloc(pn*sizeof(poly));
     2186  int j;
     2187  int* reduced_len=(int*) omalloc(pn*sizeof(int));
     2188  int reduced_c=0;
     2189  if (TEST_OPT_PROT)
     2190    PrintS("reduced system:\n");
     2191  for(j=0;j<pn;j++){
     2192   
     2193    poly h=p[j];
     2194    int h_len=pLength(h);
     2195    number coef;
     2196    h=redNF2(p_Copy(h,c->r),c,h_len,coef,0);
     2197    if (h!=NULL){
     2198      h=redNFTail(h,c->strat->sl,c->strat,h_len);
     2199      h_len=pLength(h);
     2200      reduced[reduced_c]=h;
     2201      reduced_len[reduced_c]=h_len;
     2202      reduced_c++;
     2203      if (TEST_OPT_PROT)
     2204        Print("%d ",h_len);
     2205    }
     2206  }
     2207  int reduced_sum=0;
     2208  for(j=0;j<reduced_c;j++){
     2209    reduced_sum+=reduced_len[j];
     2210  }
     2211  poly* terms=(poly*) omalloc(reduced_sum*sizeof(poly));
     2212  int tc=0;
     2213  for(j=0;j<reduced_c;j++){
     2214    poly h=reduced[j];
     2215   
     2216    while(h!=NULL){
     2217      terms[tc++]=h;
     2218      pIter(h);
     2219      assume(tc<=reduced_sum);
     2220    }
     2221  }
     2222  assume(tc==reduced_sum);
     2223  qsort(terms,reduced_sum,sizeof(poly),terms_sort_crit);
     2224  int nterms=reduced_sum;
     2225  if (TEST_OPT_PROT)
     2226    Print("orig estimation:%i\n",reduced_sum);
     2227  unify_terms(terms,nterms);
     2228  if (TEST_OPT_PROT)
     2229    Print("actual number of columns:%i\n",nterms);
     2230  int rank=reduced_c;
     2231  linalg_step_modp(reduced, p,rank,terms,nterms,c);
     2232  omfree(terms);
     2233 
     2234  pn=rank;
     2235  omfree(reduced);
     2236  if (TEST_OPT_PROT)
     2237    PrintS("\n");
     2238}
    18232239
    18242240static void go_on (slimgb_alg* c){
    18252241  //set limit of 1000 for multireductions, at the moment for
    18262242  //programming reasons
     2243  #ifdef USE_NORO
     2244  const BOOLEAN use_noro=((!(c->nc))&&(rField_is_Zp(c->r)));
     2245  #else
     2246  const BOOLEAN use_noro=FALSE;
     2247  #endif
    18272248  int i=0;
    18282249  c->average_length=0;
     
    18772298    number coef;
    18782299    int mlen=pLength(h);
    1879     if (!c->nc){
     2300    if ((!c->nc)&(!(use_noro))){
    18802301      h=redNF2(h,c,mlen,coef,2);
    18812302      redTailShort(h,c->strat);
     
    19022323  c->normal_forms+=i;
    19032324  int j;
     2325#if 1
     2326  //if ((!(c->nc))&&(rField_is_Zp(c->r))){
     2327  if (use_noro){
     2328    int pn=i;
     2329    noro_step(p,pn,c);
     2330    if (TEST_OPT_PROT){
     2331      Print("reported rank:%i\n",pn);
     2332    }
     2333    mass_add(p,pn,c);
     2334    return;
     2335    /*if (TEST_OPT_PROT)
     2336      for(j=0;j<pn;j++){
     2337        p_wrp(p[j],c->r);
     2338      }*/
     2339  }
     2340#endif
    19042341  for(j=0;j<i;j++){
    19052342    buf[j].p=p[j];
     
    19212358    Print("%dM[%d,",curr_deg,i);
    19222359  }
    1923 #ifdef FIND_DETERMINISTIC
    1924   c->modifiedS=(BOOLEAN*) omalloc((c->strat->sl+1)*sizeof(BOOLEAN));
    1925   c->expandS=(poly*) omalloc((1)*sizeof(poly));
    1926   c->expandS[0]=NULL;
    1927   int z2;
    1928   for(z2=0;z2<=c->strat->sl;z2++)
    1929     c->modifiedS[z2]=FALSE;
    1930 #endif
     2360
    19312361  multi_reduction(buf, i, c);
    19322362  #ifdef TGB_RESORT_PAIRS
     
    19622392#endif
    19632393  //resort S
    1964 #ifdef FIND_DETERMINISTIC
    1965   for(z2=0;z2<=c->strat->sl;z2++)
    1966   {
    1967     if (c->modifiedS[z2])
    1968     {
    1969       wlen_type qual;
    1970       int new_pos;
    1971       if (c->strat->lenSw!=NULL)
    1972           new_pos=simple_posInS(c->strat,c->strat->S[z2],strat->lenS[z2],strat->Sw[z2]);
    1973       else
    1974           new_pos=simple_posInS(c->strat,c->strat->S[z2],strat->lenS[z2],lenS[z2]);
    1975 
    1976       if (new_pos<z2)
    1977       {
    1978          move_forward_in_S(z2,new_pos,c->strat);
    1979       }
    1980 
    1981       assume(new_pos<=z2);
    1982     }
    1983   }
    1984   for(z2=0;c->expandS[z2]!=NULL;z2++)
    1985   {
    1986     add_to_reductors(c,c->expandS[z2],pLength(c->expandS[z2]));
    1987     // PrintS("E");
    1988   }
    1989   omfree(c->modifiedS);
    1990   c->modifiedS=NULL;
    1991   omfree(c->expandS);
    1992   c->expandS=NULL;
    1993 #endif
     2394
    19942395  if (TEST_OPT_PROT)
    19952396      Print("%i]",i);
    19962397
    1997   int* ibuf=(int*) omalloc(i*sizeof(int));
    1998   sorted_pair_node*** sbuf=(sorted_pair_node***) omalloc(i*sizeof(sorted_pair_node**));
     2398  poly* add_those=(poly*) omalloc(i*sizeof(poly));
    19992399  for(j=0;j<i;j++)
    20002400  {
     
    20122412      }
    20132413      //}
    2014     sbuf[j]=add_to_basis_ideal_quotient(p,c,ibuf+j);
     2414      add_those[j]=p;
     2415
    20152416    //sbuf[j]=add_to_basis(p,-1,-1,c,ibuf+j);
    20162417  }
    2017   int sum=0;
    2018   for(j=0;j<i;j++){
    2019     sum+=ibuf[j];
    2020   }
    2021   sorted_pair_node** big_sbuf=(sorted_pair_node**) omalloc(sum*sizeof(sorted_pair_node*));
    2022   int partsum=0;
    2023   for(j=0;j<i;j++)
    2024   {
    2025     memmove(big_sbuf+partsum, sbuf[j],ibuf[j]*sizeof(sorted_pair_node*));
    2026     omfree(sbuf[j]);
    2027     partsum+=ibuf[j];
    2028   }
    2029 
    2030   qsort(big_sbuf,sum,sizeof(sorted_pair_node*),tgb_pair_better_gen2);
    2031   c->apairs=spn_merge(c->apairs,c->pair_top+1,big_sbuf,sum,c);
    2032   c->pair_top+=sum;
    2033   clean_top_of_pair_list(c);
    2034   omfree(big_sbuf);
    2035   omfree(sbuf);
    2036   omfree(ibuf);
     2418  mass_add(add_those,i,c);
     2419  omfree(add_those);
    20372420  omfree(buf);
    2038 #ifdef TGB_DEBUG
    2039   int z;
    2040   for(z=1;z<=c->pair_top;z++)
    2041   {
    2042     assume(pair_better(c->apairs[z],c->apairs[z-1],c));
    2043   }
    2044 #endif
     2421 
     2422 
     2423 
     2424 
     2425 
     2426 
     2427
    20452428  if (TEST_OPT_PROT)
    20462429      Print("(%d)",c->pair_top+1);
    2047   while(!(idIs0(c->add_later))){
    2048     ideal add=c->add_later;
    2049     idSkipZeroes(add);
    2050     for(j=0;j<add->idelems();j++){
    2051         assume(pLength(add->m[j])==1);
    2052         p_SetCoeff(add->m[j],n_Init(1,currRing),currRing);
    2053 
    2054     }
    2055     ideal add2=kInterRed(add,NULL);
    2056     id_Delete(&add,currRing);
    2057     idSkipZeroes(add2);
    2058     c->add_later=idInit(ADD_LATER_SIZE,c->S->rank);
    2059     memset(c->add_later->m,0,ADD_LATER_SIZE*sizeof(poly));
    2060 //     for(i=0;i<add2->idelems();i++){
    2061 //       if (add2->m[i]!=NULL)
    2062 //           add_to_basis_ideal_quotient(add2->m[i],-1,-1,c,NULL);
    2063 //       add2->m[i]=NULL;
    2064 //     }
    2065     int i=add2->idelems();
    2066     int* ibuf=(int*) omalloc(i*sizeof(int));
    2067   sorted_pair_node*** sbuf=(sorted_pair_node***) omalloc(i*sizeof(sorted_pair_node**));
    2068 
    2069   for(j=0;j<i;j++)
    2070   {
    2071     int len;
    2072     poly p;
    2073     //buf[j].flatten();
    2074     //kBucketClear(buf[j].bucket,&p, &len);
    2075     //kBucketDestroy(&buf[j].bucket);
    2076     p=add2->m[j];
    2077     add2->m[j]=NULL;
    2078 
    2079     sbuf[j]=add_to_basis_ideal_quotient(p,c,ibuf+j);
    2080     //sbuf[j]=add_to_basis(p,-1,-1,c,ibuf+j);
    2081   }
    2082   int sum=0;
    2083   for(j=0;j<i;j++){
    2084     sum+=ibuf[j];
    2085   }
    2086   sorted_pair_node** big_sbuf=(sorted_pair_node**) omalloc(sum*sizeof(sorted_pair_node*));
    2087   int partsum=0;
    2088   for(j=0;j<i;j++)
    2089   {
    2090     memmove(big_sbuf+partsum, sbuf[j],ibuf[j]*sizeof(sorted_pair_node*));
    2091     omfree(sbuf[j]);
    2092     partsum+=ibuf[j];
    2093   }
    2094 
    2095   qsort(big_sbuf,sum,sizeof(sorted_pair_node*),tgb_pair_better_gen2);
    2096   c->apairs=spn_merge(c->apairs,c->pair_top+1,big_sbuf,sum,c);
    2097   c->pair_top+=sum;
    2098   clean_top_of_pair_list(c);
    2099   omfree(big_sbuf);
    2100   omfree(sbuf);
    2101   omfree(ibuf);
    2102   //omfree(buf);
    2103     id_Delete(&add2, c->r);
    2104   }
     2430  //TODO: implement that while(!(idIs0(c->add_later)))
    21052431  #ifdef TGB_RESORT_PAIRS
    21062432  delete c->replaced;
     
    23032629}
    23042630slimgb_alg::slimgb_alg(ideal I, int syz_comp,BOOLEAN F4){
     2631
    23052632  lastCleanedDeg=-1;
    23062633  completed=FALSE;
  • kernel/tgb_internal.h

    r028e0a rb68048  
    55*  Computer Algebra System SINGULAR     *
    66****************************************/
    7 /* $Id: tgb_internal.h,v 1.48 2007-01-31 15:22:22 bricken Exp $ */
     7/* $Id: tgb_internal.h,v 1.49 2007-02-06 09:59:01 bricken Exp $ */
    88/*
    99 * ABSTRACT: tgb internal .h file
     
    1818#include "polys.h"
    1919#include "stdlib.h"
     20//#define USE_NORO 1
    2021#ifdef HAVE_BOOST_DYNAMIC_BITSET_HPP
    2122#define  HAVE_BOOST 1
Note: See TracChangeset for help on using the changeset viewer.