Subversion Repositories gelsvn

Rev

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

Rev 248 Rev 277
Line 1... Line 1...
1
// $Id: CGLA.h 248 2006-06-30 10:54:06Z bj $
1
// $Id: CGLA.h 277 2006-08-29 09:14:45Z jrf $
2
 
2
 
3
#ifndef __CGLA_CGLA_H__
3
#ifndef __CGLA_CGLA_H__
4
#define __CGLA_CGLA_H__
4
#define __CGLA_CGLA_H__
5
 
5
 
6
#if (_MSC_VER >= 1200)
6
#if (_MSC_VER >= 1200)
Line 109... Line 109...
109
#endif
109
#endif
110
 
110
 
111
  template<class T>
111
  template<class T>
112
  inline T sign(T x) {return x>=T(0) ? 1 : -1;}
112
  inline T sign(T x) {return x>=T(0) ? 1 : -1;}
113
 
113
 
114
 
-
 
-
 
114
  /// Integer power function with O(log(n)) complexity
115
  template<class T>
115
  template<class T>
116
  inline T int_pow(T x, unsigned int k) 
116
  inline T int_pow(T a, unsigned int n)
117
  {
117
  {
118
    T y = static_cast<T>(1);
118
    T result = static_cast<T>(1);
119
    for(unsigned int i=0;i<k;++i)
119
    for(; n > 0; n >>= 1)
-
 
120
    {
-
 
121
      if(n & 1) result = result*a;
120
      y *= x;
122
      a *= a;
-
 
123
    }
121
    return y;
124
    return result;
122
  }
125
  }
123
 
126
 
124
	/** raw_assign takes a CGLA vector, matrix or whatever has a get() function
127
	/** raw_assign takes a CGLA vector, matrix or whatever has a get() function
125
			as its first argument and a raw pointer to a (presumed scalar) entity 
128
			as its first argument and a raw pointer to a (presumed scalar) entity 
126
			as the second argument. the contents dereferenced by the pointer is 
129
			as the second argument. the contents dereferenced by the pointer is