20 #ifndef __TPIE_PIPELINING_NUMERIC_H__
21 #define __TPIE_PIPELINING_NUMERIC_H__
24 #include <tpie/pipelining/node.h>
25 #include <tpie/pipelining/pipe_base.h>
26 #include <tpie/pipelining/factory_helpers.h>
30 namespace pipelining {
34 template <
typename dest_t>
39 inline linear_t(dest_t dest, item_type factor, item_type term) : factor(factor), term(term), dest(std::move(dest)) {
41 set_name(
"Linear transform", PRIORITY_INSIGNIFICANT);
43 inline void push(
const item_type & item) {
44 dest.push(item*factor+term);
47 item_type factor, term;
51 template <
typename dest_t>
56 range_t(dest_t dest, item_type from, item_type to, item_type increment) : from(from), to(to), increment(increment), dest(std::move(dest)) {}
59 stream_size_type items = (from - to) / increment;
64 virtual void go()
override {
65 for (item_type i=from; i < to; i += increment) {
72 item_type from, to, increment;
85 inline pipe_middle<factory<bits::linear_t, T, T> >
91 inline pipe_begin<factory<bits::range_t, T, T, T> >
92 range(T from, T to, T increment = 1) {
93 return factory<bits::range_t, T, T, T>(from, to, increment);
virtual void go() override
For initiator nodes, execute this phase by pushing all items to be pushed.
void add_push_destination(const node_token &dest)
Called by implementers to declare a push destination.
Class to deduce the item_type of a node of type T.
void forward(std::string key, T value, memory_size_type k=std::numeric_limits< memory_size_type >::max())
Called by implementers to forward auxiliary data to successors.
void set_name(const std::string &name, priority_type priority=PRIORITY_USER)
Set this node's name.
void propagate()
Propagate stream metadata.
void step(stream_size_type steps=1)
Step the progress indicator.
pipe_middle< factory< bits::linear_t, T, T > > linear(T factor, T term)
A pipelining node that transforms the items by applying a linear function to them.
Node factory for variadic argument generators.
void set_steps(stream_size_type steps)
Called by implementers that intend to call step().