Changeset d7cb52 in git


Ignore:
Timestamp:
Feb 25, 2007, 7:09:43 AM (16 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '23b0a9c07070b684aa12355009488dc00d9501e3')
Children:
74802b0c748389d7b2662b157bcd57bbbe13eb0d
Parents:
101775c32e4f8f7cd743c23b9822bc53abca1792
Message:
*bricken: more structured noro red


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

Legend:

Unmodified
Added
Removed
  • kernel/tgb_internal.h

    r101775 rd7cb52  
    55*  Computer Algebra System SINGULAR     *
    66****************************************/
    7 /* $Id: tgb_internal.h,v 1.61 2007-02-23 13:30:35 bricken Exp $ */
     7/* $Id: tgb_internal.h,v 1.62 2007-02-25 06:09:43 bricken Exp $ */
    88/*
    99 * ABSTRACT: tgb internal .h file
     
    2020#include <modulop.h>
    2121//#define USE_NORO 1
     22
     23
    2224#ifdef USE_NORO
    2325#define NORO_CACHE 1
     
    750752}
    751753*/
     754#ifdef __GNUC__
     755#define LIKELY(expression) (__builtin_expect(!!(expression), 1))
     756#define UNLIKELY(expression) (__builtin_expect(!!(expression), 0))
     757#else
     758#define LIKELY(expression) (expression)
     759#define UNLIKELY(expression) (expression)
     760#endif
     761
     762template<class number_type> SparseRow<number_type>* convert_to_sparse_row(number_type* temp_array,int temp_size,int non_zeros){
     763SparseRow<number_type>* res=new SparseRow<number_type>(non_zeros);
     764int pos=0;
     765#if 0
     766for(i=0;i<cache->nIrreducibleMonomials;i++){
     767  if (!(0==temp_array[i])){
     768 
     769    res->idx_array[pos]=i;
     770    res->coef_array[pos]=temp_array[i];
     771
     772    pos++;
     773    non_zeros--;
     774    if (non_zeros==0) break;
     775  }
     776 
     777}
     778#else
     779int64* start=(int64*) ((void*)temp_array);
     780int64* end;
     781const int multiple=sizeof(int64)/sizeof(number_type);
     782if (temp_size==0) end=start;
     783
     784else
     785{
     786  int temp_size_rounded=temp_size+(multiple-(temp_size%multiple));
     787  assume(temp_size_rounded>=temp_size);
     788  assume(temp_size_rounded%multiple==0);
     789  assume(temp_size_rounded<temp_size+multiple);
     790  number_type* nt_end=temp_array+temp_size_rounded;
     791  end=(int64*)((void*)nt_end);
     792}
     793int64* it=start;
     794while(it!=end){
     795  if UNLIKELY((*it)!=0){
     796    int small_i;
     797    const int temp_index=((number_type*)((void*) it))-temp_array;
     798    const int bound=temp_index+multiple;
     799    for(small_i=temp_index;small_i<bound;small_i++){
     800      if(temp_array[small_i]!=0){
     801        res->idx_array[pos]=small_i;
     802        res->coef_array[pos]=temp_array[small_i];
     803
     804        pos++;
     805        non_zeros--;
     806       
     807      }
     808      if (non_zeros==0) break;
     809    }
     810   
     811  }
     812  ++it;
     813}
     814#endif
     815return res;
     816}
     817
    752818template<class number_type> SparseRow<number_type> * noro_red_to_non_poly_t(poly p, int &len, NoroCache<number_type>* cache,slimgb_alg* c){
    753819  assume(len==pLength(p));
     
    785851  int temp_size=cache->nIrreducibleMonomials;
    786852  memset(temp_array,0,temp_size_bytes);
     853  number minus_one=npInit(-1);
    787854  for(i=0;i<len;i++){
    788855    MonRedResNP<number_type> red=mon[i];
     
    792859        number coef=red.coef;
    793860        int j;
    794         if (!(npIsOne(coef))){
     861        if (!((coef==(number) 1)||(coef==minus_one))){
    795862        for(j=0;j<row->len;j++){
    796863          int idx=row->idx_array[j];
     
    800867          assume(idx<temp_size);
    801868        }}else{
     869          if (coef==(number) 1){
    802870          for(j=0;j<row->len;j++){
    803871            int idx=row->idx_array[j];
     
    805873            assume(idx<temp_size);
    806874          }
     875          } else {
     876            for(j=0;j<row->len;j++){
     877            int idx=row->idx_array[j];
     878            temp_array[idx]=F4mat_to_number_type(   npSubM((number) temp_array[idx],(number) row->coef_array[j]));
     879            assume(idx<temp_size);
     880          }}
    807881        }
    808882      }
     
    829903    return NULL;
    830904  }
    831   SparseRow<number_type>* res=new SparseRow<number_type>(non_zeros);
    832   int pos=0;
    833   #if 0
    834   for(i=0;i<cache->nIrreducibleMonomials;i++){
    835     if (!(0==temp_array[i])){
    836    
    837       res->idx_array[pos]=i;
    838       res->coef_array[pos]=temp_array[i];
    839 
    840       pos++;
    841       non_zeros--;
    842       if (non_zeros==0) break;
    843     }
    844    
    845   }
    846   #else
    847   int64* start=(int64*) ((void*)temp_array);
    848   int64* end;
    849   const int multiple=sizeof(int64)/sizeof(number_type);
    850   if (temp_size==0) end=start;
    851  
    852   else
    853   {
    854     int temp_size_rounded=temp_size+(multiple-(temp_size%multiple));
    855     assume(temp_size_rounded>=temp_size);
    856     assume(temp_size_rounded%multiple==0);
    857     assume(temp_size_rounded<temp_size+multiple);
    858     number_type* nt_end=temp_array+temp_size_rounded;
    859     end=(int64*)((void*)nt_end);
    860   }
    861   int64* it=start;
    862   while(it!=end){
    863     if ((*it)!=0){
    864       int small_i;
    865       const int temp_index=((number_type*)((void*) it))-temp_array;
    866       const int bound=temp_index+multiple;
    867       for(small_i=temp_index;small_i<bound;small_i++){
    868         if(temp_array[small_i]!=0){
    869           res->idx_array[pos]=small_i;
    870           res->coef_array[pos]=temp_array[small_i];
    871 
    872           pos++;
    873           non_zeros--;
    874          
    875         }
    876         if (non_zeros==0) break;
    877       }
    878      
    879     }
    880     ++it;
    881   }
    882   #endif
     905  SparseRow<number_type>* res=convert_to_sparse_row(temp_array,temp_size, non_zeros);
     906
    883907  //omfree(temp_array);
    884908
Note: See TracChangeset for help on using the changeset viewer.