Open SSoelvsten opened 1 year ago
I saw the following quote on the Wikipedia article for Exclusive Or:
Since it is associative, it may be considered to be an n-ary operator which is true if and only if an odd number of arguments are true. That is, a XOR b XOR ... may be treated as XOR(a,b,...).
So, we might want to add a is_associative(op)
predicate to <adiar/internal/bool_op.h> to identify whether we actually can do this bottom-up tree accumulation (or have to do it left-to-right?).
Motivation
The end user may want to do something like the following
Optimisations
A more fancy way to do the same is with a FIFO queue for a more bottom-up tree-like approach.
In practice, Jaco had very good experience with doing the above with the Sylvan BDD package. For Adiar, this probably also will help a lot. One can further improve it by doing the following:
dd_1
anddd_2
can be garbage collected after the top-down sweep ofbdd_apply
has finished. Alternatively, usestd::move(...)
.Tasks
We should provide the fancy version above as part of Adiar's API. If one wants to save on memory, we could provide both versions (which one is chosen with an enum). The implementation of both approaches could be placed in adiar/internal/util.h or in adiar/internal/algorithms/prod2.h.
__bdd bdd_apply(generator<bdd>, op)
(and all the operator's aliases)bdd_apply(generator<bdd>, op)
and its overloads.__zdd zdd_binop(generator<zdd>, op)
(and all the operator's aliases)zdd_binop(generator<zdd>, op)
and its overloads.bdd_and
andbdd_or
functions with an iterator already exist in the API (#532). We need to useif constexpr
andstd::is_integral<IT::value_type>::value
/std::is_same<...>::value
to resolve which algorithm to run.template<typename IT> bdd bdd_apply(begin, end, op)
(and all the operator's aliases)bdd_apply(generator<bdd>, op)
and its overloads.template<typename IT> zdd zdd_binop(begin, end, op)
(and all the operator's aliases)zdd_binop(generator<zdd>, op)
and its overloads.