From 75572757dccc198e55f1061c8e6185b5ee83f1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 13 Jan 2026 16:04:10 +0100 Subject: [PATCH 1/4] fixedpoint: add description --- dsp-fixedpoint/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/dsp-fixedpoint/Cargo.toml b/dsp-fixedpoint/Cargo.toml index 9d3c28d..3197a62 100644 --- a/dsp-fixedpoint/Cargo.toml +++ b/dsp-fixedpoint/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "dsp-fixedpoint" +description = "Fixed point types for DSP" version = "0.1.0" edition.workspace = true authors.workspace = true From 1c5d2817a2b2b2189532ee9d077220e8bb5a47bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 13 Jan 2026 16:20:55 +0100 Subject: [PATCH 2/4] fixedpoint: doctest --- dsp-fixedpoint/src/lib.rs | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/dsp-fixedpoint/src/lib.rs b/dsp-fixedpoint/src/lib.rs index 6849346..6035694 100644 --- a/dsp-fixedpoint/src/lib.rs +++ b/dsp-fixedpoint/src/lib.rs @@ -224,6 +224,11 @@ impl Q { } /// Scale from integer base type + /// + /// ``` + /// # use dsp_fixedpoint::Q8; + /// assert_eq!(Q8::<4>::from_int(7).inner, 7 << 4); + /// ``` #[inline] pub fn from_int(value: T) -> Self { Self::new(value.shs(F)) @@ -232,6 +237,13 @@ impl Q { impl, const F: i8> Q { /// Scale from integer accu type + /// + /// + /// ``` + /// # use dsp_fixedpoint::Q8; + /// let q = Q8::<4>::from_f32(0.25); + /// assert_eq!((q * 7).quantize(), (7.0 * 0.25f32).floor() as _); + /// ``` #[inline] pub fn quantize(self) -> T { T::down(self.trunc()) @@ -239,6 +251,11 @@ impl, const F: i8> Q { } /// Lossy conversion from a dynamically scaled integer +/// +/// ``` +/// # use dsp_fixedpoint::Q8; +/// assert_eq!(Q8::<8>::from((1, 3)).inner, 1 << 5); +/// ``` impl + Shift, A, const F: i8> From<(T, i8)> for Q { fn from(value: (T, i8)) -> Self { Self::new(value.0.shs(F - value.1)) @@ -246,15 +263,22 @@ impl + Shift, A, const F: i8> From<(T, i8)> for Q { } /// Lossless conversion into a dynamically scaled integer +/// +/// ``` +/// # use dsp_fixedpoint::Q8; +/// let q: (i8, i8) = Q8::<8>::new(9).into(); +/// assert_eq!(q, (9, 8)); +/// ``` impl From> for (T, i8) { fn from(value: Q) -> Self { (value.inner, F) } } +/// Lossy conversion to and from float +/// /// ``` /// # use dsp_fixedpoint::Q8; -/// # use num_traits::AsPrimitive; /// assert_eq!(8 * Q8::<4>::from_f32(0.25), 2); /// assert_eq!(8 * Q8::<4>::from_f64(0.25), 2); /// assert_eq!(Q8::<4>::new(4).as_f32(), 0.25); @@ -269,7 +293,7 @@ macro_rules! impl_as_float { #[inline] fn as_(self) -> Q { Q::new( - (self * const { 1.0 / Q::::DELTA } as $ty) + (self * const { 1.0 / Q::::DELTA as $ty }) .round() .as_(), ) @@ -562,13 +586,6 @@ impl iter::Sum for Q { } } -impl iter::Product for Q { - #[inline] - fn product>(iter: I) -> Self { - Self::new(iter.map(|i| i.inner).product()) - } -} - /// ``` /// # use dsp_fixedpoint::Q8; /// let q = Q8::<4>::new(7); @@ -635,7 +652,7 @@ macro_rules! impl_q { } } - #[doc = concat!("Fixed point [`", stringify!($t), "`]")] + #[doc = concat!("Fixed point [`", stringify!($t), "`] with [`", stringify!($a), "`] accumulator")] pub type $alias = Q<$t, $a, F>; impl ConstOne for Q<$t, $a, F> { From 1e2dd611662da86617ff87961eb4c9208b68a253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 13 Jan 2026 16:26:10 +0100 Subject: [PATCH 3/4] manifest: fixedpoint/process versions --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ea2cb64..c307dae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,8 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/quartiq/idsp.git" [workspace.dependencies] -dsp-process = { path = "dsp-process" } -dsp-fixedpoint = { path = "dsp-fixedpoint" } +dsp-process = { version = "0.1.0", path = "dsp-process" } +dsp-fixedpoint = { version = "0.1.0", path = "dsp-fixedpoint" } num-traits = { version = "0.2.14", features = [ "libm", ], default-features = false } From eeaedea4cdcda0ee56118a6f29e09835cf865bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 13 Jan 2026 16:26:31 +0100 Subject: [PATCH 4/4] chore: Release --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c307dae..9f1de5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ missing_docs = "warn" [package] name = "idsp" -version = "0.19.0" +version = "0.20.0" edition.workspace = true authors.workspace = true license.workspace = true