Skip to content

Commit

Permalink
<cmath> : 拡張浮動小数点数型への対応続き。途中で力尽きた #1022
Browse files Browse the repository at this point in the history
  • Loading branch information
faithandbrave committed Feb 17, 2023
1 parent 88c08cc commit ace1860
Show file tree
Hide file tree
Showing 38 changed files with 1,118 additions and 389 deletions.
33 changes: 25 additions & 8 deletions reference/cmath/acos.md
Expand Up @@ -6,14 +6,17 @@

```cpp
namespace std {
float acos(float x);
double acos(double x);
long double acos(long double x);
float acos(float x); // (1) C++03からC++20まで
double acos(double x); // (2) C++03からC++20まで
long double acos(long double x); // (3) C++03からC++20まで

double acos(Integral x); // C++11 から
floating-point-type
acos(floating-point-type x); // (4) C++23

float acosf(float x); // C++17 から
long double acosl(long double x); // C++17 から
double acos(Integral x); // (5) C++11

float acosf(float x); // (6) C++17
long double acosl(long double x); // (7) C++17
}
```
* Integral[italic]
Expand All @@ -23,6 +26,14 @@ namespace std {
`acos()`は、余弦を表す[`cos()`](cos.md)の逆関数である。$\cos(\mathrm{Arccos}~x) = x$、$\mathrm{Arccos}~(\cos x) = x ~ (x \in [0, \pi])$である。
- (1) : `float`に対するオーバーロード
- (2) : `double`に対するオーバーロード
- (3) : `long double`に対するオーバーロード
- (4) : 浮動小数点数型に対するオーバーロード
- (5) : 整数型に対するオーバーロード (`double`にキャストして計算される)
- (6) : `float`型規定
- (7) : `long double`型規定
## 戻り値
引数 `x` の逆余弦を主値 `[0, π]` の範囲で返す。(単位はラジアン)
Expand All @@ -34,8 +45,9 @@ namespace std {
- $$ f(x) = \mathrm{Arccos}~ x $$
- 定義域エラーが発生した場合の挙動については、[`<cmath>`](../cmath.md) を参照。
- C++11 以降では、処理系が IEC 60559 に準拠している場合([`std::numeric_limits`](../limits/numeric_limits.md)`<T>::`[`is_iec559`](../limits/numeric_limits/is_iec559.md)`() != false`)、以下の規定が追加される。
- `x = 1` の場合、戻り値は `+0` となる。
- `x > |1|` の場合、戻り値は quiet NaN となり、[`FE_INVALID`](../cfenv/fe_invalid.md)(無効演算浮動小数点例外)が発生する。
- `x = 1` の場合、戻り値は `+0` となる。
- `x > |1|` の場合、戻り値は quiet NaN となり、[`FE_INVALID`](../cfenv/fe_invalid.md)(無効演算浮動小数点例外)が発生する。
- C++23では、(1)、(2)、(3)が(4)に統合され、拡張浮動小数点数型を含む浮動小数点数型へのオーバーロードとして定義された
## 例
Expand Down Expand Up @@ -94,3 +106,8 @@ $$ \mathrm{Arccos}~x = \frac{\pi}{2} - \sum_{n = 0}^{\infty}\frac{\left(2n\right
また、逆正接関数と逆余接関数の和は π / 2 なので [`asin`](asin.md) から求めることができる。

$$ \mathrm{Arccos}~x = \frac{\pi}{2} - \mathrm{Arcsin}~x \quad \mathrm{for} \; |x| &lt; 1 $$


## 参照
- [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html)
- C++23で導入された拡張浮動小数点数型への対応として、`float``double``long double`のオーバーロードを`floating-point-type`のオーバーロードに統合し、拡張浮動小数点数型も扱えるようにした
35 changes: 26 additions & 9 deletions reference/cmath/acosh.md
Expand Up @@ -7,21 +7,32 @@

```cpp
namespace std {
float acosh(float x);
double acosh(double x);
long double acosh(long double x);
float acosh(float x); // (1) C++11からC++20まで
double acosh(double x); // (2) C++11からC++20まで
long double acosh(long double x); // (3) C++11からC++20まで

double acosh(Integral x); // C++11 から
floating-point-type
acosh(floating-point-type x); // (4) C++23

float acoshf(float x); // C++17 から
long double acoshl(long double x); // C++17 から
double acosh(Integral x); // (5) C++11

float acoshf(float x); // (6) C++17
long double acoshl(long double x); // (7) C++17
}
```
* Integral[italic]
## 概要
算術型の逆双曲線余弦(エリアハイパボリックコサイン、area hyperbolic cosine)を求める。
- (1) : `float`に対するオーバーロード
- (2) : `double`に対するオーバーロード
- (3) : `long double`に対するオーバーロード
- (4) : 浮動小数点数型に対するオーバーロード
- (5) : 整数型に対するオーバーロード (`double`にキャストして計算される)
- (6) : `float`型規定
- (7) : `long double`型規定
## 戻り値
引数 `x` の逆双曲線余弦を `[0, +∞]` の範囲で返す。
Expand All @@ -33,9 +44,10 @@ namespace std {
- $$ f(x) = \mathrm{arcosh}~x $$
- 定義域エラーが発生した場合の挙動については、[`<cmath>`](../cmath.md) を参照。
- 処理系が IEC 60559 に準拠している場合([`std::numeric_limits`](../limits/numeric_limits.md)`<T>::`[`is_iec559`](../limits/numeric_limits/is_iec559.md)`() != false`)、以下の規定が追加される。
- `x = 1` の場合、戻り値は `+0` となる。
- `x < 1` の場合、戻り値は quiet NaN となり、[`FE_INVALID`](../cfenv/fe_invalid.md)(無効演算浮動小数点例外)が発生する。
- `x = +∞` の場合、戻り値は `+∞` となる。
- `x = 1` の場合、戻り値は `+0` となる。
- `x < 1` の場合、戻り値は quiet NaN となり、[`FE_INVALID`](../cfenv/fe_invalid.md)(無効演算浮動小数点例外)が発生する。
- `x = +∞` の場合、戻り値は `+∞` となる。
- C++23では、(1)、(2)、(3)が(4)に統合され、拡張浮動小数点数型を含む浮動小数点数型へのオーバーロードとして定義された
## 例
Expand Down Expand Up @@ -79,3 +91,8 @@ acosh(∞) = inf
対数に変換して求めることができる。

$$ \mathrm{arcosh}~x = \log_e \left(x + \sqrt{x^2-1}\right) \quad \mathrm{for} \; 1 &lt; x $$


## 参照
- [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html)
- C++23で導入された拡張浮動小数点数型への対応として、`float``double``long double`のオーバーロードを`floating-point-type`のオーバーロードに統合し、拡張浮動小数点数型も扱えるようにした
33 changes: 25 additions & 8 deletions reference/cmath/asin.md
Expand Up @@ -6,14 +6,17 @@

```cpp
namespace std {
float asin(float x);
double asin(double x);
long double asin(long double x);
float asin(float x); // (1) C++03からC++20まで
double asin(double x); // (2) C++03からC++20まで
long double asin(long double x); // (3) C++03からC++20まで

double asin(Integral x); // C++11
floating-point-type
asin(floating-point-type x); // (4) C++23

float asinf(float x); // C++17 から
long double asinl(long double x); // C++17 から
double asin(Integral x); // (5) C++11

float asinf(float x); // (6) C++17
long double asinl(long double x); // (7) C++17
}
```
* Integral[italic]
Expand All @@ -23,6 +26,14 @@ namespace std {
`asin()`は、正弦を表す[`sin()`](sin.md)の逆関数である。$\sin(\mathrm{Arcsin}~x) = x$、$\mathrm{Arcsin}~(\sin x) = x ~ (x \in [-\pi/2, \pi/2])$である。
- (1) : `float`に対するオーバーロード
- (2) : `double`に対するオーバーロード
- (3) : `long double`に対するオーバーロード
- (4) : 浮動小数点数型に対するオーバーロード
- (5) : 整数型に対するオーバーロード (`double`にキャストして計算される)
- (6) : `float`型規定
- (7) : `long double`型規定
## 戻り値
引数 `x` の逆正弦を主値 `[-π/2, π/2]` の範囲で返す。(単位はラジアン)
Expand All @@ -34,8 +45,9 @@ namespace std {
- $$ f(x) = \mathrm{Arcsin}~x $$
- 定義域エラーが発生した場合の挙動については、[`<cmath>`](../cmath.md) を参照。
- C++11 以降では、処理系が IEC 60559 に準拠している場合([`std::numeric_limits`](../limits/numeric_limits.md)`<T>::`[`is_iec559`](../limits/numeric_limits/is_iec559.md)`() != false`)、以下の規定が追加される。
- `x = ±0` の場合、戻り値は `±0` となる。(複号同順)
- `x > |1|` の場合、戻り値は quiet NaN となり、[`FE_INVALID`](../cfenv/fe_invalid.md)(無効演算浮動小数点例外)が発生する。
- `x = ±0` の場合、戻り値は `±0` となる。(複号同順)
- `x > |1|` の場合、戻り値は quiet NaN となり、[`FE_INVALID`](../cfenv/fe_invalid.md)(無効演算浮動小数点例外)が発生する。
- C++23では、(1)、(2)、(3)が(4)に統合され、拡張浮動小数点数型を含む浮動小数点数型へのオーバーロードとして定義された
## 例
Expand Down Expand Up @@ -90,3 +102,8 @@ $$ \mathrm{Arcsin}~x = \sum_{n = 0}^{\infty} \frac{(2n)!}{4^n (n!)^2 (2n+1)} x^{
$|x| = 1$ 近傍の精度低下する領域(特に $1 / \sqrt{2} &lt; |x| \le 1$)においては、以下の公式による変換で精度向上を図れる。

$$ \mathrm{Arcsin}~x = \frac{\pi}{2} - \mathrm{Arccos}~x = \frac{\pi}{2} - \mathrm{Arcsin}~\sqrt{1 - x^2} \quad \mathrm{for} \; 0 \le x \le 1 $$


## 参照
- [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html)
- C++23で導入された拡張浮動小数点数型への対応として、`float``double``long double`のオーバーロードを`floating-point-type`のオーバーロードに統合し、拡張浮動小数点数型も扱えるようにした
33 changes: 25 additions & 8 deletions reference/cmath/asinh.md
Expand Up @@ -7,21 +7,32 @@

```cpp
namespace std {
float asinh(float x);
double asinh(double x);
long double asinh(long double x);
float asinh(float x); // (1) C++11からC++20まで
double asinh(double x); // (2) C++11からC++20まで
long double asinh(long double x); // (3) C++11からC++20まで

double asinh(Integral x); // C++11 から
floating-point-type
asinh(floating-point-type x); // (4) C++23

float asinhf(float x); // C++17 から
long double asinhl(long double x); // C++17 から
double asinh(Integral x); // (5) C++11

float asinhf(float x); // (6) C++17
long double asinhl(long double x); // (7) C++17
}
```
* Integral[italic]
## 概要
算術型の逆双曲線正弦(エリアハイパボリックサイン、area hyperbolic sine)を求める。
- (1) : `float`に対するオーバーロード
- (2) : `double`に対するオーバーロード
- (3) : `long double`に対するオーバーロード
- (4) : 浮動小数点数型に対するオーバーロード
- (5) : 整数型に対するオーバーロード (`double`にキャストして計算される)
- (6) : `float`型規定
- (7) : `long double`型規定
## 戻り値
引数 `x` の逆双曲線正弦を返す。
Expand All @@ -30,8 +41,9 @@ namespace std {
## 備考
- $$ f(x) = \mathrm{arsinh}~x $$
- 処理系が IEC 60559 に準拠している場合([`std::numeric_limits`](../limits/numeric_limits.md)`<T>::`[`is_iec559`](../limits/numeric_limits/is_iec559.md)`() != false`)、以下の規定が追加される。(複号同順)
- `x = ±0` の場合、戻り値は `±0` となる。
- `x = ±∞` の場合、戻り値は `±∞` となる。
- `x = ±0` の場合、戻り値は `±0` となる。
- `x = ±∞` の場合、戻り値は `±∞` となる。
- C++23では、(1)、(2)、(3)が(4)に統合され、拡張浮動小数点数型を含む浮動小数点数型へのオーバーロードとして定義された
## 例
Expand Down Expand Up @@ -80,3 +92,8 @@ $$ \mathrm{arsinh}~x = \sum_{n = 0}^{\infty} \frac{(-1)^n (2n)!}{4^n (n!)^2 (2n
または対数に変換して求めることができる。

$$ \mathrm{arsinh}~x = \log_e \left(x + \sqrt{x^2+1}\right) \quad \mathrm{for~all} \; x $$


## 参照
- [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html)
- C++23で導入された拡張浮動小数点数型への対応として、`float``double``long double`のオーバーロードを`floating-point-type`のオーバーロードに統合し、拡張浮動小数点数型も扱えるようにした
60 changes: 46 additions & 14 deletions reference/cmath/assoc_laguerre.md
Expand Up @@ -7,15 +7,44 @@

```cpp
namespace std {
float assoc_laguerref(unsigned n, unsigned m, float x);
double assoc_laguerre(unsigned n, unsigned m, double x);
long double assoc_laguerrel(unsigned n, unsigned m, long double x);
double
assoc_laguerre(unsigned int n,
unsigned int m,
double x); // (1) C++17
floating-point-type
assoc_laguerre(unsigned int n,
unsigned int m,
floating-point-type x); // (1) C++23

Promoted
assoc_laguerre(unsigned int n,
unsigned int m,
Arithmetic x); // (2) C++17

float
assoc_laguerref(unsigned int n,
unsigned int m,
float x); // (3) C++17

long double
assoc_laguerrel(unsigned int n,
unsigned int m,
long double x); // (4) C++17
}
```
* Promoted[italic]
* Arithmetic[italic]
## 概要
ラゲール陪多項式 (associated Laguerre polynomials) を計算する。
- (1) :
- C++17 : `double`に対するオーバーロード
- C++23 : 浮動小数点数型に対するオーバーロード
- (2) : 算術型に対するオーバーロード (対応する精度の浮動小数点数型にキャストして計算される)
- (3) : `float`型規定
- (4) : `long double`型規定
## 戻り値
引数 `n`, `m`, `x` のラゲール陪多項式
Expand All @@ -28,7 +57,8 @@ $$
## 備考
`n >= 128 || m >= 128` の場合、この関数の呼び出しの効果は実装定義である。
- `n >= 128 || m >= 128` の場合、この関数の呼び出しの効果は実装定義である
- (1) : C++23では、拡張浮動小数点数型を含む浮動小数点数型へのオーバーロードとして定義された
## 例
Expand Down Expand Up @@ -93,16 +123,6 @@ assoc_laguerre(2, 1, 2) = -1
- [Visual C++](/implementation.md#visual_cpp): ??


## 関連項目
* ラゲール多項式 [`laguerre`](laguerre.md)


## 参照
- [N3060 JTC1.22.29124 Programming Language C++ — Special Math Functions](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3060.pdf)
- [WG21 P0226R1 Mathematical Special Functions for C++17, v5](https://isocpp.org/files/papers/P0226R1.pdf)
- [ISO/IEC 29124:2010 Information technology -- Programming languages, their environments and system software interfaces -- Extensions to the C++ Library to support mathematical special functions](https://www.iso.org/standard/50511.html)


## 実装例
### 閉形式
$$
Expand All @@ -114,3 +134,15 @@ $$
L_n^m(x) = \frac{(2n + m - 1 - x)L_{n-1}^m(x) - (n + m - 1) L_{n-2}^m(x)}{n};
L_0^m(x) = 1, L_1^m(x) = -x + m + 1
$$


## 関連項目
- ラゲール多項式 [`laguerre`](laguerre.md)


## 参照
- [N3060 JTC1.22.29124 Programming Language C++ — Special Math Functions](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3060.pdf)
- [WG21 P0226R1 Mathematical Special Functions for C++17, v5](https://isocpp.org/files/papers/P0226R1.pdf)
- [ISO/IEC 29124:2010 Information technology -- Programming languages, their environments and system software interfaces -- Extensions to the C++ Library to support mathematical special functions](https://www.iso.org/standard/50511.html)
- [P1467R9 Extended floating-point types and standard names](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html)
- C++23で導入された拡張浮動小数点数型への対応として、`float``double``long double`のオーバーロードを`floating-point-type`のオーバーロードに統合し、拡張浮動小数点数型も扱えるようにした

0 comments on commit ace1860

Please sign in to comment.