gslice Class Reference
List of all members.
Detailed Description
Generalized slice.
Represents a generalized slice out of an array. It specifies a starting index, a set of lengths and a set of strides; the number of lengths shall equal the number of strides. The gslice is useful for building multidimensional arrays out of the one-dimensional stdext::valarray. Used by stdext::term to construct a stdext::impl::gslice_term.
In order to step through each element selected by a gslice:
- Suppose size and stride have n elements.
- Make index with n elements, all set to 0.
- Increment the last index. Each index [i] may range from 0 to size [i] - 1, and if incrementing index [i] would exceed that range, set to 0 and increment index [i - 1] instead.
- The actual address is start + sum of index [i] * stride [i] for all i.
An example that appears in the Standard:
- Suppose start = 3, length = {2, 4, 3}, stride = {19, 4, 1}.
- Make index with 3 elements.
- Increment the last index. This yields {0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {0, 1, 0}, {0, 1, 1}, {0, 1, 2}, {0, 2, 0}, {0, 2, 1}, {0, 2, 2}, {0, 3, 0}, {0, 3, 1}, {0, 3, 2}, {1, 0, 0}, {1, 0, 1} ... The actual addresses are then: 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17, 22, 23 ...
- Header:
- #include <macstl/valarray.h>
|
Public Member Functions |
| gslice (std::size_t start, const valarray< std::size_t > &length, const valarray< std::size_t > &stride) |
| Constructs a gslice with start, a set of length and a set of stride.
|
| gslice () |
| Constructs a degenerate slice.
|
impl::array_term< std::size_t > | size () const |
| Gets the lengths of the gslice.
|
std::size_t | start () const |
| Gets the start index of the gslice.
|
impl::array_term< std::size_t > | stride () const |
| Gets the strides of the gslice.
|
Generated on Mon Jan 31 12:18:02 2005 for macstl by doxygen 1.4.0