@@ -133,110 +133,38 @@ use alloc::{boxed::Box, vec::Vec};
133133use core:: { borrow:: Borrow , fmt:: Debug , hash:: Hash , marker:: PhantomData , ops:: RangeInclusive } ;
134134use num_traits:: { float:: FloatCore , AsPrimitive , One , PrimInt , WrappingAdd , WrappingSub , Zero } ;
135135
136- /// Re-export or replacement of [`probability::distribution::Distribution`].
136+ /// Re-export of [`probability::distribution::Distribution`].
137137///
138138/// Most users will never have to interact with this trait directly. When a method requires
139139/// a type that implements `Distribution`, most users will likely use a predefined type from
140140/// the [`probability`] crate. You only need to implement this trait if you want to use a
141141/// probability distribution that is not (yet) provided by the `probability` crate.
142142///
143- /// # Technical Details
144- ///
145- /// - For most users, this trait is just a re-export (similar to a type alias) of the
146- /// [`Distribution` trait from the `probability` crate]. You'll need a type that
147- /// implements `Distribution` when you call [`LeakyQuantizer::quantize`]. The
148- /// `probability` crate provides implementations of several common `Distribution`s.
149- /// - Unfortunately, the `probability` crate does not support `no_std` mode. Thus, if you
150- /// compile `constriction` in `no_std` mode (by setting `default-features = false` for
151- /// `constriction` in your `Cargo.toml`) then you can't use the `probability` crate . In
152- /// this case, the present trait (`constriction::stream::model::Distribution`) is not a
153- /// re-export but instead a literal copy of its definition in the `probability` trait.
154- ///
155- /// # Advice for Implementors
156- ///
157- /// If you implement your own probability distribution (rather than using a pre-defined
158- /// distribution from the `probability` crate) then it is usually better to implement *this*
159- /// trait rather than `probability::distribution::Distribution`. This way, your code will
160- /// work as expected both in `std` and in `no_std` mode.
161- ///
162143/// # See Also
163144///
164145/// - [`Inverse`]
165146///
166147/// [`probability::distribution::Distribution`]:
167148/// https://docs.rs/probability/latest/probability/distribution/trait.Distribution.html
168- /// [`Distribution` trait from the `probability` crate]:
169- /// https://docs.rs/probability/latest/probability/distribution/trait.Distribution.html
170149/// [`probability`]: https://docs.rs/probability/latest/probability/
171- #[ cfg( feature = "probability" ) ]
172150pub use probability:: distribution:: Distribution ;
173151
174- /// Re-export or replacement of [`probability::distribution::Inverse`].
152+ /// Re-export of [`probability::distribution::Inverse`].
175153///
176154/// Most users will never have to interact with this trait directly. When a method requires
177155/// a type that implements `Inverse`, most users will likely use a predefined type from
178156/// the [`probability`] crate. You only need to implement this trait if you want to use a
179157/// probability distribution that is not (yet) provided by the `probability` crate.
180158///
181- /// # Technical Details
182- ///
183- /// - For most users, this trait is just a re-export (similar to a type alias) of the
184- /// [`Inverse` trait from the `probability` crate]. You'll need a type that implements
185- /// `Inverse` when you call [`LeakyQuantizer::quantize`] and then use the resulting
186- /// [`LeakilyQuantizedDistribution`] for *decoding*. The `probability` crate provides
187- /// implementations of `Inverse` for several common probability distributions.
188- /// - Unfortunately, the `probability` crate does not support `no_std` mode. Thus, if you
189- /// compile `constriction` in `no_std` mode (by setting `default-features = false` for
190- /// `constriction` in your `Cargo.toml`) then you can't use the `probability` crate . In
191- /// this case, the present trait (`constriction::stream::model::Inverse`) is not a
192- /// re-export but instead a literal copy of its definition in the `probability` trait.
193- ///
194- /// # Advice for Implementors
195- ///
196- /// If you implement your own probability distribution (rather than using a pre-defined
197- /// distribution from the `probability` crate) then it is usually better to implement *this*
198- /// trait rather than `probability::distribution::Inverse`. This way, your code will
199- /// work as expected both in `std` and in `no_std` mode.
200- ///
201159/// # See Also
202160///
203161/// - [`Distribution`]
204162///
205163/// [`probability::distribution::Inverse`]:
206164/// https://docs.rs/probability/latest/probability/distribution/trait.Inverse.html
207- /// [`Inverse` trait from the `probability` crate]:
208- /// https://docs.rs/probability/latest/probability/distribution/trait.Inverse.html
209165/// [`probability`]: https://docs.rs/probability/latest/probability/
210- #[ cfg( feature = "probability" ) ]
211166pub use probability:: distribution:: Inverse ;
212167
213- /// Mock replacement for [`probability::distribution::Distribution`] in a `no_std` context
214- ///
215- /// This trait is only exported if `constriction` is used in a `no_std` context (i.e., with
216- /// `default-features = false`). In this case, we can't use the `probability` crate because
217- /// it uses a lot of FFI calls. However, for many things, we really only need the trait
218- /// definitions for `Distribution` and for [`Inverse`], so we copy them here.
219- #[ cfg( not( feature = "probability" ) ) ]
220- pub trait Distribution {
221- /// The type of outcomes.
222- type Value ;
223-
224- /// Compute the cumulative distribution function.
225- fn distribution ( & self , x : f64 ) -> f64 ;
226- }
227-
228- /// Mock replacement for [`probability::distribution::Distribution`] in a `no_std` context
229- ///
230- /// This trait is only exported if `constriction` is used in a `no_std` context (i.e., with
231- /// `default-features = false`). In this case, we can't use the `probability` crate because
232- /// it uses a lot of FFI calls. However, for many things, we really only need the trait
233- /// definitions for [`Distribution`] and for `Inverse`, so we copy them here.
234- #[ cfg( not( feature = "probability" ) ) ]
235- pub trait Inverse : Distribution {
236- /// Compute the inverse of the cumulative distribution function.
237- fn inverse ( & self , p : f64 ) -> Self :: Value ;
238- }
239-
240168use crate :: { wrapping_pow2, BitArray , NonZeroBitArray } ;
241169
242170/// Base trait for probabilistic models of a data source.
@@ -441,7 +369,6 @@ pub trait IterableEntropyModel<'m, const PRECISION: usize>: EntropyModel<PRECISI
441369 /// Note that calling this method on a [`LeakilyQuantizedDistribution`] will return the
442370 /// entropy *after quantization*, not the differential entropy of the underlying
443371 /// continuous probability distribution.
444- #[ cfg( any( feature = "std" , feature = "libm" ) ) ]
445372 fn entropy_base2 < F > ( & ' m self ) -> F
446373 where
447374 F : num_traits:: Float + core:: iter:: Sum ,
@@ -789,7 +716,6 @@ where
789716 ( * self ) . symbol_table ( )
790717 }
791718
792- #[ cfg( any( feature = "std" , feature = "libm" ) ) ]
793719 fn entropy_base2 < F > ( & ' m self ) -> F
794720 where
795721 F : num_traits:: Float + core:: iter:: Sum ,
@@ -3147,7 +3073,6 @@ where
31473073 /// - because the order in which entries are stored will generally be different on each
31483074 /// program execution, rounding errors will be slightly different across multiple
31493075 /// program executions.
3150- #[ cfg( any( feature = "std" , feature = "libm" ) ) ]
31513076 pub fn entropy_base2 < F > ( & self ) -> F
31523077 where
31533078 F : num_traits:: Float + core:: iter:: Sum ,
0 commit comments