Giter Site home page Giter Site logo

Comments (2)

HDembinski avatar HDembinski commented on June 6, 2024

Related #336

from histogram.

HDembinski avatar HDembinski commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.