Added Latex support for doc
All threads resolved!
All threads resolved!
Added a html header files, an added metadata line in Cargo.toml and some formatting changes in the doc to have Latex formulas in docs.rs. It works locally, should work online
Merge request reports
Activity
Filter activity
- Resolved by STEVAN Antoine
- Resolved by STEVAN Antoine
added documentation improvement labels
@c.heme please apply the following patches to your
main
branch and then push them herepatches and new files to add
- formatting
diff --git a/src/fec.rs b/src/fec.rs index 715ef2f..eb55e9f 100644 --- a/src/fec.rs +++ b/src/fec.rs @@ -32,13 +32,12 @@ pub struct Shard<F: PrimeField> { impl<F: PrimeField> Shard<F> { fn dual_combination(this: &Vec<F>, alpha: F, other: &Vec<F>, beta: F) -> Vec<F> { - this - .iter() + this.iter() .zip(other.iter()) .map(|(s, o)| s.mul(alpha) + o.mul(beta)) .collect() } - + /// compute the linear combination between two [`Shard`]s /// /// if we denote the [`Shard`] itself and the other [`Shard`] by $s$ and $o$ respectively, the @@ -53,7 +52,12 @@ impl<F: PrimeField> Shard<F> { Shard { k: self.k, - linear_combination: Self::dual_combination(&self.linear_combination, alpha, &other.linear_combination, beta), + linear_combination: Self::dual_combination( + &self.linear_combination, + alpha, + &other.linear_combination, + beta, + ), hash: self.hash.clone(), data: Self::dual_combination(&self.data, alpha, &other.data, beta), size: self.size, @@ -102,7 +106,10 @@ pub fn recode_with_coeffs<F: PrimeField>(shards: &[Shard<F>], coeffs: &[F]) -> O /// > **Note** /// > /// > this is a wrapper around [`recode_with_coeffs`]. -pub fn recode_random<F: PrimeField>(shards: &[Shard<F>], rng: &mut impl RngCore) -> Result<Option<Shard<F>>, KomodoError> { +pub fn recode_random<F: PrimeField>( + shards: &[Shard<F>], + rng: &mut impl RngCore, +) -> Result<Option<Shard<F>>, KomodoError> { for (i, (s1, s2)) in shards.iter().zip(shards.iter().skip(1)).enumerate() { if s1.k != s2.k { return Err(KomodoError::IncompatibleShards(format!( @@ -139,7 +146,10 @@ pub fn recode_random<F: PrimeField>(shards: &[Shard<F>], rng: &mut impl RngCore) /// matrix. (see [`algebra::split_data_into_field_elements`]) /// /// This is the inverse of [`decode`]. -pub fn encode<F: PrimeField>(data: &[u8], encoding_mat: &Matrix<F>) -> Result<Vec<Shard<F>>, KomodoError> { +pub fn encode<F: PrimeField>( + data: &[u8], + encoding_mat: &Matrix<F>, +) -> Result<Vec<Shard<F>>, KomodoError> { let hash = Sha256::hash(data).to_vec(); let k = encoding_mat.height;
- reverting the "dual combination": if we do that, let's do it in another MR
diff --git a/src/fec.rs b/src/fec.rs index eb55e9f..9514936 100644 --- a/src/fec.rs +++ b/src/fec.rs @@ -31,13 +31,6 @@ pub struct Shard<F: PrimeField> { } impl<F: PrimeField> Shard<F> { - fn dual_combination(this: &Vec<F>, alpha: F, other: &Vec<F>, beta: F) -> Vec<F> { - this.iter() - .zip(other.iter()) - .map(|(s, o)| s.mul(alpha) + o.mul(beta)) - .collect() - } - /// compute the linear combination between two [`Shard`]s /// /// if we denote the [`Shard`] itself and the other [`Shard`] by $s$ and $o$ respectively, the @@ -52,14 +45,19 @@ impl<F: PrimeField> Shard<F> { Shard { k: self.k, - linear_combination: Self::dual_combination( - &self.linear_combination, - alpha, - &other.linear_combination, - beta, - ), + linear_combination: self + .linear_combination + .iter() + .zip(other.linear_combination.iter()) + .map(|(l, r)| l.mul(alpha) + r.mul(beta)) + .collect(), hash: self.hash.clone(), - data: Self::dual_combination(&self.data, alpha, &other.data, beta), + data: self + .data + .iter() + .zip(other.data.iter()) + .map(|(es, eo)| es.mul(alpha) + eo.mul(beta)) + .collect(), size: self.size, } }
- remove hardcoded
RUSTDOCFLAGS
from theMakefile
diff --git a/Makefile b/Makefile index bdc9111..4efa870 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ show: .PHONY: doc doc: - RUSTDOCFLAGS="--html-in-header katex.html" cargo doc --no-deps --open + cargo doc --document-private-items --no-deps --open .PHONY: build-examples build-examples:
- add a config file for Cargo in
./.cargo/config.toml
[build] rustdocflags = ["--html-in-header", "katex.html"]
result
the final diff should be
diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..35cffad --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustdocflags = ["--html-in-header", "katex.html"] diff --git a/Cargo.toml b/Cargo.toml index fe2526e..b2797fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,6 +50,7 @@ fs = [] [package.metadata.docs.rs] features = ["kzg", "aplonk"] +rustdoc-args = [ "--html-in-header", "katex.html" ] [[example]] name = "kzg" diff --git a/katex.html b/katex.html new file mode 100644 index 0000000..32ac35a --- /dev/null +++ b/katex.html @@ -0,0 +1,15 @@ +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous"> +<script src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script> +<script src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"></script> +<script> + document.addEventListener("DOMContentLoaded", function() { + renderMathInElement(document.body, { + delimiters: [ + {left: "$$", right: "$$", display: true}, + {left: "\\(", right: "\\)", display: false}, + {left: "$", right: "$", display: false}, + {left: "\\[", right: "\\]", display: true} + ] + }); + }); +</script> diff --git a/src/fec.rs b/src/fec.rs index 2329a21..9514936 100644 --- a/src/fec.rs +++ b/src/fec.rs @@ -17,7 +17,7 @@ pub struct Shard<F: PrimeField> { /// /// this effectively allows support for _recoding_. /// - /// If we denote the $k$ source shards by $(s_i)_{0 \le i \lt k}$, the linear combination by $k$ + /// If we denote the $k$ source shards by $(s\_i)\_\{0 \le i \lt k\}$, the linear combination by $k$ /// coefficients $(\alpha_i)_{0 \le i \lt k}$ and $s$ the shard itself, then /// /// $$ s = \sum\limits_{i = 0}^{k - 1} \alpha_i s_i$$ @@ -72,8 +72,8 @@ impl<F: PrimeField> Shard<F> { /// > returns [`None`] if the number of shards is not the same as the number of /// > coefficients or if no shards are provided. /// -/// if the shards are the $(s_i)_{1 \le i \le n}$ and the coefficients the -/// $(\alpha_i)_{0 \le i \le n}$, then the output will be +/// if the shards are the $(s \_i)\_\{1 \le i \le n\}$ and the coefficients the +/// $(\alpha\_i)\_\{0 \le i \le n\}$, then the output will be /// /// $$ \sum\limits_{i = 1}^{n} \alpha_i s_i$$ pub fn recode_with_coeffs<F: PrimeField>(shards: &[Shard<F>], coeffs: &[F]) -> Option<Shard<F>> {
Edited by STEVAN Antoinementioned in issue #18
enabled an automatic merge when all merge checks for a0fa2f6e pass
mentioned in commit b5381fda
Please register or sign in to reply