12 #ifndef HAMMER_MATH_HISTOGRAM
13 #define HAMMER_MATH_HISTOGRAM
53 Bin(
const Tensor& t,
bool withErrors =
false);
59 Bin(
const Serial::FBTensor* w,
const Serial::FBTensor* w2,
size_t num);
61 Bin(
const Bin& other) =
default;
63 Bin(
Bin&& other) =
default;
154 const std::string&
name()
const;
160 template <
typename... Args>
177 template <
typename... Args>
183 template <
typename... Args>
189 template <
typename... Args>
220 std::unique_ptr<Serial::FBHistogramBuilder>
write(flatbuffers::FlatBufferBuilder* msgwriter)
const;
void initHistogram()
allocate and initialize the histogram
const std::string & name() const
get the histogram name
void setDefinition(const HistogramDefinition &def)
set the dimensions of the various coordinates
Tensor _weight
tensor sum of weights
std::vector< Bin > DataType
const IndexList & dims() const
get the dimensions of all the coordinates at once
Forward declaration of serialization related typedefs and includes.
Bin class with Tensor contents.
reference operator[](PositionType pos)
Multidimensional histogram class with Tensor as cell bins.
Hammer data types declarations.
const Tensor & getWeight(Args...rest) const
get the value of a histogram bin based on an index of the bin
const Tensor & getSquaredWeight(Args...rest) const
get the value of a histogram bin based on an index of the bin
size_t getNumEvents(Args...rest) const
get the value of a histogram bin based on an index of the bin
void clear()
reset the histogram
void setDefaultValue(const Tensor &value)
set the value to be used for out-of-bounds coordinates if extrapolation is off
std::vector< BinContents > IOHistogram
size_t getNumEvents() const
the number of entries in the bin (number of times addWeight has been called)
IOHistogram evalToList(const Tensor &externalData) const
void clear()
clears the contents of the bin (including the shapes of the tensors)
Non-sparse tensor indexer.
Hammer configuration definitions.
Histogram & operator+=(const Histogram &other)
unique_ptr< Histogram > makeHistogram(const string &name, const HistogramDefinition &def, const Tensor &defaultValue)
const Tensor & getWeight() const
the sum of tensor weights contained in the bin
Bin(const Tensor &t, bool withErrors=false)
constructor based on a tensor (for determining shape and labels)
void addWeight(const Tensor &t)
add the values of a tensor to the current bin.
std::unique_ptr< Histogram > collapseIntoNew(const std::string &newName, const HistogramDefinition &newDef, const std::set< uint16_t > &collapsedIndexPositions) const
std::vector< IndexType > IndexList
std::unique_ptr< Serial::FBHistogramBuilder > write(flatbuffers::FlatBufferBuilder *msgwriter) const
write the contents of the histogram for serialization
IndexType dim(IndexType index) const
dimension of a specific coordinate
Bin & element(const IndexList &indices)
convert the indices into the position in the flattened contents into vector organized as row-major ...
Histogram definition class.
const Tensor & getSquaredWeight() const
the sum of (outer) squared tensor weights contained in the bin, or an empty tensor if the errors are ...
Multidimensional tensor class with complex numbers as elements.
Hammer histogram class template methods definitions.
size_t numValues() const
the number of elements (product of all the dimensions)
DataType::iterator iterator
Bin & operator+=(const Bin &other)
size_t _NEvents
number of entries
MultiDimensional::LabeledIndexing< MultiDimensional::AlignedIndexing > _defaultTensorIndexing
std::vector< IndexLabel > LabelsList
void clearData()
reset the histogram contents but not the shape of the histogram
Tensor _weight2
tensor sum of squared weights (in the outer square sense)
std::string _defaultTensorName
void read(const Serial::FBHistogram *msgreader, const HistogramDefinition &def)
read the contents of the histogram for serialization
Declarations for Hammer IO structs.
Histogram & operator=(const Histogram &other)=default
void fillBin(const Tensor &value, Args...rest)
set the value of a histogram bin based on the bin indices
DataType::const_iterator const_iterator
const HistogramDefinition * _definition
Log & getLog() const
logging facility
size_t rank() const
dimensionality of the histograms
Histogram operator+(const Histogram &first, const Histogram &second)
const LabelsList & getLabelVector() const
bool _initialized
whether the grid is initialized
Bin & operator=(const Bin &other)=default
virtual ~Histogram()
destructor
void setName(const std::string &name)
give the histogram a name