libpnicore
|
index slice More...
#include <slice.hpp>
Public Member Functions | |
slice () | |
default constructor | |
slice (size_t first, size_t last, size_t stride=1) | |
standard constructor More... | |
slice (const std::initializer_list< size_t > &l) | |
construction from a initializer list More... | |
slice (size_t index) | |
construction from a single index More... | |
~slice () | |
destructor | |
slice & | operator= (const slice &s) |
copy assignment operator | |
size_t | first () const |
return the first element More... | |
size_t | last () const |
return last element More... | |
size_t | stride () const |
return stride More... | |
Private Member Functions | |
void | _check_start_stop (const exception_record &o) const |
check first and last index More... | |
void | _check_stride (const exception_record &o) const |
check stride More... | |
Private Attributes | |
size_t | _first |
first index in the slice | |
size_t | _last |
last index in the slice | |
size_t | _stride |
distance between indices | |
This types represents an index slice for an array. A slice can be used to identify an index range along a single dimensions. slice objects are of particular importance for creating array_view from mdarray instancers.
A slice includes all indices between the the first and last index of the slice where the last index is not included. A stride can be passed during construction which determines the number of steps between each subsequent element. If the stride is not 1 the last index will be adopted so that the
|
explicit |
This is the default constructor for a Slice object.
range_error | if the first index exceeds the last |
first | first index |
last | index |
stride | steps between subsequent elements |
|
explicit |
This can be used for implicit conversion which is sometimes quite useful for the creation fo array views.
! If the initializer list has only two elements they are treated as first and last element of the slice and the stride is set to 1. In the case of a three element initializer list the last element is considered as the stride of the slice.
range_error | if the first element is larger than the last |
l | initializer list |
|
explicit |
Constructor uses a single index. This constructor is equivalent to use slice(index,index+1,1).
index | single index from which to create the slice |
|
private |
This private method throws an exception if the first index of the range exceeds the last one.
range_error | if first > last |
o | signature of the origin where the error occured |
|
private |
Checks if the stride does not exceed the span of the slice. If it does an exception will be thrown.
range_error | if stride exceeds span |
o | signature of the origin where the error occured |
|
inline |
|
inline |
|
inline |