60 pdf->
cd.
v[0] = sqrt(cd.
m[0][0]);
61 pdf->
cd.
v[1] = sqrt(cd.
m[1][1]);
62 pdf->
cd.
v[2] = sqrt(cd.
m[2][2]);
112 for (i = 0; i < 3; i++)
118 for (i = 0; i < 3; i++)
120 x.
v[i] = pdf->
x.
v[i];
121 for (j = 0; j < 3; j++)
122 x.
v[i] += pdf->
cr.
m[i][j] * r.
v[j];
138 do { r = drand48(); }
while (r==0.0);
140 do { r = drand48(); }
while (r==0.0);
143 }
while(w > 1.0 || w==0.0);
145 return(sigma * x2 * sqrt(-2.0*log(w)/w));
159 pf_pdf_discrete_t *pf_pdf_discrete_alloc(
int count,
double *probs)
161 pf_pdf_discrete_t *pdf;
163 pdf = calloc(1,
sizeof(pf_pdf_discrete_t));
165 pdf->prob_count = count;
166 pdf->probs = malloc(count *
sizeof(
double));
167 memcpy(pdf->probs, probs, count *
sizeof(
double));
170 pdf->rng = gsl_rng_alloc(gsl_rng_taus);
174 pdf->ran = gsl_ran_discrete_preproc(count, probs);
181 void pf_pdf_discrete_free(pf_pdf_discrete_t *pdf)
183 gsl_ran_discrete_free(pdf->ran);
184 gsl_rng_free(pdf->rng);
192 double pf_pdf_discrete_value(pf_pdf_discrete_t *pdf,
int i)
194 return pdf->probs[i];
199 int pf_pdf_discrete_sample(pf_pdf_discrete_t *pdf)
203 i = gsl_ran_discrete(pdf->rng, pdf->ran);
204 assert(i >= 0 && i < pdf->prob_count);
void pf_pdf_gaussian_free(pf_pdf_gaussian_t *pdf)
double pf_ran_gaussian(double sigma)
pf_vector_t pf_pdf_gaussian_sample(pf_pdf_gaussian_t *pdf)
pf_pdf_gaussian_t * pf_pdf_gaussian_alloc(pf_vector_t x, pf_matrix_t cx)
static unsigned int pf_pdf_seed
TFSIMD_FORCE_INLINE const tfScalar & x() const
TFSIMD_FORCE_INLINE const tfScalar & w() const
void pf_matrix_unitary(pf_matrix_t *r, pf_matrix_t *d, pf_matrix_t a)