Skip to content

Commit

Permalink
refactoring and adding Lsv for ome
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiani committed Jul 1, 2024
1 parent 6eacd3b commit b20732d
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 809 deletions.
149 changes: 59 additions & 90 deletions crates/eko/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,106 +20,68 @@ pub unsafe extern "C" fn rust_quad_ker_qcd(u: f64, rargs: *mut c_void) -> f64 {
let mut c = Cache::new(path.n());
let mut re = Vec::<f64>::new();
let mut im = Vec::<f64>::new();
if is_singlet {
let res = ekore::anomalous_dimensions::unpolarized::spacelike::gamma_singlet_qcd(
args.order_qcd,
&mut c,
args.nf,
);
for gamma_s in res.iter().take(args.order_qcd) {
for col in gamma_s.iter().take(2) {
for el in col.iter().take(2) {
re.push(el.re);
im.push(el.im);

if args.is_ome {
if is_singlet {
let res = ekore::operator_matrix_elements::unpolarized::spacelike::A_singlet(
args.order_qcd,
&mut c,
args.nf,
args.L,
);
for aS in res.iter().take(args.order_qcd) {
for col in aS.iter().take(3) {
for el in col.iter().take(3) {
re.push(el.re);
im.push(el.im);
}
}
}
}
} else {
let res = ekore::anomalous_dimensions::unpolarized::spacelike::gamma_ns_qcd(
args.order_qcd,
args.mode0,
&mut c,
args.nf,
);
for el in res.iter().take(args.order_qcd) {
re.push(el.re);
im.push(el.im);
}
}
// pass on
(args.py)(
re.as_ptr(),
im.as_ptr(),
c.n.re,
c.n.im,
jac.re,
jac.im,
args.order_qcd,
is_singlet,
args.mode0,
args.mode1,
args.nf,
args.is_log,
args.logx,
args.areas,
args.areas_x,
args.areas_y,
args.L,
args.method_num,
args.as1,
args.as0,
args.ev_op_iterations,
args.ev_op_max_order_qcd,
args.sv_mode_num,
args.is_threshold,
)
}

/// QCD intergration kernel for OME inside quad.
///
/// # Safety
/// This is the connection from Python, so we don't know what is on the other side.
#[no_mangle]
pub unsafe extern "C" fn rust_quad_ker_ome(u: f64, rargs: *mut c_void) -> f64 {
let args = *(rargs as *mut QuadQCDargs);
let is_singlet = (100 == args.mode0) || (21 == args.mode0) || (90 == args.mode0);
// prepare gamma
let path = mellin::TalbotPath::new(u, args.logx, is_singlet);
let jac = path.jac() * path.prefactor();
let mut c = Cache::new(path.n());
let mut re = Vec::<f64>::new();
let mut im = Vec::<f64>::new();
if is_singlet {
let res = ekore::operator_matrix_elements::unpolarized::spacelike::A_singlet(
args.order_qcd,
&mut c,
args.nf,
args.L,
);
for aS in res.iter().take(args.order_qcd) {
for col in aS.iter().take(3) {
for el in col.iter().take(3) {
re.push(el.re);
im.push(el.im);
} else {
let res = ekore::operator_matrix_elements::unpolarized::spacelike::A_non_singlet(
args.order_qcd,
&mut c,
args.nf,
args.L,
);
for anS in res.iter().take(args.order_qcd) {
for col in anS.iter().take(2) {
for el in col.iter().take(2) {
re.push(el.re);
im.push(el.im);
}
}
}
}
} else {
let res = ekore::operator_matrix_elements::unpolarized::spacelike::A_non_singlet(
args.order_qcd,
&mut c,
args.nf,
args.L,
);
for anS in res.iter().take(args.order_qcd) {
for col in anS.iter().take(2) {
for el in col.iter().take(2) {
re.push(el.re);
im.push(el.im);
if is_singlet {
let res = ekore::anomalous_dimensions::unpolarized::spacelike::gamma_singlet_qcd(
args.order_qcd,
&mut c,
args.nf,
);
for gamma_s in res.iter().take(args.order_qcd) {
for col in gamma_s.iter().take(2) {
for el in col.iter().take(2) {
re.push(el.re);
im.push(el.im);
}
}
}
} else {
let res = ekore::anomalous_dimensions::unpolarized::spacelike::gamma_ns_qcd(
args.order_qcd,
args.mode0,
&mut c,
args.nf,
);
for el in res.iter().take(args.order_qcd) {
re.push(el.re);
im.push(el.im);
}
}
}

// pass on
(args.py)(
re.as_ptr(),
Expand All @@ -146,6 +108,7 @@ pub unsafe extern "C" fn rust_quad_ker_ome(u: f64, rargs: *mut c_void) -> f64 {
args.ev_op_max_order_qcd,
args.sv_mode_num,
args.is_threshold,
args.Lsv,
)
}

Expand Down Expand Up @@ -175,6 +138,7 @@ type PyQuadKerQCDT = unsafe extern "C" fn(
u8,
u8,
bool,
f64,
) -> f64;

/// Additional integration parameters
Expand Down Expand Up @@ -202,6 +166,8 @@ pub struct QuadQCDargs {
pub ev_op_max_order_qcd: u8,
pub sv_mode_num: u8,
pub is_threshold: bool,
pub is_ome: bool,
pub Lsv: f64,
}

/// Empty placeholder function for python callback.
Expand Down Expand Up @@ -233,6 +199,7 @@ pub unsafe extern "C" fn my_py(
_ev_op_max_order_qcd: u8,
_sv_mode_num: u8,
_is_threshold: bool,
_lsv: f64,
) -> f64 {
0.
}
Expand Down Expand Up @@ -267,5 +234,7 @@ pub unsafe extern "C" fn empty_qcd_args() -> QuadQCDargs {
ev_op_max_order_qcd: 0,
sv_mode_num: 0,
is_threshold: false,
is_ome: false,
Lsv: 0.,
}
}
Loading

0 comments on commit b20732d

Please sign in to comment.