Expand description
The C-language interface for PineAPPL.
The PineAPPL Application Programming Interface for the C language (CAPI) defines types and
functions that allow PineAPPL to be used without having to write Rust code, and instead
offering
- C or C++, or
- Fortran as programming languages. Fortran is supported using the
iso_c_bindingmodule to wrap CAPI’s functions (see the Fortran example in the repository).
Note that the CAPI only defines a subset of functionality available in the Rust module, which is extended on an as-needed basis. If you happen to miss a function please open a new issue on the github page.
§Using and linking the CAPI
To use PineAPPL’s CAPI you must include its header pineappl_capi.h. To successfully build
your program, you should rely on pkgconf or pkg-conf, as follows:
pkg-config --cflags pineappl_capi
pkg-config --libs pineappl_capiThis will read PineAPPL’s .pc file and print the neccessary CFLAGS (--cflags) and
linker flags (--libs). This procedure is supported by many build systems, such as
- Autoconf/Automake, using the
PKG_CHECK_MODULESmacro, see the Autotools mythbuster page for correct usage, - CMake, using
FindPkgConfigand - meson, using
dependency; it usually suffices to writedependency('pineappl_capi').
§Strings and other types
Strings used in this library are have the Rust type *const c_char or *mut c_char and
correspond to the C types const char* and char*, respectively. The strings are assumed to
be encoded using UTF-8, which Rust uses internally.
All other built-in types in Rust (f64, usize, i32, u32, …) correspond to types in C
as defined by the translation tables of cbindgen. If in doubt, consult the generated header
pineappl_capi.h.
Structs§
- Channels
- Type for defining a Channel function.
- Interp
- Type for defining the interpolation object
- KeyVal
- Key-value storage for passing optional information during grid creation with
pineappl_grid_new. - Lumi
- Type for defining a luminosity function.
- Operator
Info - Type for defining the Operator info.
Constants§
- PINEAPPL_
GOF_ MERGE_ SAME_ CHANNELS - TODO
- PINEAPPL_
GOF_ OPTIMIZE_ NODES - TODO
- PINEAPPL_
GOF_ OPTIMIZE_ SUBGRID_ TYPE - TODO
- PINEAPPL_
GOF_ STRIP_ EMPTY_ CHANNELS - TODO
- PINEAPPL_
GOF_ STRIP_ EMPTY_ ORDERS - TODO
- PINEAPPL_
GOF_ SYMMETRIZE_ CHANNELS - TODO
Functions§
- pineappl_
channels_ ⚠add - Adds a generalized linear combination of initial states to the Luminosity.
- pineappl_
channels_ ⚠combinations - An exact duplicate of
pineappl_lumi_combinationsto make naming (lumi -> channel) consistent. - pineappl_
channels_ ⚠count - An exact duplicate of
pineappl_lumi_countto make naming (lumi -> channel) consistent. - pineappl_
channels_ delete - An exact duplicate of
pineappl_lumi_deleteto make naming (lumi -> channel) consistent. - pineappl_
channels_ ⚠entry - Read out the channel with index
entryof the givenchannels. The PDG ids and factors will be copied intopdg_idsandfactors. - pineappl_
channels_ new - An exact duplicate of
pineappl_lumi_newto make naming (lumi -> channel) consistent. should be deleted usingpineappl_channels_delete. - pineappl_
fktable_ ⚠optimize - Optimize the size of this FK-table by removing heavy quark flavors assumed to be zero.
- pineappl_
grid_ ⚠bin_ count - Returns the number of bins in
grid. - pineappl_
grid_ ⚠bin_ dimensions - Returns the number of dimensions of the bins this grid has.
- pineappl_
grid_ ⚠bin_ limits_ left - Write the left limits for the specified dimension into
left. - pineappl_
grid_ ⚠bin_ limits_ right - Write the right limits for the specified dimension into
right. - pineappl_
grid_ ⚠bin_ normalizations - Stores the bin sizes of
gridinbin_sizes. - pineappl_
grid_ ⚠channels - An exact duplicate of
pineappl_grid_lumito make naming (lumi -> channel) consistent. - pineappl_
grid_ ⚠clone - Returns a cloned object of
grid. - pineappl_
grid_ ⚠conv_ types - Get the type of convolutions for this Grid.
- pineappl_
grid_ ⚠convolute_ with_ one Deprecated - Wrapper for
pineappl_grid_convolve_with_one. - pineappl_
grid_ ⚠convolute_ with_ two Deprecated - Wrapper for
pineappl_grid_convolve_with_two. - pineappl_
grid_ ⚠convolutions_ len - Get the number of convolutions for a given Grid.
- pineappl_
grid_ ⚠convolve - A generalization of the convolution function for Grids.
- pineappl_
grid_ ⚠convolve_ with_ one - Convolutes the specified grid with the PDF
xfx, which is the PDF for a hadron with the PDG idpdg_id, and strong couplingalphas. These functions must evaluate the PDFs for the givenxandq2for the parton with the given PDG id,pdg_id, and return the result. Note that the value must be the PDF multiplied with its argumentx. The value of the pointerstateprovided to these functions is the same one given to this function. The parameterorder_maskmust be as long as there are perturbative orders contained ingridand is used to selectively disable (false) or enable (true) individual orders. Iforder_maskis set toNULL, all orders are active. The parameterchannel_maskcan be used similarly, but must be as long as the channelsgridwas created with has entries, orNULLto enable all channels. The valuesxi_renandxi_faccan be used to vary the renormalization and factorization from its central value, which corresponds to1.0. After convolution of the grid with the PDFs the differential cross section for each bin is written intoresults. - pineappl_
grid_ ⚠convolve_ with_ two - Convolutes the specified grid with the PDFs
xfx1andxfx2, which are the PDFs of hadrons with PDG idspdg_id1andpdg_id2, respectively, and strong couplingalphas. These functions must evaluate the PDFs for the givenxandq2for the parton with the given PDG id,pdg_id, and return the result. Note that the value must be the PDF multiplied with its argumentx. The value of the pointerstateprovided to these functions is the same one given to this function. The parameterorder_maskmust be as long as there are perturbative orders contained ingridand is used to selectively disable (false) or enable (true) individual orders. Iforder_maskis set toNULL, all orders are active. The parameterchannel_maskcan be used similarly, but must be as long as the channelsgridwas created with has entries, orNULLto enable all channels. The valuesxi_renandxi_faccan be used to vary the renormalization and factorization from its central value, which corresponds to1.0. After convolution of the grid with the PDFs the differential cross section for each bin is written intoresults. - pineappl_
grid_ ⚠dedup_ channels - Try to deduplicate channels of
gridby detecting pairs of them that contain the same subgrids. The numerical equality is tested using a tolerance ofulps, given in units of least precision. - pineappl_
grid_ delete - Delete a grid previously created with
pineappl_grid_new. - pineappl_
grid_ ⚠delete_ bins - Deletes bins with the corresponding
bin_indices. Repeated indices and indices larger or equal the bin length are ignored. - pineappl_
grid_ ⚠evolve - Evolve a grid with an evolution operator and dump the resulting FK table.
- pineappl_
grid_ ⚠evolve_ info - Get the values of the parameters contained in evolve info.
- pineappl_
grid_ ⚠evolve_ info_ shape - Get the shape of the objects represented in the evolve info.
- pineappl_
grid_ ⚠fill Deprecated - Fill
gridfor the given momentum fractionsx1andx2, at the scaleq2for the given value of theorder,observable, andlumiwithweight. - pineappl_
grid_ ⚠fill2 - Similar to
pineappl_grid_fillbut accepts any given momentum fractions {x1, …,xn} at various energy scalesfor the given value of theorder,observable, andlumiwithweight. - pineappl_
grid_ ⚠fill_ all Deprecated - Fill
gridfor the given momentum fractionsx1andx2, at the scaleq2for the given value of theorderandobservablewithweights. The parameter of weight must contain a result for entry of the luminosity function the grid was created with. - pineappl_
grid_ ⚠fill_ all2 - Similar to
pineappl_grid_fill_allbut accepts any given momentum fractions {x1, …,xn} at various energy scalesfor the given value of theorder,observable, andlumiwithweight. - pineappl_
grid_ ⚠fill_ array Deprecated - Fill
gridwith as many points as indicated bysize. - pineappl_
grid_ ⚠fill_ array2 - Similar to
pineappl_grid_fill_arraybut accepts any given momentum fractions {x1, …,xn} at various energy scalesfor the given value of theorder,observable, andlumiwithweight. - pineappl_
grid_ ⚠key_ value Deprecated - Return the value for
keystored ingrid. Ifkeyisn’t found,NULLwill be returned. After usage the string must be deallocated usingpineappl_string_delete. - pineappl_
grid_ ⚠kinematics_ len - Get the number of different kinematics for a given Grid.
- pineappl_
grid_ ⚠lumi Deprecated - Return the luminosity function of
grid. - pineappl_
grid_ ⚠merge_ and_ delete - Merges
otherintogridand subsequently deletesother. - pineappl_
grid_ ⚠merge_ bins - Merges the bins of corresponding to the indices from the half-open interval
[from, to]into a single bin. - pineappl_
grid_ ⚠new Deprecated - Creates a new and empty grid. The creation requires four different sets of parameters:
- pineappl_
grid_ ⚠new2 - Creates a new and empty grid that can accept any number of convolutions. The creation requires the following different sets of parameters:
- pineappl_
grid_ ⚠optimize - Optimizes the grid representation for space efficiency.
- pineappl_
grid_ ⚠optimize_ using - Optimizes the grid representation for space efficiency. The parameter
flagsdetermines which optimizations are applied, seeGridOptFlags. - pineappl_
grid_ ⚠order_ count - Return the number of orders in
grid. - pineappl_
grid_ ⚠order_ params Deprecated - Write the order parameters of
gridintoorder_params. - pineappl_
grid_ ⚠order_ params2 - An extension of
pineappl_grid_order_paramsthat accounts for the order of the fragmentation logs. - pineappl_
grid_ ⚠pid_ basis - Get the particle ID basis of a Grid.
- pineappl_
grid_ ⚠read - Read a
PineAPPLgrid from a file with namefilename. - pineappl_
grid_ ⚠rotate_ pid_ basis - Change the particle ID basis of a given Grid.
- pineappl_
grid_ ⚠scale - Scale all grids in
gridbyfactor. - pineappl_
grid_ ⚠scale_ by_ bin - Scales each subgrid by a bin-dependent factor given in
factors. If a bin does not have a corresponding entry infactorsit is not rescaled. Iffactorshas more entries than there are bins the superfluous entries do not have an effect. - pineappl_
grid_ ⚠scale_ by_ order - Scales each subgrid by a factor which is the product of the given values
alphas,alpha,logxir, andlogxif, each raised to the corresponding powers for each subgrid. In addition, every subgrid is scaled by a factorglobalindependently of its order. - pineappl_
grid_ ⚠set_ key_ value Deprecated - Sets an internal key-value pair for the grid.
- pineappl_
grid_ ⚠set_ remapper - Sets a remapper for the grid. This can be used to ‘upgrade’ one-dimensional bin limits to N-dimensional ones. The new bin limits must be given in the form of tuples giving the left and right limits, and a tuple for each dimension.
- pineappl_
grid_ ⚠split_ channels - Similar to
pineappl_grid_split_channels. - pineappl_
grid_ ⚠split_ lumi Deprecated - Splits the grid such that the luminosity function contains only a single combination per channel.
- pineappl_
grid_ ⚠subgrid_ array - Get the subgrid for a given bin, channel, and order.
- pineappl_
grid_ ⚠subgrid_ node_ values - Get the nodes of the subgrid.
- pineappl_
grid_ ⚠subgrid_ shape - Get the shape of a subgrid for a given bin, channel, and order.
- pineappl_
grid_ ⚠write - Write
gridto a file with namefilename. Iffilenameends in.lz4the grid is automatically LZ4 compressed. - pineappl_
keyval_ ⚠bool Deprecated - Get the boolean-valued parameter with name
keystored inkey_vals. - pineappl_
keyval_ delete Deprecated - Delete the previously created object pointed to by
key_vals. - pineappl_
keyval_ ⚠double Deprecated - Get the double-valued parameter with name
keystored inkey_vals. - pineappl_
keyval_ ⚠int Deprecated - Get the string-valued parameter with name
keystored inkey_vals. - pineappl_
keyval_ new Deprecated - Return a pointer to newly-created
pineappl_keyvalobject. - pineappl_
keyval_ ⚠set_ bool Deprecated - Set the double-valued parameter with name
keytovalueinkey_vals. - pineappl_
keyval_ ⚠set_ double Deprecated - Set the double-valued parameter with name
keytovalueinkey_vals. - pineappl_
keyval_ ⚠set_ int Deprecated - Set the int-valued parameter with name
keytovalueinkey_vals. - pineappl_
keyval_ ⚠set_ string Deprecated - Set the string-valued parameter with name
keytovalueinkey_vals. - pineappl_
keyval_ ⚠string Deprecated - Get the int-valued parameter with name
keystored inkey_vals. - pineappl_
lumi_ ⚠add Deprecated - Adds a linear combination of initial states to the luminosity function
lumi. - pineappl_
lumi_ ⚠combinations Deprecated - Returns the number of combinations of the luminosity function
lumifor the specified entry. - pineappl_
lumi_ ⚠count Deprecated - Returns the number of channel for the luminosity function
lumi. - pineappl_
lumi_ delete Deprecated - Delete luminosity function previously created with
pineappl_lumi_new. - pineappl_
lumi_ ⚠entry Deprecated - Read out the channel with index
entryof the luminosity functionlumi. The PDG ids and factors will be copied intopdg_idsandfactors. - pineappl_
lumi_ new Deprecated - Creates a new luminosity function and returns a pointer to it. If no longer needed, the object
should be deleted using
pineappl_lumi_delete. - pineappl_
string_ ⚠delete - Deletes a string previously allocated by
pineappl_grid_key_value. Ifstringis aNULLpointer this function does nothing.
Type Aliases§
- Operator
Callback - Type alias for the operator callback