Changeset d14343a in git


Ignore:
Timestamp:
May 9, 2005, 3:47:30 PM (18 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'd1ec153efbb92b07a03c829a7f893fe854f169d2')
Children:
9850430deebdde40b9b692de71cd82543d4f6968
Parents:
b553e559f98a3781f6cfd18ddbcb12a123420c3b
Message:
*hannes: code cleanup


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

Legend:

Unmodified
Added
Removed
  • kernel/int64vec.cc

    rb553e5 rd14343a  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: int64vec.cc,v 1.2 2005-05-09 12:14:57 Singular Exp $ */
     4/* $Id: int64vec.cc,v 1.3 2005-05-09 13:47:29 Singular Exp $ */
    55/*
    66* ABSTRACT: class int64vec: lists/vectors of int64
     
    9696}
    9797
    98 void int64vec::resize(int new_length)
    99 {
    100   assume(new_length > 0 && col == 1);
    101   v = (int64*) omRealloc0Size(v, row*sizeof(int64), new_length*sizeof(int64));
    102   row = new_length;
    103 }
    104 
    10598char * int64vec::String(int dim)
    10699{
     
    116109}
    117110
    118 void int64vec::operator+=(int64 intop)
    119 {
    120   for (int i=0; i<row*col; i++) { v[i] += intop; }
    121 }
    122 
    123 void int64vec::operator-=(int64 intop)
    124 {
    125   for (int i=0; i<row*col; i++) { v[i] -= intop; }
    126 }
    127 
    128111void int64vec::operator*=(int64 intop)
    129112{
    130   for (int i=0; i<row*col; i++) { v[i] *= intop; }
     113  for (int i=row*col-1; i>=0; i--) { v[i] *= intop; }
    131114}
    132115
     
    135118  if (intop == 0) return;
    136119  int64 bb=ABS(intop);
    137   for (int i=0; i<row*col; i++)
     120  for (int i=row*col-1; i>=0; i--)
    138121  {
    139122    int64 r=v[i];
     
    145128}
    146129
    147 void int64vec::operator%=(int64 intop)
    148 {
    149   if (intop == 0) return;
    150   int64 bb=ABS(intop);
    151   for (int i=0; i<row*col; i++)
    152   {
    153     int64 r=v[i];
    154     int64 c=r%bb;
    155     if (c<0) c+=bb;
    156     v[i]=c;
    157   }
    158 }
    159 
    160130int int64vec::compare(int64vec* op)
    161131{
     
    190160  }
    191161  return 0;
    192 }
    193 int int64vec::compare(int64 o)
    194 {
    195   for (int i=0; i<row*col; i++)
    196   {
    197     if (v[i] <o) return -1;
    198     if (v[i] >o) return 1;
    199   }
    200   return 0;
    201 }
    202 
    203 int64vec * iv64Copy(int64vec * o)
    204 {
    205   int64vec * iv=new int64vec(o);
    206   return iv;
    207162}
    208163
     
    267222}
    268223
    269 int64vec * iv64Tranp(int64vec * o)
    270 {
    271   int i, j, r = o->rows(), c = o->cols();
    272   int64vec * iv= new int64vec(c, r, 0);
    273   for (i=0; i<r; i++)
    274   {
    275     for (j=0; j<c; j++)
    276       (*iv)[j*r+i] = (*o)[i*c+j];
    277   }
    278   return iv;
    279 }
    280 
    281 int64 iv64Trace(int64vec * o)
    282 {
    283   int i, m = si_min(o->rows(),o->cols()), c = o->cols();
    284   int64 s = 0;
    285   for (i=0; i<m; i++)
    286   {
    287     s += (*o)[i*c+i];
    288   }
    289   return s;
    290 }
    291 
    292 int64vec * iv64Mult(int64vec * a, int64vec * b)
    293 {
    294   int i, j, k,
    295       ra = a->rows(), ca = a->cols(),
    296       rb = b->rows(), cb = b->cols();
    297   int64 sum;
    298   int64vec * iv;
    299   if (ca != rb) return NULL;
    300   iv = new int64vec(ra, cb, 0);
    301   for (i=0; i<ra; i++)
    302   {
    303     for (j=0; j<cb; j++)
    304     {
    305       sum = 0;
    306       for (k=0; k<ca; k++)
    307         sum += (*a)[i*ca+k]*(*b)[k*cb+j];
    308       (*iv)[i*cb+j] = sum;
    309     }
    310   }
    311   return iv;
    312 }
    313 
    314224/* def. internals */
    315225static int64 iv64Gcd(int, int);
  • kernel/int64vec.h

    rb553e5 rd14343a  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: int64vec.h,v 1.2 2005-05-09 12:14:57 Singular Exp $ */
     6/* $Id: int64vec.h,v 1.3 2005-05-09 13:47:29 Singular Exp $ */
    77/*
    88* ABSTRACT: class intvec: lists/vectors of int64
     
    3131  int64vec(int64vec* iv);
    3232  int64vec(intvec* iv);
    33   void resize(int new_length);
    34   int range(int i)
    35     { return ((i<row) && (i>=0) && (col==1)); }
    36   int range(int i, int j)
    37     { return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
    3833  int64& operator[](int i)
    3934    {
     
    4641      return v[i];
    4742    }
    48   void operator+=(int64 intop);
    49   void operator-=(int64 intop);
    5043  void operator*=(int64 intop);
    5144  void operator/=(int64 intop);
    52   void operator%=(int64 intop);
    5345  // -2: not compatible, -1: <, 0:=, 1: >
    5446  int compare(int64vec* o);
    55   int compare(int64 o);
    5647  int  length() const { return col*row; }
    5748  int  cols() const { return col; }
    5849  int  rows() const { return row; }
    59   void length(int l) { row = l; col = 1; }
    6050  void show(int mat=0,int spaces=0);
    61   void makeVector() { row*=col;col=1; }
    6251  char * String(int dim = 2);
    6352  char * iv64String(int not_mat=1,int mat=0,int spaces=0, int dim=2);
    64   // keiner (ausser obachman) darf das folgenden benutzen !!!
    6553  int64 * iv64GetVec() { return v; }
    6654  ~int64vec()
     
    7765    }
    7866};
    79 int64vec * iv64Copy(int64vec * o);
     67inline int64vec * iv64Copy(int64vec * o)
     68{
     69  int64vec * iv=new int64vec(o);
     70  return iv;
     71};
     72
    8073int64vec * iv64Add(int64vec * a, int64vec * b);
    8174int64vec * iv64Sub(int64vec * a, int64vec * b);
    82 int64vec * iv64Tranp(int64vec * o);
    83 int64      iv64Trace(int64vec * o);
    84 int64vec * iv64Mult(int64vec * a, int64vec * b);
    8575
    8676#ifdef MDEBUG
  • kernel/walkSupport.cc

    rb553e5 rd14343a  
    217217  for (n=2; n<=pertdeg; n++)
    218218  {
    219     temp64=iv64Copy(taun64);
    220     (*taun64)*=inveps64;
    221     for(int i=0; i<currRing->N;i++)
    222     {
    223       if((*temp64)[i]!=0 && (((*taun64)[i])/((*temp64)[i]))!=inveps64)
    224       overflow_error=12;
    225     }
    226     delete temp64;
     219    if (inveps64!=1)
     220    {
     221      temp64=iv64Copy(taun64);
     222      (*taun64)*=inveps64;
     223      for(int i=0; i<currRing->N;i++)
     224      {
     225        if((*temp64)[i]!=0 && (((*taun64)[i])/((*temp64)[i]))!=inveps64)
     226        overflow_error=12;
     227      }
     228      delete temp64;
     229    }
    227230    temp64=iv64Copy(taun64);
    228231    add64=getNthRow64(targm,n);
Note: See TracChangeset for help on using the changeset viewer.