在线文档教程
C++
数字 | Numerics

std::valarray

STD::valArray

Defined in header
template< class T > class valarray;

std::valarray用于表示和操作值数组的类。它支持按元素划分的数学运算和各种形式的广义下标算子、切片和间接访问.

注记

std::valarray助手类被定义为不受某些形式的混叠,从而使这些类上的操作能够像关键字的效果一样得到优化。限制用C语言编程。此外,函数和操作符valarray参数可以返回代理对象,使编译器能够优化表达式,如v1 = a*v2 + v3;作为一个执行v1[i] = a*v2[i] + v3[i];避免任何临时人员或多次通行证。然而,表达式模板为任何C++容器提供相同的优化技术,大多数数字库更喜欢表达式模板而不是值数组,以获得灵活性。一些C++标准库实现使用表达式模板来实现对std::valarray%28等。GNU libstdc++和LLVM libc++%29。只是很少有值数组被进一步优化,例如。英特尔并行工作室...

模板参数

T-the type of the elements. The type must meet the NumericType requirements

成员类型

Member typeDefinition
value_typeT

成员函数

(constructor)constructs new numeric array (public member function)
(destructor)destructs the numeric array (public member function)
operator=assigns the contents (public member function)
operator[]get/set valarray element, slice, or mask (public member function)
operator+operator-operator~operator!applies a unary arithmetic operator to each element of the valarray (public member function)
operator+=operator-=operator*=operator/=operator%=operator&=operator|=operator^=operator<<=operator>>=applies compound assignment operator to each element of the valarray (public member function)
swapswaps with another valarray (public member function)
sizereturns the size of valarray (public member function)
resizechanges the size of valarray (public member function)
sumcalculates the sum of all elements (public member function)
minreturns the smallest element (public member function)
maxreturns the largest element (public member function)
shiftzero-filling shift the elements of the valarray (public member function)
cshiftcircular shift of the elements of the valarray (public member function)
applyapplies a function to every element of a valarray (public member function)

非会员职能

std::swap(std::valarray) (C++11)specializes the std::swap() algorithm (function template)
std::begin(std::valarray) (C++11)specializes std::begin (function template)
std::end(std::valarray) (C++11)specializes std::end (function template)
operator+operator-operator*operator/operator%operator&operator|operator^operator<<operator>>operator&&operator||applies binary operators to each element of two valarrays, or a valarray and a value (function template)
operator==operator!=operator<operator<=operator>operator>=compares two valarrays or a valarray with a value (function template)
abs(std::valarray)applies the function std::abs to each element of valarray (function template)

指数函数

Exp%28std::valArray%29将函数std::exp应用于valArray%28函数模板%29的每个元素

log%28std::valArray%29将函数std::log应用于valArray%28函数模板%29的每个元素

log 10%28std::valArray%29将函数std::log 10应用于valArray%28函数模板%29的每个元素

幂函数

POW%28std::valArray%29将函数std::pow应用于两个valArray或valArray和值%28的函数模板%29

sqrt%28std::valArray%29将函数std::sqrt应用于valArray%28函数模板%29的每个元素

三角函数

sin%28 std::valArray%29将函数std::sin应用于valArray%28函数模板%29的每个元素

Cos%28std::valArray%29将函数std::cos应用于valArray%28函数模板%29的每个元素

Tan%28 std::valArray%29将函数std::Tan应用于valArray%28函数模板%29的每个元素

Asin%28std::valArray%29将函数std::asin应用于valArray%28函数模板%29的每个元素

ACOS%28std::valArray%29将函数std::acos应用于valArray%28函数模板%29的每个元素

Atan%28std::valArray%29将函数std::atan应用于valArray%28函数模板%29的每个元素

atan 2%28std::valArray%29将函数std::atan 2应用于valArray,并将值%28的函数模板%29应用于valArray。

双曲函数

Sinh%28std::valArray%29将函数std::sinh应用于valArray%28函数模板%29的每个元素

COSH%28std::valArray%29将函数std::cosh应用于valArray%28函数模板%29的每个元素

Tanh%28std::valArray%29将函数std::tanh应用于valArray%28函数模板%29的每个元素

帮助者类

sliceBLAS-like slice of a valarray: starting index, length, stride (class)
slice_arrayproxy to a subset of a valarray after applying a slice (class template)
gslicegeneralized slice of a valarray: starting index, set of lengths, set of strides (class)
gslice_arrayproxy to a subset of a valarray after applying a gslice (class template)
mask_arrayproxy to a subset of a valarray after applying a boolean mask operator
indirect_arrayproxy to a subset of a valarray after applying indirect operator

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/数值/valArray