BergEC-jl/osbrackets.jl

43 lines
1.4 KiB
Julia
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# compile using
# gfortran -shared -fPIC osbrac.f90 -o osbrac.so
# gfortran -shared -fPIC allosbrac.f90 -o allosbrac.so
using Libdl
function cal_BRAC(Emax, Λ, l1, l2)
ϵ = (2 * Emax - Λ) % 2
N = (l1 - l2 + Λ - ϵ) ÷ 2
M = (l1 + l2 - Λ - ϵ) ÷ 2
L = Λ
NQMAX = 2 * Emax
CO = 1/sqrt(2)
SI = 1/sqrt(2)
FIRSTCALL = true
# dimensions BRAC(0:L,0:(NQMAX-L)/2,0:(NQMAX-L)/2,0:(NQMAX-L)/2,0:(NQMAX-L)/2)
BRAC = zeros(Float64, 1 + L, 1 + (NQMAX - L) ÷ 2, 1 + (NQMAX - L) ÷ 2, 1 + (NQMAX - L) ÷ 2, 1 + (NQMAX - L) ÷ 2)
lib = Libdl.dlopen("OSBRACKETS/osbrac.so") # Open the library explicitly.
sym = Libdl.dlsym(lib, :osbrac_) # Get a symbol for the function to call.
# call signature OSBRAC(N,M,L,NQMAX,CO,SI,FIRSTCALL,BRAC)
@ccall $sym(N::Ref{Int32},M::Ref{Int32},L::Ref{Int32},NQMAX::Ref{Int32},CO::Ref{Float64},SI::Ref{Float64},FIRSTCALL::Ref{UInt8},BRAC::Ptr{Array{Float64}})::Cvoid
Libd.dlclose(lib)
return BRAC
end
function get_bracket(BRAC, Emax, Λ, n1, l1, n2, l2, n1, n2)
ϵ = (2 * Emax - Λ) % 2
NP = (l1 - l2 + Λ - ϵ) ÷ 2
N1P = n1
MP = (l1 + l2 - Λ - ϵ) ÷ 2
N1 = n1
N2 = n2
N2P = n2
if MP+N1P+N2P == M+N1+N2
# BRAC(NP,N1P,MP,N1,N2)
return BRAC[1 + NP, 1 + N1P, 1 + MP, 1 + N1, 1 + N2]
else
return 0
end
end