| 31 | TGenerator( double df_ ) : df(df_), df_2(df_/2.0) {} |
| 32 | |
| 33 | inline double operator()() const { |
| 34 | /* Some compilers (including MW6) evaluated this from right to left |
| 35 | return norm_rand() / sqrt(rchisq(df) / df); */ |
| 36 | double num = norm_rand(); |
| 37 | |
| 38 | // return num / sqrt(rchisq(df) / df); |
| 39 | // replaced by the followoing line to skip the test in |
| 40 | // rchisq because we already know |
| 41 | return num / ::sqrt( ::Rf_rgamma(df_2, 2.0) / df); |
| 42 | } |
| 43 | |
| 44 | private: |
| 45 | double df, df_2 ; |