valarray::operator*=
Multipliziert die Elemente eines angegebenen Wertarrays oder Wert des Elementtyps, elementweis, einen Operandenwertarray.
valarray<Type>& operator*=(
const valarray<Type>& _Right
);
valarray<Type>& operator*=(
const Type& _Right
);
Parameter
- _Right
Der Wertarray oder der Wert eines Elementtyps identisch mit dem des Operandenwertarrays, der zu multiplizierenden ist, elementweis, der Operandenwertarray.
Rückgabewert
Ein Wertearray, dessen Elemente elementweise das Produkt des Operandenwertarrays und _Right. sind
Beispiel
// valarray_op_emult.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i;
valarray<int> vaL ( 8 ), vaR ( 8 );
for ( i = 0 ; i < 8 ; i += 2 )
vaL [ i ] = 2;
for ( i = 1 ; i < 8 ; i += 2 )
vaL [ i ] = -1;
for ( i = 0 ; i < 8 ; i++ )
vaR [ i ] = i;
cout << "The initial valarray is: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaL [ i ] << " ";
cout << ")." << endl;
cout << "The initial Right valarray is: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaR [ i ] << " ";
cout << ")." << endl;
vaL *= vaR;
cout << "The element-by-element result of "
<< "the multiplication is the\n valarray: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaL [ i ] << " ";
cout << ")." << endl;
}
Anforderungen
Header: <valarray>
Namespace: std