@@ -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]
17731773pub 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