Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarto GHA Workflow Runner committed Aug 26, 2024
1 parent 41c386a commit 89e1b95
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
94d3304a
29d5713d
2 changes: 1 addition & 1 deletion pages/gauss/solve.html
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ <h1 class="title d-none d-lg-block"><code>bit::solve</code> — Solver</h1>
<td class="icon"> <i class="fa icon-note" title="Note"></i></td>
<td class="content">

We wan to get <em>one</em> solution for a system of equations with very little fuss.<br>
We want to get <em>one</em> solution for a system of equations with very little fuss.<br>
Over <span class="math inline">\(\mathbb{F}_2\)</span>, any free variable can take on one of the values 0 and 1. Hence, if the system is consistent and has <span class="math inline">\(f\)</span> free variables, it will have <span class="math inline">\(2^f\)</span> possible solutions. So, a consistent system will have a unique solution only if <span class="math inline">\(A\)</span> has full-rank. The <a href="../../pages/gauss/functor.html"><code>gauss::operator(i)</code></a> method iterates through potentially non-unique solutions if that is required.
</td></tr></tbody></table></div>
<p><span class="bt">Example</span></p>
Expand Down
2 changes: 1 addition & 1 deletion pages/notes/gf2.html
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ <h2 class="anchored" data-anchor-id="some-things-are-simpler">Some things are si
<section id="gaussian-elimination-in-f2" class="level2">
<h2 class="anchored" data-anchor-id="gaussian-elimination-in-f2">Gaussian Elimination in <span class="math inline">\(\mathbb{F}_2\)</span></h2>
<p>Suppose that <span class="math inline">\(A\)</span> is an <span class="math inline">\(n \times n\)</span> matrix over <span class="math inline">\(\mathbb{F}_2\)</span> and <span class="math inline">\(b\)</span> is a compatibly sized bit-vector where we are interested in finding an <span class="math inline">\(x\)</span> satisfying <span class="math inline">\(A \cdot x = b\)</span>. Then the pseudocode for Gaussian elimination looks like:</p>
<div id="alg-ge" class="pseudocode-container quarto-float" data-line-number="true" data-line-number-punc=":" data-indent-size="1.2em" data-caption-prefix="Algorithm" data-no-end="false" data-comment-delimiter="//" data-pseudocode-number="1">
<div id="alg-ge" class="pseudocode-container quarto-float" data-line-number="true" data-no-end="false" data-caption-prefix="Algorithm" data-line-number-punc=":" data-indent-size="1.2em" data-pseudocode-number="1" data-comment-delimiter="//">
<div class="pseudocode">
\begin{algorithm} \caption{Gaussian Elimination in $F_2$} \begin{algorithmic} \Procedure{Solve}{$A, b, n$} \For {$j = 0$ \To $n - 1$} \State $s = j$ \While {$A(s,j) = 0$} \State $s = s + 1$ \EndWhile \If {$s &gt; n$} \Continue \EndIf \If {$ s \ne j$} \State swap rows $s$ and $j$ in the matrix $A$ \State swap elements $s$ and $j$ in the vector $b$ \EndIf \For {$i = j+1$ \To $n$} \If {$A(i,j) == 1$} \State replace row $i$ in $A$ with the sum of rows $i$ and $j$ \State replace element $i$ in $b$ with the sum of elements $i$ and $j$ \EndIf \EndFor \EndFor \EndProcedure \end{algorithmic} \end{algorithm}
</div>
Expand Down
6 changes: 3 additions & 3 deletions pages/notes/reduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ <h2 class="anchored" data-anchor-id="a-multiply-square-technique-for-xn-mod-px">
</table>
</div>
<p>With those in place we can proceed as follows (this is just a sketch):</p>
<div id="multiply_and_square" class="pseudocode-container quarto-float" data-caption-prefix="Algorithm" data-pseudocode-number="1">
<div id="multiply_and_square" class="pseudocode-container quarto-float" data-pseudocode-number="1" data-caption-prefix="Algorithm">
<div class="pseudocode">
\begin{algorithm} \caption{Modular Reduction of $x^N$} \begin{algorithmic} \Require $\mathbf{p}$, a bit-vector of size $n$, where $P(x) = x^n + p(x)$ and $\mathbf{p} \sim p(x)$. Unchanged on output. \Require $\mathbf{r}$, a destination bit-vector of size $n$. On output $\mathbf{r} \sim r(x) = x^N \mid P(x)$. \Procedure{reduce}{$N$, $\mathbf{p}$} \State $\mathbf{r} \gets \mathbf{0}$ \State $r_1 = 1$ \While{$N &gt; 0$} \If{$N \text{ mod } 2 = 1$} \State \Call{MultiplyStep}{$\mathbf{r}$} \EndIf \State \Call{SquareStep}{$\mathbf{r}$} \State $N \gets N \gg 1$ \EndWhile \EndProcedure \end{algorithmic} \end{algorithm}
</div>
Expand All @@ -694,7 +694,7 @@ <h3 class="anchored" data-anchor-id="the-multiply-step">The Multiply Step</h3>
\]</span> then the following procedure performs the step <span class="math display">\[
q(x) \gets x q(x) \mod P(x),
\]</span> where <span class="math inline">\(q(x)\)</span> is represented by the bit-vector of its <span class="math inline">\(n\)</span> coefficients <span class="math inline">\(\bold{q} = [q_0, q_1, \ldots, q_{n-1}]\)</span>.</p>
<div id="MultiplyStep" class="pseudocode-container quarto-float" data-caption-prefix="Algorithm" data-pseudocode-number="2">
<div id="MultiplyStep" class="pseudocode-container quarto-float" data-pseudocode-number="2" data-caption-prefix="Algorithm">
<div class="pseudocode">
\begin{algorithm} \caption{The step: $q(x) \gets x q(x) \mid P(x)$.} \begin{algorithmic} \Require $\mathbf{p} \sim p(x)$ is a known bit-vector of size $n$, where $P(x) = x^n + p(x)$. \Require $\mathbf{q}$ is a bit-vector of size $n &gt; 0$. \Procedure{MultiplyStep}{$\mathbf{q}$} \State $tmp \gets q_{n-1}$ \State $\mathbf{q} \gets \mathbf{q} \gg 1$ \If {$tmp$} \State $\mathbf{q} \gets \mathbf{q} \wedge \mathbf{p}$ \EndIf \EndProcedure \end{algorithmic} \end{algorithm}
</div>
Expand Down Expand Up @@ -732,7 +732,7 @@ <h3 class="anchored" data-anchor-id="the-square-step">The Square Step</h3>
\bold{x}^0 = \bold{p}.
\]</span> With that starting point, we can easily fill in bit vectors <span class="math inline">\(\bold{x}^i\)</span> for <span class="math inline">\(i = 1, \ldots, n-1\)</span> by using <a href="#MultiplyStep" class="quarto-xref">Algorithm 2</a>.</p>
<p>The squaring step looks like the following:</p>
<div id="SquareStep" class="pseudocode-container quarto-float" data-caption-prefix="Algorithm" data-pseudocode-number="3">
<div id="SquareStep" class="pseudocode-container quarto-float" data-pseudocode-number="3" data-caption-prefix="Algorithm">
<div class="pseudocode">
\begin{algorithm} \caption{The step: $q(x) \gets q(x)^2 \mid P(x)$.} \begin{algorithmic} \Require $\mathbf{p} \sim p(x)$ is a known bit-vector of size $n$, where $P(x) = x^n + p(x)$. \Require $\mathbf{x}^i$ are known bit-vectors, where $\mathbf{x}^i \sim x^{n+i} \mid P(x)$. \Require $\mathbf{s}, \mathbf{l}$ and $\mathbf{h}$ are available workspace bit-vectors. \Require $\mathbf{q}$ is a bit-vector of size $n &gt; 0$. \Procedure{SquareStep}{$\mathbf{q}$} \State // \textit{Riffle $\mathbf{q}$ into $\mathbf{s}$.} \State \Call{riffle}{$\mathbf{q}$, $\mathbf{s}$} \State // \textit{Fill $\mathbf{l}$ with a copy of the first $n$ elements from $\mathbf{s}$ and $\mathbf{h}$ with the rest.} \State \Call{split}{$\mathbf{s}$, $n$, $\mathbf{l}$, $\mathbf{h}$} \State $\mathbf{q} \gets \mathbf{l}$ \For {$i \gets 0, n-1$} \If{$h_i$} \State $\mathbf{q} \gets \mathbf{q} \wedge \mathbf{x}^i$ \EndIf \EndFor \EndProcedure \end{algorithmic} \end{algorithm}
</div>
Expand Down
2 changes: 1 addition & 1 deletion search.json
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@
"href": "pages/gauss/solve.html",
"title": "bit::solve — Solver",
"section": "",
"text": "We supply a standalone non-member function that attempts to solve the system of linear equations \\(A \\cdot x = b\\) over \\(\\mathbb{F}_2\\).\nstd::optional&lt;bit::vector&gt;\n1bit::solve(const bit::matrix &A, const bit::vector &b)\n\n1\n\nA must be square, and b must be the same size as the number of rows in A.\n\n\nThe std::optional return value can be safely dereferenced as a bit-vector if everything goes well. That bit-vector will be a solution \\(x\\) to the system \\(A \\cdot x = b\\). The solution may or may not be unique.\nIf there is a problem, the return value will be a std::nullopt. This happens if the system of equations has no solution. It will also be the case if A is not square or if the size of b is not the same as the number of rows in A.\n\n \n \n \n \nWe wan to get one solution for a system of equations with very little fuss.\nOver \\(\\mathbb{F}_2\\), any free variable can take on one of the values 0 and 1. Hence, if the system is consistent and has \\(f\\) free variables, it will have \\(2^f\\) possible solutions. So, a consistent system will have a unique solution only if \\(A\\) has full-rank. The gauss::operator(i) method iterates through potentially non-unique solutions if that is required.\n\nExample\n#include &lt;bit/bit.h&gt;\nint main()\n{\n std::size_t m = 12;\n\n auto A = bit::matrix&lt;&gt;::random(m);\n auto b = bit::vector&lt;&gt;::random(m);\n auto x = bit::solve(A, b);\n\n if (x) {\n // Check that x is indeed a solution by computing A.x and comparing that to b\n auto Ax = bit::dot(A, *x);\n std::cout &lt;&lt; \"bit::matrix A, solution vector x, product A.x, and right hand side b:\\n\";\n std::cout &lt;&lt; \" A x A.x b\\n\";\n bit::print(A, *x, Ax, b);\n std::cout &lt;&lt; \"So A.x == b? \" &lt;&lt; (Ax == b ? \"YES\" : \"NO\") &lt;&lt; '\\n';\n }\n else {\n std::cout &lt;&lt; \"System A.x = b has NO solutions for A and b as follows:\\n\";\n std::cout &lt;&lt; \" A x\\n\";\n bit::print(A, b);\n }\n}\nOutput for a consistent system (varies on each run)\nbit::matrix A, solution vector x, product A.x, and right hand side b:\n A x A.x b\n001110110111 0 0 0\n100011110000 0 1 1\n110010110000 0 0 0\n011101011001 0 0 0\n011001111001 1 0 0\n011010011110 1 0 0\n110110110101 0 0 0\n100000010101 1 1 1\n010101000101 1 1 1\n110000011111 1 0 0\n001010000011 0 0 0\n110111110111 1 1 1\nSo A.x == b? YES\nOutput for an inconsistent system (varies on each run)\nSystem A.x = b has NO solutions for A and b as follows:\n A x\n010100100011 1\n000010010000 1\n000111111011 1\n000111111011 1\n001101110011 1\n111001110111 1\n010001010111 1\n101011000001 0\n110101110111 0\n111000010000 0\n011011010100 1\n011001110010 0\n\nSee Also\ngauss::operator()\ngauss::operator(i)\n\n\n\n\n Back to top"
"text": "We supply a standalone non-member function that attempts to solve the system of linear equations \\(A \\cdot x = b\\) over \\(\\mathbb{F}_2\\).\nstd::optional&lt;bit::vector&gt;\n1bit::solve(const bit::matrix &A, const bit::vector &b)\n\n1\n\nA must be square, and b must be the same size as the number of rows in A.\n\n\nThe std::optional return value can be safely dereferenced as a bit-vector if everything goes well. That bit-vector will be a solution \\(x\\) to the system \\(A \\cdot x = b\\). The solution may or may not be unique.\nIf there is a problem, the return value will be a std::nullopt. This happens if the system of equations has no solution. It will also be the case if A is not square or if the size of b is not the same as the number of rows in A.\n\n \n \n \n \nWe want to get one solution for a system of equations with very little fuss.\nOver \\(\\mathbb{F}_2\\), any free variable can take on one of the values 0 and 1. Hence, if the system is consistent and has \\(f\\) free variables, it will have \\(2^f\\) possible solutions. So, a consistent system will have a unique solution only if \\(A\\) has full-rank. The gauss::operator(i) method iterates through potentially non-unique solutions if that is required.\n\nExample\n#include &lt;bit/bit.h&gt;\nint main()\n{\n std::size_t m = 12;\n\n auto A = bit::matrix&lt;&gt;::random(m);\n auto b = bit::vector&lt;&gt;::random(m);\n auto x = bit::solve(A, b);\n\n if (x) {\n // Check that x is indeed a solution by computing A.x and comparing that to b\n auto Ax = bit::dot(A, *x);\n std::cout &lt;&lt; \"bit::matrix A, solution vector x, product A.x, and right hand side b:\\n\";\n std::cout &lt;&lt; \" A x A.x b\\n\";\n bit::print(A, *x, Ax, b);\n std::cout &lt;&lt; \"So A.x == b? \" &lt;&lt; (Ax == b ? \"YES\" : \"NO\") &lt;&lt; '\\n';\n }\n else {\n std::cout &lt;&lt; \"System A.x = b has NO solutions for A and b as follows:\\n\";\n std::cout &lt;&lt; \" A x\\n\";\n bit::print(A, b);\n }\n}\nOutput for a consistent system (varies on each run)\nbit::matrix A, solution vector x, product A.x, and right hand side b:\n A x A.x b\n001110110111 0 0 0\n100011110000 0 1 1\n110010110000 0 0 0\n011101011001 0 0 0\n011001111001 1 0 0\n011010011110 1 0 0\n110110110101 0 0 0\n100000010101 1 1 1\n010101000101 1 1 1\n110000011111 1 0 0\n001010000011 0 0 0\n110111110111 1 1 1\nSo A.x == b? YES\nOutput for an inconsistent system (varies on each run)\nSystem A.x = b has NO solutions for A and b as follows:\n A x\n010100100011 1\n000010010000 1\n000111111011 1\n000111111011 1\n001101110011 1\n111001110111 1\n010001010111 1\n101011000001 0\n110101110111 0\n111000010000 0\n011011010100 1\n011001110010 0\n\nSee Also\ngauss::operator()\ngauss::operator(i)\n\n\n\n\n Back to top"
},
{
"objectID": "pages/gauss/constructors.html",
Expand Down
Loading

0 comments on commit 89e1b95

Please sign in to comment.