Skip to content

Commit 7d498ef

Browse files
committed
cmath (std::sph_legendre): C++20 円周率 std::numbers::pi を使用するように例を更新
1 parent 5800b64 commit 7d498ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

reference/cmath/sph_legendre.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,9 @@ double real_sph_harmonics(unsigned l, int m, double theta, double phi) {
126126
```cpp example
127127
#include <cmath>
128128
#include <complex>
129+
#include <numbers>
129130
#include <iostream>
130131
131-
constexpr double pi = 3.141592653589793;
132-
133132
// 球面調和関数
134133
std::complex<double> sph_harmonics(unsigned l, int m, double theta, double phi) {
135134
if (m >= 0)
@@ -145,9 +144,9 @@ int main() {
145144
146145
std::cout << "#θ / π\tφ / π\tY_" << l << "^" << m << "(θ, φ)\n";
147146
for (double t : {0., 0.25, 0.5, 0.75, 1.}) {
148-
double theta = t * pi;
147+
double theta = t * std::numbers::pi;
149148
for (double p : {0., 0.25, 0.5, 0.75, 1., 1.25, 1.5, 1.75, 2.}) {
150-
double phi = p * pi / 4;
149+
double phi = p * std::numbers::pi / 4;
151150
std::cout << t << "\t" << p << "\t" << sph_harmonics(l, m, theta, phi) << "\n";
152151
if (t == 0 || t == 1) break;
153152
}
@@ -156,6 +155,7 @@ int main() {
156155
```
157156
* std::sph_legendre[color ff0000]
158157
* std::polar[link /reference/complex/complex/polar.md]
158+
* std::numbers::pi[link /reference/numbers/pi.md]
159159

160160
### 出力例
161161
```

0 commit comments

Comments
 (0)