Subversion Repositories gelsvn

Rev

Rev 39 | Rev 55 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 39 Rev 45
Line 69... Line 69...
69
  template <class Scalar>
69
  template <class Scalar>
70
  inline bool is_tiny(Scalar x)	{return (x > -TINY && x < TINY);}
70
  inline bool is_tiny(Scalar x)	{return (x > -TINY && x < TINY);}
71
 
71
 
72
  /** What power of 2 ?. if x is the argument, find the largest 
72
  /** What power of 2 ?. if x is the argument, find the largest 
73
      y so that 2^y <= x */
73
      y so that 2^y <= x */
74
  inline int two_to_what_power(int x) 
74
  inline int two_to_what_power(unsigned int x) 
75
  {
75
  {
76
    if (x<1) 
76
    if (x<1) 
77
      return -1;
77
      return -1;
78
    int i = 0;
78
    int i = 0;
79
    while (x != 1) {x>>=1;i++;}
79
    while (x != 1) {x>>=1;i++;}
Line 89... Line 89...
89
  template<class T>
89
  template<class T>
90
  inline T sign(T x) {return x>=T(0) ? 1 : -1;}
90
  inline T sign(T x) {return x>=T(0) ? 1 : -1;}
91
 
91
 
92
 
92
 
93
  template<class T>
93
  template<class T>
94
  inline T int_pow(T x, int k) 
94
  inline T int_pow(T x, unsigned int k) 
95
  {
95
  {
96
    T y = static_cast<T>(1);
96
    T y = static_cast<T>(1);
97
    for(int i=0;i<k;++i)
97
    for(unsigned int i=0;i<k;++i)
98
      y *= x;
98
      y *= x;
99
    return y;
99
    return y;
100
  }
100
  }
101
 
101
 
102
	/** raw_assign takes a CGLA vector, matrix or whatever has a get() function
102
	/** raw_assign takes a CGLA vector, matrix or whatever has a get() function