mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-11 05:07:58 +00:00
46 lines
1.6 KiB
Plaintext
46 lines
1.6 KiB
Plaintext
[section:getting_started Getting started]
|
|
|
|
To get you started quickly, here are some heavily commented examples to copy paste from. If you prefer a more traditional, structured exposition, check out the [link histogram.guide full user guide].
|
|
|
|
[section Make and use a static 1d-histogram in C++]
|
|
|
|
If possible, use the static histogram. It is faster and user errors are caught at compile time.
|
|
|
|
[import ../examples/getting_started_listing_01.cpp]
|
|
[getting_started_listing_01]
|
|
|
|
[endsect]
|
|
|
|
[section Make and use a dynamic 3d-histogram in C++]
|
|
|
|
Dynamic histograms are a bit slower than static histograms, but still faster than other libraries. Use a dynamic histogram when you only know at runtime which and how many axis are going to be used, for example, because you wrote a graphical user interface that uses Boost.Histogram underneath.
|
|
|
|
[import ../examples/getting_started_listing_02.cpp]
|
|
[getting_started_listing_02]
|
|
|
|
[note
|
|
If you care about maximum performance: In this example, `axis::category<std::string>` is used with two string labels "red" and "blue". It is faster to use an enum, `enum { red, blue };` and a `axis::category<>` axis.
|
|
]
|
|
|
|
[endsect]
|
|
|
|
[section Make and use a 2d-histogram in Python]
|
|
|
|
You need to build the library with Numpy support to run this example.
|
|
|
|
[import ../examples/getting_started_listing_03.py]
|
|
[getting_started_listing_03]
|
|
|
|
[endsect]
|
|
|
|
[section Make and use a 1d-histogram in Python without Numpy]
|
|
|
|
Building the library with Numpy support is highly recommended, but here is an example on how to use the library without Numpy support for completeness.
|
|
|
|
[import ../examples/getting_started_listing_04.py]
|
|
[getting_started_listing_04]
|
|
|
|
[endsect]
|
|
|
|
[endsect]
|