about summary refs log tree commit diff
path: root/doc/pages
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2023-03-30 15:31:05 +0900
committerNguyễn Gia Phong <mcsinyx@disroot.org>2023-03-30 15:31:05 +0900
commit26c8e08ede0bb12b98ed54ab45b1e39db595c271 (patch)
tree799a60603efdea04d1f59fc65cd6dfd78dbf1aa5 /doc/pages
parent1fec9d98a084106866d842d10f03dde9ff5472ee (diff)
downloadrub-26c8e08ede0bb12b98ed54ab45b1e39db595c271.tar.gz
Dogfood for documentation
Diffstat (limited to 'doc/pages')
-rw-r--r--doc/pages/demo/katex/index.xml115
-rw-r--r--doc/pages/demo/pygments/index.xml66
-rw-r--r--doc/pages/index.xml14
3 files changed, 195 insertions, 0 deletions
diff --git a/doc/pages/demo/katex/index.xml b/doc/pages/demo/katex/index.xml
new file mode 100644
index 0000000..e7ecb02
--- /dev/null
+++ b/doc/pages/demo/katex/index.xml
@@ -0,0 +1,115 @@
+<page xmlns="https://rub.parody">
+<title>KaTeX demo</title>
+<description>Math formulae to demo LaTeX to MathML rendering</description>
+<date>2020-04-15</date>
+<category>demo</category>
+<category>math</category>
+<markdown>
+Given two discrete-time systems <m>A</m> and <m>B</m> connected in cascade
+to form a new system <m>C = x \mapsto B(A(x))</m>, we examine
+the following properties:
+
+## Linearity
+
+If <m>A</m> and <m>B</m> are linear,
+i.e. for all signals <m>x_i</m> and scalars <m>a_i</m>,
+
+<math>
+\begin{aligned}
+  A\left(n \mapsto \sum_i a_i x_i[n]\right) = n \mapsto \sum_i a_i A(x_i)[n]\\
+  B\left(n \mapsto \sum_i a_i x_i[n]\right) = n \mapsto \sum_i a_i B(x_i)[n]
+\end{aligned}
+</math>
+
+then <m>C</m> is also linear
+
+<math><![CDATA[
+\begin{aligned}
+  C\left(n \mapsto \sum_i a_i x_i[n]\right)
+  &= B\left(A\left(n \mapsto \sum_i a_i x_i[n]\right)\right)\\
+  &= B\left(n \mapsto \sum_i a_i A(x_i)[n]\right)\\
+  &= n \mapsto \sum_i a_i B(A(x_i))[n]\\
+  &= n \mapsto \sum_i a_i C(x_i)[n]
+\end{aligned}
+]]></math>
+
+## Time Invariance
+
+If <m>A</m> and <m>B</m> are time invariant,
+i.e. for all signals <m>x</m> and integers <m>k</m>,
+
+<math><![CDATA[
+\begin{aligned}
+  A(n \mapsto x[n - k]) &= n \mapsto A(x)[n - k]\\
+  B(n \mapsto x[n - k]) &= n \mapsto B(x)[n - k]
+\end{aligned}
+]]></math>
+
+then <m>C</m> is also time invariant
+
+<math><![CDATA[
+\begin{aligned}
+  C(n \mapsto x[n - k])
+  &= B(A(n \mapsto x[n - k]))\\
+  &= B(n \mapsto A(x)[n - k])\\
+  &= n \mapsto B(A(x))[n - k]\\
+  &= n \mapsto C(x)[n - k]
+\end{aligned}
+]]></math>
+
+## LTI Ordering
+
+If <m>A</m> and <m>B</m> are linear and time-invariant, there exists
+signals <m>g</m> and <m>h</m> such that for all signals <m>x</m>,
+<m>A = x \mapsto x * g</m> and <m>B = x \mapsto x * h</m>, thus 
+
+<math>
+B(A(x)) = B(x * g) = x * g * h = x * h * g = A(x * h) = A(B(x))
+</math>
+
+or interchanging <m>A</m> and <m>B</m> order does not change <m>C</m>.
+
+## Causality
+
+If <m>A</m> and <m>B</m> are causal,
+i.e. for all signals <m>x</m>, <m>y</m> and any choise of integer <m>k</m>,
+
+<math><![CDATA[
+\begin{aligned}
+  \forall n < k, x[n] = y[n]\quad
+  \Longrightarrow &\;\begin{cases}
+  \forall n < k, A(x)[n] = A(y)[n]\\
+  \forall n < k, B(x)[n] = B(y)[n]
+  \end{cases}\\
+  \Longrightarrow &\;\forall n < k, B(A(x))[n] = B(A(y))[n]\\
+  \Longleftrightarrow &\;\forall n < k, C(x)[n] = C(y)[n]
+\end{aligned}
+]]></math>
+
+then <m>C</m> is also causal.
+
+## BIBO Stability
+
+If <m>A</m> and <m>B</m> are stable, i.e. there exists a signal <m>x</m>
+and scalars <m>a</m> and <m>b</m> that for all integers <m>n</m>,
+
+<math><![CDATA[
+\begin{aligned}
+  |x[n]| < a &\Longrightarrow |A(x)[n]| < b\\
+  |x[n]| < a &\Longrightarrow |B(x)[n]| < b
+\end{aligned}
+]]></math>
+
+then <m>C</m> is also stable, i.e. there exists a signal <m>x</m>
+and scalars <m>a</m>, <m>b</m> and <m>c</m> that for all integers <m>n</m>,
+
+<math><![CDATA[
+\begin{aligned}
+  |x[n]| < a\quad
+  \Longrightarrow &\;|A(x)[n]| < b\\
+  \Longrightarrow &\;|B(A(x))[n]| < c\\
+  \Longleftrightarrow &\;|C(x)[n]| < c
+\end{aligned}
+]]></math>
+</markdown>
+</page>
diff --git a/doc/pages/demo/pygments/index.xml b/doc/pages/demo/pygments/index.xml
new file mode 100644
index 0000000..361c6ab
--- /dev/null
+++ b/doc/pages/demo/pygments/index.xml
@@ -0,0 +1,66 @@
+<page xmlns="https://rub.parody">
+<title>Pygments demo</title>
+<description>Code snippets to demonstrate syntax highlighting</description>
+<date>2022-12-26</date>
+<category>demo</category>
+<category>aoc</category>
+<markdown>
+Syntax highlighting for D using Pygments:
+
+<highlight lang="d"><![CDATA[
+import core.stdc.stdio : getchar, printf;
+
+extern(C) void main()
+{
+    slide: for (auto q = 0u, i = 1u; q & 0xffu ^ '\n'; ++i)
+    {
+        q <<= 8u;
+        q |= getchar();
+        if (i < 4)
+            continue;
+
+        auto p = cast(ubyte*) &q;
+        for (auto s = 0u, j = 0u; j < 4u; ++j)
+        {
+            auto b = 1u << (p[j] & 0x1fu);
+            if (s & b)
+                continue slide;
+            s |= b;
+        }
+
+        printf("%d\n", i);
+        break;
+    }
+}
+]]></highlight>
+
+The same but let Pygments guess the language:
+
+<highlight><![CDATA[
+import core.stdc.stdio : getchar, printf;
+
+extern(C) void main()
+{
+    slide: for (auto q = 0u, i = 1u; q & 0xffu ^ '\n'; ++i)
+    {
+        q <<= 8u;
+        q |= getchar();
+        if (i < 4)
+            continue;
+
+        auto p = cast(ubyte*) &q;
+        for (auto s = 0u, j = 0u; j < 4u; ++j)
+        {
+            auto b = 1u << (p[j] & 0x1fu);
+            if (s & b)
+                continue slide;
+            s |= b;
+        }
+
+        printf("%d\n", i);
+        break;
+    }
+}
+]]></highlight>
+</markdown>
+</page>
diff --git a/doc/pages/index.xml b/doc/pages/index.xml
new file mode 100644
index 0000000..1a77965
--- /dev/null
+++ b/doc/pages/index.xml
@@ -0,0 +1,14 @@
+<page xmlns="https://rub.parody">
+<title>Rub</title>
+<markdown>
+Rub is a static generator framework.
+
+## Demoes
+
+* [MathML rendering](/demo/katex) via [KaTeX]
+* [Syntax highlighting](/demo/pygments) via [Pygments]
+
+[KaTeX]: https://katex.org
+[Pygments]: https://pygments.org
+</markdown>
+</page>