这个貌似是用来做数值计算用的,具体实现不清楚。 下面是MSDN中的说明和例子: // valarray_abs.cpp // compile with: /EHsc #include <valarray> #include <iostream> int main( ) { using namespace std; int i; valarray<int> va1 ( 9 ), va2 ( 9 ); for ( i = 0 ; i < 4 ; i++ ) va1 [ i ] = -i; for ( i = 4 ; i < 9 ; i++ ) va1 [ i ] = i; cout << "The initial valarray is: "; for (i = 0 ; i < 9 ; i++ ) cout << va1 [ i ] << " "; cout << "." << endl; va2 = abs ( va1 ); cout << "The absolute value of the initial valarray is: "; for (i = 0 ; i < 9 ; i++ ) cout << va2 [ i ] << " "; cout << "." << endl; }
<valarray> Members |
See Also Send Feedback |
Updated: November 2007
Reference
Functions
abs |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the absolute value of the elements of the input valarray. |
acos |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the arccosine of the elements of the input valarray. |
asin |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the arcsine of the elements of the input valarray. |
atan |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the principal value of the arctangent of the elements of the input valarray. |
atan2 |
Returns a valarray whose elements are equal to the arctangent of the Cartesian components specified by a combination of constants and elements of valarrays. |
cos |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the cosine of the elements of the input valarray. |
cosh |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the hyperbolic cosine of the elements of the input valarray. |
exp |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the natural exponential of the elements of the input valarray. |
log |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the natural logarithm of the elements of the input valarray. |
log10 |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the base 10 or common logarithm of the elements of the input valarray. |
pow |
Operates on the elements of input valarrays and constants, returning a valarray whose elements are equal to a base specified either by the elements of an input valarray or a constant raised to an exponent specified either by the elements of an input valarray or a constant. |
sin |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the sine of the elements of the input valarray. |
sinh |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the hyperbolic sine of the elements of the input valarray. |
sqrt |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the square root of the elements of the input valarray. |
tan |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the tangent of the elements of the input valarray. |
tanh |
Operates on the elements of an input valarray, returning a valarray whose elements are equal to the hyperbolic tangent of the elements of the input valarray. |