- tmp/tmpc3novgdb/{from.md → to.md} +315 -258
tmp/tmpc3novgdb/{from.md → to.md}
RENAMED
|
@@ -15,101 +15,133 @@ namespace std {
|
|
| 15 |
template<class T> class indirect_array; // an indirected array
|
| 16 |
|
| 17 |
template<class T> void swap(valarray<T>&, valarray<T>&) noexcept;
|
| 18 |
|
| 19 |
template<class T> valarray<T> operator* (const valarray<T>&, const valarray<T>&);
|
| 20 |
-
template<class T> valarray<T> operator* (const valarray<T>&,
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
|
| 23 |
template<class T> valarray<T> operator/ (const valarray<T>&, const valarray<T>&);
|
| 24 |
-
template<class T> valarray<T> operator/ (const valarray<T>&,
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
template<class T> valarray<T> operator% (const valarray<T>&, const valarray<T>&);
|
| 28 |
-
template<class T> valarray<T> operator% (const valarray<T>&,
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
|
| 31 |
template<class T> valarray<T> operator+ (const valarray<T>&, const valarray<T>&);
|
| 32 |
-
template<class T> valarray<T> operator+ (const valarray<T>&,
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
|
| 35 |
template<class T> valarray<T> operator- (const valarray<T>&, const valarray<T>&);
|
| 36 |
-
template<class T> valarray<T> operator- (const valarray<T>&,
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
template<class T> valarray<T> operator^ (const valarray<T>&, const valarray<T>&);
|
| 40 |
-
template<class T> valarray<T> operator^ (const valarray<T>&,
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
template<class T> valarray<T> operator& (const valarray<T>&, const valarray<T>&);
|
| 44 |
-
template<class T> valarray<T> operator& (const valarray<T>&,
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
template<class T> valarray<T> operator| (const valarray<T>&, const valarray<T>&);
|
| 48 |
-
template<class T> valarray<T> operator| (const valarray<T>&,
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
|
| 51 |
template<class T> valarray<T> operator<<(const valarray<T>&, const valarray<T>&);
|
| 52 |
-
template<class T> valarray<T> operator<<(const valarray<T>&,
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
|
| 55 |
template<class T> valarray<T> operator>>(const valarray<T>&, const valarray<T>&);
|
| 56 |
-
template<class T> valarray<T> operator>>(const valarray<T>&,
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
|
| 59 |
template<class T> valarray<bool> operator&&(const valarray<T>&, const valarray<T>&);
|
| 60 |
-
template<class T> valarray<bool> operator&&(const valarray<T>&,
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
|
| 63 |
template<class T> valarray<bool> operator||(const valarray<T>&, const valarray<T>&);
|
| 64 |
-
template<class T> valarray<bool> operator||(const valarray<T>&,
|
| 65 |
-
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
template<class T>
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
template<class T> valarray<bool> operator==(const
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
template<class T> valarray<bool> operator!=(const valarray<T>&,
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
template<class T>
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
template<class T> valarray<bool> operator< (const
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
template<class T> valarray<bool> operator> (const valarray<T>&,
|
| 83 |
-
|
| 84 |
-
template<class T>
|
| 85 |
-
|
| 86 |
-
template<class T> valarray<bool> operator<=(const valarray<T>&, const T&);
|
| 87 |
-
template<class T> valarray<bool> operator<=(const
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
template<class T> valarray<bool> operator>=(const T&, const valarray<T>&);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
template<class T> valarray<T> abs (const valarray<T>&);
|
| 94 |
template<class T> valarray<T> acos (const valarray<T>&);
|
| 95 |
template<class T> valarray<T> asin (const valarray<T>&);
|
| 96 |
template<class T> valarray<T> atan (const valarray<T>&);
|
| 97 |
|
| 98 |
template<class T> valarray<T> atan2(const valarray<T>&, const valarray<T>&);
|
| 99 |
-
template<class T> valarray<T> atan2(const valarray<T>&,
|
| 100 |
-
|
|
|
|
|
|
|
| 101 |
|
| 102 |
template<class T> valarray<T> cos (const valarray<T>&);
|
| 103 |
template<class T> valarray<T> cosh (const valarray<T>&);
|
| 104 |
template<class T> valarray<T> exp (const valarray<T>&);
|
| 105 |
template<class T> valarray<T> log (const valarray<T>&);
|
| 106 |
template<class T> valarray<T> log10(const valarray<T>&);
|
| 107 |
|
| 108 |
template<class T> valarray<T> pow(const valarray<T>&, const valarray<T>&);
|
| 109 |
-
template<class T> valarray<T> pow(const valarray<T>&, const T&);
|
| 110 |
-
template<class T> valarray<T> pow(const T&, const valarray<T>&);
|
| 111 |
|
| 112 |
template<class T> valarray<T> sin (const valarray<T>&);
|
| 113 |
template<class T> valarray<T> sinh (const valarray<T>&);
|
| 114 |
template<class T> valarray<T> sqrt (const valarray<T>&);
|
| 115 |
template<class T> valarray<T> tan (const valarray<T>&);
|
|
@@ -138,28 +170,28 @@ nested argument type.[^7]
|
|
| 138 |
|
| 139 |
Implementations introducing such replacement types shall provide
|
| 140 |
additional functions and operators as follows:
|
| 141 |
|
| 142 |
- for every function taking a `const valarray<T>&` other than `begin`
|
| 143 |
-
and `end`
|
| 144 |
replacement types shall be added;
|
| 145 |
- for every function taking two `const valarray<T>&` arguments,
|
| 146 |
identical functions taking every combination of `const valarray<T>&`
|
| 147 |
and replacement types shall be added.
|
| 148 |
|
| 149 |
In particular, an implementation shall allow a `valarray<T>` to be
|
| 150 |
constructed from such replacement types and shall allow assignments and
|
| 151 |
compound assignments of such types to `valarray<T>`, `slice_array<T>`,
|
| 152 |
`gslice_array<T>`, `mask_array<T>` and `indirect_array<T>` objects.
|
| 153 |
|
| 154 |
-
These library functions are permitted to throw a `bad_alloc`
|
| 155 |
-
[[bad.alloc]]
|
| 156 |
to carry out the operation. Note that the exception is not mandated.
|
| 157 |
|
| 158 |
### Class template `valarray` <a id="template.valarray">[[template.valarray]]</a>
|
| 159 |
|
| 160 |
-
####
|
| 161 |
|
| 162 |
``` cpp
|
| 163 |
namespace std {
|
| 164 |
template<class T> class valarray {
|
| 165 |
public:
|
|
@@ -259,14 +291,11 @@ object of type `valarray<T>` is referred to as an “array” throughout the
|
|
| 259 |
remainder of [[numarray]]. The illusion of higher dimensionality may be
|
| 260 |
produced by the familiar idiom of computed indices, together with the
|
| 261 |
powerful subsetting capabilities provided by the generalized subscript
|
| 262 |
operators.[^8]
|
| 263 |
|
| 264 |
-
|
| 265 |
-
in `<valarray>` as `inline`.
|
| 266 |
-
|
| 267 |
-
#### `valarray` constructors <a id="valarray.cons">[[valarray.cons]]</a>
|
| 268 |
|
| 269 |
``` cpp
|
| 270 |
valarray();
|
| 271 |
```
|
| 272 |
|
|
@@ -275,11 +304,11 @@ valarray();
|
|
| 275 |
``` cpp
|
| 276 |
explicit valarray(size_t n);
|
| 277 |
```
|
| 278 |
|
| 279 |
*Effects:* Constructs a `valarray` that has length `n`. Each element of
|
| 280 |
-
the array is value-initialized
|
| 281 |
|
| 282 |
``` cpp
|
| 283 |
valarray(const T& v, size_t n);
|
| 284 |
```
|
| 285 |
|
|
@@ -288,12 +317,11 @@ the array is initialized with `v`.
|
|
| 288 |
|
| 289 |
``` cpp
|
| 290 |
valarray(const T* p, size_t n);
|
| 291 |
```
|
| 292 |
|
| 293 |
-
*
|
| 294 |
-
elements.
|
| 295 |
|
| 296 |
*Effects:* Constructs a `valarray` that has length `n`. The values of
|
| 297 |
the elements of the array are initialized with the first `n` values
|
| 298 |
pointed to by the first argument.[^10]
|
| 299 |
|
|
@@ -336,11 +364,11 @@ templates to a `valarray`.
|
|
| 336 |
```
|
| 337 |
|
| 338 |
*Effects:* The destructor is applied to every element of `*this`; an
|
| 339 |
implementation may return all allocated memory.
|
| 340 |
|
| 341 |
-
####
|
| 342 |
|
| 343 |
``` cpp
|
| 344 |
valarray& operator=(const valarray& v);
|
| 345 |
```
|
| 346 |
|
|
@@ -348,11 +376,11 @@ valarray& operator=(const valarray& v);
|
|
| 348 |
the corresponding element of `v`. If the length of `v` is not equal to
|
| 349 |
the length of `*this`, resizes `*this` to make the two arrays the same
|
| 350 |
length, as if by calling `resize(v.size())`, before performing the
|
| 351 |
assignment.
|
| 352 |
|
| 353 |
-
*
|
| 354 |
|
| 355 |
*Returns:* `*this`.
|
| 356 |
|
| 357 |
``` cpp
|
| 358 |
valarray& operator=(valarray&& v) noexcept;
|
|
@@ -384,63 +412,64 @@ valarray& operator=(const slice_array<T>&);
|
|
| 384 |
valarray& operator=(const gslice_array<T>&);
|
| 385 |
valarray& operator=(const mask_array<T>&);
|
| 386 |
valarray& operator=(const indirect_array<T>&);
|
| 387 |
```
|
| 388 |
|
| 389 |
-
*
|
| 390 |
-
`size()`. The value of an element in the left-hand side of a
|
| 391 |
-
assignment operator does not depend on the value of another
|
| 392 |
-
that left-hand side.
|
| 393 |
|
| 394 |
These operators allow the results of a generalized subscripting
|
| 395 |
operation to be assigned directly to a `valarray`.
|
| 396 |
|
| 397 |
-
####
|
| 398 |
|
| 399 |
``` cpp
|
| 400 |
const T& operator[](size_t n) const;
|
| 401 |
T& operator[](size_t n);
|
| 402 |
```
|
| 403 |
|
| 404 |
-
*
|
| 405 |
|
| 406 |
*Returns:* A reference to the corresponding element of the array.
|
| 407 |
|
| 408 |
[*Note 1*: The expression `(a[i] = q, a[i]) == q` evaluates to `true`
|
| 409 |
for any non-constant `valarray<T> a`, any `T q`, and for any `size_t i`
|
| 410 |
such that the value of `i` is less than the length of
|
| 411 |
`a`. — *end note*]
|
| 412 |
|
| 413 |
-
*Remarks:* The expression `
|
| 414 |
-
all `size_t i` and `size_t j` such that
|
|
|
|
| 415 |
|
| 416 |
-
The expression `
|
| 417 |
-
`a` and `b` and for any `size_t i` and `size_t j`
|
| 418 |
-
`i < a.size()` and `j < b.size()`.
|
| 419 |
|
| 420 |
[*Note 2*: This property indicates an absence of aliasing and may be
|
| 421 |
used to advantage by optimizing compilers. Compilers may take advantage
|
| 422 |
of inlining, constant propagation, loop fusion, tracking of pointers
|
| 423 |
obtained from `operator new`, and other techniques to generate efficient
|
| 424 |
`valarray`s. — *end note*]
|
| 425 |
|
| 426 |
The reference returned by the subscript operator for an array shall be
|
| 427 |
-
valid until the member function
|
| 428 |
-
|
| 429 |
-
|
| 430 |
|
| 431 |
-
####
|
| 432 |
|
| 433 |
The member `operator[]` is overloaded to provide several ways to select
|
| 434 |
sequences of elements from among those controlled by `*this`. Each of
|
| 435 |
these operations returns a subset of the array. The const-qualified
|
| 436 |
versions return this subset as a new `valarray` object. The non-const
|
| 437 |
versions return a class template object which has reference semantics to
|
| 438 |
the original array, working in conjunction with various overloads of
|
| 439 |
`operator=` and other assigning operators to allow selective replacement
|
| 440 |
(slicing) of the controlled sequence. In each case the selected
|
| 441 |
-
element(s)
|
| 442 |
|
| 443 |
``` cpp
|
| 444 |
valarray operator[](slice slicearr) const;
|
| 445 |
```
|
| 446 |
|
|
@@ -587,30 +616,29 @@ v0[valarray<size_t>(vi, 5)] = v1;
|
|
| 587 |
// v0 == valarray<char>("abCDeBgAEjklmnop", 16)
|
| 588 |
```
|
| 589 |
|
| 590 |
— *end example*]
|
| 591 |
|
| 592 |
-
####
|
| 593 |
|
| 594 |
``` cpp
|
| 595 |
valarray operator+() const;
|
| 596 |
valarray operator-() const;
|
| 597 |
valarray operator~() const;
|
| 598 |
valarray<bool> operator!() const;
|
| 599 |
```
|
| 600 |
|
| 601 |
-
*
|
| 602 |
-
`T`
|
| 603 |
-
|
| 604 |
-
`operator!`)
|
| 605 |
-
`T` (`bool` for `operator!`).
|
| 606 |
|
| 607 |
*Returns:* A `valarray` whose length is `size()`. Each element of the
|
| 608 |
returned array is initialized with the result of applying the indicated
|
| 609 |
operator to the corresponding element of the array.
|
| 610 |
|
| 611 |
-
####
|
| 612 |
|
| 613 |
``` cpp
|
| 614 |
valarray& operator*= (const valarray& v);
|
| 615 |
valarray& operator/= (const valarray& v);
|
| 616 |
valarray& operator%= (const valarray& v);
|
|
@@ -621,15 +649,18 @@ valarray& operator&= (const valarray& v);
|
|
| 621 |
valarray& operator|= (const valarray& v);
|
| 622 |
valarray& operator<<=(const valarray& v);
|
| 623 |
valarray& operator>>=(const valarray& v);
|
| 624 |
```
|
| 625 |
|
| 626 |
-
*
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
|
|
|
|
|
|
|
|
|
| 631 |
|
| 632 |
*Effects:* Each of these operators performs the indicated operation on
|
| 633 |
each of the elements of `*this` and the corresponding element of `v`.
|
| 634 |
|
| 635 |
*Returns:* `*this`.
|
|
@@ -648,24 +679,23 @@ valarray& operator&= (const T& v);
|
|
| 648 |
valarray& operator|= (const T& v);
|
| 649 |
valarray& operator<<=(const T& v);
|
| 650 |
valarray& operator>>=(const T& v);
|
| 651 |
```
|
| 652 |
|
| 653 |
-
*
|
| 654 |
-
`T`
|
| 655 |
-
`T`.
|
| 656 |
|
| 657 |
*Effects:* Each of these operators applies the indicated operation to
|
| 658 |
each element of `*this` and `v`.
|
| 659 |
|
| 660 |
*Returns:* `*this`
|
| 661 |
|
| 662 |
*Remarks:* The appearance of an array on the left-hand side of a
|
| 663 |
compound assignment does not invalidate references or pointers to the
|
| 664 |
elements of the array.
|
| 665 |
|
| 666 |
-
####
|
| 667 |
|
| 668 |
``` cpp
|
| 669 |
void swap(valarray& v) noexcept;
|
| 670 |
```
|
| 671 |
|
|
@@ -684,33 +714,34 @@ size_t size() const;
|
|
| 684 |
|
| 685 |
``` cpp
|
| 686 |
T sum() const;
|
| 687 |
```
|
| 688 |
|
| 689 |
-
*
|
| 690 |
-
|
|
|
|
| 691 |
|
| 692 |
*Returns:* The sum of all the elements of the array. If the array has
|
| 693 |
length 1, returns the value of element 0. Otherwise, the returned value
|
| 694 |
is calculated by applying `operator+=` to a copy of an element of the
|
| 695 |
array and all other elements of the array in an unspecified order.
|
| 696 |
|
| 697 |
``` cpp
|
| 698 |
T min() const;
|
| 699 |
```
|
| 700 |
|
| 701 |
-
*
|
| 702 |
|
| 703 |
*Returns:* The minimum value contained in `*this`. For an array of
|
| 704 |
length 1, the value of element 0 is returned. For all other array
|
| 705 |
lengths, the determination is made using `operator<`.
|
| 706 |
|
| 707 |
``` cpp
|
| 708 |
T max() const;
|
| 709 |
```
|
| 710 |
|
| 711 |
-
*
|
| 712 |
|
| 713 |
*Returns:* The maximum value contained in `*this`. For an array of
|
| 714 |
length 1, the value of element 0 is returned. For all other array
|
| 715 |
lengths, the determination is made using `operator<`.
|
| 716 |
|
|
@@ -725,13 +756,13 @@ is `(*this)[`*`I`*` + n]` if *`I`*` + n` is non-negative and less than
|
|
| 725 |
[*Note 1*: If element zero is taken as the leftmost element, a positive
|
| 726 |
value of `n` shifts the elements left `n` places, with zero
|
| 727 |
fill. — *end note*]
|
| 728 |
|
| 729 |
[*Example 1*: If the argument has the value -2, the first two elements
|
| 730 |
-
of the result will be value-initialized
|
| 731 |
-
|
| 732 |
-
|
| 733 |
|
| 734 |
``` cpp
|
| 735 |
valarray cshift(int n) const;
|
| 736 |
```
|
| 737 |
|
|
@@ -757,183 +788,197 @@ void resize(size_t sz, T c = T());
|
|
| 757 |
assigns to each element the value of the second argument. Resizing
|
| 758 |
invalidates all pointers and references to elements in the array.
|
| 759 |
|
| 760 |
### `valarray` non-member operations <a id="valarray.nonmembers">[[valarray.nonmembers]]</a>
|
| 761 |
|
| 762 |
-
####
|
| 763 |
|
| 764 |
``` cpp
|
| 765 |
-
template<class T> valarray<T> operator*
|
| 766 |
-
|
| 767 |
-
template<class T> valarray<T> operator
|
| 768 |
-
|
| 769 |
-
template<class T> valarray<T> operator
|
| 770 |
-
|
| 771 |
-
template<class T> valarray<T> operator
|
| 772 |
-
|
| 773 |
-
template<class T> valarray<T> operator
|
| 774 |
-
|
| 775 |
-
template<class T> valarray<T> operator^
|
| 776 |
-
(const valarray<T>&, const valarray<T>&);
|
| 777 |
-
template<class T> valarray<T> operator&
|
| 778 |
-
(const valarray<T>&, const valarray<T>&);
|
| 779 |
-
template<class T> valarray<T> operator|
|
| 780 |
-
(const valarray<T>&, const valarray<T>&);
|
| 781 |
-
template<class T> valarray<T> operator<<
|
| 782 |
-
(const valarray<T>&, const valarray<T>&);
|
| 783 |
-
template<class T> valarray<T> operator>>
|
| 784 |
-
(const valarray<T>&, const valarray<T>&);
|
| 785 |
```
|
| 786 |
|
| 787 |
-
*
|
| 788 |
-
`T`
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
the same length.
|
| 792 |
|
| 793 |
*Returns:* A `valarray` whose length is equal to the lengths of the
|
| 794 |
argument arrays. Each element of the returned array is initialized with
|
| 795 |
the result of applying the indicated operator to the corresponding
|
| 796 |
elements of the argument arrays.
|
| 797 |
|
| 798 |
``` cpp
|
| 799 |
-
template<class T> valarray<T> operator* (const valarray<T>&,
|
| 800 |
-
|
| 801 |
-
template<class T> valarray<T> operator
|
| 802 |
-
|
| 803 |
-
template<class T> valarray<T> operator
|
| 804 |
-
|
| 805 |
-
template<class T> valarray<T> operator
|
| 806 |
-
|
| 807 |
-
template<class T> valarray<T> operator
|
| 808 |
-
|
| 809 |
-
template<class T> valarray<T> operator
|
| 810 |
-
|
| 811 |
-
template<class T> valarray<T> operator
|
| 812 |
-
|
| 813 |
-
template<class T> valarray<T> operator
|
| 814 |
-
|
| 815 |
-
template<class T> valarray<T> operator
|
| 816 |
-
|
| 817 |
-
template<class T> valarray<T> operator
|
| 818 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 819 |
```
|
| 820 |
|
| 821 |
-
*
|
| 822 |
-
`T`
|
| 823 |
-
|
| 824 |
-
unambiguously implicitly converted to type `T`.
|
| 825 |
|
| 826 |
*Returns:* A `valarray` whose length is equal to the length of the array
|
| 827 |
argument. Each element of the returned array is initialized with the
|
| 828 |
result of applying the indicated operator to the corresponding element
|
| 829 |
of the array argument and the non-array argument.
|
| 830 |
|
| 831 |
-
####
|
| 832 |
|
| 833 |
``` cpp
|
| 834 |
-
template<class T> valarray<bool> operator==
|
| 835 |
-
|
| 836 |
-
template<class T> valarray<bool> operator
|
| 837 |
-
|
| 838 |
-
template<class T> valarray<bool> operator<
|
| 839 |
-
|
| 840 |
-
template<class T> valarray<bool> operator>
|
| 841 |
-
|
| 842 |
-
template<class T> valarray<bool> operator<=
|
| 843 |
-
(const valarray<T>&, const valarray<T>&);
|
| 844 |
-
template<class T> valarray<bool> operator>=
|
| 845 |
-
(const valarray<T>&, const valarray<T>&);
|
| 846 |
-
template<class T> valarray<bool> operator&&
|
| 847 |
-
(const valarray<T>&, const valarray<T>&);
|
| 848 |
-
template<class T> valarray<bool> operator||
|
| 849 |
-
(const valarray<T>&, const valarray<T>&);
|
| 850 |
```
|
| 851 |
|
| 852 |
-
*
|
| 853 |
-
`T`
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
arguments have the same length.
|
| 857 |
|
| 858 |
*Returns:* A `valarray<bool>` whose length is equal to the length of the
|
| 859 |
array arguments. Each element of the returned array is initialized with
|
| 860 |
the result of applying the indicated operator to the corresponding
|
| 861 |
elements of the argument arrays.
|
| 862 |
|
| 863 |
``` cpp
|
| 864 |
-
template<class T> valarray<bool> operator==(const valarray<T>&,
|
| 865 |
-
|
| 866 |
-
template<class T> valarray<bool> operator
|
| 867 |
-
|
| 868 |
-
template<class T> valarray<bool> operator
|
| 869 |
-
|
| 870 |
-
template<class T> valarray<bool> operator
|
| 871 |
-
|
| 872 |
-
template<class T> valarray<bool> operator<
|
| 873 |
-
|
| 874 |
-
template<class T> valarray<bool> operator
|
| 875 |
-
|
| 876 |
-
template<class T> valarray<bool> operator
|
| 877 |
-
|
| 878 |
-
template<class T> valarray<bool> operator
|
| 879 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 880 |
```
|
| 881 |
|
| 882 |
-
*
|
| 883 |
-
`T`
|
| 884 |
-
|
| 885 |
-
be unambiguously implicitly converted to type `bool`.
|
| 886 |
|
| 887 |
*Returns:* A `valarray<bool>` whose length is equal to the length of the
|
| 888 |
array argument. Each element of the returned array is initialized with
|
| 889 |
the result of applying the indicated operator to the corresponding
|
| 890 |
element of the array and the non-array argument.
|
| 891 |
|
| 892 |
-
####
|
| 893 |
|
| 894 |
``` cpp
|
| 895 |
template<class T> valarray<T> abs (const valarray<T>&);
|
| 896 |
template<class T> valarray<T> acos (const valarray<T>&);
|
| 897 |
template<class T> valarray<T> asin (const valarray<T>&);
|
| 898 |
template<class T> valarray<T> atan (const valarray<T>&);
|
| 899 |
-
template<class T> valarray<T> atan2
|
| 900 |
-
|
| 901 |
-
template<class T> valarray<T> atan2(const valarray<T>&, const T&);
|
| 902 |
-
template<class T> valarray<T> atan2(const T&, const valarray<T>&);
|
| 903 |
template<class T> valarray<T> cos (const valarray<T>&);
|
| 904 |
template<class T> valarray<T> cosh (const valarray<T>&);
|
| 905 |
template<class T> valarray<T> exp (const valarray<T>&);
|
| 906 |
template<class T> valarray<T> log (const valarray<T>&);
|
| 907 |
template<class T> valarray<T> log10(const valarray<T>&);
|
| 908 |
-
template<class T> valarray<T> pow
|
| 909 |
-
|
| 910 |
-
template<class T> valarray<T> pow (const valarray<T>&, const T&);
|
| 911 |
-
template<class T> valarray<T> pow (const T&, const valarray<T>&);
|
| 912 |
template<class T> valarray<T> sin (const valarray<T>&);
|
| 913 |
template<class T> valarray<T> sinh (const valarray<T>&);
|
| 914 |
template<class T> valarray<T> sqrt (const valarray<T>&);
|
| 915 |
template<class T> valarray<T> tan (const valarray<T>&);
|
| 916 |
template<class T> valarray<T> tanh (const valarray<T>&);
|
| 917 |
```
|
| 918 |
|
| 919 |
-
*
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
|
| 924 |
-
####
|
| 925 |
|
| 926 |
``` cpp
|
| 927 |
template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
|
| 928 |
```
|
| 929 |
|
| 930 |
*Effects:* Equivalent to `x.swap(y)`.
|
| 931 |
|
| 932 |
### Class `slice` <a id="class.slice">[[class.slice]]</a>
|
| 933 |
|
| 934 |
-
####
|
| 935 |
|
| 936 |
``` cpp
|
| 937 |
namespace std {
|
| 938 |
class slice {
|
| 939 |
public:
|
|
@@ -941,18 +986,20 @@ namespace std {
|
|
| 941 |
slice(size_t, size_t, size_t);
|
| 942 |
|
| 943 |
size_t start() const;
|
| 944 |
size_t size() const;
|
| 945 |
size_t stride() const;
|
|
|
|
|
|
|
| 946 |
};
|
| 947 |
}
|
| 948 |
```
|
| 949 |
|
| 950 |
The `slice` class represents a BLAS-like slice from an array. Such a
|
| 951 |
slice is specified by a starting index, a length, and a stride.[^12]
|
| 952 |
|
| 953 |
-
####
|
| 954 |
|
| 955 |
``` cpp
|
| 956 |
slice();
|
| 957 |
slice(size_t start, size_t length, size_t stride);
|
| 958 |
slice(const slice&);
|
|
@@ -962,13 +1009,13 @@ The default constructor is equivalent to `slice(0, 0, 0)`. A default
|
|
| 962 |
constructor is provided only to permit the declaration of arrays of
|
| 963 |
slices. The constructor with arguments for a slice takes a start,
|
| 964 |
length, and stride parameter.
|
| 965 |
|
| 966 |
[*Example 1*: `slice(3, 8, 2)` constructs a slice which selects
|
| 967 |
-
elements 3, 5, 7,
|
| 968 |
|
| 969 |
-
####
|
| 970 |
|
| 971 |
``` cpp
|
| 972 |
size_t start() const;
|
| 973 |
size_t size() const;
|
| 974 |
size_t stride() const;
|
|
@@ -976,13 +1023,25 @@ size_t stride() const;
|
|
| 976 |
|
| 977 |
*Returns:* The start, length, or stride specified by a `slice` object.
|
| 978 |
|
| 979 |
*Complexity:* Constant time.
|
| 980 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 981 |
### Class template `slice_array` <a id="template.slice.array">[[template.slice.array]]</a>
|
| 982 |
|
| 983 |
-
####
|
| 984 |
|
| 985 |
``` cpp
|
| 986 |
namespace std {
|
| 987 |
template<class T> class slice_array {
|
| 988 |
public:
|
|
@@ -1008,37 +1067,37 @@ namespace std {
|
|
| 1008 |
slice_array() = delete; // as implied by declaring copy constructor above
|
| 1009 |
};
|
| 1010 |
}
|
| 1011 |
```
|
| 1012 |
|
| 1013 |
-
|
| 1014 |
-
|
| 1015 |
|
| 1016 |
``` cpp
|
| 1017 |
slice_array<T> valarray<T>::operator[](slice);
|
| 1018 |
```
|
| 1019 |
|
| 1020 |
It has reference semantics to a subset of an array specified by a
|
| 1021 |
`slice` object.
|
| 1022 |
|
| 1023 |
[*Example 1*: The expression `a[slice(1, 5, 3)] = b;` has the effect of
|
| 1024 |
assigning the elements of `b` to a slice of the elements in `a`. For the
|
| 1025 |
-
slice shown, the elements selected from `a` are
|
| 1026 |
-
13. — *end example*]
|
| 1027 |
|
| 1028 |
-
####
|
| 1029 |
|
| 1030 |
``` cpp
|
| 1031 |
void operator=(const valarray<T>&) const;
|
| 1032 |
const slice_array& operator=(const slice_array&) const;
|
| 1033 |
```
|
| 1034 |
|
| 1035 |
These assignment operators have reference semantics, assigning the
|
| 1036 |
values of the argument array elements to selected elements of the
|
| 1037 |
`valarray<T>` object to which the `slice_array` object refers.
|
| 1038 |
|
| 1039 |
-
####
|
| 1040 |
|
| 1041 |
``` cpp
|
| 1042 |
void operator*= (const valarray<T>&) const;
|
| 1043 |
void operator/= (const valarray<T>&) const;
|
| 1044 |
void operator%= (const valarray<T>&) const;
|
|
@@ -1054,11 +1113,11 @@ void operator>>=(const valarray<T>&) const;
|
|
| 1054 |
These compound assignments have reference semantics, applying the
|
| 1055 |
indicated operation to the elements of the argument array and selected
|
| 1056 |
elements of the `valarray<T>` object to which the `slice_array` object
|
| 1057 |
refers.
|
| 1058 |
|
| 1059 |
-
####
|
| 1060 |
|
| 1061 |
``` cpp
|
| 1062 |
void operator=(const T&) const;
|
| 1063 |
```
|
| 1064 |
|
|
@@ -1066,11 +1125,11 @@ This function has reference semantics, assigning the value of its
|
|
| 1066 |
argument to the elements of the `valarray<T>` object to which the
|
| 1067 |
`slice_array` object refers.
|
| 1068 |
|
| 1069 |
### The `gslice` class <a id="class.gslice">[[class.gslice]]</a>
|
| 1070 |
|
| 1071 |
-
####
|
| 1072 |
|
| 1073 |
``` cpp
|
| 1074 |
namespace std {
|
| 1075 |
class gslice {
|
| 1076 |
public:
|
|
@@ -1124,11 +1183,11 @@ If the stride parameters in the previous example are changed to {1, 1,
|
|
| 1124 |
— *end example*]
|
| 1125 |
|
| 1126 |
If a degenerate slice is used as the argument to the non-`const` version
|
| 1127 |
of `operator[](const gslice&)`, the behavior is undefined.
|
| 1128 |
|
| 1129 |
-
####
|
| 1130 |
|
| 1131 |
``` cpp
|
| 1132 |
gslice();
|
| 1133 |
gslice(size_t start, const valarray<size_t>& lengths,
|
| 1134 |
const valarray<size_t>& strides);
|
|
@@ -1136,13 +1195,13 @@ gslice(const gslice&);
|
|
| 1136 |
```
|
| 1137 |
|
| 1138 |
The default constructor is equivalent to
|
| 1139 |
`gslice(0, valarray<size_t>(), valarray<size_t>())`. The constructor
|
| 1140 |
with arguments builds a `gslice` based on a specification of start,
|
| 1141 |
-
lengths, and strides, as explained in the previous
|
| 1142 |
|
| 1143 |
-
####
|
| 1144 |
|
| 1145 |
``` cpp
|
| 1146 |
size_t start() const;
|
| 1147 |
valarray<size_t> size() const;
|
| 1148 |
valarray<size_t> stride() const;
|
|
@@ -1154,11 +1213,11 @@ specified for the `gslice`.
|
|
| 1154 |
*Complexity:* `start()` is constant time. `size()` and `stride()` are
|
| 1155 |
linear in the number of strides.
|
| 1156 |
|
| 1157 |
### Class template `gslice_array` <a id="template.gslice.array">[[template.gslice.array]]</a>
|
| 1158 |
|
| 1159 |
-
####
|
| 1160 |
|
| 1161 |
``` cpp
|
| 1162 |
namespace std {
|
| 1163 |
template<class T> class gslice_array {
|
| 1164 |
public:
|
|
@@ -1184,36 +1243,34 @@ namespace std {
|
|
| 1184 |
gslice_array() = delete; // as implied by declaring copy constructor above
|
| 1185 |
};
|
| 1186 |
}
|
| 1187 |
```
|
| 1188 |
|
| 1189 |
-
This template is a helper template used by the `
|
| 1190 |
operator
|
| 1191 |
|
| 1192 |
``` cpp
|
| 1193 |
gslice_array<T> valarray<T>::operator[](const gslice&);
|
| 1194 |
```
|
| 1195 |
|
| 1196 |
It has reference semantics to a subset of an array specified by a
|
| 1197 |
-
`gslice` object.
|
|
|
|
|
|
|
| 1198 |
|
| 1199 |
-
|
| 1200 |
-
of assigning the elements of `b` to a generalized slice of the elements
|
| 1201 |
-
in `a`.
|
| 1202 |
-
|
| 1203 |
-
#### `gslice_array` assignment <a id="gslice.array.assign">[[gslice.array.assign]]</a>
|
| 1204 |
|
| 1205 |
``` cpp
|
| 1206 |
void operator=(const valarray<T>&) const;
|
| 1207 |
const gslice_array& operator=(const gslice_array&) const;
|
| 1208 |
```
|
| 1209 |
|
| 1210 |
These assignment operators have reference semantics, assigning the
|
| 1211 |
values of the argument array elements to selected elements of the
|
| 1212 |
`valarray<T>` object to which the `gslice_array` refers.
|
| 1213 |
|
| 1214 |
-
####
|
| 1215 |
|
| 1216 |
``` cpp
|
| 1217 |
void operator*= (const valarray<T>&) const;
|
| 1218 |
void operator/= (const valarray<T>&) const;
|
| 1219 |
void operator%= (const valarray<T>&) const;
|
|
@@ -1229,11 +1286,11 @@ void operator>>=(const valarray<T>&) const;
|
|
| 1229 |
These compound assignments have reference semantics, applying the
|
| 1230 |
indicated operation to the elements of the argument array and selected
|
| 1231 |
elements of the `valarray<T>` object to which the `gslice_array` object
|
| 1232 |
refers.
|
| 1233 |
|
| 1234 |
-
####
|
| 1235 |
|
| 1236 |
``` cpp
|
| 1237 |
void operator=(const T&) const;
|
| 1238 |
```
|
| 1239 |
|
|
@@ -1241,11 +1298,11 @@ This function has reference semantics, assigning the value of its
|
|
| 1241 |
argument to the elements of the `valarray<T>` object to which the
|
| 1242 |
`gslice_array` object refers.
|
| 1243 |
|
| 1244 |
### Class template `mask_array` <a id="template.mask.array">[[template.mask.array]]</a>
|
| 1245 |
|
| 1246 |
-
####
|
| 1247 |
|
| 1248 |
``` cpp
|
| 1249 |
namespace std {
|
| 1250 |
template<class T> class mask_array {
|
| 1251 |
public:
|
|
@@ -1280,24 +1337,24 @@ mask_array<T> valarray<T>::operator[](const valarray<bool>&).
|
|
| 1280 |
```
|
| 1281 |
|
| 1282 |
It has reference semantics to a subset of an array specified by a
|
| 1283 |
boolean mask. Thus, the expression `a[mask] = b;` has the effect of
|
| 1284 |
assigning the elements of `b` to the masked elements in `a` (those for
|
| 1285 |
-
which the corresponding element in `mask` is `true`
|
| 1286 |
|
| 1287 |
-
####
|
| 1288 |
|
| 1289 |
``` cpp
|
| 1290 |
void operator=(const valarray<T>&) const;
|
| 1291 |
const mask_array& operator=(const mask_array&) const;
|
| 1292 |
```
|
| 1293 |
|
| 1294 |
These assignment operators have reference semantics, assigning the
|
| 1295 |
values of the argument array elements to selected elements of the
|
| 1296 |
`valarray<T>` object to which it refers.
|
| 1297 |
|
| 1298 |
-
####
|
| 1299 |
|
| 1300 |
``` cpp
|
| 1301 |
void operator*= (const valarray<T>&) const;
|
| 1302 |
void operator/= (const valarray<T>&) const;
|
| 1303 |
void operator%= (const valarray<T>&) const;
|
|
@@ -1312,11 +1369,11 @@ void operator>>=(const valarray<T>&) const;
|
|
| 1312 |
|
| 1313 |
These compound assignments have reference semantics, applying the
|
| 1314 |
indicated operation to the elements of the argument array and selected
|
| 1315 |
elements of the `valarray<T>` object to which the mask object refers.
|
| 1316 |
|
| 1317 |
-
####
|
| 1318 |
|
| 1319 |
``` cpp
|
| 1320 |
void operator=(const T&) const;
|
| 1321 |
```
|
| 1322 |
|
|
@@ -1324,11 +1381,11 @@ This function has reference semantics, assigning the value of its
|
|
| 1324 |
argument to the elements of the `valarray<T>` object to which the
|
| 1325 |
`mask_array` object refers.
|
| 1326 |
|
| 1327 |
### Class template `indirect_array` <a id="template.indirect.array">[[template.indirect.array]]</a>
|
| 1328 |
|
| 1329 |
-
####
|
| 1330 |
|
| 1331 |
``` cpp
|
| 1332 |
namespace std {
|
| 1333 |
template<class T> class indirect_array {
|
| 1334 |
public:
|
|
@@ -1362,15 +1419,15 @@ operator
|
|
| 1362 |
``` cpp
|
| 1363 |
indirect_array<T> valarray<T>::operator[](const valarray<size_t>&).
|
| 1364 |
```
|
| 1365 |
|
| 1366 |
It has reference semantics to a subset of an array specified by an
|
| 1367 |
-
`indirect_array`. Thus the expression `a[indirect] = b;` has the
|
| 1368 |
-
of assigning the elements of `b` to the elements in `a` whose
|
| 1369 |
-
appear in `indirect`.
|
| 1370 |
|
| 1371 |
-
####
|
| 1372 |
|
| 1373 |
``` cpp
|
| 1374 |
void operator=(const valarray<T>&) const;
|
| 1375 |
const indirect_array& operator=(const indirect_array&) const;
|
| 1376 |
```
|
|
@@ -1394,11 +1451,11 @@ a[indirect] = b;
|
|
| 1394 |
results in undefined behavior since element 4 is specified twice in the
|
| 1395 |
indirection.
|
| 1396 |
|
| 1397 |
— *end example*]
|
| 1398 |
|
| 1399 |
-
####
|
| 1400 |
|
| 1401 |
``` cpp
|
| 1402 |
void operator*= (const valarray<T>&) const;
|
| 1403 |
void operator/= (const valarray<T>&) const;
|
| 1404 |
void operator%= (const valarray<T>&) const;
|
|
@@ -1417,11 +1474,11 @@ elements of the `valarray<T>` object to which the `indirect_array`
|
|
| 1417 |
object refers.
|
| 1418 |
|
| 1419 |
If the `indirect_array` specifies an element in the `valarray<T>` object
|
| 1420 |
to which it refers more than once, the behavior is undefined.
|
| 1421 |
|
| 1422 |
-
####
|
| 1423 |
|
| 1424 |
``` cpp
|
| 1425 |
void operator=(const T&) const;
|
| 1426 |
```
|
| 1427 |
|
|
@@ -1430,22 +1487,22 @@ argument to the elements of the `valarray<T>` object to which the
|
|
| 1430 |
`indirect_array` object refers.
|
| 1431 |
|
| 1432 |
### `valarray` range access <a id="valarray.range">[[valarray.range]]</a>
|
| 1433 |
|
| 1434 |
In the `begin` and `end` function templates that follow, *unspecified*1
|
| 1435 |
-
is a type that meets the requirements of a mutable
|
| 1436 |
-
|
| 1437 |
-
[[iterator.
|
| 1438 |
-
parameter `T` and whose `reference` type is
|
| 1439 |
-
type that meets the requirements of a constant
|
| 1440 |
-
|
| 1441 |
-
|
| 1442 |
-
|
| 1443 |
|
| 1444 |
The iterators returned by `begin` and `end` for an array are guaranteed
|
| 1445 |
-
to be valid until the member function `resize(size_t, T)`
|
| 1446 |
-
[[valarray.members]]
|
| 1447 |
that array ends, whichever happens first.
|
| 1448 |
|
| 1449 |
``` cpp
|
| 1450 |
template<class T> unspecified{1} begin(valarray<T>& v);
|
| 1451 |
template<class T> unspecified{2} begin(const valarray<T>& v);
|
|
|
|
| 15 |
template<class T> class indirect_array; // an indirected array
|
| 16 |
|
| 17 |
template<class T> void swap(valarray<T>&, valarray<T>&) noexcept;
|
| 18 |
|
| 19 |
template<class T> valarray<T> operator* (const valarray<T>&, const valarray<T>&);
|
| 20 |
+
template<class T> valarray<T> operator* (const valarray<T>&,
|
| 21 |
+
const typename valarray<T>::value_type&);
|
| 22 |
+
template<class T> valarray<T> operator* (const typename valarray<T>::value_type&,
|
| 23 |
+
const valarray<T>&);
|
| 24 |
|
| 25 |
template<class T> valarray<T> operator/ (const valarray<T>&, const valarray<T>&);
|
| 26 |
+
template<class T> valarray<T> operator/ (const valarray<T>&,
|
| 27 |
+
const typename valarray<T>::value_type&);
|
| 28 |
+
template<class T> valarray<T> operator/ (const typename valarray<T>::value_type&,
|
| 29 |
+
const valarray<T>&);
|
| 30 |
|
| 31 |
template<class T> valarray<T> operator% (const valarray<T>&, const valarray<T>&);
|
| 32 |
+
template<class T> valarray<T> operator% (const valarray<T>&,
|
| 33 |
+
const typename valarray<T>::value_type&);
|
| 34 |
+
template<class T> valarray<T> operator% (const typename valarray<T>::value_type&,
|
| 35 |
+
const valarray<T>&);
|
| 36 |
|
| 37 |
template<class T> valarray<T> operator+ (const valarray<T>&, const valarray<T>&);
|
| 38 |
+
template<class T> valarray<T> operator+ (const valarray<T>&,
|
| 39 |
+
const typename valarray<T>::value_type&);
|
| 40 |
+
template<class T> valarray<T> operator+ (const typename valarray<T>::value_type&,
|
| 41 |
+
const valarray<T>&);
|
| 42 |
|
| 43 |
template<class T> valarray<T> operator- (const valarray<T>&, const valarray<T>&);
|
| 44 |
+
template<class T> valarray<T> operator- (const valarray<T>&,
|
| 45 |
+
const typename valarray<T>::value_type&);
|
| 46 |
+
template<class T> valarray<T> operator- (const typename valarray<T>::value_type&,
|
| 47 |
+
const valarray<T>&);
|
| 48 |
|
| 49 |
template<class T> valarray<T> operator^ (const valarray<T>&, const valarray<T>&);
|
| 50 |
+
template<class T> valarray<T> operator^ (const valarray<T>&,
|
| 51 |
+
const typename valarray<T>::value_type&);
|
| 52 |
+
template<class T> valarray<T> operator^ (const typename valarray<T>::value_type&,
|
| 53 |
+
const valarray<T>&);
|
| 54 |
|
| 55 |
template<class T> valarray<T> operator& (const valarray<T>&, const valarray<T>&);
|
| 56 |
+
template<class T> valarray<T> operator& (const valarray<T>&,
|
| 57 |
+
const typename valarray<T>::value_type&);
|
| 58 |
+
template<class T> valarray<T> operator& (const typename valarray<T>::value_type&,
|
| 59 |
+
const valarray<T>&);
|
| 60 |
|
| 61 |
template<class T> valarray<T> operator| (const valarray<T>&, const valarray<T>&);
|
| 62 |
+
template<class T> valarray<T> operator| (const valarray<T>&,
|
| 63 |
+
const typename valarray<T>::value_type&);
|
| 64 |
+
template<class T> valarray<T> operator| (const typename valarray<T>::value_type&,
|
| 65 |
+
const valarray<T>&);
|
| 66 |
|
| 67 |
template<class T> valarray<T> operator<<(const valarray<T>&, const valarray<T>&);
|
| 68 |
+
template<class T> valarray<T> operator<<(const valarray<T>&,
|
| 69 |
+
const typename valarray<T>::value_type&);
|
| 70 |
+
template<class T> valarray<T> operator<<(const typename valarray<T>::value_type&,
|
| 71 |
+
const valarray<T>&);
|
| 72 |
|
| 73 |
template<class T> valarray<T> operator>>(const valarray<T>&, const valarray<T>&);
|
| 74 |
+
template<class T> valarray<T> operator>>(const valarray<T>&,
|
| 75 |
+
const typename valarray<T>::value_type&);
|
| 76 |
+
template<class T> valarray<T> operator>>(const typename valarray<T>::value_type&,
|
| 77 |
+
const valarray<T>&);
|
| 78 |
|
| 79 |
template<class T> valarray<bool> operator&&(const valarray<T>&, const valarray<T>&);
|
| 80 |
+
template<class T> valarray<bool> operator&&(const valarray<T>&,
|
| 81 |
+
const typename valarray<T>::value_type&);
|
| 82 |
+
template<class T> valarray<bool> operator&&(const typename valarray<T>::value_type&,
|
| 83 |
+
const valarray<T>&);
|
| 84 |
|
| 85 |
template<class T> valarray<bool> operator||(const valarray<T>&, const valarray<T>&);
|
| 86 |
+
template<class T> valarray<bool> operator||(const valarray<T>&,
|
| 87 |
+
const typename valarray<T>::value_type&);
|
| 88 |
+
template<class T> valarray<bool> operator||(const typename valarray<T>::value_type&,
|
| 89 |
+
const valarray<T>&);
|
| 90 |
|
| 91 |
+
template<class T> valarray<bool> operator==(const valarray<T>&, const valarray<T>&);
|
| 92 |
+
template<class T> valarray<bool> operator==(const valarray<T>&,
|
| 93 |
+
const typename valarray<T>::value_type&);
|
| 94 |
+
template<class T> valarray<bool> operator==(const typename valarray<T>::value_type&,
|
| 95 |
+
const valarray<T>&);
|
| 96 |
+
template<class T> valarray<bool> operator!=(const valarray<T>&, const valarray<T>&);
|
| 97 |
+
template<class T> valarray<bool> operator!=(const valarray<T>&,
|
| 98 |
+
const typename valarray<T>::value_type&);
|
| 99 |
+
template<class T> valarray<bool> operator!=(const typename valarray<T>::value_type&,
|
| 100 |
+
const valarray<T>&);
|
| 101 |
|
| 102 |
+
template<class T> valarray<bool> operator< (const valarray<T>&, const valarray<T>&);
|
| 103 |
+
template<class T> valarray<bool> operator< (const valarray<T>&,
|
| 104 |
+
const typename valarray<T>::value_type&);
|
| 105 |
+
template<class T> valarray<bool> operator< (const typename valarray<T>::value_type&,
|
| 106 |
+
const valarray<T>&);
|
| 107 |
+
template<class T> valarray<bool> operator> (const valarray<T>&, const valarray<T>&);
|
| 108 |
+
template<class T> valarray<bool> operator> (const valarray<T>&,
|
| 109 |
+
const typename valarray<T>::value_type&);
|
| 110 |
+
template<class T> valarray<bool> operator> (const typename valarray<T>::value_type&,
|
| 111 |
+
const valarray<T>&);
|
| 112 |
+
template<class T> valarray<bool> operator<=(const valarray<T>&, const valarray<T>&);
|
| 113 |
+
template<class T> valarray<bool> operator<=(const valarray<T>&,
|
| 114 |
+
const typename valarray<T>::value_type&);
|
| 115 |
+
template<class T> valarray<bool> operator<=(const typename valarray<T>::value_type&,
|
| 116 |
+
const valarray<T>&);
|
| 117 |
+
template<class T> valarray<bool> operator>=(const valarray<T>&, const valarray<T>&);
|
| 118 |
+
template<class T> valarray<bool> operator>=(const valarray<T>&,
|
| 119 |
+
const typename valarray<T>::value_type&);
|
| 120 |
+
template<class T> valarray<bool> operator>=(const typename valarray<T>::value_type&,
|
| 121 |
+
const valarray<T>&);
|
| 122 |
|
| 123 |
template<class T> valarray<T> abs (const valarray<T>&);
|
| 124 |
template<class T> valarray<T> acos (const valarray<T>&);
|
| 125 |
template<class T> valarray<T> asin (const valarray<T>&);
|
| 126 |
template<class T> valarray<T> atan (const valarray<T>&);
|
| 127 |
|
| 128 |
template<class T> valarray<T> atan2(const valarray<T>&, const valarray<T>&);
|
| 129 |
+
template<class T> valarray<T> atan2(const valarray<T>&,
|
| 130 |
+
const typename valarray<T>::value_type&);
|
| 131 |
+
template<class T> valarray<T> atan2(const typename valarray<T>::value_type&,
|
| 132 |
+
const valarray<T>&);
|
| 133 |
|
| 134 |
template<class T> valarray<T> cos (const valarray<T>&);
|
| 135 |
template<class T> valarray<T> cosh (const valarray<T>&);
|
| 136 |
template<class T> valarray<T> exp (const valarray<T>&);
|
| 137 |
template<class T> valarray<T> log (const valarray<T>&);
|
| 138 |
template<class T> valarray<T> log10(const valarray<T>&);
|
| 139 |
|
| 140 |
template<class T> valarray<T> pow(const valarray<T>&, const valarray<T>&);
|
| 141 |
+
template<class T> valarray<T> pow(const valarray<T>&, const typename valarray<T>::value_type&);
|
| 142 |
+
template<class T> valarray<T> pow(const typename valarray<T>::value_type&, const valarray<T>&);
|
| 143 |
|
| 144 |
template<class T> valarray<T> sin (const valarray<T>&);
|
| 145 |
template<class T> valarray<T> sinh (const valarray<T>&);
|
| 146 |
template<class T> valarray<T> sqrt (const valarray<T>&);
|
| 147 |
template<class T> valarray<T> tan (const valarray<T>&);
|
|
|
|
| 170 |
|
| 171 |
Implementations introducing such replacement types shall provide
|
| 172 |
additional functions and operators as follows:
|
| 173 |
|
| 174 |
- for every function taking a `const valarray<T>&` other than `begin`
|
| 175 |
+
and `end` [[valarray.range]], identical functions taking the
|
| 176 |
replacement types shall be added;
|
| 177 |
- for every function taking two `const valarray<T>&` arguments,
|
| 178 |
identical functions taking every combination of `const valarray<T>&`
|
| 179 |
and replacement types shall be added.
|
| 180 |
|
| 181 |
In particular, an implementation shall allow a `valarray<T>` to be
|
| 182 |
constructed from such replacement types and shall allow assignments and
|
| 183 |
compound assignments of such types to `valarray<T>`, `slice_array<T>`,
|
| 184 |
`gslice_array<T>`, `mask_array<T>` and `indirect_array<T>` objects.
|
| 185 |
|
| 186 |
+
These library functions are permitted to throw a `bad_alloc`
|
| 187 |
+
[[bad.alloc]] exception if there are not sufficient resources available
|
| 188 |
to carry out the operation. Note that the exception is not mandated.
|
| 189 |
|
| 190 |
### Class template `valarray` <a id="template.valarray">[[template.valarray]]</a>
|
| 191 |
|
| 192 |
+
#### Overview <a id="template.valarray.overview">[[template.valarray.overview]]</a>
|
| 193 |
|
| 194 |
``` cpp
|
| 195 |
namespace std {
|
| 196 |
template<class T> class valarray {
|
| 197 |
public:
|
|
|
|
| 291 |
remainder of [[numarray]]. The illusion of higher dimensionality may be
|
| 292 |
produced by the familiar idiom of computed indices, together with the
|
| 293 |
powerful subsetting capabilities provided by the generalized subscript
|
| 294 |
operators.[^8]
|
| 295 |
|
| 296 |
+
#### Constructors <a id="valarray.cons">[[valarray.cons]]</a>
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
``` cpp
|
| 299 |
valarray();
|
| 300 |
```
|
| 301 |
|
|
|
|
| 304 |
``` cpp
|
| 305 |
explicit valarray(size_t n);
|
| 306 |
```
|
| 307 |
|
| 308 |
*Effects:* Constructs a `valarray` that has length `n`. Each element of
|
| 309 |
+
the array is value-initialized [[dcl.init]].
|
| 310 |
|
| 311 |
``` cpp
|
| 312 |
valarray(const T& v, size_t n);
|
| 313 |
```
|
| 314 |
|
|
|
|
| 317 |
|
| 318 |
``` cpp
|
| 319 |
valarray(const T* p, size_t n);
|
| 320 |
```
|
| 321 |
|
| 322 |
+
*Preconditions:* \[`p`, `p + n`) is a valid range.
|
|
|
|
| 323 |
|
| 324 |
*Effects:* Constructs a `valarray` that has length `n`. The values of
|
| 325 |
the elements of the array are initialized with the first `n` values
|
| 326 |
pointed to by the first argument.[^10]
|
| 327 |
|
|
|
|
| 364 |
```
|
| 365 |
|
| 366 |
*Effects:* The destructor is applied to every element of `*this`; an
|
| 367 |
implementation may return all allocated memory.
|
| 368 |
|
| 369 |
+
#### Assignment <a id="valarray.assign">[[valarray.assign]]</a>
|
| 370 |
|
| 371 |
``` cpp
|
| 372 |
valarray& operator=(const valarray& v);
|
| 373 |
```
|
| 374 |
|
|
|
|
| 376 |
the corresponding element of `v`. If the length of `v` is not equal to
|
| 377 |
the length of `*this`, resizes `*this` to make the two arrays the same
|
| 378 |
length, as if by calling `resize(v.size())`, before performing the
|
| 379 |
assignment.
|
| 380 |
|
| 381 |
+
*Ensures:* `size() == v.size()`.
|
| 382 |
|
| 383 |
*Returns:* `*this`.
|
| 384 |
|
| 385 |
``` cpp
|
| 386 |
valarray& operator=(valarray&& v) noexcept;
|
|
|
|
| 412 |
valarray& operator=(const gslice_array<T>&);
|
| 413 |
valarray& operator=(const mask_array<T>&);
|
| 414 |
valarray& operator=(const indirect_array<T>&);
|
| 415 |
```
|
| 416 |
|
| 417 |
+
*Preconditions:* The length of the array to which the argument refers
|
| 418 |
+
equals `size()`. The value of an element in the left-hand side of a
|
| 419 |
+
`valarray` assignment operator does not depend on the value of another
|
| 420 |
+
element in that left-hand side.
|
| 421 |
|
| 422 |
These operators allow the results of a generalized subscripting
|
| 423 |
operation to be assigned directly to a `valarray`.
|
| 424 |
|
| 425 |
+
#### Element access <a id="valarray.access">[[valarray.access]]</a>
|
| 426 |
|
| 427 |
``` cpp
|
| 428 |
const T& operator[](size_t n) const;
|
| 429 |
T& operator[](size_t n);
|
| 430 |
```
|
| 431 |
|
| 432 |
+
*Preconditions:* `n < size()` is `true`.
|
| 433 |
|
| 434 |
*Returns:* A reference to the corresponding element of the array.
|
| 435 |
|
| 436 |
[*Note 1*: The expression `(a[i] = q, a[i]) == q` evaluates to `true`
|
| 437 |
for any non-constant `valarray<T> a`, any `T q`, and for any `size_t i`
|
| 438 |
such that the value of `i` is less than the length of
|
| 439 |
`a`. — *end note*]
|
| 440 |
|
| 441 |
+
*Remarks:* The expression `addressof(a[i+j]) == addressof(a[i]) + j`
|
| 442 |
+
evaluates to `true` for all `size_t i` and `size_t j` such that
|
| 443 |
+
`i+j < a.size()`.
|
| 444 |
|
| 445 |
+
The expression `addressof(a[i]) != addressof(b[j])` evaluates to `true`
|
| 446 |
+
for any two arrays `a` and `b` and for any `size_t i` and `size_t j`
|
| 447 |
+
such that `i < a.size()` and `j < b.size()`.
|
| 448 |
|
| 449 |
[*Note 2*: This property indicates an absence of aliasing and may be
|
| 450 |
used to advantage by optimizing compilers. Compilers may take advantage
|
| 451 |
of inlining, constant propagation, loop fusion, tracking of pointers
|
| 452 |
obtained from `operator new`, and other techniques to generate efficient
|
| 453 |
`valarray`s. — *end note*]
|
| 454 |
|
| 455 |
The reference returned by the subscript operator for an array shall be
|
| 456 |
+
valid until the member function `resize(size_t, T)` [[valarray.members]]
|
| 457 |
+
is called for that array or until the lifetime of that array ends,
|
| 458 |
+
whichever happens first.
|
| 459 |
|
| 460 |
+
#### Subset operations <a id="valarray.sub">[[valarray.sub]]</a>
|
| 461 |
|
| 462 |
The member `operator[]` is overloaded to provide several ways to select
|
| 463 |
sequences of elements from among those controlled by `*this`. Each of
|
| 464 |
these operations returns a subset of the array. The const-qualified
|
| 465 |
versions return this subset as a new `valarray` object. The non-const
|
| 466 |
versions return a class template object which has reference semantics to
|
| 467 |
the original array, working in conjunction with various overloads of
|
| 468 |
`operator=` and other assigning operators to allow selective replacement
|
| 469 |
(slicing) of the controlled sequence. In each case the selected
|
| 470 |
+
element(s) shall exist.
|
| 471 |
|
| 472 |
``` cpp
|
| 473 |
valarray operator[](slice slicearr) const;
|
| 474 |
```
|
| 475 |
|
|
|
|
| 616 |
// v0 == valarray<char>("abCDeBgAEjklmnop", 16)
|
| 617 |
```
|
| 618 |
|
| 619 |
— *end example*]
|
| 620 |
|
| 621 |
+
#### Unary operators <a id="valarray.unary">[[valarray.unary]]</a>
|
| 622 |
|
| 623 |
``` cpp
|
| 624 |
valarray operator+() const;
|
| 625 |
valarray operator-() const;
|
| 626 |
valarray operator~() const;
|
| 627 |
valarray<bool> operator!() const;
|
| 628 |
```
|
| 629 |
|
| 630 |
+
*Mandates:* The indicated operator can be applied to operands of type
|
| 631 |
+
`T` and returns a value of type `T` (`bool` for `operator!`) or which
|
| 632 |
+
may be unambiguously implicitly converted to type `T` (`bool` for
|
| 633 |
+
`operator!`).
|
|
|
|
| 634 |
|
| 635 |
*Returns:* A `valarray` whose length is `size()`. Each element of the
|
| 636 |
returned array is initialized with the result of applying the indicated
|
| 637 |
operator to the corresponding element of the array.
|
| 638 |
|
| 639 |
+
#### Compound assignment <a id="valarray.cassign">[[valarray.cassign]]</a>
|
| 640 |
|
| 641 |
``` cpp
|
| 642 |
valarray& operator*= (const valarray& v);
|
| 643 |
valarray& operator/= (const valarray& v);
|
| 644 |
valarray& operator%= (const valarray& v);
|
|
|
|
| 649 |
valarray& operator|= (const valarray& v);
|
| 650 |
valarray& operator<<=(const valarray& v);
|
| 651 |
valarray& operator>>=(const valarray& v);
|
| 652 |
```
|
| 653 |
|
| 654 |
+
*Mandates:* The indicated operator can be applied to two operands of
|
| 655 |
+
type `T`.
|
| 656 |
+
|
| 657 |
+
*Preconditions:* `size() == v.size()` is `true`.
|
| 658 |
+
|
| 659 |
+
The value of an element in the left-hand side of a valarray compound
|
| 660 |
+
assignment operator does not depend on the value of another element in
|
| 661 |
+
that left hand side.
|
| 662 |
|
| 663 |
*Effects:* Each of these operators performs the indicated operation on
|
| 664 |
each of the elements of `*this` and the corresponding element of `v`.
|
| 665 |
|
| 666 |
*Returns:* `*this`.
|
|
|
|
| 679 |
valarray& operator|= (const T& v);
|
| 680 |
valarray& operator<<=(const T& v);
|
| 681 |
valarray& operator>>=(const T& v);
|
| 682 |
```
|
| 683 |
|
| 684 |
+
*Mandates:* The indicated operator can be applied to two operands of
|
| 685 |
+
type `T`.
|
|
|
|
| 686 |
|
| 687 |
*Effects:* Each of these operators applies the indicated operation to
|
| 688 |
each element of `*this` and `v`.
|
| 689 |
|
| 690 |
*Returns:* `*this`
|
| 691 |
|
| 692 |
*Remarks:* The appearance of an array on the left-hand side of a
|
| 693 |
compound assignment does not invalidate references or pointers to the
|
| 694 |
elements of the array.
|
| 695 |
|
| 696 |
+
#### Member functions <a id="valarray.members">[[valarray.members]]</a>
|
| 697 |
|
| 698 |
``` cpp
|
| 699 |
void swap(valarray& v) noexcept;
|
| 700 |
```
|
| 701 |
|
|
|
|
| 714 |
|
| 715 |
``` cpp
|
| 716 |
T sum() const;
|
| 717 |
```
|
| 718 |
|
| 719 |
+
*Mandates:* `operator+=` can be applied to operands of type `T`.
|
| 720 |
+
|
| 721 |
+
*Preconditions:* `size() > 0` is `true`.
|
| 722 |
|
| 723 |
*Returns:* The sum of all the elements of the array. If the array has
|
| 724 |
length 1, returns the value of element 0. Otherwise, the returned value
|
| 725 |
is calculated by applying `operator+=` to a copy of an element of the
|
| 726 |
array and all other elements of the array in an unspecified order.
|
| 727 |
|
| 728 |
``` cpp
|
| 729 |
T min() const;
|
| 730 |
```
|
| 731 |
|
| 732 |
+
*Preconditions:* `size() > 0` is `true`.
|
| 733 |
|
| 734 |
*Returns:* The minimum value contained in `*this`. For an array of
|
| 735 |
length 1, the value of element 0 is returned. For all other array
|
| 736 |
lengths, the determination is made using `operator<`.
|
| 737 |
|
| 738 |
``` cpp
|
| 739 |
T max() const;
|
| 740 |
```
|
| 741 |
|
| 742 |
+
*Preconditions:* `size() > 0` is `true`.
|
| 743 |
|
| 744 |
*Returns:* The maximum value contained in `*this`. For an array of
|
| 745 |
length 1, the value of element 0 is returned. For all other array
|
| 746 |
lengths, the determination is made using `operator<`.
|
| 747 |
|
|
|
|
| 756 |
[*Note 1*: If element zero is taken as the leftmost element, a positive
|
| 757 |
value of `n` shifts the elements left `n` places, with zero
|
| 758 |
fill. — *end note*]
|
| 759 |
|
| 760 |
[*Example 1*: If the argument has the value -2, the first two elements
|
| 761 |
+
of the result will be value-initialized [[dcl.init]]; the third element
|
| 762 |
+
of the result will be assigned the value of the first element of the
|
| 763 |
+
argument; etc. — *end example*]
|
| 764 |
|
| 765 |
``` cpp
|
| 766 |
valarray cshift(int n) const;
|
| 767 |
```
|
| 768 |
|
|
|
|
| 788 |
assigns to each element the value of the second argument. Resizing
|
| 789 |
invalidates all pointers and references to elements in the array.
|
| 790 |
|
| 791 |
### `valarray` non-member operations <a id="valarray.nonmembers">[[valarray.nonmembers]]</a>
|
| 792 |
|
| 793 |
+
#### Binary operators <a id="valarray.binary">[[valarray.binary]]</a>
|
| 794 |
|
| 795 |
``` cpp
|
| 796 |
+
template<class T> valarray<T> operator* (const valarray<T>&, const valarray<T>&);
|
| 797 |
+
template<class T> valarray<T> operator/ (const valarray<T>&, const valarray<T>&);
|
| 798 |
+
template<class T> valarray<T> operator% (const valarray<T>&, const valarray<T>&);
|
| 799 |
+
template<class T> valarray<T> operator+ (const valarray<T>&, const valarray<T>&);
|
| 800 |
+
template<class T> valarray<T> operator- (const valarray<T>&, const valarray<T>&);
|
| 801 |
+
template<class T> valarray<T> operator^ (const valarray<T>&, const valarray<T>&);
|
| 802 |
+
template<class T> valarray<T> operator& (const valarray<T>&, const valarray<T>&);
|
| 803 |
+
template<class T> valarray<T> operator| (const valarray<T>&, const valarray<T>&);
|
| 804 |
+
template<class T> valarray<T> operator<<(const valarray<T>&, const valarray<T>&);
|
| 805 |
+
template<class T> valarray<T> operator>>(const valarray<T>&, const valarray<T>&);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
```
|
| 807 |
|
| 808 |
+
*Mandates:* The indicated operator can be applied to operands of type
|
| 809 |
+
`T` and returns a value of type `T` or which can be unambiguously
|
| 810 |
+
implicitly converted to `T`.
|
| 811 |
+
|
| 812 |
+
*Preconditions:* The argument arrays have the same length.
|
| 813 |
|
| 814 |
*Returns:* A `valarray` whose length is equal to the lengths of the
|
| 815 |
argument arrays. Each element of the returned array is initialized with
|
| 816 |
the result of applying the indicated operator to the corresponding
|
| 817 |
elements of the argument arrays.
|
| 818 |
|
| 819 |
``` cpp
|
| 820 |
+
template<class T> valarray<T> operator* (const valarray<T>&,
|
| 821 |
+
const typename valarray<T>::value_type&);
|
| 822 |
+
template<class T> valarray<T> operator* (const typename valarray<T>::value_type&,
|
| 823 |
+
const valarray<T>&);
|
| 824 |
+
template<class T> valarray<T> operator/ (const valarray<T>&,
|
| 825 |
+
const typename valarray<T>::value_type&);
|
| 826 |
+
template<class T> valarray<T> operator/ (const typename valarray<T>::value_type&,
|
| 827 |
+
const valarray<T>&);
|
| 828 |
+
template<class T> valarray<T> operator% (const valarray<T>&,
|
| 829 |
+
const typename valarray<T>::value_type&);
|
| 830 |
+
template<class T> valarray<T> operator% (const typename valarray<T>::value_type&,
|
| 831 |
+
const valarray<T>&);
|
| 832 |
+
template<class T> valarray<T> operator+ (const valarray<T>&,
|
| 833 |
+
const typename valarray<T>::value_type&);
|
| 834 |
+
template<class T> valarray<T> operator+ (const typename valarray<T>::value_type&,
|
| 835 |
+
const valarray<T>&);
|
| 836 |
+
template<class T> valarray<T> operator- (const valarray<T>&,
|
| 837 |
+
const typename valarray<T>::value_type&);
|
| 838 |
+
template<class T> valarray<T> operator- (const typename valarray<T>::value_type&,
|
| 839 |
+
const valarray<T>&);
|
| 840 |
+
template<class T> valarray<T> operator^ (const valarray<T>&,
|
| 841 |
+
const typename valarray<T>::value_type&);
|
| 842 |
+
template<class T> valarray<T> operator^ (const typename valarray<T>::value_type&,
|
| 843 |
+
const valarray<T>&);
|
| 844 |
+
template<class T> valarray<T> operator& (const valarray<T>&,
|
| 845 |
+
const typename valarray<T>::value_type&);
|
| 846 |
+
template<class T> valarray<T> operator& (const typename valarray<T>::value_type&,
|
| 847 |
+
const valarray<T>&);
|
| 848 |
+
template<class T> valarray<T> operator| (const valarray<T>&,
|
| 849 |
+
const typename valarray<T>::value_type&);
|
| 850 |
+
template<class T> valarray<T> operator| (const typename valarray<T>::value_type&,
|
| 851 |
+
const valarray<T>&);
|
| 852 |
+
template<class T> valarray<T> operator<<(const valarray<T>&,
|
| 853 |
+
const typename valarray<T>::value_type&);
|
| 854 |
+
template<class T> valarray<T> operator<<(const typename valarray<T>::value_type&,
|
| 855 |
+
const valarray<T>&);
|
| 856 |
+
template<class T> valarray<T> operator>>(const valarray<T>&,
|
| 857 |
+
const typename valarray<T>::value_type&);
|
| 858 |
+
template<class T> valarray<T> operator>>(const typename valarray<T>::value_type&,
|
| 859 |
+
const valarray<T>&);
|
| 860 |
```
|
| 861 |
|
| 862 |
+
*Mandates:* The indicated operator can be applied to operands of type
|
| 863 |
+
`T` and returns a value of type `T` or which can be unambiguously
|
| 864 |
+
implicitly converted to `T`.
|
|
|
|
| 865 |
|
| 866 |
*Returns:* A `valarray` whose length is equal to the length of the array
|
| 867 |
argument. Each element of the returned array is initialized with the
|
| 868 |
result of applying the indicated operator to the corresponding element
|
| 869 |
of the array argument and the non-array argument.
|
| 870 |
|
| 871 |
+
#### Logical operators <a id="valarray.comparison">[[valarray.comparison]]</a>
|
| 872 |
|
| 873 |
``` cpp
|
| 874 |
+
template<class T> valarray<bool> operator==(const valarray<T>&, const valarray<T>&);
|
| 875 |
+
template<class T> valarray<bool> operator!=(const valarray<T>&, const valarray<T>&);
|
| 876 |
+
template<class T> valarray<bool> operator< (const valarray<T>&, const valarray<T>&);
|
| 877 |
+
template<class T> valarray<bool> operator> (const valarray<T>&, const valarray<T>&);
|
| 878 |
+
template<class T> valarray<bool> operator<=(const valarray<T>&, const valarray<T>&);
|
| 879 |
+
template<class T> valarray<bool> operator>=(const valarray<T>&, const valarray<T>&);
|
| 880 |
+
template<class T> valarray<bool> operator&&(const valarray<T>&, const valarray<T>&);
|
| 881 |
+
template<class T> valarray<bool> operator||(const valarray<T>&, const valarray<T>&);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 882 |
```
|
| 883 |
|
| 884 |
+
*Mandates:* The indicated operator can be applied to operands of type
|
| 885 |
+
`T` and returns a value of type `bool` or which can be unambiguously
|
| 886 |
+
implicitly converted to `bool`.
|
| 887 |
+
|
| 888 |
+
*Preconditions:* The two array arguments have the same length.
|
| 889 |
|
| 890 |
*Returns:* A `valarray<bool>` whose length is equal to the length of the
|
| 891 |
array arguments. Each element of the returned array is initialized with
|
| 892 |
the result of applying the indicated operator to the corresponding
|
| 893 |
elements of the argument arrays.
|
| 894 |
|
| 895 |
``` cpp
|
| 896 |
+
template<class T> valarray<bool> operator==(const valarray<T>&,
|
| 897 |
+
const typename valarray<T>::value_type&);
|
| 898 |
+
template<class T> valarray<bool> operator==(const typename valarray<T>::value_type&,
|
| 899 |
+
const valarray<T>&);
|
| 900 |
+
template<class T> valarray<bool> operator!=(const valarray<T>&,
|
| 901 |
+
const typename valarray<T>::value_type&);
|
| 902 |
+
template<class T> valarray<bool> operator!=(const typename valarray<T>::value_type&,
|
| 903 |
+
const valarray<T>&);
|
| 904 |
+
template<class T> valarray<bool> operator< (const valarray<T>&,
|
| 905 |
+
const typename valarray<T>::value_type&);
|
| 906 |
+
template<class T> valarray<bool> operator< (const typename valarray<T>::value_type&,
|
| 907 |
+
const valarray<T>&);
|
| 908 |
+
template<class T> valarray<bool> operator> (const valarray<T>&,
|
| 909 |
+
const typename valarray<T>::value_type&);
|
| 910 |
+
template<class T> valarray<bool> operator> (const typename valarray<T>::value_type&,
|
| 911 |
+
const valarray<T>&);
|
| 912 |
+
template<class T> valarray<bool> operator<=(const valarray<T>&,
|
| 913 |
+
const typename valarray<T>::value_type&);
|
| 914 |
+
template<class T> valarray<bool> operator<=(const typename valarray<T>::value_type&,
|
| 915 |
+
const valarray<T>&);
|
| 916 |
+
template<class T> valarray<bool> operator>=(const valarray<T>&,
|
| 917 |
+
const typename valarray<T>::value_type&);
|
| 918 |
+
template<class T> valarray<bool> operator>=(const typename valarray<T>::value_type&,
|
| 919 |
+
const valarray<T>&);
|
| 920 |
+
template<class T> valarray<bool> operator&&(const valarray<T>&,
|
| 921 |
+
const typename valarray<T>::value_type&);
|
| 922 |
+
template<class T> valarray<bool> operator&&(const typename valarray<T>::value_type&,
|
| 923 |
+
const valarray<T>&);
|
| 924 |
+
template<class T> valarray<bool> operator||(const valarray<T>&,
|
| 925 |
+
const typename valarray<T>::value_type&);
|
| 926 |
+
template<class T> valarray<bool> operator||(const typename valarray<T>::value_type&,
|
| 927 |
+
const valarray<T>&);
|
| 928 |
```
|
| 929 |
|
| 930 |
+
*Mandates:* The indicated operator can be applied to operands of type
|
| 931 |
+
`T` and returns a value of type `bool` or which can be unambiguously
|
| 932 |
+
implicitly converted to `bool`.
|
|
|
|
| 933 |
|
| 934 |
*Returns:* A `valarray<bool>` whose length is equal to the length of the
|
| 935 |
array argument. Each element of the returned array is initialized with
|
| 936 |
the result of applying the indicated operator to the corresponding
|
| 937 |
element of the array and the non-array argument.
|
| 938 |
|
| 939 |
+
#### Transcendentals <a id="valarray.transcend">[[valarray.transcend]]</a>
|
| 940 |
|
| 941 |
``` cpp
|
| 942 |
template<class T> valarray<T> abs (const valarray<T>&);
|
| 943 |
template<class T> valarray<T> acos (const valarray<T>&);
|
| 944 |
template<class T> valarray<T> asin (const valarray<T>&);
|
| 945 |
template<class T> valarray<T> atan (const valarray<T>&);
|
| 946 |
+
template<class T> valarray<T> atan2(const valarray<T>&, const valarray<T>&);
|
| 947 |
+
template<class T> valarray<T> atan2(const valarray<T>&, const typename valarray<T>::value_type&);
|
| 948 |
+
template<class T> valarray<T> atan2(const typename valarray<T>::value_type&, const valarray<T>&);
|
|
|
|
| 949 |
template<class T> valarray<T> cos (const valarray<T>&);
|
| 950 |
template<class T> valarray<T> cosh (const valarray<T>&);
|
| 951 |
template<class T> valarray<T> exp (const valarray<T>&);
|
| 952 |
template<class T> valarray<T> log (const valarray<T>&);
|
| 953 |
template<class T> valarray<T> log10(const valarray<T>&);
|
| 954 |
+
template<class T> valarray<T> pow (const valarray<T>&, const valarray<T>&);
|
| 955 |
+
template<class T> valarray<T> pow (const valarray<T>&, const typename valarray<T>::value_type&);
|
| 956 |
+
template<class T> valarray<T> pow (const typename valarray<T>::value_type&, const valarray<T>&);
|
|
|
|
| 957 |
template<class T> valarray<T> sin (const valarray<T>&);
|
| 958 |
template<class T> valarray<T> sinh (const valarray<T>&);
|
| 959 |
template<class T> valarray<T> sqrt (const valarray<T>&);
|
| 960 |
template<class T> valarray<T> tan (const valarray<T>&);
|
| 961 |
template<class T> valarray<T> tanh (const valarray<T>&);
|
| 962 |
```
|
| 963 |
|
| 964 |
+
*Mandates:* A unique function with the indicated name can be applied
|
| 965 |
+
(unqualified) to an operand of type `T`. This function returns a value
|
| 966 |
+
of type `T` or which can be unambiguously implicitly converted to type
|
| 967 |
+
`T`.
|
| 968 |
|
| 969 |
+
#### Specialized algorithms <a id="valarray.special">[[valarray.special]]</a>
|
| 970 |
|
| 971 |
``` cpp
|
| 972 |
template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
|
| 973 |
```
|
| 974 |
|
| 975 |
*Effects:* Equivalent to `x.swap(y)`.
|
| 976 |
|
| 977 |
### Class `slice` <a id="class.slice">[[class.slice]]</a>
|
| 978 |
|
| 979 |
+
#### Overview <a id="class.slice.overview">[[class.slice.overview]]</a>
|
| 980 |
|
| 981 |
``` cpp
|
| 982 |
namespace std {
|
| 983 |
class slice {
|
| 984 |
public:
|
|
|
|
| 986 |
slice(size_t, size_t, size_t);
|
| 987 |
|
| 988 |
size_t start() const;
|
| 989 |
size_t size() const;
|
| 990 |
size_t stride() const;
|
| 991 |
+
|
| 992 |
+
friend bool operator==(const slice& x, const slice& y);
|
| 993 |
};
|
| 994 |
}
|
| 995 |
```
|
| 996 |
|
| 997 |
The `slice` class represents a BLAS-like slice from an array. Such a
|
| 998 |
slice is specified by a starting index, a length, and a stride.[^12]
|
| 999 |
|
| 1000 |
+
#### Constructors <a id="cons.slice">[[cons.slice]]</a>
|
| 1001 |
|
| 1002 |
``` cpp
|
| 1003 |
slice();
|
| 1004 |
slice(size_t start, size_t length, size_t stride);
|
| 1005 |
slice(const slice&);
|
|
|
|
| 1009 |
constructor is provided only to permit the declaration of arrays of
|
| 1010 |
slices. The constructor with arguments for a slice takes a start,
|
| 1011 |
length, and stride parameter.
|
| 1012 |
|
| 1013 |
[*Example 1*: `slice(3, 8, 2)` constructs a slice which selects
|
| 1014 |
+
elements 3, 5, 7, …, 17 from an array. — *end example*]
|
| 1015 |
|
| 1016 |
+
#### Access functions <a id="slice.access">[[slice.access]]</a>
|
| 1017 |
|
| 1018 |
``` cpp
|
| 1019 |
size_t start() const;
|
| 1020 |
size_t size() const;
|
| 1021 |
size_t stride() const;
|
|
|
|
| 1023 |
|
| 1024 |
*Returns:* The start, length, or stride specified by a `slice` object.
|
| 1025 |
|
| 1026 |
*Complexity:* Constant time.
|
| 1027 |
|
| 1028 |
+
#### Operators <a id="slice.ops">[[slice.ops]]</a>
|
| 1029 |
+
|
| 1030 |
+
``` cpp
|
| 1031 |
+
friend bool operator==(const slice& x, const slice& y);
|
| 1032 |
+
```
|
| 1033 |
+
|
| 1034 |
+
*Effects:* Equivalent to:
|
| 1035 |
+
|
| 1036 |
+
``` cpp
|
| 1037 |
+
return x.start() == y.start() && x.size() == y.size() && x.stride() == y.stride();
|
| 1038 |
+
```
|
| 1039 |
+
|
| 1040 |
### Class template `slice_array` <a id="template.slice.array">[[template.slice.array]]</a>
|
| 1041 |
|
| 1042 |
+
#### Overview <a id="template.slice.array.overview">[[template.slice.array.overview]]</a>
|
| 1043 |
|
| 1044 |
``` cpp
|
| 1045 |
namespace std {
|
| 1046 |
template<class T> class slice_array {
|
| 1047 |
public:
|
|
|
|
| 1067 |
slice_array() = delete; // as implied by declaring copy constructor above
|
| 1068 |
};
|
| 1069 |
}
|
| 1070 |
```
|
| 1071 |
|
| 1072 |
+
This template is a helper template used by the `slice` subscript
|
| 1073 |
+
operator
|
| 1074 |
|
| 1075 |
``` cpp
|
| 1076 |
slice_array<T> valarray<T>::operator[](slice);
|
| 1077 |
```
|
| 1078 |
|
| 1079 |
It has reference semantics to a subset of an array specified by a
|
| 1080 |
`slice` object.
|
| 1081 |
|
| 1082 |
[*Example 1*: The expression `a[slice(1, 5, 3)] = b;` has the effect of
|
| 1083 |
assigning the elements of `b` to a slice of the elements in `a`. For the
|
| 1084 |
+
slice shown, the elements selected from `a` are
|
| 1085 |
+
1, 4, …, 13. — *end example*]
|
| 1086 |
|
| 1087 |
+
#### Assignment <a id="slice.arr.assign">[[slice.arr.assign]]</a>
|
| 1088 |
|
| 1089 |
``` cpp
|
| 1090 |
void operator=(const valarray<T>&) const;
|
| 1091 |
const slice_array& operator=(const slice_array&) const;
|
| 1092 |
```
|
| 1093 |
|
| 1094 |
These assignment operators have reference semantics, assigning the
|
| 1095 |
values of the argument array elements to selected elements of the
|
| 1096 |
`valarray<T>` object to which the `slice_array` object refers.
|
| 1097 |
|
| 1098 |
+
#### Compound assignment <a id="slice.arr.comp.assign">[[slice.arr.comp.assign]]</a>
|
| 1099 |
|
| 1100 |
``` cpp
|
| 1101 |
void operator*= (const valarray<T>&) const;
|
| 1102 |
void operator/= (const valarray<T>&) const;
|
| 1103 |
void operator%= (const valarray<T>&) const;
|
|
|
|
| 1113 |
These compound assignments have reference semantics, applying the
|
| 1114 |
indicated operation to the elements of the argument array and selected
|
| 1115 |
elements of the `valarray<T>` object to which the `slice_array` object
|
| 1116 |
refers.
|
| 1117 |
|
| 1118 |
+
#### Fill function <a id="slice.arr.fill">[[slice.arr.fill]]</a>
|
| 1119 |
|
| 1120 |
``` cpp
|
| 1121 |
void operator=(const T&) const;
|
| 1122 |
```
|
| 1123 |
|
|
|
|
| 1125 |
argument to the elements of the `valarray<T>` object to which the
|
| 1126 |
`slice_array` object refers.
|
| 1127 |
|
| 1128 |
### The `gslice` class <a id="class.gslice">[[class.gslice]]</a>
|
| 1129 |
|
| 1130 |
+
#### Overview <a id="class.gslice.overview">[[class.gslice.overview]]</a>
|
| 1131 |
|
| 1132 |
``` cpp
|
| 1133 |
namespace std {
|
| 1134 |
class gslice {
|
| 1135 |
public:
|
|
|
|
| 1183 |
— *end example*]
|
| 1184 |
|
| 1185 |
If a degenerate slice is used as the argument to the non-`const` version
|
| 1186 |
of `operator[](const gslice&)`, the behavior is undefined.
|
| 1187 |
|
| 1188 |
+
#### Constructors <a id="gslice.cons">[[gslice.cons]]</a>
|
| 1189 |
|
| 1190 |
``` cpp
|
| 1191 |
gslice();
|
| 1192 |
gslice(size_t start, const valarray<size_t>& lengths,
|
| 1193 |
const valarray<size_t>& strides);
|
|
|
|
| 1195 |
```
|
| 1196 |
|
| 1197 |
The default constructor is equivalent to
|
| 1198 |
`gslice(0, valarray<size_t>(), valarray<size_t>())`. The constructor
|
| 1199 |
with arguments builds a `gslice` based on a specification of start,
|
| 1200 |
+
lengths, and strides, as explained in the previous subclause.
|
| 1201 |
|
| 1202 |
+
#### Access functions <a id="gslice.access">[[gslice.access]]</a>
|
| 1203 |
|
| 1204 |
``` cpp
|
| 1205 |
size_t start() const;
|
| 1206 |
valarray<size_t> size() const;
|
| 1207 |
valarray<size_t> stride() const;
|
|
|
|
| 1213 |
*Complexity:* `start()` is constant time. `size()` and `stride()` are
|
| 1214 |
linear in the number of strides.
|
| 1215 |
|
| 1216 |
### Class template `gslice_array` <a id="template.gslice.array">[[template.gslice.array]]</a>
|
| 1217 |
|
| 1218 |
+
#### Overview <a id="template.gslice.array.overview">[[template.gslice.array.overview]]</a>
|
| 1219 |
|
| 1220 |
``` cpp
|
| 1221 |
namespace std {
|
| 1222 |
template<class T> class gslice_array {
|
| 1223 |
public:
|
|
|
|
| 1243 |
gslice_array() = delete; // as implied by declaring copy constructor above
|
| 1244 |
};
|
| 1245 |
}
|
| 1246 |
```
|
| 1247 |
|
| 1248 |
+
This template is a helper template used by the `gslice` subscript
|
| 1249 |
operator
|
| 1250 |
|
| 1251 |
``` cpp
|
| 1252 |
gslice_array<T> valarray<T>::operator[](const gslice&);
|
| 1253 |
```
|
| 1254 |
|
| 1255 |
It has reference semantics to a subset of an array specified by a
|
| 1256 |
+
`gslice` object. Thus, the expression `a[gslice(1, length, stride)] = b`
|
| 1257 |
+
has the effect of assigning the elements of `b` to a generalized slice
|
| 1258 |
+
of the elements in `a`.
|
| 1259 |
|
| 1260 |
+
#### Assignment <a id="gslice.array.assign">[[gslice.array.assign]]</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1261 |
|
| 1262 |
``` cpp
|
| 1263 |
void operator=(const valarray<T>&) const;
|
| 1264 |
const gslice_array& operator=(const gslice_array&) const;
|
| 1265 |
```
|
| 1266 |
|
| 1267 |
These assignment operators have reference semantics, assigning the
|
| 1268 |
values of the argument array elements to selected elements of the
|
| 1269 |
`valarray<T>` object to which the `gslice_array` refers.
|
| 1270 |
|
| 1271 |
+
#### Compound assignment <a id="gslice.array.comp.assign">[[gslice.array.comp.assign]]</a>
|
| 1272 |
|
| 1273 |
``` cpp
|
| 1274 |
void operator*= (const valarray<T>&) const;
|
| 1275 |
void operator/= (const valarray<T>&) const;
|
| 1276 |
void operator%= (const valarray<T>&) const;
|
|
|
|
| 1286 |
These compound assignments have reference semantics, applying the
|
| 1287 |
indicated operation to the elements of the argument array and selected
|
| 1288 |
elements of the `valarray<T>` object to which the `gslice_array` object
|
| 1289 |
refers.
|
| 1290 |
|
| 1291 |
+
#### Fill function <a id="gslice.array.fill">[[gslice.array.fill]]</a>
|
| 1292 |
|
| 1293 |
``` cpp
|
| 1294 |
void operator=(const T&) const;
|
| 1295 |
```
|
| 1296 |
|
|
|
|
| 1298 |
argument to the elements of the `valarray<T>` object to which the
|
| 1299 |
`gslice_array` object refers.
|
| 1300 |
|
| 1301 |
### Class template `mask_array` <a id="template.mask.array">[[template.mask.array]]</a>
|
| 1302 |
|
| 1303 |
+
#### Overview <a id="template.mask.array.overview">[[template.mask.array.overview]]</a>
|
| 1304 |
|
| 1305 |
``` cpp
|
| 1306 |
namespace std {
|
| 1307 |
template<class T> class mask_array {
|
| 1308 |
public:
|
|
|
|
| 1337 |
```
|
| 1338 |
|
| 1339 |
It has reference semantics to a subset of an array specified by a
|
| 1340 |
boolean mask. Thus, the expression `a[mask] = b;` has the effect of
|
| 1341 |
assigning the elements of `b` to the masked elements in `a` (those for
|
| 1342 |
+
which the corresponding element in `mask` is `true`).
|
| 1343 |
|
| 1344 |
+
#### Assignment <a id="mask.array.assign">[[mask.array.assign]]</a>
|
| 1345 |
|
| 1346 |
``` cpp
|
| 1347 |
void operator=(const valarray<T>&) const;
|
| 1348 |
const mask_array& operator=(const mask_array&) const;
|
| 1349 |
```
|
| 1350 |
|
| 1351 |
These assignment operators have reference semantics, assigning the
|
| 1352 |
values of the argument array elements to selected elements of the
|
| 1353 |
`valarray<T>` object to which it refers.
|
| 1354 |
|
| 1355 |
+
#### Compound assignment <a id="mask.array.comp.assign">[[mask.array.comp.assign]]</a>
|
| 1356 |
|
| 1357 |
``` cpp
|
| 1358 |
void operator*= (const valarray<T>&) const;
|
| 1359 |
void operator/= (const valarray<T>&) const;
|
| 1360 |
void operator%= (const valarray<T>&) const;
|
|
|
|
| 1369 |
|
| 1370 |
These compound assignments have reference semantics, applying the
|
| 1371 |
indicated operation to the elements of the argument array and selected
|
| 1372 |
elements of the `valarray<T>` object to which the mask object refers.
|
| 1373 |
|
| 1374 |
+
#### Fill function <a id="mask.array.fill">[[mask.array.fill]]</a>
|
| 1375 |
|
| 1376 |
``` cpp
|
| 1377 |
void operator=(const T&) const;
|
| 1378 |
```
|
| 1379 |
|
|
|
|
| 1381 |
argument to the elements of the `valarray<T>` object to which the
|
| 1382 |
`mask_array` object refers.
|
| 1383 |
|
| 1384 |
### Class template `indirect_array` <a id="template.indirect.array">[[template.indirect.array]]</a>
|
| 1385 |
|
| 1386 |
+
#### Overview <a id="template.indirect.array.overview">[[template.indirect.array.overview]]</a>
|
| 1387 |
|
| 1388 |
``` cpp
|
| 1389 |
namespace std {
|
| 1390 |
template<class T> class indirect_array {
|
| 1391 |
public:
|
|
|
|
| 1419 |
``` cpp
|
| 1420 |
indirect_array<T> valarray<T>::operator[](const valarray<size_t>&).
|
| 1421 |
```
|
| 1422 |
|
| 1423 |
It has reference semantics to a subset of an array specified by an
|
| 1424 |
+
`indirect_array`. Thus, the expression `a[{}indirect] = b;` has the
|
| 1425 |
+
effect of assigning the elements of `b` to the elements in `a` whose
|
| 1426 |
+
indices appear in `indirect`.
|
| 1427 |
|
| 1428 |
+
#### Assignment <a id="indirect.array.assign">[[indirect.array.assign]]</a>
|
| 1429 |
|
| 1430 |
``` cpp
|
| 1431 |
void operator=(const valarray<T>&) const;
|
| 1432 |
const indirect_array& operator=(const indirect_array&) const;
|
| 1433 |
```
|
|
|
|
| 1451 |
results in undefined behavior since element 4 is specified twice in the
|
| 1452 |
indirection.
|
| 1453 |
|
| 1454 |
— *end example*]
|
| 1455 |
|
| 1456 |
+
#### Compound assignment <a id="indirect.array.comp.assign">[[indirect.array.comp.assign]]</a>
|
| 1457 |
|
| 1458 |
``` cpp
|
| 1459 |
void operator*= (const valarray<T>&) const;
|
| 1460 |
void operator/= (const valarray<T>&) const;
|
| 1461 |
void operator%= (const valarray<T>&) const;
|
|
|
|
| 1474 |
object refers.
|
| 1475 |
|
| 1476 |
If the `indirect_array` specifies an element in the `valarray<T>` object
|
| 1477 |
to which it refers more than once, the behavior is undefined.
|
| 1478 |
|
| 1479 |
+
#### Fill function <a id="indirect.array.fill">[[indirect.array.fill]]</a>
|
| 1480 |
|
| 1481 |
``` cpp
|
| 1482 |
void operator=(const T&) const;
|
| 1483 |
```
|
| 1484 |
|
|
|
|
| 1487 |
`indirect_array` object refers.
|
| 1488 |
|
| 1489 |
### `valarray` range access <a id="valarray.range">[[valarray.range]]</a>
|
| 1490 |
|
| 1491 |
In the `begin` and `end` function templates that follow, *unspecified*1
|
| 1492 |
+
is a type that meets the requirements of a mutable
|
| 1493 |
+
*Cpp17RandomAccessIterator* [[random.access.iterators]] and models
|
| 1494 |
+
`contiguous_iterator` [[iterator.concept.contiguous]], whose
|
| 1495 |
+
`value_type` is the template parameter `T` and whose `reference` type is
|
| 1496 |
+
`T&`. *unspecified*2 is a type that meets the requirements of a constant
|
| 1497 |
+
*Cpp17RandomAccessIterator* and models `contiguous_iterator`, whose
|
| 1498 |
+
`value_type` is the template parameter `T` and whose `reference` type is
|
| 1499 |
+
`const T&`.
|
| 1500 |
|
| 1501 |
The iterators returned by `begin` and `end` for an array are guaranteed
|
| 1502 |
+
to be valid until the member function `resize(size_t, T)`
|
| 1503 |
+
[[valarray.members]] is called for that array or until the lifetime of
|
| 1504 |
that array ends, whichever happens first.
|
| 1505 |
|
| 1506 |
``` cpp
|
| 1507 |
template<class T> unspecified{1} begin(valarray<T>& v);
|
| 1508 |
template<class T> unspecified{2} begin(const valarray<T>& v);
|