17 #if defined __cplusplus
27 char const *toUnits[3] ) {
30 double norm, wUnitFactor;
31 char const *wFromUnit, *toUnitsXY[2] = { toUnits[1], toUnits[2] };
54 if( ( dists->
Ws = (
double *)
smr_malloc2( smr, W_XYs->
length *
sizeof(
double ), 1,
"dists->Ws" ) ) == NULL )
goto err;
57 for( i = 0; i < W_XYs->
length; i++ ) {
58 XYs = &(W_XYs->
XYs[i]);
59 dists->
Ws[i] = wUnitFactor * XYs->
value;
64 else if( std::fabs( 1. - norm ) > 0.99 ) {
101 if( ( dist->
Xs = (
double *)
smr_malloc2( smr, 3 * n1 *
sizeof(
double ), 0,
"dist->Xs" ) ) == NULL )
goto err;
105 for( j1 = 0; j1 <
n1; j1++ ) {
107 dist->
Xs[j1] = point->
x;
108 dist->
pdf[j1] = point->
y;
117 double inv_norm,
sum = 0;
119 inv_norm = 1.0 / ( dist->
Xs[n1-1] - dist->
Xs[0] );
120 for( j1 = 0; j1 <
n1; ++j1 ) {
121 if( j1 > 0 ) sum += dist->
Xs[j1] - dist->
Xs[j1-1];
123 dist->
cdf[j1] = sum * inv_norm;
125 dist->
cdf[n1-1] = 1.; }
128 for( j1 = 0; j1 <
n1; j1++ ) dist->
pdf[j1] /= *norm;
171 #if defined __cplusplus