std::gslice
De cppreference.com
< cpp | numeric | valarray
Version du 2 novembre 2012 à 15:14 par P12bot (discuter | contributions)
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Déclaré dans l'en-tête <valarray>
|
||
class gslice; |
||
std::gslice
est la classe de sélection qui identifie un sous-ensemble d'indices std::valarray définies par un ensemble à plusieurs niveaux de progrès et de tailles. Objets de std::gslice
type peuvent être utilisés comme des indices avec operator[]
valarray à sélectionner, par exemple, les colonnes d'un tableau multidimensionnel représenté comme un valarray
.Original:
std::gslice
is the selector class that identifies a subset of std::valarray indices defined by a multi-level set of strides and sizes. Objects of type std::gslice
can be used as indices with valarray's operator[]
to select, for example, columns of a multidimensional array represented as a valarray
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Compte tenu de la s valeur de départ, la liste des progrès i
j et une liste des tailles d
j, un
j=s+Σ
j(i
jd
j) .
j et une liste des tailles d
j, un
std::gslice
construit à partir de ces valeurs sélectionne l'ensemble des indices kj=s+Σ
j(i
jd
j) .
Original:
Given the starting value s, a list of strides i
j and a list of sizes d
j, a
j=s+Σ
j(i
jd
j).
j and a list of sizes d
j, a
std::gslice
constructed from these values selects the set of indices kj=s+Σ
j(i
jd
j).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Par exemple, un GSlice avec
3
indice de départ, des progrès {19,4,1
} et longueurs {2,4,3}
génère l'ensemble suivant des indices:Original:
For example, a gslice with starting index
3
, strides {19,4,1
} and lengths {2,4,3}
generates the following set of indices:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3 + 0*19 + 0*4 + 0*1 = 3,
3 + 0*19 + 0*4 + 1*1 = 4,
3 + 0*19 + 0*4 + 2*1 = 5,
3 + 0*19 + 1*4 + 0*1 = 7,
3 + 0*19 + 1*4 + 1*1 = 8,
...
3 + 1*19 + 3*4 + 2*1 = 36
Il est possible de construire des objets
std::gslice
qui sélectionnent certains indices plus d'une fois: si l'exemple ci-dessus utilise la {1,1,1}
progrès, les indices auraient été {3, 4, 5, 4, 5, 6, ...}
. Gslices Elles ne peuvent être utilisées comme arguments à la version const de std::valarray::operator[]
, sinon le comportement est indéfini .Original:
It is possible to construct
std::gslice
objects that select some indices more than once: if the above example used the strides {1,1,1}
, the indices would have been {3, 4, 5, 4, 5, 6, ...}
. Such gslices may only be used as arguments to the const version of std::valarray::operator[]
, otherwise the behavior is undefined.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Les fonctions membres
construit un GSlice Original: constructs a gslice The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
accède au début de la GSlice Original: accesses the start of the gslice The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
accède au tableau des progrès de la GSlice Original: accesses the array of strides of the gslice The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
accède à l'ensemble de sizees de la GSlice Original: accesses the array of sizees of the gslice The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) |
Exemple
illustre l'utilisation de gslices pour répondre colonnes d'un tableau 3D
Original:
demonstrates the use of gslices to address columns of a 3D array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream> #include <valarray> void test_print(std::valarray<int>& v, int rows, int cols, int planes) { for(int r=0; r<rows; ++r) { for(int c=0; c<cols; ++c) { for(int z=0; z<planes; ++z)