這個貌似是用來做數值計算用的,具體實作不清楚。 下面是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: "; cout << va2 [ i ] << " "; } <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 | elements are equal to the arccosine of the elements of the input valarray. |
asin | elements are equal to the arcsine of the elements of the input valarray. |
atan | 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 | elements are equal to the cosine of the elements of the input valarray. |
cosh | elements are equal to the hyperbolic cosine of the elements of the input valarray. |
exp | elements are equal to the natural exponential of the elements of the input |
log | elements are equal to the natural logarithm of the elements of the input |
log10 | 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 | elements are equal to the sine of the elements of the input valarray. |
sinh | elements are equal to the hyperbolic sine of the elements of the input valarray. |
sqrt | elements are equal to the square root of the elements of the input valarray. |
tan | elements are equal to the tangent of the elements of the input valarray. |
tanh | elements are equal to the hyperbolic tangent of the elements of the input valarray. |