Commit 849ad30a authored by Jan-Oliver Kaiser's avatar Jan-Oliver Kaiser

Add inline annotations.

parent 2cc206c8
......@@ -2,6 +2,7 @@
//// STIRLING APPROXIMATIONS
pub mod stirling_approximation{
use std::f64;
#[inline]
pub fn fac_stirling(n: f64) -> f64{
let result: f64 = (2.0*f64::consts::PI*n).sqrt();
let frac: f64 = (n/f64::consts::E).powf(n);
......@@ -15,6 +16,7 @@ pub mod stirling_approximation{
}
#[inline]
pub fn log_binomial_coefficient_stirling(n: usize, k: usize) -> f64{
let res: f64;
if n == k{
......@@ -33,6 +35,7 @@ pub mod stirling_approximation{
}
#[inline]
pub fn gammaln_stirling(z: f64) -> f64{
let result: f64 = z*z.ln() - z + 0.5*(2.0*f64::consts::PI/z).ln();
result / f64::consts::LN_2
......@@ -42,6 +45,8 @@ pub mod stirling_approximation{
//// DATA-TO-MODEL FOR DISTRIBUTIONS
pub mod d2m_codes{
use basic_codes::stirling_approximation;
#[inline]
pub fn d2m_nonzero_distribution_cost(counts: usize, bins: usize) -> f64{
//println!("approximating d2m NONZERO distribution cost: {} counts in {} bins", counts, bins);
if counts < bins{
......@@ -54,6 +59,7 @@ pub mod d2m_codes{
stirling_approximation::log_binomial_coefficient_stirling(counts - 1, bins - 1)
}
#[inline]
pub fn d2m_distribution_cost(counts: usize, bins: usize) -> f64{
//println!("approximating d2m distribution cost: {} counts in {} bins", counts, bins);
if bins == 1
......@@ -101,6 +107,7 @@ pub mod uic{
res + UIC_NORMALIZATION_CONSTANT
}
#[inline]
pub fn uic_memoized(n: usize) -> f64 {
if n < MAX_UIC_MEMOIZATION
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment