Comments (2)
Related #336
from histogram.
Prototype for experimenting
#include <boost/histogram.hpp>
#include <boost/histogram/ostream.hpp>
#include <boost/rational.hpp>
#include <iostream>
int main() {
namespace bh = boost::histogram;
struct axis {
using value_type = boost::rational<int>;
using index_type = bh::axis::index_type;
index_type num_;
value_type offset_;
value_type scale_;
axis(index_type n, value_type a, value_type b) :
num_{n}, offset_{a}, scale_{rat{n} / (b - a)} {}
index_type index(const value_type& x) const {
const auto i = boost::rational_cast<index_type>(scale_ * (x - offset_));
return i >= -1 ? (i < num_ ? i : num_) : -1;
}
value_type value(index_type i) const {
return i / scale_ + offset_;
}
index_type size() const { return num_; }
static constexpr auto options() { return bh::axis::option::underflow | bh::axis::option::overflow; }
};
auto h = bh::make_histogram(axis{10, 0, 5});
h(-1);
h(1);
h(2);
std::cout << h << std::endl;
}
from histogram.
Related Issues (20)
- storage_adaptor<std::vector> missing efficient move assignment from std::vector HOT 4
- Fuzzy testing of index and value of regular axis
- windows.h illegally uses `#define small char`, explore possible work-arounds
- Division support for weighted storages HOT 5
- Fix MacOS CI
- Add collector accumulator HOT 1
- Confusing error on `make_histogram(axis::integer(0, 1), dense_storage())`
- Extend arithmetic operator support for accumulators
- Sum segfault when mixing empty growable axes with other axes HOT 2
- BLOSC storage HOT 1
- indexed(histogram) not usable with ranges HOT 3
- Extend fraction to weighted samples HOT 1
- boost::histogram::axis::variant, allow users to choose between sorted_array+std::lower_bound and eytzinger_layout+eytzinger_binary_search HOT 14
- Boost.Histogram 1.81.0: Test failed to be built with gcc-12.2.0 HOT 6
- Introducing `variable_t` and similar types for convenience HOT 9
- axes should provide strong exception guarantee for metadata HOT 10
- Improve numerical accuracy of circular axis HOT 3
- Sparse histograms and maped-based storage HOT 10
- CMake Warning from boostorg super project cmake
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from histogram.