Skip to content

Commit 9d6f897

Browse files
committed
Undo interface change to pineappl_channels_entry
1 parent 9c08d4f commit 9d6f897

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

examples/cpp/display-channels.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
4343

4444
// read out the channel with index given by `channel`, writing the particle identifiers into
4545
// `pids` and the corresponding factors into `factors`
46-
pineappl_channels_entry(channels, channel, n_conv, pids.data(), factors.data());
46+
pineappl_channels_entry(channels, channel, pids.data(), factors.data());
4747

4848
for (std::size_t combination = 0; combination != combinations; ++combination) {
4949
auto factor = factors.at(combination);

pineappl_capi/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,26 +1760,28 @@ pub unsafe extern "C" fn pineappl_grid_split_channels(grid: *mut Grid) {
17601760
grid.split_channels();
17611761
}
17621762

1763-
/// Similar to `pineappl_lumi_entry` but for luminosity channels that involve 3 or more partons, ie.
1764-
/// in the case of multiple convolutions.
1763+
/// Read out the channel with index `entry` of the given `channels`. The PDG ids and factors will
1764+
/// be copied into `pdg_ids` and `factors`.
17651765
///
17661766
/// # Safety
17671767
///
1768-
/// The parameter `channels` must point to a valid `Channels` object created by `pineappl_channels_new` or
1769-
/// `pineappl_grid_channels`. The parameter `factors` must point to an array as long as the size
1770-
/// returned by `pineappl_channels_combinations` and `pdg_ids` must point to an array that is twice as
1771-
/// long.
1768+
/// The parameter `channels` must point to a valid [`Channels`] object created by
1769+
/// [`pineappl_channels_new`] or [`pineappl_grid_channels`]. The parameter `factors` must point to
1770+
/// an array as long as the result of [`pineappl_channels_combinations`] and `pdg_ids` must
1771+
/// point to an array as long as the result multiplied with the number of convolutions.
17721772
#[no_mangle]
17731773
pub unsafe extern "C" fn pineappl_channels_entry(
17741774
channels: *const Channels,
17751775
entry: usize,
1776-
nb_convolutions: usize,
17771776
pdg_ids: *mut i32,
17781777
factors: *mut f64,
17791778
) {
17801779
let channels = unsafe { &*channels };
17811780
let entry = channels.0[entry].entry();
1782-
let pdg_ids = unsafe { slice::from_raw_parts_mut(pdg_ids, nb_convolutions * entry.len()) };
1781+
// if the channel has no entries we assume no convolutions, which is OK we don't copy anything
1782+
// in this case
1783+
let convolutions = entry.get(0).map_or(0, |x| x.0.len());
1784+
let pdg_ids = unsafe { slice::from_raw_parts_mut(pdg_ids, convolutions * entry.len()) };
17831785
let factors = unsafe { slice::from_raw_parts_mut(factors, entry.len()) };
17841786

17851787
entry

0 commit comments

Comments
 (0)