diff --git a/helper.jl b/helper.jl index 4d284ba..e48b171 100644 --- a/helper.jl +++ b/helper.jl @@ -1,7 +1,7 @@ using LinearAlgebra, DelimitedFiles "Sum over array while minimizing catastrophic cancellation as much as possible" -function better_sum(arr::Array{Float64}) +function better_sum(arr::Array{T}) where T<:Real pos_arr = arr[arr .> 0] neg_arr = arr[arr .< 0] diff --git a/math.jl b/math.jl index 0556def..96c440b 100644 --- a/math.jl +++ b/math.jl @@ -15,7 +15,7 @@ laguerre(l, n, x) = gamma(n + l + 3/2) * better_sum([(-x * x)^k / gamma(k + l + ho_basis(l, n, x) = (-1)^n / sqrt_sqrt_pi * 2^((n + l + 2) / 2) * sqrt_factorial(n) / sqrt_double_factorial(2*n + 2*l + 1) * x^(l + 1) * exp(-x^2 / 2) * laguerre(l, n, x) # for implementation of simple relative coordinates -double_factorial(n) = Iterators.prod(Float64, n:-2:1) +double_factorial(n::Int) = Iterators.prod(big, n:-2:1) "Gaussian integral for n ∈ Integers (Ref: Wolfram MathWorld + simplifications)" gauss_int(a, n) = double_factorial(n - 1) / (2 * a)^((n + 1)/2) * (iseven(n) ? sqrt(π / 2) : 1)