31 #include <tiled_sequence.h> 45 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
48 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
49 float sample(
const uint32 idx,
const uint32 vertex,
const uint32 dim)
const {
return sequence.sample(idx, vertex * 3 + dim); }
61 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
63 sequence(_sequence), res_x(_res_x), res_y(_res_y) {}
65 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
66 float sample(
const uint32 idx,
const uint32 vertex,
const uint32 dim)
const 68 const uint32 pixel_x = idx % res_x;
69 const uint32 pixel_y = idx / res_x;
71 if (vertex == 1 && dim < 2)
75 (pixel_x + sequence.sample_2d(pixel_x, pixel_y, dim)) /
float(res_x) :
76 (pixel_y + sequence.sample_2d(pixel_x, pixel_y, dim)) /
float(res_y);
79 return sequence.sample_2d(pixel_x, pixel_y, (vertex - 1) * 6 + dim);
95 CauchyPerturbation = 0x1,
96 IndependentSample = 0x2
99 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
100 uint32 chain_coordinate_index(
const uint32 idx,
const uint32 dim)
const 102 return dim*n_chains + idx;
105 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
107 const uint32 _n_chains,
109 const uint32 _path_vertex_offset,
111 const uint32 _mut_vertex_offset,
113 const float _radius = 0.01f) :
114 path_u(_path_u + _path_vertex_offset * 3 * _n_chains),
115 mut_u(_mut_u + _mut_vertex_offset * 3 * _n_chains),
121 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
122 float sample(
const uint32 idx,
const uint32 vertex,
const uint32 dim)
const {
return perturbed_u(idx, vertex * 3 + dim); }
124 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
125 float u_m(
const uint32 chain_id,
const uint32 dim)
const {
return mut_u[chain_coordinate_index(chain_id, dim)]; }
127 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
128 float& u(
const uint32 chain_id,
const uint32 dim) {
return path_u[chain_coordinate_index(chain_id, dim)]; }
130 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
131 const float& u(
const uint32 chain_id,
const uint32 dim)
const {
return path_u[chain_coordinate_index(chain_id, dim)]; }
133 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
134 float perturbed_u(
const uint32 chain_id,
const uint32 dim)
const 136 if (type == CauchyPerturbation)
140 return cugar::mod(u(chain_id, dim) + cauchy.
map(u_m(chain_id, dim)), 1.0f);
142 else if (type == IndependentSample)
144 return u_m(chain_id, dim);
147 return u(chain_id, dim);
Defines various distributions.
float CUGAR_HOST_DEVICE mod(const float x, const float m)
Definition: numbers.h:606
Definition: tiled_sequence.h:53
Definition: bpt_samplers.h:90
Definition: bpt_samplers.h:59
Definition: bpt_samplers.h:43
Definition: distributions.h:295
CUGAR_HOST_DEVICE float map(const float U) const
Definition: distributions.h:306