slice::stride
查找元素之间的距离在 valarray 切片。
size_t stride( ) const;
返回值
元素之间的距离在 valarray 切片。
示例
// slice_stride.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i;
size_t strideVAR;
valarray<int> va ( 20 ), vaResult;
for ( i = 0 ; i < 20 ; i += 1 )
va [ i ] = 3 * ( i + 1 );
cout << "The operand valarray va is:\n ( ";
for ( i = 0 ; i < 20 ; i++ )
cout << va [ i ] << " ";
cout << ")." << endl;
slice vaSlice ( 4 , 5 , 3 );
vaResult = va [ vaSlice ];
cout << "The slice of valarray va is vaResult = "
<< "va[slice( 4, 5, 3)] =\n ( ";
for ( i = 0 ; i < 5 ; i++ )
cout << vaResult [ i ] << " ";
cout << ")." << endl;
strideVAR = vaSlice.stride ( );
cout << "The stride of slice vaSlice is: "
<< strideVAR << "." << endl;
}
要求
Header: <valarray>
命名空间: std