@@ -59,7 +59,7 @@ use itertools::izip;
5959use pineappl:: boc:: { Bin , BinsWithFillLimits , Channel , Kinematics , Order , ScaleFuncForm , Scales } ;
6060use pineappl:: convolutions:: { Conv , ConvType , ConvolutionCache } ;
6161use pineappl:: grid:: { Grid , GridOptFlags } ;
62- use pineappl:: interpolation:: { Interp , InterpMeth , Map , ReweightMeth } ;
62+ use pineappl:: interpolation:: { Interp as InterpMain , InterpMeth , Map , ReweightMeth } ;
6363use pineappl:: packed_array:: ravel_multi_index;
6464use pineappl:: pids:: PidBasis ;
6565use pineappl:: subgrid:: Subgrid ;
@@ -91,7 +91,7 @@ pub const PINEAPPL_GOF_STRIP_EMPTY_CHANNELS: GridOptFlags = GridOptFlags::STRIP_
9191
9292// TODO: make sure no `panic` calls leave functions marked as `extern "C"`
9393
94- fn grid_interpolation_params ( key_vals : Option < & KeyVal > ) -> Vec < Interp > {
94+ fn grid_interpolation_params ( key_vals : Option < & KeyVal > ) -> Vec < InterpMain > {
9595 let mut q2_min = 1e2 ;
9696 let mut q2_max = 1e8 ;
9797 let mut q2_nodes = 40 ;
@@ -213,7 +213,7 @@ fn grid_interpolation_params(key_vals: Option<&KeyVal>) -> Vec<Interp> {
213213 }
214214
215215 vec ! [
216- Interp :: new(
216+ InterpMain :: new(
217217 q2_min,
218218 q2_max,
219219 q2_nodes,
@@ -222,7 +222,7 @@ fn grid_interpolation_params(key_vals: Option<&KeyVal>) -> Vec<Interp> {
222222 Map :: ApplGridH0 ,
223223 InterpMeth :: Lagrange ,
224224 ) ,
225- Interp :: new(
225+ InterpMain :: new(
226226 x1_min,
227227 x1_max,
228228 x1_nodes,
@@ -231,7 +231,7 @@ fn grid_interpolation_params(key_vals: Option<&KeyVal>) -> Vec<Interp> {
231231 Map :: ApplGridF2 ,
232232 InterpMeth :: Lagrange ,
233233 ) ,
234- Interp :: new(
234+ InterpMain :: new(
235235 x2_min,
236236 x2_max,
237237 x2_nodes,
@@ -1465,27 +1465,21 @@ pub struct Channels(Vec<Channel>);
14651465
14661466/// Type for defining the interpolation object
14671467#[ repr( C ) ]
1468- pub struct InterpTuples {
1469- node_min : f64 ,
1470- node_max : f64 ,
1471- nb_nodes : usize ,
1472- interp_degree : usize ,
1473- reweighting_method : ReweightMeth ,
1474- mapping : Map ,
1475- interpolation_method : InterpMeth ,
1476- }
1477-
1478- #[ must_use]
1479- fn construct_interpolation ( interp : & InterpTuples ) -> Interp {
1480- Interp :: new (
1481- interp. node_min ,
1482- interp. node_max ,
1483- interp. nb_nodes ,
1484- interp. interp_degree ,
1485- interp. reweighting_method ,
1486- interp. mapping ,
1487- interp. interpolation_method ,
1488- )
1468+ pub struct Interp {
1469+ /// TODO
1470+ pub min : f64 ,
1471+ /// TODO
1472+ pub max : f64 ,
1473+ /// TODO
1474+ pub nodes : usize ,
1475+ /// TODO
1476+ pub order : usize ,
1477+ /// TODO
1478+ pub reweight : ReweightMeth ,
1479+ /// TODO
1480+ pub map : Map ,
1481+ /// TODO
1482+ pub interp_meth : InterpMeth ,
14891483}
14901484
14911485/// An exact duplicate of `pineappl_lumi_new` to make naming (lumi -> channel) consistent.
@@ -1605,30 +1599,32 @@ pub extern "C" fn pineappl_channels_delete(channels: Option<Box<Channels>>) {}
16051599/// `0` -> `ScaleFuncForm::NoScale`, ..., `n` -> `ScaleFuncForm::Scale(n - 1)`.
16061600///
16071601/// # Safety
1602+ ///
16081603/// TODO
16091604///
16101605/// # Panics
1606+ ///
16111607/// TODO
16121608#[ no_mangle]
16131609#[ must_use]
16141610pub unsafe extern "C" fn pineappl_grid_new2 (
1615- pid_basis : PidBasis ,
1616- channels : * const Channels ,
1617- orders : usize ,
1618- order_params : * const u8 ,
16191611 bins : usize ,
16201612 bin_limits : * const f64 ,
1621- nb_convolutions : usize ,
1613+ orders : usize ,
1614+ order_params : * const u8 ,
1615+ channels : * const Channels ,
1616+ pid_basis : PidBasis ,
16221617 convolution_types : * const ConvType ,
1623- pdg_ids : * const c_int ,
1618+ convolution_pdg_ids : * const c_int ,
1619+ interpolations : usize ,
1620+ interp_info : * const Interp ,
16241621 kinematics : * const Kinematics ,
1625- interpolations : * const InterpTuples ,
16261622 mu_scales : * const usize ,
16271623) -> Box < Grid > {
1628- // Luminosity channels
1629- let channels = unsafe { & * channels } ;
1630-
1631- // Perturbative orders
1624+ let bins = BinsWithFillLimits :: from_fill_limits (
1625+ unsafe { slice :: from_raw_parts ( bin_limits , bins + 1 ) } . to_vec ( ) ,
1626+ )
1627+ . unwrap ( ) ;
16321628 let order_params = unsafe { slice:: from_raw_parts ( order_params, 5 * orders) } ;
16331629 let orders: Vec < _ > = order_params
16341630 . chunks ( 5 )
@@ -1640,32 +1636,47 @@ pub unsafe extern "C" fn pineappl_grid_new2(
16401636 logxia : s[ 4 ] ,
16411637 } )
16421638 . collect ( ) ;
1643-
1644- let bins = BinsWithFillLimits :: from_fill_limits (
1645- unsafe { slice:: from_raw_parts ( bin_limits, bins + 1 ) } . to_vec ( ) ,
1646- )
1647- . unwrap ( ) ;
1639+ let channels = unsafe { & * channels } ;
16481640
16491641 // Construct the convolution objects
1642+ let convolutions = channels. 0 [ 0 ] . entry ( ) [ 0 ] . 0 . len ( ) ;
16501643 let convolution_types =
1651- unsafe { slice:: from_raw_parts ( convolution_types, nb_convolutions) . to_vec ( ) } ;
1652- let pdg_ids = unsafe { slice:: from_raw_parts ( pdg_ids, nb_convolutions) . to_vec ( ) } ;
1653- let convolutions = izip ! ( convolution_types. iter( ) , pdg_ids. iter( ) )
1654- . map ( |( & conv, & pdg_value) | Conv :: new ( conv, pdg_value) )
1644+ unsafe { slice:: from_raw_parts ( convolution_types, convolutions) . to_vec ( ) } ;
1645+ let convolution_pdg_ids =
1646+ unsafe { slice:: from_raw_parts ( convolution_pdg_ids, convolutions) . to_vec ( ) } ;
1647+ let convolutions = convolution_types
1648+ . iter ( )
1649+ . zip ( convolution_pdg_ids)
1650+ . map ( |( & convolution_type, pdg_id) | Conv :: new ( convolution_type, pdg_id) )
16551651 . collect ( ) ;
16561652
16571653 // Grid interpolations
1658- let interp_slices = unsafe { std:: slice:: from_raw_parts ( interpolations, nb_convolutions + 1 ) } ;
1659- let interp_vecs: Vec < Interp > = interp_slices. iter ( ) . map ( construct_interpolation) . collect ( ) ;
1654+ let interp_slices = unsafe { std:: slice:: from_raw_parts ( interp_info, interpolations) } ;
1655+ let interp_vecs: Vec < _ > = interp_slices
1656+ . iter ( )
1657+ . map ( |interp| {
1658+ InterpMain :: new (
1659+ interp. min ,
1660+ interp. max ,
1661+ interp. nodes ,
1662+ interp. order ,
1663+ interp. reweight ,
1664+ interp. map ,
1665+ interp. interp_meth ,
1666+ )
1667+ } )
1668+ . collect ( ) ;
16601669
16611670 // Construct the kinematic variables
1662- let kinematics = unsafe { slice:: from_raw_parts ( kinematics, interp_vecs. len ( ) ) . to_vec ( ) } ;
1671+ let kinematics = unsafe { slice:: from_raw_parts ( kinematics, interp_vecs. len ( ) ) } . to_vec ( ) ;
16631672
16641673 // Scales. An array containing the values of {ren, fac, frg}
16651674 let mu_scales = unsafe { std:: slice:: from_raw_parts ( mu_scales, 3 ) } ;
1666- let mu_scales_vec: Vec < ScaleFuncForm > = mu_scales
1675+ let mu_scales_vec: Vec < _ > = mu_scales
16671676 . iter ( )
16681677 . map ( |& scale| {
1678+ // TODO: this doesn't allow all other `ScaleFuncForm`, for instance
1679+ // `ScaleFuncForm::QuadraticSum`
16691680 if scale == 0 {
16701681 ScaleFuncForm :: NoScale
16711682 } else {
0 commit comments