Skip to content

Commit ef962fa

Browse files
committed
Improve evolution performance for double-hadronic grids
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.
1 parent 8dc1eb4 commit ef962fa

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

pineappl/src/evolution.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -957,11 +957,14 @@ pub(crate) fn evolve_with_two(
957957
pids_a
958958
.iter()
959959
.zip(operators_a.iter())
960-
.cartesian_product(pids_b.iter().zip(operators_b.iter()))
961-
.find_map(|((&(pa0, pa1), opa), (&(pb0, pb1), opb))| {
962-
(pa0 == pida0 && pa1 == pida1 && pb0 == pidb0 && pb1 == pidb1)
963-
.then_some((opa, opb))
960+
.find_map(|(&(pa0, pa1), opa)| {
961+
(pa0 == pida0 && pa1 == pida1).then_some(opa)
964962
})
963+
.zip(pids_b.iter().zip(operators_b.iter()).find_map(
964+
|(&(pb0, pb1), opb)| {
965+
(pb0 == pidb0 && pb1 == pidb1).then_some(opb)
966+
},
967+
))
965968
.map(|(opa, opb)| (fk_table, opa, opb))
966969
})
967970
{
@@ -1069,11 +1072,14 @@ pub(crate) fn evolve_slice_with_two(
10691072
pids_a
10701073
.iter()
10711074
.zip(operators_a.iter())
1072-
.cartesian_product(pids_b.iter().zip(operators_b.iter()))
1073-
.find_map(|((&(pa0, pa1), opa), (&(pb0, pb1), opb))| {
1074-
(pa0 == pida0 && pa1 == pida1 && pb0 == pidb0 && pb1 == pidb1)
1075-
.then_some((opa, opb))
1075+
.find_map(|(&(pa0, pa1), opa)| {
1076+
(pa0 == pida0 && pa1 == pida1).then_some(opa)
10761077
})
1078+
.zip(pids_b.iter().zip(operators_b.iter()).find_map(
1079+
|(&(pb0, pb1), opb)| {
1080+
(pb0 == pidb0 && pb1 == pidb1).then_some(opb)
1081+
},
1082+
))
10771083
.map(|(opa, opb)| (fk_table, opa, opb))
10781084
})
10791085
{

0 commit comments

Comments
 (0)