@@ -1461,7 +1461,7 @@ pub unsafe extern "C" fn pineappl_string_delete(string: *mut c_char) {
14611461
14621462/// Type for defining a Channel function.
14631463#[ derive( Default ) ]
1464- pub struct Channels ( Vec < Channel > ) ;
1464+ pub struct Channels ( Vec < Channel > , usize ) ;
14651465
14661466/// Type for defining the interpolation object
14671467#[ repr( C ) ]
@@ -1486,8 +1486,8 @@ pub struct Interp {
14861486/// should be deleted using `pineappl_channels_delete`.
14871487#[ no_mangle]
14881488#[ must_use]
1489- pub extern "C" fn pineappl_channels_new ( ) -> Box < Channels > {
1490- Box :: default ( )
1489+ pub extern "C" fn pineappl_channels_new ( convolutions : usize ) -> Box < Channels > {
1490+ Box :: new ( Channels ( Vec :: new ( ) , convolutions ) )
14911491}
14921492
14931493/// Adds a generalized linear combination of initial states to the Luminosity.
@@ -1503,13 +1503,12 @@ pub extern "C" fn pineappl_channels_new() -> Box<Channels> {
15031503pub unsafe extern "C" fn pineappl_channels_add (
15041504 channels : * mut Channels ,
15051505 combinations : usize ,
1506- nb_convolutions : usize ,
15071506 pdg_id_combinations : * const i32 ,
15081507 factors : * const f64 ,
15091508) {
15101509 let channels = unsafe { & mut * channels } ;
15111510 let pdg_id_pairs =
1512- unsafe { slice:: from_raw_parts ( pdg_id_combinations, nb_convolutions * combinations) } ;
1511+ unsafe { slice:: from_raw_parts ( pdg_id_combinations, channels . 1 * combinations) } ;
15131512 let factors = if factors. is_null ( ) {
15141513 vec ! [ 1.0 ; combinations]
15151514 } else {
@@ -1518,9 +1517,9 @@ pub unsafe extern "C" fn pineappl_channels_add(
15181517
15191518 channels. 0 . push ( Channel :: new (
15201519 pdg_id_pairs
1521- . chunks ( nb_convolutions )
1520+ . chunks ( channels . 1 )
15221521 . zip ( factors)
1523- . map ( |x| ( ( 0 ..nb_convolutions ) . map ( |i| x. 0 [ i] ) . collect ( ) , x. 1 ) )
1522+ . map ( |x| ( ( 0 ..channels . 1 ) . map ( |i| x. 0 [ i] ) . collect ( ) , x. 1 ) )
15241523 . collect ( ) ,
15251524 ) ) ;
15261525}
@@ -1535,7 +1534,10 @@ pub unsafe extern "C" fn pineappl_channels_add(
15351534pub unsafe extern "C" fn pineappl_grid_channels ( grid : * const Grid ) -> Box < Channels > {
15361535 let grid = unsafe { & * grid } ;
15371536
1538- Box :: new ( Channels ( grid. channels ( ) . to_vec ( ) ) )
1537+ Box :: new ( Channels (
1538+ grid. channels ( ) . to_vec ( ) ,
1539+ grid. convolutions ( ) . len ( ) ,
1540+ ) )
15391541}
15401542
15411543/// An exact duplicate of `pineappl_lumi_count` to make naming (lumi -> channel) consistent.
@@ -1639,7 +1641,7 @@ pub unsafe extern "C" fn pineappl_grid_new2(
16391641 let channels = unsafe { & * channels } ;
16401642
16411643 // Construct the convolution objects
1642- let convolutions = channels. 0 [ 0 ] . entry ( ) [ 0 ] . 0 . len ( ) ;
1644+ let convolutions = channels. 1 ;
16431645 let convolution_types =
16441646 unsafe { slice:: from_raw_parts ( convolution_types, convolutions) . to_vec ( ) } ;
16451647 let convolution_pdg_ids =
0 commit comments