Expression Templates Library (ETL)
sequence.hpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2014-2023 Baptiste Wicht
3 // Distributed under the terms of the MIT License.
4 // (See accompanying file LICENSE or copy at
5 // http://opensource.org/licenses/MIT)
6 //=======================================================================
7 
13 #pragma once
14 
15 namespace etl {
16 
20 template <typename T = double>
22  using value_type = T;
23 
24  const value_type start;
26 
27  static constexpr bool gpu_computable = false;
28 
33  explicit sequence_generator_op(value_type start = 0) : start(start), current(start) {}
34 
40  return current++;
41  }
42 
49  friend std::ostream& operator<<(std::ostream& os, const sequence_generator_op& s) {
50  return os << "[" << s.start << ",...]";
51  }
52 };
53 
54 } //end of namespace etl
Generator from a sequence.
Definition: sequence.hpp:21
static constexpr bool gpu_computable
Indicates if the operator is computable on GPU.
Definition: sequence.hpp:27
auto s(T &&value)
Force the evaluation of the given expression.
Definition: stop.hpp:18
friend std::ostream & operator<<(std::ostream &os, const sequence_generator_op &s)
Outputs the given generator to the given stream.
Definition: sequence.hpp:49
const value_type start
The beginning of the sequence.
Definition: sequence.hpp:24
T value_type
The value type.
Definition: sequence.hpp:22
Root namespace for the ETL library.
Definition: adapter.hpp:15
sequence_generator_op(value_type start=0)
Construct a new generator with the given sequence start.
Definition: sequence.hpp:33
value_type current
The current sequence element.
Definition: sequence.hpp:25
value_type operator()()
Generate a new value.
Definition: sequence.hpp:39