首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::valarray

Defined in header <valarray>

?

?

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 type

Definition

value_type

T

成员函数

(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)

swap

swaps with another valarray (public member function)

size

returns the size of valarray (public member function)

resize

changes the size of valarray (public member function)

sum

calculates the sum of all elements (public member function)

min

returns the smallest element (public member function)

max

returns the largest element (public member function)

shift

zero-filling shift the elements of the valarray (public member function)

cshift

circular shift of the elements of the valarray (public member function)

apply

applies 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的每个元素

帮助者类

slice

BLAS-like slice of a valarray: starting index, length, stride (class)

slice_array

proxy to a subset of a valarray after applying a slice (class template)

gslice

generalized slice of a valarray: starting index, set of lengths, set of strides (class)

gslice_array

proxy to a subset of a valarray after applying a gslice (class template)

mask_array

proxy to a subset of a valarray after applying a boolean mask operator

indirect_array

proxy to a subset of a valarray after applying indirect operator

代码语言:txt
复制
 ? cppreference.com

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com