Changeset 5cea7a in git for gfanlib/gfanlib_vector.h


Ignore:
Timestamp:
Aug 2, 2016, 6:08:41 PM (7 years ago)
Author:
Yue <ren@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
Children:
fbaeb59f9025699b9055c1091c0deef1925dbb40
Parents:
6a97c544535256c37da0f10bcb6821b592546c68
git-author:
Yue <ren@mathematik.uni-kl.de>2016-08-02 18:08:41+02:00
git-committer:
Yue <ren@mathematik.uni-kl.de>2016-08-05 18:10:20+02:00
Message:
chg: new gfanlib version 0.6
File:
1 edited

Legend:

Unmodified
Added
Removed
  • gfanlib/gfanlib_vector.h

    r6a97c54 r5cea7a  
    7272  // Access
    7373  //--------
    74   typ& operator[](int n)
     74  typ& operator[](int n)__attribute__((always_inline))
    7575    {
    7676      if(!(n>=0 && n<(int)v.size()))outOfRange(n,v.size());
    7777      return (v[n]);
    7878    }
    79   const typ& operator[](int n)const{assert(n>=0 && n<(int)v.size());return (v[n]);}
    80   const typ& UNCHECKEDACCESS(int n)const{return (v[n]);}
     79  const typ& operator[](int n)const __attribute__((always_inline)){assert(n>=0 && n<(int)v.size());return (v[n]);}
     80  typ& UNCHECKEDACCESS(int n)__attribute__((always_inline)){return (v[n]);}
     81  const typ& UNCHECKEDACCESS(int n)const __attribute__((always_inline)){return (v[n]);}
    8182
    8283  //-------------
     
    8586  unsigned int size()const{return v.size();};
    8687  void resize(int n){v.resize(n,typ());};
    87   void grow(int i){if((int)size()<i)resize(i);}
     88  void grow(int i){if(size()<i)resize(i);}
    8889  void push_back(typ a)
    8990  {
     
    293294  std::string toString()const
    294295  {
    295     std::stringstream f;
    296     f<<*this;
    297     return f.str();
     296          std::stringstream f;
     297          f<<*this;
     298          return f.str();
    298299  }
    299300
    300301  typ gcd()const
    301302  {
     303    typ temp1,temp2;
    302304    typ ret(1);
    303305    for(unsigned i=0;i<size();i++)
    304       ret=typ::gcd(ret,v[i]);
     306      ret=typ::gcd(ret,v[i],temp1,temp2);
    305307    return ret;
    306308  }
     
    309311    assert(!typ::isField());
    310312    return (*this)/gcd();
    311   }
    312 
    313   void debugPrint()const
    314   {
    315     std::stringstream s;
    316     s<<"(";
    317     for(typename std::vector<typ>::const_iterator i=this->v.begin();i!=this->v.end();i++)
    318     {
    319       if(i!=this->v.begin()) s<<",";
    320       s<<*i;
    321     }
    322     s<<")"<<std::endl;
    323     std::cout << s.str();
    324     return;
    325313  }
    326314};
     
    415403
    416404    return ret;
    417 };
    418 
    419 };
     405}
     406
     407}
    420408
    421409#endif /* LIB_ZVECTOR_H_ */
Note: See TracChangeset for help on using the changeset viewer.