Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
valarray
classes:
gslice
gslice_array
indirect_array
mask_array
slice
slice_array
valarray
global functions:
abs
acos
asin
atan
atan2
cos
cosh
exp
log
log10
pow
sin
sinh
sqrt
tan
tanh
gslice
gslice::gslice
member functions:
gslice::size
gslice::start
gslice::stride


gslice::gslice

public member function
gslice ();
gslice (size_t start, const valarray<size_t>& lengths, const valarray<size_t>& strides);
gslice (const gslice& gslc);

gslice constructor

Constructs a gslice (generalized slice) object.

Parameters

start
Index of the first element in the generalized slice.
The index of the first element in a valarray is 0, not 1.
size_t is an unsigned integral type.
lengths
valarray object with each element representing the number of elements in each dimension of the slice.
size_t is an unsigned integral type.
strides
valarray object with each element representing the separation between the elements (dimension size).
size_t is an unsigned integral type.
gslc
gslice object (copy constructor).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// gslice example
#include <iostream>
#include <valarray>
using namespace std;
int main ()
{
  valarray<int> foo (14);
  for (int i=0; i<14; ++i) foo[i]=i;
  size_t start=1;
  size_t lengths[]= {2,3};
  size_t strides[]= {7,2};
  gslice mygslice (start,valarray<size_t>(lengths,2),valarray<size_t>(strides,2));
  valarray<int> bar = foo[mygslice];
  cout << "gslice: ";
  for (size_t n=0; n<bar.size(); n++)
	  cout << bar[n] << ' ';
  cout << endl;
  return 0;
}


Output:

gslice: 1 3 5 8 10 12

See also