This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
[valarray.access]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.access)
### 29.6.2 Class template valarray [[template.valarray]](template.valarray#valarray.access)
#### 29.6.2.4 Element access [valarray.access]
[🔗](#lib:operator%5b%5d,valarray)
`const T& operator[](size_t n) const;
T& operator[](size_t n);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7577)
*Hardened preconditions*: n < size() is true[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7581)
*Returns*: A reference to the corresponding element of the array[.](#2.sentence-1)
[*Note [1](#note-1)*:
The expression (a[i] = q, a[i]) == q evaluates to true for any non-constant valarray<T> a,
any T q, and for any size_t i such that the value of i is less than the length of a[.](#2.sentence-2)
— *end note*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7591)
*Remarks*: The expression addressof(a[i + j]) == addressof(a[i]) + j evaluates to true for all size_t i and size_t j such that i + j < a.size()[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7597)
The expression addressof(a[i]) != addressof(b[j]) evaluates to true for any two arraysa and b and for anysize_t i and size_t j such that i < a.size() and j < b.size()[.](#4.sentence-1)
[*Note [2](#note-2)*:
This property indicates an absence of aliasing and can be used to
advantage by optimizing compilers[.](#4.sentence-2)
Compilers can take advantage
of inlining, constant propagation, loop fusion,
tracking of pointers obtained fromoperator new,
and other techniques to generate efficientvalarrays[.](#4.sentence-3)
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7614)
The reference returned by the subscript operator for an array shall
be valid until the member function[resize(size_t, T)](valarray.members#lib:valarray,resize "29.6.2.8Member functions[valarray.members]") is called for that array or until the lifetime of
that array ends, whichever happens first[.](#5.sentence-1)

113
cppdraft/valarray/assign.md Normal file
View File

@@ -0,0 +1,113 @@
[valarray.assign]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.assign)
### 29.6.2 Class template valarray [[template.valarray]](template.valarray#valarray.assign)
#### 29.6.2.3 Assignment [valarray.assign]
[🔗](#lib:operator=,valarray)
`valarray& operator=(const valarray& v);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7482)
*Effects*: Each element of the*this array is assigned the value of the corresponding element of v[.](#1.sentence-1)
If the length of v is not equal to the length of *this,
resizes *this to make the two arrays the same length,
as if by calling resize(v.size()), before performing the assignment[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7491)
*Postconditions*: size() == v.size()[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7495)
*Returns*: *this[.](#3.sentence-1)
[🔗](#lib:operator=,valarray_)
`valarray& operator=(valarray&& v) noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7506)
*Effects*: *this obtains the value of v[.](#4.sentence-1)
The value of v after the assignment is not specified[.](#4.sentence-2)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7511)
*Returns*: *this[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7515)
*Complexity*: Linear[.](#6.sentence-1)
[🔗](#lib:operator=,valarray__)
`valarray& operator=(initializer_list<T> il);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7526)
*Effects*: Equivalent to: return *this = valarray(il);
[🔗](#lib:operator=,valarray___)
`valarray& operator=(const T& v);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7538)
*Effects*: Assigns v to each element of *this[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7542)
*Returns*: *this[.](#9.sentence-1)
[🔗](#lib:operator=,valarray____)
`valarray& operator=(const slice_array<T>&);
valarray& operator=(const gslice_array<T>&);
valarray& operator=(const mask_array<T>&);
valarray& operator=(const indirect_array<T>&);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7556)
*Preconditions*: The length of the array to which the argument refers equals size()[.](#10.sentence-1)
The value of an element in the left-hand side of a valarray assignment
operator does not depend on the value of another element in that left-hand side[.](#10.sentence-2)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7562)
These operators allow the results of a generalized subscripting operation
to be assigned directly to avalarray[.](#11.sentence-1)

111
cppdraft/valarray/binary.md Normal file
View File

@@ -0,0 +1,111 @@
[valarray.binary]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.binary)
### 29.6.3 valarray non-member operations [[valarray.nonmembers]](valarray.nonmembers#valarray.binary)
#### 29.6.3.1 Binary operators [valarray.binary]
[🔗](#lib:operator*,valarray)
`template<class T> valarray<T> operator* (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator/ (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator% (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator+ (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator- (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator^ (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator& (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator| (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator<<(const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator>>(const valarray<T>&, const valarray<T>&);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8119)
*Mandates*: The indicated operator can be applied to operands of type T and returns
a value of type T or which can be unambiguously
implicitly converted to T[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8125)
*Preconditions*: The argument arrays have the same length[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8129)
*Returns*: A valarray whose length is equal to the
lengths of the argument arrays[.](#3.sentence-1)
Each element of the returned array is
initialized with the result of applying the indicated operator to the
corresponding elements of the argument arrays[.](#3.sentence-2)
[🔗](#lib:operator*,valarray_)
`template<class T> valarray<T> operator* (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator* (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator/ (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator/ (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator% (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator% (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator+ (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator+ (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator- (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator- (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator^ (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator^ (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator& (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator& (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator| (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator| (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator<<(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator<<(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator>>(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator>>(const typename valarray<T>::value_type&,
const valarray<T>&);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8192)
*Mandates*: The indicated operator can be applied to operands of type T and returns
a value of type T or which can be unambiguously
implicitly converted to T[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8198)
*Returns*: A valarray whose length is equal to the
length of the array argument[.](#5.sentence-1)
Each element of the returned array is
initialized with the result of applying the indicated operator to the
corresponding element of the array argument and the non-array argument[.](#5.sentence-2)

View File

@@ -0,0 +1,101 @@
[valarray.cassign]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.cassign)
### 29.6.2 Class template valarray [[template.valarray]](template.valarray#valarray.cassign)
#### 29.6.2.7 Compound assignment [valarray.cassign]
[🔗](#lib:operator*=,valarray)
`valarray& operator*= (const valarray& v);
valarray& operator/= (const valarray& v);
valarray& operator%= (const valarray& v);
valarray& operator+= (const valarray& v);
valarray& operator-= (const valarray& v);
valarray& operator^= (const valarray& v);
valarray& operator&= (const valarray& v);
valarray& operator|= (const valarray& v);
valarray& operator<<=(const valarray& v);
valarray& operator>>=(const valarray& v);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7853)
*Mandates*: The indicated operator can be applied to two operands of type T[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7857)
*Preconditions*: size() == v.size() is true[.](#2.sentence-1)
The value of an element in the left-hand side of a valarray compound
assignment operator does not depend on the value of another element in that left
hand side[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7865)
*Effects*: Each of these operators
performs the indicated operation on each of the elements of *this and the
corresponding element of v[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7871)
*Returns*: *this[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7875)
*Remarks*: The appearance of an array on the left-hand side of a compound assignment
does not invalidate references or pointers[.](#5.sentence-1)
[🔗](#lib:operator*=,valarray_)
`valarray& operator*= (const T& v);
valarray& operator/= (const T& v);
valarray& operator%= (const T& v);
valarray& operator+= (const T& v);
valarray& operator-= (const T& v);
valarray& operator^= (const T& v);
valarray& operator&= (const T& v);
valarray& operator|= (const T& v);
valarray& operator<<=(const T& v);
valarray& operator>>=(const T& v);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7905)
*Mandates*: The indicated operator can be applied to two operands of type T[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7909)
*Effects*: Each of these operators applies the indicated operation to each element
of *this and v[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7914)
*Returns*: *this[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7918)
*Remarks*: The appearance of an array on the left-hand side of a compound assignment
does not
invalidate references or pointers to the elements of the array[.](#9.sentence-1)

View File

@@ -0,0 +1,101 @@
[valarray.comparison]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.comparison)
### 29.6.3 valarray non-member operations [[valarray.nonmembers]](valarray.nonmembers#valarray.comparison)
#### 29.6.3.2 Logical operators [valarray.comparison]
[🔗](#lib:operator==,valarray)
`template<class T> valarray<bool> operator==(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator!=(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator< (const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator> (const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator<=(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator>=(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator&&(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator||(const valarray<T>&, const valarray<T>&);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8229)
*Mandates*: The indicated operator can be applied to operands of type T and returns
a value of type bool or which can be unambiguously
implicitly converted to bool[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8235)
*Preconditions*: The two array arguments have the same length[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8240)
*Returns*: A valarray<bool> whose length
is equal to the length of the array arguments[.](#3.sentence-1)
Each element of the returned
array is initialized with the result of applying the indicated
operator to the corresponding elements of the argument arrays[.](#3.sentence-2)
[🔗](#lib:operator==,valarray_)
`template<class T> valarray<bool> operator==(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator==(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator!=(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator!=(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator< (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator< (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator> (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator> (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator<=(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator<=(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator>=(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator>=(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator&&(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator&&(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator||(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator||(const typename valarray<T>::value_type&,
const valarray<T>&);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8293)
*Mandates*: The indicated operator can be applied to operands of type T and returns
a value of type bool or which can be unambiguously
implicitly converted to bool[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8299)
*Returns*: A valarray<bool> whose
length is equal to the length of the array argument[.](#5.sentence-1)
Each element
of the returned array is initialized with the result of applying the
indicated operator to the corresponding element of the array and the non-array argument[.](#5.sentence-2)

159
cppdraft/valarray/cons.md Normal file
View File

@@ -0,0 +1,159 @@
[valarray.cons]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.cons)
### 29.6.2 Class template valarray [[template.valarray]](template.valarray#valarray.cons)
#### 29.6.2.2 Constructors [valarray.cons]
[🔗](#lib:valarray,constructor)
`valarray();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7333)
*Effects*: Constructs a valarray that has zero length[.](#1.sentence-1)[249](#footnote-249 "This default constructor is essential, since arrays of valarray can be useful. After initialization, the length of an empty array can be increased with the resize member function.")
[🔗](#lib:valarray,constructor_)
`explicit valarray(size_t n);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7354)
*Effects*: Constructs a valarray that has length n[.](#2.sentence-1)
Each element of the array is [value-initialized](dcl.init#def:value-initialization "9.5Initializers[dcl.init]")[.](#2.sentence-2)
[🔗](#lib:valarray,constructor__)
`valarray(const T& v, size_t n);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7366)
*Effects*: Constructs a valarray that has length n[.](#3.sentence-1)
Each element of the array is initialized with v[.](#3.sentence-2)
[🔗](#lib:valarray,constructor___)
`valarray(const T* p, size_t n);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7379)
*Preconditions*: [p, p + n) is a valid range[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7383)
*Effects*: Constructs a valarray that has length n[.](#5.sentence-1)
The values of the elements of the array are initialized with the
firstn values pointed to by the first argument[.](#5.sentence-2)[250](#footnote-250 "This constructor is the preferred method for converting a C array to a valarray object.")
[🔗](#lib:valarray,constructor____)
`valarray(const valarray& v);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7404)
*Effects*: Constructs a valarray that has the same length as v[.](#6.sentence-1)
The elements are initialized with the values of the corresponding
elements of v[.](#6.sentence-2)[251](#footnote-251 "This copy constructor creates a distinct array rather than an alias. Implementations in which arrays share storage are permitted, but they would need to implement a copy-on-reference mechanism to ensure that arrays are conceptually distinct.")
[🔗](#lib:valarray,constructor_____)
`valarray(valarray&& v) noexcept;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7424)
*Effects*: Constructs a valarray that has the same length as v[.](#7.sentence-1)
The elements are initialized with the values of the corresponding
elements of v[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7430)
*Complexity*: Constant[.](#8.sentence-1)
[🔗](#lib:valarray,constructor______)
`valarray(initializer_list<T> il);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7441)
*Effects*: Equivalent to valarray(il.begin(), il.size())[.](#9.sentence-1)
[🔗](#lib:valarray,constructor_______)
`valarray(const slice_array<T>&);
valarray(const gslice_array<T>&);
valarray(const mask_array<T>&);
valarray(const indirect_array<T>&);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7455)
These conversion constructors convert one of the four reference templates
to avalarray[.](#10.sentence-1)
[🔗](#lib:valarray,destructor)
`~valarray();
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7467)
*Effects*: The destructor is applied to every element of*this;
an implementation may return all allocated memory[.](#11.sentence-1)
[249)](#footnote-249)[249)](#footnoteref-249)
This default constructor is essential,
since arrays ofvalarray can be useful[.](#footnote-249.sentence-1)
After initialization, the length of an empty array can be increased with theresize member function[.](#footnote-249.sentence-2)
[250)](#footnote-250)[250)](#footnoteref-250)
This constructor is the
preferred method for converting a C array to avalarray object[.](#footnote-250.sentence-1)
[251)](#footnote-251)[251)](#footnoteref-251)
This copy constructor creates
a distinct array rather than an alias[.](#footnote-251.sentence-1)
Implementations in which arrays share storage are permitted, but they
would need to implement a copy-on-reference mechanism to ensure that arrays are
conceptually distinct[.](#footnote-251.sentence-2)

View File

@@ -0,0 +1,192 @@
[valarray.members]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.members)
### 29.6.2 Class template valarray [[template.valarray]](template.valarray#valarray.members)
#### 29.6.2.8 Member functions [valarray.members]
[🔗](#lib:swap,valarray)
`void swap(valarray& v) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7933)
*Effects*: *this obtains the value ofv[.](#1.sentence-1)
v obtains the value of *this[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7938)
*Complexity*: Constant[.](#2.sentence-1)
[🔗](#lib:size,valarray)
`size_t size() const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7949)
*Returns*: The number of elements in the array[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7953)
*Complexity*: Constant time[.](#4.sentence-1)
[🔗](#lib:sum,valarray)
`T sum() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7964)
*Mandates*: operator+= can be applied to operands of type T[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7968)
*Preconditions*: size() > 0 is true[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7972)
*Returns*: The sum of all the elements of the array[.](#7.sentence-1)
If the array has length 1, returns the value of element 0[.](#7.sentence-2)
Otherwise, the returned value is calculated by applyingoperator+= to a copy of an element of the array and
all other elements of the array in an unspecified order[.](#7.sentence-3)
[🔗](#lib:min,valarray)
`T min() const;
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7988)
*Preconditions*: size() > 0 is true[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7992)
*Returns*: The minimum value contained in *this[.](#9.sentence-1)
For an array of length 1, the value of element 0 is returned[.](#9.sentence-2)
For all other array
lengths, the determination is made usingoperator<[.](#9.sentence-3)
[🔗](#lib:max,valarray)
`T max() const;
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8007)
*Preconditions*: size() > 0 is true[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8011)
*Returns*: The maximum value contained in *this[.](#11.sentence-1)
For an array of length 1, the value of element 0 is returned[.](#11.sentence-2)
For all other array
lengths, the determination is made usingoperator<[.](#11.sentence-3)
[🔗](#lib:shift,valarray)
`valarray shift(int n) const;
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8026)
*Returns*: A valarray of length size(), each of whose elements*I* is(*this)[*I* + n] if *I* + n is non-negative and less thansize(), otherwise T()[.](#12.sentence-1)
[*Note [1](#note-1)*:
If element zero is taken as the leftmost element,
a positive value of n shifts the elements left n places, with zero fill[.](#12.sentence-2)
— *end note*]
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8040)
[*Example [1](#example-1)*:
If the argument has the value −2,
the first two elements of the result will be [value-initialized](dcl.init#def:value-initialization "9.5Initializers[dcl.init]"); the third element of the result will be assigned the value
of the first element of *this; etc[.](#13.sentence-1)
— *end example*]
[🔗](#lib:cshift,valarray)
`valarray cshift(int n) const;
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8054)
*Returns*: A valarray of length size() that is a circular shift of *this[.](#14.sentence-1)
If element zero is taken as
the leftmost element, a non-negative value of n shifts
the elements circularly left n places and a negative
value of n shifts the elements circularly right −n places[.](#14.sentence-2)
[🔗](#lib:apply,valarray)
`valarray apply(T func(T)) const;
valarray apply(T func(const T&)) const;
`
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8070)
*Returns*: A valarray whose length is size()[.](#15.sentence-1)
Each element of the returned array is assigned
the value returned by applying the argument function to the
corresponding element of *this[.](#15.sentence-2)
[🔗](#lib:resize,valarray)
`void resize(size_t sz, T c = T());
`
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8084)
*Effects*: Changes the length of the *this array to sz and then assigns to each element the value of the second argument[.](#16.sentence-1)
Resizing invalidates all pointers and references to elements in the array[.](#16.sentence-2)

View File

@@ -0,0 +1,253 @@
[valarray.nonmembers]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.nonmembers)
### 29.6.3 valarray non-member operations [valarray.nonmembers]
#### [29.6.3.1](#valarray.binary) Binary operators [[valarray.binary]](valarray.binary)
[🔗](#lib:operator*,valarray)
`template<class T> valarray<T> operator* (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator/ (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator% (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator+ (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator- (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator^ (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator& (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator| (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator<<(const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> operator>>(const valarray<T>&, const valarray<T>&);
`
[1](#valarray.binary-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8119)
*Mandates*: The indicated operator can be applied to operands of type T and returns
a value of type T or which can be unambiguously
implicitly converted to T[.](#valarray.binary-1.sentence-1)
[2](#valarray.binary-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8125)
*Preconditions*: The argument arrays have the same length[.](#valarray.binary-2.sentence-1)
[3](#valarray.binary-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8129)
*Returns*: A valarray whose length is equal to the
lengths of the argument arrays[.](#valarray.binary-3.sentence-1)
Each element of the returned array is
initialized with the result of applying the indicated operator to the
corresponding elements of the argument arrays[.](#valarray.binary-3.sentence-2)
[🔗](#lib:operator*,valarray_)
`template<class T> valarray<T> operator* (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator* (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator/ (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator/ (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator% (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator% (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator+ (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator+ (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator- (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator- (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator^ (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator^ (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator& (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator& (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator| (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator| (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator<<(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator<<(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<T> operator>>(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<T> operator>>(const typename valarray<T>::value_type&,
const valarray<T>&);
`
[4](#valarray.binary-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8192)
*Mandates*: The indicated operator can be applied to operands of type T and returns
a value of type T or which can be unambiguously
implicitly converted to T[.](#valarray.binary-4.sentence-1)
[5](#valarray.binary-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8198)
*Returns*: A valarray whose length is equal to the
length of the array argument[.](#valarray.binary-5.sentence-1)
Each element of the returned array is
initialized with the result of applying the indicated operator to the
corresponding element of the array argument and the non-array argument[.](#valarray.binary-5.sentence-2)
#### [29.6.3.2](#valarray.comparison) Logical operators [[valarray.comparison]](valarray.comparison)
[🔗](#lib:operator==,valarray)
`template<class T> valarray<bool> operator==(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator!=(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator< (const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator> (const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator<=(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator>=(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator&&(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator||(const valarray<T>&, const valarray<T>&);
`
[1](#valarray.comparison-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8229)
*Mandates*: The indicated operator can be applied to operands of type T and returns
a value of type bool or which can be unambiguously
implicitly converted to bool[.](#valarray.comparison-1.sentence-1)
[2](#valarray.comparison-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8235)
*Preconditions*: The two array arguments have the same length[.](#valarray.comparison-2.sentence-1)
[3](#valarray.comparison-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8240)
*Returns*: A valarray<bool> whose length
is equal to the length of the array arguments[.](#valarray.comparison-3.sentence-1)
Each element of the returned
array is initialized with the result of applying the indicated
operator to the corresponding elements of the argument arrays[.](#valarray.comparison-3.sentence-2)
[🔗](#lib:operator==,valarray_)
`template<class T> valarray<bool> operator==(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator==(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator!=(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator!=(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator< (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator< (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator> (const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator> (const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator<=(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator<=(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator>=(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator>=(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator&&(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator&&(const typename valarray<T>::value_type&,
const valarray<T>&);
template<class T> valarray<bool> operator||(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator||(const typename valarray<T>::value_type&,
const valarray<T>&);
`
[4](#valarray.comparison-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8293)
*Mandates*: The indicated operator can be applied to operands of type T and returns
a value of type bool or which can be unambiguously
implicitly converted to bool[.](#valarray.comparison-4.sentence-1)
[5](#valarray.comparison-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8299)
*Returns*: A valarray<bool> whose
length is equal to the length of the array argument[.](#valarray.comparison-5.sentence-1)
Each element
of the returned array is initialized with the result of applying the
indicated operator to the corresponding element of the array and the non-array argument[.](#valarray.comparison-5.sentence-2)
#### [29.6.3.3](#valarray.transcend) Transcendentals [[valarray.transcend]](valarray.transcend)
[🔗](#lib:abs,valarray)
`template<class T> valarray<T> abs (const valarray<T>&);
template<class T> valarray<T> acos (const valarray<T>&);
template<class T> valarray<T> asin (const valarray<T>&);
template<class T> valarray<T> atan (const valarray<T>&);
template<class T> valarray<T> atan2(const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> atan2(const valarray<T>&, const typename valarray<T>::value_type&);
template<class T> valarray<T> atan2(const typename valarray<T>::value_type&, const valarray<T>&);
template<class T> valarray<T> cos (const valarray<T>&);
template<class T> valarray<T> cosh (const valarray<T>&);
template<class T> valarray<T> exp (const valarray<T>&);
template<class T> valarray<T> log (const valarray<T>&);
template<class T> valarray<T> log10(const valarray<T>&);
template<class T> valarray<T> pow (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> pow (const valarray<T>&, const typename valarray<T>::value_type&);
template<class T> valarray<T> pow (const typename valarray<T>::value_type&, const valarray<T>&);
template<class T> valarray<T> sin (const valarray<T>&);
template<class T> valarray<T> sinh (const valarray<T>&);
template<class T> valarray<T> sqrt (const valarray<T>&);
template<class T> valarray<T> tan (const valarray<T>&);
template<class T> valarray<T> tanh (const valarray<T>&);
`
[1](#valarray.transcend-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8350)
*Mandates*: A unique function with the indicated name can be applied (unqualified)
to an operand of type T[.](#valarray.transcend-1.sentence-1)
This function returns a value of type T or which can be unambiguously implicitly converted to type T[.](#valarray.transcend-1.sentence-2)
#### [29.6.3.4](#valarray.special) Specialized algorithms [[valarray.special]](valarray.special)
[🔗](#lib:swap,valarray)
`template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
`
[1](#valarray.special-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8366)
*Effects*: Equivalent to x.swap(y)[.](#valarray.special-1.sentence-1)

View File

@@ -0,0 +1,55 @@
[valarray.range]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.range)
### 29.6.10 valarray range access [valarray.range]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9147)
In the begin and end function templates that follow, *unspecified*1
is a type that meets the requirements of a mutable[*Cpp17RandomAccessIterator*](random.access.iterators#:Cpp17RandomAccessIterator "24.3.5.7Random access iterators[random.access.iterators]") ([[random.access.iterators]](random.access.iterators "24.3.5.7Random access iterators"))
and models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14Concept contiguous_­iterator[iterator.concept.contiguous]") ([[iterator.concept.contiguous]](iterator.concept.contiguous "24.3.4.14Concept contiguous_­iterator")),
whose value_type is the template
parameter T and whose reference type is T&[.](#1.sentence-1)
*unspecified*2 is a
type that meets the requirements of a constant[*Cpp17RandomAccessIterator*](random.access.iterators#:Cpp17RandomAccessIterator "24.3.5.7Random access iterators[random.access.iterators]") and models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14Concept contiguous_­iterator[iterator.concept.contiguous]"),
whose value_type is the template
parameter T and whose reference type is const T&[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9160)
The iterators returned by begin and end for an array
are guaranteed to be valid until the member function[resize(size_t, T)](valarray.members#lib:valarray,resize "29.6.2.8Member functions[valarray.members]") is called for that
array or until the lifetime of that array ends, whichever happens
first[.](#2.sentence-1)
[🔗](#lib:begin,valarray)
`template<class T> unspecified1 begin(valarray<T>& v);
template<class T> unspecified2 begin(const valarray<T>& v);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9174)
*Returns*: An iterator referencing the first value in the array[.](#3.sentence-1)
[🔗](#lib:end,valarray)
`template<class T> unspecified1 end(valarray<T>& v);
template<class T> unspecified2 end(const valarray<T>& v);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9186)
*Returns*: An iterator referencing one past the last value in the array[.](#4.sentence-1)

View File

@@ -0,0 +1,20 @@
[valarray.special]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.special)
### 29.6.3 valarray non-member operations [[valarray.nonmembers]](valarray.nonmembers#valarray.special)
#### 29.6.3.4 Specialized algorithms [valarray.special]
[🔗](#lib:swap,valarray)
`template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8366)
*Effects*: Equivalent to x.swap(y)[.](#1.sentence-1)

149
cppdraft/valarray/sub.md Normal file
View File

@@ -0,0 +1,149 @@
[valarray.sub]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.sub)
### 29.6.2 Class template valarray [[template.valarray]](template.valarray#valarray.sub)
#### 29.6.2.5 Subset operations [valarray.sub]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7624)
The member operator[] is overloaded to provide several ways to select
sequences of elements from among those controlled by *this[.](#1.sentence-1)
Each of these
operations returns a subset of the array[.](#1.sentence-2)
The const-qualified versions return this
subset as a new valarray object[.](#1.sentence-3)
The non-const versions return a class
template object which has reference semantics to the original array, working in
conjunction with various overloads of operator= and other assigning
operators to allow selective replacement (slicing) of the controlled sequence[.](#1.sentence-4)
In each case the selected element(s) shall exist[.](#1.sentence-5)
[🔗](#lib:operator%5b%5d,valarray_)
`valarray operator[](slice slicearr) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7640)
*Returns*: A valarray containing those
elements of the controlled sequence designated by slicearr[.](#2.sentence-1)
[*Example [1](#example-1)*: const valarray<char> v0("abcdefghijklmnop", 16);// v0[slice(2, 5, 3)] returns valarray<char>("cfilo", 5) — *end example*]
[🔗](#lib:operator%5b%5d,valarray__)
`slice_array<T> operator[](slice slicearr);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7658)
*Returns*: An object that holds references to elements of the controlled
sequence selected by slicearr[.](#3.sentence-1)
[*Example [2](#example-2)*: valarray<char> v0("abcdefghijklmnop", 16);
valarray<char> v1("ABCDE", 5);
v0[slice(2, 5, 3)] = v1;// v0 == valarray<char>("abAdeBghCjkDmnEp", 16); — *end example*]
[🔗](#lib:operator%5b%5d,valarray___)
`valarray operator[](const gslice& gslicearr) const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7678)
*Returns*: A valarray containing those
elements of the controlled sequence designated by gslicearr[.](#4.sentence-1)
[*Example [3](#example-3)*: const valarray<char> v0("abcdefghijklmnop", 16);const size_t lv[] = { 2, 3 };const size_t dv[] = { 7, 2 };const valarray<size_t> len(lv, 2), str(dv, 2);// v0[gslice(3, len, str)] returns// valarray<char>("dfhkmo", 6) — *end example*]
[🔗](#lib:operator%5b%5d,valarray____)
`gslice_array<T> operator[](const gslice& gslicearr);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7700)
*Returns*: An object that holds references to elements of the controlled
sequence selected by gslicearr[.](#5.sentence-1)
[*Example [4](#example-4)*: valarray<char> v0("abcdefghijklmnop", 16);
valarray<char> v1("ABCDEF", 6);const size_t lv[] = { 2, 3 };const size_t dv[] = { 7, 2 };const valarray<size_t> len(lv, 2), str(dv, 2);
v0[gslice(3, len, str)] = v1;// v0 == valarray<char>("abcAeBgCijDlEnFp", 16) — *end example*]
[🔗](#lib:operator%5b%5d,valarray_____)
`valarray operator[](const valarray<bool>& boolarr) const;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7723)
*Returns*: A valarray containing those
elements of the controlled sequence designated by boolarr[.](#6.sentence-1)
[*Example [5](#example-5)*: const valarray<char> v0("abcdefghijklmnop", 16);const bool vb[] = { false, false, true, true, false, true };// v0[valarray<bool>(vb, 6)] returns// valarray<char>("cdf", 3) — *end example*]
[🔗](#lib:operator%5b%5d,valarray______)
`mask_array<T> operator[](const valarray<bool>& boolarr);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7743)
*Returns*: An object that holds references to elements of the controlled
sequence selected by boolarr[.](#7.sentence-1)
[*Example [6](#example-6)*: valarray<char> v0("abcdefghijklmnop", 16);
valarray<char> v1("ABC", 3);const bool vb[] = { false, false, true, true, false, true };
v0[valarray<bool>(vb, 6)] = v1;// v0 == valarray<char>("abABeCghijklmnop", 16) — *end example*]
[🔗](#lib:operator%5b%5d,valarray_______)
`valarray operator[](const valarray<size_t>& indarr) const;
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7764)
*Returns*: A valarray containing those
elements of the controlled sequence designated by indarr[.](#8.sentence-1)
[*Example [7](#example-7)*: const valarray<char> v0("abcdefghijklmnop", 16);const size_t vi[] = { 7, 5, 2, 3, 8 };// v0[valarray<size_t>(vi, 5)] returns// valarray<char>("hfcdi", 5) — *end example*]
[🔗](#lib:operator%5b%5d,valarray________)
`indirect_array<T> operator[](const valarray<size_t>& indarr);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7784)
*Returns*: An object that holds references to elements of the controlled
sequence selected by indarr[.](#9.sentence-1)
[*Example [8](#example-8)*: valarray<char> v0("abcdefghijklmnop", 16);
valarray<char> v1("ABCDE", 5);const size_t vi[] = { 7, 5, 2, 3, 8 };
v0[valarray<size_t>(vi, 5)] = v1;// v0 == valarray<char>("abCDeBgAEjklmnop", 16) — *end example*]

84
cppdraft/valarray/syn.md Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,42 @@
[valarray.transcend]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.transcend)
### 29.6.3 valarray non-member operations [[valarray.nonmembers]](valarray.nonmembers#valarray.transcend)
#### 29.6.3.3 Transcendentals [valarray.transcend]
[🔗](#lib:abs,valarray)
`template<class T> valarray<T> abs (const valarray<T>&);
template<class T> valarray<T> acos (const valarray<T>&);
template<class T> valarray<T> asin (const valarray<T>&);
template<class T> valarray<T> atan (const valarray<T>&);
template<class T> valarray<T> atan2(const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> atan2(const valarray<T>&, const typename valarray<T>::value_type&);
template<class T> valarray<T> atan2(const typename valarray<T>::value_type&, const valarray<T>&);
template<class T> valarray<T> cos (const valarray<T>&);
template<class T> valarray<T> cosh (const valarray<T>&);
template<class T> valarray<T> exp (const valarray<T>&);
template<class T> valarray<T> log (const valarray<T>&);
template<class T> valarray<T> log10(const valarray<T>&);
template<class T> valarray<T> pow (const valarray<T>&, const valarray<T>&);
template<class T> valarray<T> pow (const valarray<T>&, const typename valarray<T>::value_type&);
template<class T> valarray<T> pow (const typename valarray<T>::value_type&, const valarray<T>&);
template<class T> valarray<T> sin (const valarray<T>&);
template<class T> valarray<T> sinh (const valarray<T>&);
template<class T> valarray<T> sqrt (const valarray<T>&);
template<class T> valarray<T> tan (const valarray<T>&);
template<class T> valarray<T> tanh (const valarray<T>&);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L8350)
*Mandates*: A unique function with the indicated name can be applied (unqualified)
to an operand of type T[.](#1.sentence-1)
This function returns a value of type T or which can be unambiguously implicitly converted to type T[.](#1.sentence-2)

View File

@@ -0,0 +1,32 @@
[valarray.unary]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.unary)
### 29.6.2 Class template valarray [[template.valarray]](template.valarray#valarray.unary)
#### 29.6.2.6 Unary operators [valarray.unary]
[🔗](#lib:operator+,valarray)
`valarray operator+() const;
valarray operator-() const;
valarray operator~() const;
valarray<bool> operator!() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7813)
*Mandates*: The indicated operator can be applied to operands of type T and returns a value of type T (bool foroperator!) or which may be unambiguously implicitly converted to typeT (bool for operator!)[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7820)
*Returns*: A valarray whose length is size()[.](#2.sentence-1)
Each element of the returned array is initialized with the result of
applying the indicated operator to the corresponding element of the array[.](#2.sentence-2)