5#include <cgv/math/vec.h>
6#include <cgv/math/fvec.h>
7#include <cgv/math/mat.h>
8#include <cgv/math/eig.h>
9#include <cgv/math/diag_mat.h>
10#include <cgv/math/perm_mat.h>
11#include <cgv/math/up_tri_mat.h>
12#include <cgv/math/low_tri_mat.h>
13#include <cgv/math/quaternion.h>
29 unsigned long long u,v,w;
36 v = 4101842887655102017LL;
38 unsigned long long ull;
47 unsigned long long seed = clock();
52 random(
unsigned long long seed) : storedval(0.0)
60 u = u*2862933555777941757LL + 7046029254386353087LL;
61 v ^= v >> 17; v ^= v <<31; v ^= v >> 8;
62 w = 4294957665U*(w & 0xffffffff) + (w >> 32);
63 unsigned long long x = u ^(u << 21); x ^= x >>35; x^=x << 4;
102 unsigned long long v;
108 void uniform(
const unsigned min,
const unsigned max,
unsigned& rv)
111 rv =rv%(max-min+1)+min;
115 void uniform(
const int min,
const int max,
int& rv)
118 rv =(int)(rv%(
unsigned)(max-min+1))+min;
125 unsigned long long v;
127 rv= 5.42101086242752217E-20 * v;
131 void uniform(
const double min,
const double max,
double &rv)
135 rv= (max-min)*v + min;
147 void uniform(
const float min,
const float max,
float& rv)
151 rv= (max-min)*f + min;
157 for(
unsigned i = 0; i < rv.
size();i++)
164 for(
unsigned i = 0; i < rv.
size();i++)
173 for(
unsigned i = 0; i < rv.
size();i++)
180 for(
unsigned i = 0; i < rv.
size();i++)
185 template<
typename T, cgv::type::u
int32_type N>
188 for(
unsigned i = 0; i < N; i++)
193 template<
typename T, cgv::type::u
int32_type N>
196 for(
unsigned i = 0; i < N; i++)
203 for(
unsigned i = 0; i < rv.
nrows(); i++)
204 for(
unsigned j = 0; j < rv.
ncols(); j++)
211 for(
unsigned i = 0; i < rv.
nrows(); i++)
212 for(
unsigned j = 0; j < rv.
ncols(); j++)
220 for(
unsigned i = 0; i < rv.
size();i++)
231 for(
unsigned i = 0; i < rv.nrows(); i++)
232 for(
unsigned j = i; j < rv.ncols(); j++)
241 for(
unsigned i = 0; i < rv.nrows(); i++)
242 for(
unsigned j = i; j < rv.ncols(); j++)
249 for(
unsigned i = 0; i < rv.nrows(); i++)
250 for(
unsigned j = i; j < rv.ncols(); j++)
257 for(
unsigned i = 0; i < rv.nrows(); i++)
258 for(
unsigned j = i; j < rv.ncols(); j++)
265 for(
unsigned i = 0; i < rv.nrows(); i++)
266 for(
unsigned j = 0; j <= i; j++)
273 for(
unsigned i = 0; i < rv.nrows(); i++)
274 for(
unsigned j = 0; j <= i; j++)
281 for(
unsigned j = 0; j < rv.ncols(); j++)
282 for(
unsigned i = 0; i < j; i++)
289 for(
unsigned j = 0; j < rv.ncols(); j++)
290 for(
unsigned i = 0; i < j; i++)
297 for(
unsigned i = 0; i < rv.
nrows(); i++)
304 for(
unsigned i = 0; i < rv.
nrows(); i++)
311 for(
unsigned i = 0; i < rv.
nrows(); i++)
318 for(
unsigned i = 0; i < rv.
nrows(); i++)
326 for(
unsigned i = 0; i < rv.
nrows(); i++)
327 for(
unsigned j = 0; j < rv.
ncols(); j++)
334 for(
unsigned i = 0; i < rv.
nrows(); i++)
335 for(
unsigned j = 0; j < rv.
ncols(); j++)
344 double v1,v2,rsq,fac;
354 }
while(rsq >= 1.0 || rsq == 0.0);
355 fac = sqrt(-2.0*std::log(rsq)/rsq);
376 void normal(
const double mu,
const double sigma,
double &rv)
384 void normal(
const float mu,
const float sigma,
float& rv)
394 for(
unsigned i = 0;i < v.
size(); i++)
403 for(
unsigned i = 0;i < v.
size();i++)
416 T z, r, theta, omega;
420 theta = T(2) * T(3.14159) * x[1];
421 omega = T(3.14159) * x[2];
425 b = s * cos(theta) * r;
426 c = s * sin(theta) * r;
457 for (
unsigned i=0; i<p.
size(); ++i)
467 for (
unsigned i=0; i<p.
size(); ++i)
477 r = std::pow(r, 1.0/p.
size());
491 p= u*p1 + v*p2 +(1.0-u-v)*p3;
498 for(
unsigned i = 0;i < p.
size();i++)
508 std::set<unsigned> s;
518 for(std::set<unsigned>::iterator it =s.begin(); it != s.end();it++,i++)
matrix of fixed size dimensions
A vector with zero based index.
A matrix type (full column major storage) The matrix can be loaded directly into OpenGL without need ...
unsigned ncols() const
number of columns
unsigned nrows() const
number of rows
void set(AxisEnum axis, coord_type angle)
set quaternion from coordinate axis and rotation angle
void put_homogeneous_matrix(hmat_type &M) const
compute equivalent homogeneous 4x4 rotation matrix
void put_matrix(mat_type &M) const
compute equivalent 3x3 rotation matrix
void resize(unsigned dim)
resize the vector
unsigned size() const
number of elements
void normalize()
normalize the vector using the L2-Norm
A diagonal matrix type which internally stores the elements on the main diagonal in a vector.
unsigned nrows() const
number of rows
a permutation matrix type
unsigned size() const
number of stored elements
High quality random number generator, which is a little bit slower than typical random number generat...
void normal(double &rv)
generates a normal deviate double-precision floating point value with mu = 0 and sigma = 1
void uniform(low_tri_mat< double > &rv)
generates a pseudo random double precision lower triangular matrix with uniformly distribute componen...
void uniform(vec< float > &rv)
generates a pseudo random single precision vector with uniformly distribute components between 0 and ...
void uniform(mat< float > &rv)
generates a pseudo random single precision full matrix with uniformly distribute components between 0...
void normal(const double mu, const double sigma, double &rv)
generates a normal deviate double-precision floating point value with mu and sigma
void uniform(unsigned int &rv)
generates a 32bit pseudo random unsigned integer
void uniform_point_on_sphere(const vec< double > ¢er, const double &radius, vec< double > &p)
creates an uniform distributed random point on the surface of a sphere with given center and radius
void uniform_quat_orientation(quaternion< T > &q)
generates a random orientation represented as a unit quaternion
void uniform(const double min, const double max, double &rv)
generates a pseudo random double-precision floating point number uniformly distributed between min an...
void uniform(const double min, const double max, up_tri_mat< double > &rv)
generates a pseudo random double precision upper triangular matrix with uniformly distribute componen...
void uniform(const float min, const float max, mat< float > &rv)
generates a pseudo random single precision full matrix with uniformly distribute components between m...
void uniform_point_in_triangle(const vec< double > &p1, const vec< double > &p2, const vec< double > &p3, vec< double > p)
creates an uniform distributed random point in triangle p1,p2,p3
void uniform(long &rv)
generates a 32bit pseudo random signed integer
void uniform(diag_mat< double > &rv)
generates a pseudo random double precision diagonal matrix with uniformly distribute components betwe...
void uniform(const float min, const float max, vec< float > &rv)
generates a pseudo random single precision vector with uniformly distribute components between min an...
void uniform_orientation(fmat< T, 3, 3 > &m)
generates a single precision random orientation represented as a rotation matrix
void uniform(float &rv)
generates a pseudo random single-precision floating point number uniformly distributed between 0 and ...
void uniform_direction(vec< double > &v)
generates a double precision random direction (uniformly distributed position on the unit sphere)
void uniform(diag_mat< float > &rv)
generates a pseudo random single precision diagonal matrix with uniformly distribute components betwe...
void uniform_orientation(fmat< T, 4, 4 > &m)
generates a single precision random orientation represented as a homogeneous rotation matrix
void set_seed(unsigned long long seed)
set a new seed
void uniform(const double min, const double max, mat< double > &rv)
generates a pseudo random double full matrix with uniformly distribute components between min and max
void uniform_point_in_unit_ball(vec< double > &p)
creates an uniform distributed random point in unit sphere
void uniform_direction(vec< float > &v)
generates a single precision random direction (uniformly distributed position on the unit sphere)
void uniform(const unsigned min, const unsigned max, unsigned &rv)
generates a pseudo random integer between min and max
void uniform(const double min, const double max, low_tri_mat< double > &rv)
generates a pseudo random double precision lower triangular matrix with uniformly distribute componen...
void uniform(low_tri_mat< float > &rv)
generates a pseudo random single precision lower triangular matrix with uniformly distribute componen...
void uniform_nchoosek(unsigned n, unsigned k, vec< unsigned > &indices)
creates a vector of k unique indices drawn from 0 to n-1
void uniform_point_in_box(const vec< double > &minp, const vec< double > &maxp, vec< double > &p)
creates an uniform distributed random point in box minp..maxp
void uniform(const float min, const float max, up_tri_mat< float > &rv)
generates a pseudo random single precision upper triangular matrix with uniformly distribute componen...
void uniform(up_tri_mat< double > &rv)
generates a pseudo random double precision upper triangular matrix with uniformly distribute componen...
void uniform(unsigned long long &rv)
generates 64bit pseudo random integer
void normal(float &rv)
generates a normal deviate single-precision floating point value with mu = 0 and sigma = 1
void uniform(mat< double > &rv)
generates a pseudo random double full matrix with uniformly distribute components between 0 and 1
void uniform_point_in_unit_box(vec< double > &p)
creates an uniform distributed random point in unit box (0,0,...,0)..(1,1,...,1); if dim(p)=0,...
void uniform(vec< double > &rv)
generates a pseudo random double precision vector with uniformly distribute components between 0 and ...
void uniform(up_tri_mat< float > &rv)
generates a pseudo random single precision upper triangular matrix with uniformly distribute componen...
void uniform(cgv::math::fvec< T, N > &rv)
generates a pseudo random single precision fixed-size vector with uniformly distribute components bet...
void uniform(bool &rv)
generates a pseudo random boolean
void uniform(const float min, const float max, low_tri_mat< float > &rv)
generates a pseudo random single precision lower triangular matrix with uniformly distribute componen...
void uniform(const float min, const float max, cgv::math::fvec< T, N > &rv)
generates a pseudo random single precision fixed-size vector with uniformly distribute components bet...
void uniform(const int min, const int max, int &rv)
generates a pseudo random integer between min and max
random(unsigned long long seed)
constructor initializes random generator with given seed
void uniform(perm_mat &rv)
generates a pseudo random permutation matrix
void uniform(const double min, const double max, diag_mat< double > &rv)
generates a pseudo random double precision diagonal matrix with uniformly distribute components betwe...
random()
standard constructor uses system time as random seed
void uniform(const float min, const float max, float &rv)
generates a pseudo random single-precision floating point number uniformly distributed between min an...
void uniform(long long &rv)
generates a 64bit pseudo random signed integer
void uniform(const float min, const float max, diag_mat< float > &rv)
generates a pseudo random single precision diagonal matrix with uniformly distribute components betwe...
void uniform(const double min, const double max, vec< double > &rv)
generates a pseudo random double precision vector with uniformly distribute components between min an...
void uniform(int &rv)
generates a 32bit pseudo random signed integer
void uniform(double &rv)
generates a pseudo random double-precision floating point number uniformly distributed between 0 and ...
void normal(const float mu, const float sigma, float &rv)
generates a normal deviate single-precision floating point value with mu and sigma