131 if ((!ret) && (p > 0))
148 double zero = 0.0, half = 0.5, one = 1.0, delta = .000001;
157 for (
int i = aux->
nn - 1, i1 = aux->
nn - 2; i >= 1; i--, i1--) {
159 aux->
c[i] = aux->
c[i1];
166 aux->
bdrs[0] = (double) o->
a.
f;
167 aux->
bdrs[aux->
nn] = (
double) o->
b.
f;
168 aux->
c[0] = (double) o->
x.
f;
173 for (
int i = 0, i1 = 1; i < aux->
nn; i++, i1++) {
175 aux->
sc[i] = half * (aux->
c[i1] + aux->
c[i])
181 for (
int i = 0; i < aux->
nn; i++) {
183 aux->
sc[i] = v * aux->
norm;
186 if (aux->
sc[aux->
nn-1] < one - delta
187 || one + delta < aux->sc[aux->
nn-1]) {
191 for (
int i = aux->
nn-1; i > 0; i--) {
192 aux->
sc[i] = aux->
sc[i-1];
195 aux->
sc[aux->
nn] = one;
211 double x, y, dy, slope, zero = 0.0, two = 2.0;
222 while (x >= aux->
sc[i]) i++;
225 slope = ((aux->
c[i] - aux->
c[i-1]) * aux->
norm) /
228 y = aux->
c[i-1] * aux->
norm;
230 dy = (sqrt(y*y + two*slope*(x)) - y)/slope;
232 y = aux->
bdrs[i-1] + dy;
256 if (x <= o->a.d || x >= o->
b.
d) {
262 while (x > aux->
bdrs[i]) i++;
263 slope = (aux->
c[i] - aux->
c[i-1]) /
265 y = (aux->
c[i-1] + (slope * (x - aux->
bdrs[i-1])))
283 double zero = 0.0, one = 1.0, half = 0.5, y;
293 }
else if (x >= o->
b.
d) {
299 while (x > aux->
bdrs[i]) i++;
300 diff = (x - aux->
bdrs[i-1]);
301 slope = (aux->
c[i] - aux->
c[i-1]) /
303 y = (aux->
c[i-1] + (slope * diff));
304 y = aux->
sc[i-1] + half * (y + aux->
c[i-1])*diff*aux->
norm;
320 float x, y, dy, slope, zero = 0.0, two = 2.0;
331 while (x >= aux->
sc[i]) i++;
334 slope = ((aux->
c[i] - aux->
c[i-1]) * aux->
norm) /
337 y = aux->
c[i-1] * aux->
norm;
339 dy = (sqrtf(y*y + two*slope*(x)) - y)/slope;
341 y = aux->
bdrs[i-1] + dy;
365 if (x <= o->a.f || x >= o->
b.
f) {
371 while (x > aux->
bdrs[i]) i++;
372 slope = (aux->
c[i] - aux->
c[i-1]) /
374 y = (aux->
c[i-1] + (slope * (x - aux->
bdrs[i-1])))
392 float zero = 0.0, one = 1.0, half = 0.5, y;
402 }
else if (x >= o->
b.
f) {
408 while (x > aux->
bdrs[i]) i++;
409 diff = (x - aux->
bdrs[i-1]);
410 slope = (aux->
c[i] - aux->
c[i-1]) /
412 y = (aux->
c[i-1] + (slope * diff));
413 y = aux->
sc[i-1] + half * (y + aux->
c[i-1])*diff*aux->
norm;
int LR_lspl_new(LR_obj *o, int n)
LR_lspl_new(LR_obj *o, int n) - create a new linear spline object.
int LR_lspl_rm(LR_obj *o)
LR_lspl_rm(LR_obj *o) - strip out the LR_lspl object part of LR_obj.
#define LRerr_SuspiciousValues
float LRf_lspline_PDF(LR_obj *o, float x)
LRf_lspline_PDF(LR_obj *o, float x) - float linear spline probablity distribution function...
int LR_pcs_set(LR_obj *o, double x, double p)
LR_pcs_set(LR_obj *o, double x) - add interval boundary (will order internally).
#define LRerr_UnmetPreconditions
A special object for defining some of the random variate distributions.
int LR_lspl_set(LR_obj *o, double x, double p)
LR_lspl_set(LR_obj *o, double x) - add interval boundary (will order internally). ...
float LRf_lspline_RAN(LR_obj *o)
LRf_lspline_RAN(LR_obj *o) - float random linear spline distribution.
#define LRerr_NoAuxNormalizeDone
double LRd_lspline_CDF(LR_obj *o, double x)
LRd_lspline_CDF(LR_obj *o, double x) - double linear spline cumulative distribution function...
double LRd_lspline_PDF(LR_obj *o, double x)
LRd_lspline_PDF(LR_obj *o, double x) - double linear spline probablity distribution function...
int LR_pcs_rm(LR_obj *o)
LR_pcs_rm(LR_obj *o) - strip out the LR_pcs object part of LR_obj.
double LRd_lspline_RAN(LR_obj *o)
LRd_lspline_RAN(LR_obj *o) - double random linear spline distribution random variate.
float LRf_lspline_CDF(LR_obj *o, float x)
LRf_lspline_CDF(LR_obj *o, float x) - float linear spline cumulative distribution function...
int LR_lspl_norm(LR_obj *o)
LR_lspl_norm(LR_obj *o) - normalize the interval scale factors.
The LibRan common header file.
int LR_pcs_new(LR_obj *o, int n)
LR_pcs_new(LR_obj *o, int n) - create a new piecewise uniform object set of segments.
the fundamental LibRan random variate distribution object