Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide


Library:  Numerics

Does not inherit

Local Index



A numeric array class for representing a BLAS-like slice from an array


#include <valarray>

namespace std {
  class slice ;


The valarray helper class slice allows you to represent a BLAS-like slice from an array. A BLAS slice contains a starting index, a length, and a stride. The index indicates the first element in the slice, the length determines the number of elements, and the stride indicates the interval between elements in the original array. For instance, the slice (1,3,2) applied to the array (1,2,3,4,5,6,7) produces the array (2,4,6).

When applied to a valarray using the slice subscript operator (see valarray) a slice produces a slice_array. The slice_array gives a view into the original valarray that is tailored to match parameters of the slice. The elements in a slice_array are references to the elements in the original array. This means you need to explicitly copy the slice_array into another valarray in order to have a distinct array.



slice(size_t start, size_t length, size_t stride);
slice(const slice&)


size_t start() const;
size_t size() const;
size_t stride() const;


See Also

valarray, slice_array, gslice, gslice_array, mask_array, indirect_array

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 26.3.4

Previous fileTop of DocumentContentsIndex pageNext file