Namespace
Varianti

std::slice

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

 
 
Numeri libreria
Comuni funzioni matematiche
Virgola mobile ambiente
I numeri complessi
Array numerici
Pseudo-casuale generazione
In fase di compilazione aritmetica razionale (C++11)
Generici operazioni numeriche
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
 
 
Elemento definito nell'header <valarray>
class slice;
std::slice è la classe selettore che identifica un sottoinsieme di std::valarray simile alla slice BLAS. Un oggetto di tipo std::slice contiene tre valori: l'indice di partenza, il passo, e il numero totale di valori nel sottoinsieme. Gli oggetti di std::slice tipo possono essere utilizzati come indici con operator[] valarray di.
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.

[modifica] Membri funzioni

costruisce una fetta
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.

(metodo pubblico)
accede l'inizio della fetta
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.

(metodo pubblico)
accede alla dimensione della slice
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.

(metodo pubblico)
accede al passo della fetta
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.

(metodo pubblico)

[modifica] Esempio

Barebones valarray-backed classe Matrix con una funzione di calcolo traccia .
Original:
Barebones valarray-backed Matrix class with a traccia 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

[modifica] Vedi anche

get / set elemento valarray, fetta, o maschera
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.

(metodo pubblico) [modifica]
fetta generalizzata di un valarray: indice iniziale, set di lunghezze, serie di passi
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) [modifica]
proxy per un sottoinsieme di un valarray dopo l'applicazione di una fetta
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.

(classe template) [modifica]