Changeset 9922fa7 in git


Ignore:
Timestamp:
Apr 30, 2018, 4:37:20 PM (6 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
9ae5a3bbc24553f5fdd77d09f6bd086318329be3
Parents:
35a2fb48e744c3334747118a4c8ac8457f0ba3ec
Message:
fix: format + handling very large matrices in slimgb (>2GB)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/tgb_internal.h

    r35a2fb4 r9922fa7  
    129129  int len;
    130130  BOOLEAN onlyBorrowed;
    131   bool operator<(const MonRedRes& other) const{
     131  bool operator<(const MonRedRes& other) const
     132  {
    132133    int cmp=p_LmCmp(p,other.p,currRing);
    133     if ((cmp<0)||((cmp==0)&&((onlyBorrowed)&&(!(other.onlyBorrowed))))){
     134    if ((cmp<0)||((cmp==0)&&((onlyBorrowed)&&(!(other.onlyBorrowed)))))
     135    {
    134136      return true;
    135137    } else return false;
    136138  }
    137139  DataNoroCacheNode* ref;
    138   MonRedRes(){
     140  MonRedRes()
     141  {
    139142    ref=NULL;
    140143    p=NULL;
     
    832835*/
    833836
    834 template<class number_type> SparseRow<number_type>* convert_to_sparse_row(number_type* temp_array,int temp_size,int non_zeros){
     837template<class number_type> SparseRow<number_type>* convert_to_sparse_row(number_type* temp_array,int temp_size,int non_zeros)
     838{
    835839SparseRow<number_type>* res=new SparseRow<number_type>(non_zeros);
    836840//int pos=0;
     
    839843int* it_idx=res->idx_array;
    840844#if 0
    841 for(i=0;i<cache->nIrreducibleMonomials;i++){
    842   if (!(0==temp_array[i])){
     845for(i=0;i<cache->nIrreducibleMonomials;i++)
     846{
     847  if (!(0==temp_array[i]))
     848  {
    843849
    844850    res->idx_array[pos]=i;
     
    10631069          #ifndef SING_NDEBUG
    10641070          assume(idx<temp_size);
    1065           #endif
     1071          #endif
    10661072        }
    10671073}
     
    11571163   for(i=0;i<cache->nIrreducibleMonomials;i++)
    11581164   {
    1159      //if (!(temp_array[i]==0)){
     1165     //if (!(temp_array[i]==0))
     1166     //{
    11601167     //  non_zeros++;
    11611168     //}
     
    14031410  return res;
    14041411}
    1405 template<class number_type> SparseRow<number_type> * noro_red_to_non_poly_t(poly p, int &len, NoroCache<number_type>* cache,slimgb_alg* c){
     1412template<class number_type> SparseRow<number_type> * noro_red_to_non_poly_t(poly p, int &len, NoroCache<number_type>* cache,slimgb_alg* c)
     1413{
    14061414  assume(len==pLength(p));
    14071415  if (p==NULL)
     
    14591467
    14601468
    1461 template <class number_type > void write_poly_to_row(number_type* row, poly h, poly*terms, int tn, ring r){
     1469template <class number_type > void write_poly_to_row(number_type* row, poly h, poly*terms, int tn, ring r)
     1470{
    14621471  //poly* base=row;
    1463   while(h!=NULL){
     1472  while(h!=NULL)
     1473  {
    14641474    //Print("h:%i\n",h);
    14651475    number coef=p_GetCoeff(h,r);
     
    14721482  }
    14731483}
    1474 template <class number_type > poly row_to_poly(number_type* row, poly* terms, int tn, ring r){
     1484template <class number_type > poly row_to_poly(number_type* row, poly* terms, int tn, ring r)
     1485{
    14751486  poly h=NULL;
    14761487  int j;
    14771488  number_type zero=0;//;npInit(0);
    1478   for(j=tn-1;j>=0;j--){
    1479     if (!(zero==(row[j]))){
     1489  for(j=tn-1;j>=0;j--)
     1490  {
     1491    if (!(zero==(row[j])))
     1492    {
    14801493      poly t=terms[j];
    14811494      t=p_LmInit(t,r);
     
    15171530    this->ncols=nncols;
    15181531    this->nrows=nnrows;
    1519     rows=(number_type**) omalloc(nnrows*sizeof(number_type*));
    1520     startIndices=(int*)omalloc(nnrows*sizeof(int));
     1532    rows=(number_type**) omalloc((size_t)nnrows*sizeof(number_type*));
     1533    startIndices=(int*)omalloc((size_t)nnrows*sizeof(int));
    15211534    int i;
    15221535    for(i=0;i<nnrows;i++)
    15231536    {
    1524       rows[i]=array+(i*nncols);
     1537      rows[i]=array+((long)i*(long)nncols);
    15251538      updateStartIndex(i,-1);
    15261539    }
     
    17721785  int c=0;
    17731786  int r=0;
    1774   while(mat.findPivot(r,c)){
     1787  while(mat.findPivot(r,c))
     1788  {
    17751789    //int pivot=find_pivot()
    17761790      mat.reduceOtherRowsForward(r);
     
    17851799}
    17861800//int term_nodes_sort_crit(const void* a, const void* b);
    1787 template <class number_type> void noro_step(poly*p,int &pn,slimgb_alg* c){
     1801template <class number_type> void noro_step(poly*p,int &pn,slimgb_alg* c)
     1802{
    17881803  //Print("Input rows %d\n",pn);
    17891804  int j;
     
    18411856  //  Print("Evaluate Rows \n");
    18421857  pn=non_zeros;
    1843   number_type* number_array=(number_type*) omalloc0(n*pn*sizeof(number_type));
     1858  number_type* number_array=(number_type*) omalloc0(((size_t)n)*pn*sizeof(number_type));
    18441859
    18451860  for(j=0;j<pn;j++)
    18461861  {
    18471862    int i;
    1848     number_type* row=number_array+n*j;
     1863    number_type* row=number_array+((long)n)*(long)j;
    18491864    /*for(i=0;i<n;i++)
    18501865    {
     
    18831898
    18841899  int p_pos=0;
    1885   for(j=0;j<pn;j++){
    1886     poly h=row_to_poly(number_array+j*n,terms,n,c->r);
    1887     if(h!=NULL){
     1900  for(j=0;j<pn;j++)
     1901  {
     1902    poly h=row_to_poly(number_array+((long)j)*((long)n),terms,n,c->r);
     1903    if(h!=NULL)
     1904    {
    18881905      p[p_pos++]=h;
    18891906    }
     
    19011918}
    19021919
    1903 template <class number_type> void NoroCache<number_type>::collectIrreducibleMonomials( std::vector<DataNoroCacheNode<number_type> *>& res){
     1920template <class number_type> void NoroCache<number_type>::collectIrreducibleMonomials( std::vector<DataNoroCacheNode<number_type> *>& res)
     1921{
    19041922  int i;
    1905   for(i=0;i<root.branches_len;i++){
     1923  for(i=0;i<root.branches_len;i++)
     1924  {
    19061925    collectIrreducibleMonomials(1,root.branches[i],res);
    19071926  }
    19081927}
    1909 template <class number_type> void NoroCache<number_type>::collectIrreducibleMonomials(int level, NoroCacheNode* node, std::vector<DataNoroCacheNode<number_type>*>& res){
     1928template <class number_type> void NoroCache<number_type>::collectIrreducibleMonomials(int level, NoroCacheNode* node, std::vector<DataNoroCacheNode<number_type>*>& res)
     1929{
    19101930  assume(level>=0);
    19111931  if (node==NULL) return;
     
    19281948}
    19291949
    1930 template<class number_type> DataNoroCacheNode<number_type>* NoroCache<number_type>::getCacheReference(poly term){
     1950template<class number_type> DataNoroCacheNode<number_type>* NoroCache<number_type>::getCacheReference(poly term)
     1951{
    19311952  int i;
    19321953  NoroCacheNode* parent=&root;
    1933   for(i=1;i<(currRing->N);i++){
     1954  for(i=1;i<(currRing->N);i++)
     1955  {
    19341956    parent=parent->getBranch(p_GetExp(term,i,currRing));
    1935     if (!(parent)){
     1957    if (!(parent))
     1958    {
    19361959      return NULL;
    19371960    }
     
    19401963  return res_holder;
    19411964}
    1942 template<class number_type> poly NoroCache<number_type>::lookup(poly term, BOOLEAN& succ, int & len){
     1965template<class number_type> poly NoroCache<number_type>::lookup(poly term, BOOLEAN& succ, int & len)
     1966{
    19431967  int i;
    19441968  NoroCacheNode* parent=&root;
    1945   for(i=1;i<(currRing->N);i++){
     1969  for(i=1;i<(currRing->N);i++)
     1970  {
    19461971    parent=parent->getBranch(p_GetExp(term,i,currRing));
    1947     if (!(parent)){
     1972    if (!(parent))
     1973    {
    19481974      succ=FALSE;
    19491975      return NULL;
     
    19511977  }
    19521978  DataNoroCacheNode<number_type>* res_holder=(DataNoroCacheNode<number_type>*) parent->getBranch(p_GetExp(term,i,currRing));
    1953   if (res_holder){
     1979  if (res_holder)
     1980  {
    19541981    succ=TRUE;
    1955     if ( /*(*/ res_holder->value_len==backLinkCode /*)*/ ){
     1982    if ( /*(*/ res_holder->value_len==backLinkCode /*)*/ )
     1983    {
    19561984      len=1;
    19571985      return term;
Note: See TracChangeset for help on using the changeset viewer.