public member function
std::gslice::gslice
<valarray>
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:
See also
- gslice::start
- Return start of gslice (public member function)
- gslice::size
- Return sizes of gslice (public member function)
- gslice::stride
- Return strides of gslice (public member function)