MADNESS
0.10.1
|
A slice defines a sub-range or patch of a dimension. More...
#include <slice.h>
Public Member Functions | |
Slice () | |
Slice (long s, long e, long stp=1) | |
Slice & | operator= (const Slice &s) |
template<typename Archive > | |
void | serialize (Archive &ar) |
Public Attributes | |
long | end |
long | start |
long | step |
A slice defines a sub-range or patch of a dimension.
The slice Slice(start,end,step)
defines the subvector
with indices as if generated from these loops
Note that start
and end
are inclusive, unlike the Python convention of specifying end+1 (note that we cannot do this easily in C/C++ unless we also define a special value to indicate the end of a dimension of unknown size).
Negative values for start
or end
(similar to Python) are relative to the end of the (possibly unknown) dimension. E.g.,
end=-1
is equivalent to end=dim-1
start=-4
is equivalent to start=dim-4
step=0
and start==end
implies dimension will be eliminated when the slice is used to index a tensor<=
or >=
bounds in the loops specified above.Special slices have been defined as constants
_
(1 underscore) = Slice
(0,-1,1) = full slice in current order___
(3 underscores) = Array of Slices with value _
so that t(___)
will generate an assignable view of the entire tensor t
.Slice
(-1,0,-1) = full dimension reversedSlice()
— full slice in current orderSlice
(0,-1,1) — full slice in current orderSlice(3,3,0)
— eliminate this dimension setting index=3 (step=0)Slice(3,3,1)
— reduce a dimension to length 1 using index=3 (step=1)Slice
(-1,0,-1) — reverse a dimensionSlice
(0,-1,2) — use all even numbered elementsSlice
(1,-1,2) — use all odd numbered elements
|
inline |
|
inline |
|
inline |
long madness::Slice::end |
Referenced by operator=(), and serialize().
long madness::Slice::start |
Referenced by operator=(), and serialize().
long madness::Slice::step |
Referenced by operator=(), and serialize().