Skip to content

Commit

Permalink
rust: Add unit tests for ad/u/s/as1
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhekhorn committed Aug 18, 2023
1 parent fbf6fe4 commit 4574b0d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
62 changes: 62 additions & 0 deletions crates/ekore/src/anomalous_dimensions/unpolarized/spacelike/as1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,65 @@ pub fn gamma_singlet(c: &mut Cache, nf: u8) -> [[Complex<f64>; 2]; 2] {
[gamma_gq(c, nf), gamma_gg(c, nf)],
]
}

#[cfg(test)]
mod tests {
use crate::{anomalous_dimensions::unpolarized::spacelike::as1::*, harmonics::cache::Cache};
use float_cmp::assert_approx_eq;
use num::complex::Complex;
const NF: u8 = 5;

#[test]
fn number_conservation() {
const N: Complex<f64> = Complex::<f64> { re: 1., im: 0. };
let mut c = Cache::new(N);
let me = gamma_ns(&mut c, NF);
assert_approx_eq!(f64, me.re, 0., epsilon = 1e-12);
assert_approx_eq!(f64, me.im, 0., epsilon = 1e-12);
}

#[test]
fn quark_momentum_conservation() {
const N: Complex<f64> = Complex::<f64> { re: 2., im: 0. };
let mut c = Cache::new(N);
let me = gamma_ns(&mut c, NF) + gamma_gq(&mut c, NF);
assert_approx_eq!(f64, me.re, 0., epsilon = 1e-12);
assert_approx_eq!(f64, me.im, 0., epsilon = 1e-12);
}

#[test]
fn gluon_momentum_conservation() {
const N: Complex<f64> = Complex::<f64> { re: 2., im: 0. };
let mut c = Cache::new(N);
let me = gamma_qg(&mut c, NF) + gamma_gg(&mut c, NF);
assert_approx_eq!(f64, me.re, 0., epsilon = 1e-12);
assert_approx_eq!(f64, me.im, 0., epsilon = 1e-12);
}

#[test]
fn gamma_qg_() {
const N: Complex<f64> = Complex::<f64> { re: 1., im: 0. };
let mut c = Cache::new(N);
let me = gamma_qg(&mut c, NF);
assert_approx_eq!(f64, me.re, -20. / 3.0, ulps = 32);
assert_approx_eq!(f64, me.im, 0., epsilon = 1e-12);
}

#[test]
fn gamma_gq_() {
const N: Complex<f64> = Complex::<f64> { re: 0., im: 1. };
let mut c = Cache::new(N);
let me = gamma_gq(&mut c, NF);
assert_approx_eq!(f64, me.re, 4. / 3.0, ulps = 32);
assert_approx_eq!(f64, me.im, -4. / 3.0, ulps = 32);
}

#[test]
fn gamma_gg_() {
const N: Complex<f64> = Complex::<f64> { re: 0., im: 1. };
let mut c = Cache::new(N);
let me = gamma_gg(&mut c, NF);
assert_approx_eq!(f64, me.re, 5.195725159621, ulps = 32, epsilon = 1e-11);
assert_approx_eq!(f64, me.im, 10.52008856962, ulps = 32, epsilon = 1e-11);
}
}
1 change: 1 addition & 0 deletions crates/ekore/src/harmonics/polygamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ mod tests {
let fref = FORTRAN_REF[kit.0][zit.0];
let me = cern_polygamma(*zit.1, *kit.1);
assert_approx_eq!(f64, me.re, fref.re, ulps = 32);
assert_approx_eq!(f64, me.im, fref.im, ulps = 32);
}
}
}
Expand Down

0 comments on commit 4574b0d

Please sign in to comment.