Skip to content

Commit 41d6e28

Browse files
Update mkl_distributions.cpp
1 parent be85402 commit 41d6e28

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

mkl_random/src/mkl_distributions.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -659,18 +659,11 @@ irk_noncentral_chisquare_vec(irk_state *state, npy_intp len, double *res, const
659659

660660
mkl_free(pvec);
661661
} else {
662-
double lambda;
663-
664662
/* noncentral_chisquare(1, nonc) ~ (Z + sqrt(nonc))**2 for df == 1 */
665-
err = vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, state->stream, len, res, d_zero, d_one);
666663
loc = sqrt(nonc);
667-
668-
#pragma ivdep
669-
for(i=0; i<len; i++) {
670-
lambda = res[i] + loc;
671-
/* squaring could result in an overflow */
672-
res[i] = lambda * lambda;
673-
}
664+
err = vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, state->stream, len, res, loc, d_one);
665+
assert(err == VSL_STATUS_OK);
666+
vmdSqrt(len, res, res, VML_HA);
674667
}
675668
}
676669
}

0 commit comments

Comments
 (0)