Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
JamboChen committed Oct 11, 2024
1 parent a8e3596 commit 88e58bc
Showing 1 changed file with 53 additions and 59 deletions.
112 changes: 53 additions & 59 deletions rand_distr/tests/cdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,63 +791,63 @@ fn owen_t(h: f64, a: f64) -> f64 {
}

fn tf(h: f64, a: f64, ah: f64) -> f64 {
let rtwopi = 0.15915494309189533577;
let rrtpi = 0.39894228040143267794;
let rtwopi = 0.159_154_943_091_895_35;
let rrtpi = 0.398_942_280_401_432_7;

let c2 = [
0.99999999999999987510,
-0.99999999999988796462,
0.99999999998290743652,
-0.99999999896282500134,
0.99999996660459362918,
-0.99999933986272476760,
0.99999125611136965852,
-0.99991777624463387686,
0.99942835555870132569,
-0.99697311720723000295,
0.98751448037275303682,
-0.95915857980572882813,
0.89246305511006708555,
-0.76893425990463999675,
0.58893528468484693250,
-0.38380345160440256652,
0.20317601701045299653,
-0.82813631607004984866e-01,
0.24167984735759576523e-01,
-0.44676566663971825242e-02,
0.39141169402373836468e-03,
0.999_999_999_999_999_9,
-0.999_999_999_999_888,
0.999_999_999_982_907_5,
-0.999_999_998_962_825,
0.999_999_966_604_593_7,
-0.999_999_339_862_724_7,
0.999_991_256_111_369_6,
-0.999_917_776_244_633_8,
0.999_428_355_558_701_4,
-0.996_973_117_207_23,
0.987_514_480_372_753,
-0.959_158_579_805_728_8,
0.892_463_055_110_067_1,
-0.768_934_259_904_64,
0.588_935_284_684_846_9,
-0.383_803_451_604_402_55,
0.203_176_017_010_453,
-8.281_363_160_700_499e-2,
2.416_798_473_575_957_8e-2,
-4.467_656_666_397_183e-3,
3.914_116_940_237_383_6e-4,
];

let pts = [
0.35082039676451715489e-02,
0.31279042338030753740e-01,
0.85266826283219451090e-01,
0.16245071730812277011,
0.25851196049125434828,
0.36807553840697533536,
0.48501092905604697475,
0.60277514152618576821,
0.71477884217753226516,
0.81475510988760098605,
0.89711029755948965867,
0.95723808085944261843,
0.99178832974629703586,
3.508_203_967_645_171_6e-3,
3.127_904_233_803_075_6e-2,
8.526_682_628_321_945e-2,
0.162_450_717_308_122_77,
0.258_511_960_491_254_36,
0.368_075_538_406_975_3,
0.485_010_929_056_047,
0.602_775_141_526_185_7,
0.714_778_842_177_532_3,
0.814_755_109_887_601,
0.897_110_297_559_489_7,
0.957_238_080_859_442_6,
0.991_788_329_746_297,
];

let wts = [
0.18831438115323502887e-01,
0.18567086243977649478e-01,
0.18042093461223385584e-01,
0.17263829606398753364e-01,
0.16243219975989856730e-01,
0.14994592034116704829e-01,
0.13535474469662088392e-01,
0.11886351605820165233e-01,
0.10070377242777431897e-01,
0.81130545742299586629e-02,
0.60419009528470238773e-02,
0.38862217010742057883e-02,
0.16793031084546090448e-02,
1.883_143_811_532_350_3e-2,
1.856_708_624_397_765e-2,
1.804_209_346_122_338_5e-2,
1.726_382_960_639_875_2e-2,
1.624_321_997_598_985_8e-2,
1.499_459_203_411_670_5e-2,
1.353_547_446_966_209e-2,
1.188_635_160_582_016_5e-2,
1.007_037_724_277_743_2e-2,
8.113_054_574_229_958e-3,
6.041_900_952_847_024e-3,
3.886_221_701_074_205_7e-3,
1.679_303_108_454_609e-3,
];

let hrange = [
Expand All @@ -866,15 +866,9 @@ fn tf(h: f64, a: f64, ah: f64) -> f64 {
[2, 3, 4, 4, 6, 6, 18, 18, 18, 18, 17, 17, 17, 12, 12],
];

let ihint = match hrange.iter().position(|&r| h < r) {
Some(idx) => idx,
None => 14,
};
let ihint = hrange.iter().position(|&r| h < r).unwrap_or(14);

let iaint = match arange.iter().position(|&r| a < r) {
Some(idx) => idx,
None => 7,
};
let iaint = arange.iter().position(|&r| a < r).unwrap_or(7);

let icode = select[iaint][ihint];
let m = [
Expand Down Expand Up @@ -973,7 +967,7 @@ fn tf(h: f64, a: f64, ah: f64) -> f64 {
tf += wts[i] * (hs * r).exp() / r;
}
tf *= a;
return tf;
tf
}
6 => {
let normh = znorm2(h);
Expand All @@ -983,7 +977,7 @@ fn tf(h: f64, a: f64, ah: f64) -> f64 {
if r != 0.0 {
tf -= rtwopi * r * (-0.5 * y * h * h / r).exp();
}
return tf;
tf
}
_ => 0.0,
}
Expand Down

0 comments on commit 88e58bc

Please sign in to comment.