diff --git a/Core/Basics/Complex.h b/Core/Basics/Complex.h index 13dff4f89e3c3fa5837ec9f5c0dc9d4284655e9c..5434dce6e47a57eafdea27a4d51ea464346aeb92 100644 --- a/Core/Basics/Complex.h +++ b/Core/Basics/Complex.h @@ -17,7 +17,8 @@ #include <complex> -typedef std::complex<double> complex_t; +using complex_t = std::complex<double>; +constexpr complex_t I = complex_t(0.0, 1.0); //! Returns product I*z, where I is the imaginary unit. inline complex_t mul_I(complex_t z) diff --git a/Core/HardParticle/FormFactorPolyhedron.cpp b/Core/HardParticle/FormFactorPolyhedron.cpp index ab3cda4e776a021a8d201682047e52edfdeae55d..e222907fbe58c813f36b538c4a7a65521d4e2fbf 100644 --- a/Core/HardParticle/FormFactorPolyhedron.cpp +++ b/Core/HardParticle/FormFactorPolyhedron.cpp @@ -26,7 +26,6 @@ namespace { -const complex_t I = {0., 1.}; const double eps = 2e-16; constexpr auto ReciprocalFactorialArray = Precomputed::GenerateReciprocalFactorialArray<171>(); } // namespace diff --git a/Core/HardParticle/FormFactorTruncatedSpheroid.cpp b/Core/HardParticle/FormFactorTruncatedSpheroid.cpp index b7e93ff209271203c2b1c63d88ee074a293e20dc..2f7c2199158892eab2e4b92eb48680674143277a 100644 --- a/Core/HardParticle/FormFactorTruncatedSpheroid.cpp +++ b/Core/HardParticle/FormFactorTruncatedSpheroid.cpp @@ -70,7 +70,7 @@ complex_t FormFactorTruncatedSpheroid::Integrand(double Z) const complex_t qrRz = std::sqrt(m_q.x() * m_q.x() + m_q.y() * m_q.y()) * Rz; complex_t J1_qrRz_div_qrRz = MathFunctions::Bessel_J1c(qrRz); - return Rz * Rz * J1_qrRz_div_qrRz * std::exp(complex_t(0.0, 1.0) * m_q.z() * Z); + return Rz * Rz * J1_qrRz_div_qrRz * std::exp(I * m_q.z() * Z); } complex_t FormFactorTruncatedSpheroid::evaluate_for_q(cvector_t q) const @@ -82,7 +82,7 @@ complex_t FormFactorTruncatedSpheroid::evaluate_for_q(cvector_t q) const if (std::abs(m_q.mag()) <= std::numeric_limits<double>::epsilon()) return M_PI / 3. / fp * (H * H * (3. * R - H / fp) - m_dh * m_dh * (3. * R - m_dh / fp)); - complex_t z_part = std::exp(complex_t(0.0, 1.0) * m_q.z() * (H - fp * R)); + complex_t z_part = std::exp(I * m_q.z() * (H - fp * R)); return M_TWOPI * z_part * ComplexIntegrator().integrate([&](double Z) { return Integrand(Z); }, fp * R - H, fp * R - m_dh); diff --git a/Core/HardParticle/Ripples.cpp b/Core/HardParticle/Ripples.cpp index f4b677e2c50abb5e1090c44a140b31a5c169e46f..f1e301c79672ae5277c9e76b165b726935442535 100644 --- a/Core/HardParticle/Ripples.cpp +++ b/Core/HardParticle/Ripples.cpp @@ -60,7 +60,7 @@ complex_t ripples::profile_yz_cosine(complex_t qy, complex_t qz, double width, d // numerical integration otherwise const complex_t ay = qy * width / M_TWOPI; - const complex_t az = complex_t(0, 1) * qz * (height / 2); + const complex_t az = I * qz * (height / 2); const auto integrand = [&](double u) -> complex_t { return sin(u) * exp(az * std::cos(u)) * (ay == 0. ? u : sin(ay * u) / ay); diff --git a/Core/Material/MaterialUtils.cpp b/Core/Material/MaterialUtils.cpp index 82d5dccb24672fd7f54627e9cb74246c627c593e..206c75ac156b423be7c2e67cb3a412ba37dad866 100644 --- a/Core/Material/MaterialUtils.cpp +++ b/Core/Material/MaterialUtils.cpp @@ -29,8 +29,6 @@ const Eigen::Matrix2cd Unit_Matrix(Eigen::Matrix2cd::Identity()); // Imaginary unit namespace { -const complex_t I(0, 1); - // Pauli matrices const Eigen::Matrix2cd Pauli_X((Eigen::Matrix2cd() << 0, 1, 1, 0).finished()); const Eigen::Matrix2cd Pauli_Y((Eigen::Matrix2cd() << 0, -I, I, 0).finished()); diff --git a/Core/Multilayer/SpecularMagneticOldStrategy.cpp b/Core/Multilayer/SpecularMagneticOldStrategy.cpp index 2727c0903e10a64b258fd4c19926b6ac0bf9d112..35cad22657186425ede61cc9fcf434ceb502088a 100644 --- a/Core/Multilayer/SpecularMagneticOldStrategy.cpp +++ b/Core/Multilayer/SpecularMagneticOldStrategy.cpp @@ -28,7 +28,6 @@ void CalculateTransferAndBoundary(const std::vector<Slice>& slices, std::vector<MatrixRTCoefficients>& coeff); void SetForNoTransmission(std::vector<MatrixRTCoefficients>& coeff); complex_t GetImExponential(complex_t exponent); -const complex_t I(0, 1); } // namespace ISpecularStrategy::coeffs_t SpecularMagneticOldStrategy::Execute(const std::vector<Slice>& slices, diff --git a/Core/Multilayer/SpecularMagneticStrategy.cpp b/Core/Multilayer/SpecularMagneticStrategy.cpp index c66b7c84075c9755501ca3543f6ae3fb69554617..f58c2bb910d0b921e944082e4eb2cca8608a35b0 100644 --- a/Core/Multilayer/SpecularMagneticStrategy.cpp +++ b/Core/Multilayer/SpecularMagneticStrategy.cpp @@ -27,7 +27,6 @@ complex_t GetImExponential(complex_t exponent); // The factor 1e-18 is here to have unit: 1/T*nm^-2 constexpr double magnetic_prefactor = PhysConsts::m_n * PhysConsts::g_factor_n * PhysConsts::mu_N / PhysConsts::h_bar / PhysConsts::h_bar * 1e-18; -constexpr complex_t I(0.0, 1.0); } // namespace ISpecularStrategy::coeffs_t SpecularMagneticStrategy::Execute(const std::vector<Slice>& slices, diff --git a/Core/RT/MatrixRTCoefficients_v2.cpp b/Core/RT/MatrixRTCoefficients_v2.cpp index 9dee94138426fa152e7665c608438574aa1a5050..b82e825e5482a465cff89bb0494e940ff4101687 100644 --- a/Core/RT/MatrixRTCoefficients_v2.cpp +++ b/Core/RT/MatrixRTCoefficients_v2.cpp @@ -18,8 +18,6 @@ namespace { Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix, const Eigen::Vector4cd& boundary_cond); - -constexpr complex_t I = complex_t(0.0, 1.0); } // namespace MatrixRTCoefficients_v2::MatrixRTCoefficients_v2(double kz_sign, Eigen::Vector2cd eigenvalues, diff --git a/Tests/UnitTests/Core/Axes/CVectorTest.cpp b/Tests/UnitTests/Core/Axes/CVectorTest.cpp index 2c9f32e5f6e7b9eccdd1d19abbfc6d646315523c..28d4b8ef3cb26c908d5876c2658bce05a5aa7735 100644 --- a/Tests/UnitTests/Core/Axes/CVectorTest.cpp +++ b/Tests/UnitTests/Core/Axes/CVectorTest.cpp @@ -37,6 +37,6 @@ TEST_F(CVectorTest, BasicArithmetics) // f = f_re + j*f_im cvector_t vec_e(1., 2., 3.); cvector_t vec_f(5., 6., 7.); - EXPECT_EQ(vec_e + complex_t(0, 1) * vec_f, + EXPECT_EQ(vec_e + I * vec_f, cvector_t(complex_t(1., 5.), complex_t(2., 6), complex_t(3, 7))); }