std::valarray::apply - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
|
|
||
|
|
||
Restituisce una nuova valarray della stessa dimensione, con valori che vengono acquisiti applicando func funzione ai valori precedenti degli elementi.
Original:
Returns a new valarray of the same size with values which are acquired by applying function func to the previous values of the elements.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parametri
| func | - | funzione da applicare ai valori Original: function to apply to the values The text has been machine-translated via Google Translate. |
Valore di ritorno
Il valarray risultante con i valori acquisiti applicando func funzione.
Original:
The resulting valarray with values acquired by applying function func.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Note
La funzione può essere implementata con il tipo restituito diverso da std::valarray. In questo caso, il tipo di sostituzione ha le seguenti proprietà:
Original:
The function can be implemented with the return type different from std::valarray. In this case, the replacement type has the following properties:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tutte le funzioni di membro
conststd::valarray sono forniti.Original:
All
constmember functions of std::valarray are provided.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.std::valarray,
std::slice_array,std::gslice_array,std::mask_arraystd::indirect_arraye può essere costruito con il tipo di sostituzione.Original:
std::valarray,
std::slice_array,std::gslice_array,std::mask_arrayandstd::indirect_arraycan be constructed from the replacement type.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.Tutte le funzioni che accettano un argomento di
const std::valarray&tipo devono anche accettare il tipo di sostituzione.Original:
All functions accepting a arguments of type
const std::valarray&should also accept the replacement type.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.Tutte le funzioni che accettano due argomenti di tipo
const std::valarray&dovrebbe accettare ogni combinazione diconst std::valarray&e il tipo di sostituzione.Original:
All functions accepting two arguments of type
const std::valarray&should accept every combination ofconst std::valarray&and the replacement type.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Esempio
calcola e stampa i primi 10 fattoriali
Original:
calculates and prints the first 10 factorials
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> #include <cmath> int main() { std::valarray<int> v = {1,2,3,4,5,6,7,8,9,10}; v = v.apply([](int n)->int { return std::round(std::tgamma(n+1)); }); for(auto n : v) { std::cout << n << ' '; } std::cout << '\n'; }
Output:
1 2 6 24 120 720 5040 40320 362880 3628800
Vedi anche
applica una funzione ad una serie di elementi Original: applies a function to a range of elements The text has been machine-translated via Google Translate. (funzione di modello) [modifica] | |