Skip to content

Commit 06596ef

Browse files
committed
doc fixes
1 parent 3b2b5e3 commit 06596ef

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

doc/benchmarks.qbk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ The following plot shows results of a benchmark on a 9 GHz Macbook Pro. Random n
99
[variablelist Plot legend:
1010
[[root] [[@https://root.cern.ch ROOT classes] (`TH1I` for 1D, `TH3I` for 3D and `THnI` for 6D)]]
1111
[[py:numpy] [numpy functions ([python]`numpy.histogram` for 1D, `numpy.histogramdd` for 2D, 3D, and 6D)]]
12-
[[py:hd_sd] [[classref boost::histogram::dynamic_histogram] with [classref boost::histogram::adaptive_storage], called from Python]]
13-
[[hs_ss] [[classref boost::histogram::static_histogram] with [classref boost::histogram::array_storage<int>]]]
14-
[[hs_sd] [[classref boost::histogram::static_histogram] with [classref boost::histogram::adaptive_storage]]]
15-
[[hd_ss] [[classref boost::histogram::dynamic_histogram] with [classref boost::histogram::array_storage<int>]]]
16-
[[hd_sd] [[classref boost::histogram::dynamic_histogram] with [classref boost::histogram::adaptive_storage]]]
12+
[[py:hd_sd] [[funcref boost::histogram::make_dynamic_histogram dynamic histogram] with [classref boost::histogram::adaptive_storage], called from Python]]
13+
[[hs_ss] [[funcref boost::histogram::make_static_histogram static histogram] with [classref boost::histogram::array_storage<int>]]]
14+
[[hs_sd] [[funcref boost::histogram::make_static_histogram static histogram] with [classref boost::histogram::adaptive_storage]]]
15+
[[hd_ss] [[funcref boost::histogram::make_dynamic_histogram dynamic histogram] with [classref boost::histogram::array_storage<int>]]]
16+
[[hd_sd] [[funcref boost::histogram::make_dynamic_histogram dynamic histogram] with [classref boost::histogram::adaptive_storage]]]
1717
]
1818

19-
[classref boost::histogram::static_histogram] is always faster than [classref boost::histogram::dynamic_histogram] and safer to use, as more checks are done at compile time. It is recommended when working in C++ only. [classref boost::histogram::adaptive_storage] is faster than [classref boost::histogram::array_storage] for histograms with many bins, because it uses the cache more effectively due to its smaller memory consumption per bin. If the number of bins is small, it is slower because of overhead of handling memory in a dynamic way.
19+
A [classref boost::histogram::make_static_histogram static histogram] is always faster than [classref boost::histogram::make_dynamic_histogram dynamic histogram] and safer to use, as more checks are done at compile time. It is recommended when working in C++ only. [classref boost::histogram::adaptive_storage] is faster than [classref boost::histogram::array_storage] for histograms with many bins, because it uses the cache more effectively due to its smaller memory consumption per bin. If the number of bins is small, it is slower because of overhead of handling memory in a dynamic way.
2020

2121
The histograms in this library are mostly faster than the competition, in some cases by a factor of 2. Simultaneously they are more flexible, since binning strategies can be customised. The Python-wrapped histogram is slower than numpy's own specialized function for 1D, but beats numpy's multi-dimensional histogramming function by a factor 2 to 3.
2222

doc/concepts.qbk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ An `axis_type` converts input values into bin indices.
88

99
An `axis_type` is required to:
1010

11-
* derive publically from [classref boost::histogram::axis::axis_base] or [classref boost::histogram::axis::axis_base_uoflow]
11+
* derive publically from [classref boost::histogram::axis::labeled_base] and [classref boost::histogram::axis::iterator_mixin]
1212
* be default/copy/move constructable
1313
* be copy/move assignable
1414
* be equal comparable
@@ -37,6 +37,7 @@ A `storage_type` is required to:
3737
* be default/copy/move constructable
3838
* be copy/move assignable
3939
* be equal comparable
40+
* have a nested type `allocator_type`
4041
* have a nested type `element_type`, which represent the bin count
4142
* have a nested type `const_reference`, its const reference version
4243
* have a constructor `storage_type(std::size_t n)`, which prepares the storage of `n` bins.

doc/guide.qbk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ In addition to the required parameters for an axis, you can assign an optional l
6161

6262
Without the labels it would be difficult to remember which axis was covering which quantity, because they look the same otherwise. Labels are the only axis property that can be changed later. Axes objects with different label do not compare equal with `operator==`.
6363

64-
By default, additional under- and overflow bins are added automatically for each axis where that makes sense. If you create an axis with 20 bins, the histogram will actually have 22 bins along that axis. The two extra bins are generally very good to have, as explained in [link histogram.rationale.uoflow the rationale]. If you are certain that the input cannot exceed the axis range, you can disable the extra bins to save memory. This is done by passing the enum value [enumref boost::histogram::axis::uoflow uoflow::off] to the axis constructor:
64+
By default, additional under- and overflow bins are added automatically for each axis where that makes sense. If you create an axis with 20 bins, the histogram will actually have 22 bins along that axis. The two extra bins are generally very good to have, as explained in [link histogram.rationale.uoflow the rationale]. If you are certain that the input cannot exceed the axis range, you can disable the extra bins to save memory. This is done by passing the enum value [enumref boost::histogram::axis::uoflow_type uoflow_type::off] to the axis constructor:
6565

6666
[import ../examples/guide_axis_with_uoflow_off.cpp]
6767
[guide_axis_with_uoflow_off]
@@ -95,7 +95,7 @@ Why weighted increments are sometimes useful, especially in a scientific context
9595

9696
After the histogram has been filled, you want to access the counts per bin at some point. You may want to visualize the counts, or compute some quantities like the mean from the data distribution approximated by the histogram.
9797

98-
To access each bin, you use a multi-dimensional index, which consists of a sequence of bin indices for each axes in order. You can use this index to access the value for each and the variance estimate, using the method `histogram::bin(...)`. It accepts integral indices, one for each axis of the histogram, and returns the associated bin counter type. The bin counter type then allows you to access the count value and its variance.
98+
To access each bin, you use a multi-dimensional index, which consists of a sequence of bin indices for each axes in order. You can use this index to access the value for each and the variance estimate, using the method `histogram::at(...)` (in analogy to `std::vector::at`). It accepts integral indices, one for each axis of the histogram, and returns the associated bin counter type. The bin counter type then allows you to access the count value and its variance.
9999

100100
The calls are demonstrated in the next example.
101101

examples/guide_access_bin_counts.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int main() {
2828
<< std::endl;
2929
// prints: 1 4 9 16
3030

31-
// you can also make a copy of the type that holds the bin count
31+
// this is more efficient when you want to query value and variance
3232
auto c11 = h.at(1, 1);
3333
std::cout << c11.value() << " " << c11.variance() << std::endl;
3434
// prints: 4 16
@@ -39,11 +39,24 @@ int main() {
3939
std::cout << h.at(idx).value() << std::endl;
4040
// prints: 2
4141

42-
// histogram also provides extended iterators
42+
// histogram also provides bin iterators
4343
auto sum = std::accumulate(h.begin(), h.end(),
4444
typename decltype(h)::element_type(0));
4545
std::cout << sum.value() << " " << sum.variance() << std::endl;
4646
// prints: 10 30
47+
48+
// bin iterators are fancy iterators with extra methods
49+
for (auto it = h.begin(), end = h.end(); it != end; ++it) {
50+
const auto x = *it;
51+
std::cout << it.idx(0) << " " << it.idx(1) << ": "
52+
<< x.value() << " " << x.variance() << std::endl;
53+
}
54+
// prints: (iteration order is an implementation detail, don't rely on it)
55+
// 0 0: 1 1
56+
// 1 0: 3 9
57+
// ...
58+
// 2 -1: 0 0
59+
// -1 -1: 0 0
4760
}
4861

4962
//]

examples/guide_fill_histogram.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ int main() {
2424
// functional-style processing is also supported
2525
std::vector<std::pair<int, double>> input_data{
2626
{0, 1.2}, {2, 3.4}, {4, 5.6}};
27-
// Note that std::for_each takes the functor by value, thus it makes a
28-
// potentially expensive copy of your histogram. Passing freshly created
29-
// histograms is ok, though, because of return-value-optimization
27+
// std::for_each takes the functor by value, thus it potentially makes
28+
// expensive copies of the histogram, but modern compilers are usually smart
29+
// enough to avoid the superfluous copies
3030
auto h2 =
3131
std::for_each(input_data.begin(), input_data.end(),
3232
bh::make_static_histogram(bh::axis::regular<>(8, 0, 4),

examples/guide_make_dynamic_histogram.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main() {
1919

2020

2121
// make_dynamic_histogram copies axis objects; to instead move the whole axis
22-
// vector into the histogram, create a histogram instance directly like so
22+
// vector into the histogram, create a histogram instance directly
2323
auto h2 = bh::histogram<decltype(v)>(std::move(v));
2424

2525
// do something with h2

0 commit comments

Comments
 (0)