Skip to content

Commit

Permalink
Merge pull request #1208 from newpavlov/rand_distr/fix_no_std
Browse files Browse the repository at this point in the history
rand_distr: fix no_std build
  • Loading branch information
vks committed Jan 13, 2022
2 parents 19404d6 + 9ef737b commit 8f37250
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions rand_distr/CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.3] - 2021-12-30
- Fix `no_std` build (#1208)

## [0.4.2] - 2021-09-18
- New `Zeta` and `Zipf` distributions (#1136)
- New `SkewNormal` distribution (#1149)
Expand Down
2 changes: 1 addition & 1 deletion rand_distr/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rand_distr"
version = "0.4.2"
version = "0.4.3"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 2 additions & 0 deletions rand_distr/src/binomial.rs
Expand Up @@ -13,6 +13,8 @@ use crate::{Distribution, Uniform};
use rand::Rng;
use core::fmt;
use core::cmp::Ordering;
#[allow(unused_imports)]
use num_traits::Float;

/// The binomial distribution `Binomial(n, p)`.
///
Expand Down
2 changes: 2 additions & 0 deletions rand_distr/src/geometric.rs
Expand Up @@ -3,6 +3,8 @@
use crate::Distribution;
use rand::Rng;
use core::fmt;
#[allow(unused_imports)]
use num_traits::Float;

/// The geometric distribution `Geometric(p)` bounded to `[0, u64::MAX]`.
///
Expand Down
2 changes: 2 additions & 0 deletions rand_distr/src/hypergeometric.rs
Expand Up @@ -4,6 +4,8 @@ use crate::Distribution;
use rand::Rng;
use rand::distributions::uniform::Uniform;
use core::fmt;
#[allow(unused_imports)]
use num_traits::Float;

#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
Expand Down
3 changes: 2 additions & 1 deletion rand_distr/src/utils.rs
Expand Up @@ -11,6 +11,7 @@
use crate::ziggurat_tables;
use rand::distributions::hidden_export::IntoFloat;
use rand::Rng;
use num_traits::Float;

/// Calculates ln(gamma(x)) (natural logarithm of the gamma
/// function) using the Lanczos approximation.
Expand All @@ -25,7 +26,7 @@ use rand::Rng;
/// `Ag(z)` is an infinite series with coefficients that can be calculated
/// ahead of time - we use just the first 6 terms, which is good enough
/// for most purposes.
pub(crate) fn log_gamma<F: num_traits::Float>(x: F) -> F {
pub(crate) fn log_gamma<F: Float>(x: F) -> F {
// precalculated 6 coefficients for the first 6 terms of the series
let coefficients: [F; 6] = [
F::from(76.18009172947146).unwrap(),
Expand Down

0 comments on commit 8f37250

Please sign in to comment.