gslice::start
尋找一般切割的起始索引valarray。
size_t start( ) const;
傳回值
一般的扇區起始索引valarray。
範例
// gslice_start.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 ] = i;
cout << "The operand valarray va is:\n ( ";
for ( i = 0 ; i < 20 ; i++ )
cout << va [ i ] << " ";
cout << ")." << endl;
valarray<size_t> Len ( 2 ), Stride ( 2 );
Len [0] = 4;
Len [1] = 4;
Stride [0] = 7;
Stride [1] = 4;
gslice vaGSlice ( 0, Len, Stride );
vaResult = va [ vaGSlice ];
size_t vaGSstart = vaGSlice.start ( );
cout << "The valarray for vaGSlice is vaResult:"
<< "\n va[vaGSlice] = ( ";
for (i = 0 ; i < 8 ; i++ )
cout << vaResult [ i ] << " ";
cout << ")." << endl;
cout << "The index of the first element of vaResult is: "
<< vaGSstart << "." << endl;
}
需求
標題: <valarray>
命名空間: std