Skip to content
Snippets Groups Projects

resolved clang support issue

Merged Lars Bocklage requested to merge clang_problem into main
4 files
+ 92
28
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -27,10 +27,7 @@
#include "../nexus_definitions.h"
#include "../math/constants.h"
#include <iostream>
#include "../utilities/errors.h"
namespace quantum {
@@ -57,7 +54,7 @@ namespace quantum {
constexpr short kCacheSize = 16;
static constexpr unsigned long long factorial_cache[kCacheSize] = {1, 1, 2, 6, 24, 120, 720, 5040,
static constexpr unsigned long long factorial_cache[kCacheSize] = { 1, 1, 2, 6, 24, 120, 720, 5040,
40320, 362880, 3628800, 39916800,
479001600, 6227020800,
87178291200, 1307674368000 };
@@ -71,7 +68,7 @@ namespace quantum {
else
{
f = factorial_cache[kCacheSize - 1];
for (int i = kCacheSize; i <= n; i++)
f *= i;
}
@@ -142,7 +139,7 @@ namespace quantum {
const int k_max = *std::min_element(upperbound, upperbound + 3);
double clebsh_gordon = 0.0;
for (int k = k_min; k <= k_max; k++)
{
clebsh_gordon += pow(-1, k) / static_cast<double>(Factorial(k) * Factorial(j1 + j2 - J - k) * Factorial(j1 - m1 - k)
@@ -159,7 +156,7 @@ namespace quantum {
double ThreeJSymbol(const double j1, const double j2, const double j3, const double m1, const double m2, const double m3)
{
return pow(-1, j1 - j2 - m3) / sqrt(2* j3 + 1) * ClebshGordon(j1, j2, m1, m2, j3, -1 * m3);
return pow(-1, j1 - j2 - m3) / sqrt(2 * j3 + 1) * ClebshGordon(j1, j2, m1, m2, j3, -1 * m3);
}
@@ -177,7 +174,7 @@ namespace quantum {
const double v = static_cast<double>(Factorial(a - b + c));
const double w = static_cast<double>(Factorial(-a + b + c));
const double z = static_cast<double>(Factorial(a + b + c + 1));
double tc = 0.0;
if (z > 0)
@@ -205,10 +202,10 @@ namespace quantum {
const int z_max = *std::min_element(upperbound, upperbound + 3);
double w_coeff = 0.0;
for (int z = z_min; z <= z_max; z++)
{
w_coeff += pow(-1, z + b_1) * Factorial(z + 1) /
w_coeff += pow(-1, z + b_1) * Factorial(z + 1) /
static_cast<double>(Factorial(z - a_1) * Factorial(z - a_2) * Factorial(z - a_3) * Factorial(z - a_4) * Factorial(b_1 - z) * Factorial(b_2 - z) * Factorial(b_3 - z));
}
@@ -230,8 +227,8 @@ namespace quantum {
double SmallWignerDmatrix(const double j, const double m1, const double m2, const double beta)
{
if (fabs(m1) > j ||
fabs(m2) > j ||
j <= 0)
fabs(m2) > j ||
j <= 0)
{
return 0.0;
}
@@ -265,40 +262,57 @@ namespace quantum {
return exp(-1.0i * m1 * alpha) * SmallWignerDmatrix(j, m1, m2, beta) * exp(-1.0i * m2 * gamma);
}
// polynomials - not for clang
#ifndef NEXUS_WITH_CLANG
// polynomials - for clang they return NaN
double Laguerre(const int n, const double x)
{
#ifndef NEXUS_WITH_CLANG
if (n < 0)
return std::numeric_limits<double>::quiet_NaN();
return std::laguerre(n, x);
#else
errors::WarningMessage("Quantum", "macOS does not support this function.");
return std::numeric_limits<double>::quiet_NaN();
#endif
}
double AssociatedLaguerre(const int n, const int k, const double x)
{
#ifndef NEXUS_WITH_CLANG
if (n < 0 || k < 0)
return std::numeric_limits<double>::quiet_NaN();
return std::assoc_laguerre(n, k, x);
#else
errors::WarningMessage("Quantum", "macOS does not support this function.");
return std::numeric_limits<double>::quiet_NaN();
#endif
}
double Legendre(const int n, const double x)
{
#ifndef NEXUS_WITH_CLANG
if (n < 0)
return std::numeric_limits<double>::quiet_NaN();
return std::legendre(n, x);
#else
errors::WarningMessage("Quantum", "macOS does not support this function.");
return std::numeric_limits<double>::quiet_NaN();
#endif
}
double AssociatedLegendre(const int l, const int m, const double x, const bool csp)
{
#ifndef NEXUS_WITH_CLANG
if (l < 0 || m < 0)
return std::numeric_limits<double>::quiet_NaN();
@@ -308,20 +322,32 @@ namespace quantum {
cs_phase = pow(-1, m);
return cs_phase * std::assoc_legendre(l, m, x);
#else
errors::WarningMessage("Quantum", "macOS does not support this function.");
return std::numeric_limits<double>::quiet_NaN();
#endif
}
double Hermite(const int n, const double x)
{
#ifndef NEXUS_WITH_CLANG
if (n < 0)
return std::numeric_limits<double>::quiet_NaN();
return std::hermite(n, x);
#else
errors::WarningMessage("Quantum", "macOS does not support this function.");
return std::numeric_limits<double>::quiet_NaN();
#endif
}
Complex SphericalHarmonics(const int l, const int m, const double theta, const double phi, const bool csp, const bool racah_norm)
{
#ifndef NEXUS_WITH_CLANG
if (l < 0 || m < 0)
return std::numeric_limits<double>::quiet_NaN();
@@ -331,9 +357,13 @@ namespace quantum {
norm *= sqrt( (2.0 * l + 1.0) / (4.0 * constants::kPi) );
return norm * AssociatedLegendre(l, m, cos(theta), csp) * exp(1.0i * static_cast<double>(m) * phi);
}
#else
errors::WarningMessage("Quantum", "macOS does not support this function.");
return std::numeric_limits<double>::quiet_NaN();
#endif
}
VecSpherHarm VecSpherHarmPolarization(const int L, const int lambda, const coordinates::Euler euler)
{
Loading