diff --git a/examples/object-oriented-cpp/Makefile b/examples/object-oriented-cpp/Makefile index af948c23..bbcd2ffb 100644 --- a/examples/object-oriented-cpp/Makefile +++ b/examples/object-oriented-cpp/Makefile @@ -3,7 +3,7 @@ CXXFLAGS = -std=c++11 -Wall -Wextra -O3 PINEAPPL_DEPS != pkg-config --cflags --libs pineappl_capi LHAPDF_DEPS != pkg-config --cflags --libs lhapdf -dyaa: dyaa.cpp PineAPPL.hpp +dyaa: dyaa.cpp $(CXX) $(CXXFLAGS) $< $(PINEAPPL_DEPS) $(LHAPDF_DEPS) -o $@ PHONY: clean diff --git a/pineappl_capi/Cargo.toml b/pineappl_capi/Cargo.toml index 09fce3d5..8bb2fa96 100644 --- a/pineappl_capi/Cargo.toml +++ b/pineappl_capi/Cargo.toml @@ -20,4 +20,7 @@ itertools = "0.10.1" capi = [] [package.metadata.capi] -min_version = "0.6.16+cargo-0.45" +min_version = "0.9.0" + +[package.metadata.capi.install.include] +asset = [{from = "include/PineAPPL.hpp"}] diff --git a/examples/object-oriented-cpp/PineAPPL.hpp b/pineappl_capi/include/PineAPPL.hpp similarity index 84% rename from examples/object-oriented-cpp/PineAPPL.hpp rename to pineappl_capi/include/PineAPPL.hpp index f27dbb9f..56123711 100644 --- a/examples/object-oriented-cpp/PineAPPL.hpp +++ b/pineappl_capi/include/PineAPPL.hpp @@ -1,6 +1,5 @@ /** - * @file PineAPPL.hpp - * @brief object oriented interface to PineAPPL + * @brief Object oriented interface to PineAPPL. */ #ifndef PineAPPL_HPP_ #define PineAPPL_HPP_ @@ -13,16 +12,16 @@ #include #include -/** @brief object oriented interface to PineAPPL */ +/** @brief Object oriented interface to PineAPPL. */ namespace PineAPPL { /** @brief Key-value storage for passing optional information during grid - * creation */ + * creation. */ struct KeyVal { - /** @brief underlying raw object */ + /** @brief Underlying raw object. */ pineappl_keyval *raw; - /** @brief constructor */ + /** @brief Constructor. */ KeyVal() : raw(pineappl_keyval_new()) {} KeyVal(const KeyVal &) = delete; @@ -33,10 +32,10 @@ struct KeyVal { KeyVal &operator=(KeyVal &&) = delete; - /** @brief destructor */ + /** @brief Destructor. */ ~KeyVal() { pineappl_keyval_delete(this->raw); } - /** @name setter */ + /** @name Setter. */ ///@{ void set_double(const std::string &key, const double value) const { pineappl_keyval_set_double(this->raw, key.c_str(), value); @@ -52,7 +51,7 @@ struct KeyVal { } ///@} - /** @name getter */ + /** @name Getter. */ ///@{ double get_double(const std::string &key) const { return pineappl_keyval_double(this->raw, key.c_str()); @@ -69,24 +68,24 @@ struct KeyVal { ///@} }; -/** @brief Entry in luminosity function */ +/** @brief Entry in luminosity function. */ struct LumiEntry { - /** @brief first parton id */ + /** @brief First parton id. */ std::int32_t pid1; - /** @brief second parton id */ + /** @brief Second parton id. */ std::int32_t pid2; - /** @brief relative weight */ + /** @brief Relative weight. */ double weight; }; -/** @brief Luminosity function */ +/** @brief Luminosity function. */ struct Lumi { - /** @brief underlying raw object */ + /** @brief Underlying raw object. */ pineappl_lumi *raw; - /** @brief constructor */ + /** @brief Constructor. */ Lumi() : raw(pineappl_lumi_new()) {} Lumi(const Lumi &) = delete; @@ -97,14 +96,14 @@ struct Lumi { Lumi &operator=(Lumi &&) = delete; - /** @brief destructor */ + /** @brief Destructor. */ ~Lumi() { pineappl_lumi_delete(this->raw); } - /** @brief number of elements */ + /** @brief Number of elements. */ std::size_t count() const { return pineappl_lumi_count(this->raw); } /** - * @brief add a luminosity function + * @brief Add a luminosity function. * @param c luminosity function */ void add(const std::vector &c) const { @@ -146,13 +145,14 @@ struct Order { std::uint32_t logxif; }; +/** @brief The central grid object. */ struct Grid { - /** @brief underlying raw object */ + /** @brief Underlying raw object. */ pineappl_grid *raw; /** - * @brief constructor + * @brief Constructor. * @param lumi luminosity * @param orders orders * @param bin_limits bin limits @@ -184,11 +184,11 @@ struct Grid { Grid &operator=(Grid &&) = delete; - /** @brief destructor */ + /** @brief Destructor. */ ~Grid() { pineappl_grid_delete(this->raw); } /** - * @brief Number of orders + * @brief Number of orders. * @return number of orders */ std::size_t order_count() const { @@ -196,13 +196,13 @@ struct Grid { } /** - * @brief Number of bins + * @brief Number of bins. * @return number of bins */ std::size_t bin_count() const { return pineappl_grid_bin_count(this->raw); } /** - * @brief Fill grid for the given parameters + * @brief Fill grid for the given parameters. * @param x1 first momentum fraction * @param x2 second momentum fraction * @param q2 scale @@ -218,7 +218,7 @@ struct Grid { } /** - * @brief perform a convolution of the grid with PDFs + * @brief Perform a convolution of the grid with PDFs. * @param pdg_id hadron ID * @param pdf PDF * @param xi_ren renormalization scale variation @@ -260,7 +260,7 @@ struct Grid { } /** - * @brief Write grid to file + * @brief Write grid to file. * @param filename file name */ void write(const std::string &filename) const { @@ -268,7 +268,7 @@ struct Grid { } /** - * @brief Set a metadata entry + * @brief Set a metadata entry. * @param key key * @param value value */ @@ -277,7 +277,7 @@ struct Grid { } /** - * @brief Get a metadata entry + * @brief Get a metadata entry. * @param key key * @return value */ @@ -288,6 +288,22 @@ struct Grid { pineappl_string_delete(value); return res; } + + /** + * @brief Scale grid with a number. + * This multiplies all subgrids with the given number. + * @param s factor + */ + void scale(const double s) const { + pineappl_grid_scale(this->raw, s); + } + + /** + * @brief Optimizes the grid representation for space efficiency. + */ + void optimize() const { + pineappl_grid_optimize(this->raw); + } }; } // namespace PineAPPL