STL中的valarray

简介:   这个貌似是用来做数值计算用的,具体实现不清楚。下面是MSDN中的说明和例子:// valarray_abs.

 

 

这个貌似是用来做数值计算用的,具体实现不清楚。

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

 

相关文章
|
2月前
|
存储 算法 编译器
【C++】初识C++模板与STL
【C++】初识C++模板与STL
|
2月前
|
存储 算法 C++
带你一步认识STL
带你一步认识STL
44 0
|
7月前
|
C++ 容器
【C++】STL之空间配置器(了解)
【C++】STL之空间配置器(了解)
|
4月前
|
算法 安全 Linux
|
7月前
|
存储 算法 C++
|
7月前
|
算法 C++ 容器
STL小结
STL小结
|
7月前
|
算法 C++ 容器
STL注意问题
STL注意问题
|
存储 算法 程序员
c++之STL详解(一)
c++之STL详解(一)
84 0
|
存储 设计模式 算法
c++之STL详解(二)
c++之STL详解(二)
95 0