From a96c8274273d2f02fe154bcd80db2e358ca0ae8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Sat, 6 Jan 2024 21:10:38 +0100 Subject: [PATCH] update docs --- src/num/int/wrapper/impl_base.rs | 4 +- src/num/int/wrapper/impl_count.rs | 4 +- src/num/int/wrapper/impl_div.rs | 4 +- src/num/int/wrapper/impl_factors.rs | 4 +- src/num/int/wrapper/impl_gcd_lcm.rs | 4 +- src/num/int/wrapper/impl_sqrt.rs | 68 ++++++++++++++--------------- src/num/int/wrapper/mod.rs | 28 ++++++------ 7 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/num/int/wrapper/impl_base.rs b/src/num/int/wrapper/impl_base.rs index 77cc5906..4a1801f6 100644 --- a/src/num/int/wrapper/impl_base.rs +++ b/src/num/int/wrapper/impl_base.rs @@ -24,7 +24,7 @@ macro_rules! impl_base { (@signed $t:ty : $dl:literal) => { paste! { /* signed digits */ - #[doc = "# Numeric base related methods for `" $t "`\n\n"] + #[doc = "# Integer base related methods for `" $t "`\n\n"] #[doc = "- [digits](#method.digits" $dl ")"] #[doc = "- [digits_sign](#method.digits_sign" $dl ")"] #[doc = "- [digits_base](#method.digits_base" $dl ")"] @@ -161,7 +161,7 @@ macro_rules! impl_base { // implements unsigned ops (@unsigned $t:ty : $dl:literal) => { paste! { - #[doc = "# Numeric base related methods for `" $t "`\n\n"] + #[doc = "# Integer base related methods for `" $t "`\n\n"] #[doc = "- [digits](#method.digits" $dl ")"] #[doc = "- [digits_sign](#method.digits_sign" $dl ")"] #[doc = "- [digits_base](#method.digits_base" $dl ")"] diff --git a/src/num/int/wrapper/impl_count.rs b/src/num/int/wrapper/impl_count.rs index 4d6077d3..862d559e 100644 --- a/src/num/int/wrapper/impl_count.rs +++ b/src/num/int/wrapper/impl_count.rs @@ -23,7 +23,7 @@ macro_rules! impl_count { // implements signed ops (@signed $t:ty : $dl:literal) => { paste! { - #[doc = "# Numeric counting related methods for `" $t "`\n\n"] + #[doc = "# Integer counting related methods for `" $t "`\n\n"] #[doc = "- [factorial](#method.factorial" $dl ")"] #[doc = "- [combine](#method.combine" $dl ")"] #[doc = "- [combine_rep](#method.combine_rep" $dl ")"] @@ -231,7 +231,7 @@ macro_rules! impl_count { // implements unsigned ops (@unsigned $t:ty : $dl:literal) => { paste! { - #[doc = "# Numeric counting related methods for `" $t "`\n\n"] + #[doc = "# Integer counting related methods for `" $t "`\n\n"] #[doc = "- [factorial](#method.factorial" $dl ")"] #[doc = "- [combine](#method.combine" $dl ")"] #[doc = "- [combine_rep](#method.combine_rep" $dl ")"] diff --git a/src/num/int/wrapper/impl_div.rs b/src/num/int/wrapper/impl_div.rs index 2fb11e51..8605ee65 100644 --- a/src/num/int/wrapper/impl_div.rs +++ b/src/num/int/wrapper/impl_div.rs @@ -25,7 +25,7 @@ macro_rules! impl_div { (@signed $t:ty : $dl:literal) => { paste! { /* signed division */ - #[doc = "# Numeric division related methods for `" $t "`\n\n"] + #[doc = "# Integer division related methods for `" $t "`\n\n"] #[doc = "- [div_rem](#method.div_rem" $dl ")"] #[doc = "- [div_ceil](#method.div_ceil" $dl ")"] #[doc = "- [div_floor](#method.div_floor" $dl ")"] @@ -220,7 +220,7 @@ macro_rules! impl_div { // implements unsigned ops (@unsigned $t:ty : $dl:literal) => { paste! { - #[doc = "# Numeric division related methods for `" $t "`\n\n"] + #[doc = "# Integer division related methods for `" $t "`\n\n"] #[doc = "- [div_rem](#method.div_rem" $dl ")"] #[doc = "- [div_ceil](#method.div_ceil" $dl ")"] #[doc = "- [div_floor](#method.div_floor" $dl ")"] diff --git a/src/num/int/wrapper/impl_factors.rs b/src/num/int/wrapper/impl_factors.rs index e9f172a1..7c4ed89f 100644 --- a/src/num/int/wrapper/impl_factors.rs +++ b/src/num/int/wrapper/impl_factors.rs @@ -31,7 +31,7 @@ macro_rules! impl_factors { // implements signed ops (@signed $t:ty : $dl:literal) => { paste! { - #[doc = "# Numeric factors-related methods for `" $t "`\n\n"] + #[doc = "# Integer factors related methods for `" $t "`\n\n"] /// - Allocating: #[doc = " - [factors](#method.factors" $dl ")"] #[doc = " - [factors_proper](#method.factors_proper" $dl ")"] @@ -356,7 +356,7 @@ macro_rules! impl_factors { // implements unsigned ops (@unsigned $t:ty : $dl:literal) => { paste! { - #[doc = "# Numeric factors-related methods for `" $t "`\n\n"] + #[doc = "# Integer factors related methods for `" $t "`\n\n"] /// - Allocating: #[doc = " - [factors](#method.factors" $dl ")"] #[doc = " - [factors_proper](#method.factors_proper" $dl ")"] diff --git a/src/num/int/wrapper/impl_gcd_lcm.rs b/src/num/int/wrapper/impl_gcd_lcm.rs index a4784046..aa2d8edc 100644 --- a/src/num/int/wrapper/impl_gcd_lcm.rs +++ b/src/num/int/wrapper/impl_gcd_lcm.rs @@ -30,7 +30,7 @@ macro_rules! impl_gcd_lcm { (@signed $t:ty : $up:ty : $dl:literal) => { paste! { /* signed count_digits */ - #[doc = "# Numeric GCD and " + #[doc = "# Integer GCD and " "LCM related methods for `" $t "`\n\n"] #[doc = "- [gcd](#method.gcd" $dl ")"] #[doc = "- [gcd_ext](#method.gcd_ext" $dl ")"] @@ -198,7 +198,7 @@ macro_rules! impl_gcd_lcm { // implements unsigned ops (@unsigned $t:ty : $up:ty : $dl:literal) => { paste! { - #[doc = "# Numeric GCD and " + #[doc = "# Integer GCD and " "LCM related methods for `" $t "`\n\n"] #[doc = "- [gcd](#method.gcd" $dl ")"] #[doc = "- [lcm](#method.lcm" $dl ")"] diff --git a/src/num/int/wrapper/impl_sqrt.rs b/src/num/int/wrapper/impl_sqrt.rs index 20afafaa..f8aca33c 100644 --- a/src/num/int/wrapper/impl_sqrt.rs +++ b/src/num/int/wrapper/impl_sqrt.rs @@ -18,7 +18,7 @@ macro_rules! impl_sqrt { (@signed $t:ty : $dl:literal) => { paste! { /* signed sqrt */ - #[doc = "# Numeric square root related methods for `" $t "`\n\n"] + #[doc = "# Integer square root related methods for `" $t "`\n\n"] #[doc = "- [is_square](#method.is_square" $dl ")"] #[doc = "- [sqrt_floor](#method.sqrt_floor" $dl ")"] #[doc = "- [sqrt_ceil](#method.sqrt_ceil" $dl ")"] @@ -31,9 +31,9 @@ macro_rules! impl_sqrt { /// Returns `false` otherwise, which includes all negative values. /// # Algorithm /// $$ \large - /// \text{is\textunderscore square}(n) = \begin{cases} - /// \text{true} & \text{if } \left(\lfloor \sqrt{n} \rfloor\right)^2 = n \cr - /// \text{false} & \text{if } \left(\lfloor \sqrt{n} \rfloor\right)^2 \neq n + /// \text{is\textunderscore square}(a) = \begin{cases} + /// \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr + /// \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a /// \end{cases} /// $$ /// # Examples @@ -56,27 +56,27 @@ macro_rules! impl_sqrt { /// /// Returns `None` if `a` is negative. /// # Algorithm - /// $$ \large \left\lfloor \sqrt{x} \right\rfloor = n_{k} $$ + /// $$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$ /// /// Where $n_{k}$ is the result of a sequence of estimates that - /// starts with an initial $n_{0} = x/2$ which is updated using + /// starts with an initial $n_{0} = a/2$ which is updated using /// [*Heron's method*]( /// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Heron's_method): /// /// $$ \large - /// n_{i+1} = n_{i} - ( n_{i}^{2} - x) / 2n_{i}, + /// n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, /// \quad \small\text{for} \quad i = 0, 1, \ldots, k, /// $$ /// /// Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next - /// estimate, $x$ is self, and $k$ is the number of iterations + /// estimate, $a$ is self, and $k$ is the number of iterations /// needed to converge to a solution, on the order of the number of /// bits of self, about $O(\log_2 b)$, which for e.g. 128 bits would /// be $ ±7 $ iterations. /// /// Hence, the function continues updating the estimate until /// reaching $n_{k}$, which provides the largest integer less than - /// or equal to the square root of `x`. + /// or equal to the square root of `a`. /// # Examples /// ``` /// # use devela::num::Int; @@ -110,10 +110,10 @@ macro_rules! impl_sqrt { /// # Algorithm /// $$ \large /// \begin{align} - /// \notag \left\lceil \sqrt{x} \thinspace\right\rceil = \begin{cases} - /// n & \text{if } n^2 = x \cr - /// n+1 & \text{if } n^2 < x \end{cases} \cr - /// \notag \normalsize\text{where } n = \lfloor \sqrt{x} \rfloor & + /// \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} + /// n & \text{if } n^2 = a \cr + /// n+1 & \text{if } n^2 < a \end{cases} \cr + /// \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & /// \end{align} /// $$ /// # Examples @@ -142,10 +142,10 @@ macro_rules! impl_sqrt { /// # Algorithm /// $$ \large /// \begin{align} - /// \notag \left\lfloor\sqrt{x} \thinspace\right\rceil = \begin{cases} - /// n & \text{if } x - n^2 < (n+1)^2 - x \cr - /// n+1 & \text{if } x - n^2 \geq (n+1)^2 - x \end{cases} \cr - /// \notag \normalsize\text{where } n = \lfloor \sqrt{x} \rfloor & + /// \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} + /// n & \text{if } a - n^2 < (n+1)^2 - a \cr + /// n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr + /// \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & /// \end{align} /// $$ /// # Examples @@ -181,7 +181,7 @@ macro_rules! impl_sqrt { // implements unsigned ops (@unsigned $t:ty : $dl:literal) => { paste! { - #[doc = "# Numeric square root related methods for `" $t "`\n\n"] + #[doc = "# Integer square root related methods for `" $t "`\n\n"] #[doc = "- [is_square](#method.is_square" $dl ")"] #[doc = "- [sqrt_floor](#method.sqrt_floor" $dl ")"] #[doc = "- [sqrt_ceil](#method.sqrt_ceil" $dl ")"] @@ -195,9 +195,9 @@ macro_rules! impl_sqrt { /// /// # Algorithm /// $$ \large - /// \text{is\textunderscore square}(n) = \begin{cases} - /// \text{true} & \text{if } \left(\lfloor \sqrt{n} \rfloor\right)^2 = n \cr - /// \text{false} & \text{if } \left(\lfloor \sqrt{n} \rfloor\right)^2 \neq n + /// \text{is\textunderscore square}(a) = \begin{cases} + /// \text{true} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 = a \cr + /// \text{false} & \text{if } \left(\lfloor \sqrt{a} \rfloor\right)^2 \neq a /// \end{cases} /// $$ /// @@ -219,27 +219,27 @@ macro_rules! impl_sqrt { /// Returns the floored integer square root. /// # Algorithm - /// $$ \large \left\lfloor \sqrt{x} \right\rfloor = n_{k} $$ + /// $$ \large \left\lfloor \sqrt{a} \right\rfloor = n_{k} $$ /// /// Where $n_{k}$ is the result of a sequence of estimates that - /// starts with an initial $n_{0} = x/2$ which is updated using + /// starts with an initial $n_{0} = a/2$ which is updated using /// [*Heron's method*]( /// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Heron's_method): /// /// $$ \large - /// n_{i+1} = n_{i} - ( n_{i}^{2} - x) / 2n_{i}, + /// n_{i+1} = n_{i} - ( n_{i}^{2} - a) / 2n_{i}, /// \quad \small\text{for} \quad i = 0, 1, \ldots, k, /// $$ /// /// Where $n_{i}$ is the current estimate, $n_{i+1}$ is the next - /// estimate, $x$ is `a`, and $k$ is the number of iterations + /// estimate, $a$ is `a`, and $k$ is the number of iterations /// needed to converge to a solution, on the order of the number of /// bits of `a`, about $O(\log_2 b)$, which for e.g. 128 bits would /// be $ ±7 $ iterations. /// /// Hence, the function continues updating the estimate until /// reaching $n_{k}$, which provides the largest integer less than - /// or equal to the square root of `x`. + /// or equal to the square root of `a`. /// /// # Examples /// ``` @@ -269,10 +269,10 @@ macro_rules! impl_sqrt { /// # Algorithm /// $$ \large /// \begin{align} - /// \notag \left\lceil \sqrt{x} \thinspace\right\rceil = \begin{cases} - /// n & \text{if } n^2 = x \cr - /// n+1 & \text{if } n^2 < x \end{cases} \cr - /// \notag \normalsize\text{where } n = \lfloor \sqrt{x} \rfloor & + /// \notag \left\lceil \sqrt{a} \thinspace\right\rceil = \begin{cases} + /// n & \text{if } n^2 = a \cr + /// n+1 & \text{if } n^2 < a \end{cases} \cr + /// \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & /// \end{align} /// $$ /// # Examples @@ -294,10 +294,10 @@ macro_rules! impl_sqrt { /// # Algorithm /// $$ \large /// \begin{align} - /// \notag \left\lfloor\sqrt{x} \thinspace\right\rceil = \begin{cases} - /// n & \text{if } x - n^2 < (n+1)^2 - x \cr - /// n+1 & \text{if } x - n^2 \geq (n+1)^2 - x \end{cases} \cr - /// \notag \normalsize\text{where } n = \lfloor \sqrt{x} \rfloor & + /// \notag \left\lfloor\sqrt{a} \thinspace\right\rceil = \begin{cases} + /// n & \text{if } a - n^2 < (n+1)^2 - a \cr + /// n+1 & \text{if } a - n^2 \geq (n+1)^2 - a \end{cases} \cr + /// \notag \normalsize\text{where } n = \lfloor \sqrt{a} \rfloor & /// \end{align} /// $$ /// # Examples diff --git a/src/num/int/wrapper/mod.rs b/src/num/int/wrapper/mod.rs index 1dd7fb74..03c8b4b7 100644 --- a/src/num/int/wrapper/mod.rs +++ b/src/num/int/wrapper/mod.rs @@ -21,23 +21,23 @@ mod impl_sqrt; /// /// The documentation is the same for all bit sizes. For example, for 32 bits: /// - Methods for `i32` related to: -/// [base][Self#numeric-base-related-methods-for-i32], -/// [counting][Self#numeric-counting-related-methods-for-i32], -/// [division][Self#numeric-division-related-methods-for-i32], -/// [factors][Self#numeric-factors-related-methods-for-i32], -/// [gcd and lcm][Self#numeric-gcd-and-lcm-related-methods-for-i32]. +/// [base][Self#integer-base-related-methods-for-i32], +/// [counting][Self#integer-counting-related-methods-for-i32], +/// [division][Self#integer-division-related-methods-for-i32], +/// [factors][Self#integer-factors-related-methods-for-i32], +/// [gcd and lcm][Self#integer-gcd-and-lcm-related-methods-for-i32], +/// [square root][Self#integer-square-root-related-methods-for-i32]. /// - Methods for `u32` related to: -/// [base][Self#numeric-base-related-methods-for-u32], -/// [counting][Self#numeric-counting-related-methods-for-u32], -/// [division][Self#numeric-division-related-methods-for-u32], -/// [factors][Self#numeric-factors-related-methods-for-u32], -/// [gcd and lcm][Self#numeric-gcd-and-lcm-related-methods-for-u32]. +/// [base][Self#integer-base-related-methods-for-u32], +/// [counting][Self#integer-counting-related-methods-for-u32], +/// [division][Self#integer-division-related-methods-for-u32], +/// [factors][Self#integer-factors-related-methods-for-u32], +/// [gcd and lcm][Self#integer-gcd-and-lcm-related-methods-for-u32], +/// [square root][Self#integer-square-root-related-methods-for-u32]. /// /// See also the related traits: -/// [`NumOpsBase`][crate::num::NumOpsBase], -/// [`NumOpsCounting`][crate::num::NumOpsCounting], -/// [`NumOpsFactors`][crate::num::NumOpsFactors], -/// [`NumInt`][super::NumInt]. +/// [`NumInt`][super::NumInt], +/// [`NumOpsFactors`][crate::num::NumOpsFactors]. #[repr(transparent)] pub struct Int(pub T);