Ranges
-
inline friend range_t operator+(T shift, const range_t &other)
Shift a range to the right.
- Parameters:
shift – The amount to shift, in units of the range step size.
other – The range to shift.
- Returns:
The shifted range. After shifting,
other[i]becomesother[i] + shift*other.step().
-
inline friend range_t operator-(T shift, const range_t &other)
Shift a range to the left.
- Parameters:
shift – The amount to shift, in units of the range step size.
other – The range to shift.
- Returns:
The shifted range. After shifting,
other[i]becomesother[i] - shift*other.step().
-
inline friend range_t operator|(const range_t &lhs, T rhs)
Append an element to a range.
- Parameters:
lhs – The range to which to append.
rhs – A range element. Must be equal to
lhs.to(), that is, the element immediately following the last element oflhsduring iteration.
- Returns:
The combined range.
-
inline friend range_t operator|(T lhs, const range_t &rhs)
Prepend an element to a range.
- Parameters:
lhs – A range element. Must be equal to
rhs.from()-rhs.step(), that is, the element immediately preceding the first element ofrhsduring iteration.rhs – The range to which to prepend.
- Returns:
The combined range.
-
template<typename T, typename = detail::enable_if_numeric<T>>
auto range(T to) The range
[0,to).- Parameters:
to – The value one higher than the last element in the range. This is equal to the number of elements in the range. Must be an integral or enum type.
- Returns:
Range object, of the same type as
to, that can be used to index a tensor.
-
template<typename T, typename U, typename = detail::enable_if_numeric<T, U>>
auto range(T from, U to) The range
[from,to).- Parameters:
from – The value of the first element in the range. Must be an integral or enum type.
to – The value one higher than the last element in the range. The number of elements is equal to
to-from. Must be an integral or enum type.
- Returns:
Range object, whose type is the common arithmetic type of
fromandto, that can be used to index a tensor.
-
template<typename T, typename U, typename V, typename = detail::enable_if_numeric<T, U, V>>
auto range(T from, U to, V delta) The range
[from,to)with spacingdelta.- Parameters:
from – The value of the first element in the range. Must be an integral or enum type.
to – The value higher than all elements in the range. Must be an integral or enum type.
delta – The distance between consecutive elements in the range. The number of elements is equal to
ceil((to-from)/delta). Must be an integral or enum type.
- Returns:
Range object, whose type is the common arithmetic type of
from,to, anddelta, that can be used to index a tensor.
-
template<typename T, typename U, typename = detail::enable_if_numeric<T, U>>
auto rangeN(T from, U N) The range
[from,from+N).- Parameters:
from – The value of the first element in the range. Must be an integral or enum type.
N – The number of elements in the range. Must be an integral or enum type.
- Returns:
Range object, whose type is the common arithmetic type of
fromandN, that can be used to index a tensor.
-
template<typename T, typename U, typename V, typename = detail::enable_if_numeric<T, U, V>>
auto rangeN(T from, U N, V delta) The range
[from,from+N*delta)with spacingdelta.- Parameters:
from – The value of the first element in the range. Must be an integral or enum type.
N – The number of elements in the range. Must be an integral or enum type.
delta – The distance between consecutive elements in the range. Must be an integral or enum type.
- Returns:
Range object, whose type is the common arithmetic type of
from,N, anddelta, that can be used to index a tensor.
-
template<typename T, typename = detail::enable_if_numeric<T>>
auto reversed_range(T to) The range
[0,to)in reverse order.- Parameters:
to – The value one higher than the first element in the range. This is equal to the number of elements in the range. Must be an integral or enum type.
- Returns:
Range object, of the same type as
to, that can be used to index a tensor.
-
template<typename T, typename U, typename = detail::enable_if_numeric<T, U>>
auto reversed_range(T from, U to) The range
[from,to)in reverse order.- Parameters:
from – The value of the last element in the range. Must be an integral or enum type.
to – The value one higher than the first element in the range. The number of elements is equal to
to-from. Must be an integral or enum type.
- Returns:
Range object, whose type is the common arithmetic type of
fromandto, that can be used to index a tensor.
-
template<typename T, typename U, typename V, typename = detail::enable_if_numeric<T, U, V>>
auto reversed_range(T from, U to, V delta) The range
[from,to)with spacingdeltain reverse order.- Parameters:
from – The value of the last element in the range. Must be an integral or enum type.
to – The value one higher than the first element in the range. Must be an integral or enum type.
delta – The distance between consecutive elements in the range. The number of elements is equal to
ceil(to-from)/delta). Must be an integral or enum type.
- Returns:
Range object, whose type is the common arithmetic type of
from,to, anddelta, that can be used to index a tensor.
-
template<typename T, typename U, typename = detail::enable_if_numeric<T, U>>
auto reversed_rangeN(T to, U N) The range
[to-N,to)in reverse order.- Parameters:
to – The value one larger than the first element in the range. Must be an integral or enum type.
N – The number of elements in the range. Must be an integral or enum type.
- Returns:
Range object, whose type is the common arithmetic type of
fromandN, that can be used to index a tensor.
-
template<typename T, typename U, typename V, typename = detail::enable_if_numeric<T, U, V>>
auto reversed_rangeN(T to, U N, V delta) The range
[to-N*delta,to)with spacingdeltain reverse order.- Parameters:
to – The value one larger than the first element in the range. Must be an integral or enum type.
N – The number of elements in the range. Must be an integral or enum type.
delta – The distance between consecutive elements in the range. Must be an integral or enum type.
- Returns:
Range object, whose type is the common arithmetic type of
fromandN, that can be used to index a tensor.