The Wayback Machine - https://web.archive.org/web/20180506061434/http://pt.cppreference.com:80/w/cpp/numeric/valarray/slice
Espaços nominais
Variantes
Acções

std::slice

Da cppreference.com
< cpp‎ | numeric‎ | valarray

 
 
Biblioteca numéricos
Funções matemáticas comuns
De ponto flutuante ambiente
Números complexos
Matrizes numéricas
Pseudo-aleatório de geração de números
Tempo de compilação aritmética racional(C++11)
Genéricos operações numéricas
Original:
Generic numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iota(C++11)
accumulate
inner_product
adjacent_difference
partial_sum
 
 
Defined in header <valarray>
class slice;
std::slice é a classe selector que identifica um subconjunto de std::valarray semelhante a fatia BLAS. Um objecto da std::slice tipo prende três valores: o índice de partida, o passo, e o número total de valores no subconjunto. Objectos de std::slice tipo podem ser usados ​​como índices com operator[] valarray de.
Original:
std::slice is the selector class that identifies a subset of std::valarray similar to BLAS slice. An object of type std::slice holds three values: the starting index, the stride, and the total number of values in the subset. Objects of type std::slice can be used as indexes with valarray's operator[].
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Funções de membro

constrói uma fatia
Original:
constructs a slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)
acede ao início da fatia
Original:
accesses the start of the slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)
acede ao tamanho da fatia
Original:
accesses the size of the slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)
acessa o tranco da fatia
Original:
accesses the stride of the slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)

[editar]Exemplo

Barebones classe Matrix valarray apoiado com uma função traçar cálculo .
Original:
Barebones valarray-backed Matrix class with a traçar calculating function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>#include <valarray>class Matrix {std::valarray<int> data;int dim;public: Matrix(int r, int c): data(r*c), dim(c){}int& operator()(int r, int c){return data[r*dim + c];}int trace()const{return data[std::slice(0, dim, dim+1)].sum();}};int main(){ Matrix m(3,3);int n =0;for(int r=0; r<3;++r)for(int c=0; c<3;++c) m(r, c)=++n;std::cout<<"Trace of the matrix (1,2,3) (4,5,6) (7,8,9) is "<< m.trace()<<'\n';}

Output:

Trace of the matrix (1,2,3) (4,5,6) (7,8,9) is 15

[editar]Veja também

get / set elemento valarray, uma fatia ou máscara
Original:
get/set valarray element, slice, or mask
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)[edit]
fatia generalizada de uma valarray: índice inicial, conjunto de comprimentos, conjunto de passos
Original:
generalized slice of a valarray: starting index, set of lengths, set of strides
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe)[edit]
proxy para um subconjunto de uma valarray após a aplicação de uma fatia
Original:
proxy to a subset of a valarray after applying a slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(modelo de classe)[edit]
close