Namespaces
Variants
Views
Actions

std::gslice

From cppreference.com
< cpp‎ | numeric‎ | valarray
Revision as of 07:35, 25 January 2012 by Cubbi (Talk | contribs)

Template:cpp/numeric/valarray/sidebar

Defined in header <valarray>
class gslice;

std::gslice is the selector class that identifies a subset of Template:cpp indices defined by a multi-level set of strides and sizes. Objects of type std::gslice can be used as indices with valarray's operator[] to select, for example, columns of a multidimensional array represented as a valarray.

Given the starting value s, a list of strides ij and a list of sizes dj, a std::gslice constructed from these values selects the set of indices kj=s+Σj(ijdj).

For example, a gslice with starting index 3, strides {19,4,1} and lengths {2,4,3} generates the following set of indices: Template:cpp

It is possible to construct std::gslice objects that select some indices more than once: if the above example used the strides {1,1,1} , the indices would have been {3, 4, 5, 4, 5, 6, ...} . Such gslices may only be used as arguments to the const version of std::valarray::operator[], otherwise the behavior is undefined.

Member functions

constructs a gslice
(public member function)
accesses the start of the gslice
(public member function)
accesses the array of strides of the gslice
(public member function)
accesses the array of sizees of the gslice
(public member function)

Example

Template:example cpp

See also

Template:cpp/numeric/valarray/dcl list operator atTemplate:cpp/numeric/valarray/dcl list sliceTemplate:cpp/numeric/valarray/dcl list gslice array