5#ifndef __UTIL_MATH_CDF_H__
6#define __UTIL_MATH_CDF_H__
15template<
typename Functor>
17 const int resolution,
const float from,
const float to, Functor functor,
vector<float> &cdf)
19 const int cdf_count = resolution + 1;
20 const float range = to -
from;
21 cdf.resize(cdf_count);
24 for (
int i = 0; i < resolution; ++i) {
25 float x = from + range * (
float)i / (resolution - 1);
27 cdf[i + 1] = cdf[i] +
fabsf(y);
30 float fac = (cdf[resolution] == 0.0f) ? 0.0f : 1.0f / cdf[resolution];
31 for (
int i = 0; i <= resolution; i++) {
34 cdf[resolution] = 1.0f;
42 const bool make_symmetric,
46template<
typename Functor>
51 const bool make_symmetric,
#define CCL_NAMESPACE_END
draw_view in_light_buf[] float
CCL_NAMESPACE_BEGIN void util_cdf_evaluate(const int resolution, const float from, const float to, Functor functor, vector< float > &cdf)
void util_cdf_invert(const int resolution, const float from, const float to, const vector< float > &cdf, const bool make_symmetric, vector< float > &inv_cdf)
void util_cdf_inverted(const int resolution, const float from, const float to, Functor functor, const bool make_symmetric, vector< float > &inv_cdf)