Skip to content

Commit

Permalink
Improve evolution performance for double-hadronic grids
Browse files Browse the repository at this point in the history
Instead of using a cartesian product of two PIDs which is subsequently
filtered use two iterators of PIDs first filtered and subsequently
zipped. This is a change of O(n^2) to O(n) which makes a big difference
if n is large enough. This is the case for dijet grids, for example.
  • Loading branch information
cschwan committed Oct 14, 2023
1 parent 8dc1eb4 commit ef962fa
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions pineappl/src/evolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,14 @@ pub(crate) fn evolve_with_two(
pids_a
.iter()
.zip(operators_a.iter())
.cartesian_product(pids_b.iter().zip(operators_b.iter()))
.find_map(|((&(pa0, pa1), opa), (&(pb0, pb1), opb))| {
(pa0 == pida0 && pa1 == pida1 && pb0 == pidb0 && pb1 == pidb1)
.then_some((opa, opb))
.find_map(|(&(pa0, pa1), opa)| {
(pa0 == pida0 && pa1 == pida1).then_some(opa)
})
.zip(pids_b.iter().zip(operators_b.iter()).find_map(
|(&(pb0, pb1), opb)| {
(pb0 == pidb0 && pb1 == pidb1).then_some(opb)
},
))
.map(|(opa, opb)| (fk_table, opa, opb))
})
{
Expand Down Expand Up @@ -1069,11 +1072,14 @@ pub(crate) fn evolve_slice_with_two(
pids_a
.iter()
.zip(operators_a.iter())
.cartesian_product(pids_b.iter().zip(operators_b.iter()))
.find_map(|((&(pa0, pa1), opa), (&(pb0, pb1), opb))| {
(pa0 == pida0 && pa1 == pida1 && pb0 == pidb0 && pb1 == pidb1)
.then_some((opa, opb))
.find_map(|(&(pa0, pa1), opa)| {
(pa0 == pida0 && pa1 == pida1).then_some(opa)
})
.zip(pids_b.iter().zip(operators_b.iter()).find_map(
|(&(pb0, pb1), opb)| {
(pb0 == pidb0 && pb1 == pidb1).then_some(opb)
},
))
.map(|(opa, opb)| (fk_table, opa, opb))
})
{
Expand Down

0 comments on commit ef962fa

Please sign in to comment.