Translations of this page?:

apply

Syntax:

    #include <valarray>
    valarray apply( TYPE f(TYPE val) ) const;
    valarray apply( TYPE f(const TYPE& val) ) const;

The apply() function creates a new valarray, applying f() to each element.

This function does not affect the previous contents of the valarray.

Unfortunately, this function does not accept a function object as an argument.

For example, the following code creates a new valarray with incremented elements:

   double incr( double d ) { return d+1; }
 
   void f( valarray<double>& v )
   {
      valarray<double> v2 = v.apply(incr);
   }
 
• • • IndexRecent changesRSScc