Subversion Repositories gelsvn

Rev

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

Rev 277 Rev 417
Line 1... Line 1...
1
// $Id: CGLA.h 277 2006-08-29 09:14:45Z jrf $
1
// $Id: CGLA.h 417 2009-01-12 15:40:09Z 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 48... Line 48...
48
	
48
	
49
  /** Numerical constant represents something small.
49
  /** Numerical constant represents something small.
50
      value is a bit arbitrary */
50
      value is a bit arbitrary */
51
  const double SMALL=10e-2;
51
  const double SMALL=10e-2;
52
 
52
 
-
 
53
  /** The GEL pseudo-random number generator uses
-
 
54
      UINT_MAX as RAND_MAX to avoid mod operations. */
-
 
55
  const unsigned int GEL_RAND_MAX=UINT_MAX;
-
 
56
 
53
		inline double sqrt3()
57
		inline double sqrt3()
54
		{
58
		{
55
				static const double sqrt3_val = sqrt(3.0);
59
				static const double sqrt3_val = sqrt(3.0);
56
				return sqrt3_val;
60
				return sqrt3_val;
57
		}
61
		}
Line 73... Line 77...
73
  Scalar s_max(Scalar a, Scalar b)
77
  Scalar s_max(Scalar a, Scalar b)
74
  {
78
  {
75
    return a>b ? a : b;
79
    return a>b ? a : b;
76
  }
80
  }
77
 
81
 
78
  ///Template for a function that squares the argument.
82
  /// Template for a function that squares the argument.
79
  template <class Scalar>
83
  template <class Scalar>
80
  inline Scalar sqr(Scalar x) {///
84
  inline Scalar sqr(Scalar x) {///
81
    return x*x;}
85
    return x*x;}
82
	
86
	
83
  /// Scalaremplate for a function that returns the cube of the argument.
87
  /// Scalar template for a function that returns the cube of the argument.
84
  template <class Scalar>
88
  template <class Scalar>
85
  inline Scalar qbe(Scalar x) {///
89
  inline Scalar qbe(Scalar x) {///
86
    return x*x*x;}
90
    return x*x*x;}
87
 
91
 
88
  template <class Scalar>
92
  template <class Scalar>
Line 121... Line 125...
121
      if(n & 1) result = result*a;
125
      if(n & 1) result = result*a;
122
      a *= a;
126
      a *= a;
123
    }
127
    }
124
    return result;
128
    return result;
125
  }
129
  }
-
 
130
  
-
 
131
  /// Function that seeds the GEL pseudo-random number generator
-
 
132
  void gel_srand(unsigned int seed);
-
 
133
 
-
 
134
  /** GEL provides a linear congruential pseudo-random number 
-
 
135
      generator which is optimized for speed. This version allows 
-
 
136
      an integer argument which is useful for grid-based noise
-
 
137
      functions. */
-
 
138
  unsigned int gel_rand(unsigned int k);
-
 
139
 
-
 
140
  /** GEL provides a linear congruential pseudo-random number 
-
 
141
      generator which is optimized for speed. This means
-
 
142
      that GEL_RAND_MAX==UINT_MAX. */
-
 
143
  unsigned int gel_rand();
126
 
144
 
127
	/** raw_assign takes a CGLA vector, matrix or whatever has a get() function
145
	/** raw_assign takes a CGLA vector, matrix or whatever has a get() function
128
			as its first argument and a raw pointer to a (presumed scalar) entity 
146
			as its first argument and a raw pointer to a (presumed scalar) entity 
129
			as the second argument. the contents dereferenced by the pointer is 
147
			as the second argument. the contents dereferenced by the pointer is 
130
			copied to the entity given as first argument. */
148
			copied to the entity given as first argument. */