Udostępnij za pośrednictwem


operator- (<valarray>)

Uzyskuje odpowiednie elementy na dwie równe valarrays lub z element-wise różnica między valarray określonej wartości.

template<class Type>
   valarray<Type> operator-(
      const valarray<Type>& _Left,
      const valarray<Type>& _Right
   );
template<class Type>
   valarray<Type> operator-(
      const valarray<Type>& _Left,
      const Type& _Right
   );
template<class Type>
   valarray<Type> operator-(
      const Type& _Left,
      const valarray<Type>& _Right
   );

Parametry

  • _Left
    Wartość lub valarray, który służy jako odjemna, z którego mają zostać odjęte w tworzących różnica inne wartości lub valarrays.

  • _Right
    Wartość lub valarray, który służy jako odjemnik, który ma być odjęta od innych wartości lub valarrays w tworzących różnica.

Wartość zwracana

Valarray, której elementy są różnica element-wise z _Left i_Right.

Uwagi

Arytmetyczne terminologii używanej w opisujące odejmowanie:

Różnica = odjemna - odjemnik

Przykład

// valarray_op_ediff.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>

int main( )
{
   using namespace std;
   int i;

   valarray<int> vaL ( 8 ), vaR ( 8 );
   valarray<int> vaNE ( 8 );
   for ( i = 0 ; i < 8 ; i += 2 )
      vaL [ i ] =  10;
   for ( i = 1 ; i < 8 ; i += 2 )
      vaL [ i ] =  0;
   for ( i = 0 ; i < 8 ; i++ )
      vaR [ i ] =  i;
   
   cout << "The initial Left 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;

   vaNE = ( vaL - vaR );
   cout << "The element-by-element result of "
        << "the difference is the\n valarray: ( ";
      for (i = 0 ; i < 8 ; i++ )
         cout << vaNE [ i ] << " ";
   cout << ")." << endl;
}
  
  
  

Wymagania

Nagłówek: <valarray>

Obszar nazw: std