- tmp/tmpup9wnyty/{from.md → to.md} +31 -120
tmp/tmpup9wnyty/{from.md → to.md}
RENAMED
|
@@ -1,14 +1,17 @@
|
|
| 1 |
## Complex numbers <a id="complex.numbers">[[complex.numbers]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
The header `<complex>` defines a class template, and numerous functions
|
| 4 |
for representing and manipulating complex numbers.
|
| 5 |
|
| 6 |
-
The effect of instantiating the template `complex` for any type
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
If the result of a function is not mathematically defined or not in the
|
| 12 |
range of representable values for its type, the behavior is undefined.
|
| 13 |
|
| 14 |
If `z` is an lvalue of type cv `complex<T>` then:
|
|
@@ -32,15 +35,10 @@ expression `a[i]` is well-defined for an integer expression `i`, then:
|
|
| 32 |
``` cpp
|
| 33 |
namespace std {
|
| 34 |
// [complex], class template complex
|
| 35 |
template<class T> class complex;
|
| 36 |
|
| 37 |
-
// [complex.special], specializations
|
| 38 |
-
template<> class complex<float>;
|
| 39 |
-
template<> class complex<double>;
|
| 40 |
-
template<> class complex<long double>;
|
| 41 |
-
|
| 42 |
// [complex.ops], operators
|
| 43 |
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&);
|
| 44 |
template<class T> constexpr complex<T> operator+(const complex<T>&, const T&);
|
| 45 |
template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
|
| 46 |
|
|
@@ -126,12 +124,12 @@ namespace std {
|
|
| 126 |
template<class T> class complex {
|
| 127 |
public:
|
| 128 |
using value_type = T;
|
| 129 |
|
| 130 |
constexpr complex(const T& re = T(), const T& im = T());
|
| 131 |
-
constexpr complex(const complex&);
|
| 132 |
-
template<class X> constexpr complex(const complex<X>&);
|
| 133 |
|
| 134 |
constexpr T real() const;
|
| 135 |
constexpr void real(T);
|
| 136 |
constexpr T imag() const;
|
| 137 |
constexpr void imag(T);
|
|
@@ -153,108 +151,29 @@ namespace std {
|
|
| 153 |
```
|
| 154 |
|
| 155 |
The class `complex` describes an object that can store the Cartesian
|
| 156 |
components, `real()` and `imag()`, of a complex number.
|
| 157 |
|
| 158 |
-
### Specializations <a id="complex.special">[[complex.special]]</a>
|
| 159 |
-
|
| 160 |
-
``` cpp
|
| 161 |
-
namespace std {
|
| 162 |
-
template<> class complex<float> {
|
| 163 |
-
public:
|
| 164 |
-
using value_type = float;
|
| 165 |
-
|
| 166 |
-
constexpr complex(float re = 0.0f, float im = 0.0f);
|
| 167 |
-
constexpr complex(const complex<float>&) = default;
|
| 168 |
-
constexpr explicit complex(const complex<double>&);
|
| 169 |
-
constexpr explicit complex(const complex<long double>&);
|
| 170 |
-
|
| 171 |
-
constexpr float real() const;
|
| 172 |
-
constexpr void real(float);
|
| 173 |
-
constexpr float imag() const;
|
| 174 |
-
constexpr void imag(float);
|
| 175 |
-
|
| 176 |
-
constexpr complex& operator= (float);
|
| 177 |
-
constexpr complex& operator+=(float);
|
| 178 |
-
constexpr complex& operator-=(float);
|
| 179 |
-
constexpr complex& operator*=(float);
|
| 180 |
-
constexpr complex& operator/=(float);
|
| 181 |
-
|
| 182 |
-
constexpr complex& operator=(const complex&);
|
| 183 |
-
template<class X> constexpr complex& operator= (const complex<X>&);
|
| 184 |
-
template<class X> constexpr complex& operator+=(const complex<X>&);
|
| 185 |
-
template<class X> constexpr complex& operator-=(const complex<X>&);
|
| 186 |
-
template<class X> constexpr complex& operator*=(const complex<X>&);
|
| 187 |
-
template<class X> constexpr complex& operator/=(const complex<X>&);
|
| 188 |
-
};
|
| 189 |
-
|
| 190 |
-
template<> class complex<double> {
|
| 191 |
-
public:
|
| 192 |
-
using value_type = double;
|
| 193 |
-
|
| 194 |
-
constexpr complex(double re = 0.0, double im = 0.0);
|
| 195 |
-
constexpr complex(const complex<float>&);
|
| 196 |
-
constexpr complex(const complex<double>&) = default;
|
| 197 |
-
constexpr explicit complex(const complex<long double>&);
|
| 198 |
-
|
| 199 |
-
constexpr double real() const;
|
| 200 |
-
constexpr void real(double);
|
| 201 |
-
constexpr double imag() const;
|
| 202 |
-
constexpr void imag(double);
|
| 203 |
-
|
| 204 |
-
constexpr complex& operator= (double);
|
| 205 |
-
constexpr complex& operator+=(double);
|
| 206 |
-
constexpr complex& operator-=(double);
|
| 207 |
-
constexpr complex& operator*=(double);
|
| 208 |
-
constexpr complex& operator/=(double);
|
| 209 |
-
|
| 210 |
-
constexpr complex& operator=(const complex&);
|
| 211 |
-
template<class X> constexpr complex& operator= (const complex<X>&);
|
| 212 |
-
template<class X> constexpr complex& operator+=(const complex<X>&);
|
| 213 |
-
template<class X> constexpr complex& operator-=(const complex<X>&);
|
| 214 |
-
template<class X> constexpr complex& operator*=(const complex<X>&);
|
| 215 |
-
template<class X> constexpr complex& operator/=(const complex<X>&);
|
| 216 |
-
};
|
| 217 |
-
|
| 218 |
-
template<> class complex<long double> {
|
| 219 |
-
public:
|
| 220 |
-
using value_type = long double;
|
| 221 |
-
|
| 222 |
-
constexpr complex(long double re = 0.0L, long double im = 0.0L);
|
| 223 |
-
constexpr complex(const complex<float>&);
|
| 224 |
-
constexpr complex(const complex<double>&);
|
| 225 |
-
constexpr complex(const complex<long double>&) = default;
|
| 226 |
-
|
| 227 |
-
constexpr long double real() const;
|
| 228 |
-
constexpr void real(long double);
|
| 229 |
-
constexpr long double imag() const;
|
| 230 |
-
constexpr void imag(long double);
|
| 231 |
-
|
| 232 |
-
constexpr complex& operator= (long double);
|
| 233 |
-
constexpr complex& operator+=(long double);
|
| 234 |
-
constexpr complex& operator-=(long double);
|
| 235 |
-
constexpr complex& operator*=(long double);
|
| 236 |
-
constexpr complex& operator/=(long double);
|
| 237 |
-
|
| 238 |
-
constexpr complex& operator=(const complex&);
|
| 239 |
-
template<class X> constexpr complex& operator= (const complex<X>&);
|
| 240 |
-
template<class X> constexpr complex& operator+=(const complex<X>&);
|
| 241 |
-
template<class X> constexpr complex& operator-=(const complex<X>&);
|
| 242 |
-
template<class X> constexpr complex& operator*=(const complex<X>&);
|
| 243 |
-
template<class X> constexpr complex& operator/=(const complex<X>&);
|
| 244 |
-
};
|
| 245 |
-
}
|
| 246 |
-
```
|
| 247 |
-
|
| 248 |
### Member functions <a id="complex.members">[[complex.members]]</a>
|
| 249 |
|
| 250 |
``` cpp
|
| 251 |
-
|
| 252 |
```
|
| 253 |
|
| 254 |
*Ensures:* `real() == re && imag() == im` is `true`.
|
| 255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
``` cpp
|
| 257 |
constexpr T real() const;
|
| 258 |
```
|
| 259 |
|
| 260 |
*Returns:* The value of the real component.
|
|
@@ -440,11 +359,11 @@ were implemented as follows:
|
|
| 440 |
``` cpp
|
| 441 |
basic_ostringstream<charT, traits> s;
|
| 442 |
s.flags(o.flags());
|
| 443 |
s.imbue(o.getloc());
|
| 444 |
s.precision(o.precision());
|
| 445 |
-
s << '(' << x.real() <<
|
| 446 |
return o << s.str();
|
| 447 |
```
|
| 448 |
|
| 449 |
[*Note 1*: In a locale in which comma is used as a decimal point
|
| 450 |
character, the use of comma as a field separator can be ambiguous.
|
|
@@ -663,28 +582,20 @@ imag real
|
|
| 663 |
|
| 664 |
where `norm`, `conj`, `imag`, and `real` are `constexpr` overloads.
|
| 665 |
|
| 666 |
The additional overloads shall be sufficient to ensure:
|
| 667 |
|
| 668 |
-
- If the argument has type `
|
| 669 |
-
`complex<
|
| 670 |
-
- Otherwise, if the argument has
|
| 671 |
-
|
| 672 |
-
- Otherwise, if the argument has type `float`, then it is effectively
|
| 673 |
-
cast to `complex<float>`.
|
| 674 |
|
| 675 |
-
Function template `pow`
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
`complex<long double>`.
|
| 681 |
-
- Otherwise, if either argument has type `complex<double>`, `double`, or
|
| 682 |
-
an integer type, then both arguments are effectively cast to
|
| 683 |
-
`complex<double>`.
|
| 684 |
-
- Otherwise, if either argument has type `complex<float>` or `float`,
|
| 685 |
-
then both arguments are effectively cast to `complex<float>`.
|
| 686 |
|
| 687 |
### Suffixes for complex number literals <a id="complex.literals">[[complex.literals]]</a>
|
| 688 |
|
| 689 |
This subclause describes literal suffixes for constructing complex
|
| 690 |
number literals. The suffixes `i`, `il`, and `if` create complex numbers
|
|
|
|
| 1 |
## Complex numbers <a id="complex.numbers">[[complex.numbers]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="complex.numbers.general">[[complex.numbers.general]]</a>
|
| 4 |
+
|
| 5 |
The header `<complex>` defines a class template, and numerous functions
|
| 6 |
for representing and manipulating complex numbers.
|
| 7 |
|
| 8 |
+
The effect of instantiating the template `complex` for any type that is
|
| 9 |
+
not a cv-unqualified floating-point type [[basic.fundamental]] is
|
| 10 |
+
unspecified. Specializations of `complex` for cv-unqualified
|
| 11 |
+
floating-point types are trivially-copyable literal types
|
| 12 |
+
[[term.literal.type]].
|
| 13 |
|
| 14 |
If the result of a function is not mathematically defined or not in the
|
| 15 |
range of representable values for its type, the behavior is undefined.
|
| 16 |
|
| 17 |
If `z` is an lvalue of type cv `complex<T>` then:
|
|
|
|
| 35 |
``` cpp
|
| 36 |
namespace std {
|
| 37 |
// [complex], class template complex
|
| 38 |
template<class T> class complex;
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
// [complex.ops], operators
|
| 41 |
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&);
|
| 42 |
template<class T> constexpr complex<T> operator+(const complex<T>&, const T&);
|
| 43 |
template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
|
| 44 |
|
|
|
|
| 124 |
template<class T> class complex {
|
| 125 |
public:
|
| 126 |
using value_type = T;
|
| 127 |
|
| 128 |
constexpr complex(const T& re = T(), const T& im = T());
|
| 129 |
+
constexpr complex(const complex&) = default;
|
| 130 |
+
template<class X> constexpr explicit(see below) complex(const complex<X>&);
|
| 131 |
|
| 132 |
constexpr T real() const;
|
| 133 |
constexpr void real(T);
|
| 134 |
constexpr T imag() const;
|
| 135 |
constexpr void imag(T);
|
|
|
|
| 151 |
```
|
| 152 |
|
| 153 |
The class `complex` describes an object that can store the Cartesian
|
| 154 |
components, `real()` and `imag()`, of a complex number.
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
### Member functions <a id="complex.members">[[complex.members]]</a>
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
+
constexpr complex(const T& re = T(), const T& im = T());
|
| 160 |
```
|
| 161 |
|
| 162 |
*Ensures:* `real() == re && imag() == im` is `true`.
|
| 163 |
|
| 164 |
+
``` cpp
|
| 165 |
+
template<class X> constexpr explicit(see below) complex(const complex<X>& other);
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
*Effects:* Initializes the real part with `other.real()` and the
|
| 169 |
+
imaginary part with `other.imag()`.
|
| 170 |
+
|
| 171 |
+
*Remarks:* The expression inside `explicit` evaluates to `false` if and
|
| 172 |
+
only if the floating-point conversion rank of `T` is greater than or
|
| 173 |
+
equal to the floating-point conversion rank of `X`.
|
| 174 |
+
|
| 175 |
``` cpp
|
| 176 |
constexpr T real() const;
|
| 177 |
```
|
| 178 |
|
| 179 |
*Returns:* The value of the real component.
|
|
|
|
| 359 |
``` cpp
|
| 360 |
basic_ostringstream<charT, traits> s;
|
| 361 |
s.flags(o.flags());
|
| 362 |
s.imbue(o.getloc());
|
| 363 |
s.precision(o.precision());
|
| 364 |
+
s << '(' << x.real() << ',' << x.imag() << ')';
|
| 365 |
return o << s.str();
|
| 366 |
```
|
| 367 |
|
| 368 |
[*Note 1*: In a locale in which comma is used as a decimal point
|
| 369 |
character, the use of comma as a field separator can be ambiguous.
|
|
|
|
| 582 |
|
| 583 |
where `norm`, `conj`, `imag`, and `real` are `constexpr` overloads.
|
| 584 |
|
| 585 |
The additional overloads shall be sufficient to ensure:
|
| 586 |
|
| 587 |
+
- If the argument has a floating-point type `T`, then it is effectively
|
| 588 |
+
cast to `complex<T>`.
|
| 589 |
+
- Otherwise, if the argument has integer type, then it is effectively
|
| 590 |
+
cast to `complex<double>`.
|
|
|
|
|
|
|
| 591 |
|
| 592 |
+
Function template `pow` has additional overloads sufficient to ensure,
|
| 593 |
+
for a call with one argument of type `complex<T1>` and the other
|
| 594 |
+
argument of type `T2` or `complex<T2>`, both arguments are effectively
|
| 595 |
+
cast to `complex<common_type_t<T1, T2>>`. If `common_type_t<T1, T2>` is
|
| 596 |
+
not well-formed, then the program is ill-formed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
|
| 598 |
### Suffixes for complex number literals <a id="complex.literals">[[complex.literals]]</a>
|
| 599 |
|
| 600 |
This subclause describes literal suffixes for constructing complex
|
| 601 |
number literals. The suffixes `i`, `il`, and `if` create complex numbers
|