#pragma once #include #include template class complex_normal_distribution { private: std::normal_distribution d; T δx; T δy; std::complex μ; std::complex eθ; public: complex_normal_distribution(std::complex μ, T σ, std::complex κ) : μ(μ), d(0, σ / sqrt(2)) { δx = sqrt(1 + std::abs(κ)); δy = sqrt(1 - std::abs(κ)); eθ = std::polar((T)1, std::arg(κ)); } template std::complex operator()(Generator& g) { // First generate an axis-aligned complex number centered at the origin. std::complex z(d(g) * δx, d(g) * δy); // Shift and rotate the number. return μ + eθ * z; } };