ゼロ近傍で傾きを持ち、x→±∞ で f(x) → ±1 or ±π/2 になる関数、ようするに図1の5つの関数を集めてみた。
図1: グーデルマン関数 gd(x)、誤差関数 erf(x)、tanh(x)、ランジュバン関数 L(x)
| map print, | |
| map "hello = $_->[0] , world = $_->[1]\n", | |
| map [split ','], | |
| map {s/[\x0d\x0a]//g; $_} | |
| map scalar <STDIN>, | |
| 1..<STDIN>; |
| // EloRating Calculator | |
| // http://www.kurims.kyoto-u.ac.jp/~ooura/gamerf.html | |
| pub fn gammaln_6(x: f64) -> f64 { | |
| // 0 < x < infinity | |
| // err = 2.09144255e-18 | |
| (x - 0.5) * (x + 6.0975075753906857609437558e+0).ln() - x | |
| + ((((((1.1240582657165407383437999e-2 / (x + 5.0003589884831925541613237e+0) | |
| + 5.0219722703392090725884168e-1) | |
| / (x + 3.9999966300007508932097016e+0) |
| import struct | |
| import zlib | |
| from typing import BinaryIO, List, Tuple | |
| Pixel = Tuple[int, int, int] | |
| Image = List[List[Pixel]] | |
| BLACK_PIXEL: Pixel = (0, 0, 0) | |
| WHITE_PIXEL: Pixel = (255, 255, 255) |
| // If `unsafe` and `nightly` are enabled, enable unstable `core_intrinsics` feature | |
| // with #![feature(core_intrinsics)] (Nightly only). | |
| macro_rules! invariant { | |
| ($expr: expr) => { | |
| cfg_if::cfg_if! { | |
| if #[cfg(all(feature = "unsafe", feature = "nightly"))] { | |
| core::intrinsics::assume($expr); | |
| } | |
| else if #[cfg(feature = "unsafe")] { |
| # Function to check if the script is running as Administrator | |
| function Test-IsAdmin { | |
| $currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | |
| return $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
| } | |
| # If not running as Administrator, restart the script with elevated privileges | |
| if (-not (Test-IsAdmin)) { | |
| Write-Output "Restarting script with elevated privileges..." | |
| Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs |