Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Elisabetta Manca
    @emanca
    let me test this and I will open a PR in your repo
    thanks a lot for your help!
    Hans Dembinski
    @HDembinski
    I am not sure why, it should work without
    Elisabetta Manca
    @emanca
    uhm
    definitely it doesn't work without this:
    &operator+=(value_type arg)
    Hans Dembinski
    @HDembinski
    I stripped it down to the essentials, it does nothing but it compiles
    Elisabetta Manca
    @emanca
    yes I see
    uhm
    Hans Dembinski
    @HDembinski
    I think it would be very powerful to make a storage that uses https://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange on its elements.
    It would then automatically work with all the accumulators.
    Elisabetta Manca
    @emanca
    yes I see what you mean
    I'm trying to understand why your example works
    and I can think about your proposal
    I think it is because you made this templated
    Nope, that is not it...
    Also, upon closer inspection the idea with the atomic storage probably does not work
    In https://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange they use only atomic writes to a pointer
    Elisabetta Manca
    @emanca
    ok your implementation doesn't work if you add a line for filling the histogram:
    Hans Dembinski
    @HDembinski
    Ah
    Elisabetta Manca
    @emanca
    instead this one does work:
    adding operator+= with value_type
    Hans Dembinski
    @HDembinski
    Ok, maybe this is actually a bug in the metaprogramming
    Elisabetta Manca
    @emanca
    ok it's nice that we have solved anyways :)
    The mistake is here, it detects weight support via the expression accumulator += 0, which fails without the overload
    Elisabetta Manca
    @emanca
    ah yes I see
    Hans Dembinski
    @HDembinski
    And it worked by accident so far since weighted_sum += 0 calls weighted_sum += weighted_sum(0) which works
    While in your case it does not, you don't have a ctor which accepts a value_type
    It is a bug
    Hans Dembinski
    @HDembinski
    Hans Dembinski
    @HDembinski
    Hans Dembinski
    @HDembinski
    grafik.png
    I slept over it and read my own words more carefully. Programming with Boost sometimes feels like you are a lawyer.
    So it says here that one either needs to support an expression a(w, ...) or a += v, where w is weight_type, but v is just a number
    Hans Dembinski
    @HDembinski
    This is not wrong but incomplete. If the accumulator should be able to distinguish between filling a weight and just adding a number, one has to implement a += w and a += v. If you fill a weight into a weighted_sum, you want to add the weight squared to the sum_w2. a+=v should be implemented so that it behaves as if we added another accumulator that was filled with weights w=1. The two have a different implementation and the two signatures are used by the library to distinguish the two cases.
    Boost Histogram allows you to add an unweighted histogram to a weighted histogram, for example, and there it uses a += v.
    So it should say in the concepts that one has to implement a+=w and optionally a+=v
    Hans Dembinski
    @HDembinski
    Hans Dembinski
    @HDembinski
    @emanca https://gist.github.com/emanca/ebeda5686942e39c20910cd8c8c6baa9#file-thread_safe_withvariance-hpp-L76 Don't you have to update the old_val in the while loop as well?
    Josh Bendavid
    @bendavid
    this should already done by the compare_exchange call if it fails
    Elisabetta Manca
    @emanca
    @HDembinski, @bendavid suggested me this trick when I have setup this implementation
    Hans Dembinski
    @HDembinski
    Ah, thanks. Ok I see it in the docs.
    vakokako
    @vakokako

    Hey all,
    I want to update the histogram to new bounds, same as algorithm::shrink, but for both shrinking and growing.

    Something like shrinkOrExpand:

    auto hist = make_histogram_with(std::vector<size_t>(), axis::regular(5, 0, 10));
    
    // new histogram with bounds [4, 14):
    auto hist2 = algorithm::reduce(hist, algorithm::shrinkOrExpand(4, 13));

    What is the best way to do this?

    Hans Dembinski
    @HDembinski
    As described in my answer to boostorg/histogram#333, expanding an axis is not supported, because there is no unambiguous way to do this.
    Hans Dembinski
    @HDembinski
    If you need an axis that expands, you can use a growing axis.