// utils.H

#ifndef _PHB_UTILS_H_
#define _PHB_UTILS_H_

namespace xrml {

// samples the discrete pdf w with n components and sum of weights sumw.
// Rescales xi so it will properly lay into the interval [0,1) again.
extern int SampleDiscretePDF(float *w, int n, float sumw, float *xi);

// clips x to zero if negative
#define clamppos(x) (x > 0. ? x : 0.)

}  // namespace xrml

#endif /*_PHB_UTILS_H_*/
