Changeset 89e45b in git for kernel/tgb_internal.h


Ignore:
Timestamp:
Feb 26, 2007, 1:52:45 PM (17 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
08932b1c52841085c67412beca95f77ba46d4014
Parents:
f529246505a5d745330cbb08ffc3f1db543d3ed3
Message:
*bricken: avoid multiplications in sparse


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

Legend:

Unmodified
Added
Removed
  • kernel/tgb_internal.h

    rf52924 r89e45b  
    55*  Computer Algebra System SINGULAR     *
    66****************************************/
    7 /* $Id: tgb_internal.h,v 1.64 2007-02-26 10:57:39 bricken Exp $ */
     7/* $Id: tgb_internal.h,v 1.65 2007-02-26 12:52:45 bricken Exp $ */
    88/*
    99 * ABSTRACT: tgb internal .h file
     
    922922  int idx;
    923923  bool operator<(const CoefIdx<number_type>& other) const{
    924     return idx<other.idx;
    925   }
    926 };
     924    return (idx<other.idx);
     925  }
     926};
     927template<class number_type> void write_coef_times_xx_idx_to_buffer(CoefIdx<number_type>* const pairs,int& pos,int* const idx_array, number_type* const coef_array,const int rlen, const number coef){
     928  int j;
     929  for(j=0;j<rlen;j++){
     930    assume(coef_array[j]!=0);
     931    CoefIdx<number_type> ci;
     932    ci.coef=F4mat_to_number_type(npMultM((number) coef,(number) coef_array[j]));
     933    ci.idx=idx_array[j];
     934    pairs[pos++]=ci;
     935  }
     936}
     937template<class number_type> void write_coef_idx_to_buffer(CoefIdx<number_type>* const pairs,int& pos,int* const idx_array, number_type* const coef_array,const int rlen){
     938  int j;
     939  for(j=0;j<rlen;j++){
     940    assume(coef_array[j]!=0);
     941    CoefIdx<number_type> ci;
     942    ci.coef=coef_array[j];
     943    ci.idx=idx_array[j];
     944    pairs[pos++]=ci;
     945  }
     946}
     947
     948template<class number_type> void write_minus_coef_idx_to_buffer(CoefIdx<number_type>* const pairs,int& pos,int* const idx_array, number_type* const coef_array,const int rlen){
     949  int j;
     950  for(j=0;j<rlen;j++){
     951    assume(coef_array[j]!=0);
     952    CoefIdx<number_type> ci;
     953    ci.coef=F4mat_to_number_type(npNegM(coef_array[j]));
     954    ci.idx=idx_array[j];
     955    pairs[pos++]=ci;
     956  }
     957}
    927958template <class number_type> SparseRow<number_type>* noro_red_to_non_poly_sparse(MonRedResNP<number_type>* mon, int len,NoroCache<number_type>* cache){
    928959  int i;
     
    944975  int pos=0;
    945976  int j;
     977  const number one=npInit(1);
     978  const number minus_one=npInit(-1);
    946979  for(i=0;i<len;i++){
    947980    MonRedResNP<number_type> red=mon[i];
     
    951984      number_type* coef_array=red.ref->row->coef_array;
    952985      int rlen=red.ref->row->len;
    953       for(j=0;j<rlen;j++){
    954         assume(coef_array[j]!=0);
    955         CoefIdx<number_type> ci;
    956         ci.coef=F4mat_to_number_type(npMultM((number) red.coef,(number) coef_array[j]));
    957         ci.idx=idx_array[j];
    958         pairs[pos++]=ci;
     986      number coef=red.coef;
     987      if ((coef!=one)&&(coef!=minus_one)){
     988      write_coef_times_xx_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen, coef);
     989    } else
     990    {
     991      if (coef==one){
     992        write_coef_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen);
     993      } else {
     994        assume(coef==minus_one);
     995        write_minus_coef_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen);
    959996      }
     997    }
    960998    } else {
    961999      if ((red.ref) &&(red.ref->value_len==NoroCache<number_type>::backLinkCode)){
     
    10381076  len=i;
    10391077  bool dense=true;
    1040   if (max_density<0.1) dense=false;
     1078  if (max_density<0.05) dense=false;
    10411079  if (dense){
    10421080    SparseRow<number_type>* res=noro_red_to_non_poly_dense(mon,len,cache);
Note: See TracChangeset for help on using the changeset viewer.