1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// The ghost functions are the same as those of pure Yang-Mills theory to one loop,
// so just re-export them. Unfortunately, cbindgen won't pick up the ffi functions,
// so we need to copy-paste those. While we are at it, we'll make them use this
// module's inlines rather than those of crate::ym.
//
// Do not write tests, it's not worth it at this stage. Keep in mind though that the
// ffi module is currently unchecked.

pub use crate::ym::ghost::native::*;

// For use in other languages, e.g. C/C++/Python
//
// - Re-export at crate::ffi, since symbols need to be unmangled anyway and the
//   namespace will not be preserved.
//
// - Here too each function calls its inline analogue, but the objective is to
//   switch from generic to concrete argument types so that the functions can
//   be compiled into a C dynamic library. To do so, we need to double their
//   number (one function for real arguments, another for complex arguments).
pub(crate) mod ffi {
    use super::inlines;
    use crate::{C, R};

    #[no_mangle]
    pub extern "C" fn qcd__ghost__dressing_inv_landau(s: R, g0: R) -> R {
        inlines::dressing_inv_landau(s, g0)
    }

    #[no_mangle]
    pub extern "C" fn qcd__ghost__dressing_inv_landau__complex(s: C, g0: R) -> C {
        inlines::dressing_inv_landau(s, g0)
    }

    #[no_mangle]
    pub extern "C" fn qcd__ghost__dressing_inv(s: R, g0: R, xi: R) -> R {
        inlines::dressing_inv(s, g0, xi)
    }

    #[no_mangle]
    pub extern "C" fn qcd__ghost__dressing_inv__complex(s: C, g0: R, xi: R) -> C {
        inlines::dressing_inv(s, g0, xi)
    }

    #[no_mangle]
    pub extern "C" fn qcd__ghost__dressing_landau(s: R, g0: R) -> R {
        inlines::dressing_landau(s, g0)
    }

    #[no_mangle]
    pub extern "C" fn qcd__ghost__dressing_landau__complex(s: C, g0: R) -> C {
        inlines::dressing_landau(s, g0)
    }

    #[no_mangle]
    pub extern "C" fn qcd__ghost__dressing(s: R, g0: R, xi: R) -> R {
        inlines::dressing(s, g0, xi)
    }

    #[no_mangle]
    pub extern "C" fn qcd__ghost__dressing__complex(s: C, g0: R, xi: R) -> C {
        inlines::dressing(s, g0, xi)
    }
}

pub(crate) mod inlines {
    #[allow(unused_imports)]
    pub use crate::ym::ghost::inlines::*;
}