Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/helpers.hpp

    ra67d19 r920c70  
    2424/********************************************** definitions *********************************/
    2525
    26 // some algebraic matrix stuff
    27 double RDET3(const double a[NDIM*NDIM]);
    28 double RDET2(const double a[4]);
    29 double RDET2(const double a0, const double a1, const double a2, const double a3);
    30 
    3126/********************************************** helpful functions *********************************/
    3227
     
    5348bool check_bounds(double *x, double *cell_size);
    5449void bound(double *b, double lower_bound, double upper_bound);
    55 int pot(int base, int n);
    5650int CountLinesinFile(ifstream &InputFile);
    5751char *FixedDigitNumber(const int FragmentNumber, const int digits);
     
    6458/********************************************** helpful template functions *********************************/
    6559
    66 /** Flips two values.
    67  * \param x first value
    68  * \param y second value
    69  */
    70 template <typename T> void flip(T &x, T &y)
    71 {
    72   T tmp;
    73   tmp = x;
    74   x = y;
    75   y = tmp;
    76 };
    7760
    7861/** returns greater of the two values.
     
    132115
    133116  // allocate and fill
    134   LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable");
     117  LookupTable = new T*[count];
    135118  if (LookupTable == NULL) {
    136119    DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl);
     
    187170};
    188171
     172#define PLURAL_S(v) (((v)==1)?"":"s")
    189173
     174// this is to allow different modes of access for
     175// maps and sets
     176template<typename Res,typename T>
     177struct _take{
     178  Res get(T value) const;
     179};
     180
     181// if we have a set,vector etc we can directly access the result
     182template<typename Res>
     183struct _take<Res,Res>{
     184  static inline Res get(Res value){
     185    return value;
     186  }
     187};
     188
     189// if we have a map we have to access the second part of
     190// the pair
     191template<typename Res,typename T1>
     192struct _take<Res,std::pair<T1,Res> >{
     193  static inline Res get(std::pair<T1,Res> value){
     194    return value.second;
     195  }
     196};
    190197
    191198#endif /*HELPERS_HPP_*/
Note: See TracChangeset for help on using the changeset viewer.