閱讀616 返回首頁    go 阿裏雲 go 技術社區[雲棲]


STL中的valarray

 

 

這個貌似是用來做數值計算用的,具體實現不清楚。

下麵是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. 

 

最後更新:2017-04-02 06:51:26

  上一篇:go 詳解C++中的this指針
  下一篇:go 關於信號量與線程互斥鎖的區別與實現