Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

slice


Valarray helpers

Summary

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

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <valarray>
class slice ;

Description

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.

Interface

class slice {
public:
  // constructors
  slice();
  slice(size_t, size_t, size_t);
 
  // Accessors
  size_t start() const;
  size_t size() const;
  size_t stride() const;
};

Constructors

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

Accessors

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

Example

Program Output

Warnings

If your compiler does not support namespaces, then you do not need the using declaration for std.

See Also

valarray, slice_array, gslice, gslice_array, mask_array, indirect_array



Previous fileTop of documentContentsIndexNext file
Copyright (c) 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998