Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Defines a subset of a valarray that consists of a number of elements that are an equal distance apart and that start at a specified element.
slice( );
slice(
size_t _StartIndex,
size_t _Len,
size_t _Stride
);
Parameters
_StartIndex
The valarray index of the first element in the subset._Len
The number of elements in the subset._Stride
The distance between elements in the subset.
Return Value
The default constructor stores zeros for the starting index, total length, and stride. The second constructor stores _StartIndex for the starting index, _Len for the total length, and _Stride for the stride.
Remarks
The stride may be negative.
Example
// slice_ctor.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i;
valarray<int> va ( 20 ), vaResult;
for ( i = 0 ; i < 20 ; i+=1 )
va [ i ] = 2 * (i + 1 );
cout << "The operand valarray va is:\n( ";
for ( i = 0 ; i < 20 ; i++ )
cout << va [ i ] << " ";
cout << ")." << endl;
slice vaSlice ( 1 , 7 , 3 );
vaResult = va [ vaSlice ];
cout << "\nThe slice of valarray va is vaResult:"
<< "\nva[slice( 1, 7, 3)] = ( ";
for ( i = 0 ; i < 7 ; i++ )
cout << vaResult [ i ] << " ";
cout << ")." << endl;
}
The operand valarray va is:
( 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 ).
The slice of valarray va is vaResult:
va[slice( 1, 7, 3)] = ( 4 10 16 22 28 34 40 ).
Requirements
Header: <valarray>
Namespace: std