Skip to content

Commit 67edab5

Browse files
committed
Fix a few clippy warnings
1 parent ada5ef5 commit 67edab5

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

pineappl/src/boc.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ impl ScaleFuncForm {
111111
Self::ScaleMax(_, _) => |(s1, s2)| s1.max(s2),
112112
Self::ScaleMin(_, _) => |(s1, s2)| s1.min(s2),
113113
Self::Prod(_, _) => |(s1, s2)| s1 * s2,
114-
Self::S2plusS1half(_, _) => |(s1, s2)| 0.5 * (s1 + 2.0 * s2),
115-
Self::Pow4Sum(_, _) => |(s1, s2)| (s1 * s1 + s2 * s2).sqrt(),
116-
Self::WgtAvg(_, _) => |(s1, s2)| (s1 * s1 + s2 * s2) / (s1 + s2),
117-
Self::S2plusS1fourth(_, _) => |(s1, s2)| 0.25 * s1 + s2,
114+
Self::S2plusS1half(_, _) => |(s1, s2)| 0.5 * s2.mul_add(2.0, s1),
115+
Self::Pow4Sum(_, _) => |(s1, s2)| s1.hypot(s2),
116+
Self::WgtAvg(_, _) => |(s1, s2)| s1.mul_add(s1, s2 * s2) / (s1 + s2),
117+
Self::S2plusS1fourth(_, _) => |(s1, s2)| s1.mul_add(0.25, s2),
118118
Self::ExpProd2(_, _) => {
119119
|(s1, s2)| (s1.sqrt() * (0.3 * s2.sqrt()).exp()).powi(2)
120120
}
@@ -145,6 +145,7 @@ impl ScaleFuncForm {
145145
}
146146

147147
/// TODO
148+
#[must_use]
148149
pub fn idx(&self, indices: &[usize], scale_dims: &[usize]) -> usize {
149150
match self.clone() {
150151
Self::NoScale => unreachable!(),

pineappl/src/import_subgrid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl From<&SubgridEnum> for ImportSubgridV1 {
162162

163163
for (mut indices, value) in subgrid.indexed_iter() {
164164
for (index, range) in indices.iter_mut().zip(&ranges) {
165-
*index = *index - range.start;
165+
*index -= range.start;
166166
}
167167

168168
array[indices.as_slice()] += value;

pineappl/src/interpolation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const MAX_DIMENSIONS: usize = 8;
1111

1212
mod applgrid {
1313
pub fn reweight_x(x: f64) -> f64 {
14-
(x.sqrt() / (1.0 - 0.99 * x)).powi(3)
14+
(x.sqrt() / x.mul_add(-0.99, 1.0)).powi(3)
1515
}
1616

1717
pub fn fx2(y: f64) -> f64 {
@@ -23,7 +23,7 @@ mod applgrid {
2323
if delta.abs() < 1e-12 {
2424
return x;
2525
}
26-
let deriv = -1.0 - 5.0 * x;
26+
let deriv = x.mul_add(-5.0, -1.0);
2727
yp -= delta / deriv;
2828
}
2929

pineappl/tests/drell_yan_lo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn hadronic_pspgen(rng: &mut impl Rng, mmin: f64, mmax: f64) -> Psp2to2 {
9898
jacobian *= tau * tau0.ln().powi(2) * r1;
9999

100100
// theta integration (in the CMS)
101-
let cos_theta = 2.0 * rng.gen::<f64>() - 1.0;
101+
let cos_theta = rng.gen::<f64>().mul_add(2.0, -1.0);
102102
jacobian *= 2.0;
103103

104104
let t = -0.5 * s * (1.0 - cos_theta);

pineappl_cli/tests/import.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const IMPORT_FLEX_GRID_QUADRATIC_SUM_STR: &str =
9090
-+------------+------------+--------------+-------------
9191
0 8.1098571e1 8.1098571e1 -4.7739590e-15 7.3274720e-15
9292
1 3.5222658e1 3.5222658e1 1.1102230e-15 6.8833828e-15
93-
2 7.7939468e0 7.7939468e0 1.9984014e-15 4.5519144e-15
93+
2 7.7939468e0 7.7939468e0 1.7763568e-15 4.5519144e-15
9494
3 9.1540624e-1 9.1540624e-1 -5.7731597e-15 7.7715612e-15
9595
";
9696

@@ -188,7 +188,7 @@ const IMPORT_FLEX_GRID_13_STR: &str = "b PineAPPL fastNLO rel. diff
188188
#[cfg(feature = "fastnlo")]
189189
const IMPORT_FLEX_GRID_14_STR: &str = "b PineAPPL fastNLO rel. diff svmaxreldiff
190190
-+------------+------------+--------------+-------------
191-
0 8.2850540e1 8.2850540e1 6.8833828e-15 7.1054274e-15
191+
0 8.2850540e1 8.2850540e1 6.8833828e-15 6.8833828e-15
192192
1 3.5828674e1 3.5828674e1 2.6645353e-15 1.0103030e-14
193193
2 7.9087501e0 7.9087501e0 -8.2156504e-15 8.2156504e-15
194194
3 9.3462321e-1 9.3462321e-1 4.4408921e-16 8.2156504e-15

pineappl_fastnlo/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,18 @@ impl ffi::EScaleFunctionalForm {
228228
match self {
229229
Self::kScale1 => s1 * s1,
230230
Self::kScale2 => s2 * s2,
231-
Self::kQuadraticSum => s1 * s1 + s2 * s2,
232-
Self::kQuadraticMean => 0.5 * (s1 * s1 + s2 * s2),
233-
Self::kQuadraticSumOver4 => 0.25 * (s1 * s1 + s2 * s2),
231+
Self::kQuadraticSum => s1.mul_add(s1, s2 * s2),
232+
Self::kQuadraticMean => 0.5 * s1.mul_add(s1, s2 * s2),
233+
Self::kQuadraticSumOver4 => 0.25 * s1.mul_add(s1, s2 * s2),
234234
Self::kLinearMean => 0.25 * (s1 + s2).powi(2),
235235
Self::kLinearSum => (s1 + s2).powi(2),
236236
Self::kScaleMax => s1.max(s2).powi(2),
237237
Self::kScaleMin => s1.min(s2).powi(2),
238238
Self::kProd => (s1 * s2).powi(2),
239-
Self::kS2plusS1half => 0.5 * (s1 * s1 + 2.0 * s2 * s2),
239+
Self::kS2plusS1half => 0.5 * s1.mul_add(s1, 2.0 * s2 * s2),
240240
Self::kPow4Sum => (s1.powi(4) + s2.powi(4)).sqrt(),
241-
Self::kWgtAvg => (s1.powi(4) + s2.powi(4)) / (s1 * s1 + s2 * s2),
242-
Self::kS2plusS1fourth => 0.25 * s1 * s1 + s2 * s2,
241+
Self::kWgtAvg => (s1.powi(4) + s2.powi(4)) / s1.mul_add(s1, s2 * s2),
242+
Self::kS2plusS1fourth => (0.25 * s1).mul_add(s1, s2 * s2),
243243
Self::kExpProd2 => (s1 * (0.3 * s2).exp()).powi(2),
244244
Self::kExtern => todo!(),
245245
Self::kConst => todo!(),

0 commit comments

Comments
 (0)