repo
stringlengths 26
115
| file
stringlengths 54
212
| language
stringclasses 2
values | license
stringclasses 16
values | content
stringlengths 19
1.07M
|
---|---|---|---|---|
https://github.com/piepert/logik-tutorium-wise2024-2025 | https://raw.githubusercontent.com/piepert/logik-tutorium-wise2024-2025/main/src/templates/slides.typ | typst | Creative Commons Zero v1.0 Universal | #import "@preview/grape-suite:1.0.0": slides
#import slides: *
#import "/src/packages/inference.typ": *
#let slides = slides.with(
series: "Logik-Tutorium",
author: [<NAME>],
outline-title-text: [Ablauf],
box-example-title: [Beispiel],
box-hint-title: [Hinweis],
box-notice-title: [Achtung],
box-solution-title: [Lösung],
box-task-title: [Aufgabe],
) |
https://github.com/yhtq/Notes | https://raw.githubusercontent.com/yhtq/Notes/main/代数学二/章节/下半学期.typ | typst | #import "../../template.typ": *
// Take a look at the file `template.typ` in the file panel
// to customize this template and discover how it works.
= 赋值环|Valuation ring
== 全序阿贝尔群
#definition[][
称一个阿贝尔群全序,如果其上有全序且满足:
$
r <= r' => a r <= a r'
$
两个全序阿贝尔群之间的同态是保持序关系的群同态
]
#example[][
- $RR^+$ 在乘法和通常的序下当然是全序的
- $RR$ 在加法和通常的序下当然是全序的。事实上通过取指数/对数,它与上面的群同构
]
#definition[][
设 $P$ 是全序阿贝尔群,$Q subset P$ 是子群,称 $Q$ 是凸的,如果以下等价条件成立对所有 $delta, delta', gamma in P$ 成立:
- $delta <= gamma <= 1 and delta in Q => gamma in Q$
- $delta, gamma <= 1, delta gamma in Q => delta, gamma in Q$
- $delta <= gamma <= delta', delta, delta' in Q => gamma in Q$
]
#proof[
- 1 $=>$ 2 注意到 $delta gamma <= delta, gamma <= 1$,由 1 结论成立
- 2 $=>$ 1 注意到 $gamma <=1, delta <= gamma => delta Inv(gamma) <= 1$,由 2 结论成立
- 3 $=>$ 1 显然
- 1 $=>$ 3 将有:
$
delta Inv(delta') <= gamma Inv(delta') <= 1 => gamma Inv(delta') in Q => gamma in Q
$
]
#definition[][
设 $P$ 是全序阿贝尔群,定义 $ht(P)$ 为 $P$ 的除 ${1}$ 外的凸子集的个数,显然 $ht(P) >= 0$ 可能为 $infinity$
]
#example[][
- $ht(RR^+) = ht(RR) = 1$
- 任取 $H subset P$,存在一个最小的包含 $H$ 中的凸子集:
$
{gamma in P| exists x, y in H, x <= gamma <= y}
$
]
#proposition[][
- 设 $H_1, H_2$ 是两个凸子群,则必有 $H_1 subset H_2$ 或 $H_2 subset H_1$
- 设 $phi: P -> Q$ 是全序阿贝尔群之间的同态,则 $ker phi$ 是凸子集
- 设 $H$ 是凸子群,则商群 $P quo H$ 上也有全序结构,定义为 #TODO,并有 $ht(P) = ht(P quo H) + ht(H)$
- $ht(P) = 0 <=> P = {1}$
]
#proof[
- 否则,设 $x in H_1 - H_2, y in H_2 - H_1$,不妨设 $x, y < 1$(否则取逆)以及 $x < y < 1$\
然而第二式已经给出 $x, 1 in H_1$ 进而 $y in H_1$,矛盾!
]
#proposition[][
设 $P != [1]$ 是全序阿贝尔群,以下条件等价:
- $ht(P) = 1$
- $P$ 可以嵌入 $RR^+$(或 $RR$ 加法群)
- $P$ 是阿基米德的,也即 $forall x < 1, y < 1 in P$ 均存在 $m$ 使得 $x^m < y$
]
#proof[
本门课程不会用到这些事实,不作证明
]
== 赋值、赋值谱
#definition[][
设 $A$ 是环,$P$ 是全序阿贝尔群,称一个赋值是映射:
$
abs(dot): A -> P union {0}
$
并且满足:
- $abs(a + b) <= max(abs(a), abs(b))$
- $abs(a b) = abs(a) abs(b)$
- $abs(0) = 0, abs(1) = 1$
若 $A$ 是拓扑环(加法和乘法都连续且兼容),则称赋值是连续赋值,如果任意 $x in P$,都有:
$
{abs(a) < x} "是开集"
$
]
#definition[][
称两个赋值等价,如果存在交换图表:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $P$, 2),
node((1, 0), $P'$, 3),
arr(1, 2, $$),
arr(3, 2, $$, bij_str),
arr(1, 3, $$),)]
]
#proposition[][
设 $k$ 是域,则其上的赋值等价于一个群同态 $k^times -> P$ 结合 $v(0) = infinity$
]
#example[平凡赋值][
对于任意环 $A$ 和其中素理想 $p$ ,给出一个平凡赋值:
$
abs(a) = cases(
0 quad a in p,
1 quad a in.not p
)
$
]
#definition[赋值谱|valuation spectrum][
设 $A$ 是环,定义其赋值谱 $Spv(A)$ 为所有赋值的等价类的集合。进一步,可以定义其上的闭集族为:
$
Spv(A)(f/s) := {v i Spv(A) | abs(f)_v <= abs(s)_v != 0}
$
构成拓扑空间
]
#proposition[][
任给环同态 $phi: A -> B$,诱导映射 $abs(dot): Spv(B) -> abs(dot) compose phi: Spv(A)$,它是连续映射
]
#remark[][
平凡赋值给出 $Spec(A) -> Spv(A)$ 的映射,而 $ker$ 给出 $Spv(A) -> Spec(A)$ 的映射,满足:
#align(center)[#commutative-diagram(
node((0, 0), $Spec(A)$, 1),
node((0, 1), $Spv(A)$, 2),
node((1, 0), $Spec(A)$, 3),
arr(1, 2, $$, inj_str),
arr(2, 3, $$),
arr(1, 3, $$),)]
]
#example[p-adic][
- $QQ$ 上的赋值一定是某个素数 $p$ 产生的平坦赋值,称为 $p-$进赋值,换言之:
$
Spv(QQ) = Spec(ZZ)
$
- $QQ$ 上的赋值可以限制到 $ZZ$ 上,更进一步:
$
Spv(ZZ) = Spv(QQ) union {abs(dot)_(0, p), p "is prime"}
$
其中后者是 $F_p$ 上的平凡赋值
]
== 赋值环
#definition[dominate][
设 $A subset B$ 是局部环,极大理想分别为 $m, n$,若 $n sect A = m$ 则称 $B$ 支配 $A$
]
#definition[valuation ring][
设 $A$ 是整环,$k$ 是分式域,称 $A$ 是 $k$ 的赋值环,如果以下等价条件成立:
+ $forall x in k, x in A or Inv(x) in A$
+ 存在全序阿贝尔群 $(Gamma, +)$ 和满同态 $nu: k^* -> Gamma$,并且满足:
$
nu(x + y) >= min(nu(x), nu(y))\
nu(x y) = nu(x) + nu(y)
$
并且 $A = {x in k | nu(x) >= 0}$
此时,称 $v$ 是 $A$ 的一个(加性)赋值
+ $A$ 的主理想在包含关系下构成全序集
+ $A$ 的所有理想在包含关系下构成全序集
+ $A$ 是局部环并且每个有限生成理想是主理想
+ $A$ 是局部环且不存在 $k$ 中的局部环支配 $A$
+ 存在代数闭域 $L$ 以及同态 $theta: A -> L$(一般不是单射),并且 $A, theta$ 是极大的,也就是若 $A subset A' subset k, theta': A' -> L$ 是 $theta$ 的延拓,则 $A = A'$
]<valuation-ring-cond>
#proof[
- 1 $=>$ 2 取 $Gamma = k^* quo B^*$,$nu$ 是自然映射,只需给出序结构。对于 $gamma, gamma' in Gamma$,有:
$
gamma <= gamma' <=> gamma - gamma' in im(B - {0} -> Gamma)
$
可以验证这是一个全序阿贝尔群
- 2 $=>$ 1 显然
- 1 $=>$ 3\
断言 $A$ 的主理想与 $(A - {0}) quo A^*$ 有一一对应,既然主理想 $(a), (b)$ 相等当且仅当 $a, b$ 之间相差一个可逆元,进而 2 的结论就给出其上的全序关系
- 4 $=>$ 3 显然
- 3 $=>$ 4 任取两个理想 $I_1, I_2$ ,设 $I_1 subset.not I_2$ ,往证 $I_2 subset I_1$\
任取 $a in I - J, b in J$,$a in.not J => (a) subset.not (b) subset J$,而由主理想的全序性必有 $(b) subset (a) subset I => b in I$,证毕
- 4 $=>$ 5 由理想的全序性,两个极大理想必然可比,当然只能有唯一一个极大理想。同时,设 $I = (x_1, x_2, ..., x_n)$ ,此时 $(x_1)$ 与 $(x_2, x_3, ..., x_n)$ 相互包含,因此可以去掉一个生成元,以此类推可以只剩下一个生成元,进而是主理想
- 5 $=>$ 1 设 $a, b in k != 0$, 往证 $a / b in A or b / a in A$\
设 $I = (a, b)$ 由条件它是主理想,因此 $I quo m I$ 是一维的线性空间,进而:
$
exists u, v in A, (u + m I) a + (v + m I) b = m I => u a + v b in m I
$
其中 $u, v$ 不全在 $m I$ 之中,继而可设:
$
exists x, y in m, u a + v b = x a + y b=> (u - x) a = (y - v) b
$
无妨设 $u in.not m$ ,然而局部环表明 $u$ 是单位。同时 $x in m$,因此 $u - x$ 不在 $m$ 中,也是单位,进而 $a = k b, k in A$ ,证毕
- 1 $=>$ 6 假设 $A'$ 是局部环,且 $A subset.neq A'$,往证 $A'$ 不支配 $A$,也就是存在 $A$ 中极大理想中的元素,在 $A'$ 中是单位(进而 $m_A subset.not m_(A') sect A$) \
取 $x in A' - A$,由条件 $Inv(x) in A subset A'$ ,因此 $x$ 在 $A'$ 中一定是单位\
此时,$Inv(x)$ 当然不是 $A$ 中的单位,但在 $A'$ 中是单位,证毕。
- 6 $=>$ 7 设 $K = A quo m$ 是留域,取 $L$ 是 $K$ 的代数闭包,$theta: A -> A quo m -> L$\
假设存在延拓 $A subset A' subset k, theta': A' -> L, theta'|_A = theta$\
显然,$ker theta = m$,设 $m' = ker(theta')$,则 $A'$ 可以嵌入 $A'_m'$ (注意到 $A'$ 是域的子环,当然是整环),此时只需证明 $A = A'_(m')$ 因此不妨设 $A'$ 是局部环,$m'$ 是极大理想\
显然,此时 $m = ker theta = ker theta' sect A = m' sect A$,利用条件 6 知结论成立
- 7 $=>$ 1 这步较为困难,需要建立若干个引理,之后会证明
]
#example[][
- 满足 $dim = 1$ 的赋值环只有两种:离散赋值环(赋值在 $ZZ$ 上的赋值,一定是 Noether 的)和非离散的
- 设 $v: k(x, y) -> ZZ^2$ 并使用 $ZZ^2$ 上字典序,也即 $v(x) = (1, 0), v(y) = (0, 1)$\
此时 ${x | v(x) >= 0}$ 是赋值环
- 设 $k[x] subset k[x^(1/2)] subset ... subset k[x^(1/n)] subset ..$\
$
O_n = k[x^(1/2^n)]_(p_n) where p_n = (x^(1/2^n))
$
可以验证:
$
O_n subset O_(n+1), p_(n+1) sect O_n = p_n
$
设 $O = union_n O_n$ ,此时 $O$ 是非 Noether 的赋值环,赋值群是
$
{z/(2^n) | z in NN, n in NN}
$
的子群
]
#proposition[][
设 $B$ 是赋值环,$k$ 是分式域,则:
- $B$ 是局部环
- 设 $B'$ 是环使得 $B subset B' subset k$,则 $B'$ 也是赋值环
- $B$ (在 $k$ 中)整闭
- 设 $p$ 是 $B$ 的素理想,则 $B quo p, B_p$ 在各自的分式域都是赋值环
]<valuation-ring-prop>
#proof[
- 之前已经证明,但是我们换一种方法再次证明。设 $m$ 是 $B$ 中所有非单位元,显然只需证明 $m$ 是理想。\
- 假设 $a in B, x in m$,若 $a x in.not m$,则 $Inv((a x)) in B => Inv(x) = a Inv((a x)) in B$ 矛盾!
- 假设 $x, y != 0 in m$ ,由定义 $x Inv(y) in B$ 或 $y Inv(x) in B$ ,不妨设前者成立,则:
$
x + y = y (1 + Inv(y) x)
$
显然若 $x + y$ 可逆,则 $y$ 也可逆,矛盾!
- 设 $x in k$,显然:
$
x in B => x in B'\
Inv(x) in B => Inv(x) in B'\
$
至少有一个成立,因此 $B'$ 当然也是赋值环
- 设 $x in k$ 在 $B$ 上整,设 $f(x) = 0$,也即:
$
x^(n) + a_1 x^(n-1) + ... + a_n = 0\
x + a_1 + ... + a_n x^(-(n-1)) = 0\
x = -a_1 - ... - a_n x^(-(n-1))\
$
注意到若 $x in.not B$ 必有 $Inv(x) in B$,然而上式右侧全部是 $B$ 中元素,进而 $x$ 也是,矛盾!
- 利用 $x in A orC Inv(x) in A$ 简单验证即可
]
#theorem[赋值环的构造][
设 $k$ 是任意一个域,$Omega$ 是代数闭域,令:
$
Sigma = {(A, f) | A subset k "是子环", f in Hom(A, Omega)}
$
定义偏序关系:
$
(A, f) <= (A', f') <=> "存在交换图表:"
$
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $A'$, 2),
node((1, 0), $Omega$, 3),
arr(1, 2, $$, inj_str),
arr(2, 3, $f'$),
arr(1, 3, $f$),)]
则 $Sigma$ 非空且有极大元 $(A, f)$,且其极大元是赋值环,$ker f$ 是唯一的极大理想
]<extension-of-valuation>
#proof[
首先,$Sigma$ 非空(可以取 $(0, 0)$),且满足 Zoun 引理条件,进而存在极大元\
设 $B$ 是一个极大元
#lemmaLinear[][
$B$ 是局部环,且 $m = ker(f)$ 是极大理想
]
#proof[
设 $m = ker(f)$,可以局部化得到 $B_m$,同时注意到:
$
f(B - m) subset U(Omega)
$
当然 $f$ 可以延拓到 $B_m$ 上,而由极大性得 $B_m = B$,证毕
]
#lemmaLinear[][
任取 $x in k - {0}, B[x] subset k, m[x] := m B[x]$ ,则以下两者至少有一个成立:
- $m[x] subset.not B[x]$
- $m[Inv(x)] subset.not B[Inv(x)]$
]
#proof[
如若不然,则两者同时成立,则由 $1 in B[x], B[Inv(x)]$ 得:
$
1 = sum_(i=0)^n u_i x^i, u_i in m\
1 = sum_(i=0)^m v_i x^(-i), v_i in m
$
不妨设 $m, n$ 各自最小且 $m >= n$,此时二式给出:
$
(1 - v_n) x^n = v_1 x^(n-1) +... + v_(n-1) x + v_n
$
注意到 $1-v_n$ 是单位,上式可以化成首一的多项式,进而和一式做带余除法将降低次数,与 $m, n$ 的极小性矛盾!
]
回到定理的证明,往证 $x in B or Inv(x) in B$,由上面的引理不妨设 $m[x] != B[x] := B'$,则存在 $B'$ 的极大理想 $m'$ 使得 $m[x] subset m'$\
另一方面,我们证明 $f: B -> Omega$ 可以延拓到 $B' = B[x]$ 上即可\
首先,显然有 $m' sect B = m$(既然 $m subset m' sect B$ 而 $m$ 是极大理想),这表明 $B quo m$ 可以嵌入 $B' quo m'$,且 $B' quo m'$ 在 $B quo m$ 上代数
]
#theorem[][
设 $A subset k$ 其中 $A$ 是整环,$k$ 是域,则 $A$ 的整闭包恰为 $k$ 中包含 $A$ 的所有赋值环的交
]
#proof[
- 一方面,设 $B$ 是赋值环且 $A subset B subset k$,注意到 $B$ 是整闭的,因此 $A$ 的整闭包当然只能含于 $B$
- 另一方面,我们要证明若 $x$ 含于所有这样的赋值环,则含于 $A$ 的整闭包\
反之,设 $x$ 在 $A$ 上不是整元,只需构造一个赋值环 $B supset A$ 使得 $x$ 不在 $B$ 中\
令 $A' = A[Inv(x)]$ 它不是有限生成 $A-$模,也不包含 $x$,设 $Inv(x) in A'$ (注意到它不是单位)包含于极大理想 $m'$,考虑:
$
f: A -> A' -> A quo m' -> overline(A quo m')
$
最后一项是指代数闭包。\
在 @extension-of-valuation 中,注意到 $(A, f)$ 是符合定义的二元组,因此存在一个比它更大的元素 $(B, g)$ 使得 $A subset B subset k$ 且有交换图表:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $A'$, 2),
node((0, 2), $A quo m'$, 4),
node((0, 3), $overline(A quo m')$, 5),
node((1, 0), $B$, 3),
arr(1, 2, $$, inj_str),
arr(2, 3, $$, inj_str),
arr(3, 5, $g$),
arr(2, 4, $$),
arr(4, 5, $$),
)]
断言 $x in.not B$,否则又注意到 $(A' -> overline(A quo m')) (Inv(x)) = 0$,若 $x in B$
则 $Inv(x) in ker g$ 是可逆元导致 $g$ 平凡,这是荒谬的
]
== 离散赋值环|Discrete valuation ring
#definition[Discrete valuation ring, DVR][
设 $k$ 是域,$k$ 上的离散赋值是指映射:
$
v: k^* -> ZZ,
$
满足:
+ $v$ 是满射
+ $v(x y) = v(x) + v(y)$
+ $v(x + y) >= min{v(x), v(y)}$
(有时也将 $v$ 视作 $k -> ZZ union {infinity}$)\
此时:
- 称 $k$ 是*离散赋值域*|discrete valuation field, dvf
- 若 $v(pi) = 1$,则称 $pi$ 是一个一致化子|uniformizer
- 记 $O_v = {x in k | v(x) >= 0}$ (特别的令 $0 in O_v$),则 $O_v$ 是赋值环且 $ht(O_v) = 1$
- 记 $m_v = {x in k | v(x) >= 1}$ 它是 $O_v$ 的理想,稍后证明它是极大的
一般的,若一个整环是上面方法所产生的赋值环,则称之为*离散赋值环*
]
#example[][
- 设 $k = QQ, p$ 是素数,对任意非零 $x in k$ ,可设 $x = p^a y$ 且 $y$ 的分子分母都与 $p$ 互素,此时定义 $v_p (x) = a$,这给出 $QQ$ 上的一个离散赋值,它的赋值环 $O_v_p = {r/s | (s, p) = 1} = ZZ_((p))$
- 令 $K = k(x), f in k[x]$ 是不可约多项式,类似的可以做唯一因子分解将 $K$ 中任意一个元素写作 $x = f^a y$ 以及赋值 $v_f$
]
#proposition[][
设 $A$ 是离散赋值环,以分式域 $k$ 上的离散赋值 $v$ 产生,则 $A$ 是整闭的局部环且:
- 其中的单位就是赋值为零的那些元素
- 极大理想就是 $m_v = {x in k|v(x) >= 1}$
- $v(x) = v(y)$ 当且仅当 $x, y$ 只差一个可逆元,也即 $(x) = (y)$
- 任取 $A$ 中理想 $I$,选出其中赋值最小的元素 $x$ ,则 $I = (x) = {y in A|v(y) >= v(x)}$
- 设 $pi$ 是一致化子,则 $v(pi^k) = k$,由上一个命题所有理想 $I$ 都是由某个 $pi^k$ 生成的主理想,表明 $A$ 中所有非零理想构成链:
$
m_v = (pi) = {x in k|v(x) >= 1} >= m_v^2 = (pi^2) >= ...
$
$m_v$ 是唯一的非零素理想,特别的,$A$ 是 $dim A = 1$ 的 Noether 环
]
#proof[
由 @valuation-ring-prop 可知 $A$ 是局部环且整闭
- 注意到 $v(x) = 0 => v(Inv(x)) = 0 => Inv(x) in A$ 表明 $A$ 中赋值为零的元素都是单位。同时不难验证赋值为正的元素不是单位
- 由赋值的定义不难验证它是理想,上一条给出它当然就是极大理想
- 注意到 $v(x) = v(y) => v(Inv(x) y) = 0 => Inv(x) y in U(A)$,因此 $x, y$ 只差可逆元
- 设 $v(y) >= v(x)$ 则 $v(y Inv(x)) >= 0 => y Inv(x) in A => y in (x)$\
如此,赋值不小于 $x$ 的元素都在 $I$ 中,而由假设 $I$ 中没有赋值小于 $x$ 的元素,因此 $I = (x) = {y in A|v(y) >= v(x)}$
- 显然
]
#theorem[][
设 $A$ 是 Noether 的局部整环,且 $dim A = 1$,$m$ 为极大理想,$k$ 为留域,则以下条件等价:
+ $A$ 是离散赋值环
+ $A$ 整闭
+ $m$ 是主理想
+ $dim_k m quo m^2 = 1$
+ $A$ 中每个非零理想都是 $m$ 的幂
+ $exists x in A$ 使得每个非零理想都形如 $(x^k), k >= 0$
]
#proof[
#lemmaLinear[][
设 $I$ 是非平凡理想,则存在 $n > 0, m^n subset I$
]
#proof[
注意到 $sqrt(I)$ 是包含 $I$ 的所有素理想的交,由 $dim A = 1$ 知它就是 $m$,再由 Noether 知 $m$ 有限生成,考虑生成元不难发现结论成立
]
#lemmaLinear[][
$m^k != m^(k+1)$
]
#proof[
如若不然由 @noether-local-classification 可得环是 Artin 环,这与 $dim A = 1$ 矛盾
]
- 1 $=>$ 2 显然
- 2 $=>$ 3 任取 $0 != a in m$,由引理,设 $n$ 满足:
$
m^n subset (a), m^(n-1) subset.not (a)
$
取 $b in m^(n-1) - (a)$,令 $x = a /b in k$,往证:
- $x$ 不是 $A$ 中单位,否则 $(a) = (b)$ 与取法矛盾
- $Inv(x) m subset.not m$ ,否则利用 Hamiton-Cayley 可以证明 $Inv(x)$ 是整元
- 3 $=>$ 4 显然主理想的生成元就是向量空间 $m quo m^2$ 的生成元,同时 $m quo m^2 != 0$ 否则由 Nakayama 知 $m = 0$,导致 $dim A = 0$
- 4 $=>$ 5 继续利用引理,设 $I$ 是非平凡理想,且 $m^n subset I, m^(n-1) subset.not I$,,注意到 $A quo m^n$ 是 Artin 局部环,由 @artin-local-prop 结合条件立得结论正确
- 5 $=>$ 6 取 $x in m - m^2$,由结论 $(x) = m^r$ 再根据假设只能有 $r = 1 => (x) = m$ ,由于所有理想都是 $m$ 的幂次当然结论成立
- 6 $=>$ 1 有条件,当然有 $m = (x)$,且 $(x^k) != (x^(k+1))$\
对任意 $A$ 中非零元素 $a$,定义 $v(a) = r$ 若 $(a) = (x^r)$
- 由条件,这个 $r$ 是唯一的
- 将赋值延拓到分式环上,可以验证它是一个离散赋值
]
#theorem[][
设 $A$ 是 Noether 的整环,且 $dim A = 1$,则以下条件等价:
+ $A$ 整闭
+ $A$ 在所有素理想/极大理想处的局部化都整闭
+ $A$ 在所有素理想/极大理想处的局部化都是离散赋值环
]<dedekind-the>
#proof[
注意到整闭是局部性质,由上面的定理不难推出该定理
]
== 戴德金整环|Dedekind domains
这部分在数论课程中更加重要,本门课程不会要求太高
#definition[戴德金整环|Dedekind domains][
满足 @dedekind-the 条件的环成为戴德金整环
]
#proposition[][
戴德金整环中,所有理想都可以唯一分解为素理想的乘积
]
#proof[
这个结论是唯一分解性质的进一步推广,我们不证明这个结论
]
#proposition[][
- 主理想整环都是戴德金整环,既然主理想整环都诺特,且主理想整环作为唯一分解整环满足非零素理想都极大进而 $dim = 1$,同时它的局部化也是主理想环,故满足 @dedekind-the 条件
- 设 $k quo Q$ 是有限代数扩张,$A$ 是 $ZZ$ 在 $k$ 中的整闭包,也就是 $k$ 中的代数整数,则 $A$ 是戴德金整环
#proof[
- $A$ 当然整闭
- $A$ 是诺特的,证明略
- 下证 $dim A = 1$,也即所有非零素理想都极大。这是因为任取 $p in Spec(A)$,一定有 $p sect ZZ$ 是素理想
- 若 $p sect ZZ = 0$,然而 $0 subset p$ 同样有 $0 sect ZZ = 0$,由整扩张性质 @integral-prime-containing 立得 $p = 0$ 矛盾!
- 否则,$p sect ZZ$ 是极大理想,由 @integral-prime-containing 知 $p$ 也是极大理想
]
]
== 分式理想
#definition[分式理想/可逆理想][
设 $A$ 是整环,$K$ 是分式域:
- 称 $K$ 的子 $A-$模 $M$ 是分式理想,如果:
$
exists x != 0 in A, x M subset A
$
若 $M$ 是分式理想,定义:
$
(A:M) = {x in K | x M subset A}
$
- 称 $K$ 的子 $A-$模 $M$ 是可逆理想,如果存在 $K$ 的子 $A-$模 $N$ 使得 $M N = A$\
- 所有的可逆理想构成群(单位元是 $A$)
]
#example[][
- $A$ 的理想当然是分式理想,取 $x = 1$ 即可。
- 若 $M$ 是有限生成的 $K$ 子 $A-$模,取 $x$ 为生成元分母的乘积,它也是分式理想。
- 任取 $u in K^*$ ,则 $(u)$ 是分式理想,也是可逆理想,它的逆就是 $(1/u)$
]
#proposition[][
设 $A$ 是诺特环,则所有分式理想都是有限生成的
]<noether-fractional-ideal-finite>
#proof[
设 $M$ 是分式理想,$x M$ 是 $A$ 的理想,进而有限生成,当然 $M$ 也是有限生成的 $AModule(A)$
]
#proposition[][
- 可逆理想都是分式理想
- $M$ 是可逆理想时,它的逆就是 $(A:M)$
- 可逆理想都是有限生成理想
]
#proof[
- 设 $N$ 是一个逆,任取 $n in N$ 当然有 $n M subset A$
- 由上条的证明过程知 $N subset (A:M)$,同时 $(A:M) = (A:M) M N subset A N subset N$
- 由 $M N = A$ 可得:
$
1 = sum_i m_i n_i
$
上式右侧是有限和。任取 $z in M$ 都有:
$
z = z sum_i m_i n_i = sum_i (z n_i) m_i in sum_i A m_i
$
表明 $m_i$ 就是一组生成元
]
#theorem[可逆性是局部性质][
以下条件等价:
- $M$ 是可逆理想
- $M$ 有限生成,且对任意素理想 $p$,$M_p$ 是可逆理想
- $M$ 有限生成,且对任意极大理想 $m$,$M_m$ 是可逆理想
]
#proof[
- 1 $=>$ 2 之前证明了 $A = M (A:M)$,我们希望做局部化。注意到 $M$ 是有限生成的,因此局部化可以和 $Ann$ 交换,自然可以和 $(A:M)$ 交换,故结论成立
- 2 $=>$ 3 显然
- 3 $=>$ 1 设 $I = M (A:M)$ 由条件它不含于任何的极大理想中(否则可以做局部化),因此就是 $A$
]
#theorem[][
设 $A$ 是局部环,则 $A$ 是离散赋值环当且仅当每个非零分式理想都可逆
]
#proof[
- 设 $A$ 是离散赋值环,设 $m = (pi)$ 是极大理想,若 $M$ 是分式理想,则存在 $y$ 使得:
$
y = (pi^s)\
y M = (pi^r)\
M = (pi^(r-s))
$
这当然是可逆的
- 首先,可逆理想都有限生成,因此 $A$ 当然是诺特环。往证所有理想都是极大理想的幂次。\
令 $Sigma$ 为 $A$ 中所有不是 $m$ 幂次的理想,若其非空,由诺特条件找到一个极大元 $I$\
由条件,将有:
$
Inv(m) I subset.not Inv(m) m = A
$
同时,$Inv(m) I != m$ 否则 $I = m^2$,类似的它也不是 $m$ 的幂次\
然而 $I subset Inv(m) I$,由极大性 $I = Inv(m) I$ 除非 $I = 0$ 否则这是荒谬的
]
#corollary[][
设 $A$ 是整环,则 $A$ 是戴德金整环当且仅当所有的非零分式理想都可逆
]
#proof[
利用局部化,显然(注意到左推右需要利用诺特性和 @noether-fractional-ideal-finite,右推左需要利用分式理想都有限生成表明环是诺特的)
]
= Kahler-differentials
这部分是补充内容,讨论代数的导数和切空间等内容
#definition[derivation][
设 $A$ 是环,$B$ 是 $A-$代数,$M$ 是 $B-$模,一个 $M$ 中 $B$ 的 $A-$导数(A-derivation of B into M)是一个 $A-$线性映射 $dif: B -> M$ 满足莱布尼茨法则:
$
dif(x y) = x dif(y) + y dif(x), forall x, y in B
$
显然这里的 $B$ 的定位类似于 $A$ 上的函数,$M$ 类似于切空间\
定义所有这样的导数构成集合:
$
Der_A (B, M)
$
]
#proposition[][
- $dif(1) = dif(1 dot 1) = dif(1) + dif(1) => dif(1) = 0, dif(a) = a dif(1) = 0$,这就是在说常值函数的导数为零
]
#definition[][
设 $B$ 是 $A-$代数,则存在 $B-$模 $Omega'_(B quo A)$,和相应的 $A-$导数 $dif$ 并且满足泛性质:对任意 $B-$模 $M$ 和 $A-$导数 $dif': B -> M$,有交换图表:
#align(center)[#commutative-diagram(
node((0, 0), $B$, 1),
node((0, 1), $M$, 2),
node((1, 0), $Omega'_(B quo A)$, 3),
arr(1, 2, $dif'$),
arr(3, 2, $exists ! phi$),
arr(1, 3, $dif$),)]
这个泛性质等价于同构:
$
Der_A (B, M) tilde.eq Hom_B (Omega'_(B quo A), M)
$
称 $Omega'_(B quo A)$ 为 the module of relative differential forms of B over A\
]
#proof[
和张量积类似,唯一性由范畴的始对象给出,存在性也用类似张量积的构造方法,用自由模商掉我们需要的关系即可\
具体来说,令 $F$ 是由符号 ${dif b | b in B}$ 生成的自由 $B-$模,令:
$
N = generatedBy({dif a | a in A} union {dif (b_1 + b_2) - dif b_1 - dif b_2 | b_1, b_2 in B} union {dif (b_1 b_2) - b_1 dif b_2 - b_2 dif b_1 | b_1, b_2 in B})\
Omega_(B quo A) = F quo N
$
并且 $dif$ 就是自然的同态,很容易验证它满足莱布尼茨法则
为了证明泛性质,给出交换图表:
#align(center)[#commutative-diagram(
node((0, 0), $B$, 1),
node((0, 1), $M$, 2),
node((1, 0), $F$, 3),
node((2, 0), $Omega_(B quo A)$, 4),
arr(1, 2, $dif'$),
arr(3, 2, $exists phi$),
arr(1, 3, $dif$),
arr(3, 4, $$),
arr(4, 2, $exists phi'$)
)]
其中:
- $phi$ 来自于自由模的泛性质
- 不难验证 $N subset ker phi$,因此 $phi'$ 产生于商模的泛性质
]
#example[][
设 $B = A[t_1, ..., t_n]$ 是多项式环,则 $Omega'_(B quo A)$ 就是自由模 $directSum_i B dif t_i$, 其中:
$
dif F = sum_i partialDer(F, t_i) dif t_i
$
这是因为任取 $dif'$ 不难计算一定有:
$
dif' F = sum_i partialDer(F, t_i) dif' t_i
$
因此 $dif t_i -> dif' t_i$ 给出典范的同态,这就证明了泛性质
]
#example[][
若 $B = A quo I$ 或 $B = Inv(S) A$ 则 $Omega'_(B quo A) = 0$\
只需说明任何导数都为零即可:
- 若 $B = A quo I$,任取 $x in B$,则 $x = a + I$,有 $dif (a + I) = a dif(1 + I) = 0$
- 若 $B = Inv(S) A$ ,任取 $s/t in B$,有 $t dif (s/t) = dif (s) = 0$ 而 $t$ 是 $B$ 中可逆元,当然就有 $dif(s /t) = 0$
]
#definition[][
设 $B ->^f C$ 是 $A-$代数同态以及两个导数:
$
C ->^(dif_C) Omega'_(C quo A)\
B ->^(dif_B) Omega'_(B quo A)
$
可以定义映射:
$
Omega_(B quo A) &-> Omega_(C quo A)\
dif b &-> dif f(b)\
Omega_(B quo A) tensorProduct C &-> Omega_(C quo A)\
dif b tensorProduct c &-> c dif f(b)
$
]
#proposition[][
设 $B$ 是 $A-$代数
- 换基性质:任取环同态 $A -> A', B' = A' tensorProduct_A B$,则有:
$
Omega_(B' quo A') tilde.eq Omega_(B quo A) tensorProduct_A B'
$
- 任取 $B ->^f C$ 是 $A-$代数同态,有正合列:
$
Omega_(B quo A) tensorProduct_B C -> Omega_(C quo A) -> Omega_(C quo B) -> 0
$
- 任取 $B$ 的乘性子集 $S$,有:
$
Inv(S) Omega_(B quo A) = Omega_(B quo A) tensorProduct_B Inv(S) B tilde.eq Omega_(Inv(S) B quo A)
$
- 设 $C = B quo I$ 有正合列:
$
I quo I^2 -> Omega_(B quo A) tensorProduct_B C -> Omega_(C quo A) -> 0
$
]
#example[][
设 $B = A[T_1, ..., T_n], C = B quo (F)$,由上面的命题有正合列:
$
(F) quo (F^2) -> Omega_(B quo A) tensorProduct_B C -> Omega_(C quo A) -> 0
$
]
= 完备化
== 拓扑阿贝尔群
#definition[拓扑阿贝尔群][
设 $G$ 是阿贝尔群,$G$ 上的拓扑是说 $G$ 是拓扑空间,且群运算是连续的
]
#lemma[][
$G$ 是拓扑阿贝尔群,则 $G$ 是 Hausdorff 空间当且仅当 ${0}$ 是闭集
]
#proof[
- 若 $G$ 是 Hausdorff 空间,则 ${0}$ 当然是闭集
- 注意到:
#align(center)[#commutative-diagram(
node((0, 0), $G$, 1),
node((0, 1), $G times G$, 2),
node((1, 0), ${0}$, 3),
node((1, 1), $G$, 4),
arr(1, 2, $"diag"$),
arr(1, 3, $$),
arr(2, 4, $\"-\"$),
arr(3, 4, $$),)]
因此在 $G times G$ 中,对角线作为 ${0}$ 的连续逆像是闭集,进而 $G$ 是 Hausdorff 空间
]
#lemma[][
设 $H$ 为所有 $0$ 的邻域的交,则:
- $H$ 是子群
- $H = overline({0})$
- $G quo H$ 是 Hausdorff 空间
- $G$ 是 Hausdorff 空间当且仅当 $H = {0}$
]
#proof[
- 设 $x, y in H$ ,任取 $0$ 的开邻域 $O$,注意到 $T_x: G -> G$ 连续,则 $Inv(T_x)(O)$ 是开集。同时 $x in O => 0 in Inv(T_x)(O) => y in Inv(T_x)(O) => x + y in O$
-
$
x in H <=> x in U, forall U in N(0)\
$
任取 $S$ 是闭集,$0 in S <=> 0 in.not G - S$,假设 $x in.not S <=> x in G - S$,则 $x - (G - S)$ 是开集,且 $0$ 在其中,进而:
$
x in x - (G - S) => 0 in G - S
$
矛盾!\
因此 $x$ 处于 $0$ 的所有闭邻域之中,自然处于 $H$ 中。反之是类似的。
- 不难发现 ${0} subset G quo H$ 当然是闭集,因此结论成立
- 就是上面的引理
]
== 分次环
#definition[分次环|graded ring][
设 $A$ 是环,$A = directSum A_n$,称 $A$ 是分次环,若 $A_i A_j subset A_(i+j)$
此时,称 $A_i$ 为 $i$ 次齐次部分。设 $I$ 是 $A$ 的理想,则称 $I$ 是齐次的,若 $I = directSum (I sect A_i)$,也即它被齐次元素生成
]
#lemma[][
设 $I$ 是齐次理想,则 $I$ 是素理想当且仅当任取齐次元素 $x, y, x y in I$ 均有 $x in I or y in I$
]
#proposition[][
对于分次环 $A$,以下事实等价:
- $A$ 是诺特环
- $A_0$ 是诺特环且 $A$ 是 $A_0$ 上有限生成代数
]<graded-noether>
== 拓扑完备化
#definition[拓扑完备化][
设 $G$ 是拓扑阿贝尔群,且 $0$ 处有可数邻域基,则可以定义完备化 $hat(G)$ 为所有柯西序列的等价类,其中:
- ${x_n}$ 是柯西序列当且仅当任取 $0$ 的开邻域 $U$ 均有对于充分大的 $n, m$ 有 $x_n - x_m in U$
- 两个柯西序列 $x_n, y_n$ 等价当且仅当 $x_n - y_n -> 0$,也即任取 $0$ 的开邻域 $U$ 均有对于充分大的 $n$ 有 $x_n - y_n in U$
在其上定义:
- ${x_n} + {y_n} = {x_n + y_n}$
-
$
funcDef(phi, G, hat(G), a, {a})
$
一般来说 $phi$ 不是单射。事实上,$ker phi$ 就是 $0$ 的所有开邻域的交,因此 $phi$ 是单射当且仅当 $G$ 是 Hausdorff 空间
- 函子性:设 $f: G -> H$ 是连续同态,则柯西序列的像还是柯西序列,从而 $f$ 可以诱导 $hat(f)$ ,也即完备化具有函子性
]
#example[][
假设 $G_n$ 是 $0$ 的开邻域,且满足:
$
G = G_0 >= G_1 >= ... >= G_n >= ...
$
并且, $U$ 是 $0$ 的邻域当且仅当存在 $G_n subset U$,此时断言:
- $G_n$ 既开由闭
- 先证明开集,设 $g in G_n$ 则 $g + G_n subset G_n$ 是 $g$ 的一个 $G_n$ 中的开邻域,继而 $G_n$ 一定是开集
- 再证明闭集,既然 $G - G_n = union_(h in.not G_n) (h + G_n)$ 是开集,因此 $G_n$ 是闭集
此时,完备化可以有纯代数的定义:
$
hat(G) tilde.eq inverseLimit G quo G_n
$
同构如下给出:
- 任取 $(xi_n) in inverseLimit G quo G_n$,给出对应的柯西序列为:
$
x_n in G\
x_n = xi_n mod G_n\
$
此时将有 $x_(n+1) - x_n in G_n$,不难验证它是柯西序列
- 任取柯西序列 $(x_n)$,既然只要 $m, m'$ 充分大即有:
$
overline(x_m) = overline(x_m') in G quo G_n
$
因此对充分大的 $m$ 定义 $xi_m = overline(x_m) in G quo n$
]<alg-top-completion>
#lemma[][
若:
$
0 -> {A_n} -> {B_n} -> {C_n} -> 0
$
是逆向系统的正合列,则:
$
0 -> inverseLimit A_n -> inverseLimit B_n -> inverseLimit C_n
$
正合(逆向极限是左正合的)
进一步,若 $A_n$ 是满射系统(也即每个 $A_(n+1) -> A_n$ 是满射),则:
$
0 -> inverseLimit A_n -> inverseLimit B_n -> inverseLimit C_n -> 0
$
正合
]
#proof[
设 $A = product A_n$,定义:
$
funcDef(d_A, A, A, (a_n), (a_n - overline(a_(n+1))))
$
则 $ker d_A = inverseLimit A_n$\
将有交换图表:
#align(center)[#commutative-diagram(
node((0, 0), $0$, 1),
node((0, 1), $A$, 2),
node((0, 2), $B$, 3),
node((0, 3), $C$, 4),
node((1, 0), $0$, 5),
node((1, 1), $A$, 6),
node((1, 2), $B$, 7),
node((1, 3), $C$, 8),
node((0, 4), $0$, 9),
node((1, 4), $0$, 10),
arr(1, 2, $$),
arr(2, 3, $$),
arr(3, 4, $$),
arr(5, 6, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(2, 6, $d_A$),
arr(3, 7, $d_B$),
arr(4, 8, $d_C$),
arr(4, 9, $$),
arr(8, 10, $$),
)]
蛇形引理给出正合列:
$
0 -> ker d_A -> ker d_B -> ker d_C -> coker d_A -> coker d_B -> coker d_C -> 0
$
进一步,若 ${A_n}$ 是满系统,只需证明 $d_A$ 满继而 $coker d_A = 0$. 事实上,任给 $(a_n) in A$,只需找到 $(x_n)$ 使得 $x_n - overline(x_(n+1)) = a_n$,递归定义即可
]
#remark[][
这里 $coker d_A$ 事实上就是 $inverseLimit^1 A_n$,也即导出函子
]
#corollary[][
设 $G$ 满足 @alg-top-completion 的条件,且有正合列:
$
0 -> G' -> G -> G'' -> 0
$
其中 $G', G''$ 分别用 ${G_n sect G'}$ 和 ${(G -> G'') (G_n)}$ 定义拓扑,将有:
$
0 -> hat(G') -> hat(G) -> hat(G'') -> 0
$
正合。
]<exact-completion>
#proof[
注意到有正合列:
$
0 -> {G quo G' sect G_n} -> {G quo G_n} -> {G quo ((G -> G'') (G_n))} -> 0
$
取逆向极限利用之前的结论立得结论成立
]
#corollary[][
取正合列:
$
0 -> G_n -> G -> G quo G_n -> 0
$
注意到 $G quo G_n$ 有离散拓扑(所有子集都是开集),完备化就是本身,即可得正合列:
$
0 -> hat(G_n) -> hat(G) -> G quo G_n -> 0
$
因此:
$
hat(G) quo hat(G_n) tilde.eq G quo G_n
$
特别的,$hat(hat(G)) = hat(G)$(取逆向极限即可)
]<completion-of-completion>
#proof[
利用之前的结论即可
]
#definition[完备][
设 $phi: G -> hat(G)$ 是同构,则称 $G$ 是完备空间。
]
#proposition[][
- 既然 $ker phi = {0}$ 故完备空间一定 Hausdorff
- 在 @completion-of-completion 的条件中,$hat(G)$ 当然一定是完备空间
]
== $I-$adic 拓扑
#example[环/模的完备化][
- 设 $A$ 是环,$I$ 是理想,取 $G = A, G_n = I^n$,由 $G_n$ 定义的拓扑称为 $I$-adic 拓扑,如此可以产生完备化:
$
hat(A) = inverseLimit A quo I^n, phi: A -> hat(A), ker phi = sect I_n
$
- 设 $M$ 是 $AModule(A)$,取 $G = M, G_n = I^n M$ 类似可以定义 $M$ 上的 $I$-adic 拓扑,以及 $hat(M)$ 称为连续 $AModule(A)$($A$ 在其上的作用是连续的)
- 特别的:
- 取 $A = k[x], I = (x)$,则 $hat(A) = k[[x]]$ 就是形式幂级数环
- 取 $A = ZZ, I = (p)$,则 $hat(A) = ZZ_p$ 就是 $p$-进整数环
]
下面的所谓 filtrations 是为了提供另一种在模上定义拓扑的方法
#definition[][
设 $M$ 是$AModule(A)$,$I$ 是理想,称一个 $M$ 的 $A-$ filtration 是一个子模的无穷序列:
$
M = M_0 >= M_(1) >= ...
$
- 称之为 $I-$filtration ,如果 $I M_n subset M_(n+1)$
- 称之为稳定 $I-$filtration ,如果满足上条的条件且对于充分大的 $n$ 有 $I M_n = M_(n+1)$
]
#example[][
$(I^n M)$ 当然是稳定 $I-$filtration
]
#lemma[稳定 $I-$filtration给出相同的拓扑][
若 $(M_n), (M'_n)$ 都是稳定 $I-$filtration,则它们有有界差距(bounded diffrence)也即:
$
forall n > 0, exists n_0, M_(n+n_0) subset M'_n, M'_(n+n_0) subset M_n
$
因此,$(M_n), (M'_n)$ 定义相同的 $I-$adic 拓扑
]
#proof[
由定义,显然有:
$
M'_n supset I^n M, forall n
$
只需找到 $n_0$ 使得 $M_(n + n_0) subset I^n M$,事实上,不妨设 $forall n' > n_0$ 均有:
$
I M_(n') = M_(n' + 1)
$
换言之,有 $M_(n + n_0) = I^n M_(n_0) subset I^n M$,证毕
]
设 $A^* = directSum_(n = 0)^infinity I^n$ 是分次环,则 $M^* = directSum_(n = 0)^infinity M_n$ 将是分次 $A^*$ 模。若 $A$ 是诺特的,可设 $I = (x_1, x_2, ..., x_n)$,此时 $A^* = A[x_1, x_2, ..., x_n]$ 当然也是诺特的
#lemma[][
设 $A$ 诺特,$I$ 是理想,$M$ 是有限生成模以及 $I-$filtration $(M_n)$,则以下条件等价:
+ $M^*$ 是有限生成模
+ $(M_n)$ 是稳定 $I-$filtration
]
#proof[
设:
$
Q_n = directSum_(i = 0)^n M_i subset M^*
$
(未必是 $A^*$模),令 $M_n^*$ 是由其生成的模。由于 $M$ 有限生成,显然 $M_n^*$ 也是有限生成的。事实上有:
$
M_n^* = directSum_(i = 0)^n M_i directSum I M_n directSum I^2 M_n directSum ...
$
显然 $M_n^*$ 构成升链,且 $union M_n^* = M^*$,可以验证:
$
M^* "有限生成" <=> M^* = M^*_(n), n "充分大"
$
而后者就等价于 $M_n$ 最终稳定,证毕
]
#proposition[<NAME>][
设 $A$ 诺特,$I$ 是理想,$M$ 是有限生成模以及稳定 $I-$filtration $(M_n)$,$M'$ 是 $M$ 的子模,则 $M' sect M_n$ 是稳定 $I-$filtration\
特别的,若 $M_n = I^n M$,则存在充分大的 $k$ 使得:
$
(I^n M) sect N = I^(n-k) (I^k M sect N)
$
换言之,$I-$adic 拓扑的限制还是 $I-$adic 拓扑
]<Artin-Rees>
#proof[
- 首先,$I(M' sect M_n) subset I M' sect I M_n subset M' sect M_(n+1)$,表明这是 $I-$filtration
- 其次,上面的引理给出 $M^*$ 有限生成,而 $directSum (M' sect M_n)$ 当然是它的子模。诺特环上有限生成模是诺特的,其子模仍然有限生成,因此 $directSum (M' sect M_n)$ 是子模,进而再次利用引理即可得到结论
]
#corollary[][
设 $A$ 诺特,$I$ 是理想,则:
$
0 -> hat(M') -> hat(M) -> hat(M'') -> 0
$
也正合
]
#proof[
@Artin-Rees 结合 @exact-completion 立得
]
#proposition[][
设 $M$ 是有限生成 $A-$模,则 $M tensorProduct_A hat(A) -> hat(M)$ 是满射。进一步若 $A$ 是诺特的,则它是同构。
]
#proof[
- $I-$adic 完备化和有限直和是交换的(既然它们都是逆向极限)
- $F$ 是有限自由模时,$hat(F) = (hat(A))^n$ 继而 $F tensorProduct hat(A) = hat(F)$
由 $M$ 有限生成,有正合列:
$
0 -> N -> F -> M -> 0
$
其中 $F$ 是有限自由模,由张量积右正合:
$
N tensorProduct hat(A) -> F tensorProduct hat(A) -> M tensorProduct hat(A) -> 0
$
有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $N tensorProduct hat(A)$, 1),
node((0, 1), $F tensorProduct hat(A)$, 2),
node((0, 2), $M tensorProduct hat(A)$, 3),
node((0, 3), $0$, 4),
node((1, 0), $hat(N)$, 5),
node((1, 1), $hat(F)$, 6),
node((1, 2), $hat(M)$, 7),
node((1, 3), $0$, 8),
node((1, -1), $0$, 9),
arr(9, 5, $$),
arr(1, 2, $$),
arr(2, 3, $$),
arr(3, 4, $$),
arr(5, 6, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(1, 5, $$),
arr(2, 6, $$, bij_str),
arr(3, 7, $$),
arr(4, 8, $$),
)]
其中上下(下是因为满射系统的逆向极限是正合函子)都正合,继而简单的追图可得 $M tensorProduct hat(A) -> hat(M)$ 是满射。若 $A$ 是诺特的,$N$ 作为有限生成模的子模也是有限生成模,$N tensorProduct hat(A) -> hat(N)$ 也满射,同时 $hat(N) -> hat(F)$ 由完备化的正合性(上面的推论)将成为单射,运用蛇形引理即得 $ker (M tensorProduct hat(A) -> hat(M)) = 0 $,证毕
]
#let hA = $hat(A)$
#let hI = $hat(I)$
#corollary[][
设 $A$ 诺特,$I$ 是任意理想,在 $I-$ adic 拓扑下有:
- 完备化是正合函子
- $hat(A)$ 是平坦 $A$-模
- $hat(I) = I tensorProduct hat(A) = I hat(A)$
- $hat(I^n) = (hat(I))^n$
- $hat(A) quo hat(I) tilde.eq A quo I$(之前已经证明,这条不需要诺特)
- $I^n quo I^(n+1) tilde.eq hat(I^n) quo hat(I^(n+1))$
- $hat(I)$ 落在 $hat(A)$ 的 Jacobson 根中
]
#proof[
只证明最后一条,任取 $x in hat(I), y in hat(A)$,有:
$
Inv((1- y x)) = 1 + y x + ...
$
由完备性,上式右侧是有意义的,表明 $1 -y x$ 是单位,证毕
]
#proposition[][
设 $A$ 是诺特局部环,$m$ 是极大理想,则 $hat(A)$ 仍是局部环,极大理想是 $hat(m)$
]
#proof[
首先 $hat(A) quo hat(m) tilde.eq A quo m$ 保证 $hat(m)$ 是极大理想\
其次,前面已经证明 $hat(m)$ 落在 Jacobson 根中,因此 $hat(m)$ 是唯一极大理想
]
#theorem[Krull][
设 $A$ 诺特, $M$ 有限生成,则:
$
ker (M -> hat(M)) = sect I^n M = {x in M | exists y in I, (1 + y) x = 0}
$
特别的,若 $A$ 是整环且 $I != (1)$,则 $sect I^n M = {0}$
]<Krull>
#proof[
设 $E = ker(M -> hat(M))$,它也是 $0$ 的所有开邻域的交。
注意到 $E$ 的限制拓扑是平凡的,也即 $E$ 是唯一一个 $E$ 中 $0$ 的邻域,而 @Artin-Rees 引理给出 $E$ 作为 $M$ 的子模产生兼容的拓扑。因此,$I E$ 当然也是 $0$ 的开邻域,
以上事实给出 $I E = E$,由 Nakayama 引理的一个版本可得存在 $alpha in I$ 使得 $(1 - alpha) E = 0$
另一方面,设 $(1 - alpha) x = 0$,则 $x = alpha x = ... alpha^n x = ...$,当然 $x in sect I^n M$
]
#corollary[][
在前面的条件中,若 $I$ 落在 Jacobson 根中,必有 $sect I^n M = 0$,继而 $M$ 上的 $I-$adic 拓扑是 Hausdorff 的。
特别的,若 $A$ 是诺特的局部环,则其上所有有限生成模的 $I-$adic 拓扑都是 Hausdorff 的,包括 $A$ 本身
]
#remark[][
设 $S = 1 + alpha$,前面证明了这是乘性子集,因此产生局部化 $Inv(S) A$\
另一方面,注意到:
$
(1 - x)^(-1) = 1 + x + x^2 + ...
$
在 $hat(A)$ 中收敛,也即在 $hat(A)$ 中 $S$ 中元素都可逆,泛性质给出 $Inv(S) A$ 可被嵌入 $hat(A)$
]
#theorem[][
设 $A$ 的诺特环,则 $hat(A)$ 还是诺特的。特别的,诺特环上有限个变元的形式幂级数环(作为多项式环的完备化)还是诺特的
]
#proof[
它的证明需要一些铺垫
#let Gn(n) = $M_(#n) quo M_(#n +1)$
#definition[][
定义:
$
G(A) = directSum_(n = 0)^infinity I^n quo I^(n+1)
$
它是分次环
若 $M$ 有 $I-$filtration,可以类似定义:
$
G(M) = directSum_(n = 0)^infinity Gn(n)
$
它是分次 $G(A)$ 模
]
#proposition[][
设 $A$ 诺特,则:
- $G(A)$ 是诺特的
- $G_I (A) tilde.eq G_(hI) (hA)$
- 设 $M$ 是有限生成的,且其上的 $I-$filtration 是稳定的,则 $G(M)$ 有限生成
]
#proof[
- 显然 $I$ 有限生成,不妨设 $I = (x_1, x_2, ..., x_n)$,显然:
$
G(A) = A quo I [overline(x_1), ..., overline(x_n) ]
$
它当然是诺特的
- 前面已经证明 $I^n quo I^(n+1) tilde.eq hat(I)^n quo hat(I)^(n+1)$,结论显然
- $n$ 充分大时,有 $M_(n+1) quo M_(n+2) tilde.eq (I M_n) quo (I M_(n+1)) tilde.eq I (Gn(n))$,因此 $G(M)$ 本质上仅有前面有限项生成(后面的只是 $I$ 在其上的作用),而前面有限项当然每项都是有限生成的,它们的直和也是有限生成的
]
#proposition[][
设 $M$ 是有限生成,且其上的 $I-$filtration 是稳定的,假设 $A$ 完备且 $M$ 是 Hausdoff 的,也即 $sect M_n = 0$,则:
- 若 $G(M)$ 有限生成,则 $M$ 有限生成
- 若 $G(M)$ 诺特,则 $M$ 诺特
]
#proof[
#lemma[][
设 $phi: A -> B$ 是 filtered 群间的同态(也即满足 $phi(A_n) subset B_n$),诱导 $hat(phi): hat(A) -> hat(B), G(phi) : G(A) -> G(B)$,则:
- $G(phi)$ 是单射给出 $hat(phi)$ 是单射
- $G(phi)$ 是满射给出 $hat(phi)$ 是满射
]
#proof[
有交换图:
#align(center)[#commutative-diagram(
node((0, -1), $0$, -1),
node((1, -1), $0$, -2),
node((0, 0), $A quo A_(n+1)$, 1),
node((0, 1), $A quo A_(n+1)$, 2),
node((0, 2), $A quo A_n$, 3),
node((0, 3), $0$, 4),
node((1, 0), $B_n quo B_(n+1)$, 5),
node((1, 1), $B quo B_(n+1)$, 6),
node((1, 2), $B quo B_(n)$, 7),
node((1, 3), $0$, 8),
arr(-1, 1, $$),
arr(-2, 5, $$),
arr(-1, -2, $$),
arr(1, 2, $$),
arr(2, 3, $$),
arr(3, 4, $$),
arr(5, 6, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(1, 5, $G_n (phi)$),
arr(2, 6, $alpha_n$),
arr(3, 7, $alpha_(n+1)$),
arr(4, 8, $$),
)]
对 $n$ 做归纳,利用蛇形引理可以验证 $alpha_(n+1)$ 是单射/满射,对 $alpha_n$ 取逆向极限结合两者都是满射系统知结论成立
]
取 $G(M)$ 的齐次生成元 $xi_i = overline(x_i), x_i in M_(n_i)$,希望证明 $x_i$ 就是 $M$ 的生成元
取:
$
F = directSum_i F^i where F^i = A
$
定义 $phi: F -> M, phi(1_i) = xi_i$,则 $G(phi)$ 是满射,由引理 $hat(phi)$ 是满射,有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $F$, 1),
node((0, 1), $M$, 2),
node((1, 0), $hat(F)$, 3),
node((1, 1), $hat(M)$, 4),
arr(1, 2, $$),
arr(1, 3, $$),
arr(2, 4, $$),
arr(3, 4, $$),
print: true
)]
注意到 $A$ 完备,$M$ Hausdoff,则 $M -> hat(M)$ 是单射。同时由于 $F$ 是有限自由模,可以验证:
$
F tilde.eq inverseLimit F quo I^n F tilde.eq hat(F)
$
(将 $F$ 拆成 $A$ 的直和结合 $A$ 的完备性)\
再结合 $hat(phi)$ 的满射性,追图即得 $phi$ 也是满射。
对于第二个结论,证明 $M$ 的任意子模 $M'$ 是有限生成即可。令:
$
M'_n = M' sect M_n
$
可以验证 $M'_n quo M'_(n+1)$ 可以嵌入 $M_n quo M_(n+1)$,而后者是诺特模,前者也是,利用第一个结论即可
]
有了上面的命题,原结论是容易的。事实上,$G(A) tilde.eq G(hat(A))$ 根据上面的命题是诺特的,而 $hat(A)$ 是完备的 Hausdoff 空间,因此由上面的命题 $hat(A)$ 是诺特的。
]
#corollary[][
诺特环上有限个变元的形式幂级数环是诺特的
]
= 维数理论 | Dimension theory
== 维数
#definition[height, dimension][
设 $A != 0$ 是环
- 设 $p$ 是素理想,定义 $ht(p)$ 为最大的 $n$ 可以构成一个素理想升链 $p_0 = p < p_1 < ... <p_n$,它也就是 $dim A_p$
- 设 $I$ 是理想,定义 $ht(I) = inf(ht(V(I)))$
- 定义 $dim A = sup_(p in Spec(A)) ht(p)$
- 设 $M$ 是 $AModule(A)$,定义 $dim M := dim A quo Ann(M)$
]
#proposition[][
$dim A quo I + ht(I) <= dim A$
]
#proof[
由定义显然
]
#theorem[][
设 $A$ 是诺特环,$M$ 是有限生成模,则以下条件等价:
- $M$ 是有限长度的
- $A quo Ann(M)$ 是 Artin 环
- $dim M = 0$
]
#proof[
在@chain-cond 已经证明了
]
== 整值多项式
接下来的主要目标是,设 $(A, m)$ 是诺特的局部环,我们将找到一个多项式 $x_m^A (n)$ 使得:
- $dim A = deg x_m^A (n)$
- $n$ 充分大时,有 $x_m^A (n)$ 就是 $A quo m^n$ 的长度
这部分内容也可参考 Serre, local Algebra
#lemma[][
设:
- $Q_k (x) = C_x^k = (x (x-1) ... (x - k + 1))/(k!)$
- $Delta f(n) = f(n + 1) - f(n)$
则可以证明 $Delta Q_(k+1) = Q_k$,且设 $f$ 是有理系数多项式,则以下条件等价:
+ $f(x) = sum_i a_i Q_(i) (x)$
+ $f(ZZ) subset ZZ$
+ $f(n) subset ZZ, n in ZZ$ 充分大
+ $Delta f (ZZ) subset ZZ andC exists n_0, f(n_0) in ZZ$
成立时,称 $f$ 是取整值的多项式|integer-valued polynomial,并称 $e_i (f) := a_i$ 是展开系数,并有容易的等式:
$
Delta f = sum_i a_i Q_(i-1) => e_(i-1) (Delta f) = e_i (f)
$
]
#proof[
- $2 => 1$ 由于 $Q_i$ 次数逐渐上升,自然构成 $QQ-$线性空间的基,因此先可设:
$
f = sum_i e_i Q_i
$
再不断差分可以证明 $e_i$ 都是整数
- $4 => 2$ 显然
- $3 => 1$ 利用归纳法,差分和 4 即可
]
#definition[][
设 $f: NN -> ZZ$ ,称 $f$ 是类多项式|polynomial like 的,如果存在多项式 $p(x)$ 使得 $n$ 充分大时有:
$
f(n) = p(n)
$
]
#lemma[][
以下条件等价:
- $f$ 是类多项式
- $Delta f$ 是类多项式
- 存在 $l > 0$ 使得 $Delta^l f(n) = 0, forall n$ 充分大
]
== 庞卡莱序列
#definition[庞卡莱序列][
设 $A = directSum_i A_i$ 是诺特的分次环,每个 $A_n$ 都诺特。$M$ 是分次的有限生成 $A_0-$模,$lambda$ 是有限 $A_n-$模 $-> ZZ$ 的加性函数,定义 $M$ 的庞卡莱序列为:
$
P(M, t) = sum_(n >= 0) lambda (M_n) t^n
$
]
#theorem[][
$P(M, t)$ 是有理函数,且:
$
P(M, t) = (f(t))/(product_(i = 1)^s (1 - t^(k_i))), f(t) in ZZ[x]
$
定义 $d(M)$ 为这个函数 $P(M, t)$ 在 $t = 1$ 处极点的阶数\
其中 $s$ 是 $A$ 作为 $A_0$ 代数的齐次生成元的个数(@graded-noether),$k_s$ 是每个齐次生成元的次数(也就是将 $M_n$ 通过乘法送入 $M_(n + k_s)$)
]
#proof[
对 $s$ 进行归纳
- $s = 0$ 时结论显然成立(既然形式幂级数 $P(M, t)$ 仅有有限项)
- 一般的,考虑:
$
M_n ->^(x_s) M_(n + k_s)
$
当然 $k = deg x_s$,产生正合列:
$
0 -> K_n -> M_n -> M_(n + k) -> L_(n+k) -> 0
$
其中 $K_n, L_n$ 分别是 $ker, coker$\
令 $K = directSum K_n, L = directSum L_n$,则 $K, L$ 被 $x_s$ 零化,进而成为 $A_0 [x_1, ..., x_(s-1)]$ 上的模。由归纳假设 $P(K, t), P(L, t)$ 都是定理形式的有理函数。\
对正合列取庞卡莱序列,有:
$
sum_n lambda(K_n) t^(n + k_s) - sum_n lambda(M_n) t^n + sum_n lambda(M_(n + k_s)) t^n - sum_n lambda(L_(n + k_s)) t^(n + k_s) = 0
$
化简即得结论。
]
#corollary[希尔伯特多项式][
若证明过程中 $k_1 = k_2 = ... = k_s = 1$,则 $P(M, t) = (f(t))/(1-t)^s$,进而 $n -> lambda(M_n)$ 是 $d(M) - 1$ 次的类多项式。这个多项式称为 $M$ 的希尔伯特多项式
]
#proof[
第一条是直接推论。对于第二条注意到根据定义 $lambda(M_n)$ 就是 $P(M, t) = f(t)/(1-t)^s$ 的 $n$ 次项系数。无妨设 $f(t), 1 - t$ 互素,否则约去令 $s$ 更小即可。作展开:
$
f(t)/(1-t)^s = f(t) (1 + t + ...)^s := (sum_(k=0)^N a_k t^k)(1 + t + ...)^s
$
可以计算得当 $ n> N$ 时,将有:
$
lambda(M_n) = sum_(k = 0)^N a_k C_(s + n - k + 1)^(s - i)
$
确实是关于 $n$ 的多项式,且次数是 $d - 1$,证毕
]
#proposition[][
设 $x in A_k$ 不是 $M$ 的零因子($m in M, x m = 0 => m = 0$),则:
$
d(M quo x M) = d(M) - 1
$
]
#proof[
根据 $M_n ->^x M_(n+k)$ 构造正合列:
$
0 -> M_n ->^x M_(n+k) -> M_(n+k) quo (x M_n) -> 0
$
将有:
$
P(M quo x M, t) = P(M, t) -t^k P(M, t) + r(t)
$
显然极点的阶刚好降低一,证毕
]
#example[][
设 $A_0$ 是 Artin 环,$A = A_0 [x_1, ..., x_s]$,则恰有 $d(A) = s$\
这是因为:
- $A_n$ 是自由 $A_0$模,生成元集为所有 $n$ 次单项式,作为自由模的维数是 $C_(n + s -1)^(s - 1)$
- 可以计算得:
$
P(A, t) = lambda(A_0) + lambda(A_1) t + ... = = sum_n C_(n + s - 1)^(s - 1) t^n = (1 - t)^(-s)
$
]
#proposition[][
假设 $(A, m)$ 是诺特的局部环,$q$ 是理想且 $sqrt(q) = m$(往往就取 $q = m$), $M$ 是有限生成 $A-$模,$M_n$ 是稳定 $q-$filtration,则:
- $M quo M_n$ 有限长度
- $n -> "length"(M quo M_n)$ 是不超过 $s$ 次类多项式,其中 $s$ 是 $q$ 最少的生成元个数
- 上面多项式的次数和首项系数与 $q$ 无关,只与 $M$ 有关
该多项式称为特征多项式,记作 $chi_q (n)$
]<degree-of-char-poly>
#proof[
- 令 $G(A) = directSum_n q^n quo q^(n+1)$,则由极大理想幂零 $G_n$ 是 Artinian Noetherian 局部环,$G(M)$ 是有限生成 $G(A)$ 模,且每一项都 Artinian Noethenian 环 $A quo q$ 上的有限生成模,进而是 Artinian Noethenian 模,因此 $M_n quo M_(n+1)$ 有限长度,$M quo M_n$ 也有限长度。
- 由上题结论,$n -> l(M_(n - 1) quo M_n)$ 是类多项式函数,次数不超过 $s - 1$,求和得 $n -> l(M quo M_n)$ 也是类多项式,次数不超过 $s$,表明结论正确
- 之前证明了两个稳定 $q-$filtration 互相控制,因此 $n$ 充分大时对应多项式也相互控制,进而首项应该都是一样的
]
#corollary[][
$deg chi_q (n) = deg chi_m (n)$ 且首项相等
]
#proof[
注意到:
$
m subset q subset m^r\
m^n subset q^n subset m^(r n)
$
由长度的定义可得:
$
chi_m (n) <= chi_q (n) <= chi_m (r n)
$
令 $n -> infinity$ 可得结论
]
#definition[][
设 $A$ 是诺特的局部环,则令:
$
d(A) := deg chi_q (n) = deg chi_m (n) = deg( n -> "length"(A quo m^n)) = d(G_m (A))
$
其中 $G_m (A) = directSum (m^i quo m^(i+1))$,$d(G_m (A))$ 是之前定义的希尔伯特多项式的极点阶数
]
== 诺特局部环的维度
#definition[][
设 $A$ 是诺特的局部环,令 $delta(A)$ 为 $A$ 中 $m-$ primary 理想的最小生成元数量。
]
本节的目标是:
$
delta(A) = d(A) = dim (A)
$
为此,我们证明:
$
delta(A) >= d(A) >= dim (A) >= delta(A)
$
#proposition[][
设 $M$ 是有限生成 $A-$ 模,$x$ 不是零因子,则:
$
deg chi_q^(M quo x M) <= deg chi_q^(M) - 1
$
]
#proof[
令 $N := x M$,作为 $AModule(A)$同构于 $M$\
再令 $M' = M quo x M$\
由正合列:
$
0 -> N quo N_n -> M quo q^n M -> M' quo q^n M' -> 0
$
由长度的加性,$n$ 充分大时有:
$
l(N quo N_n) - chi_q^M (n) + chi_q^M' (n) = 0
$
既然 $N$ 与 $M$ 同构,又由 @Artin-Rees 有 $n$ 充分大时 $l(N quo N_n) = l(N quo q^n N)$,故 $l(N quo N_n), chi_q^M (n)$ 有相同的次数和首项,因此 $chi_q^M' (n)$ 必然比其至少低一次
]
#proposition[][
$d(A) >= dim(A)$
]
#proof[
做归纳:
- 若 $d(A) = 0$,则 $n$ 充分大时 $A quo m^n$ 的长度的常值,继而:
$
l(m^n quo m^(n+1)) = 0
$
注意到它是 $A quo m$ 上的向量空间,因此 $m^n = m^(n+1)$,这是标准的 Artin 条件,故 $A$ 是 Artin 的,$dim A = 0$
- 一般的,任取素理想升链:
$
p_0 < ... < p_l
$
取 $x in p_1 - p_0, A' = A quo p_0$ 是整环,继而由之前的命题:
$
d(A' quo x) <= d(A') - 1
$
注意到 $A quo m^n$ 到 $A' quo m'^n$ 存在满射,因此:
$
l(A quo m^n) >= l(A' quo m'^n)\
d(A) >= d(A') >= d(A' quo x) + 1
$
由归纳假设,有:
$
d(A' quo x)>= dim (A' quo x)
$
然而由最开始的素理想升链可得 $dim(A' quo x')$ 不小于 $dim A - 1$,结合上式即得结论
]
#corollary[][
- $dim(A)$ 有限
- 对于一般的诺特环 $A$,每个素理想的降链都有限长
]
#proposition[][
设 $A$ 是诺特的局部环,$dim A = d$,则存在 $m-$primary 理想恰有 $d$ 个生成元。换言之,$delta(A) <= d$
]
#proof[
归纳构造 $x_i$ 使得每个包含 $(x_1, x_2, ..., x_i)$ 的素理想的 height 都至少为 $i$\
假设 $x_1, ..., x_(i-1)$ 已经构造,令 $p_j$ 是包含 $(x_1, ..., x_(i-1))$ 的极小素理想且高度恰为 $i -1$,也就是 $Ass(A quo (x_1, ..., x_(i-1)))$ 中极小元(仅有有限个)\
既然 $i - 1< d = dim A$ 而 $m$ 的高度就是 $d$,因此 $p_j$ 不是 $m$,取 $x_i in m - union p_j$\
设 $q$ 是任意包含 $(x_1, ..., x_i)$ 的素理想,则 $q$ 包含某个包含 $(x_1, ..., x_(i-1))$ 的极小素理想 $p$
- 若 $p = p_j$,则 $x_i in q - p$ 表明 $p subset.neq q$,表明 $q$ 的高度至少是 $p$ 的高度加一,结论成立
- 否则,由于刚才取得了所有高度为 $i - 1$ 的极小素理想,$p$ 的高度至少为 $i$,继而 $q$ 也至少有高度 $i$
]
#theorem[Dimension][
对于诺特的局部环 $A$,以下三个整数相等:
- 最大素理想升链的长度
- 特征多项式 $l(A quo m^n)$ 的次数
- $m-$primary 理想的最少生成元个数
]
#proof[
$delta(A) >= d(A)$ 是上节的主要结论(@degree-of-char-poly),其余便是本节的结论。
]
#example[][
之前证明了多项式环的幂级数是 $1 / (1-t)^n$ ,因此它的维度也是 $n$
]
#corollary[][
设 $A$ 是诺特的局部环,$k$ 是留域,则 $dim A <= dim_k m quo m^2$
]
#proof[
取 ${x_i} subset m$ 使得它们的像构成 $m quo m^2$ 的一组基,此时 $x_i$ 必然生成 $m$(利用 Nakayama 引理的推论 @basis-is-generator-Nakayama),因此有:
$
dim A = delta(A) <= dim_k m quo m^2
$
]
#corollary[][
设 $A$ 是不一定局部的诺特环,$x_1, ..., x_r in A$,则每个包含 $x_1, ..., x_r$ 的极小素理想的高度都不大于 $r$
]
#proof[
设 $p$ 是包含这些元素的极小素理想,在 $A_p$ 中当然有:
$
sqrt((x_1, ..., x_r)) = p A_p
$
表明:
$
r >= delta(A_p) = dim A_p = "height"(p)
$
]
#theorem[Krull's principal ideal theorem][
设 $A$ 诺特,$x$ 不是单位或零因子,$p$ 是包含 $x$ 的极小素理想,则 $p$ 的高度就是 $1$
]
#proof[
由上面的引理,$p$ 的高度只能为零或一
- $"height" (p) = 0$,书上的 primary decomposition 章节证明了这样的素理想(也就是环上的极小素理想)其中每个元素都是零因子,与 $x in p$ 是矛盾的
因此只能为 $1$
]
#corollary[][
$dim A = dim hat(A)$
]
#proof[
注意到:
$
A quo m^n tilde.eq hat(A) quo hat(m)^n
$
当然特征多项式是一致的
]
#corollary[][
设 $A$ 是诺特的局部环,$x$ 不是零因子或单位,则:
$
dim A quo (x) = dim A - 1
$
]
#proof[
前面已经证明 $d (A quo (x)) <= d (A) - 1$,另一方面不难通过生成元数量验证 $delta(A quo (x)) >= delta(A) - 1$ 进而结论成立
]
#definition[][
设 $A$ 是诺特局部环,$d = dim A$, 若 $sqrt((x_1, ..., x_d)) = m$,则称 $x_1, ..., x_d$ 是一个参数系统|system of parameters
]
#proposition[][
设 $q = (x_1, ... x_d)$ 是参数系统,$f(t_1, ..., t_d)$ 是 $s$ 次齐次多项式,且系数落在 $q^(s + 1)$ 中,则这些系数也落在 $m$ 中
]
#proof[
考察:
$
funcDef(phi, A quo q [t_1, ..., t_d], G_q (A),t_i, x_i)
$
容易验证它是满射\
假设 $f$ 有系数不在 $m$ 中,由前面的习题有 $phi(f)$ 不是零因子,将有:
$
d(A) = d(G_m (A)) <= d( (A quo q [t_1, ..., t_d]) quo (phi(f))) <= d (A quo q [t_1, ..., t_d]) - 1 = d - 1
$
矛盾!
]
#corollary[][
设 $k = A quo m subset A, x_1, ..., x_d$ 是参数系统,则 $x_1, ..., x_d$ 代数独立
]
#proof[
假设有这样的多项式 $f$,取出其中最低非零次 $s$ 齐次部分 $f_s$,断言:
$
f_s (x_1, ..., x_d) = 0 in q^s quo q^(s+1), q = (x_2, ..., x_d)\
$
由上面的引理,$f_s$ 的系数全在 $m$ 中,与假设矛盾!
]
#definition[Regular Local Ring][
设 $A$ 是诺特的局部环,$dim A = d, m$ 是极大理想,$k = A quo m $,若以下等价条件成立:
- $G_m (A) tilde.eq k[t_1, ..., t_d]$
- $dim_k m quo m^2 = d$
- $m$ 可被 $d$ 个元素生成
]
#proof[
- 1 $=>$ 2 容易验证
- 2 $=>$ 3 @basis-is-generator-Nakayama
- 3 $=>$ 1 前面定义了典范的满射 $k[x_1, ..., x_n] -> G_m (A)$,由上一个命题的代数独立性这里 $ker$ 为零,继而是同构
]
#lemma[][
设 $A$ 是环,$I$ 是理想且 $sect I^n = 0$,假设 $G_I (A)$ 是整环,则 $A$ 是整环
]
#proof[
任取 $x, y != 0$,取最大的 $r, s$ 使得:
$
x in I^r\
y in I^s
$
则 $x y$ 在 $G_I (A)$ 中的像非零,当然就有 $x y != 0$
]
#corollary[][
- Regular Local Ring 是整的
- Regular Local Ring 是整闭的
]
#proof[
- $k[t_1, .., t_d]$ 当然是整环,由 @Krull 知必有 $sect m^n = 0$,因此由上面的引理知结论成立。
- $dim = 1$ 时,由于离散赋值环等价于切空间 $m quo m^2$ 恰为一维,故结论成立。一般的证明略。
]
#proposition[][
$A$ regular $<=> hat(A)$ regular
]
#proof[
注意到 $G_m (A) = G_(hat(m)) (hat(A))$,结论显然
]
#corollary[][
设 $A$ 是 regular local ring ,$k = A quo m subset A$ ,则 $hat(A)$ 同构于 $k[[t_1, ..., t_d]]$
]
= 同调代数
== 回顾
#definition[Abel 范畴][
称范畴 $AA$ 是 Abel 范畴,如果 $Hom_AA (A, B) in Ob(AA)$ 且其上有 Abel 群结构,并满足分配律:
$
h(g + g') f = h g f + h g' f\
forall h in Hom_AA (B, \*), f in Hom_AA (\*, A)
$
]
#definition[加性函子][
称 Abel 范畴 $AA, BB$ 间的函子 $F: AA -> BB$ 是加性函子,如果对于任意 $A, B in AA$,$F$ 保持 $Hom$ 的加法结构(是加法群同态)
]
本学期由于时间原因,不能详细讲解 Abel 范畴,但所幸有下面的定理:
#theorem[Frey-Miichell embedding][
设 $CC$ 是 Abel 范畴,则存在全忠实的正合函子将 $CC$ 嵌入某个环上的模范畴
]
#definition[chain complex][
设:
$
X = ... -> X_(k + 1) ->^(d_(k+1)) X_k ->^(d_k) X_(k-1) -> ...
$
并记:
- $Z_k (X) = ker d_k$
- $B_k (X)= im d_(k+1)$
若成立 $0 subset B_k subset Z_k subset X_k$,则称之为一个链复形,并记:
$
H_n (X) = Z_n quo B_n
$
称为第 $n$ 个同调模。可以证明,$H_n$ 具备函子性
]
#definition[cochain complex][
设:
$
X = ... -> X^(k - 1) ->^(d^(k-1)) X^(k) ->^(d^(k)) X^(k+1) -> ...
$
并记:
- $Z^k (X) = ker d^(k)$
- $B^k (X)= im d^(k-1)$
若成立 $0 subset B^k subset Z^k subset X^k$,则称之为一个链复形,并记:
$
H^n (x) = Z^n quo B^n
$
称为第 $n$ 个同调模。可以证明,$H^n$ 具备函子性
]
#definition[][
chain/cochain 之间可以定义同态,要求同态与 $d_n$(也被称为差分)可交换。进一步,构成 Abel 范畴,记作 $CC$
]
#remark[Singular Complex functor][
可以定义从拓扑空间的范畴 $"Top"$ 到 $Mod_ZZ$ 上链复形的函子:
$
"ZSing"_n (X) = ZZ[Hom (abs(Delta^n), X)]
$
其中:
- $abs(Delta^0) = $ 单点
- $abs(Delta^1) = 0, 1$ 线段
- $abs(Delta^2) = $ 三角形
- ...
下降的态射是对边界求和
]
#definition[分裂][
设有链复形:
$
.. ->^d X^(k-1) ->^d X^k ->^d X^(k+1) ->^d ...
$
且存在态射 $s: X^(n) -> X^(n-1)$ 使得:
$
d = d s d
$
则称复形分裂。
]
#definition[同伦|homotopic][
- $f, g : X -> Y$ 是两个链复形之间的同态。称 $f, g$ 同伦,记作 $f tilde g$,如果存在 $s^n: X^n -> Y^(n-1)$ 使得以下交换图表成立:
#align(center)[#commutative-diagram(
node((0, 0), $X^n$, 1),
node((0, 1), $X^(n+1)$, 2),
node((1, -1), $Y^(n-1)$, 3),
node((1, 0), $Y^n$, 4),
arr(1, 2, $$),
arr(1, 3, $s^n$),
arr(2, 4, $s^(n+1)$),
arr(3, 4, $$),
arr(1, 4, $f^n - g^n$)
)]
等价的,就是:
$
f - g = d_Y s + s d_X
$
- 称 $X ->^f Y$ 是同伦等价的,如果存在 $h: Y -> X$ 使得 $h compose f tilde id, f compose h tilde id$,此时也称 $X$ 与 $Y$ 同伦等价或 $X tilde Y$
]
#lemma[][
- 设 $f tilde g$,则 $H^k (f) = H^k (g)$
- 设 $X tilde Y$,则 $H^k (X) = H^k (Y)$
- 加性函子保持同伦性
- 链复形分裂当且仅当 $id$ 与零同伦
]<homotopic-equivalence>
#proof[
- 等价于 $H^k (f - g) = 0$,注意到:
$
f tilde g <=> f - g tilde 0
$
因此不妨就设 $g = 0, f tilde 0$,往证 $H^k (f)= 0$\
由定义,有:
$
f^n = s^(n+1) d_X^n + d_Y^(n-1) s^n
$
注意到:
$
f^n (ker d_X^n) = d_Y^(n-1)(s^n (ker d_X^n)) subset im d_Y^(n-1)\
$
由定义:
$
H^n (f) : ker (d_X^n) quo im(d_X^(n-1)) -> ker (d_Y^n) quo im(d_Y^(n-1))
$
由上面的计算,这意味着 $H^n (f) = 0$,证毕
- 同理
- 同伦无非是等式,当然被加性函子保持
- 定义验证即可
]
#definition[][
设 $F$ 是两个 Abel 范畴间的函子,它自然诱导了 Abel 范畴上复形的函子。
- 若 $F$ 将短正合列映到短正合列,则称 $F$ 是正合函子。这也等价于保持 $ker, im, coker, coim$ 或者等价于保持有限极限/余极限。当然由保持 $ker, im$ 可以推出它保持同调群。
]
#proposition[][
- $Hom(M, *)$ 是左正合函子。它正合时称 $M$ 为投射对象,等价于将任何满同态|eqimorphism $Y -> Z$ 作用得到满同态 $Hom(M, Y) -> Hom(M, Z)$
- $Hom(*, N)$ 是反变左正合函子。它正合时称 $Y$ 为内射对象,等价于将任何单同态|monomorphism $Y -> Z$ 作用得到满同态 $Hom(Z, N) -> Hom(Y, N)$
]
#example[][
- $QQ quo ZZ$ 是 Abel 群范畴中的内射对象
- 设 $R$ 是环,则$Hom_("abel")(R, Q quo ZZ)$ 是内射 $R-$ 模
- $M$ 是平坦模当且仅当 $Hom_("abel") (M, QQ quo ZZ)$ 是内射 $R-$ 模(利用伴随关系)
]
#proposition[短正合列诱导长正合列][
设有复形间正合列:
$
0 -> X -> Y -> Z -> 0
$
则有长正合列:
$
... &-> H^(n-1) (X) -> H^(n-1) (Y) -> H^(n-1) (Z) \
&-> H^n (X) -> H^n (Y) -> H^n (Z)\
&->^delta H^(n+1) (X) -> H^(n+1) (Y) -> H^(n+1) (Z) -> ...
$
进一步,这个长正合列是典范的(具有函子性),也即若两个复形正合列之间有同态,则它们诱导的长正合列之间也有诱导的同态。
]<short-exact-sequence-induced-long-exact-sequence>
#proof[
我们希望利用蛇形引理。对:
$
0 -> &X^n -> &&Y^n -> &&Z^n -> 0\
0 -> &X^(n+1) -> &&Y^(n+1) -> &&Z^(n+1) -> 0
$
之间利用蛇形引理,得到正合列:
$
0 -> ker d_X^n -> ker d_Y^n -> ker d_Z^n -> coker d_X^n -> coker d_Y^n -> coker d_Z^n -> 0
$
进而得到两个正合列正合列:
$
coker d_X^(n-1) -> coker d_Y^(n-1) -> coker d_Z^(n-1) -> 0\
0 -> ker d_X^(n + 1) -> ker d_Y^(n + 1) -> ker d_Z^(n + 1)
$
事实上,注意到:
$
im d_X^(n-1) subset ker d_X^(n)
$
因此 $d_X^(n)$ 自然诱导 $coker d_X^(n-1) = X^(n) quo im d_X^(n-1) -> im d_X^n subset ker d^(n+1)_X$ 的同态,且容易验证这些同态与蛇形引理诱导出的正合列交换,也即有交换图:
#align(center)[#commutative-diagram(
node((0, 1), $coker d_X^(n-1) $, 2),
node((0, 2), $coker d_Y^(n-1)$, 3),
node((0, 3), $coker d_Z^(n-1)$, 4),
node((0, 4), $0$, 5),
node((1, 0), $0$, 6),
node((1, 1), $ker d_X^(n + 1)$, 7),
node((1, 2), $ker d_Y^(n + 1)$, 8),
node((1, 3), $ker d_Z^(n + 1)$, 9),
arr(2, 3, $$),
arr(3, 4, $$),
arr(4, 5, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(8, 9, $$),
arr(2, 7, $$),
arr(3, 8, $$),
arr(4, 9, $$),
)]
再次利用蛇形引理,并注意到:
$
ker (coker d_X^(n-1) -> ker d_X^(n + 1)) \
= ker (d_X^n: coker d_X^(n-1) -> ker d_X^(n + 1)) = (ker d_X^n) quo im d_X^(n-1) = H^n (X)\
coker (coker d_X^(n-1) -> ker d_X^(n + 1)) \
= coker (d_X^n: coker d_X^(n-1) -> ker d_X^(n + 1)) = (ker d_X^(n+1)) quo im d_X^n = H^(n+1) (X)
$
得到的结果便是:
$
H^n (X) -> H^n (Y) -> H^n (Z) -> H^(n+1) (X) -> H^(n+1) (Y) -> H^(n+1) (Z)
$
对所有 $n$ 都成立,连接起来就是所求的长正合列,证毕
]
== Mapping Cones and Cylinders(补充)
#definition[][
设 $f: X -> Y$ 是链复形之间的态射,定义新的复形:
$
... -> X_(n-1) directSum Y_n ->^(d_n) X_(n-2) directSum Y_(n-1) -> ...
$
其中 $d_n$ 定义为:
$
vec(x_(n-1), y_n) -> mat(-d^X_(n - 1), 0;-f, d^Y_n) vec(x_(n-1), y_n)
$
称为 $f$ 的映射锥(mapping cone)$cone(f)$
对偶的,定义 cochain 上上的复形:
$
... -> X^(n+1) directSum Y^n ->^(d^(n)) X^(n+1) directSum Y^(n) -> ...
$
]
== 解消
#example[][
之前定义过投射对象/内射对象。在 $ZZ$ 和除环中,投射对象就是自由模,一般而言未必。在所有有限交换群构成的范畴中,没有投射对象。
]
#lemma[][
- 投射对象是自由模的直和项。投射对象的直和仍然投射
- 内射对象的直积仍然是内射对象
]
#lemma[][
在主理想整环 $R$ 上,$A$ 是内射模当且仅当可除,也即对于任意 $r !=0 in R, r A = A$
]<injective-divisible>
#definition[Resulution][
设 $A in CC$ 是一个对象
- 一个 $A$ 的内射解消是指复形:
$
I^* := 0 -> I^0 -> I^1 -> I^2 -> ...
$
其中 $I^i$ 都是内射对象,且:
$
0 -> X -> I^0 -> I^1 -> I^2 -> ...
$
是正合列,等价于 $H^0 (I^*) = X, H^i (I^*) = X, forall i > 0$\
- 一个 $A$ 的投射解消是指复形:
$
P^* := ... -> P^(-2) -> P^(-1) -> P^0 -> 0
$
其中 $P^i$ 都是投射对象,且:
$
... -> P^(-2) -> P^(-1) -> P^0 -> A -> 0
$
是正合列,等价于 $H^0 (P^*) = A, H^i (P^*) = 0, forall i < 0$
- 若 $CC$ 中每个对象可以嵌入一个内射对象,则称 $CC$ 有足够多的内射对象
- 若 $CC$ 中每个对象都存在投射对象映满到它,则称 $CC$ 有足够多的投射对象
]
#lemma[][
- 假设 $CC$ 有足够多的内射对象,则任意对象 $X in CC$ 都有一个内射解消
- 假设 $CC$ 有足够多的投射对象,则任意对象 $X in CC$ 都有一个投射解消
]
#lemma[][
- $Mod_R$ 有足够多的内射对象
- $Mod_R$ 有足够多的投射对象
]
#proof[
- 利用 $Hom (R, QQ quo ZZ)$ 的内射性
- 在任意模上构造自由模即可
]
#proposition[][
设 $CC$ 是 Abel 范畴,假设有正合列:
$
0 -> A -> A^0 -> A^1 -> ...
$
复形:
$
0 -> B -> I^0 -> I^1 -> ...
$
映射:
$
f: A -> B
$
则存在交换图:
#align(center)[#commutative-diagram(
node((0, 0), $0$, 1),
node((0, 1), $A$, 2),
node((0, 2), $A^0$, 3),
node((0, 3), $A^1$, 4),
node((1, 0), $0$, 5),
node((1, 1), $B$, 6),
node((1, 2), $I^0$, 7),
node((1, 3), $I^1$, 8),
node((0, 4), $...$, 9),
node((1, 4), $...$, 10),
arr(1, 2, $$),
arr(2, 3, $$),
arr(3, 4, $$),
arr(5, 6, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(1, 5, $$),
arr(2, 6, $f$),
arr(3, 7, $f^0$),
arr(4, 8, $f^1$),
arr(4, 9, $$),
arr(8, 10, $$),
)]
且所有这样的延拓都是同伦的
]<morphism-extension>
#proof[
首先注意到 $A -> A^0$ 是单射,由内射对象的性质 $f^0$ 是存在的。\
归纳构造,假设 $f^i: A^i -> I^i, i = 0, 1, ..., n - 1$ 已经构造好,注意到由正合性,有单态射:
$
coker(A^(n-2) -> A^(n-1)) -> A^n
$
其次,注意到:
$
A^(n-2) -> A^(n-1) -> I^(n-1) -> I^n\
= A^(n-2) -> I^(n-2) -> I^(n-1) -> I^n = 0
$
因此有自然的态射:
$
coker(A^(n-2) -> A^(n-1)) -> I^n
$
由内射性质立得 $A^n -> I^n$ 态射,存在性证毕
假设还有另一种延拓 $g$,记 $I^(-1) = 0$,首先要构造下图中的 $h_0$ :
#align(center)[#commutative-diagram(
node((0, 0), $$, 1),
node((0, 1), $A^0$, 2),
node((0, 2), $A^1$, 3),
node((1, 0), $I^(-1)$, 4),
node((1, 1), $I^0$, 5),
node((1, 2), $I^1$, 6),
arr(2, 4, $0$),
arr(3, 5, $h_0$),
arr(2, 3, $$),
arr(4, 5, $$),
arr(5, 6, $$),
arr(2, 5, $$),
arr(3, 6, $$),)]
注意到 $(f^0 - g^0) compose (A -> A^0) = A -> B -> I^0 - A -> B -> I^0 = 0$,因此可将 $f^0 - g^0$ 延拓到 $A^0 quo A -> I^0$,又由正合性,$A^0 quo A$ 嵌入 $A^1$,内射性产生我们需要的 $h_0$,之后的构造是类似的。
]
#corollary[][
任意两个内射解消是同伦等价的
]<injection-resolution-eqvi>
#proof[
假设有两个内射解消 $I, J$ 则有正合列间同态 $f: I -> J$ 和 $g: J -> I$ 都是 $id_A$ 的延拓。注意到 $g compose f$ 成为 $I -> I$ 的同态且是 $id_A$ 的延拓,而 $id$ 是 $I -> I$ 延拓 $id_A$ 的自然同态,唯一性给出 $g compose f tilde id$,另一个方向类似,因此有 $I tilde J$
]
== 余调 $delta-$函子,导出函子
#definition[$delta-$函子][
一个 homological $delta-$ functor 是一族函子 $T_i, i in NN$ 以及连接同态 $delta_i: T_i (C) -> T_(i-1) (A)$,使得:
- 对于任何短正合列 $0 -> A -> B -> C -> 0$ 有长正合列:
$
... -> T_i A -> T_i B -> T_i C ->^(delta_i) T_(i-1) A -> T_(i-1) B -> T_(i-1) C -> ...
$
- 这个长正合列是典范的,也即短正合列间的同态诱导对应长正合列的同态
一个 Cohomological $delta-$ functor 是一族函子 $T_i, i in NN$ 以及连接同态 $delta^i: T^i (C) -> T^(i+1) (A)$,使得:
- 对于任何短正合列 $0 -> A -> B -> C -> 0$ 有长正合列:
$
... -> T^i A -> T^i B -> T^i C ->^(delta^i) T^(i+1) A -> T^(i+1) B -> T^(i+1) C -> ...
$
- 这个长正合列是典范的,也即短正合列间的同态诱导对应长正合列的同态
]
我们的目标是对于一般的函子/加性函子/左正合/右正合函子,能否构造出以其为开始的余调 $delta-$函子,这些函子就是前面提到过的导出函子。
#lemma[][
设有两个关于 $A, B$ 的内射解消:
$
0 -> A -> I^0 -> I^1 -> I^2 -> ...\
0 -> B -> J^0 -> J^1 -> J^2 -> ...
$
只要存在 $A -> B$ 的同态,便可以延拓成正合列的同态。若该同态是同构,则两个正合列同伦等价。
]
#definition[(右)导出函子][
设 $CC$ 有足够多的内射对象, $F$ 是左正合函子, $X in CC$,找到一个 $X$ 的内射解消,也就是正合列:
$
0 -> X -> I^0 -> I^1 -> I^2 -> ...
$
定义:
$
R^n F(X) = H^n (F(I^*))\
$
给出一个与内射解消的选取无关的函子,称为 $F$ 的右导出函子。
]
#proof[
- 由 @injection-resolution-eqvi 和 @homotopic-equivalence 知,这个定义是良定义的。
- 我们还要验证 $R^n F$ 确实具有函子性。对于任意 $A ->^f B$,有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $I_A$, 2),
node((1, 0), $B$, 3),
node((1, 1), $I_B$, 4),
arr(1, 2, $$),
arr(1, 3, $f$),
arr(2, 4, $f^*$),
arr(3, 4, $$),)]
其中 $f^*$ 来自于 @morphism-extension
]
#lemma[Horse shoe][
设 $0 -> A -> B -> C -> 0$ 是短正合列,并有内射解消:
$
A -> I\
C -> J
$
则存在正合序列:
$
0 -> B -> I directSum J
$
使得下图交换:
#align(center)[#commutative-diagram(
node((0, 0), $0$, 1),
node((0, 1), $A$, 2),
node((0, 2), $B$, 3),
node((0, 3), $C$, 4),
node((1, 0), $0$, 5),
node((1, 1), $I$, 6),
node((1, 2), $I directSum J$, 7),
node((1, 3), $J$, 8),
node((0, 4), $0$, 9),
node((1, 4), $0$, 10),
arr(1, 2, $$),
arr(2, 3, $$),
arr(3, 4, $$),
arr(5, 6, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(2, 6, $$),
arr(3, 7, $$),
arr(4, 8, $$),
arr(4, 9, $$),
arr(8, 10, $$),
)]
注意这里不是简单的直和,对象确实是直和但态射不是自然的态射
]<Horse-shoe>
#proposition[][
- $R^0 F tilde.eq F$
- 设 $A$ 是内射模,则 $R^i F A = 0, forall i > 0$
- 任取短正合列:
$
0 -> A -> B -> C -> 0
$
由 @Horse-shoe 知存在复形的正合列:
$
0 -> I_A -> I_B -> I_C -> 0
$
这里 $I_A, I_C$ 是内射解消,$I_B = I_A directSum I_C$\
既然 $F$ 具有加性,以下也是正合列:
$
0 -> F I_A -> F I_B -> F I_C -> 0
$
立刻诱导出长正合列:
$
... -> H^i (F I_A) -> H^i (F I_B) -> H^i (F I_C) -> H^(i+1) (F I_A) -> ...
$
也就是:
$
... -> R^i F A -> R^i F B -> R^i F C -> R^(i+1) F A -> ...
$
]
#proof[
- 任取内射解消 $0 -> A -> I$,由于 $F$ 左正合知 $0 -> F A -> F I$ 也正合,进而:
$
R^0 F = H^0 (F I) = F A
$
- 注意到此时:
$
0 -> A -> A -> 0
$
成为内射解消,进而:
$
R^i F = H^i (F (0 -> A -> 0 -> ...)) = 0
$
且这个长正合列是典范的
]
上面的命题表明,${R^i F}$ 确实是前面定义的余调 $delta-$函子。
== acyclic objects
#let Facyclic = [$F-$acyclic]
#definition[#Facyclic][
- 设 $F$ 是左正合函子,若 $J$ 满足 $R^i F J = 0, forall i >= 1$,则称 $J$ 是 #Facyclic 的
- 一个 #Facyclic 解消是指正合列:
$
0 -> A -> J^0 -> J^1 -> J^2 -> ...
$
其中 $J^i$ 是 #Facyclic 的
]
#theorem[可用 #Facyclic 解消计算导出函子][
假设 $CC$ 有足够多内射对象,$F$ 左正合,则:
$
R^i F A = H^i (F (J))
$
$J$ 是任意一个 #Facyclic 解消
]
#proof[
令 $Z^i (J) = ker (J^i -> J^(i+1))$,有正合列:
$
0 -> A -> J^0 -> Z^1 -> 0
$
对于 $i >= 2$,有正合列:
$
R^(i-1) F J^0 -> R^(i-1) F Z^1 -> R^i F A -> R^i F J^0 \
0 -> R^(i-1) F Z^1 -> R^i F A -> 0
$
表明 $R^(i-1) F Z^1 = R^i F A$\
接下来,有正合列:
$
0 -> Z^1 -> J^1 -> Z^2 -> 0
$
类似可以证明:
$
forall i >= 3, R^(i-2) F Z^2 = R^(i-1) F Z^1 = R^i F A
$
不断进行,可以证明:
$
R^i F A = R^1 F (Z^(i-1) (J))
$
而我们有正合列:
$
0 -> F Z^(i-1) -> F (J^(i-1)) -> F (Z^i) -> R^1 F Z^(i-1) -> 0
$
因此:
$
R^1 F Z^(i-1) = (F (Z^i))/(im (F (J^(i-1)) -> F (Z^i)))
$
另一方面,有:
$
H^i (F (J)) &= (ker F J^i -> F J^(i+1))/(im F J^(i-1) -> F J^i)\
&= (F Z^i) / (im F J^(i-1) -> F J^i)
$
注意到有正合列:
$
0 -> J^(i-1) -> J^i -> J^i quo Z^i -> 0
$
$F$ 作用之,得正合列:
$
0 -> F J^(i-1) -> F J^i -> F (J^i quo Z^i)
$
给出 $F J^(i-1) -> F J^i$ 是嵌入,当然有 #TODO
]
#remark[Dimension shifting][
设有正合列:
$
0 -> A -> B -> C -> 0
$
且 $B$ 是 #Facyclic 的,则有:
$
R^i F C = R^(i+1) F A, forall i >= 1
$
]
假设我们构造了一族余调 $delta-$函子,且 $T^0 = F$,何时这个函子是右导出函子呢?
#definition[泛余调 $delta-$函子][
称一个余调 $delta-$ 函子 $T$ 是泛的,如果对于任何其他的余调 $delta-$函子 $T'$ 和自然变换 $T^0 ->^f T'^0$,有唯一的自然变换族 $f^i : T^i -> T'^i$ 使得对于任何正合列
$
0 -> A -> B -> C -> 0
$
有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $T^i A$, 1),
node((0, 1), $T^i B$, 2),
node((0, 2), $T^i C$, 3),
node((0, 3), $T^(i+1) A$, 4),
node((1, 0), $T'^i A$, 5),
node((1, 1), $T'^i B$, 6),
node((1, 2), $T'^i C$, 7),
node((1, 3), $T'^(i+1) A$, 8),
arr(1, 2, $$),
arr(2, 3, $$),
arr(3, 4, $$),
arr(5, 6, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(1, 5, $f^i A $),
arr(2, 6, $f^i B$),
arr(3, 7, $f^i C$),
arr(4, 8, $f^(i+1 A)$),)]
]
#definition[effaceable][
称函子 $F$ 是 effaceable 的,如果对于任意 $A in CC$,存在一个单同态 $u: A -> M$ 使得 $F u = 0$\
对偶的,称 $F$ 是 co-effaceable 的,如果对于任意 $A in CC$,存在一个满同态 $v: A -> M$ 使得 $F v = 0$
]
#lemma[][
设 $CC$ 有足够多内射对象,$F$ 左正合,则$R^i F$ 是 effaceable 的
]
#proof[
将 $A$ 嵌入内射对象 $I$,用 $R^i F$ 作用产生:
$
R^i F A -> R^i F I = 0
$
当然就意味着 $F (A -> I) = 0$
]
#lemma[][
设 $T$ 是余调 $delta-$函子,$T^0 = F$,若 $T^i, i >= 1$ 是 effaceable 的,则 $T$ 是泛余调 $delta-$函子
]
#proof[
设 $T^i$ 是另一族余调 $delta-$函子以及 $T^0 ->^(f^0) T'^0$,归纳构造 $f^n$,假设已经有对于任何短正合列:
$
0 &-> A &&->^() B &&->^() C &&-> 0
$
有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $T^i C$, 1),
node((0, 1), $T^(i+1) A$, 2),
node((1, 0), $T'^i C$, 3),
node((1, 1), $T'^(i+1) A$, 4),
arr(1, 2, $delta^i$),
arr(1, 3, $f_A^i$),
arr(2, 4, $f_C^i$),
arr(3, 4, $$),)]
其中 $i = 0, 1, ..., n-1$\
想法是利用条件进行降维,对于 $n$ ,选取 $u: A -> M$ 是单态射且 $T^n u = 0$,有短正合列:
$
0 &-> A &&->^() M &&->^() A quo M &&-> 0
$
用 $T$ 进行作用,得到:
#align(center)[#commutative-diagram(
node((0, 0), $T^(n-1) M$, 1),
node((0, 1), $T^(n-1) M quo A$, 2),
node((0, 2), $T^n A$, 3),
node((1, 0), $T'^(n-1) M$, 4),
node((1, 1), $T'^(n-1) M quo A$, 5),
node((1, 2), $T'^n A$, 6),
arr(1, 2, $$),
arr(2, 3, $$),
arr(4, 5, $$),
arr(5, 6, $$),
arr(1, 4, $$),
arr(2, 5, $$),
arr(3, 6, $exists f_(A, u)^n$),)]
其中可以证明 $T^(n-1) M quo A -> T^n A$ 是满射,$f$ 追图可得,需要验证它与 $u$ 无关,再找 $A ->^v N$,有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $M$, 2),
node((1, 0), $N$, 3),
node((1, 1), $coker ((u, -v): A -> M directSum N)$, 4),
arr(1, 2, $u$),
arr(1, 3, $v$),
arr(2, 4, $$),
arr(3, 4, $$),
arr(1, 4, $omega$)
)]
显然 $T^n omega = 0$,往证 $f_u = f_omega$(对称的,有 $f_omega = f_v$),首先有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $M$, 2),
node((0, 2), $M quo A$, 3),
node((1, 0), $A$, 4),
node((1, 1), $L$, 5),
node((1, 2), $L quo A$, 6),
arr(1, 2, $$),
arr(2, 3, $$),
arr(4, 5, $$),
arr(5, 6, $$),
arr(1, 4, $$),
arr(2, 5, $$),
arr(3, 6, $$),)]
由于上下都是短正合列,用 $T$ 作用于其上,再追图即可
再证明 $f_A^n$ 是具有函子性的,也即给定 $u: A -> B$,考虑交换图:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $M$, 2),
node((0, 2), $M quo A$, 3),
node((1, 0), $B$, 4),
node((1, 1), $N$, 5),
node((1, 2), $N quo B$, 6),
arr(1, 2, $$),
arr(2, 3, $$),
arr(4, 5, $$),
arr(5, 6, $$),
arr(1, 4, $$),
arr(2, 5, $$),
arr(3, 6, $$),)]
其中 $N$ 是用类似上面的在直和中取余核构造得到的,之后的证明是类似的
最后,证明 $f^n$ 与 $delta$ 有交换性,任取短正合列:
$
0 &-> A &&->^() B &&->^() C &&-> 0
$
选取 $v: B -> M$ 使得 $T^n v = 0$,有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $B$, 2),
node((0, 2), $C$, 3),
node((1, 0), $A$, 4),
node((1, 1), $M$, 5),
node((1, 2), $M quo A$, 6),
arr(1, 2, $$),
arr(2, 3, $$),
arr(4, 5, $$),
arr(5, 6, $$),
arr(1, 4, $$),
arr(2, 5, $$),
arr(3, 6, $$),)]
以 $T$ 作用于其上,之后的证明也是类似的
]
#theorem[][
- $R^i F$ 是泛余调 $delta-$函子
- 任何泛余调 $delta-$函子都同构于 $R^i F$
]
#proof[
第一个结论是前两个引理的推论,第二个结论来自于泛余调 $delta-$函子的唯一性(这是容易证明的)
]
== Tor 与 Ext
设 $R$ 是交换环,$A, B in Mod_R$\
#definition[][
$
Tor_i (M, N) = L_i (- tensorProduct N) (M)\
= H^(-i) ( ... -> M tensorProduct P^(-2) -> M tensorProduct P^(-1) -> M tensorProduct P^0 -> 0)\
= H_i (... -> M tensorProduct P_(2) -> M tensorProduct P_(1) -> M tensorProduct P_0 -> 0)
$
]
#definition[][
$
Ext^i (M, N) = (R^i Hom (*, N)) (M)\
$
这里 $Hom (*, N)$ 是反变函子
]
显然,$Hom, tensorProduct$ 都是二元函子,为了证明上述导出函子也是二元函子(也就是与先选取谁无关),需要用到下面的平衡性:
#definition[][
设 $T: C_1 times ... times C_(n)$,其中 $C_n$ 可能是 $C$ 或者 $C_("op")$\
若它左正合,且满足:
- 若 $T^i$ 是共变的,则只要该分量取任意内射对象,则函子正合
- 若 $T^i$ 是反变的,则只要该分量取任意投射对象,则函子正合
则称 $T$ 是右平衡的,类似的可以对右正合函子定义左平衡
]
#lemma[][
$
Hom(M_1, M_2), Hom(M_1 tensorProduct M_2, M_3)
$
都是右平衡的\
$tensorProduct$ 是左平衡的
]
#theorem[][
对于右平衡,左正合函子 $T$,有:
$
R^i T(A_1, ..., A_(i-1), *, A_(i+1), ..., A^n) (A_i)
$
与 $i$ 取值无关
]
#proof[
需要用到谱序列,不证明
]
#example[][
设 $C$ 是 Abel 群构成的范畴,考虑:
$
Tor_i (Z quo p, B)
$
注意到有投射解消:
$
0 -> ZZ ->^p ZZ -> ZZ quo p -> 0
$
进而:
$
Tor_i (Z quo p, B) = H_i (0 -> B ->^p B -> 0)
$
可得:
$
Tor_i (Z quo p, B) = cases(
B quo p B quad i = 0,
{b in B | p b = 0} quad i = 1,
0 quad i > 1
)
$
]
#proposition[][
设 $A, B$ 是交换群,则:
- $Tor_1 (A, B)$ 是 torsion group
- $Tor_i (A, B) = 0, i > 1$
- 既然 $QQ quo ZZ = union Z quo n ZZ$,有 $Tor_1 (QQ quo ZZ, B) = B_("tor")$
- 无挠群都平坦
]
#proposition[][
对于张量积函子,平坦模是 acyclic ,既然:
$
L_i F(N) = 0 <=> Tor_i (M, N) = 0, forall i > 0
$
进而计算 $Tor$ 可以使用平坦解消
]
#lemma[][
- $M$ 是内射对象当且仅当 $Ext^1 (*, M) = 0$
- $M$ 是投射对象当且仅当 $Ext^1 (M, *) = 0$
]
#proof[
任取短正合列用 $Ext$ 作用即可
]
#example[][
- 设 $A, B$ 是 Abel 范畴中的对象,则 $Ext^n (A, B) = 0, forall n >= 2$
- 对于 $ZZ quo p$ 有投射解消:
$
0 -> ZZ ->^p ZZ -> ZZ quo p -> 0
$
由定义有:
$
Ext^n (ZZ quo p, B) = H^n (0 -> Hom(ZZ, B) -> Hom(ZZ, B))
$
- $Ext(ZZ, A) = 0$
- 为了计算 $Ext(A, ZZ)$ 对 $ZZ$ 有内射解消:
$
0 -> ZZ -> QQ -> QQ quo ZZ -> 0
$
因此:
$
Ext^n (A, ZZ) = H^n (0 -> Hom(A, QQ) -> Hom(A, QQ quo ZZ) -> 0)
$
假设 $A$ 是挠群,则 $Hom(A, ZZ) = 0 = Hom (A, QQ)$,则此时:
$
Ext^0 = 0\
Ext^1 (A, ZZ) = Hom (A, QQ quo ZZ)
$
]
#proof[
将 $B$ 嵌入内射对象 $I$,有正合列:
$
0 -> B -> I -> I quo B -> 0
$
然而由@injective-divisible 可得 $I quo B$ 也是内射的,进而结论成立
]
#definition[][
称 $B$ 是 $A$ 的扩张,如果有短正合列:
$
0 -> A -> X -> B -> 0
$
称两个扩张等价,如果有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $0$, 1),
node((0, 1), $A$, 2),
node((0, 2), $X$, 3),
node((0, 3), $B$, 4),
node((0, 4), $0$, 5),
node((1, 0), $0$, 6),
node((1, 1), $A$, 7),
node((1, 2), $Y$, 8),
node((1, 3), $B$, 9),
node((1, 4), $0$, 10),
arr(1, 2, $$),
arr(2, 3, $$),
arr(3, 4, $$),
arr(4, 5, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(8, 9, $$),
arr(9, 10, $$),
arr(2, 7, $$, bij_str),
arr(3, 8, $$),
arr(4, 9, $$, bij_str),
)]
由 5-lemma,此时一定有 $X tilde.eq Y$\
称 $eta$ 是分裂的,如果 $eta$ 等价于:
$
0 &-> A &&->^() A directSum B &&->^() B &&-> 0
$
]
#lemma[][
对于正合列:
$
eta: 0 -> A -> X -> B -> 0
$
可得长正合列:
$
0 &-> Hom (B, A) &&->^() Hom (B, X) &&->^() Hom (B, B) &&->^delta Ext^1 (B, A) -> ...
$
注意到 $id_B in Hom (B, B)$ 可以诱导 $delta_eta (id_A)$\
这就构造了所有扩张 $eta$ 到 $Ext^1 (B, A)$ 的映射。可以证明这是双射\
特别的,若 $Ext^1 (B, A) = 0$,则任意扩张都是分裂的
]
== 三角范畴与导出范畴
设 $AA$ 是 Abel 范畴,令 $C(AA)$ 是复形构成的范畴,$K(AA)$ 是复形范畴商掉同伦关系。 对于任何加性函子 $F: AA -> AA$,它当然保持同伦也因此可以延拓到 $K(AA)$ 上。不幸的是,$K(AA)$ 不是 Abel 范畴,不能自由的取 $ker, coker$,但它可以产生一个三角范畴。
#definition[三角范畴][
设 $K$ 是加性范畴,称 $K$ 是三角范畴,如果它具有自同构 $T = [1] : K -> K$9有时称为 translation functor)以及一族三角形 $A -> B -> C -> A [1]$(也称为正合三角形),要求满足:
+ 每个态射 $f: A -> B$ 可被延拓成正合三角形 $A -> B -> C -> A[1]$\
特别的,$A ->^id A -> 0 -> A[1]$ 是正合三角形,同时同构于正合三角形的三角形也正合
+ 设 $A -> B -> C -> A [1]$ 是正合三角形,则旋转:
$
B -> C -> A[1] ->^(-(A -> B)[1]) B[1]\
C[-1] ->^(-(C -> A[1])[-1]) -> A -> B -> C
$
是正合三角形
+
设有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $B$, 2),
node((0, 2), $C$, 3),
node((0, 3), $A[1]$, 4),
node((1, 0), $A'$, 5),
node((1, 1), $B'$, 6),
node((1, 2), $C'$, 7),
node((1, 3), $A'[1]$, 8),
arr(1, 2, $$),
arr(2, 3, $$),
arr(3, 4, $$),
arr(5, 6, $$),
arr(6, 7, $$),
arr(7, 8, $$),
arr(1, 5, $f$),
arr(2, 6, $$),
arr(4, 8, $f[1]$),)]
其中上下行都是正合三角形,则存在 $C -> C'$ 的态射使得图表交换。
+ 对于交换的三角形:
#align(center)[#commutative-diagram(
node((0, 0), $A$, 1),
node((0, 1), $B$, 2),
node((1, 0), $C$, 3),
arr(1, 2, $$),
arr(3, 2, $$),
arr(1, 3, $$),)]
沿着三边分别向外延拓出正合三角形,则延拓的第三项“共线”,也即可延拓出正合三角形。
]
#definition[拟同构][
称 $E -> F$ 是拟同构,如果 $forall n, H^n (E) tilde.eq H^n (F)$
]
#definition[局部化][
设 $C$ 是范畴,$S$ 是 $C$ 中一些态射的集合。称 $C$ 关于 $S$ 的局部化是范畴 $Inv(S) C$ 以及函子 $Inv(S): C -> Inv(S) C$,满足:
- $forall s in S, Inv(S) s$ 是同构
- 有泛性质:若 $F s$ 对于所有 $s in S$ 都是同构,则有交换图:
#align(center)[#commutative-diagram(
node((0, 0), $CC$, 1),
node((0, 1), $DD$, 2),
node((1, 0), $Inv(S) CC$, 3),
arr(1, 2, $F$),
arr(3, 2, $exists !$),
arr(1, 3, $Inv(S)$),)]
]
#remark[][
之前构造 $Inv(S) R$ 时,可以将 $R$ 视作范畴,其中 $Ob$ 只有一个元素,$Hom(*, *) = R$,这样局部化的概念就是一致的
]
#theorem[][
范畴的局部化总是存在的
]
#definition[][
称 $S$ 是乘性系统,如果:
- $S$ 包含所有 $id$
- $S$ 在复合下封闭
- 对于任何交换图:
#align(center)[#commutative-diagram(
node((0, 0), $X$, 1),
node((0, 1), $Y$, 2),
node((1, 0), $Z$, 3),
arr(1, 2, $$),
arr(3, 2, $t in S$),
)]
存在交换图:
#align(center)[#commutative-diagram(
node((0, 0), $W$, 1),
node((0, 1), $Z$, 2),
node((1, 0), $X$, 3),
node((1, 1), $Y$, 4),
arr(1, 2, $$),
arr(1, 3, $$),
arr(2, 4, $$),
arr(3, 4, $$),)]
类似于 $Inv(t) g = g Inv(s)$
- 有消去律:\
设 $f, g : X -> Y$,以下条件等价:
- $exists s in S, s f = s g$
- $exists s in S, f t = g t$
]
#theorem[Gabriel-Zisman][
设 $S$ 是乘性系统,则 $Inv(S) CC$ 可以被显式构造:
- $Ob(Inv(S) CC) = Ob (CC)$
- $Hom (X, Y) = {f Inv(t) : X <-^t X' -> Y} quo tilde$
其中 $ X <-^t_1 X'_1 -> Y$ 与 $ X <-^t_2 X'_2 -> Y$ 等价当今仅当存在 $ X <-^t_3 X'_3 -> Y$ 以及 $X_3 -> X_1, X_3 -> X_2$,并构成交换图
则这确实是范畴,且就是 $Inv(S) CC$,对应函子是:
$
funcDef(q, CC, Inv(CC), (X ->^f Y), (X ->^id X ->^f Y))
$
]
#definition[][
对于任意 Abel 范畴 $AA$,则 $K(AA)$ 是三角范畴,取 $S$ 为其中所有拟同构,则可以验证它是乘性系统,做商得到的范畴称为导出范畴。它包含了所有同调群的信息。
]
#lemma[][
设 $F: A -> B$ 是加性函子,则自然的拓展到 $K(A) ->^F K(B)$
- 若 $F$ 是正合函子,则 $F$ 保持同调群同构,当然就可以延拓到 $D(A) -> D(B)$
- 若 $F$ 不是正合函子,一般不能直接进行延拓
]
#definition[][
设 $q: K(A) -> D(A)$ 称 $F$ 的(全)右导出函子是指 $R F: D^* (AA) -> D^* (B)$ 以及自然变换 $xi: q F -> R F q$,并满足泛性质:对于任意 $G: D(A) -> D(B), eta: q F -> G q$,都有自然变换 $epsilon$ 使得 $epsilon xi = eta$(换言之,这是某种最小的延拓)。
既然由泛性质给出,故只要存在右导出就是唯一的
]
#theorem[][
若 $AA$ 有足够多的内射对象,则 $R F$ 存在,且满足若 $I$ 是内射对象的有界复形,则:
$
R F(I) tilde.eq q F(I) => H^n (R F(A)) tilde.eq R^n F(A)
$
]
#definition[Kan extension][
设 $F: AA -> BB, G: CC -> DD$,一个 $F$ 沿着 $G$ 的左 Kan-extension 是指:
- 函子 $K: DD -> BB$
- 自然变换 $alpha: F -> K G$
并且是这样的二元组组成范畴的始对象。
对偶的,可以定义右 Kan-extension
]
#example[][
余极限、极限可以实现成左、右 Kan 延拓。考虑:
#align(center)[#commutative-diagram(
node((0, 0), $CC$, 1),
node((0, 1), $0$, 2),
node((1, 0), $DD$, 3),
arr(1, 2, $$),
arr(1, 3, $F$),)]
]
则 $F$ 沿着 $0$ 的左 Kan 延拓是 $(K: 0 -> DD, alpha: F -> K 0)$ 并满足泛性质。事实上,$K$ 只有一个像,记作 $"colim" F$,而自然变换就是交换图:
#commutative-diagram(
node((0, 0), $F A$, 1),
node((0, 1), $F B$, 2),
node((1, 0), $"colim" F$, 3),
arr(1, 2, $$),
arr(3, 2, $$),
arr(1, 3, $$),)
始对象对应的就是余极限的泛性质
|
|
https://github.com/Mc-Zen/tidy | https://raw.githubusercontent.com/Mc-Zen/tidy/main/examples/wiggly-doc.typ | typst | MIT License | #import "/src/tidy.typ": *
#import "wiggly.typ"
#let docs = parse-module(
read("/examples/wiggly.typ"),
name: "wiggly",
scope: (wiggly: wiggly),
preamble: "import wiggly: *;"
)
#show-module(docs, style: styles.minimal)
|
https://github.com/isaacholt100/isaacholt100.github.io | https://raw.githubusercontent.com/isaacholt100/isaacholt100.github.io/master/maths-notes/2-durham%3A-year-2/dssc/dssc.typ | typst | #import "../../template.typ": template
#show: template
= Introduction
- $29$
- By Central Limit Theorem, if sample $(x_1, ..., x_n)$ with each $X_i tilde.op D(mu, sigma^2)$ ($D$ is some distribution) then as $n -> oo$, $ overline(X) tilde.op N(mu, sigma^2 / n) $ So distribution of sample mean always tends to normal distribution, with standard deviation $sigma \/ sqrt(n)$.
- *Unbiased estimate of standard deviation of sample mean*: $ s = sqrt(1 / (n - 1) sum_(i = 1)^n (x_i - overline(x))^2) $
- *Standard error of sample mean*: estimate of standard deviation of sample mean: $s \/ sqrt(n)$.
- If $n$ too small then $s$ is poor estimator and mean may not be normally distributed.
- If population distribution is normal and $n$ small then sample mean is $t$-distributed: $ (X - mu) / (s \/ sqrt(n)) tilde.op t_(n - 1) $ $(X - mu) / (s \/ sqrt(n))$ is *pivotal quantity* as distribution doesn't depend on parameters of $X$.
- *Hypothesis test* for $underline(x)$:
- Define *null hypothesis* which identifies distribution believed to have generated each $x_i$.
- Choose *test statistic* $h$ (function of $underline(x)$), extreme when null is false, not extreme when null is true.
- *Observed test statistic* is $t = h(underline(x))$.
- Determine how extreme $t$ is as a realisation of $T = h(X_1, ..., X_N)$ (so need to know distribution of $T$).
- *One sided $p$-value*: $ PP(T >= t | H_0 "true") quad "or" quad PP(T <= t | H_0 "true") $
- *Two sided $p$-value*: $ PP(T >= |t| union T <= -|t| | H_0 "true") $
= Monte Carlo testing
- *Monte Carlo testing*: given observed test stat $t = h(underline(x))$, distribution $F(x | theta)$, hypotheses $H_0: theta = theta_0$, $H_1: theta > theta_0$:
- For $j in {1, ..., N}$:
- Simulate $n$ observations $(z_1, ..., z_n)$ from $F(dot.op | theta_0)$.
- Compute $t_j = h(z_1, ..., z_n)$.
- Estimate $p$-value by $ P(T >= t | H_0 "true") approx hat(p) = 1/N sum_(j = 1)^N II{t_j >= t} $
- *Resampling risk*: probability that Monte Carlo simulated $p$-value and true $p$-value are on different sides of significance threshold $alpha$ (situation where Monte Carlo test is incorrect): $ "resampling risk" = cases(
PP(hat(p) > alpha) & "if" p <= alpha,
PP(hat(p) <= alpha) & "if" p > alpha
) $
= The bootstrap
- *The non-parametric bootstrap estimate*: given independent data $underline(x) = (x_1, ..., x_n)$ and stat $S(dot.op)$, *resample* (draw samples of size $n$ with replacement) $underline(x)$ $B$ times to give $underline(x)^(* 1), ..., underline(x)^(* B)$. To compute *bootstrap estimate of standard error of $S$*, compute $ hat("Var")(S(underline(x))) = 1/(B - 1) sum_(b = 1)^B (S(underline(x)^(* b)) - overline(S)^*)^2 $ where $ overline(S)^* = 1/B sum_(b = 1)^B S(underline(x)^(* b)) $ The standard error estimate is then $sqrt(hat("Var")(S(underline(x))))$, i.e. the standard deviation of $S(underline(x)^(* 1)), ..., S(underline(x)^(* B))$ The *bootstrap estimate* of $S$ is simply $S(underline(x))$.
- For random variable $X$, *(cumulative) distribution function (cdf)* $F: RR -> [0, 1]$ is $ F_X(x) = F(x) := PP(X <= x) $
- Properties of cdf:
- $lim_(x -> -oo) F(x) = 0$ and $lim_(x -> oo) F(x) = 1$.
- *Monotonicity*: $x' < x ==> F(x') <= F(x)$.
- *Right-continuity*: $lim_(t -> x^+) F(t) = F(x)$.
- Given data $(x_1, ..., x_n)$ with each sample i.i.d. realisation of random variable $X$, *empirical (cumulative) distribution function (ecdf)* is $ hat(F)(x) := 1/n sum_(i = 1)^n II{x_i <= x} $
- *Glivenko-Cantelli theorem*: Let $X_1, ..., X_n$ be random sample from distribution with cdf $F$. Then $ sup_(x in RR)|hat(F)(x) - F(x)| -> 0 quad "as" n -> oo $
- Given data $(x_1, ..., x_n)$, sampling uniformly at random from $underline(x)$ is equivalent to sampling from distribution with cdf defined as ecdf constructed from $underline(x)$.
- For mean of sample of $m$ draws from ecdf constructed from $n$ data points, expectation and variance are $ EE[overline(Y)] = overline(x), quad "Var"(overline(Y)) = (n - 1)/n s_x^2 / m $
- If $S$ is the mean, $hat("Var")(S(underline(x)) -> (n - 1)/n s^2 / n$ as $B -> oo$.
- If *sampling fraction* $f = n/N$ where $N$ population size, $n$ sample size, is $f >= 0.1$, can't assume infinite population.
- Given finite population of size $N$, mean $overline(X)$ of sample drawn uniformly at random without replacement has variance $ "Var"(overline(X)) = (N - n) / (N - 1) sigma^2 / n $ where $sigma^2$ is true population variance.
- Given finite population of size $N$, sample of size $n$ with variance $S^2$ drawn without replacement, $ EE[(1 - n/N) S^2/n] = "Var"(overline(X)) $ so it is unbiased estimator of $"Var"(overline(X))$
- *Population bootstrap*: given independent data $(x_1, ..., x_n)$ drawn from finite population of size $N$, assuming $N\/n = k$ is integer, construct new data set $ tilde(underline(x)) = (x_1, ..., x_n, x_1, ..., x_n, ..., x_1, ..., x_n) $ by repeating $underline(x)$ $k$ times. Then construct $B$ new samples $underline(x)^(* 1), ..., underline(x)^(* B)$ by sampling without replacement. Then compute $ hat("Var")(S(underline(x))) = 1/(B - 1) sum_(b = 1)^B (S(underline(x)^(* b)) - overline(S)^*)^2 $ where $ overline(S)^* = 1/B sum_(b = 1)^B S(underline(x)^(* b)) $ If $N \/ n$ not integer, $N = k n + m$ for $0 < m < n$, then before each of the $B$ samples, append to $tilde(underline(x))$ a sample without replacement of size $m$ from $underline(x)$.
- If data believed to follow type of distribution, can use *parametric bootstrap*: given independent data $(x_1, ..., x_n)$, believed to be drawn from distribution $F(dot.op, theta)$ with parameter $theta$:
- Find maximum likelihood estimator $hat(theta)$.
- Draw $B$ new samples of size $n$ from $F(dot.op, hat(theta))$ to give $underline(x)^(* 1), ..., underline(x)^(* B)$.
- Compute $ hat("Var")(S(underline(x))) = 1/(B - 1) sum_(b = 1)^B (S(underline(x)^(* b)) - overline(S)^*)^2 $ where $ overline(S)^* = 1/B sum_(b = 1)^B S(underline(x)^(* b)) $
- For parameter $theta$ of distribution, estimated by statistic $S$, with $hat(theta) = S(underline(x))$, *bias* is $ "bias"(theta, hat(theta)) = EE[hat(theta)] - theta $
- *Basic bootstrap bias estimate*: $ hat("bias")(theta, hat(theta)) = overline(S)^* - hat(theta) = 1/B sum_(b = 1)^B S(underline(x)^(* b)) - S(underline(x)) $
- *Bias correction*: subtract bias from usual estimate: $ hat(theta) - hat("bias")(theta, hat(theta)) = 2 hat(theta) - overline(S)^* $ But often $2 hat(theta) - overline(S)^*$ has higher variance as estimator than $hat(theta)$.
- *Normal confidence interval for bootstrap estimate*: $100(1 - alpha)%$ confidence interval is $ hat(theta) plus.minus z_(alpha \/ 2) sqrt(hat("Var")(S(underline(x)))) $ where $z_(alpha \/ 2)$ is $100(alpha \/ 2)%$ percentile of standard normal distribution. *Note*: only valid if size of data large enough, need to check for normality of bootstrap samples using quantile plot.
- *Percentile confidence interval*: use if $hat(F)$ close to true distribution. $100(1 - alpha)%$ confidence interval is $ [S_(((alpha \/ 2) B))^*, S_(((1 - alpha \/ 2) B))^*] $ where $S_((i))^*$ is $i$th largest value of $S(underline(x)^(* b))$ for $b = 1, ..., B$. $B$ must be chosen to make $(alpha \/ 2) B$ and $(1 - alpha \/ 2) B$ integers. $B$ must be $> 2000$ for this to be good estimate. *Note*: inaccurate if bias or non-constant standard error or distribution of $S(X) | theta$ isn't symmetric.
- *BC (bias corrected)* and *BCa (bias corrected and accelerated)* confidence intervals make adjustments when bias is present or there is non-constant standard error.
= Monte Carlo integration
- Let random variable $Y$ take values in sample space $Omega$ with pdf $f_Y$, then $ mu := EE[Y] = integral_Omega y f_Y(y) dif y $
- $mu$ approximated by $ hat(mu)_n = 1/n sum_(i = 1)^n Y_i $ for i.i.d. samples $Y_i$.
- If $Y = g(X)$ with $X$ random variable with pdf $f_X$, then $ mu = EE[Y] = EE[g(X)] = integral g(x) f_X(x) dif x $
- To estimate $integral_a^b f(x) dif x$, use $X ~ "Unif"(a, b)$ $ mu = integral_a^b f(x) dif x = integral_a^b (b - a) f(x) 1/(b - a) dif x = integral_a^b (b - a) f(x) f_X(x) dif x = EE[(b - a) f(X)] $ which can be estimated by $ hat(mu)_n = (b - a) 1/n sum_(i = 1)^n f(X_i) $ for i.i.d. samples $X_i$.
- If $"Var"(Y) = sigma^2 < oo$, Monte Carlo integration unbiased as $EE[hat(mu)_n] = mu$.
- *Mean-square error*: $"Var"(hat(mu)_n) = EE[(hat(mu)_n - mu)^2] = sigma^2 / n$.
- *Root mean-square error*: $"RMSE" = sqrt(EE[(hat(mu)_n - mu)^2]) = sigma / sqrt(n)$.
- $"RMSE"$ is $O(n^(-1\/2))$.
- For functions $f, g$, $f(n) = O(g(n))$ as $n -> oo$ if exist $C, n_0 in RR$ such that $ forall n >= n_0, quad |f(n)| <= C g(n) $
- *Midpoint Riemann integral estimate*: $ integral_a^b f(x) dif x = (b - a) / n sum_(i = 1)^n f(x_i) $ where $ x_i = a + (b - a)/n (i - 1/2) $
- For $d$ dimensions, Riemann sum converges in $O(n^(-2\/d))$, Monte Carlo converges in $O(n^(-1\/2))$ regardless of $d$.
- $100(1 - alpha)%$ confidence interval for Monte Carlo integration: $ mu in hat(mu)_n plus.minus z_(alpha \/ 2) sigma / sqrt(n) $ where $sigma$ estimated with standard sample deviation of ${y_i} = {g(x_i)}$.
- If $g(x)$ constant multiple of indicator function, $g(x) = c II{A(x)}$ for condition $A$, then $ hat(p)_n = 1/n sum_(i = 1)^n II{A(x_i)} $ is estimator for $p = PP(A)$. Binomial confidence interval is $ p in hat(p)_n plus.minus z_(alpha \/ 2) sqrt((hat(p)_n (1 - hat(p)_n)) / n) $ so confidence interval for $mu$ is $ mu in hat(mu)_n plus.minus c z_(alpha \/ 2) sqrt((hat(p)_n (1 - hat(p)_n)) / n) $ ($hat(mu)_n = c hat(p)_n$).
- Probability of no $1$s in $n$ Monte Carlo samples is $(1 - p)^n$ so one-sided $100(1 - alpha)%$ confidence interval has upper bound $p <= 1 - alpha^(1\/n) approx -log(alpha) / n$ using Taylor expansion.
- If $hat(p)$ very small and non-zero, $ c z_(alpha \/ 2) sqrt((hat(p)_n (1 - hat(p)_n)) / n) approx c z_(alpha \/ 2) sqrt((hat(p)_n) / n) $ so relative error is $ delta := c z_(alpha \/ 2) sqrt((hat(p)_n) / n) \/ hat(p) = (c z_(alpha \/ 2)) / sqrt(hat(p)_n n) $ for relative error at most $delta$, $ n >= (c^2 z_(alpha \/ 2)^2) / (hat(p)_n delta^2) $ so $n$ grows inversely with $hat(p)_n$.
- To estimate probability of event $PP(X in E)$, Monte Carlo estimate $EE[II{X in E}]$.
= Simulation
- Let $F$ cdf, then *generalised inverse cdf* is $ F^(-1)(u) := inf{x: F(x) >= u} $
- *Inverse transform sampling algorithm*: let random variable $X$ with cdf $F$, with generalised inverse $F^(-1)$.
- Simulate $U tilde.op "Unif"(0, 1)$.
- Compute $X = F^(-1)(U)$.
$X$ is then distributed with cdf $F$. Only works for 1D distributions.
- *Rejection sampling algorithm*: given *target density* function $f$, *proposal density* function $tilde(f)$ with $forall x in RR^d, f(x) <= c tilde(f)(x)$ for some $c < oo$,
- Set $a = "false"$
- While $a = "false"$:
- Simulate $u tilde.op "Unif"(0, 1)$.
- Simulate $x tilde.op tilde(f)(dot.op)$.
- If $u <= f(x) / (c tilde(f)(x))$, set $a = "true"$.
- Once while loop exited, return $x$, which is distributed with pdf $f$.
- *Note*: $f$ and $tilde(f)$ don't need to be normalised.
- When $f, tilde(f)$ normalised, expected number of iterations of rejection sampling algorithm is $c$.
- *Important*: when choosing value of $c$, always round *up* if inexact.
- When checking if rejection sampling can be used, check if ratio $f(x) \/ tilde(f)(x)$ tends to $0$ as $x -> plus.minus oo$ and differentiate ratio with respect to $x$ to find maximum.
- *Normalised importance sampling*: given normalised density function $f$ and normalised proposal density function $tilde(f)$, $n$ importance samples produced by: for $i in {1, ..., n}$:
- Simulate $x_i tilde.op tilde(f)(dot.op)$.
- Compute $w_i = f(x_i) \/ tilde(f)(x_i)$.
This produces importance samples ${(x_i, w_i)}_(i = 1)^n$. $mu = EE_(tilde(f))[g(X)]$ estimated by *importance sampling estimator* $ hat(mu) = 1/n sum_(i = 1)^n w_i g(x_i) $ ($EE_(tilde(f))[hat(mu)] = mu$, provided $tilde(f)(x) > 0$ whenever $f(x) g(x) != 0$).
- Variance of importance sampling estimator is $ "Var"(hat(mu)) = (sigma_(tilde(f))^2) / n $ where $ sigma_(tilde(f))^2 = integral_(tilde(Omega)) (g(x) f(x) - mu tilde(f)(x))^2 / (tilde(f)(x)) dif x $ and $tilde(Omega)$ is support of $tilde(f)$.
- Can estimate variance with $ hat(sigma)_(tilde(f))^2 = 1/n sum_(i = 1)^n (w_i g(x_i) - hat(mu))^2 $
- Distribution which minimises estimator variance is $ tilde(f)_"opt"(x) = (|g(x)| f(x)) / (integral_Omega |g(x)| f(x) dif x) $
- *Self-normalised importance sampling*: same as normalised importance sampling, but compute $ hat(mu) = 1/(sum_(i = 1)^n w_i) sum_(i = 1)^n w_i g(x_i) $ Can use for unnormalised density functions $f, tilde(f)$. $hat(mu)$ is not unbiased.
- Approximate variance of self-normalised estimator: $ "Var"(hat(mu)) approx (hat(sigma)_(tilde(f))^2) / n $ where $ hat(sigma)_(tilde(f))^2 = sum_(i = 1)^n w_i'^2 (g(x_i) - hat(mu))^2 $ and $ w_i' = w_i / (sum_(j = 1)^n w_j) $
- *Effective sample size $n_e$*: size of sample for which variance of naive Monte Carlo average $(1/n_e sum_(i = 1)^(n_e) g(x_i))$ with sample size $n_e$, $sigma^2 \/ n_e$ ($sigma^2$ is variance of $g(X)$), is equal to variance of importance sampling estimator $hat(mu)$, $"Var"(hat(mu))$: $ n_e = (n overline(w)^2) / overline(w^2) $ where $ overline(w)^2 = (1/n sum_(i = 1)^n w_i)^2, quad overline(w^2) = 1/n sum_(i = 1)^n w_i^2 $
- Small $n_e$ means importance sampling is poor estimator.
- Poor estimator if proposal distribution has much less probability in tails than target distribution. |
|
https://github.com/OverflowCat/astro-typst | https://raw.githubusercontent.com/OverflowCat/astro-typst/master/README.md | markdown | # `astro-typst`
An Astro Integration that lets you render Typst within Astro.
<img src="https://github.com/user-attachments/assets/613eaf8e-53da-4cf0-bbaa-f32592d7f742" alt="Demo" width="400" />
## Features
- [x] Import packages in [Typst Universe](https://typst.app/universe/)
- [x] `import` / `include` / `read` files or resources
- [x] Use system fonts
- [x] Selectable, clickable text layer
- [x] Set scale
- [x] Static SVGs without JavaScript
- [ ] Responsive SVGs
- [ ] Add font files or blobs
- [x] [Content collections](https://docs.astro.build/en/guides/content-collections/)
## Installation
```bash
npm install astro-typst
# or
pnpm add astro-typst
# or
yarn add astro-typst
```
## Usage
### As an integration
```js
// astro.config.mjs
import { typst } from 'astro-typst';
... // other imports
export default defineConfig({
integrations: [/** other integrations */ ..., typst()],
});
```
Then you can use `.typ` files just like anything else in Astro: render directly by router, or import in another file.
### As a component
To use the component, you need to manually install a dependency to avoid SSR errors:
```
npm install @myriaddreamin/typst-ts-node-compiler
# or
pnpm add @myriaddreamin/typst-ts-node-compiler
# or
yarn add @myriaddreamin/typst-ts-node-compiler
```
and add this to your `/astro.config.(t|j)s/`:
```diff
export default defineConfig({
...,
vite: {
ssr: {
- external: [...],
+ external: [..., "@myriaddreamin/typst-ts-node-compiler"],
},
...,
},
...,
});
```
Then, you can pass either one of `code | src | input` to the component:
```astro
---
import { Typst } from "astro-typst/src/components";
const code = `
#set page(margin: 1em)
#let typst = {
text(font: "Linux Libertine", weight: "semibold", fill: eastern)[typst]
}
#show "Typst": typst
== Typst: Compose paper faster
$ cases(
dot(x) = A x + B u = mat(delim: "[", 0, 0, dots.h.c, 0, - a_n; 1, 0, dots.h.c, 0, - a_(n - 1); 0, 1, dots.h.c, 0, - a_(n - 2); dots.v, dots.v, dots.down, dots.v, dots.v; 0, 0, dots.h.c, 1, - a_1) x + mat(delim: "[", b_n; b_(n - 1); b_(n - 2); dots.v; b_1) u,
y = C x = mat(delim: "[", 0, 0, dots.h.c, 1) x
) $
#set text(font: ("Garamond", "Noto Serif CJK SC"))
#import "@preview/tablem:0.1.0": tablem
#tablem[
| *English* | *German* | *Chinese* | *Japanese* |
| --------- | -------- | --------- | ---------- |
| Cat | Katze | 猫 | 猫 |
| Fish | Fisch | 鱼 | 魚 |
]
`;
---
<Typst code={code} />
```
### In content collections
See [demo](/src/content/).
#### Frontmatter
> [`metadata`](https://typst.app/docs/reference/introspection/metadata/) exposes a value to the query system without producing visible content.
Attach a label `frontmatter` to the metadata declaration:
```typ
#let desc = [$oo$ fun with `math`]
#metadata(
(
title: "Test page",
author: "Neko",
desc: desc,
date: datetime(
year: 2024,
month: 8,
day: 7,
),
)
)<frontmatter>
```
yields
```json
{
"title": "Test page",
"author": "Neko",
"desc": {
"children": [
{
"block": false,
"body": {
"func": "text",
"text": "∞"
},
"func": "equation"
},
{ "func": "space" },
{ "func": "text", "text": "fun with" },
{ "func": "space" },
{
"block": false,
"func": "raw",
"text": "math"
}
],
"func": "sequence"
},
"date": "datetime(year: 2024, month: 8, day: 7)"
}
```
## Development
### Playground
```bash
pnpm tsc -w
# in another terminal
pnpm dev
```
### Build package
```bash
pnpm compile
```
|
|
https://github.com/KrisjanisP/lu-icpc-notebook | https://raw.githubusercontent.com/KrisjanisP/lu-icpc-notebook/main/8-other.typ | typst |
= I'm running out of time
== Simulated annealing
```cpp
const ld T = (ld)2000;
const ld alpha = 0.999999;
// (new_score - old_score) / (temperature_final) ~ 10 works well
const ld L = (ld)1e6;
ld small_rand(){
return ((ld)gen(L))/L;
}
ld P(ld old, ld nw, ld temp){
if(nw > old)
return 1.0;
return exp((nw-old)/temp);
}
{
auto start = chrono::steady_clock::now();
ld time_limit = 2000;
ld temperature = T;
ld max_score = -1;
while(elapsed_time < time_limit){
auto cur = chrono::steady_clock::now();
elapsed_time = chrono::duration_cast<chrono::milliseconds>(cur - start).count();
temperature *= alpha;
// try a neighboring state
// ....
// ....
old_score = score(old_state);
new_score = score(new_state);
if(P(old_score, new_score, temperature) >= small_rand()){
old_state = new_state;
old_score = new_score;
}
if(old_score > max_score){
max_score = old_score;
max_state = old_state;
}
}
}
```
]
#columns(2)[
#block( breakable: false,[
== Eulerian Path
#image("./assets/eulerian-path.png", width: 100%)
])
#block(breakable: false)[
== Flows with demands
#image("./assets/flows-with-demands.png", width: 100%)
]
#block( breakable: false,[
== Point in convex polygon $O(log n)$
#image("./assets/point-in-convex-polygon.png", width: 100%)
```cpp
bool pointInTriangle(pt a, pt b, pt c, pt point) {
long long s1 = abs(a.cross(b, c));
long long s2 = abs(point.cross(a, b)) + abs(point.cross(b, c)) + abs(point.cross(c, a));
return s1 == s2;
}
void prepare(vector<pt> &points) {
n = points.size();
int pos = 0;
for (int i = 1; i < n; i++) {
if (lexComp(points[i], points[pos]))
pos = i;
}
rotate(points.begin(), points.begin() + pos, points.end());
n--;
seq.resize(n);
for (int i = 0; i < n; i++)
seq[i] = points[i + 1] - points[0];
translation = points[0];
}
```
])
#block(breakable: false,[
```cpp
bool pointInConvexPolygon(pt point) {
point = point - translation;
if (seq[0].cross(point) != 0 &&
sgn(seq[0].cross(point)) != sgn(seq[0].cross(seq[n - 1])))
return false;
if (seq[n - 1].cross(point) != 0 &&
sgn(seq[n - 1].cross(point)) != sgn(seq[n - 1].cross(seq[0])))
return false;
if (seq[0].cross(point) == 0)
return seq[0].sqrLen() >= point.sqrLen();
int l = 0, r = n - 1;
while (r - l > 1) {
int mid = (l + r) / 2;
int pos = mid;
if (seq[pos].cross(point) >= 0)
l = mid;
else
r = mid;
}
int pos = l;
return pointInTriangle(seq[pos], seq[pos + 1], pt(0, 0), point);
}
```
])
#block( breakable: false,[
== Minkowski sum of convex polygons
#image("./assets/minkowski-sum-1.png", width: 100%)
])
#block( breakable: false,[
#image("./assets/minkowski-sum-2.png", width: 100%)
```cpp
void reorder_polygon(vector<pt> & P){
size_t pos = 0;
for(size_t i = 1; i < P.size(); i++){
if(P[i].y < P[pos].y || (P[i].y == P[pos].y && P[i].x < P[pos].x))
pos = i;
}
rotate(P.begin(), P.begin() + pos, P.end());
}
vector<pt> minkowski(vector<pt> P, vector<pt> Q){
// the first vertex must be the lowest
reorder_polygon(P); reorder_polygon(Q);
// we must ensure cyclic indexing
P.push_back(P[0]); P.push_back(P[1]);
Q.push_back(Q[0]); Q.push_back(Q[1]);
vector<pt> result; size_t i = 0, j = 0;
while(i < P.size() - 2 || j < Q.size() - 2){
result.push_back(P[i] + Q[j]);
auto cross = (P[i + 1] - P[i]).cross(Q[j + 1] - Q[j]);
if(cross >= 0 && i < P.size() - 2) ++i;
if(cross <= 0 && j < Q.size() - 2) ++j;
}
return result
}
```
])
#block(breakable: false,[
== janY template
```cpp
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define rev(x) reverse(x.begin(),x.end())
#define fi first
#define se second
#define pb push_back
#define PI 3.14159265359
typedef pair<int,int> pii;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return a.second<b.second;}
#define sortpairbysec(x) sort(all(x), sortbysec)
bool sortcond(const pair<int,int> &a,const pair<int,int> &b){
if(a.fi!=b.fi) return a.fi<b.fi;
return a.se>b.se;
}
struct myComp {
constexpr bool operator()(pii const& a, pii const& b) const noexcept{
if(a.first!=b.first) return a.first<b.first;
return a.second>b.second;
}
};
const int mod=1000000007, N=3e5, M=N;
// & - AND; | - OR; ^ - XOR
vl a;
ll n,m,k,q;
void solve(int tc){
int i,j;
cin>>n;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t=1; cin>>t; int i;
fo(i,t) solve(i+1);
return 0;
}
```
])
] |
|
https://github.com/jamesrswift/pixel-pipeline | https://raw.githubusercontent.com/jamesrswift/pixel-pipeline/main/src/math/vector.typ | typst | The Unlicense | /// Returns a new vector of dimension `dim` with all fields set to `init` (defaults to 0).
///
/// - dim (int): Vector dimension
/// - init (float): Initial value of all fields
/// -> vector
#let new(dim, init: 0) = {
return range(0, dim).map(x => init)
}
/// Returns the dimension of a vector.
///
/// - v (vector): The vector to find the dimension of.
/// -> int
#let dim(v) = {
assert(
type(v) == array,
message: "Expected vector to be of array type, got: " + repr(v)
)
return v.len()
}
/// Converts a vector to a row or column matrix.
///
/// - v (vector): The vector to convert.
/// - mode (str): The type of matrix to convert into. Must be one of `"row"` or `"column"`.
/// -> matrix
#let as-mat(v, mode: "row") = {
if mode == "column" {
return (v,)
} else if mode == "row" {
return (for c in v { (c,) }, )
} else {
panic("Invalid mode " + mode)
}
}
/// Ensures a vector has an exact dimension. This is done by passing another vector `init` that has the required dimension. If the original vector does not have enough dimensions, the values from `init` will be inserted. It is recommended to use a zero vector for `init`.
///
/// - v (vector): The vector to ensure.
/// - init (vector): The vector to check the dimension against.
/// -> vector
#let as-vec(v, init: (0, 0, 0)) = {
for i in range(0, calc.min(dim(v), dim(init))) {
init.at(i) = v.at(i)
}
return init
}
/// Return length/magnitude of a vector.
///
/// - v (vector): The vector to find the magnitude of.
/// -> float
#let len(v) = {
return calc.sqrt(v.fold(0, (s, c) => s + c * c))
}
/// Adds two vectors of the same dimension
///
/// - v1 (vector): The vector on the left hand side.
/// - v2 (vector): The vector on the right hand side.
/// -> vector
#let add(v1, v2) = {
if dim(v1) != dim(v2) {
v1 = as-vec(v1)
v2 = as-vec(v2)
}
assert(dim(v1) == dim(v2), message: "Cannot add vectors, " + repr(v1) + " and " + repr(v2) + " are not of the same dimensions.")
return v1.zip(v2).map(((a, b)) => a + b)
}
/// Subtracts two vectors of the same dimension
///
/// - v1 (vector): The vector on the left hand side.
/// - v2 (vector): The vector on the right hand side.
/// -> vector
#let sub(v1, v2) = {
if dim(v1) != dim(v2) {
v1 = as-vec(v1)
v2 = as-vec(v2)
}
assert(dim(v1) == dim(v2), message: "Cannot subtract vectors, " + repr(v1) + " and " + repr(v2) + " are not of the same dimensions.")
return v1.zip(v2).map(((a, b)) => a - b)
}
/// Calculates the distance between two vectors by subtracting the length of vector `a` from vector `b`.
///
/// - a (vector): Vector a
/// - b (vector): Vector b
/// -> float
#let dist(a, b) = len(sub(b, a))
/// Multiplys a vector with scalar `x`
/// - v (vector): The vector to scale.
/// - x (float): The scale factor.
/// -> vector
#let scale(v, x) = v.map(s => s * x)
/// Divides a vector by scalar `x`
/// - v (vector): The vector to be divded.
/// - x (float): The inverse scale factor.
#let div(v, x) = v.map(s => s / x)
/// Negates each value in a vector
/// - v (vector): The vector to negate.
/// -> vector
#let neg(v) = scale(v, -1)
/// Normalizes a vector (divide by its length)
/// - v (vector): The vector to normalize.
/// -> vector
#let norm(v) = div(v, len(v))
/// Calculates the dot product between two vectors.
/// - v1 (vector): The vector on the left hand side.
/// - v2 (vector): The vector on the right hand side.
/// -> float
#let dot(v1, v2) = {
assert(dim(v1) == dim(v2))
return v1.enumerate().fold(0, (s, t) => s + t.at(1) * v2.at(t.at(0)))
}
/// Calculates the cross product of two vectors with a dimension of three.
/// - v1 (vector): The vector on the left hand side.
/// - v2 (vector): The vector on the right hand side.
/// -> vector
#let cross(v1, v2) = {
assert(dim(v1) == 3 and dim(v2) == 3)
let x = v1.at(1) * v2.at(2) - v1.at(2) * v2.at(1)
let y = v1.at(2) * v2.at(0) - v1.at(0) * v2.at(2)
let z = v1.at(0) * v2.at(1) - v1.at(1) * v2.at(0)
return (x, y, z)
}
/// Calculates the angle between two vectors and the x-axis in 2d space
/// - a (vector): The vector to measure the angle from.
/// - b (vector): The vector to measure the angle to.
/// -> angle
#let angle2(a, b) = {
// Typst's atan2 is (x, y) order, not (y, x)
return calc.atan2(b.at(0) - a.at(0), b.at(1) - a.at(1))
}
/// Calculates the angle between three vectors
/// - v1 (vector): The vector to measure the angle from.
/// - c (vector): The vector to measure the angle at.
/// - v2 (vector): The vector to measure the angle to.
#let angle(v1, c, v2) = {
assert(dim(v1) == dim(v2), message: "Vectors " + repr(v1) + " and " + repr(v2) + " do not have the same dimensions.")
if dim(v1) == 2 or dim(v1) == 3 {
v1 = sub(v1, c)
v2 = sub(v2, c)
return calc.acos(dot(norm(v1), norm(v2)))
} else {
panic("Invalid vector dimension")
}
}
/// Linear interpolation between two vectors.
/// - v1 (vector): The vector to interpolate from.
/// - v2 (vector): The vector to interpolate to.
/// - t (float): The factor to interpolate by. A value of `0` is `v1` and a value of `1` is `v2`.
#let lerp(v1, v2, t) = {
return add(
v1,
scale(
sub(
v2,
v1
),
t,
)
)
}
/// Rotates a vector of dimension 2 or 3 around the z-axis by an angle.
/// - v (vector): The vector to rotate.
/// - angle (angle): The angle to rotate by.
/// -> vector
#let rotate-z(v, angle) = {
assert(v.len() >= 2,
message: "Vector size must be >= 2")
let (x, y, ..) = v
v.at(0) = x * calc.cos(angle) - y * calc.sin(angle)
v.at(1) = x * calc.sin(angle) + y * calc.cos(angle)
return v
} |
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/name-it/0.1.0/example.typ | typst | Apache License 2.0 | #import "./name-it.typ": name-it
#set page(width: auto, height: auto, margin: 1cm)
- #name-it(-5)
- #name-it(-5, negative-prefix: "minus")
- #name-it(0)
- #name-it(1)
- #name-it(10)
- #name-it(11)
- #name-it(42)
- #name-it(100)
- #name-it(110)
- #name-it(1104)
- #name-it(11040)
- #name-it(11000)
- #name-it(110000)
- #name-it(1100004)
- #name-it(10000000000006)
- #name-it(10000000000006, show-and: false)
- #name-it("200000000000000000000000007")
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/layout/par-bidi_02.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test that consecutive, embedded RTL runs stay RTL.
// Here, we have three runs: "גֶ", bold "שֶׁ", and "ם".
#let content = par[Aגֶ#strong[שֶׁ]םB]
#set text(font: ("Linux Libertine", "Noto Serif Hebrew"))
#text(lang: "he", content)
#text(lang: "de", content)
|
https://github.com/rlpundit/typst | https://raw.githubusercontent.com/rlpundit/typst/main/Typst/fr-Rapport/Rapport-PFE.typ | typst | MIT License | // RAPPORT PFE
#import "Class.typ": *
#import "common/metadata.typ": *
#import "Title-page.typ": *
#import "@preview/colorful-boxes:1.2.0": outlinebox
#set document(author: author, title: title, keywords: motscles, date: auto)
#show: report.with(
title: title,
diploma: diploma,
program: program,
supervisor: supervisor,
author: author,
date: date,
)
#titlepage(
title: title,
diploma: diploma,
program: program,
supervisor: supervisor,
author: author,
date: date
)
#set math.equation(numbering: "(1)" )
/* ### Rapport PFE ### */
// TOC
#set page(numbering: "i")
#counter(page).update(1)
#outline(depth: 3, indent: auto)
// LOF
#pagebreak()
#outline(
title: [Liste des figures],
target: figure.where(kind: image),
)
// LOT
#pagebreak()
#outline(
title: [Liste des tableaux],
target: figure.where(kind: table),
)
#pagebreak()
#pagebreak()
#place(bottom + right, box(width: 256pt, text(emph(dedication))))
#set heading(numbering: none)
#chap("Remerciements") // ACK
#ack
#set page(numbering: "1")
#counter(page).update(1)
#chap("Introduction générale") // IG
#include "chaps/intro.typ"
#set heading(numbering: "1.", supplement: [Chapter])
#chap(chap1) // Chapitre 1
#include "chaps/chpt1.typ"
#chap(chap2) // Chapitre 2
#include "chaps/chpt2.typ"
#chap(chap3) // Chapitre 3
#include "chaps/chpt3.typ"
#set heading(numbering: none)
#chap("Conclusion générale") // CG
#include "chaps/outro.typ"
// --- Références ---
#chap("Bibliographie")
#set page(header: smallcaps(title) + h(1fr) + emph("Bibliographie") + line(length: 100%))
#text(white)[#heading(bookmarked: true)[Bibliographie]]#v(-1cm)
#bibliography("Biblio.bib", title: none, full: true, style: "ieee")
// --- Résumé | Abstract ---
#set page(header: none, numbering: none)
#outlinebox(
title: "Résumé",
color: none,
width: auto,
radius: 2pt,
centering: false
)[
#resume
#line(length: 100%)
_*Mots clés --*_ #motscles
]
#outlinebox(
title: "Abstract",
color: none,
width: auto,
radius: 2pt,
centering: false
)[
#abstract
#line(length: 100%)
_*Keywords --*_ #keywords
]
|
https://github.com/jackjohn7/xlsx_typst | https://raw.githubusercontent.com/jackjohn7/xlsx_typst/main/README.md | markdown | # XLSX to Typst Figure
This is a tool I'm personally using for writing my lab reports. It needs to be cleaned up and is missing some features, but it's working for my basic needs.
## How to use
1. Copy your cells that you want to bring into Typst
2. Execute `python3 main.py`
3. Copy the output
4. Paste into Typst document
## Future features
- Full CLI with options
- Choose to include column names (useful for formatting)
- Choose to caption the figure
- Choose to set alignment
|
|
https://github.com/Miunn/Typst-Template | https://raw.githubusercontent.com/Miunn/Typst-Template/master/template/template.typ | typst | #let cover(
title: [Title],
subTitle: [Subtitle],
authors: (),
imagePath: "no-image.png",
professor: none,
semester: none,
) = {
let curr_month = datetime.today().month()
let curr_year = datetime.today().year()
set page(
header: align(
end,
grid(
columns: (auto, auto),
align: horizon,
image("insa.png", height: 40pt),
image("uphf.png", height: 40pt),
)
),
footer: [
#if professor != none [
Enseignant : #professor
]
#linebreak()
Informatique et Cybersécurité
#h(1fr)
#if semester != none [
Semestre #semester
]
#linebreak()
#if curr_month > 8 [
Année universitaire #curr_year / #(curr_year + 1)
] else [
Année universitaire #(curr_year - 1) / #curr_year
]
#h(1fr)
INSA Hauts-de-France
]
)
{ linebreak() * 4 }
text(20pt, [*#title*])
linebreak()
text(15pt, subTitle)
linebreak()
text(
13pt,
(
..authors.map(author => author.name)
).join(", ")
)
line()
image(imagePath)
}
#let conf(
title: [],
subTitle: [],
authors: (),
keywords: (),
date: auto,
imagePath: "no-image.png",
professor: none,
semester: none,
pageTitle: [],
outlineTitle: [Table des matières],
bibliographyTitle: [Bibliographie],
doc,
) = {
set document(
title: title,
author: authors.map(author => author.name),
keywords: keywords,
date: date,
)
set text(lang: "fr")
set heading(
numbering: "I.1.a.",
depth: 3,
)
set figure(
kind: figure,
supplement: "Figure",
)
show link: underline
show ref: it => {
let el = it.element
if el != none and el.func() == heading {
[#counter(heading).display() #el.body]
} else {
it
}
}
show outline.entry: it => {
if it.at("label", default: none) == <custom-entry> {
it
} else {
[
#outline.entry(
it.level,
it.element,
it.body,
it.fill,
[#it.element.location().page()],
) <custom-entry>
]
}
}
set page(
background: place(left, rect(
fill: rgb("#008db0"),
height: 100%,
width: 0.3cm,
))
)
cover(
title: title,
subTitle: subTitle,
authors: authors,
imagePath: imagePath,
professor: professor,
semester: semester,
)
pagebreak(weak: true)
set page(
paper: "a4",
header: [
#pageTitle
#h(1fr)
#datetime.today().display("[day] [month repr:short] [year]")
#line(length: 100%)
],
)
outline(
title: outlineTitle,
depth: 2,
indent: true
)
pagebreak(weak: true)
set page(
numbering: "— 1 —",
)
doc
pagebreak(weak: true)
bibliography("../bib.yaml", title: bibliographyTitle, style: "the-institution-of-engineering-and-technology")
} |
|
https://github.com/Nrosa01/TFG-2023-2024-UCM | https://raw.githubusercontent.com/Nrosa01/TFG-2023-2024-UCM/main/Memoria%20Typst/capitulos/4.PluginsYScriptingV2.typ | typst | #import "@preview/sourcerer:0.2.1": code
A la hora de crear un videojuego, existen varias estrategias a la hora de diseñar la arquitectura de software. Existe la posibilidad de programar el comportamiento del juego de forma directa, sin embargo esto resulta en un sistema difícil de modificar y reutilizar. Debido a esto se han creado motores de videojuegos. Un motor de videojueogs @gregory-2018 es un conjunto de herramientas que permiten a los desarrolladores crear videojuegos de forma más sencilla. Un motor de videojuegos puede o no tener una interfaz visual. Dicho conjunto de herramientas permite crear el "gameplay" o comportamiento del juego.
Un motor de videojuegos puede proveer más o menos elementos reutilizables. Sin embargo, mientras más elementos o comportamientos predefinidos tenga el motor, más especializado será, lo cual límita su capcidad de extensibilidad. La forma en que se desarrollan los comportamientos del juego con el motor depende de este mismo. Existen diferentes opciones, cada una con sus ventajas y desventajas.
En este capítulo se van a explorar tres posibilidades para desarrollar el sistema de "scripting" de un motor de videojuegos. Estas son: ficheros de definición de datos, librerías dinámicas y lenguajes de scripting.
== Ficheros de definición de datos
Una opción es usar ficheros de definición de datos, archivos que como su nombre indican, solo contienen datos. Suelen ser representados con un formato legible (YAML, JSON...) puesto que están pensados para ser editados por humanos que además, pueden no ser programadores. Al implementar esta opción, los juegos resultantes son "dirigidos por datos" @sharvit-2022, debido a que en lugar de especificar el comportamiento del juego mediante código, se configura mediante estos ficheros. Esto permite separar el trabajo de los programadores de los diseñadores de niveles o de juego.
Un ejemplo sencillo de esto es un juego _bullet hell_, un subgénero del _shoot'em up_ que se caracteriza por presentar una gran cantidad de proyectiles en pantalla. En lugar de especificar mediante código cada patrón, velocidad, tiempos, etc. se puede definir un fichero que el motor carga durante la ejecución del juego y contiene todos los parámetros necesarios para crear las balas. A continuación muestra un ejemplo de un posible fichero de definición de datos para un juego bullet hell.
#code(
lang: "YAML",
```yaml
define_action:
name: "shoot"
behaviour:
type: "linear"
speed: 5
direction: 90
time: 1
define_action:
name: "spawnLots"
behaviour:
type: "spawn"
amount: 10
do_action:
type: "shoot"
direccion: random 0 360
level:
do_action: "spawnLots"
wait: 5
repeat 10:
do_action: "spawnLots"
wait: 0.5
```
)
Debido a que el motor debe contener el código necesario para poder interpretar estos ficheros, existe una gran dependencia con el motor y las opciones de extensibilidad sean limitadas. En este tipo de sistemas no es posible crear juegos radicalmente distintos con solo cambiar los datos debido a estas limitaciones.
== Librerías dinámicas
Para superar las restricciones del modelo anterior, es necesario que el motor sea más flexible, es decir, debe poder permitir definir comportamiento permitiendo mayor libertad. Para ello, se pueden usar librerías dinámicas.
Una librería dinámica @linkers_and_loaders es un archivo que contiene código compilado que puede ser cargado y vinculado a un programa en tiempo de ejecución. Esto significa que el programa no necesita incluir este código en su propio archivo binario, sino que puede cargarlo cuando se necesita. Esto permite definir comportamiento con mucha más flexibilidad. Siguen existiendo limitaciones por parte del motor, pues el desarrollador solo puede usar las funciones del motor que exponga mediante su API. A pesar de ello, esta alternativa resulta ser mucho más versátil que la anterior.
El uso de librerías dinámicas no es exclusivo de los motores de videojuegos. Muchos programas de software utilizan este mecanismo para extender su funcionalidad.
Las librería dinámicas no son un formato universal, sino que cada sistema operativo tiene su propio mecanismo para cargar y vincular librerías dinámicas. Por ejemplo, en Windows se utilizan archivos DLL, en Linux se utilizan archivos SO y en macOS se utilizan archivos dylib. Esto significa que las librerías dinámicas no son necesariamente portables entre sistemas operativos, lo que puede ser una limitación en algunos casos. No obstante, existe un consenso al respecto a su funcionalidad. Por ejemplo, los grandes sistemas operativos actuales, Windows, Linux y MacOS, permiten definir callbacks o funciones para que una librería detecte cuando se ha cargado o descargado por el programa principal. Usar una dependencia que solo funcione en un sistema operativo podría dificultar la portabilidad del juego. Para mantener la portabilidad del sistema es importante ser cuidadodoso con las dependencias que se usan.
A pesar de su versatilidad, el uso de librerías dinámicas tiene ciertos problemas. Como se ha dicho, una librería dinamica contiene código compilado, esto implica que durante el desarrollo del juego, cada vez que se modifique el código de la librería, es necesario recompilarla y recargarla en el motor. Esto puede resultar en un proceso tedioso y lento que afecte de forma significativa al flujo de trabajo. Para evitar este problema, se pueden usar lenguajes de scripting.
== Lenguajes de scripting
Un lenguaje de scripting @barron-2000 es un lenguaje de programación que se utiliza para controlar la ejecución de un programa o para extender su funcionalidad. A diferencia de los lenguajes de programación tradicionales, los lenguajes de scripting suelen ser interpretados en lugar de compilados.
Un lenguaje de programación compilado es aquel que se transforma en código máquina mediante un proceso conocido como compilación, antes de su ejecución. Durante la ejecución, el sistema operativo carga este código máquina en la memoria y lo ejecuta directamente.
Por otro lado, un lenguaje de programación interpretado no se traduce previamente a código máquina. En su lugar, se traduce y ejecuta simultáneamente durante el tiempo de ejecución por un programa llamado intérprete. Este proceso de traducción incurre en un sobrecoste que hace que los lenguajes interpretados sean más lentos que los compilados.
Sin embargo, los lenguajes de scripting suelen ser más fáciles de aprender y de utilizar que los lenguajes de programación tradicionales. Esto se debe a que los lenguajes de scripting suelen tener una sintaxis más sencilla y menos reglas que los lenguajes de programación compilados. Suelen ser lenguajes que gestionan la memoria automáticamente, es decir, no es necesario liberar la memoria que se ha reservado, lo que facilita la programación.
Uno de los lenguajes de scripting más usados para modificar e incluso desarrollar videojuegos es Lua @ierusalimschy-2006. Lua es un lenguaje de scripting de alto nivel, multi-paradigma, ligero y eficiente, diseñado principalmente para la incorporación en aplicaciones. Fue creado en 1993 por <NAME>, <NAME> y <NAME>, miembros del Grupo de Tecnología en Computación Gráfica (Tecgraf) de la Pontificia Universidad Católica de Río de Janeiro, Brasil.
Lua es conocido por su simplicidad, eficiencia y flexibilidad. Su diseño se centra en la economía de recursos, tanto en términos de memoria como de velocidad de ejecución. Existe una única estructura de datos, la tabla, que se utiliza para representar tanto arrays como diccionarios. Además, para poder "heredar" funciones de una tabla, Lua define el concepto de metatabla. En Lua, cada tabla puede tener asociada una metatabla. Cuando el desarrollador llama a una función y esta no está definida en la tabla, Lua busca en la metatabla de la tabla para ver si la función está definida ahí. Esto es comparable a los prototipos en JavaScript.
Una de las características más destacadas de Lua es su capacidad para ser embebido en aplicaciones @ltd-2023. Esto se debe a su diseño como un lenguaje de scripting, que permite que el código Lua sea llamado desde un programa en C, C++ u otros lenguajes de programación. Esta característica ha llevado a que Lua sea ampliamente utilizado en la industria de los videojuegos, donde se utiliza para controlar la lógica del juego y las interacciones del usuario. Existen motores como Defold que integran Lua como lenguaje de scripting o el popular juego Roblox, que permite a los usuarios crear sus propios juegos utilizando una version modificada de Lua llamada Luau.
Sin embargo, esta flexibilidad es un arma de doble filo. Lua puede ser integrado en aplicacions escritas en diversos lenguajes. A menudo será necesario enviar y recibir datos entre el programa principal y el código de Lua. Esta comunicación se realiza mediante un mecanismo llamado FFI o "Foreign Function Interface" (interfaz de funciones foráneas) por sus siglas en inglés. Esta barrera entre ambos lenguajes provoca que la comunicación entre ellos sea más lenta que si se usara un solo lenguaje de programación. Para cada función del API del sistema en el lenguaje principal hay que crear un "binding" o nexo con el lenguaje de scripting. Esto se denomina "glue code" o código de pegamento. Si en algún momento el sistema cambia y por tanto su API, habrá que ajustar el código pegamento para que siga funcionando.
Como se ha mencionado, los lenguajes de scripting son interpretados. Sin embargo, existe una técnica llamada compilación Just-In-Time (JIT) que permite compilar el código de un lenguaje de scripting en código máquina durante la ejecución. Esto permite que el código sea ejecutado de forma más rápida, ya que no es necesario interpretarlo en tiempo real. LuaJIT @ltd-2023 es una implementación de Lua que utiliza esta técnica y que ha demostrado ser muy eficiente en términos de velocidad de ejecución.
Sin embargo, cabe destacar que en los lenguajes JIT, puede llegar a ser importante saber ciertos detalles de su funcionamiento interno para poder aprovechar su potencial. Como se mencionó anteriormente, la única estructura de datos en Lua es la tabla, no existen tipos salvo los primitivos (números, booleanos y cadenas de texto). Esto significa que algunas optimizaciones dependen del uso que el desarrollador haga del lenguaje. Por ejemplo, si una función recibe dos parámetros y esos dos parámetros siempre son números, LuaJIT puede optimizar la función en base a heurísticas @de-figueiredo-2008 @ltd-2023. Sin embargo, si durante la ejecución se llama a la función con otro tipo de dato, LuaJIT desactivará la optimización y la función se ejecutará de forma más lenta. Este tipo de optimizaciones son comunes en los lenguajes JIT, por lo que es importante tener en cuenta cómo funcionan para poder aprovechar su potencial.
== Blockly
#include "5.1.Blockly.typ"
|
|
https://github.com/Myriad-Dreamin/tinymist | https://raw.githubusercontent.com/Myriad-Dreamin/tinymist/main/crates/tinymist-query/src/fixtures/type_check/infer_stroke_dict.typ | typst | Apache License 2.0 | #text(stroke: (
paint: black,
thickness: 1pt,
))[]
|
https://github.com/sitandr/typst-examples-book | https://raw.githubusercontent.com/sitandr/typst-examples-book/main/src/basics/scripting/braces.md | markdown | MIT License | # Braces, brackets and default
## Square brackets
You may remember that square brackets convert everything inside to *content*.
```typ
#let v = [Some text, _markup_ and other #strong[functions]]
#v
```
We may use same for functions bodies:
```typ
#let f(name) = [Hello, #name]
#f[World] // also don't forget we can use it to pass content!
```
**Important:** It is very hard to convert _content_ to _plain text_, as _content_ may contain *anything*! Sp be careful when passing and storing content in variables.
## Braces
However, we often want to use code inside functions.
That's when we use `{}`:
```typ
#let f(name) = {
// this is code mode
// First part of our output
"Hello, "
// we check if name is empty, and if it is,
// insert placeholder
if name == "" {
"anonym"
} else {
name
}
// finish sentence
"!"
}
#f("")
#f("Joe")
#f("world")
```
## Scopes
**This is a very important thing to remember**.
_You can't use variables outside of scopes they are defined (unless it is file root, then you can import them)_. _Set and show rules affect things in their scope only._
```typ
#{
let a = 3;
}
// can't use "a" there.
#[
#show "true": "false"
This is true.
]
This is true.
```
## Return
**Important**: by default braces return anything that "returns" into them. For example,
```typ
#let change_world() = {
// some code there changing everything in the world
str(4e7)
// another code changing the world
}
#let g() = {
"Hahaha, I will change the world now! "
change_world()
" So here is my long evil monologue..."
}
#g()
```
To avoid returning everything, return only what you want explicitly, otherwise everything will be joined:
```typ
#let f() = {
"Some long text"
// Crazy numbers
"2e7"
return none
}
// Returns nothing
#f()
```
## Default values
What we made just now was inventing "default values".
They are very common in styling, so there is a special syntax for them:
```typ
#let f(name: "anonym") = [Hello, #name!]
#f()
#f(name: "Joe")
#f(name: "world")
```
You may have noticed that the argument became _named_ now.
In Typst, named argument is an argument _that has default value_.
|
https://github.com/Area-53-Robotics/53B-Notebook-Over-Under-2023-2024 | https://raw.githubusercontent.com/Area-53-Robotics/53B-Notebook-Over-Under-2023-2024/master/entries/early_season/trouble_shoot_drive.typ | typst | Creative Commons Attribution Share Alike 4.0 International | #import "/templates/entries.typ": *
#import "/templates/headers.typ": *
#import "/templates/text.typ": *
#create_default_entry(
title: [Drive Train Issues],
date: [September 29th, 2023],
witness: [Gabe],
design: [Deb],
content: [
#box_header(
title: [Omni Wheels],
color: purple.lighten(60%)
) \
#entry_text()
After testing the new drive train for a bit, our drive Imaad noticed that the bot had too much drift for his liking. This was fixed by replacing the middle wheel in the drive train with a traction wheel instead of an omni wheel.
#entry_header(title: [Sleds])
#entry_text()
We decided against using sleds, and instead shortned the c-channel connecting the drive train so that the wheels contact objects first, and therefore are able to climb over said objects with ease.
#box_header(
title: [Structural Integrity],
color: yellow.lighten(60%)
) \
#entry_text()
Second problem was the lack of structural support. Originally, the CAD only had two 2 horizontal crossbars that connected the drive halves together. Since they where both on top, the drive train was bowing inward. To combat this, we added a support crossbeam on the bottom of the drive train, which solved the issue.
#image("/assets/drive_side.jpg")
]
) |
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/g-exam/0.3.0/README.md | markdown | Apache License 2.0 | # g-exam
This template provides a way to generate exams. You can create questions and sub-questions, header with information about the academic center, score box, subject, exam, header with student information, clarifications, solutions, watermark with information about the exam model and teacher.
#### Features
- Scoreboard.
- Scoring by questions and subquestions.
- Student information, on the first page or on all odd pages.
- Question and subcuestion.
- Show solutions and clarifications
- List of clarifications.
- Teacher's Watermark
- Exam Model Watermark
## Usage
For information, see the [manual](https://github.com/MatheSchool/typst-g-exam/blob/master/doc/g-exam-manual.pdf?raw=true).
To use this package, simply add the following code to your document:
#### A sample exam
<img src="./gallery/exam-table-content.png" alt="Exam - Table of content" style="width:500px;"/>
#### Source:
```typ
#import "@preview/g-exam:0.3.0": *
#show: g-exam.with(
school: (
name: "Sunrise Secondary School",
logo: read("./logo.png", encoding: none),
),
exam-info: (
academic-period: "Academic year 2023/2024",
academic-level: "1st Secondary Education",
academic-subject: "Mathematics",
number: "2nd Assessment 1st Exam",
content: "Radicals and fractions",
model: "Model A"
),
show-studen-data: "first-page",
show-grade-table: true,
clarifications: "Answer the questions in the spaces provided. If you run out of room for an answer, continue on the back of the page."
)
#g-question(point:2.5)[Is it true that $x^n + y^n = z^n$ if $(x,y,z)$ and $n$ are positive integers?. Explain.]
#v(1fr)
#g-question(point:2.5)[Prove that the real part of all non-trivial zeros of the function $zeta(z) "is" 1/2$].
#v(1fr)
#g-question(point:2)[Compute $ integral_0^infinity (sin(x))/x $ ]
#v(1fr)
```
## Changelog
### v0.3.0
- Include parameter question-text-parameters.
- Show solution.
- Expand documentation.
- Possibility of estrablecer question-point-position to none.
- Bug fix show watermark.
### v0.2.0
- Control the size of the logo image.
- Convert to template
- Allow true and false values in show-studen-data.
- Show clarifications.
- Widen margin points.
- Show solution.
### v0.1.1
- Fix loading image.
### v0.1.0
- Initial version submitted to typst/packages.
|
https://github.com/FriendlyUser/IntroductionToTypst | https://raw.githubusercontent.com/FriendlyUser/IntroductionToTypst/main/main.typ | typst | Apache License 2.0 | #import "template.typ": *
// Take a look at the file `template.typ` in the file panel
// to customize this template and discover how it works.
#show: resume.with(
title: "New Grad Resume",
location: "Vancouver, BC",
postalCode: "V5Y 1V4",
phoneNumber: "(604) 873-7000",
email: "<EMAIL>",
experiences: (
(
employee: "Big Company",
jobTitle: "Software Developer",
startDate: "March 2020",
endDate: "Current",
location: "BC, Canada",
points: (
(
"Implementing web app for a website with html css and javascript"
),
(
"Implementing mobile app all by myself"
),
(
"Releasing untested code"
),
(
"Buggy software development"
)
)
),
(
employee: "<NAME>",
jobTitle: "Software Engineer",
startDate: "March 2018",
endDate: "March 2020",
location: "BC, Canada",
points: (
("Quality Assurance for mobile app"),
(
"Unit Testing for mobile app"
),
(
"Gaining credit for coop"
)
)
),
),
education: (
name: "University of Victoria",
startDate: "September 2016",
endDate: "December 2019",
degree: "Computer Engineering",
location: "Victoria, BC",
points: (
(
"Good At Math"
),
(
"Good at Coding"
)
)
)
)
|
https://github.com/vEnhance/1802 | https://raw.githubusercontent.com/vEnhance/1802/main/src/sol-bravo.typ | typst | MIT License | #import "@local/evan:1.0.0":*
= Solutions to Part Bravo
== Solution to @exer-basis-birthday
Neither vector is zero,
and for almost everyone the two vectors won't be a multiple of each other.
So for most people the answer is that the span is *all of $RR^2$*.
In order to find a K-pop idol whose two vectors are linearly dependent
(to get the answer "line" instead),
we need to find a database of K-pop birthdays, and we need to know where to look in it.
There are roughly two strategies you can adopt:
- For idols born before 2000, the only year that's viable is 1995
(because $19$ is a prime greater than $12$, the last two digits need to be a multiple of $19$).
The two days that work here are January 5 and February 10.
As an example, <NAME> from former boy group Snuper was born on February 10, 1995.
- For idols born after 2000, good years to try would be 2004 or 2005.
(The year 2004 has May 1 and October 2; the year 2005 has April 1, October 2, December 3.)
As an example, <NAME> from KJRGL was born on October 2, 2004.
|
https://github.com/Kasci/LiturgicalBooks | https://raw.githubusercontent.com/Kasci/LiturgicalBooks/master/covers/oktoich/H12_GR.typ | typst | #set text(font: "<NAME>", weight: "semibold", lang: "gr", fill: black)
#set page(header: "", footer: "")
#import "/style.typ": *
#align(center)[#text(80pt)[#primText[☦]]]
#align(center)[#primText[
#text(60pt)[ΟΚΤΩΗΧΟΣ]\ \ \ \ \ \
]]
#align(center)[#secText[
#text(50pt)[Ήχος α'‑β']\
]]\
#align(center)[#text(20pt)[#primText[<NAME>]]]\
#align(center)[#text(20pt)[<NAME>\ Prešov\ 2024]]
|
|
https://github.com/LDemetrios/Typst4k | https://raw.githubusercontent.com/LDemetrios/Typst4k/master/src/test/resources/suite/model/bibliography.typ | typst | // Test citations and bibliographies.
--- bibliography-basic ---
#set page(width: 200pt)
= Details
See also @arrgh #cite(<distress>, supplement: [p.~22]), @arrgh[p.~4], and @distress[p.~5].
#bibliography("/assets/bib/works.bib")
--- bibliography-before-content ---
// Test unconventional order.
#set page(width: 200pt)
#bibliography(
"/assets/bib/works.bib",
title: [Works to be cited],
style: "chicago-author-date",
)
#line(length: 100%)
As described by #cite(<netwok>, form: "prose"),
the net-work is a creature of its own.
This is close to piratery! @arrgh
And quark! @quark
--- bibliography-multiple-files ---
#set page(width: 200pt)
#set heading(numbering: "1.")
#show bibliography: set heading(numbering: "1.")
= Multiple Bibs
Now we have multiple bibliographies containing @glacier-melt @keshav2007read
#bibliography(("/assets/bib/works.bib", "/assets/bib/works_too.bib"))
--- bibliography-duplicate-key ---
// Error: 15-65 duplicate bibliography keys: netwok, issue201, arrgh, quark, distress, glacier-melt, tolkien54, DBLP:books/lib/Knuth86a, sharing, restful, mcintosh_anxiety, psychology25
#bibliography(("/assets/bib/works.bib", "/assets/bib/works.bib"))
--- bibliography-ordering ---
#set page(width: 300pt)
@mcintosh_anxiety
@psychology25
#bibliography("/assets/bib/works.bib")
--- bibliography-full ---
#set page(paper: "a6", height: auto)
#bibliography("/assets/bib/works_too.bib", full: true)
--- bibliography-math ---
#set page(width: 200pt)
@Zee04
#bibliography("/assets/bib/works_too.bib", style: "mla")
--- issue-4618-bibliography-set-heading-level ---
// Test that the bibliography block's heading is set to 2 by the show rule,
// and therefore should be rendered like a level-2 heading. Notably, this
// bibliography heading should not be underlined.
#show heading.where(level: 1): it => [ #underline(it.body) ]
#show bibliography: set heading(level: 2)
= Level 1
== Level 2
@Zee04
#bibliography("/assets/bib/works_too.bib")
|
|
https://github.com/chendaohan/bevy_tutorials_typ | https://raw.githubusercontent.com/chendaohan/bevy_tutorials_typ/main/17_window_properties/window_properties.typ | typst | #set page(fill: rgb(35, 35, 38, 255), height: auto, paper: "a3")
#set text(fill: color.hsv(0deg, 0%, 90%, 100%), size: 22pt, font: "Microsoft YaHei")
#set raw(theme: "themes/Material-Theme.tmTheme") |
|
https://github.com/yhtq/Notes | https://raw.githubusercontent.com/yhtq/Notes/main/经济学原理/hw/hw4.typ | typst | #import "../../template.typ": *
#show: note.with(
title: "作业3",
author: "YHTQ ",
date: none,
logo: none,
withOutlined: false
)
#set heading(numbering: none)
= 一、
1. D
$
E_p = elasticity(P, Q) = elasticity(P, 10 / P)
\ = -(10 / P^2) / (10 / P^2) = - 1
$
2. B
偏好与收入无关
3. A
#align(center,image("image/image1.png", width: 200pt))
= 二、
1.(1)
#align(center,image("image/image2.png", width: 200pt))
(2)
#align(center,image("image/image3.png", width: 200pt))
2.
(1) 不完备,个子小、跑得慢与个子大、跑得快之间无法比较\
(2) 完备,记 $A, B$ 的三项指标分别为 $(x_1, y_1, z_1), (x_2, y_2, z_2)$,则:
$
x_1 - x_2, y_1 - y_2, z_1 - z_2
$
由抽屉原理至少有两个同号,因此可以在这两个指标上比较大小。但它是不传递的。考虑:
$
A_1 = (10, 10, 0), A_2 = (10, 9, 21), A_3 = (9, 11, 20)
$
即有 $A_1 >= A_2 >= A_3$,但 $A_1 >= A_3$ 不成立
= 三、
- 完备性是显然的
- 传递性:设 $(x_1, y_1) >= (x_2, y_2) >= (x_3, y_3)$
- 若 $x_1 > x_2$
- 此时必有 $x_2 >= x_3$ ,则 $x_1 > x_2 >= x_3 => (x_1, y_1) >= (x_3, y_3)$
- 若 $x_1 = x_2$,从而 $y_1 >= y_2$
- 若 $x_2 > x_3$,则 $x_1 = x_2 > x_3 => (x_1, y_1) >= (x_3, y_3)$
- 若 $x_2 = x_3$,从而 $y_2 >= y_3$,则 $y_1 >= y_2 >= y_3 => (x_1, y_1) >= (x_3, y_3)$
- 严格凸性:设 $(x_1, y_1) >= (x_2, y_2)$
- 若 $x_1 = x_2$,则退化为第二分量比较,也即 $R$ 上的通常序关系,满足严格凸性
- 若 $x_1 != x_2$,则退化为第一分量比较,同样相当于 $R$ 上的通常序关系满足,严格凸性
|
|
https://github.com/The-Notebookinator/notebookinator | https://raw.githubusercontent.com/The-Notebookinator/notebookinator/main/docs/src/introduction.md | markdown | The Unlicense | # Introduction
Welcome to the documentation for the notebookinator, a Typst package meant to simplify the notebooking process for the Vex Robotics Competition. Its theming capabilities handle all of the styling for you, letting you jump right into writing documentation.
While it was designed with VRC in mind, it could just as easily be used for other competitor systems such as the First Robotics Competition and the First Tech Challenge.
If you're new here, we recommend you read the [installation guide](./installation.md) and the [basic usage guide](./basic_usage.md).
If you already know what you're doing, and just some quick information, check out the [API reference](./reference.typ).
If you're an advanced user, and want to extend / contribute to the Notebookinator, check out our [developer documentation](./developer_documentation/developer_documentation.md).
|
https://github.com/Cheng0Xin/typst-libs | https://raw.githubusercontent.com/Cheng0Xin/typst-libs/master/semantics/test.typ | typst | #import "@local/note:1.0.0": *
#import "semantics.typ": *
#let pr = sym.tack.r
// For debuging
#let printit(x) = style(s =>
{
let res = cons-obj(x, s)
res
})
#let x = (
label: tt[contract],
up: (
up: (
label: tt[$->$-E],
up: (
(
label: tt[Id],
up: [],
down: $y : A pr y : A$
),
(
up: (
(
label: tt[Id],
up: [],
down: $f : A -> B pr f : A -> B$
),
(
label: tt[Id],
up: [],
down: $z : A pr z : A$
)
),
down: $f : A -> B, z : A pr f(z) : B$
)
),
down: ($y : A, f : A -> B, z : A pr (y, f(z)) : A times B$)
),
down: ($f : A -> B, y : A, z : A #pr (y, f(z)) : A times B$)
),
down: [$f : A -> B, x : A #pr A (x, f(x)) : A times B$],
)
#rule(x)
#rule(
(
label: tt[$->$E],
up: ($Gamma, A pr B$, $Gamma pr A$),
down: $Gamma pr B$
)
)
|
|
https://github.com/andymeneely/examify.typst | https://raw.githubusercontent.com/andymeneely/examify.typst/master/lib.typ | typst | MIT License | #let showing_solutions(loc) = {
query(<show_solutions>, loc).len() > 0
}
#let cover_sheet(content) = {
show heading: content => {
set align(center)
set text(weight: "bold")
content
}
v(5cm)
align(content)
}
#let points(num) = {
let total = state("totalpoints", 0.0)
total.update(total => total + num)
[(#num point#if num != 1 [s])]
}
#let sub_points(num) = {
[(#num point#if num != 1 [s])]
}
#let choices(content) = {
v(3mm)
set enum(numbering: "A. ", indent: 10mm)
content
}
#let correct(content) = {
locate(loc =>
if showing_solutions(loc) {
rect(content, radius: 6pt, inset: 0cm, outset: 0.1cm)
} else {
content
}
)
}
#let question(content) = {
let qnum = state("question_number", 0)
qnum.update(qnum => qnum + 1)
set list(indent: 0.5cm)
block({
qnum.display()
[. ]
content
}, breakable: false
)
}
#let sub_question(content) = {
let sub_qnum = counter("sub_question_number")
sub_qnum.step()
set list(indent: 0.5cm)
pad(left: 1cm, {
sub_qnum.display("a.")
content
})
}
#let solution(content, height: 3cm) = {
locate( loc =>
if showing_solutions(loc) {
align(center,rect(content, height: height, radius: 6pt))
} else {
rect([], height: height, stroke: none)
}
)
}
// Go to the end of the document and calculate the final value
#let num_questions() = {
locate(loc => state("question_number").final(loc) )
}
// Go to the end of the document and calculate the final value
#let total_points() = {
locate(loc => state("totalpoints", 0.0).final(loc))
}
#let blank(len) = {
$underline(#h(len))$
}
#let fill_in_blank(len, answer) = {
locate( loc =>
if showing_solutions(loc) {
$underline(answer)$
} else {
$underline(#h(len))$
}
)
} |
https://github.com/cunhapaulo/typst_styles | https://raw.githubusercontent.com/cunhapaulo/typst_styles/main/toolbox/toolbox.typ | typst | MIT License | /*
-----------------------------------------------------------------------------------------
Toolbox for the writing of academic documents in ABNT fomat.
Version: 20231103
Author(s): <NAME> (<EMAIL>)
Copyright: Copyright (c) 2023 <NAME>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------
*/
//------------------------------------------------------------------
// highlightBox(title: "Box title", "text")
//------------------------------------------------------------------
//
// Inserts a graphical text box with smaller font to convey
// text in focus. Title is optional and gray is the default color.
//
//------------------------------------------------------------------
#let highlightBox(title: none, fontsize: 10pt, leading: 6.75pt, color: "gray", stroke: 0pt, radius: 4pt, alignment: left, width: auto, body) = {
let STROKE_COLOR = luma(70)
let BACKGROUND_COLOR = white
let TITLE_INSET_SPACE = 6pt
let TEXT_INSET_SPACE = 25pt
if color == "gray" {
STROKE_COLOR = rgb(150, 150, 150)
BACKGROUND_COLOR = rgb(240, 240, 240)
} else if color == "green" {
STROKE_COLOR = rgb(102, 174, 62)
BACKGROUND_COLOR = rgb(235, 244, 222)
} else if color == "blue" {
STROKE_COLOR = rgb(29, 144, 208)
BACKGROUND_COLOR = rgb(232, 246, 253)
} else if color == "red" {
STROKE_COLOR = rgb(237, 32, 84)
BACKGROUND_COLOR = rgb(253, 228, 224)
}
return block(above: 18pt, below: 18pt)[
#box(
fill: BACKGROUND_COLOR,
stroke: stroke + STROKE_COLOR,
radius: radius,
width: width
)[
#if title == none {
TITLE_INSET_SPACE = 0pt
}
#set align(alignment)
#block(
fill: STROKE_COLOR,
inset: TITLE_INSET_SPACE,
radius: (top-left: radius, bottom-right: radius),
)[#text(fill: white, weight: "bold")[#title]]
#block(
breakable: true,
spacing: TITLE_INSET_SPACE + 20pt,
width: 100%,
inset: (x: TEXT_INSET_SPACE, bottom: TEXT_INSET_SPACE)
)[#par(leading: leading)[#text(size: fontsize)[#body]]]
]
]
}
//------------------------------------------------------------------
// myfigure(body, width: 50%, caption: "", source: "")
//------------------------------------------------------------------
//
// Inserts a graphical object in the text
// respecting the ABNT standard, with caption and
// the description o its source in order to respecting
// eventual copyrights.
//
//------------------------------------------------------------------
#let myfigure(body, width: 50%, caption: "", source: "") = {
return block(above: 25pt, below: 25pt, width: 100%)[
#figure(
image(body, width: width),
gap: 10pt,
caption: caption
)
#set align(center)
#if source != "" {
"Fonte: " + source
}
]
}
//------------------------------------------------------------------
// mytable(body, width: 50%, caption: "")
//------------------------------------------------------------------
//
// Inserts a table within the ABNT standard.
//
//------------------------------------------------------------------
#let mytable(body, width: 50%, caption: "") = {
return block(above: 25pt, below: 25pt, width: 100%)[
#figure(
image(body, width: width),
gap: 10pt,
caption: caption
)
]
}
//------------------------------------------------------------------
// citeonline(reference, supplement)
//------------------------------------------------------------------
//
// Created to mimimc the exact behaviour of
// LaTeX citeonline refence command.
// Produces:
// a. citeonline(<Knuth1986>, supplement: "p. 123")
// => Knuth (1986, p. 123)
// b. citeonline(<Knuth1986>)
// => Knuth (1986)
//------------------------------------------------------------------
#let citeonline(body, supplement: "") = {
if supplement != "" {
return cite(body, supplement: supplement, form: "prose");
} else {
return cite(body, form: "prose");
}
}
//------------------------------------------------------------------
// footciteref(reference)
//------------------------------------------------------------------
//
// Created to mimic the exac behaviour of
// LaTex homonimous reference command.
// Produces:
// a. #footnote[#footciteref(<reference>)]
// produces a footnote where the complete reference
// is put.
//------------------------------------------------------------------
#let footciteref(body) = {
cite(body, form: "full")
}
//------------------------------------------------------------------
// section_()
//------------------------------------------------------------------
//
// Createa header without numbering, just like in LaTeX
// \section*{Text}
// Produces:
// Text (without numbering).
//
// #header(numbering: none)[Title goes here]
//
//------------------------------------------------------------------
// #let section(arg: "") = {
// heading(numbering: none, arg)
// }
#let section_ = heading.with(level:1, numbering: none)
#let subsection_ = heading.with(level: 2, numbering: none)
#let subsubsection_ = heading.with(level: 3, numbering: none) |
https://github.com/RY997/Thesis | https://raw.githubusercontent.com/RY997/Thesis/main/thesis_typ/acknowledgement.typ | typst | MIT License | #let acknowledgement() = {
set page(
margin: (left: 30mm, right: 30mm, top: 40mm, bottom: 40mm),
numbering: none,
number-align: center,
)
let body-font = "New Computer Modern"
let sans-font = "New Computer Modern Sans"
set text(
font: body-font,
size: 12pt,
lang: "en"
)
set par(leading: 1em)
// --- Acknowledgements ---
align(left, text(font: sans-font, 2em, weight: 700,"Acknowledgements"))
text[
I would like to express my heartfelt gratitude to the following people, whose contributions were indispensable in bringing this thesis to fruition:
To Prof. Dr. <NAME>, for his invaluable guidance and unwavering support throughout this project.
To my thesis advisor, <NAME>, for his mentorship and encouragement, which helped me navigate through the challenges of this thesis.
To my project partner, <NAME>, for his hard work, dedication, and countless hours spent collaborating with me which were instrumental to the success of this project.
To <NAME>, for his invaluable assistance and insightful advice during the development of this thesis.
To participants of the Interactive Learning practical course (Summer Semester 2023), for their dedication and efforts in founding the Iris project, laying the groundwork for the success of this thesis.
To members of the Artemis developer team: for their meticulous review and constructive feedback on this thesis project.
To my friends, <NAME> and <NAME>, for their encouragement, which was a source of strength during challenging times throughout this project.
To my parents, for their unconditional love and unwavering support.
]
v(15mm)
} |
https://github.com/ClazyChen/Table-Tennis-Rankings | https://raw.githubusercontent.com/ClazyChen/Table-Tennis-Rankings/main/history/2017/WS-10.typ | typst |
#set text(font: ("Courier New", "NSimSun"))
#figure(
caption: "Women's Singles (1 - 32)",
table(
columns: 4,
[Ranking], [Player], [Country/Region], [Rating],
[1], [DING Ning], [CHN], [3524],
[2], [ZHU Yuling], [MAC], [3342],
[3], [LIU Shiwen], [CHN], [3338],
[4], [CHEN Meng], [CHN], [3248],
[5], [MU Zi], [CHN], [3181],
[6], [SUN Yingsha], [CHN], [3170],
[7], [WANG Manyu], [CHN], [3150],
[8], [WU Yang], [CHN], [3137],
[9], [ISHIKAWA Kasumi], [JPN], [3113],
[10], [ITO Mima], [JPN], [3059],
[11], [KIM Song I], [PRK], [3036],
[12], [HIRANO Miu], [JPN], [3025],
[13], [GU Yuting], [CHN], [2976],
[14], [HAN Ying], [GER], [2974],
[15], [FENG Yalan], [CHN], [2973],
[16], [WEN Jia], [CHN], [2967],
[17], [CHEN Xingtong], [CHN], [2964],
[18], [HU Limei], [CHN], [2944],
[19], [JEON Jihee], [KOR], [2922],
[20], [SAMARA Elizabeta], [ROU], [2914],
[21], [SHAN Xiaona], [GER], [2903],
[22], [FENG Tianwei], [SGP], [2892],
[23], [HAYATA Hina], [JPN], [2884],
[24], [LI Jie], [NED], [2874],
[25], [<NAME>], [ROU], [2874],
[26], [HU Melek], [TUR], [2873],
[27], [NI Xia Lian], [LUX], [2864],
[28], [CHENG I-Ching], [TPE], [2858],
[29], [GU Ruochen], [CHN], [2849],
[30], [HASHIMOTO Honoka], [JPN], [2832],
[31], [ZENG Jian], [SGP], [2830],
[32], [KIM Kyungah], [KOR], [2827],
)
)#pagebreak()
#set text(font: ("Courier New", "NSimSun"))
#figure(
caption: "Women's Singles (33 - 64)",
table(
columns: 4,
[Ranking], [Player], [Country/Region], [Rating],
[33], [SHI Xunyao], [CHN], [2827],
[34], [YANG Xiaoxin], [MON], [2823],
[35], [ZHANG Qiang], [CHN], [2820],
[36], [CHOI Hyojoo], [KOR], [2819],
[37], [LANG Kristin], [GER], [2814],
[38], [HAMAMOTO Yui], [JPN], [2813],
[39], [LI Xiaodan], [CHN], [2813],
[40], [KATO Miyu], [JPN], [2812],
[41], [MORI Sakura], [JPN], [2808],
[42], [JIANG Huajun], [HKG], [2807],
[43], [CHEN Ke], [CHN], [2807],
[44], [#text(gray, "ISHIGAKI Yuka")], [JPN], [2804],
[45], [CHEN Szu-Yu], [TPE], [2798],
[46], [DOO Hoi Kem], [HKG], [2786],
[47], [SHIBATA Saki], [JPN], [2785],
[48], [CHE Xiaoxi], [CHN], [2781],
[49], [TIE Yana], [HKG], [2781],
[50], [POLCANOVA Sofia], [AUT], [2779],
[51], [SUH Hyo Won], [KOR], [2776],
[52], [LI Qian], [POL], [2776],
[53], [YU Fu], [POR], [2773],
[54], [POTA Georgina], [HUN], [2773],
[55], [SZOCS Bernadette], [ROU], [2770],
[56], [SATO Hitomi], [JPN], [2766],
[57], [LI Jiao], [NED], [2762],
[58], [ANDO Minami], [JPN], [2758],
[59], [YANG Ha Eun], [KOR], [2750],
[60], [YU Mengyu], [SGP], [2745],
[61], [HUANG Yi-Hua], [TPE], [2744],
[62], [#text(gray, "SHEN Yanfei")], [ESP], [2733],
[63], [LI Fen], [SWE], [2728],
[64], [ZHANG Mo], [CAN], [2720],
)
)#pagebreak()
#set text(font: ("Courier New", "NSimSun"))
#figure(
caption: "Women's Singles (65 - 96)",
table(
columns: 4,
[Ranking], [Player], [Country/Region], [Rating],
[65], [SAWETTABUT Suthasini], [THA], [2716],
[66], [LEE Ho Ching], [HKG], [2716],
[67], [HE Zhuojia], [CHN], [2713],
[68], [LEE Zion], [KOR], [2712],
[69], [LIU Gaoyang], [CHN], [2712],
[70], [ZHOU Yihan], [SGP], [2710],
[71], [<NAME>], [HKG], [2707],
[72], [WINTER Sabine], [GER], [2704],
[73], [<NAME>], [JPN], [2703],
[74], [SOLJA Petrissa], [GER], [2701],
[75], [MAEDA Miyu], [JPN], [2701],
[76], [MATSUZAWA Marina], [JPN], [2695],
[77], [<NAME>], [JPN], [2689],
[78], [KATO Kyoka], [JPN], [2682],
[79], [EERLAND Britt], [NED], [2679],
[80], [LIU Jia], [AUT], [2672],
[81], [<NAME>aki], [JPN], [2665],
[82], [MIKHAILOVA Polina], [RUS], [2665],
[83], [LI Jiayi], [CHN], [2662],
[84], [LIU Fei], [CHN], [2659],
[85], [<NAME>], [BLR], [2650],
[86], [<NAME>], [KOR], [2649],
[87], [<NAME>], [TPE], [2649],
[88], [<NAME>], [TPE], [2638],
[89], [<NAME>], [POL], [2638],
[90], [<NAME>], [CHN], [2632],
[91], [#text(gray, "<NAME>")], [PRK], [2630],
[92], [KHETKHUAN Tamolwan], [THA], [2628],
[93], [NOSKOVA Yana], [RUS], [2624],
[94], [#text(gray, "LOVAS Petra")], [HUN], [2618],
[95], [<NAME>], [USA], [2616],
[96], [#text(gray, "VACENOVSKA Iveta")], [CZE], [2610],
)
)#pagebreak()
#set text(font: ("Courier New", "NSimSun"))
#figure(
caption: "Women's Singles (97 - 128)",
table(
columns: 4,
[Ranking], [Player], [Country/Region], [Rating],
[97], [XIAO Maria], [ESP], [2609],
[98], [BALAZOVA Barbora], [SVK], [2600],
[99], [WANG Yidi], [CHN], [2600],
[100], [NAGASAKI Miyu], [JPN], [2599],
[101], [KOMWONG Nanthana], [THA], [2598],
[102], [DIAZ Adriana], [PUR], [2595],
[103], [LIU Xi], [CHN], [2594],
[104], [<NAME>], [KOR], [2594],
[105], [MIT<NAME>], [GER], [2592],
[106], [<NAME>], [UKR], [2591],
[107], [PESOTSKA Margaryta], [UKR], [2588],
[108], [<NAME>], [PRK], [2587],
[109], [PASKAUSKIENE Ruta], [LTU], [2585],
[110], [NG <NAME>], [HKG], [2583],
[111], [<NAME>], [JPN], [2581],
[112], [<NAME>], [RUS], [2577],
[113], [<NAME>], [POR], [2577],
[114], [PROKHOROVA Yulia], [RUS], [2574],
[115], [<NAME>], [UKR], [2574],
[116], [MESHREF Dina], [EGY], [2573],
[117], [VOROBEVA Olga], [RUS], [2571],
[118], [<NAME>], [AUS], [2567],
[119], [CHA Hyo Sim], [PRK], [2567],
[120], [GRZYBOWSKA-FRANC Katarzyna], [POL], [2566],
[121], [SO Eka], [JPN], [2565],
[122], [#text(gray, "ZHENG Jiaqi")], [USA], [2565],
[123], [LEE Eunhye], [KOR], [2562],
[124], [TIAN Yuan], [CRO], [2561],
[125], [<NAME>], [KOR], [2560],
[126], [<NAME>], [SWE], [2558],
[127], [<NAME>], [SGP], [2556],
[128], [<NAME>], [CZE], [2550],
)
) |
|
https://github.com/RaphGL/ElectronicsFromBasics | https://raw.githubusercontent.com/RaphGL/ElectronicsFromBasics/main/DC/chap6/1_voltage_divider_circuits.typ | typst | Other | #import "../../core/core.typ"
=== Voltage divider circuits
Let\'s analyze a simple series circuit, determining the voltage drops
across individual resistors:
#image("static/00106.png")
#image("static/10096.png")
From the given values of individual resistances, we can determine a
total circuit resistance, knowing that resistances add in series:
#image("static/10097.png")
From here, we can use Ohm\'s Law ($I = E/R$) to determine the total
current, which we know will be the same as each resistor current,
currents being equal in all parts of a series circuit:
#image("static/10098.png")
Now, knowing that the circuit current is 2 mA, we can use Ohm\'s Law
($E = I R$) to calculate voltage across each resistor:
#image("static/10099.png")
It should be apparent that the voltage drop across each resistor is
proportional to its resistance, given that the current is the same
through all resistors. Notice how the voltage across R#sub[2] is double
that of the voltage across R#sub[1], just as the resistance of R#sub[2]
is double that of R#sub[1].
If we were to change the total voltage, we would find this
proportionality of voltage drops remains constant:
#image("static/10100.png")
The voltage across R#sub[2] is still exactly twice that of R#sub[1]\'s
drop, despite the fact that the source voltage has changed. The
proportionality of voltage drops (ratio of one to another) is strictly a
function of resistance values.
With a little more observation, it becomes apparent that the voltage
drop across each resistor is also a fixed proportion of the supply
voltage. The voltage across R#sub[1], for example, was 10 volts when the
battery supply was 45 volts. When the battery voltage was increased to
180 volts (4 times as much), the voltage drop across R#sub[1] also
increased by a factor of 4 (from 10 to 40 volts). The #emph[ratio]
between R#sub[1]\'s voltage drop and total voltage, however, did not
change:
$ E_(R 1) / E_"total" = (10 V) / (45 V) = (40 V) / (180 V) = 0.22222 $
Likewise, none of the other voltage drop ratios changed with the
increased supply voltage either:
$ E_(R 2) / E_"total" = (20 V) / (45 V) = (80 V) / (180 V) = 0.44444 $
$ E_(R 3) / E_"total" = (15 V) / (45 V) = (60 V) / (180 V) = 0.33333 $
For this reason a series circuit is often called a #emph[voltage
divider] for its ability to proportion -- or divide -- the total voltage
into fractional portions of constant ratio. With a little bit of
algebra, we can derive a formula for determining series resistor voltage
drop given nothing more than total voltage, individual resistance, and
total resistance:
$ "Voltage drop across any resistor" => E_r = I_r R_r $
$ "Current in a series circuit" => I_"total" = E_"total" / R_"total" $
$ ... "Substituting" E_"total" / R_"total" "for" I_r "in the first equation" ... $
$ "Voltage drop across any series resistor" => E_r = E_"total" / R_"total" R_r $
$ ... "or" .. $
#core.boxed_text[
$ E_r = E_"total" R_r/R_"total" $
]
The ratio of individual resistance to total resistance is the same as
the ratio of individual voltage drop to total supply voltage in a
voltage divider circuit. This is known as the #emph[voltage divider
formula], and it is a short-cut method for determining voltage drop in a
series circuit without going through the current calculation(s) of
Ohm\'s Law.
Using this formula, we can re-analyze the example circuit\'s voltage
drops in fewer steps:
#image("static/00106.png")
$
E_(R 1) &= 45 V (5k Omega)/(22.5k Omega) = 10 V \
E_(R 2) &= 45 V (10k Omega)/(22.5k Omega) = 20 V \
E_(R 3) &= 45 V (7.5k Omega)/(22.5k Omega) = 15 V \
$
Voltage dividers find wide application in electric meter circuits, where
specific combinations of series resistors are used to \"divide\" a
voltage into precise proportions as part of a voltage measurement
device.
#image("static/00107.png")
One device frequently used as a voltage-dividing component is the
#emph[potentiometer], which is a resistor with a movable element
positioned by a manual knob or lever. The movable element, typically
called a #emph[wiper], makes contact with a resistive strip of material
(commonly called the #emph[slidewire] if made of resistive metal wire)
at any point selected by the manual control:
#image("static/00108.png")
The wiper contact is the left-facing arrow symbol drawn in the middle of
the vertical resistor element. As it is moved up, it contacts the
resistive strip closer to terminal 1 and further away from terminal 2,
lowering resistance to terminal 1 and raising resistance to terminal 2.
As it is moved down, the opposite effect results. The resistance as
measured between terminals 1 and 2 is constant for any wiper position.
#image("static/00109.png")
Shown here are internal illustrations of two potentiometer types, rotary
and linear:
#image("static/00483.png")
#image("static/00484.png")
Some linear potentiometers are actuated by straight-line motion of a
lever or slide button. Others, like the one depicted in the previous
illustration, are actuated by a turn-screw for fine adjustment ability.
The latter units are sometimes referred to as #emph[trimpots], because
they work well for applications requiring a variable resistance to be
\"trimmed\" to some precise value. It should be noted that not all
linear potentiometers have the same terminal assignments as shown in
this illustration. With some, the wiper terminal is in the middle,
between the two end terminals.
The following photograph shows a real, rotary potentiometer with exposed
wiper and slidewire for easy viewing. The shaft which moves the wiper
has been turned almost fully clockwise so that the wiper is nearly
touching the left terminal end of the slidewire:
#image("static/50031.jpg")
Here is the same potentiometer with the wiper shaft moved almost to the
full-counterclockwise position, so that the wiper is near the other
extreme end of travel:
#image("static/50032.jpg")
If a constant voltage is applied between the outer terminals (across the
length of the slidewire), the wiper position will tap off a fraction of
the applied voltage, measurable between the wiper contact and either of
the other two terminals. The fractional value depends entirely on the
physical position of the wiper:
#image("static/00363.png")
Just like the fixed voltage divider, the potentiometer\'s voltage
#emph[division ratio] is strictly a function of resistance and not of
the magnitude of applied voltage. In other words, if the potentiometer
knob or lever is moved to the 50 percent (exact center) position, the
voltage dropped between wiper and either outside terminal would be
exactly 1/2 of the applied voltage, no matter what that voltage happens
to be, or what the end-to-end resistance of the potentiometer is. In
other words, a potentiometer functions as a variable voltage divider
where the voltage division ratio is set by wiper position.
This application of the potentiometer is a very useful means of
obtaining a variable voltage from a fixed-voltage source such as a
battery. If a circuit you\'re building requires a certain amount of
voltage that is less than the value of an available battery\'s voltage,
you may connect the outer terminals of a potentiometer across that
battery and \"dial up\" whatever voltage you need between the
potentiometer wiper and one of the outer terminals for use in your
circuit:
#image("static/00364.png")
When used in this manner, the name #emph[potentiometer] makes perfect
sense: they #emph[meter] (control) the #emph[potential] (voltage)
applied across them by creating a variable voltage-divider ratio. This
use of the three-terminal potentiometer as a variable voltage divider is
very popular in circuit design.
Shown here are several small potentiometers of the kind commonly used in
consumer electronic equipment and by hobbyists and students in
constructing circuits:
#image("static/50037.jpg")
The smaller units on the very left and very right are designed to plug
into a solderless breadboard or be soldered into a printed circuit
board. The middle units are designed to be mounted on a flat panel with
wires soldered to each of the three terminals.
Here are three more potentiometers, more specialized than the set just
shown:
#image("static/50038.jpg")
The large \"Helipot\" unit is a laboratory potentiometer designed for
quick and easy connection to a circuit. The unit in the lower-left
corner of the photograph is the same type of potentiometer, just without
a case or 10-turn counting dial. Both of these potentiometers are
precision units, using multi-turn helical-track resistance strips and
wiper mechanisms for making small adjustments. The unit on the
lower-right is a panel-mount potentiometer, designed for rough service
in industrial applications.
#core.review[
- Series circuits proportion, or #emph[divide], the total supply voltage
among individual voltage drops, the proportions being strictly
dependent upon resistances: $E_(R_n) = E_"Total" (R_n /
R_"Total")$
- A potentiometer is a variable-resistance component with three
connection points, frequently used as an adjustable voltage divider.
]
|
https://github.com/maxgraw/bachelor | https://raw.githubusercontent.com/maxgraw/bachelor/main/apps/document/src/0-base/5-figures.typ | typst | #set heading(numbering: none, supplement: [Abschnitt])
= Abbildungsverzeichnis
#outline(
title: none,
target: figure.where(kind: image),
)
#pagebreak() |
|
https://github.com/kotfind/hse-se-2-notes | https://raw.githubusercontent.com/kotfind/hse-se-2-notes/master/prob/lectures/2024-09-20.typ | typst | #import "/utils/math.typ": *
= Независимость в совокупности
#def[
События $A_1, ..., A_n$ #defitem[независимы в совокупности], если
$ forall 1 <= i_1 < i_2 < ... < i_k <= n: P(A_1 A_2 ...) = P(A_(i_1)) P(A_(i_2)) ... $
]
- Независимы в совокупности $->$ независимы попарно
- Независимы все подмножества $->$ независимы совокупно
#blk[
Тетраэдр; Стороны: красная, синяя, зеленая, все вместе
$A_1$ --- выпала грань с *красным* цветом
$A_2$ --- выпала грань с *синим* цветом
$A_3$ --- выпала грань с *зеленым* цветом
$ P(A_1) = P(A_2) = P(A_3) = 2/4 = 1/2 $
$ P(A_1 A_2) = P(A_1 A_3) = P(A_2 A_3) = 1/4 $
$ P(A_1 A_2 A_3) = 1/4 eq.not P(A_1) P(A_2) P(A_3) $
]
= Теорема умножения вероятностей
Пусть $P(A_1 A_2 ... A_n) > 0$, $ P(overbrace(A_1 ... A_n, A))
= P(A_1) P(A_2 | A_1) P(A_3 | A_1 A_2) ... P(A_n | A_1 ... A_(n-1)) $
#proof[
Пусть:
$
B_(n-1) = A_1 ... A_(n-1) \
B_(n-2) = A_1 ... A_(n-2) \
dots.v \
B_1 = A_1
$
Тогда
$ A = B_(n-1) A_n $
$
P(A) &= P(B_(n-1) A_n) =\
&= P(overbrace(B_(n-1), B_(n-2) A_(n-1))) P(A_n | B_(n-1)) =\
&= P(A_n | A_1 ... A_(n-1))P(B_(n-2))P(A_(n-2) | B_(n-2)) = ...
$
]
#blk(title: [Пример])[
Перестановки: МАТАН
$ P("'М'" "'А'" "'Т'" "'А'" "'Н'") =\
= P("'М'")
P("'А'" | "'М'" )
P("'Т'" | "'М'" "'А'")
P ("'А'" | "'М'" "'А'" "'Т'")
P("'Н'" | "'М'" "'А'" "'Т'" "'А'") =\
= 1/5 dot 2/4 dot 1/3 dot 1/2 dot 1 $
]
= Биномиальная схема испытаний Бернулли
Схема испытаний, которая удовлетворяет условиям:
- Исход двоичен. Происходит $A$ (успех) или $overline(A)$ (неудача)
- Всех испытания независимы в совокупности
- $p = P(A)$ не изменяется от опыта к опыту
$k$ успехов из $n$ испытаний:
$ P_n(k) = C_n^k p^k (1 - p)^(n - k) = C_n^k p^k q^(n-k) $
#proof[
Если все успехи в начале:
$ P(underbrace("УУ...У", k)"НН...Н") = p^k q^(n-k) $
Учтем перестановки. Выберем, где места будут успехи ($C_n^k$ способов):
$ P_n(k) = C_n^k p^k q^(n-k) $
]
$ P(k_1 <= k <= k_2) = sum^(k_2)_(i = k_1) C_n^i p^i q^(n-i) $
$ 1 = sum^n_(k=0) P_n(k) = sum^n_(k=0) C_n^i p^i q^(n-i) = (p + q)^n = 1^n = 1 $
== Наиболее вероятное число успехов
По определению:
$ k_0 = "argmax"_(1 <= i <= n) C_n^i p^i q^(n-i) $
По удобному:
$ k_0 = cases(
[(n + 1)p] &" если " (n + 1)p in.not ZZ,
(n + 1)p " и " (n + 1)p - 1 &" если " (n + 1)p in ZZ,
) $
= Формула полной вероятности
#def[
Пусть $H_1, ..., H_n in Omega$. Если
+ $forall i eq.not j: H_i dot H_j = emptyset$
+ $H_1 + ... + H_n = Omega$
то $H_1, ..., H_n$ #defitem[полная группа событий (гипотезы)]
]
#figure(
caption: [Полная группа событий (гипотезы)],
image("./hypotises.svg", height: 5cm)
)
Пусть $A subset Omega, H_1, ... H_n$ --- полная группа событий
$ P(A) &= P(A dot Omega) = P(A dot (H_1 + ... + H_n)) =\ &= P(A H_1 + ... A H_n)
overbrace(=, "т.к несовместны") P(H_1) P(A | H_1) + ... + P(H_n) P(A | H_n) $
#blk(title: "Пример")[
$N$ --- всего билетов
$m$ --- билетов студент Сидоров выучил
$A$ --- Сидорову попался счастливый билет
Иванов заходит первый. Сидоров заходит второй.
$H_1$ --- Иванов вытащил счастливый (для Сидорова)
$H_2$ --- Иванов вытащил *не* счастливый (для Сидорова)
$ P(H_1) = m / N $
$ P(H_2) = (N - m) / N $
$ P(A) &= P(H_1) P(A | H_1) + P(H_2) P(A | H_2) =\
&= m/N dot (m-1)/(N-1) + (N-m)/N dot m/(N-1) $
]
Для гипотез:
- Априорные вероятности --- знаем ещё до опыта:
$ P(H_1), ..., P(H_n) $
- Апостериорные вероятности --- вероятности гипотез после эксперимента (когда
знаем, что некоторое событие уже произошло):
$ P(H_1 | A), ..., P(H_n | A) $
|
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/text/copy-paste_00.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
The after fira 🏳️🌈!
#set text(lang: "ar", font: "Noto Sans Arabic")
مرحبًا
|
https://github.com/Akida31/anki-typst | https://raw.githubusercontent.com/Akida31/anki-typst/main/typst/tests/examples/more/test.typ | typst | #import "/src/lib.typ" as anki
#import anki.theorems: item
#show: anki.setup.with(
enable_theorems: true,
prefix_deck_names_with_numbers: true,
title: "TITLE",
)
#set heading(numbering: "1.")
#let theorem = item("Theorem", proof_name: "Precious Proof", initial_tags: ("proof",))
#let example = item("Example", initial_tags: ("example",), id: fields => fields.at("number"))
#let unnumbered = item("Unnumbered", numbering: none)
// NOTE that this requires a model named `some-model`. If you just want to try this out you can delete this line.
// The default model is anki-typst.
#anki.theorems.model("some-model")
= Heading
== Subheading
#theorem("Euclid")[
Theorem-content
][
This is a proof
]<euclid>
#unnumbered("Notation")[
Did you know? @euclid was also a human
]
= Heading2
#example("Pythagoras")[
Did you know?
$ a^2 + b^2 = c^2 $
]
#example("hey", secondary: auto)[]
#anki.set_date("2024")
#example("ho")[]
#let bemerkung = item("Bemerkung")
#bemerkung("F", secondary: auto)[
]
#anki.set_date("2024")
#bemerkung("∞")[
D
]
#anki.set_date("2024-04-13")
We start with an example
#example("TODO")[
This is an example: $i^2 = -1$
]
#example("whats", secondary: auto)[
$ 1 + 1 = 2 $
]
#anki.set_date("2024")
#example("up")[] |
|
https://github.com/The-Notebookinator/notebookinator | https://raw.githubusercontent.com/The-Notebookinator/notebookinator/main/utils/misc.typ | typst | The Unlicense | /// Returns the raw image data, not image content
/// You'll still need to run image.decode on the result
///
/// - raw-icon (string): The raw data for the image. Must be svg data.
/// - fill (color): The new icon color
/// -> string
#let change-icon-color(
raw-icon: "",
fill: red,
) = {
return raw-icon.replace(
"<path",
"<path style=\"fill: " + fill.to-hex() + "\"",
)
}
/// Takes the path to an icon as input, recolors that icon, and then returns the decoded image as output.
///
/// - path (string): The path to the icon. Must point to a svg.
/// - fill (color): The new icon color.
/// - width (ratio length): Width of the image
/// - height (ratio length): height of the image
/// - fit (string): How the image should adjust itself to a given area. Takes either "cover", "contain", or "stretch"
/// -> content
#let colored-icon(
path,
fill: red,
width: 100%,
height: 100%,
fit: "contain",
) = {
let raw-icon = read(path)
let raw-colored-icon = raw-icon.replace(
"<path",
"<path style=\"fill: " + fill.to-hex() + "\"",
)
return image.decode(
raw-colored-icon,
width: width,
height: height,
fit: fit,
)
}
|
https://github.com/TechnoElf/mqt-qcec-diff-thesis | https://raw.githubusercontent.com/TechnoElf/mqt-qcec-diff-thesis/main/content/background.typ | typst | = Background
This section presents an overview of the technologies and concepts used throughout this work.
Specifically, to understand the methods developed in this thesis, it is necessary to understand quantum computation in general as well as the methods for representing and manipulating quantum functionality.
Additionally, knowledge of the problems of comparing sequences of values and especially the @lcs problem is required.
All of these topics will be covered in this section.
The application of these to quantum circuit verification will then be discussed in the next section.
#include "background/quantum.typ"
#include "background/dd.typ"
#include "background/lcs.typ"
|
|
https://github.com/saurabtharu/Internship-repo | https://raw.githubusercontent.com/saurabtharu/Internship-repo/main/Internship%20Report%20-%20typst/chapters/chapter-1-intro.typ | typst | /*
While I was an intern at F1Soft International, one of the leading fintech companies, I got deeply involved in DevOps. F1Soft International is famous for its creative financial products that serve various clients like banks, financial institutions and big businesses. They use modern technology so as to make financial services available to everyone and enhance their experience in the digital space. I was supposed to make their development and operation processes more efficient and effective since I was working in this department.
This practical training enabled me engage myself in projects where software development meets operations commonly referred to as DevOps. It mainly entailed creating Continuous Integration (CI) servers; systems which automate building and testing new software versions whenever developers commit changes into a shared repository thus keeping the codebase constantly updated with all working builds. These servers help integrate these builds more frequently hence allowing for reliable deployment and reducing time taken from development completion to its release in production environment among others.
Besides CI/CD pipeline automation, I was also tasked with managing the company’s bare metal infrastructure. Unlike working on clouds which offer virtualized environment with unlimited resources at your disposal, using physical servers brought about their fair share of challenges and learning opportunities such as direct hardware control including manual configurations among others that were not present when dealing purely with software layers like OS installations and configurations etc…. My responsibility included ensuring security against threats like unauthorized access or data breaches; optimizing performance through load balancing measures while at same time making sure availability never goes below certain levels even during peak usage hours – sometimes this meant working late into night hours depending on nature of demand spikes being experienced by different services hosted within our platforms.
The areas of focus I had while working here were mainly centered on making the current systems more effective. This involved getting rid of repetitive manual jobs through automation, improving how we monitor our systems as well as coming up with alerts that would help us take care of any arising issues immediately. My goal through this was to minimize downtime by having fewer hand-operated interventions so that F1Soft’s applications could run smoothly and reliably all the time.
This document records what I achieved during my time of training; it outlines projects I handled, difficulties I faced and how I solved them. It also indicates some capabilities and understanding gained throughout which added towards shaping me into a better professional in DevOps. In addition, it is meant to give an oversight about what I did in relation to company’s infrastructure at large (specifically focusing on their server setup) as well as show the general effect brought about by my efforts towards enhancing operational efficiency within F1Soft.
From this internship period onwards not only have I been able to get hands-on skills in various areas related to DevOps but also realize the significance of this practice in connecting software development teams with IT operations unit. Furthermore, my engagement at F1Soft highlighted the need for continuous improvement alongside team work and automated tests if one is to deliver quality products frequently. These insights will serve as a foundation upon which future challenges can be tackled within DevOps field thereby building more capable engineers like myself who are always ready for anything.
#pagebreak()
Over the course of my internship at F1Soft International—a prominent fintech company—I got a comprehensive understanding of DevOps. F1Soft International is one of the most well-known names in innovative financial solutions, offering a wide array of innovative and advanced solutions to commercial banks, development banks, financial institutions, and several other large enterprises. The company is committed to using advanced technology with the view of enhancing financial inclusion and making digital experience seamless. My primary responsibility, as a member of their DevOps team, has been to streamline and enhance the development and operational processes, ensuring that the resulting systems are robust, efficient, and reliable.
At this internship, I was given a unique opportunity to work on live projects that demanded integrating software development and IT operations, which both together integrate as DevOps. Primarily, my work was around setting up and optimizing CI/CD—continuous integration and continuous deployment—pipelines, which are the foundation of a practice that automates the software delivery process. These pipelines help integrate code changes more frequently and deploy them reliably, reducing time to market and increasing the overall productivity of the development team.
Further, I was responsible for managing the bare-metal infrastructure at F1Soft, unlike the cloud-based environments. Some of the key learning areas and challenges of working with bare-metal servers include direct hardware management, manual configuration, and optimization of performance, as well as making the infrastructure capable of scaling to meet the growing demands while remaining secure against the threats and ensuring high availability.
One of the core objectives throughout my stint was ensuring that the present systems were efficient enough. This, in turn, implied the automation of repetitive tasks, augmentation of system monitoring, and implementation of alerting mechanisms to ensure that all issues are promptly fixed. By doing so, I aimed to reduce manual intervention, minimize downtime, and ensure that the applications delivered by F1Soft were running smoothly and reliably.
This report outlines my way throughout the internship, the projects I undertook, the difficulties I faced, and their solutions. It also outlines the skills and knowledge I have attained during this time and which are important for my growth into a DevOps practitioner. The structure of the report provides a sufficient viewpoint on my contribution to F1Soft's infrastructure and the overall impact of my work on their operational efficiency.
Not just practical experience, but also the critical role of DevOps to bridge the gap between software development and IT operations, gets to be known through this internship. Working at F1Soft has shown me how to accentuate the importance of continual improvement, collaboration, and automation in the delivery of high-quality software products. Skills and insights to be gained during this period are preparing me to face future challenges in the field of DevOps, making me a more proficient and capable engineer.
#pagebreak()
*/
= Chapter 1: Introduction
\
== 1.1. Introduction
#v(15pt, weak: true)
Over the course of my DevOps internship at F1Soft International, the chance was given to fully embrace the DevOps culture and observe how it has been used effectively to bridge the gap between software development and IT operations. F1Soft International is one of the most well-known names in innovative financial solutions, offering a wide array of innovative and advanced solutions to commercial banks, development banks, financial institutions, and several other large enterprises. The company is committed to using advanced technology with the view of enhancing financial inclusion and making digital experience seamless.The primary responsibility, as a member of the DevOps team, has been to learn how to streamline and enhance the development and operational processes, so that the resulting systems could be robust, efficient, and reliable.
The main duty included understanding the implementation of DevOps practices to automate and simplify different parts of the software delivery process. This entailed creation as well as optimization of Continuous Integration/Continuous Deployment (CI/CD) pipelines which automate integration of code changes frequently and reliably should be deployed; they are important in reducing time-to-market while increasing overall development team's productivity.
Additionally, there was an opportunity was given to observe how corporations utilize automation for handling repetitive tasks in their environments. Automation not only saves time but also reduces human error, thereby increasing reliability and yielding consistent results. Practical experience was gained in automating routine operations, configuring infrastructures without any challenges, and managing applications seamlessly deployed across different systems or platforms.
// This paper serves as a documentation of my internship experience showing what projects I worked on, where difficulties arose and how they were solved. It also indicates the skills gained and knowledge acquired which contributed immensely to shaping me into becoming an expert DevOps professional.
Real-world experience with DevOps, complementing the theoretical knowledge I previously acquired, has been one of the best outcomes of this internship. A better understanding of the collaborative and iterative nature of DevOps was also achieved. F1Soft has been able to produce quality software faster by focusing on continuous improvement, automation, and ensuring effective communication between development and operations teams. These skills and ideas will help in handling future challenges in this area, thereby contributing to becoming an even better engineer.
#v(10pt)
== 1.2. Problem Statement
#v(15pt, weak: true)
F1Soft International, like many tech-driven organizations, faced challenges related to the manual processes in software deployment, the scalability of their infrastructure, and the efficiency of their operational workflows. The primary issues included:
#set enum(numbering: "i)")
+ *Manual Deployment Processes*: \ The existing deployment processes were largely manual, leading to inconsistencies, longer deployment times, and higher risk of errors.
+ *Infrastructure Scalability*: \ With a growing user base, the need for scalable infrastructure became critical. The current setup struggled to efficiently handle the increased load, affecting performance and user experience.
+ *Operational Efficiency*: \ The lack of automated workflows resulted in slower response times to incidents and less efficient use of resources.
Addressing these problems was crucial for maintaining F1Soft’s competitive edge, ensuring customer satisfaction, and supporting the company’s growth objectives.
#v(10pt)
== 1.3. Objectives
#v(15pt, weak: true)
The primary objectives of my internship at F1Soft International were:
#set enum(numbering: "i)")
+ *Gain Professional Experience*: \ Work in a real-world corporate environment to understand team dynamics, project management, and effective communication within a professional setting.
+ *Develop Problem-Solving Skills*: \ Tackle real-world challenges and develop solutions, enhancing critical thinking and problem-solving abilities.
+ *Automate Deployment Processes*: \ Implement CI/CD pipelines to automate the build, test, and deployment processes, reducing deployment time and errors.
+ *Improve Operational Efficiency*: \ Develop and integrate automated monitoring and alerting systems to enhance incident response times and operational efficiency.
#v(10pt)
== 1.4. Scope and Limitation
#v(15pt, weak: true)
*1.4.1. Scope* \
The scope of my internship included the following key areas:
+ *CI/CD Pipeline Implementation*: \ Setting up automated pipelines for continuous integration and deployment on bare-metal servers.
+ *Bare-Metal Infrastructure Management*: \ Designing and deploying scalable solutions using physical servers.
+ *Monitoring and Alerting*: \ Implementing tools like Prometheus and Grafana for monitoring and setting up alerting mechanisms.
+ *Security Enhancements*: \ Adding security checks within the CI/CD pipeline and ensuring infrastructure compliance with security standards.
*1.4.2. Limitations* \
Despite the comprehensive scope, there were some limitations during my internship:
+ *Time Constraints*: \ The duration of the internship was limited, which restricted the depth of exploration and implementation of certain advanced DevOps practices and tools.
+ *Resource Availability*: \ Access to certain hardware and software resources was limited, which occasionally hindered the implementation and testing of specific solutions on a larger scale.
+ *Learning Curve*: \ The complexity of some tools and technologies, especially those I was unfamiliar with, required significant time to learn, reducing the time available for hands-on application.
+ *Assigned Task Scope*: \ The tasks assigned were predetermined, leaving limited room to explore additional areas of personal or emerging interest within the DevOps field.
#v(10pt)
== 1.5. Report Organization
#v(15pt, weak: true)
This report is structured into four main chapters, each detailing different aspects of my internship experience at F1Soft International. Here is a brief overview of each chapter:
+ *Chapter 1: Introduction* \ This chapter introduces the work completed during my internship. It outlines the problem statement, the objectives of the internship, the scope and limitations of the project, and provides an overview of the report’s organization.
+ *Chapter 2: Organization Details and Literature Review* \ In this chapter, a comprehensive introduction to F1Soft International has been provided. This includes an overview of the organization, its hierarchy, the various domains in which it operates, and a detailed description of the department where internship has been completed. Additionally, this chapter includes a literature review or related study, highlighting relevant theories and frameworks that underpin the works that have been performed during the internship.
+ *Chapter 3: Internship Activities* \ This chapter delves into the specifics of my internship activities. It outlines my roles and responsibilities, provides a weekly log of the technical activities, describes the involved projects, and details the technical tasks and activities have been completed successfully. This section offers an in-depth look at the hands-on experience obtained.
+ *Chapter 4: Conclusion and Learning Outcomes* \ A brief overview of the experience gained during the internship is also stated in this last part, as well as the main conclusions. It mentions my skills and knowledge, challenges I faced and how I dealt with them. Additionally, the section talks about what the future holds in terms of career development after such an opportunity.
#pagebreak() |
|
https://github.com/neeruuppalapati/MATH-Notes | https://raw.githubusercontent.com/neeruuppalapati/MATH-Notes/main/template.typ | typst | // Imports =============================================================
#import "@preview/whalogen:0.1.0": ce
#import "@preview/codelst:1.0.0": sourcecode, codelst
#import "@preview/showybox:2.0.1": showybox
#import "@preview/ctheorems:1.0.0": *
// Template ============================================================
#let template(
// The title of the lecture notes
title: "Lecture Notes Title",
// The short_title is shown in the running header
short_title: none, // string
// The description of the lecture notes; is optional. Example:
// description: [A template for lecture notes]
description: none,
// The date of the lecture notes; is optional. Example
// datetime(year: 2020, month: 02, day: 02)
date: none,
// An array of authors. For each author you can specify a name, orcid, and affiliations.
// affiliations should be content, e.g. "1", which is shown in superscript and should match the affiliations list.
// Everything but but the name is optional.
authors: (
// name: "",
// orcid: "",
// link: "",
// affiliations: "1,2",
),
// This is the affiliations list. Include an id and `name` in each affiliation. These are shown below the authors.
affiliations: (
// (id: "1", name: "Organization 1"),
// (id: "2", name: "Organization 2"),
),
// Enable/disable the list of figures, tables, and listings.
lof: false,
lot: false,
lol: false,
// The path to a bibliography file if you want to cite some external works.
bibliography_file: none,
// Citation style
bibstyle: "apa",
// The article's paper size. Also affects the margins.
paper_size: "a4",
// The number of columns to be used in the page
cols: 1,
// The text and code font. Must be a valid font name.
text_font: "Linux Libertine",
code_font: "DejaVu Sans Mono",
// The color of the lecture notes' accent color. Must be a valid HEX color.
accent: "#DC143C",
// The lecture notes' content.
body
) = {
// Necessary for ctheorems package
show: thmrules
// Logos
let orcidSvg = ```<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24"> <path fill="#AECD54" d="M21.8,12c0,5.4-4.4,9.8-9.8,9.8S2.2,17.4,2.2,12S6.6,2.2,12,2.2S21.8,6.6,21.8,12z M8.2,5.8c-0.4,0-0.8,0.3-0.8,0.8s0.3,0.8,0.8,0.8S9,7,9,6.6S8.7,5.8,8.2,5.8z M10.5,15.4h1.2v-6c0,0-0.5,0,1.8,0s3.3,1.4,3.3,3s-1.5,3-3.3,3s-1.9,0-1.9,0H10.5v1.1H9V8.3H7.7v8.2h2.9c0,0-0.3,0,3,0s4.5-2.2,4.5-4.1s-1.2-4.1-4.3-4.1s-3.2,0-3.2,0L10.5,15.4z"/></svg>```.text
let accent_color = {
if type(accent) == "string" {
rgb(accent)
} else if type(accent) == "color" {
accent
} else {
rgb("#DC143C")
}
}
// Construct string title from title content
let str_title = ""
if type(title) == content and title.has("children") {
for element in title.children {
if element.has("text") {
str_title = str_title + element.text + " "
}
}
} else if type(title) == "string" {
str_title = title
}
str_title = str_title.trim(" ")
// Set document metadatra
set document(title: str_title, author: authors.map(author => author.name))
set par(justify: false)
// Set the text and code font
set text(font: text_font, size: 10pt)
show raw: set text(font: code_font)
// Make links blue and underlined. Disable for author list.
show link: it => {
let author_names = ()
for author in authors {
author_names.push(author.name)
}
if it.body.has("text") and it.body.text in author_names {
it
} else {
underline(stroke: (dash: "densely-dotted"), text(fill: blue, it))
}
}
// Configure the page.
set page(
paper: paper_size,
columns: cols,
numbering: "1 / 1",
number-align: center,
// The margins depend on the paper size.
margin: if cols > 1 {
(x: 36pt, y: 72pt)
} else {
auto
// 72pt
// (x: 1.25in, y: 1in)
},
// if paper_size == "a4" {
// (x: 41.5pt, top: 80.51pt, bottom: 89.51pt)
// } else {
// (
// x: (50pt / 216mm) * 100%,
// top: (55pt / 279mm) * 100%,
// bottom: (64pt / 279mm) * 100%,
// )
// },
header: locate(loc => {
let elems = query(
selector(heading.where(level: 1)).before(loc),
loc,
)
let head_title = text(fill: accent_color)[
#if short_title != none { short_title } else { str_title }
]
if elems == () {
align(right, "")
} else {
let current_heading = elems.last()
if current_heading.numbering != none {
emph(counter(heading.where(level: 1)).display("1. ") + current_heading.body) + h(1fr) + head_title
} else {
emph(current_heading.body) + h(1fr) + head_title
}
v(-7pt)
line(length: 100%, stroke: (thickness: 1pt, paint: accent_color, dash: "solid"))
}
})
)
// Configure equation numbering and spacing.
set math.equation(numbering: "[1.1]")
show math.equation: eq => {
set block(spacing: 0.65em)
eq
}
// Configure lists.
set enum(indent: 0pt, body-indent: 6pt)
set list(indent: 0pt, body-indent: 6pt)
// TODO: Configure headings
set heading(numbering: "1.1.1.1.1.")
show heading: it => {
it
v(12pt, weak: true)
}
// Configure code blocks.
show raw.where(
block: false,
): it => box(fill: luma(240), inset: (x: 2pt), outset: (y: 3pt), radius: 1pt)[#it]
// show raw.where(
// block: true,
// ): it => block(
// breakable: false,
// width: 100%,
// fill: luma(240),
// radius: 4pt,
// inset: (x: 1.5em, y: 1em)
// )[#it]
show: codelst(reversed: true)
// Configure figures
// set figure(placement: auto)
show figure.where(
kind: table
): set figure.caption(position: top)
show figure.where(
kind: raw
): it => {
set block(width: 100%)
it
}
// Display the paper's title and description.
align(center, [
#set text(18pt, weight: "bold")
#title
])
if description != none {
align(center, box(width: 90%)[
#set text(size: 12pt, style: "italic")
#description
])
}
v(18pt, weak: true)
// Authors and affiliations
align(center)[
#if authors.len() > 0 {
box(inset: (y: 10pt), {
authors.map(author => {
text(11pt, weight: "semibold")[
#if "link" in author {
[#link(author.link)[#author.name]]
} else { author.name }]
if "affiliations" in author {
super(author.affiliations)
}
if "orcid" in author {
link("https://orcid.org/" + author.orcid, box(height: 1.1em, baseline: 13.5%)[#image.decode(orcidSvg)])
}
}).join(", ", last: {
if authors.len() > 2 {
", and"
} else {
" and"
}
})
})
}
#v(-2pt, weak: true)
#if affiliations.len() > 0 {
box(inset: (bottom: 10pt), {
affiliations.map(affiliation => {
text(8pt)[
#super(affiliation.id)#h(1pt)#affiliation.name
]
}).join(", ")
})
}
]
v(6pt, weak: true)
// Display the lecture notes' last updated date.
if date != none {
align(center, table(
columns: (auto, auto),
stroke: none,
gutter: 0pt,
align: (right, left),
[#text(size: 11pt, "Published:")],
[#text(
size: 11pt,
fill: accent_color,
weight: "semibold",
date.display("[month repr:long] [day padding:zero], [year repr:full]")
)
],
text(size: 11pt, "Last updated:"),
text(
size: 11pt,
fill: accent_color,
weight: "semibold",
datetime.today().display("[month repr:long] [day padding:zero], [year repr:full]")
)
))
} else {
align(center,
text(size: 11pt)[Last updated:#h(5pt)] + text(
size: 11pt,
fill: accent_color,
weight: "semibold",
datetime.today().display(
"[month repr:long] [day padding:zero], [year repr:full]"
)
)
)
}
v(18pt, weak: true)
show outline.entry: it => {
text(fill: accent_color)[#it]
}
// Display the lecture notes' table of contents.
outline(indent: auto)
if lof [
#v(3pt)
#outline(
indent: auto,
title: [List of Figures],
target: figure.where(kind: image),
)
]
if lot [
#v(3pt)
#outline(
indent: auto,
title: [List of Tables],
target: figure.where(kind: table),
)
]
if lol [
#v(3pt)
#outline(
indent: auto,
title: [List of Listings],
target: figure.where(kind: raw),
)
]
v(24pt, weak: true)
// Set paragraph to be justified and set linebreaks
set par(justify: true, linebreaks: "optimized", leading: 0.8em)
// Display the lecture notes' content.
body
v(24pt, weak: true)
// Display bibliography.
if bibliography_file != none {
show bibliography: set text(8pt)
bibliography(bibliography_file, title: text(10pt)[References], style: bibstyle)
}
}
// Functions ===========================================================
// Configure blockquotes.
#let blockquote(cite: none, body) = [
#set text(size: 0.97em)
#pad(left: 1.5em)[
#block(
breakable: true,
width: 100%,
fill: gray.lighten(90%),
radius: (left: 0pt, right: 5pt),
stroke: (left: 5pt + gray, rest: 1pt + silver),
inset: 1em
)[#body]
]
]
// Configure horizontal ruler
#let horizontalrule = [#v(0.5em) #line(start: (20%,0%), end: (80%,0%)) #v(0.5em)]
// Configure alternative horizontal ruler
#let sectionline = align(center)[#v(0.5em) * \* #sym.space.quad \* #sym.space.quad \* * #v(0.5em)]
// Attempt to add \boxed{} command from LaTeX
#let dboxed(con) = box(stroke: 0.5pt + black, outset: (x: 2pt), inset: (y: 8pt), baseline: 11pt, $display(#con)$)
#let iboxed(con) = box(stroke: 0.5pt + black, outset: (x: 2pt), inset: (y: 3pt), baseline: 2pt, $#con$)
// ==== Nice boxes using showybox and ctheorems packages ====
//
// | Environment | Accent Color |
// |-------------|----------------------|
// | Definition | olive |
// | Example | purple |
// | Note | blue |
// | Attention | red / rgb("#DC143C") |
// | Quote | black |
// | Theorem | navy |
// | Proposition | maroon |
#let boxnumbering = "1.1.1.1.1.1"
#let boxcounting = "heading"
#let definition = thmenv(
"definition",
"Definition",
boxcounting,
none,
(name, number, body, ..args) => {
showybox(
title: [#name #h(1fr) Definition #number],
frame: (
border-color: olive,
title-color: olive.lighten(30%),
body-color: olive.lighten(95%),
footer-color: olive.lighten(80%),
),
..args.named(),
body
)
}
).with(numbering: boxnumbering)
#let example = thmenv(
"example",
"Example",
boxcounting,
none,
(name, number, body, ..args) => {
showybox(
title: [#name #h(1fr) Example #number],
frame: (
border-color: purple,
title-color: purple.lighten(30%),
body-color: purple.lighten(95%),
footer-color: purple.lighten(80%),
),
..args.named(),
body
)
}
).with(numbering: boxnumbering)
#let note = thmenv(
"note",
"Note",
boxcounting,
none,
(name, number, body, ..args) => {
showybox(
title: [#name #h(1fr) Note #number],
frame: (
border-color: blue,
title-color: blue.lighten(30%),
body-color: blue.lighten(95%),
footer-color: blue.lighten(80%),
),
..args.named(),
body
)
}
).with(numbering: boxnumbering)
#let attention = thmenv(
"attention",
"Attention",
boxcounting,
none,
(name, number, body, ..args) => {
showybox(
title: [#name #h(1fr) Attention #number],
frame: (
border-color: rgb("#DC143C"),
title-color: rgb("#DC143C").lighten(30%),
body-color: rgb("#DC143C").lighten(95%),
footer-color: rgb("#DC143C").lighten(80%),
),
..args.named(),
body
)
}
).with(numbering: boxnumbering)
#let quote = thmenv(
"quote",
"Quote",
boxcounting,
none,
(name, number, body, ..args) => {
showybox(
title: [#name #h(1fr) Quote #number],
frame: (
border-color: black,
title-color: black.lighten(30%),
body-color: black.lighten(95%),
footer-color: black.lighten(80%),
),
..args.named(),
body
)
}
).with(numbering: boxnumbering)
#let theorem = thmenv(
"theorem",
"Theorem",
boxcounting,
none,
(name, number, body, ..args) => {
showybox(
title: [#name #h(1fr) Theorem #number],
frame: (
border-color: navy,
title-color: navy.lighten(30%),
body-color: navy.lighten(95%),
footer-color: navy.lighten(80%),
),
..args.named(),
body
)
}
).with(numbering: boxnumbering)
#let proposition = thmenv(
"proposition",
"Proposition",
boxcounting,
none,
(name, number, body, ..args) => {
showybox(
title: [#name #h(1fr) Proposition #number],
frame: (
border-color: maroon,
title-color: maroon.lighten(30%),
body-color: maroon.lighten(95%),
footer-color: maroon.lighten(80%),
),
..args.named(),
body
)
}
).with(numbering: boxnumbering)
|
|
https://github.com/dashuai009/dashuai009.github.io | https://raw.githubusercontent.com/dashuai009/dashuai009.github.io/main/src/content/blog/046.typ | typst |
#let date = datetime(
year: 2023,
month: 6,
day: 17,
)
#metadata((
title: "使用c++扩展python",
subtitle: [cpython,c++],
author: "dashuai009",
description: "",
pubDate: date.display(),
))<frontmatter>
#import "../__template/style.typ": conf
#show: conf
= 简介
c++可以编写python的扩展库。
1. Extending Python with C or C++ — Python 3.11.4 documentation
= 开发环境
linux 下需要安装python3-dev
= CMAKE编写
这里给出test.cpp编写的python模块和测试用 的test.py
编译与执行
```
mkdir build
cmake -S . -B ./build
cmake --build ./build
python3 test.py
```
```cmake
cmake_minimum_required(VERSION 3.12) # 3.12才可以find_package(python)
project(test_cp)
find_package (Python REQUIRED Interpreter Development)
set(test_cpp_demo_name "test_cpp") # 定义一个库的名字,同时作为py模块的名字
add_definitions(-DPY_MODULE_NAME_STR="${test_cpp_demo_name}")
add_definitions(-DPY_MODULE_NAME=PyInit_${test_cpp_demo_name})
add_library(${test_cpp_demo_name} SHARED test.cpp)
set_target_properties(
${test_cpp_demo_name}
PROPERTIES
PREFIX "" # 输出前缀没有了
OUTPUT_NAME ${test_cpp_demo_name}.cpython-310-x86_64-linux-gnu # 注意后边的python版本、平台版本、编译器组织
)
target_include_directories(${test_cpp_demo_name} PRIVATE
${Python_INCLUDE_DIRS})
target_link_directories(${test_cpp_demo_name} PRIVATE
${Python_LIBRARY_DIRS})
target_link_libraries(${test_cpp_demo_name} PRIVATE
${Python_LIBRARIES})
```
= TEST.CPP
具体可以参考上边给出的链接
```cpp
#include "Python.h"
// 起一个命名空间
namespace test_cpp {
constexpr int N = 1000;
int f[N];
bool flag = false;
int Fib_impl(int n) {
if (flag && 0 <= n && n < N) {
return f[n];
}
f[1] = 1;
for (int i = 2; i < N; ++i) {
f[i] = f[i - 1] + f[i - 2];
}
flag = true;
return f[n];
}
} // namespace test_cpp
// 给python导出接口
static PyObject *Fib(PyObject * /* unused module reference */, PyObject *o) {
int n = PyLong_AsLong(o);
int fn = test_cpp::Fib_impl(n);
return Py_BuildValue("i", fn);
}
//定义python模块中有哪些函数
static struct PyMethodDef test_cpp_methods[] = {
{"fast_fib", Fib, METH_O, "fast fib"},
// Terminate the array with an object containing nulls.
{nullptr, nullptr, 0, nullptr}};
// 定义模块
static struct PyModuleDef test_cpp_module = {
PyModuleDef_HEAD_INIT,
PY_MODULE_NAME_STR, /* name of module */ // python里可以import 这个名字
nullptr, /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
test_cpp_methods
};
//定义模块的初始化函数,import之后会自动执行
// .so的名字要和这个函数的名字、和PyModuleDef里的name对齐
PyMODINIT_FUNC PY_MODULE_NAME(void) {
PyObject *m;
m = PyModule_Create(&test_cpp_module);
if (m == NULL)
return NULL;
return m;
}
```
= PYTHON使用
```python
import sys
# sys.path.append("./build/lib.linux-x86_64-3.10")
sys.path.append("./build")
import test_cpp
a = test_cpp.fast_fib(10);
print(a)
``` |
|
https://github.com/mattfbacon/armv7-refcard | https://raw.githubusercontent.com/mattfbacon/armv7-refcard/main/template.typ | typst | Creative Commons Zero v1.0 Universal | #import "@preview/tablex:0.0.5": tablex, colspanx, hlinex, vlinex
#let serif = "Inter"
#let serif-italic = "Inter Italic"
#let monospace = "Fira Code"
#let text-size = 6pt
#let gray = luma
#let left-pad(length, pad, input) = pad * calc.max(0, length - input.len()) + input
// A thin space to use as a thousands separator.
#let thousand = h(1pt)
#let chunks(length, input, from: "start") = {
if from == "start" {
for start in range(0, input.len(), step: length) {
(input.slice(start, calc.min(start + length, input.len())),)
}
} else if from == "end" {
(for end in range(input.len(), 0, step: -length) {
(input.slice(calc.max(0, end - length), end),)
}).rev()
}
}
#let zip(..arrs) = {
let arrs = arrs.pos()
let length = calc.min(..arrs.map(arr => arr.len()))
for i in range(0, length) {
(arrs.map(arr => arr.at(i)),)
}
}
#let quo-if-whole(dividend, divisor) = if calc.rem(dividend, divisor) == 0 { calc.quo(dividend, divisor) } else { none }
#let info-table(name, columns-or-num-columns, main-column: auto, ..args) = {
let line-stroke = 0.4pt
let columns = if type(columns-or-num-columns) == "array" {
columns-or-num-columns
} else {
let num-columns = columns-or-num-columns
let main-column = if main-column == none {
none
} else if main-column == auto {
num-columns - 1
} else {
main-column
};
let columns = (auto,) * num-columns
if main-column != none {
columns.at(main-column) = 1fr
}
columns
}
let num-columns = columns.len()
block(breakable: false, {
block(fill: gray(238), outset: 0pt, inset: 2pt, below: 0pt, width: 100%, stroke: line-stroke, [*#name;*])
tablex(columns: columns, align: left + horizon, header-rows: 1, map-hlines: (v) => (..v, stroke: line-stroke), map-vlines: (v) => (..v, stroke: line-stroke), auto-lines: false, inset: 3pt, fill: (_col, row) => if calc.even(row) { gray(255) } else { gray(248) }, hlinex(), vlinex(), ..args, hlinex(), vlinex())
})
}
#let instruction-table(name, extra-column: false, ..args) = info-table(name, if extra-column { 4 } else { 3 }, main-column: 2, (), vlinex(), vlinex(), (), ..args)
#let heading-group(content) = {
show heading: set block(spacing: 5pt)
content
}
#let ascii-table = {
let characters = (
// 0x00
"NUL",
"SOH",
"STX",
"ETX",
"EOT",
"ENQ",
"ACK",
"BEL",
"BS",
"TAB",
"LF",
"VT",
"FF",
"CR",
"SO",
"SI",
"DLE",
// 0x10
"DC1",
"DC2",
"DC3",
"DC4",
"NAK",
"SYN",
"ETB",
"CAN",
"EM",
"SUB",
"ESC",
"FS",
"GS",
"RS",
"US",
// 0x20
[\'#sym.space.en\'],
..range(0x21, 0x7e + 1).map(str.from-unicode),
text(size: text-size - 2pt, "DEL"),
)
let characters = characters.enumerate().map(((i, chr)) => {
align(right, [#chr #h(1pt) #left-pad(2, "0", upper(str(i, base: 16)))])
})
let characters = zip(..chunks(16, characters)).flatten()
info-table("ASCII Character Set", (auto,) * 2 + (1fr,) * 6,
..for column in range(8) {
(vlinex(x: column),)
},
..characters
)
}
#let powers-hex-table = {
let make-row(num) = {
let si-units = (none, "K", "M", "G", "T")
let m16 = quo-if-whole(num, 4)
let si-unit = {
let i = quo-if-whole(num, 10)
if i != none {
let unit = si-units.at(i, default: none)
if unit != none {
unit + "iB"
}
}
}
let pow2 = text(font: monospace, chunks(3, str(calc.pow(2, num)), from: "end").join(sym.space.quarter))
let binary = text(font: monospace, chunks(4, left-pad(4, "0", str(num, base: 2)), from: "end").join(sym.space.quarter))
let num-dec = if num == 14 { 13 } else { num }; // Intentional error.
(str(num-dec), upper(str(num, base: 16)), binary, m16, si-unit, pow2, "")
}
info-table("Powers/Hexadecimal", 7,
$N=$, vlinex(), "Hex", vlinex(), "Binary", vlinex(), $M_16=$, vlinex(), "iB", vlinex(), [$2^N$ and $16^M$], vlinex(), "Notes",
..(range(0, 16) + range(16, 40 + 1, step: 4) + (30,)).sorted().map(make-row).flatten(),
align: (_x, y) => if y == 0 { center + horizon } else { right + horizon },
)
}
// TODO add a small table here for frequencies and periods, like Ghz and picoseconds.
#let gdb-table = {
let u = underline
info-table("GNU Debugger (GDB) Commands", 3,
[#u("l")ist], [_line number_], "Show program source code listing, optional line number",
[#u("b")reak], [_line number_], "Set a break point at a specific line number",
[#u("del")ete], [_break number_], "Delete the specified break point (all if no specified)",
[#u("r")un], [_arguments_], "Run the program with optional cmdline arguments",
[#u("c")ontinue], [_ignore_], [Continue (_ignore_ times) after breaking from breakpoint],
[#u("fin")ish], "", "Continue, finish function/loop, then break again",
[#u("s")tep], [_lines_], [Runs a single (or _lines_) instruction or source line],
[#u("i")nfo], [b, f, r, s], [Display #u("b")reakpoint, #u("r")egister, #u("f")p registers, or #u("s")tack],
[#u("p")rint/f], [_(type) myVar_], [Display w/type of (int), (float) /f => x-hex, f-float, t-bin],
[e#u("x")amine], [_/nfu address_], [Display value at address /n => Num elems, f => #u("s")tring, #u("i")nstruction, he#u("x"), /u => size in #u("b")yte, #u("h")alfword, #u("w")ord],
// [#u("q")uit], "", "Quit GDB",
// [#u("h")elp], "", "Get help on a GDB command",
)
}
#let bit(..xs) = text(font: monospace, "0x" + chunks(4, left-pad(8, "0", str(xs.pos().map(x => calc.pow(2, x)).sum(), base: 16))).join(thousand))
#let ref-card = (body) => {
set page(flipped: true, paper: "us-legal", margin: 16pt)
set text(font: serif, stylistic-set: 2, size: text-size, fallback: false)
show heading: it => align(center, it)
show math.equation: it => {
show ":": it => { h(0pt); it; h(0pt); }
show ";": it => { it; h(2pt) }
it
}
show: it => columns(4, gutter: 5pt, it)
set block(spacing: 5pt)
body
}
|
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/017%20-%20Dragons%20of%20Tarkir/004_The%20Guardian.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"The Guardian",
set_name: "Dragons of Tarkir",
story_date: datetime(day: 02, month: 04, year: 2015),
author: "<NAME>",
doc
)
#emph[In the original timeline of ] Khans of Tarkir#emph[, Anafenza ] was khan of the Abzan#emph[, the stalwart ruler of an enduringly loyal clan. In the alternative timeline of ] Dragons of Tarkir#emph[, her fate has been less kind, but no less grand…]
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
It was the same in every military camp—or that's how it seemed to Oret for the past year.
He was a cartographer for <NAME>, one of the few humans Dragonlord Dromoka and her scalelords respected enough to consult in matters of war. As such, Oret had leave to come and go as he needed. He had ridden through the night, and as he passed through the camp, he was being tugged in opposing directions by hunger and weariness. There were pockets of soldiers huddled around cookfires, and the smell of meat cooking in fat tipped the odds in favor of hunger.
#figure(image("004_The Guardian/01.jpg", width: 100%), caption: [Salt Road Quartermasters | Art by Anthony Polumbo], supplement: none, numbering: none)
He dismounted at one such cookfire, where the soldiers were engaged in a lively discussion Oret had no intention of interrupting. He knew what they were discussing anyway: the Guardian.
He filled an amber bowl with water and took a seat.
"I've seen spirits. Fought them, even," said a stern-faced ainok. When he spoke, Oret noticed he was missing several teeth. "They're malicious and spiteful. Unnatural."
"Then explain what they saw," said a youthful soldier.
"I'm not sure that I can, no matter how many times you go over it." The old ainok shrugged. "I wasn't there, and neither were you."
The younger soldier turned to her comrade on her left. "Yeffa! #emph[You] were there!"
"You know I was," said Yeffa, a broad woman who flashed a broad grin at seeing her friend's exasperation.
"Explain to Khurz here what you saw."
"We shouldn't be talking about this, Ajuf," said a fourth soldier. He was a gaunt man, the skin of his face bronzed by the sun. He didn't look at the others as he spoke.
Yeffa waved a hand dismissively at him. To Oret, it seemed a practiced gesture, and he watched as the veteran leaned in closer to the others. Yeffa was whispering, clearly reveling in the thrill of the forbidden. "Though I was across the battlefield, I know what I saw. From nowhere, their shrieks came, followed by riders beyond count, all charging into our left flank."
#figure(image("004_The Guardian/02.jpg", width: 100%), caption: [Pitiless Horde | Art by Viktor Titov], supplement: none, numbering: none)
#emph[This one's a storyteller] , Oret thought.
"Before our forces could do more than face the charge," said Yeffa, "the Kolaghan were into their slaughter. The line began to crumble beneath the hooves of their horses. And that's when it happened." She paused to look her comrades in the eye, each in turn. "A great wave of sand rose up behind the line. It surged past our soldiers to crash down upon the enemy."
Khurz raised both hands to protest, but before he could speak, Yeffa continued, "'But we have sandbringers that could accomplish such feats,' you may say. And to that I would add that at the front this great wave of sand was the form of a woman, armed and armored as a Dromoka soldier. This was no sandbringer's trick. This was the Guardian."
"And you saw this detail from across the battlefield?" Khurz clicked his tongue. "Taram is right, we shouldn't be wasting our time talking about this."
"She saved us, whatever you may say," said Yeffa.
"There are others who saw the same thing," said Ajuf. "In other battles too. I've even heard talk that she has healed wounded soldiers and freed captured prisoners."
Khurz let out a hollow chuckle. "And I suppose she makes the wastes bloom, and the tempests subside, too. Who, then, is this spirit who watches over us?"
There was silence among them. All but Taram seemed to contemplate a plausible answer, and if not plausible, then at least clever. Finding neither, Yeffa stirred the wood of the cookfire with a stick. "Who can say?" she said at last.
Oret knew these stories. He'd heard them in every camp on his travels. They had warmed him more than the fire before him.
"I can tell you who she is." He did not whisper. The words came out crisp and heavy with authority. The way the soldiers turned to him as he spoke told him they had forgotten he was sitting there. To him it was a bit silly, the thought of himself as the mysterious stranger. But that's exactly what he'd become in the past year, drifting across Dromoka territory.
"And who are you, stranger?" asked Khurz, at last.
"I'm the one who killed that spirit in life."
The soldiers clung to every one of Oret's words that followed.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#figure(image("004_The Guardian/03.jpg", width: 100%), caption: [Mountain | Art by <NAME>], supplement: none, numbering: none)
Two trails of dust merged into one behind the pair of ibexes that raced at full gallop, carrying their armored riders along the canyon floor. Anafenza, the lead rider, risked a glance over her shoulder to scan for the crush of enemies they both were expecting to overtake them.
"Captain! Did we lose them?" called Oret, his voice cracking with strain. "I think we lost them."
The captain's head tilted skyward to where dark, roiling clouds were gathering. "Not likely," she said more to herself than to the other rider. The walls of the canyon closed in around them, and the captain spurred her ibex on.
"We should wait for our scalelord. He will break their offensive."
The captain wheeled about so suddenly that Oret was almost thrown from his saddle in his effort to halt his mount. "Our lord is occupied with other things at the moment." She pointed up toward the mountains that rose on the eastern edge of the canyon. "On the outcrop, see?"
Oret saw him, his scalelord, the dragon to whom he was bonded. The scalelord had a smaller, four-winged dragon pinned beneath his massive arms. As Oret watched, lightning erupted from the smaller dragon's mouth. His scalelord tumbled backward as the other dragon flew away.
#figure(image("004_The Guardian/04.jpg", width: 100%), caption: [Stormwing Dragon | Art by <NAME>], supplement: none, numbering: none)
"Is he in trouble?" asked Oret.
"He's occupied. #emph[We're] in trouble."
"Then we're alone."
"Not quite. Follow me." And the captain was off again.
Oret stared a moment longer at his scalelord, locked in an exchange of power he would never fully understand. Behind him came the rumble of horses, and the taunts of their riders, and he too was off. He followed his captain, who drove her ibex through the twisting path that brought the pair deeper into the canyon. It proved to be difficult to keep pace with her, as she would all but disappear around a bend, or suddenly change directions to dart down one of the canyon's countless labyrinthine branches. Wherever she was leading them, if nothing else, it was away from the Kolaghan warriors. Oret had served with his captain for several years, and he had never seen her act rashly. There was always a plan, always some contingency that proved that she had considered the threats and made the correct preparations. But here they were, their fortress lost and their lines broken, fleeing for their lives before the bulk of a Kolaghan horde.
More twists. More narrow paths. The Kolaghan war-shrieks at their heels soon became scattered and confused shouts that echoed off the canyon walls. A smiled crept in at the corner of Oret's mouth. He realized what his captain was doing. At best, the Kolaghan would lose track of their quarry and overshoot their position entirely. At worst, the captain would have forced the Kolaghan to divide their forces to find them. In the narrow corridors of the canyon, the two of them may actually be able to fight their way out.
The captain made another abrupt turn into a gap in the canyon wall. Oret missed it, and rode past before slowing to wheel about. He opened his mouth to call after his leader, but before words emerged, he was struck by the sudden taste of metal on his tongue. The air became unnaturally dry, and a crackling hum drowned out all noise, except the panicked bleating of Oret's ibex. He struggled with the reins in a vain attempt to maintain control over the animal.
"Captain!" Oret yelled, desperate to leave. "Anafenza!" He dug his heels into his mount's flanks, and it bolted.
A pop broke over the air. After only three steps, the ibex lurched and crumpled mid-stride. Oret fell hard from his saddle and his jaw slammed closed when the ground rose up to meet it. He tasted blood as he scrambled for cover behind his ibex, which lay lifeless with a spear jutting from its back. All along the shaft, electrical energy still danced, curling and blackening the surrounding fur.
Another echo boomed through the canyon. This one, the growling, guttural bellow of a hunter after a kill. Oret found a Kolaghan orc perched above him at the edge of a flat rock that poked out part way up the canyon wall. He was adorned with a metal mantle that rose from a harness on his back. A web of lightning fanned out from the mantle to complete the impression of formidable wings, bright against the dark, churning clouds above.
The orc roared once more, this time forming a sound that Oret could discern. "Gvar!"
Oret knew the name. Gvar, the orc who led the attack on Sandsteppe Gateway. Beneath the shadow of Kolaghan dragons, Gvar stormed the walls, dislodged its Dromoka defenders, and drove the survivors into the wilderness.
#figure(image("004_The Guardian/05.jpg", width: 100%), caption: [Warbringer | Art by Raymond Swanland], supplement: none, numbering: none)
The warrior's call would summon Gvar to finish the two remaining soldiers of the garrison.
But the orc did not wait for his leader, and instead he leapt for Oret.
There was time for Oret to scramble to his feet or draw his sword, not both. Oret rose, and the raider was on him. A powerful downward cut punctuated his war cry, but Oret shifted so the blow glanced off a pauldron. He closed the distance between them, and before his attacker could recover, Oret threw his armor-clad bulk forward, bringing both of them the ground in a cloud of dust and curses.
The Kolaghan raider maneuvered until his elbow pressed in on Oret's throat. The blood in his mouth welled, but Oret could not swallow it. Instead, he let it fly at the orc in a spray of red. It was enough for Oret to wrench free. And it was then that he heard his captain's voice.
"Oret, move," said Anafenza.
The command was a simple one, and Oret complied. He broke away from the raider, but the orc refused to relent. Anafenza stepped forward, wreathed in shimmering golden-white light, and the sand around her feet rippled as though alive. Anafenza held out a hand, and the swirling light curled around her arm and spiraled out toward the orc. It passed through him, pulling something unseen but vital from him as it passed, leaving him lifeless in the dust.
No sooner than the body collapsed than were the walls of the canyon again awakened by the sounds of war. Hoofbeats and warshouts boomed out, growing louder with each passing moment.
"Captain?"
"This way," said Anafenza, indicating the narrow path behind her. "Gvar and his horde will be here soon. We must be ready for them."
The pair was on foot, running flat out, careful enough only to avoid rolling an ankle on the loose, stony ground. Behind Anafenza, Oret emerged in an oblong chamber that was hemmed in almost entirely by the sheer face of the canyon wall. The only way out was the way they had come.
"A dead end," said Oret.
"It's a good thing, too," said Anafenza. She was unlacing her boots. "It will be harder for them to flee."
Nervously, Oret paced the perimeter of the chamber. He found Anafenza's ibex tied to a small, twisted tree, drinking water from an amber bowl. The humble tree was half hidden in the shadow of the wall. Scattered all around tree, Oret saw shards of amber. To his eye, many of the shards had once fit together to form an untold number of containers, figurines, or ornaments. Oret knelt and scooped up a shard, this one a remnant of some ancient intricately crafted pitcher.
"What are these, Captain?"
"Amber is a special substance, Oret. The broken vessels at your feet served two functions. Like any vessel, they carried water. But made from amber, a substance of trees, these vessels could also carry spirits."
Oret dropped the amber shard as though it burned. "Captain, please. We should not be here."
"I want to show you something," said Anafenza, calmly talking past him. She was standing at the tree, and Oret cautiously obliged. She took his hand and placed it on the bare trunk. "Now look closer." Oret leaned in. His eyes strained in the growing darkness, but there, carved into the surface of the trunk were dozens, if not hundreds of names.
Oret recoiled. "Cursed names?"
"That was my first thought as well, but I've come to believe otherwise. Many people went to great lengths to bring these here. Spirits can be carried in amber, but I believe the tree is their anchor."
"You've been here before?"
"Many times."
Anafenza crouched at the base of trunk, brushing sand away until the arches of roots were revealed. She rose, and placed her bare feet upon the roots. "Now, Oret, get behind me. You're going to see something amazing." She flashed him a smile, the first one he'd seen since the attack on Sandsteppe Gateway.
"I can't do that, Captain." Oret smiled back. It was a sad smile. His captain—his cousin—was going to die there. #emph[He] was going to die there. But not easily. He drew his sword.
It wasn't long before the Kolaghan caught up. The taunts resumed as they closed in, even before they could be seen.
"Let's hope all that running has left enough strength for a fight." By the time the words were uttered, Gvar's hulking frame entered the chamber. "I am <NAME>, who shattered your gates, and toppled your walls."
Anafenza unsheathed the curved two-handed sword that hung in a scabbard across her back. "It's because you are <NAME>, who shattered our gates, and toppled our walls, that you will not leave this place."
Dozens of Kolaghan warriors piled into the chamber behind Gvar. Shamans were among them, and they began summoning lightning, which crackled into being among them.
Ever calm, Anafenza removed her helmet and reached up to touch a gnarled branch with her hand. "Spirits of this tree, ancestors of my people, your descendants need you." It was not the first time she said the words, Oret was certain, and at their utterance, the still air of the chamber began to stir. Dust rose, and tiny golden flecks of amber rose with it. For the moment, the gathered warriors at the opposite end of the chamber halted their taunts.
Although Anafenza was barely visible through the maelstrom of dust, Oret could still hear his captain, who said, "Oret, get behind me." And Oret moved to the other side of the tree, shielding his face as best he could.
He was pulling Anafenza's ibex over to him when he saw impressions of human shapes take form in the dust. They were not solid forms, although some appeared to be armored in the manner of the ancients. Oret's eyes widened.
Spirits.
The revelation stole the remaining moisture from this mouth.
Necromancy.
Anafenza inhaled deeply. Her lungs filled with dust and amber, and the spirits swirled in toward her. They merged with her, until she became a blur of amber light. She stepped off the roots, took another step forward, and an instant later, she was among the Kolaghan.
She was a horrifying mass of spirit limbs, angry and vengeful. Sand and dust moved in great billowing sheets, fed by an endless stream of furious spirits that continued to surge from the tree. Among the tumult, Oret was able to track Anafenza by the flashes of her blade and the cries she extracted from the Kolaghan as she went.
Gvar, the shamans, all of the Kolaghan raiders—they didn't stand a chance.
During the carnage, the storm clouds overhead swelled. As Anafenza caught, and cut down the last of Gvar's warriors, lightning split the sky, thunder shook the canyon, and the clouds spilled out their contents. Dragons of Kolaghan's brood descended from the sky.
#figure(image("004_The Guardian/06.jpg", width: 100%), caption: [Dragon Tempest | Art by <NAME>urai], supplement: none, numbering: none)
Oret was stuck between the horror composed of spirits and death before him, and the horrors borne on four wings above him.
The lead dragon tucked its four feathered wings back and fell into a dive at Oret's spirit-shrouded captain. There was no hesitation, no moment of panic or fear. Anafenza simply looked skyward, and all at once, the spirits within her streaked up toward the clouds to meet the dragon. They moved as a massive bolt of golden light, and at its advance the dragon tried to reverse course. Too late, though, for the bolt tore through scales and flesh and bone.
#figure(image("004_The Guardian/07.jpg", width: 100%), caption: [Radiant Purge | Art by <NAME>], supplement: none, numbering: none)
Oret saw spirits splinter off to devour the rest of the monster, and the remaining dragons scattered back into the safety of the clouds.
The dust and sand in the chambers settled back to earth. Utterly exhausted, Anafenza collapsed.
It took Oret a long moment to realize that the sequence of threats had ceased. Slowly, he made his way to where his captain lay, motionless. Air rattled in her lungs. It was a sound that both unsettled and relieved Oret. Anafenza's eyes hung open, but her pupils had rolled back in her head, leaving only a pair of glassy, white fields in their place.
"Anafenza," Oret whispered.
More air passed through her lungs, weak and ragged.
Oret put his hand on her shoulder, and gently shook her. "Anafenza," he said again. And again, louder, "Captain!" He desperately wanted to help her, and lacking another course of action, he looked for some wound, some physical evidence of harm he could bind or mend. But there was nothing. This wasn't a slash from a sword, or a puncture from an arrow.
"Oret." The word came as a hoarse whisper.
Oret's face broke into a smile. He looked down to find Anafenza staring up at him.
"You see?" she asked.
"Don't strain yourself, Captain."
"I'm okay," she said, propping herself on her elbows. "Really. I just needed a moment."
"Captain, I've never seen anything like that."
"Me neither. I've never #emph[felt] anything like it." The fullness of her voice was returning, and she began to speak rapidly. "Oret, so many ancestors, all bound by common purpose—to protect their descendants, their people. There was nothing political about it. There was no maneuvering for the favor of a dragon. It was pure, and it was powerful."
A sudden gust riled the sand, and they felt the air in their ears compress. Wing beats. If there were no clouds, a massive shadow would have filled the oblong canyon chamber. But there was no shadow, only a series of sickening cracks, as their scalelord descended into the chamber where, beneath its great weight, the ancient tree fell to splinters. And with it, Anafenza's last shred of obedience.
"He saw," Anafenza said through gritted teeth. Even as Oret bowed his head, she stared directly into the dragon's eyes.
"Captain, please," Oret said. "Not now." But Oret knew, as he was sure Anafenza knew. The cost of calling upon spirits, of practicing necromancy, was death. Their scalelord would open his mouth, and out would pour a blast of scouring light that would peel away all the layers of her being until there was nothing remaining. Not even a spirit.
#figure(image("004_The Guardian/08.jpg", width: 100%), caption: [Enduring Scalelord | Art by <NAME>], supplement: none, numbering: none)
The dragon reared its head back, and Oret stepped between his scalelord and his captain.
"This is the way of it, Oret," Anafenza said, "get out of the way. There's no getting out of it. My life is forfeit for what I've done."
Oret remained. "Sovereign of mine," he said, dropping to one knee before the dragon, "I ask you, with all the respect of one of your humble children, to grant a single request."
Dragons didn't debase themselves with the language of people. When they spoke, their draconic words first passed through speakers. There, in the canyon, there was no one to translate, and the only indication of understanding Oret would have would be the dragon's actions. It was a prospect that clawed at his stomach.
"My captain has practiced necromancy," he continued. "An affront that must be punished." Oret swallowed. "Please, my scalelord, allow me to be the one to execute her."
The dragon's gaze shifted from Oret to Anafenza, and finally back to Oret, to whom he dipped his head. It was a gesture Oret took to be a nod. His request was granted.
Anafenza made no motion to escape, and Oret allowed himself a momentary glance in her direction. She was calm, as always. She knelt to receive her judgment, and as he bent to scoop up her two-handed sword, she turned to smile at him.
The leather hilt of Anafenza's sword was coated in dust, making it difficult to grip.
Anafenza had called forth spirits from the tree to protect them. She called the spirits ancestors, and from across the ages, these ancestors found a common bond, and they emerged to fight the enemies of their people. Anafenza had discovered this bond. She was driven by the same cause.
Oret raised the blade over his head. "This is not the end," he whispered to his captain. A moment later, it was done.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Taram spat into the fire. "Justice served. Now I've heard enough. If you're going go on about necromancy all day, then I'm off." He rose and walked off into the dim light of the morning.
"I don't understand," said Ajuf, still transfixed. "Those spirits saved you. She saved you. And you killed her for it."
"I did," Oret said, "and I was honored for it. Blood was pooling around my captain's lifeless body, and I knelt before my scalelord to receive his favor."
#figure(image("004_The Guardian/09.jpg", width: 100%), caption: [Scale Blessing | Art by <NAME>], supplement: none, numbering: none)
He continued. "Upon my arrival at the city of Kavah, I was greeted as a hero. I was raised to the rank of scout captain, honored with the title of cartographer and, with it, a life in exile. But I put my exile to use, and soon my wanderings brought me back to the canyon. Nothing remained of Anafenza's body. The wilderness saw to that. But that's not what I went there for. Among the remnants of the tree were all those pieces of amber that had carried the spirits of ancestors to the site. In those I placed my hope, and I scoured the sand for every bit of amber I could find."
Oret drained the last of his water. "The cartographer of <NAME> has the distinguished honor of maintaining the official maps of the territory, and from such maps, I found my destination. Months of travel brought me to a stretch of cracked, arid land. At the horizon, I spotted the ruins of a crumbling fortress that I knew I would find. Between myself and the fortress, reaching up from the highest point of a low hill, was an ancient tree. I compared the tree in the distance to the equivalent notation on my map. All trees in Dromoka territory are noted on maps as an indicator of water, but the leafless limbs of that tree could never provide such comfort for travelers. There was nothing there. It was perfect.
"When I reached the tree, I emptied my bags of all the amber pieces I brought from the canyon and spread them around the trunk in a ring. I had no idea if I was doing it correctly, but if amber truly was a vessel for spirits, then Anafenza's had to be in one of the pieces.
"Where the trunk disappeared into the sand, I shoveled the sand away. With my knife, I carved her name into the living wood, and when I finished, I pushed the sand back into place. It was to be Anafenza's tree. One that would not be splintered, or burned, or uprooted. It would be her anchor."
#figure(image("004_The Guardian/10.jpg", width: 100%), caption: [Anafenza, Kin-Tree Spirit | Art by Ryan Yee], supplement: none, numbering: none)
"Unbelievable!" said Ajuf.
"Agreed. I'm not sure I believe a thing you've said," said Khurz. It was his turn to rise to leave. But before he left, "Where is this tree, then?"
"My answer won't convince you of the truth of it," Oret said through a smile, "because all records of that tree, on every official map have been destroyed."
"Of course they have." Khurz let out a sharp hiss of disgust. "And now you travel through our lands sharing this story?"
"Believe what you will. The success of my journey did not become apparent to me until tales like Yeffa's began to crop up. For Anafenza, it had always been about the clan. In death, her fervor has refused to wane. I now travel our territory to share the truth. She is, as Yeffa said, a guardian."
#figure(image("004_The Guardian/11.jpg", width: 100%), caption: [Echoes of the Kin Tree | Art by <NAME>], supplement: none, numbering: none)
|
|
https://github.com/typst-community/glossarium | https://raw.githubusercontent.com/typst-community/glossarium/master/advanced-docs/main.typ | typst | MIT License | #import "../themes/default.typ": *
#show: make-glossary
#set page(paper: "a4")
#set heading(numbering: "1.")
#show link: set text(fill: red)
#let typc(body) = raw(body, lang: "typc")
#let typc-block(body) = rect(
width: 100%,
fill: gray.lighten(80%),
)[#set text(size: 9pt);#body]
#let entry-list = (
(
key: "WHO",
short: "WHO",
long: "World Health Organization",
description: lorem(5),
group: "Organizations",
),
(
key: "WTO",
short: "WTO",
long: "World Trade Organization",
description: lorem(5),
group: "Organizations",
),
(
key: "IMF",
short: "IMF",
long: "International Monetary Fund",
description: lorem(5),
),
(
key: "UN",
short: "UN",
long: "United Nations",
description: lorem(5),
),
(
key: "EU",
short: "EU",
long: "European Union",
description: lorem(5),
),
(
key: "USA",
short: "USA",
long: "United States of America",
description: lorem(5),
group: "Countries",
),
(
key: "UK",
short: "UK",
long: "United Kingdom",
description: lorem(5),
group: "Countries",
),
(
key: "UAE",
short: "UAE",
long: "United Arab Emirates",
description: lorem(5),
group: "Countries",
),
)
#register-glossary(entry-list)
#let entries = __normalize_entry_list(entry-list)
#let groups = entries.map(x => x.at("group")).dedup()
#align(
center,
heading([`glossarium@`#glossarium_version], level: 1, numbering: none),
)\
#text(fill: red.darken(10%), size: 11pt, font: "Iosevka Extrabold Extended")[
This document outline how to change the default behaviour of `glossarium` by
implementing "user functions". It is recommended to keep the default implementation and not to change the default behaviour of the package.
If you have a need that require to change the defaults, you are expected to be knowledgeable in writing complex typst code and to try to debug your issues first on you own. Be aware that helping regular users and fixing bugs will take priority over helping you debug your own implementation of `glossarium` internal functions.]
#outline(indent: 1em)
= Customization
This section shows how to change the default behaviour of `glossarium` by
implementing user functions. It is recommended to keep to the user available
interface and not to change the default behaviour of the package. If you have
any suggestions or need help, please open an issue on the
#link("https://github.com/typst-community/glossarium")[GitHub repository].
There are effectively two requirements for a user to use `glossarium`:
+ Write a #typc("show: make-glossary") rule to transform all
#typc("@key") and #typc("@key:pl") into #typc("#gls(key)") or
#typc("#glspl(key)")
+ Call #typc("print-glossary(entry-list)") somewhere in order to write all
labels
The `glossarium` package provides a default behaviour to
#typc("print-glossary"). In ascending order, all implemented behaviours are:
+ #typc("default-print-back-references(entry) -> contextual content")
+ #typc("default-print-description(entry) -> content")
+ #typc("default-print-title(entry) -> content")
+ #typc("default-print-gloss(entry, ...) -> contextual content")
+ #typc("default-print-reference(entry, ...) -> contextual content")
+ #typc("default-print-glossary(entries, groups, ...) -> contextual content")
/ gloss: A *gloss* is a single entry in the glossary. It is composed of a
*title*, a *description*, and a list of *back references*.
/ reference: A *reference* is the construct `glossarium` uses to manage the
glossary. Internally, it is constructed using #typc("figure()") and #typc("label()").
/ glossary: A *glossary* is the list of all glosses. It is composed of a list of
*entries* and a list of *groups*. The default *group* is #typc("\"\"").
Each of these functions can be replaced by a user-defined function with the same
signature. Then, the user can pass them directly to #typc("print-glossary()"),
e.g.,
#typc-block[
```typc
let my-print-description(entry) = {
let ent-description = entry.at("description", default: "")
return text.with(size: 9pt)[#ent-description]
}
print-glossary(entry-list, user-print-description: my-print-description)
```
]
Keep in mind that some options are available from the start:
- `show-all (bool)` : show all entries, even if they are not referenced in the document
- `disable-back-references (bool)`: do not show back references
- `user-group-break (function: () => content)`: a function to call between groups
== Default functions
The functions are listed in order of reverse call hierarchy:
+ #typc("print-glossary(entry-list)")
+ #typc("default-print-glossary(entries, groups)")
+ #typc("default-print-reference(entry)")
+ #typc("default-print-gloss(entry)")
+ #typc("default-print-title(entry)")
+ #typc("default-print-description(entry)")
+ #typc("default-print-back-references(entry)")
+ #typc("default-group-break()")
#text.with(fill: red.darken(10%))([
#emoji.warning Although #typc("default-print-reference") is available to the
user, it is not recommended to modify this function.
])
The full signatures for #typc("default-print-gloss()"),
#typc("default-print-reference()"), and
#typc("default-print-glossary()") in the next sections.
=== Arguments
The functions take the following arguments:
+ #typc("entries"): the normalized entry list
+ #typc("groups"): the list of groups
+ #typc("entry"): an entry
This is one #typc("entry"):
#typc-block[
#entries.first()
]
#typc("groups")
#typc-block[
#groups
]
#typc("entries")
#typc-block[
#entries.slice(0, 2)
]
=== #typc("default-print-back-references(entry)")
The default implementation is:
#typc-block[
```typc
#let default-print-back-references(entry) = {
return get-entry-back-references(entry).join(", ")
}
```
]
Without going into details, assume that
#typc("get-entry-back-references(entry)") returns a list of back references. The
function simply joins them with a comma.
For example, for @WHO, the back references are:
#typc-block[#context get-entry-back-references(entries.first()).join(", ")]
The value of #typc("get-entry-back-references(entry)") is:
#typc-block[#context get-entry-back-references(entries.first())]
where #typc("dest") contains a #typc("location").
=== #typc("default-print-description(entry)")
The default implementation is:
#typc-block[
```typc
#let default-print-description(entry) = {
return entry.at("description")
}
```
]
=== #typc("default-print-title(entry)")
The default implementation is:
#typc-block[
```typc
#let default-print-title(entry) = {
let caption = []
let txt = text.with(weight: 600)
if has-long(entry) {
caption += txt(emph(entry.short) + [ -- ] + entry.long)
} else {
caption += txt(emph(entry.short))
}
return caption
}
```
]
The function is fairly simple to understand:
- If the entry has a long description, it returns #typc("text.with(weight: 600)[emph(entry.short) -- entry.long]")
- If the entry does not have a long description, it returns #typc("text.with(weight: 600)[emph(entry.short)]")
=== #typc("default-print-gloss(entry)") <ssec:print-gloss>
The default implementation is
#typc-block[
```typc
#let default-print-gloss(
entry,
show-all: false,
disable-back-references: false,
user-print-title: default-print-title,
user-print-description: default-print-description,
user-print-back-references: default-print-back-references,
) = context {
let caption = []
if show-all == true or count-refs(entry) != 0 {
// Title
caption += user-print-title(entry)
// Description
if has-description(entry) {
// Title - Description separator
caption += ": "
caption += user-print-description(entry)
}
// Back references
if disable-back-references != true {
caption += " "
caption += user-print-back-references(entry)
}
}
return caption
}
```
]
- #typc("default-print-gloss") is responsible for printing separators between
the title, description, and back references.
- It also checks if the entry should be printed or not. If the entry is not
referenced in the document, it will not be printed unless #typc("show-all:
true").
- If back references are disabled (#typc("disable-back-references: true")), they
will not be printed.
The default behaviour will be displayed as such:
#typc-block[
#default-print-gloss(entries.first())
]
Without back references:
#typc-block[
#default-print-gloss(entries.first(), disable-back-references: true)
]
For a non-referenced entry:
#typc-block[
show-all: false => #default-print-gloss(entries.at(1))
show-all: true => #default-print-gloss(entries.at(2), show-all: true)
]
One important utility function is #typc("count-refs"). For @WHO,
#typc("#context count-refs(entry)") is
#typc-block[
#context count-refs(entries.first())
]
=== #typc("default-print-reference(entry)") <ssec:print-reference>
#text.with(fill: red.darken(10%))([
#emoji.warning There are few reasons to modify this function. It is recommended
to keep the default behaviour, but an override option is provided for advanced
users.
])
The default implementation is:
#typc-block[
```typc
#let default-print-reference(
entry,
show-all: false,
disable-back-references: false,
user-print-gloss: default-print-gloss,
user-print-title: default-print-title,
user-print-description: default-print-description,
user-print-back-references: default-print-back-references,
) = {
return [
#show figure.where(kind: __glossarium_figure): it => it.caption
#par(
hanging-indent: 1em,
first-line-indent: 0em,
)[
#figure(
supplement: "",
kind: __glossarium_figure,
numbering: none,
caption: user-print-gloss(
entry,
show-all: show-all,
disable-back-references: disable-back-references,
user-print-title: user-print-title,
user-print-description: user-print-description,
user-print-back-references: user-print-back-references,
),
)[] #label(entry.key)
// Line below can be removed safely
#figure(kind: __glossarium_figure, supplement: "")[] #label(entry.key + ":pl")
]
#parbreak()
]
}
```
]
The function is responsible for creating the referenceable element and the label
for the gloss.
- it uses #typc("figure()") and #typc("label()") to create the element and make
it referenceable. #typc("glossarium") uses #typc("kind: __glossarium_figure")
to uniquely identify glossary figures
- the figure's caption is the result of #typc("user-print-gloss()") (see
previous section @ssec:print-gloss)
- By default, an additional empty figure with label #typc("key:pl")
is created. This is useful for referencing plural forms of the glossary entry,
e.g., #typc("@WHO:pl")=@WHO:pl. It can be safely removed.
#text.with(fill: red.darken(10%))([
#emoji.warning Notice that #typc("entry.key") is used as the label. This usage
implies that glosses with duplicate keys will not work, as labels must be
unique.
])
The code below panics:
#typc-block[
```typc
#figure(caption: "test")[]#label("a")
#figure(caption: "test")[]#label("a")
@a
```
]
with error
#typc-block[
```shell
error: label `<a>` occurs multiple times in the document
```
]
=== #typc("default-print-glossary(entries, groups)")
#typc-block[
```typc
#let default-print-glossary(
entries,
groups,
show-all: false,
disable-back-references: false,
user-print-reference: default-print-reference,
user-group-break: default-group-break,
user-print-gloss: default-print-gloss,
user-print-title: default-print-title,
user-print-description: default-print-description,
user-print-back-references: default-print-back-references,
) = {
let body = []
let previous-heading = query(selector(heading).before(here())).last()
for group in groups.sorted() {
let group-entries = entries.filter(x => x.at("group") == group)
let group-ref-counts = group-entries.map(count-refs)
let print-group = (
group != ""
and (
show-all == true
or group-ref-counts.any(x => x > 0)
)
)
// Only print group name if any entries are referenced
if print-group {
body += [#heading(group, level: previous-heading.level + 1)]
}
for entry in group-entries.sorted(key: x => x.key) {
body += user-print-reference(
entry,
show-all: show-all,
disable-back-references: disable-back-references,
user-print-gloss: user-print-gloss,
user-print-title: user-print-title,
user-print-description: user-print-description,
user-print-back-references: user-print-back-references,
)
}
body += user-group-break()
}
return body
}
```
]
The function is responsible for printing the glossary. It iterates over all
groups and prints the entries. It also checks if the group should be printed or
not. If the group is empty, it will not be printed unless #typc("show-all:
true").
See the default style in @sssec:default-style.
== Styles
=== Default glossary <sssec:default-style>
// let parent-heading = query(heading(1)).first()
#typc-block[
= Glossary
#print-glossary(
entry-list,
show-all: true,
)
]
|
https://github.com/Shedward/dnd-charbook | https://raw.githubusercontent.com/Shedward/dnd-charbook/main/dnd/dnd.typ | typst | #import "core/core.typ"
#import "page/page.typ"
#import "game/game.typ"
|
|
https://github.com/EstebanMunoz/typst-template-evaluacion | https://raw.githubusercontent.com/EstebanMunoz/typst-template-evaluacion/main/README.md | markdown | MIT No Attribution | # typst-template-evaluacion
Template para la creación de evaluaciones usando Typst.
|
https://github.com/BrainTmp/MetaNote | https://raw.githubusercontent.com/BrainTmp/MetaNote/main/demo_typst.typ | typst | #import "Typst/metanote.typ": *
// If you have created the local package, change this to
// #import "@local/MetaNote:0.0.1": *
#show: doc => MetaNote(
title: [
An Introduction to Elementology (A)
],
authors: (
(
name: "Impact",
affiliation: "University of Genshin",
email: "<EMAIL>",
),
(
name: "Genshin",
affiliation: "Teyvat Health University",
email: "<EMAIL>",
),
),
print: true,
doc,
)
= The Study of Elemental Energy
== Character Energy Regeneration
We have discovered that the elemental energy of the world is closely related to the elemental attributes of the characters. When a character comes into contact with elemental energy, it triggers an energy recovery. The energy recovery value for the corresponding character is influenced by factors such as team size, the elemental attribute of the character and the elemental energy, and the elemental recharge efficiency.
Our formula is given below:
$
cal(A r k n i g h t s) = lim_(n -> inf) sum_(i=1)^n ((E_(i,"in") dot C_(i,"eff"))/T_i - E_(i,"out")D_(i,"eff") )
$
In this formula, $E_(i,"in")$ represents the incoming elemental energy, $C_(i,"eff" )$ stands for the effective conversion coefficient, $T_i$ denotes the transfer efficiency, $E_(i,"out")$ is the outgoing elemental energy, and $D_(i,"in")$ represents the effective dissipation coefficient. This equation could describe the process involving the interaction and transformation of elemental energies within the context of elemental studies in the Genshin world.
#theorem("Character Energy Regeneration")[
When a character in the field comes into contact with energy drops (referred to as "spheres" hereafter, including particles or crystals), it triggers an energy recovery. Both on-field and off-field characters can obtain energy.
The energy recovery value for the corresponding character is influenced by factors such as team size, the elemental attribute of the character and the energy drop, and the elemental recharge efficiency.
The calculation formula is as follows: Actual energy recovery value = Basic energy recovery value $times$ Elemental conversion coefficient $times$ Team allocation coefficient $times$ Current elemental recharge efficiency.
]
#proof[
I don't have access to the specific game mechanics or code to provide direct proof of this conclusion. However, the information you provided aligns with common gameplay mechanics in many RPG and adventure games, where characters can gain energy or mana by interacting with specific objects or elements within the game world. This mechanic is often influenced by various factors such as team composition, character attributes, and environmental elements.
To further validate this conclusion for Genshin Impact, I recommend consulting the official game documentation, community forums, or reaching out to the game's support channels for detailed information on energy recovery mechanics and calculations.
]
=== Basic Energy Recovery Value
#corollary()[
The basic energy recovery value is determined by the energy drop and the elemental attribute of the character. The basic energy recovery value of the same energy drop is different for different elemental attributes.
]
#note[
Note that the basic energy recovery value is not affected by the elemental recharge efficiency, and the elemental conversion coefficient is 1, so we arrived at a strong conclusion that the basic energy recovery value is determined by the energy drop and the elemental attribute of the character.
]
Now we enter the next stage of the proof. We will first prove that the basic energy recovery value is determined by the energy drop and the elemental attribute of the character. Then we will prove that the basic energy recovery value of the same energy drop is different for different elemental attributes. |
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/layout/par_03.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// While we're at it, test the larger block spacing wins.
#set block(spacing: 0pt)
#show raw: set block(spacing: 15pt)
#show list: set block(spacing: 2.5pt)
```rust
fn main() {}
```
- List
Paragraph
|
https://github.com/7sDream/fonts-and-layout-zhCN | https://raw.githubusercontent.com/7sDream/fonts-and-layout-zhCN/master/chapters/05-features/shaping/selection.typ | typst | Other | #import "/template/template.typ": web-page-template
#import "/template/components.typ": note
#import "/lib/glossary.typ": tr
#show: web-page-template
// ### Rule selection
=== 规则选取
// Next then processes substitution rules from the GSUB table, and finally the positioning rules from the GPOS table. (This makes sense, because you need to know what glyphs you're going to draw before you position them...)
下一个步骤是处理`GSUB`表中的#tr[substitution]规则,然后再处理`GPOS`表中的#tr[positioning]规则。这个先后顺序十分自然,毕竟你需要知道最终要绘制的#tr[glyph]是什么,然后才能确定它们的#tr[position]。
// The first step in processing the table is finding out which rules to apply and in what order. The shaper does this by having a set of features that it is interested in processing.
处理每张表的第一步都是去决定要应用其中的哪些规则,以及要以什么顺序应用它们。#tr[shaper]会根据其内部的一个相关特性集来完成这一步。
// The general way of thinking about this order is this: first, those "pre-shaping" features which change the way characters are turned into glyphs (such as `ccmp`, `rvrn` and `locl`); next, script-specific shaping features which, for example, reorder syllable clusters (Indic scripts) or implement joining behaviours (Arabic, N'ko, etc.), then required typographic refinements such as required ligatures (think Arabic again), discretionary typographic refinements (small capitals, Japanese centered punctuation, etc.), then positioning features (such as kerning and mark positioning).[^1]
通常,你可以认为特性是按如下顺序进行处理:首先是那些可能改变#tr[character]映射到的#tr[glyph]的“#tr[shaping]前”特性,比如 `ccmp`、`rvrn`、`locl`等;然后处理针对特定#tr[scripts]的#tr[shaping]特性,比如婆罗米系#tr[scripts]需要的重排音节簇,或阿拉伯文和N'ko等#tr[script]中的特殊连接行为;再之后是#tr[typography]效果上的调整,比如必要#tr[ligature]以及小型大写字母、日文标点居中等自选排版特性;最后处理#tr[position]相关的特性,像是#tr[kern]和符号#tr[positioning]等。#footnote[
// See <NAME>'s paper [*Enabling Typography*](http://tiro.com/John/Enabling_Typography_(OTL).pdf) for an explanation of this model and its implications for particular features.
对于此模型的详细解释及其对某些特性实现的影响,可参阅#cite(<Hudson.EnablingTypography.2014>, form: "prose")。
]
// More specifically, Uniscribe gathers the following features for the Latin script: `ccmp`, `liga`, `clig`, `dist`, `kern`, `mark`, `mkmk`. Harfbuzz does it in the order `rvrn`, either `ltra` and `ltrm` (for left to right contexts) or `rtla` and `rtlm` (for right to left context), then `frac`, `numr`, `dnom`, `rand`, `trak`, the private-use features `HARF` and `BUZZ`, then `abvm`, `blwm`, `ccmp`, `locl`, `mark`, `mkmk`, `liga`, and then either `calt`, `clig`, `curs`, `dist`, `kern`, `liga`, and `rclt` (for horizontal typesetting) or `vert` (for vertical typesetting).
更确切的说,在拉丁文环境下,Windows 中的 Uniscribe 组件会考虑使用`ccmp`、`liga`、`clig`、`dist`、`kern`、`mark`、`mkmk` 特性。HarfBuzz 的顺序则是:`rvrn`;从左往右的环境中使用` ltra`、`ltrm`,从右往左的环境换成 `rtla` 、`rtlm`;然后依次为 `frac`、`numr`、`dnom`、`rand`、`trak`、私有特性 `HARF`和`BUZZ`、`abvm`、`blwm`、`ccmp`、`locl`、`mark`、`mkmk`、`liga`;接着在横排下使用 `calt`、`clig`、`curs`、`dist`、`kern`、`liga`、`rclt`,在竖排下使用 `vert`。
// For other scripts, the order in which features are processed (at least by Uniscribe, although Harfbuzz generally follows Uniscribe's lead) can be found in Microsoft's "Script Development Specs" documents. See, for instance, the specification for [Arabic](https://docs.microsoft.com/en-gb/typography/script-development/arabic); the ordering for other scripts can be accessed using the side menu.
其他#tr[scripts]环境下的特性处理顺序可以在微软的《字体开发规范》文档中找到。至少 Uniscribe 会遵守此规范,而 HarfBuzz 通常会跟随 Uniscribe 的开发方向。打开阿拉伯文的规范#[@Microsoft.DevelopingArabic],通过侧边菜单可以前往关于其他#tr[scripts]的页面。
// After these default feature lists required for the script, we add any features that have been requested by the layout engine - for example, the user may have pressed the button for small capitals, which would cause the layout engine to request the `smcp` feature from the font; or the layout engine may see a fraction and turn on the `numr` feature for the numbers before the slash and the `dnom` feature for numbers after it.
除了特定#tr[scripts]所需的默认特性列表外,#tr[layout]引擎可能还会要求增加某些特性。比如用户可能按下了小型大写字母的按钮,此时#tr[layout]引擎就会要求使用字体中的`smcp`特性。或者#tr[layout]引擎在发现类似3/5形式的分数时,可能为斜杠前面的数字开启`numr`特性,为之后的数字开启`dnom`特性,可以产生#text(features: ("numr",))[3]/#text(features: ("dnom",))[5]这样的效果。
// Now that we have a set of features we are looking for, we need to turn that into a list of lookups. We take the language and script of the input, and see if there is a feature defined for that language/script combination; if so, we add the lookups in that feature to our list. If not, we look at the features defined for the input script and the default language for that script. If that's not defined, then we look at the features defined for the `dflt` script.
现在我们有了一个将要被应用的特性列表,它需要被转换成#tr[lookup]列表。我们从输入中得知当前语言和#tr[scripts]后,会去检查字体中是否有为这种组合定义的特性。如果存在的话,就会将特性中的所有#tr[lookup]加入列表中。如果不存在,就会去查找输入的#tr[scripts]加默认语言的组合。如果还是不存在,会使用为 `dflt` 定义的特性。
// For example, if you have text that we know to be in Urdu (language tag `URD`) using the Arabic script (script tag `arab`), the shaper will first check if Arabic is included in the script table. If it is, the shaper will then look to see if there are any rules defined for Urdu inside the Arabic script rules; if there are, it will use them. If not, it will use the "default" rules for the Arabic script. If the script table doesn't have any rules for Arabic at all, it'll instead pretend that the script is called `DFLT` and use the feature list defined for that script.
举个例子,假设你输入了一段使用阿拉伯文(`arab`)书写的乌尔都语(`URD`)文本。此时#tr[shaper]会首先检查字体的支持#tr[scripts]列表中是否有阿拉伯文。如果有,#tr[shaper]会查找阿拉伯文的规则中是否有定义为乌尔都语使用的,有的话就会只使用这些规则。要是没有,他会使用阿拉伯文的“默认”规则。如果字体中根本没有阿拉伯文的规则,#tr[shaper]会将输入文本视为“DFLT”文,然后使用为此#tr[scripts]定义的特性列表。
|
https://github.com/Meisenheimer/Notes | https://raw.githubusercontent.com/Meisenheimer/Notes/main/src/PDE.typ | typst | MIT License | #import "@local/math:1.0.0": *
= Partial Differential Equation
#env("Definition")[
A $mathbf(2)$*th order* *partial differential equation* in $RR^n$ takes the form
$ sum_(i=0)^n sum_(j=0)^n a_(i j) (mathbf(x)) u_(x_i x_j) + sum_(i=0)^n b_(i) (mathbf(x)) u_(x_i) + c(mathbf(x)) u(mathbf(x)) = f(mathbf(x)), $
where $a_(i j)(mathbf(x)) = a_(j i)(mathbf(x))$.
]
#env("Definition")[
Let $A(mathbf(x)) = (a_(i j)(mathbf(x)))_(n times n)$ be a symmetric matrix, and $lambda_1 gt.eq dots.c gt.eq lambda_n$ the eigenvalues of $A$ at $mathbf(x)_0$, then
- The equation is *elliptic* at $mathbf(x)_0$ if for $i = 1, dots, n$, $lambda_i < 0$
- The equation is *parabolic* at $mathbf(x)_0$ if $lambda_1 = 0$ and for $i = 2, dots, n$, $lambda_i < 0$;
- The equation is *hyperbolic* at $mathbf(x)_0$ if $lambda_1 > 0$ and for $i = 2, dots, n$, $lambda_i < 0$;
]
#env("Definition")[
The boundary conditions for the unknown function $y$, constants $c_0, c_1$ specified by the boundary conditions, and known scalar functions $g, h$ specified by the boundary conditions, where
- *Dirichlet boundary condition*: $y = g$;
- *Neumann boundary condition*: $(partial y)/(partial n) = g$;
- *Robin boundary condition*: $c_0 y + c_1 (partial y)/(partial n) = g$ where $c_0, c_1 eq.not 0$;
- *Mixed boundary condition*: $y = g$ and $c_0 y + c_1 (partial y)/(partial n) = h$ where $c_0, c_1 eq.not 0$;
- *Cauchy boundary condition*: $y = g$ and $(partial y)/(partial n) = h$.
]
== Poisson's Equation
#env("Definition")[
A *Poisson's equation* in $RR^n$ takes the form
$ - Delta u = f(mathbf(x)), $
where $Delta$ is the Laplace operator, $u, f: RR^n -> RR$ and $mathbf(x) in RR^n$.
]
== Heat Equation
#env("Definition")[
A *Heat equation* in $RR^n times RR$ takes the form
$ (partial u)/(partial t) - a^2 Delta u = f(mathbf(x), t), $
where $Delta$ is the Laplace operator on $RR^n$, $u, f: RR^n times RR -> RR$ and $mathbf(x) in RR^n$.
]
== Wave Equation
#env("Definition")[
A *Wave equation* in $RR^n times RR$ takes the form
$ (partial^2 u)/(partial t^2) - a^2 Delta u = f(mathbf(x), t), $
where $Delta$ is the Laplace operator on $RR^n$, $u, f: RR^n times RR -> RR$ and $mathbf(x) in RR^n$.
]
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/packages/typst.node/npm/linux-arm64-musl/README.md | markdown | Apache License 2.0 | # `@myriaddreamin/typst-ts-node-compiler-linux-arm64-musl`
This is the **aarch64-unknown-linux-musl** binary for `@myriaddreamin/typst-ts-node-compiler`
|
https://github.com/Kasci/LiturgicalBooks | https://raw.githubusercontent.com/Kasci/LiturgicalBooks/master/CSL_old/oktoich/Hlas4/0_Nedela.typ | typst | #let M = (
"HV": (
("", "", "Životvorjáščemu tvojemú krestú, neprestánno kláňajuščesja <NAME>, tridnévnoje voskresénije tvojé slávim: ťím vo obnovíl jesí istľívšeje čelovíčeskoje jestestvó Vsesíľne, i íže na nebesá voschód obnovíl jesí nám, jáko jedín bláh, i čelovikoľúbec."),
("", "", "Životvorjáščemu tvojemú krestú, neprestánno kláňajuščesja <NAME>, tridnévnoje voskresénije tvojé slávim: ťím vo obnovíl jesí istľívšeje čelovíčeskoje jestestvó Vsesíľne, i íže na nebesá voschód obnovíl jesí nám, jáko jedín bláh, i čelovikoľúbec."),
("", "", "Dréva preslušánija zapreščénije razrišíl jesí Spáse, na drévi krestňim vóleju prihvozdívsja, i vo ád sošéd síľne, smértnyja úzy jáko Bóh rasterzál jesí. Ťímže kláňajemsja jéže iz mértvych tvojemú voskreséniju, rádostiju vopijúšče: vsesíľne Hóspodi, sláva tebí."),
("", "", "Vratá ádova sokrušíl jesí Hóspodi, i tvojéju smértiju smértnoje cárstvo razrušíl jesí: ród že čelovíčeskij ot istľínija svobodíl jesí, živót i netľínije míru darováv, i véliju mílosť."),
("Dogmat", "", "Bez símene začalá jesí i rodilá jesí neizrečénno, nizložívšaho síľnyja ot prestól, i voznosjáščaho smirénnyja, i vozdvizájuščaho róh vírnych svojích, slávjaščich Christóv krest i pohrebénije, i slávnoje voskresénije. Ťímže ťá Bohoródice, chodátaicu tolíkich bláh nemólčnymi písňmi ublažájem, jáko moľáščujusja prísno, jéže spastísja dušám nášym."),
),
"S": (
("", "", "Hóspodi vozšéd na krest, práďidňuju nášu kľátvu potrebíl jesí, i sošéd vo ád, víčnyja úzniki svobodíl jesí, netľínije dáruja čelovíčeskomu ródu: sehó rádi pojúšče slávim životvorjáščeje i spasíteľnoje tvojé vostánije."),
("", "Zvánnyj svýše", "Iz beznačáľna Otcá Sýn bezľítno, nizchoždénija rádi i spasénija čelovíkov, Bóh čelovík býsť, da podást pervozdánnomu nýňi ráj: tohdá i vsé jestestvó izbávitsja ot prélesti zmíjevy, i óbraz pádšij spasét, jáko blahopreminíteľ: otňúduže Máter soďíla nevistoródicu čístu jáko neskvérnu, júže jáko ankíru vsí, i pristánišče ublažájem."),
("", "", "Voploščénna sozdáteľa vsích, imíla jesí vo utróbi tvojéj Bohoblažénnaja, voobrazívšaho čelovíka, préžde pádšaho prestuplénijem zmijínym: Bóha bo rodilá jesí plótiju neskazánno nám, i iz tľínija svobodíla jesí jestestvó vsé obetšávšeje, roždestvóm tvojím. Ťímže pojém i slávim tvojú blahodáť Ďívo beznevístnaja, molítisja ne prestáj, spastísja dušám nášym."),
("", "", "Da tvojejá vsím mnóžestvo mílosti i bláhosti otkrýješi nám neopreďilímuju pučínu, hrichí rabóv tvojích vsjá zahládi: ímaši bo vseneporóčnaja, jáko Máti súšči Bóžija, vlásť sozdánija, i vódiši vsjá, jáko chóščeši, síloju tvojéju: íbo blahodáť Dúcha svjatáho jávi vséľšajasja v ťá, soďíjstvujet tí vo vsém prísno vseblažénňijšaja."),
("Dogmat", "", "Íže so Otcém i Dúchom slavoslóvimyj Sýn, vo výšnich ot Serafímov pervosozdánnaho páki obnovíti choťá, vsehó sebé istoščí neizrečénno vo utróbi tvojéj, Bohoródice vsepítaja: i iz tebé vozsijávyj, prosvití vsehó míra Božestvóm, izbávivyj ot idoloneístovstva, i sobóju obožívyj, na nebesá vozvedé čelovíčestvo, Christós Bóh i Spás dúš nášich."),
)
)
#let V = (
"HV": (
("", "", "Životvorjáščemu tvojemú krestú, neprestánno kláňajuščesja Christé Bóže, tridnévnoje voskresénije tvojé slávim: ťím bo obnovíl jesí istľívšeje čelovíčeskoje jestestvó vsesíľne, i íže na nebesá voschód obnovíl jesí nám, jáko jedín bláh i čelovikoľúbec."),
("", "", "Dréva preslušánija zapreščénije razrišíl jesí Spáse, na drévi krestňim vóleju prihvozdívsja, i vo ád sošéd síľne, smértnyja úzy jáko Bóh rasterzál jesí. Ťímže kláňajemsja jéže iz mértvych tvojemú voskreséniju, rádostiju vopijúšče: vsesíľne Hóspodi, sláva tebí."),
("", "", "Vratá ádova sokrušíl jesí Hóspodi, i tvojéju smértiju smértnoje cárstvo razrušíl jesí: ród že čelovíčeskij ot istľínija svobodíl jesí, živót i netľínije míru darováv, i véliju mílosť."),
("", "", "Prijidíte vospojím ľúdije, Spásovo tridnévnoje vostánije, ímže izbávichomsja ádovych nerešímych úz: i netľínije i žízň vsí vosprijáchom zovúšče: raspnýjsja, i pohrebýjsja, i voskrésýj, spasí ny voskresénijem tvojím jedíne čelovikoľúbče."),
("", "", "Ánheli i čelovicy Spáse, tvojé pojút tridnévnoje vostánije, ímže ozaríšasja vselénnyja koncý, i rabóty vrážija vsí izbávichomsja, zovúšče: životvórče vsesíľne Spáse spasí ny voskresénijem tvojím, jedíne čelovikoľúbče."),
("", "", "Vratá mídnaja stérl jesí, i verejí sokrušíl jesí Christé Bóže, i ród čelovíčeskij pádšij voskresíl jesí. Sehó rádi sohlásno vopijém: voskresýj iz mértvych Hóspodi, sláva tebí."),
("", "", "Hóspodi, jéže ot Otcá tvojé roždestvó, bezľítno jésť i prisnosúščno: jéže ot Ďívy voploščénije, neizrečénno čelovíkom i neskazánno: i jéže vo ád sošéstvije strášno dijávolu i áhhelom jehó: smérť bo popráv, tridnéven voskrésl jesí, netľínije podavája čelovíkom, i véliju mílosť."),
("", "O preslávnaho čudesé!", "Tebé vírnym pokróv pokazá, íže vsjáčeskich Bóh, voplóščsja ot krovéj tvojích Bohoródice vsečístaja, i predstáteľnicu i pobórnicu súščym v núždach i obstojánijich, i v búri pristánišče blahoutíšnoje: tý úbo spasí ot vsjákija skórbi i tuhí, vsích pritekájuščich k božéstvennomu pokróvu tvojemú."),
("", "", "Da proslavľáju i počitáju, da čtú i pojú, da vospiváju vsehdá tvojé božéstvennoje ímja, preblažénnaja Vladýčice, da mjá ne ostáviši vrahóm rádovanije býti, pokróvu tvojemú pritekájuščaho: no krilý čestných molítv tvojích vsehdá cíla mjá sochraní ot vsích iskušénij."),
("", "", "Rádujsja, Bohomáti prečístaja. Rádujsja, vírnym nadéžda. Rádujsja, míru očiščénije. Rádujsja, izbavľájuščaja vsjákich skorbéj rabý tvojá, jáže smérti razrušíteľnica. Rádujsja, životonósnaja. Rádujsja, utéšiteľnice. Rádujsja, zastúpnice. rádujsja pribížišče."),
("Dogmat", "", "Íže tebé rádi Bohootéc prorók Davíd písnenno o tebí provozhlasí, velíčija tebí sotvóršemu: predstá caríca odesnúju tebé. Ťá bo Máter, chodátaicu životá pokazá, bez otcá iz tebé vočelovíčitisja blahovolívyj Bóh, da svój páki obnovít óbraz, istľívšij strasťmí, i zablúždšeje horochíščnoje obrít ovčá, na rámo vosprijím, ko Otcú prinesét, i svojemú choťíniju, s nebésnymi sovokupít sílami, i spasét Bohoródice, mír, Christós imíjaj véliju i bohátuju mílosť."),
),
"S": (
("", "", "Hóspodi, vozšéd na krest, práďidňuju nášu kľátvu potrebíl jesí, i sošéd vo ád, víčnyja úzniki svobodíl jesí, netľínije dáruja čelovíčeskomu ródu: sehó rádi pojúšče slávim životvorjáščeje i spasíteľnoje tvojé vostánije."),
("", "", "Povíšen na drévi jedíne síľne, vsjú tvár pokolebál jesí: položén že vo hróbi, živúščyja vo hrobích voskresíl jesí, netľínije i žízň dáruja čelovíčeskomu ródu. Ťímže pojúšče slávim tridnévnoje tvojé vostánije."),
("", "", "Ľúdije bezzakónniji Christé, tebé predávše Pilátu, raspjáti osudíša, neblahodárni o blahoďíteľi javívšesja. No vóleju preterpíl jesí pohrebénije: samovlástno voskrésl jesí tridnévno jáko Bóh, dáruja nám bezkonéčnyj živót, i véliju mílosť."),
("", "", "So slezámi žený došédša hróba, tebé iskáchu, ne obrítša že, rydájuščja s pláčem vopijúščja hlahólachu: uvý nám, Spáse náš carjú vsích, káko ukráden býl jesí? Kóe že místo deržít živonósnoje ťílo tvojé? Ánhel že k ním otviščaváše, ne pláčite, hlahólet, no šédša propovídite, jáko voskrése Hospóď, podajá nám rádosť, jáko jedín blahoutróben."),
("Dogmat", "", "Prízri na molénija tvojích ráb vseneporóčnaja, utoľájušči ľútaja na ný vostánija, vsjákija skórbi nás izmiňájušči: ťá bo jedínu tvérdoje i izvístnoje utverždénije ímamy, i tvojé predstáteľstvo sťažáchom. Da ne postydímsja Vladýčice, ťá prizyvájuščiji, potščísja na umolénije, tebé vírno vopijúščich: rádujsja Vladýčice, vsích pómošče, rádoste i pokróve, i spasénije dúš nášich."),
),
"T": (
("", "", "Svítluju voskrésnija própoviď ot ánhela uvíďivša Hospódni učenícy, i práďidneje osuždénije otvérhša, apóstolom chváľaščjasja hlahólachu: isprovéržesja smérť, voskrése Christós Bóh, dárujaj mírovi véliju mílosť."),
("Bohoródičen", "", "Jéže ot víka utajénoje, i ánhelom nesvídomoje tájinstvo: tobóju Bohoródice súščym na zemlí javísja Bóh, v neslítnom sojedinéniji voploščájem, i krest vóleju nás rádi vosprijím, ímže voskresív pervozdánnaho, spasé ot smérti dúšy náša."),
),
)
#let P = (
"1": (
("", "", "Mórja čermnúju pučínu nevlážnymi stopámi drévnij pišešéstvovav Izráiľ, krestoobráznyma Mojséovyma rukáma, Amalíkovu sílu v pustýni pobidíl jésť."),
("", "", "Jáže jedína v napástech i skórbech zaščiščájuščaja, pod króv tvój prečístaja, pribihájuščich tépľi, prijimí jáko preblahája, jáže ot sérdca molénija."),
("", "", "Pristánišče nevlájemoje obrít ťá nerazúmnyj, napástnyja že i núždnyja prilóhi otrivája, blahodárnoje pojú ti vospivánije, Bohomúžnaja rodíteľnice."),
("", "", "Mílostivnym i krótkim tvojím ókom, Bohorodíteľnice, zrjášči mjá vo obstojániji i skórbi oderžíma, vskóri svobodí: ťá bo prizyváju na pómošč."),
("", "", "Preklonéna mjá Vladýčice, skorbmí núždnymi ľúťi, jáko mílostiva jedína blahája predstáteľnica rabóv tvojích, rúku moľbý prostrí, i ľútych bíd izbávi mjá."),
),
"3": (
("", "", "Lúk síľnych iznemóže, i nemoščstvújuščiji prepojásašasja síloju: sehó rádi utverdísja v Hóspoďi sérdce mojé."),
("", "", "Orúžije krípko, i sťínu ťá sťažáv áz, pobiždáju soprotívnych polkí, i pojú velíčija tvojá, Bohoródice neiskusobráčnaja."),
("", "", "Péšč razorjáješi pečálej, i pohašáješi otčájanija znój: któ bo táko, jákože tý Ďívo Bohoródice, upovánije náše?"),
("", "", "Vnuší hlás rabá tvojehó, tvojejá trébujuščaho pómošči, Bohomáti: upovánije mojé, uslýši mjá, i napástej ischití."),
("", "", "Priíde ot prehrišénij mnóžestva mučíteľstvo nám, nosjá smérť páhubnuju: no spasí tvojá rabý Bohoródice, tý bo móžeši."),
),
"4": (
("", "", "Vozneséna ťá víďivši cérkov na kresťí, sólnce právednoje, stá v číňi svojém, dostójno vzyvájušči: sláva síľi tvojéj Hóspodi."),
("", "", "Pobíždši vraždújuščich mňí vsúje, jáko dúšu mojú tščáščichsja ľúťi prijáti, sochraní mja Vladýčice, pomíluj, i spasí: k tebí bo pribiháju ráb tvój."),
("", "", "Izbavľájušči mjá ot jazýka ľstivohlahóliva, blahája zastúpnice mojá, bezpákostna pokaží, i žitéjskich ďijánij: mnóho bo móžeši, jáko ziždíteľa Máti súšči."),
("", "", "Bezboľíznennu vídyj ťá cilébnicu nemoščnýj, Dúchom i ustý zovú: iscilí mja Vladýčice, pomíluj, i spasí: k tebí bo pribiháju ráb tvój."),
("", "", "Ne ostávi mené napástem prédanu býti, Máti Bóha nášeho, no ot vsjákija skórbi i zlóby čelovíči sochraní nevreždéna: tý bo jesí pomóščnica vsím nám."),
),
"5": (
("", "", "Tý Hóspodi mój, svít v mír prišél jesí, svít svjatýj, obraščájaj iz mráčna nevíďinija, víroju vospivájuščyja ťá."),
("", "", "Isprávi čístaja, molítvu rabá tvojehó ko Hóspodu Sýnu tvojemú: da obrjášču razrišénije mnóhich mojích prehrišénij."),
("", "", "Izbávi mjá strastéj i bíd, Bohonevísto: ťá bo položí Bóh očiščénije voístinnu mojemú smiréniju."),
("", "", "Pokróv mój tý jesí, i prísnoje chvalénije, o Vladýčice Bohoródice! Nikákože bo preziráješi k tebí pribihájuščich."),
("", "", "Pomíluj čístaja, čtúščich roždestvó tvojé, i izbávi mučíteľstva, i hóresti čelovíčeskija: íbo ímaši jéže moščí."),
),
"6": (
("", "", "Požrú ti so hlásom chvalénija Hóspodi, cérkov vopijét tí, ot bisóvskija króve očíščšisja, rádi mílosti ot rébr tvojích istékšeju króviju."),
("", "", "Kríposť mí samá jesí prečístaja Vladýčice, vo obrítšich mjá ziló nenačájannych skórbech, i vopijú ti: jáko vélija jesí pokrovíteľnica rabú tvojemú."),
("", "", "Iscilí dušévnyja mojá jázvy prečístaja, zastupí mja Ďívo, i izbávi rabá tvojehó ot oklevetánija, navíta že i razvraščénija neprávedna."),
("", "", "Sokruší na mjá, prísno pribihájuščaho k tebí, navítniki neprávednyja, i ne ostávi mjá pohíbnuti: jáko vsjá tebí vozmóžna čístaja, jáko Bohootrokovíci."),
("", "", "Pobídí duší mojejá svirípuju vólnu, jáko mnóžestvo prehrišénij, napástej i skorbéj, Vladýčice, vostáša na mjá, no samá mja spasí."),
),
"S": (
("", "", "Mnóhimi prehrišénij áz blúdnyj úm pomračív, vopijú tvojemú krípkomu zastupléniju Bohoródice: prosvití duší mojejá zínicy, vozsijáj mí pokajánija svítluju zarjú, i oblecý mja vo orúžije svíta, Bohorodíteľnice čístaja."),
),
"7": (
("", "", "Spasýj vo ohní avraámskija tvojá ótroki, i Chaldéji ubív, jáže právda právedno ulovľáše, prepítyj Hóspodi Bóže otéc nášich, blahoslovén jesí."),
("", "", "Íže ot Ahárjan nasílovanije skóro potrébľši mečém molítv tvojích Maríje, ľúdi i stádo tvojé sochraní, Sýnu tvojemú zovúščyja: Bóže otéc nášich, blahoslovén jesí."),
("", "", "Ravnoľípnaja skínija, prijimí mja k tebí pribihájuščaho, da ne priímet mjá vráh pohubíti choťá, zovúščaho: prevoznosímyj otéc nášich Bóže, blahoslovén jesí."),
("", "", "Bohorodíteľnice Maríje, predvarí rabá tvojehó vskóri, v trevolnénijich napástej potopľájemaho, ne imúščaho pómošči, k tebí že zovúšča: upovánije koncév, pomíluj mjá."),
("", "", "Čelovéčeskija pómysly jáko hrichóm vinóvny, nýňi Bohoródice blahája razorí, božéstvennymi tvojími molítvami, i rabý tvojá izbávi boľíznennyja napásti i vsjákaho vréda."),
),
"8": (
("", "", "Izbáviteľu vsích vsesíľne, posreďí plámene blahočéstvovavšyja, snizšéd orosíl jesí, i naučíl jesí píti: vsjá ďilá blahoslovíte , pójte Hóspoda."),
("", "", "Nájde na ný jazýk bezzakónen, chvaľásja pohubíti služíteli tvojá: jehóže potrébľši prečístaja, pokrýj vzyvájuščyja: vsjá ďilá blahoslovíte Hospódňa Hóspoda."),
("", "", "Mnóhija tvojá ščedróty mílostivno nás spasájut, jedína Bohomáti, ot hrichóvnaho sudá, i razlíčnych napástej: tý bo róždši Bóha, míluješi mír jehó."),
("", "", "Jáko tý jesí kríposť i pómošč, ne bojúsja vrahóv nehodovánija, no pojú ťa Vladýčice, i vopijú Sýnu tvojemú: blahoslovíte vsjá ďilá Hospódňa Hóspoda."),
("", "", "Na moľbú mojú nýňi umilosérdisja, i rádosť v pečáli místo dáruj mí: da pojú ťa Vladýčice, i vopijú Sýnu tvojemú: blahoslovíte vsjá ďilá Hospódňa Hóspoda."),
),
"9": (
("", "", "Jéva úbo nedúhom preslušánija kľátvu vselíla jésť: tý že Ďívo Bohoródice, prozjabénijem črevonošénija mírovi blahoslovénije procvilá jesí, ťím ťá vsí veličájem."),
("", "", "Orúžije úbo na ný obostrív, soviščavájet ľstívyj arávľanin bezzakónnyj: tý ž Ďívo Bohoródice, síloju krestá i molítv tvojích, vooružáješi na nehó rabý tvojá. Ťímže propovídajem slávu tvojú."),
("", "", "Kríposť tebí na vrahí dadésja Vladýčice, i izbavlénije mí ot bíd: čtó že áz tebí prinesú, ne dovím. Obáče, jéže ímam, blahodarénije prinošú ti: prijimí sijé nýňi, i spasí mja."),
("", "", "O Máti vsjáčeskich tvorcá vsesvítlaja, pečálnych uťícha, potopľájemych predstáteľnica, i prenemohájuščichsja zastúpnica, do životá mojehó tý mja sochraní."),
("", "", "Uťisňájema mjá hrichí mnóhimi, i bidámi, ne prézri mené vsepítaja nýňi, tebí chvalénija žértvu prinošú, priľížno vzyvája tí: svjatája Bohoródice, pomozí mi, ťá bo slávja písň skončaváju."),
),
)
#let N = (
"1": (
("", "", "Mórja čermnúju pučínu, nevlážnymi stopámi, drévnij pišešéstvovav Izráiľ, krestoobráznyma Mojséovyma rukáma, Amalíkovu sílu v pustýni pobidíl jésť."),
("", "", "Tróicu Bohonačáľnuju da proslávim ipostásmi, jedínstvennoje že jestestvó trijéch, soprisnosúščnuju, soprestóľnuju, júže moľášče, hlahólem: spasí íže víroju tebé slávjaščich."),
("", "", "Pomázasja ot Otcá Dúchom rádovanija, Bohoďíteľnym jeléjem, Sýn, i čelovík býsť, i jedínaho Božestvá trijipostásnoje naučíl jésť."),
("", "", "Dobrótu nepristúpnyja slávy tvojejá jedínice trisólnečnaja, Serafími ne terpjášče zríti, spokryvájutsja kríly: i trisvjatými písňmi neprestánno tebé slávjat."),
("Bohoródičen", "", "Neizrečénno tvorcá rodilá jesí vsích prečístaja, izbavľájuščaho drévnija kľátvy čelovíki, i smértnyja tlí, i tobóju poznáchom jedínaho Bóha triipostásnaho."),
),
"3": (
("", "", "Ne múdrostiju i síloju i bohátstvom chválimsja, no tobóju Ótčeju ipostásnoju múdrostiju Christé: ňísť bo svját, páče tebé čelovikoľúbče."),
("", "", "Sílu svýše svjatým tvojím préžde apóstolom, jáko poslál jesí Christé, ot Otcá Uťíšiteľa, jedíno javíl jesí jestestvó trisólnečnoje."),
("", "", "Patrijárchu Avraámu jehdá javílasja jesí vo óbrazi múžesťi, Tróičňa jedínice, nepremínnoje pokazála jesí tvojejá bláhosti i Hospóďstva."),
("", "", "Íže vo óbrazich trijéch, jedín Bóh vírujemyj: neopísannyj jávi, nedomýslimyj vsími, izbávi dúšy náša ot vsjákija skórbi."),
("Bohoródičen", "", "Nastávľšesja Sýna tvojehó premúdrymi privedéňmi, jedínstvennoje i trisvítloje Bohonačálije slávim, i tebé blažím prisnoďívu."),
),
"S1": (
("", "Skóro predvarí", "Trisólnečnaja, nesozdánnaja i jedinosúščnaja jedínice, trijipostásnaja i nepostižímaja, rabý tvojá uščédri: spasí ot bíd, jáko Bóh mílostiv, ťá bo Hóspodi, jedínaho izbáviteľa i Vladýku ímamy, vopijúšče: búdi nám mílostiv."),
("Bohoródičen", "", "Mnóhimi obstojáňmi i napásťmi ľútych Ďívo, okružájemi, i ko otčájaniju prísno vpádajušče, jedínu ťá spasénije i nadéždu, i sťínu ímamy Bohoródice, i tebé po dólhu víroju i nýňi mólim: spasí rabý tvojá."),
),
"4": (
("", "", "Siďáj v slávi na prestóľi božestvá, vo óblaci léhci priíde Iisús prebožéstvennyj, netľínnoju dlániju, i spasé zovúščyja: sláva Christé síľi tvojéj."),
("", "", "Presúščnuju Tróicu, vo jedínici Božestvá i Hóspodonačálije, so Serafímy tebé slávim, jáko nerazďíľno jestestvó, jáko nepristúpnoje, jáko ravnostátno slávoju, Bóže nepostižímyj."),
("", "", "Razďilénnu súšču neizrečénno lícy Božestvá, i sojediňájemu deržávoju vkúpi jedíňim Hospóďstvom, bezpreďiľnu jedínu, neopísannu, vospivájem ťá tvorcá vsejá tvári."),
("", "", "Úm beznačáľnyj, Slóvo neizhlahólanňi rodí, i božéstvennaho Dúcha ravnomóščna ispustí: i sehó rádi Tróicu jedinosúščnuju, Vladýku vsích Bóha propovídajem."),
("Bohoródičen", "", "Vídim byvája drévnimi obrázňi, predvozvistílo jésť, jéže ot tebé voploščénije, Slóvo: no pósľižde jávľsja čelovíkom, poístinňi trijipostásnoje jedinonačálije javí."),
),
"5": (
("", "", "Užasóšasja vsjáčeskaja o božéstvenňij slávi tvojéj: tý bo neiskusobráčnaja Ďívo, imíla jesí vo utróbi nad vsími Bóha, i rodilá jesí bezľítnaho Sýna, vsím vospivájuščym ťá mír podavájuščaja."),
("", "", "Razumívše ot víry vseďíteľnaho Božestvá, jedíno úbo nepristúpno suščestvó, trí že ipostási živonačáľny, srásleny čtém: Otcá, i Sýna, i Dúcha svjatáho soprisnosúščnoje bytijé."),
("", "", "Svíte trisóľnečne, súščestvennaho svíta tvojehó vozsijáj mí jedínstvennoje Božestvó, nesozdánnoje jestestvó, i svitoďíjstvennyj istóčniče vsjákija svitodáteľnyja zarí: da sozercáju tvojú dobrótu neizrečénnuju."),
("", "", "Jáko jedínomu súšču soďíteľu vsjáčeskich, i soderžíteľu, i kórmčiju vsepremúdru, voístinnu i žízni podáteľu, sehó rádi i vopijém tí vírno: Vladýko trisólnečne, pojúščyja ťá sobľudí."),
("Bohoródičen", "", "Obožíti choťá drévle istľívšaho čelovíka, za bláhosť Ďívo sozdávyj, i pokazávyj óbraza božéstvennyj zrák, čelovík býsť iz tebé, jedíno tričíslennoje Bohonačálije propovída."),
),
"6": (
("", "", "Vozopí, proobrazúja pohrebénije tridnévnoje, prorók Jóna v kíťi moľásja: ot tlí izbávi mjá, Iisúse carjú síl."),
("", "", "Javí Otéc izhlahóluja Synovstvó, i Dúch, Christú kréščšusja, vídim býv: sehó rádi jedíno i Tróičeskoje Bohonačálije slávim."),
("", "", "Jáko víďi ťá trisvjatými hlásy vospivájemaho Isáia, na vysóci prestóľi siďášča, Tróičeskuju pozná jedínaho Bohonačálija ipostás."),
("", "", "Vozvyšéno sérdce pokaží i nás ráb tvojích, vysókij carjú trijipostásne: da tvojejá slávy zrím jásno svítlosť."),
("Bohoródičen", "", "Voschoťí voobrazítisja jávi v náše, ot Ďívy Sýn Bóžij jáko čelovikoľúbec, i božéstvennyja slávy óbščniki čelovíki sotvorí."),
),
"S2": (
("", "Skóro predvarí", "Otcá neroždénna, Sýna že roždénna, i Dúcha svjatáho ischódna ot Otcá múdrstvujušče, propovídajem beznačáľnoje cárstvo i Božestvó jedíno, jéže slavoslóvjašče jedinomúdrenno vopijém: Tróice jedinosúščnaja, spasí nás Bóže."),
("Bohoródičen", "", "Ľít prevýšše, i préžde vík Bóha, v ľíto rodilá jesí prejestéstvenňi plótiju, Bóha čelovíka prečístaja. Ťímže ťá Bohoródicu, ístinno i Hospóďstvenňi vsí ispovídajušče, priľížno tí vopijém: slávy víčnyja vsjá spodóbi."),
),
"7": (
("", "", "V peščí avraámstiji ótrocy persídsťij, ľubóviju blahočéstija páče, néželi plámenem opaľájemi, vzyváchu: blahoslovén jesí v chrámi slávy tvojejá Hóspodi."),
("", "", "Učinénaja nebésnaja jestestvá, i úmnyja číny pravoslávno vsí zemnoródniji podražájušče, slávim jedíno Božestvó v trijéch ravnoďíteľnych ipostásich."),
("", "", "Učinénaja nebésnaja jestestvá, i úmnyja číny pravoslávno vsí zemnoródniji podražájušče, slávim jedíno Božestvó v trijéch ravnoďíteľnych ipostásich."),
("", "", "Ríči svjatých prorók, ťá drévle obrázno jedínaho vikóv vsích soďíteľa projavíša, neizrečénnaho Bóha i Hóspoda, Bohonačáľnymi tremí ipostásmi."),
("Bohoródičen", "", "Íže po suščestvú nevídimoje Slóvo i vseďíteľnoje, javílsja jesí čelovíkom, čelovík ot čístyja Bohomátere, čelovíka prizyvája ko pričástiju tvojehó Božestvá."),
),
"8": (
("", "", "Rúci rasprostér Daniíl, ľvóv zijánija v róvi zatčé: óhnennuju že sílu uhasíša, dobroďíteliju prepojásavšesja, blahočéstija račíteli ótrocy, vzyvájušče: blahoslovíte vsjá ďilá Hospódňa Hóspoda."),
("", "", "Svíte jedinonačáľnyj i trisijánnyj, suščestvó beznačáľnoje, dobróto nedovídomaja, v sérdci mojém vselísja, i chrám tvojehó Božestvá, svitovíden i číst pokaží mja, zovúšča: blahoslovíte vsjá ďilá Hospódňa Hóspoda, pójte i prevoznosíte jehó vo víki."),
("", "", "Svíte jedinonačáľnyj i trisijánnyj, suščestvó beznačáľnoje, dobróto nedovídomaja, v sérdci mojém vselísja, i chrám tvojehó Božestvá, svitovíden i číst pokaží mja, zovúšča: blahoslovíte vsjá ďilá Hospódňa Hóspoda, pójte i prevoznosíte jehó vo víki."),
("", "", "Ot razlíčnych mjá strastéj Tróice nerazďíľnaja, jedínice neslítnaja, i omračénija prehrišénij izbávi, i ozarí lučámi tvojími božéstvennymi: da voobrazúju tvojú slávu, i vospiváju ťá slávy Hóspoda."),
("Bohoródičen", "", "Úm úbo neroždénnyj Otéc, i Slóvo soobrázno, i Dúch soprestólen, suščestvó, síla, bytijé: presúščnaja, neizrečénnaja, velikoďíjstvennaja Tróice, jedínice, sobľudáj stádo tvojé molítvami Bohoródicy, jáko jestestvóm čelovikoľúbec."),
),
"9": (
("", "", "Vsják zemnoródnyj da vzyhrájetsja dúchom prosviščájem, da toržestvújet že bezplótnych umóv jestestvó, počitájuščeje svjaščénnoje toržestvó Bohomátere, i da vopijét: rádujsja vseblažénnaja Bohoródice, čístaja prisnoďívo."),
("", "", "Vsé k tebí nýňi dvížu sérdce mojé i mýsľ, i predložénija že vsejá duší i ťíla, soďíteľu i izbáviteľu mojemú, jedinonačáľne, i trisvítle, i vopijú ti: spasí mja rabá tvojehó ot vsjákich iskušénij i skorbéj."),
("", "", "Vsé k tebí nýňi dvížu sérdce mojé i mýsľ, i predložénija že vsejá duší i ťíla, soďíteľu i izbáviteľu mojemú, jedinonačáľne, i trisvítle, i vopijú ti: spasí mja rabá tvojehó ot vsjákich iskušénij i skorbéj."),
("", "", "Vozvýsi náš úm, i mýsľ k tebí výšnemu, prosvití tvojími sijáňmi prečístymi, Ótče, Slóve, Uťišiteľu, vo svíťi živýj nepristúpňim, slávy sólnce, svitodéržče, vsehdá sláviti ťá jedinonačáľnaho Bóha triipostásnaho."),
("Bohoródičen", "", "Spasí íže v ťá vírujuščyja Hóspodi, i propovídajuščyja beznačáľnoje prisnosúščnoje suščestvó jedíno, trí že líca Bohonačáľna i soobrázna, tvojehó Hospóďstvija, i božéstvennyja slávy tvojejá spodóbi, moľbámi čístyja Bohomátere."),
),
)
#let U = (
"T": (
("", "", "Svítluju voskrésnija própoviď ot ánhela uvíďivša Hospódni učenícy, i práďidneje osuždénije otvérhša, apóstolom chváľaščjasja hlahólachu: isprovéržesja smérť, voskrése Christós Bóh, dárujaj mírovi véliju mílosť."),
("Bohoródičen", "", "Jéže ot víka utajénoje, i ánhelom nesvídomoje tájinstvo: tobóju Bohoródice súščym na zemlí javísja Bóh, v neslítnom sojedinéniji voploščájem, i krest vóleju nás rádi vosprijím, ímže voskresív pervozdánnaho, spasé ot smérti dúšy náša."),
),
"S1": (
("", "", "Vozzrívša na hróbnyj vchód, i plámene ánheľskaho ne terpjáščja mironósicy, s trépetom divľáchusja, hlahóľuščja: jehdá ukrádesja otvérzyj razbójniku ráj? Jedá li vostá, íže i préžde strásti propovídavyj vostánije? Voístinnu voskrése Christós, súščym vo áďi podajá živót, i voskresénije."),
("", "", "Vóľnym tvojím sovítom krest preterpíl jesí Spáse: i vo hróbi nóvi čelovícy položíša ťá smértniji, slóvom koncý sostávľšaho. Ťímže svjázan býsť čúždij: smérť ľúto pľiňášesja, i súščiji vo áďi vsí vzyváchu živonósnomu vostániju tvojemú: Christós voskrése, žiznodávec prebyvájaj vo víki."),
("Bohoródičen", "", "Udivísja Jósif, jéže páče jestestvá zrjá, i vnimáše mýsliju íže na runó dóžď, v bezsímenňim začátiji tvojém Bohoródice, kupinú ohném neopalímuju, žézl Aarónov prozjábšij, i sviďíteľstvuja obrúčnik tvój i chraníteľ, svjaščénnikom vzyváše: Ďíva raždájet, i po roždeství páki Ďíva prebyvájet."),
),
"S2": (
("", "Skóro predvarí", "Voskrésl jesí jáko bezsmértnyj ot hróba Spáse, sovozdvíhl jesí mír tvój síloju tvojéju Christé Bóže náš, sokrušíl jesí v kríposti smérti deržávu, pokazál jesí mílostive, voskresénije vsím: ťímže ťá i slávim jedíne čelovikoľúbče."),
("", "", "S hórnich vysót sošéd Havrijíl, i ko kámeňu pristúpľ, iďíže kámeň žízni, bilonosjáj vzyváše ko pláčuščym: prestánite vý ot rydánija vópľa, imíjuščyja i nýňi mílostivnoje: jehóže bo íščete pláčuščja, derzájte, jáko voístinnu vostál jésť. Ťímže vozopíjte apóstolom: jáko voskrése Hospóď, vostávšemu poklonítesja rádosť prijémša. Derzájte úbo, da derzájet úbo i Jéva."),
("Bohoródičen", "", "Udivíšasja čístaja, vsí ánhelov lícy tájinstvu tvojehó roždénija strášnomu: káko íže vsjá soderžáj mánijem jedíňim, objátiji tvojími jáko čelovík soderžavájetsja, i prijémlet načálo prevíčnyj i mlekóm pitájetsja, íže vsjákoje dychánije pitájaj neizrečénnoju bláhostiju? I ťá jáko voístinnu Bóžiju Máter chváľašče slávjat."),
),
"Y": (
("", "", "Jáže tvojehó preslávnaho vostánija, predtékša mironósicy, apóstolom propovídachu Christé, jáko voskrésl jesí jáko Bóh, podajá mírovi véliju mílosť."),
),
"A1": (
("", "", "Ot júnosti mojejá mnózi bórjut mjá strásti, no sám mjá zastupí, i spasí Spáse mój."),
("", "", "Nenavíďaščiji Sijóna, posramítesja ot Hóspoda, jáko travá bo ohném búdete izsóchše."),
("", "", "Svjatým Dúchom vsjáka dušá živítsja, i čistotóju vozvyšájetsja, svitľíjetsja Tróičeskim jedínstvom svjáščennotájňi."),
("", "", "Svjatým Dúchom vsjáka dušá živítsja, i čistotóju vozvyšájetsja, svitľíjetsja Tróičeskim jedínstvom svjáščennotájňi."),
),
"A2": (
("", "", "Vozzvách tebí Hóspodi tépľi, iz hlubiný duší mojejá, i mňí da búdut na poslušánije božéstvennaja tvojá ušesá."),
("", "", "Na Hóspoda nadéždu vsják któ sťažáv, výššij jésť vsích skorbjáščich."),
("", "", "Svjatým Dúchom tóčatsja blahodátnyja strují, napajájuščja vsjáku tvár ko oživléniju."),
("", "", "Svjatým Dúchom tóčatsja blahodátnyja strují, napajájuščja vsjáku tvár ko oživléniju."),
),
"A3": (
("", "", "Sérdce mojé k tebí Slóve da vozvýsitsja, i da ničtóže usladít mjá ot mirskích krasót na slábosť."),
("", "", "K máteri svojéj jákože ímať któ ľubóv, ko Hóspodu tépľše ľublénijem dólžni jesmý."),
("", "", "Svjatým Dúchom Bohovíďinija bohátstvo, zrínija, i premúdrosti: vsjá bo v sém Otéčeskaja veľínija Slóvo otkryvájet."),
("", "", "Svjatým Dúchom Bohovíďinija bohátstvo, zrínija, i premúdrosti: vsjá bo v sém Otéčeskaja veľínija Slóvo otkryvájet."),
),
"P": (
("", "", "Voskresní Hóspodi, pomozí nám, i izbávi nás ímene tvojehó rádi."),
("", "", "Bóže ušíma nášima uslýšachom: Vsjákoje dychánije"),
),
"K": (
"P1": (
"1": (
("", "", "Mórja čermnúju pučínu nevlážnymi stopámi, drévnij pišešéstvovav Izráiľ, krestoobráznyma Moiséovyma rukáma Amalíkovu sílu v pustýni pobidíl jésť."),
("", "", "Voznéslsja jesí na prečísťim drévi krestňim, náše otpadénije ispravľája, jéže na drévi isciľája vsehubíteľstvo Vladýko, jáko bláh i vsesílen."),
("", "", "Vo hróbi plótski, vo áďi že s dušéju, jáko Bóh: v rají že s razbójnikom, i na prestóľi býl jesí Christé, so Otcém i Dúchom, vsjá ispolňája neopísannyj."),
("Bohoródičen", "", "Bez símene Ótčeju vóleju ot božéstvennaho Dúcha Bóžija začalá jesí Sýna, i plótiju rodilá jesí: íže iz Otcá bez mátere, nás že rádi, iz tebé bez otcá."),
),
"2": (
("", "", "Otvérzu ustá mojá i napólňatsja Dúcha, i slóvo otrýhnu caríci Máteri, i javľúsja svítlo toržestvúja, i vospojú rádujasja tojá čudesá."),
("", "", "Iscilíl jesí sokrušénije čelovíčestva Hóspodi, božéstvennoju tvojéju króviju obnovívyj tó: i sokrušíl jesí síľnaho v kríposti, íže drévle sokrušívšaho tvojé sozdánije."),
("", "", "Mértvych vostánije, umerščvlénijem býl jesí: kríposť bo otjátsja umerščvlénija, brávšisja s žízniju víčnoju, íže vsími vladýčestvujušču voploščénnomu Bóhu."),
("Bohoródičen", "", "Krasén prevýšši nebésnych síl, božéstvennyj tvój býsť chrám oduševlénnyj, vo utróbi tý nosívši Ďívo, horó svjatája, Bóha nášeho."),
),
"3": (
("", "", "Tristáty krípkija, roždéjsja ot Ďívy, bezstrástija vo hlubiňí, duší tričástnoje potopí, moľúsja, da tebí jáko v timpánňi vo umerščvléniji ťilesé, pobídnoje vospojú pínije."),
("", "", "Sotrjasóšasja ľúdije, smatóšasja jazýcy, cárstvija že deržávnaja ukloníšasja čístaja, ot strácha roždestvá tvojehó: priíde bo cár mój, i nizloží mučíteľa, i mír ot tlí izbávi."),
("", "", "Žilíšče svojé živýj v výšnich, k čelovíkom sošéd, osvjatí Christé, i nepokolebímo javí: jedína bo po roždeství ďívstva sokróvišče, ziždíteľa róždši prebylá jesí."),
)
),
"P3": (
"1": (
("", "", "Veselítsja o tebí cérkov tvojá Christé, zovúšči: tý mojá kríposť Hóspodi, i pribížišče, i utverždénije."),
("", "", "Drévo živótnoje, mýslennyj ístinnyj vinohrád, na kresťí vísit, vsím istočája netľínije."),
("", "", "Jáko velík, jáko strášen, jáko ádovo nizlóž šatánije, i jáko Bóh netľínen, nýňi plótski voskrése."),
("Bohoródičen", "", "Tý jedína súščym na zemlí, jáže páče jestestvá blahích chodátaica, Máti Bóžija bylá jesí: ťímže tí, rádujsja, prinósim."),
),
"2": (
("", "", "Tvojá pisnoslóvcy Bohoródice, živýj i nezavístnyj istóčniče, lík sebí sovokúplšyja duchóvno utverdí, v božéstvenňij tvojéj slávi, vincév slávy spodóbi."),
("", "", "Jádom ispólnennyj mňí zmíj zúby vonzé, Spáse, jáže vsederžíteľu Vladýko, hvozďmí rúk tvojích sokrušíl jesí: jáko ňísť svját vo svjatých, páče tebé čelovikoľúbče."),
("", "", "Víďin býl jesí čelovikoľúbče vóleju vo hróbi mértv, životvórče, i vratá razvérhl jesí ádova, jáže ot vikóv dušám: jáko ňísť svját vo svjatých rázvi tebé čelovikoľúbče."),
("Bohoródičen", "", "Neorána brazdá javílasja jesí, klás živótnyj róždši, vsím pričaščájuščymsja bezsmértiju chodátaja, vo svjatých svjatáho svjáto počivájuščaho."),
),
"3": (
("", "", "S vysotý snizšél jesí vóleju na zémľu, prevýše vsjákaho načála, i smirénnoje voznésl jesí iz áda preispódňaho jestestvó čelovíčeskoje: ňísť bo svját páče tebé, čelovikoľúbče."),
("", "", "Očiščájetsja čelovíkov suščestvó, tobóju prisovokúpľšejesja nesterpímomu božéstvennomu ohňú: jáko sokrovénnyj, prečístaja Ďívo, v tebí chľíb ispékšejesja, íže i tebé nevreždénnu sochránšemu."),
("", "", "Kája sijá jáže voístinnu blíz Bóha? Jáko prevozšédši vsjá ánheľskija číny, jedína dobrótoju ďívstva, jáko Máti sijájušči vsederžíteľa."),
)
),
"P4": (
"1": (
("", "", "Vozneséna ťá víďivši cérkov na kresťí, sólnce právednoje, stá v číňi svojém, dostójno vzyvájušči: sláva síľi tvojéj Hóspodi."),
("", "", "Vozšél jesí, strásti mojá isciľája, na krest strástiju prečístyja plóti tvojejá, v ňúže vóleju obléklsja jesí. Ťímže tí vzyvájem: sláva síľi tvojéj Hóspodi."),
("", "", "Bezhríšnaho smérť vkusívši, životvorjáščaho ťíla tvojehó, dostójno Vladýko umertvísja: mý že vopijém tí, sláva síľi tvojéj Hóspodi."),
("Bohoródičen", "", "Neiskusobráčno rodilá jesí Ďívo, i po roždeství javílasja jesí ďívstvujušči páki: ťímže nemólčnymi hlásy, jéže rádujsja tebí Vladýčice, víroju nesumňínnoju vzyvájem."),
),
"2": (
("", "", "Neizsľídnyj Bóžij sovít, jéže ot Ďívy voploščénija, tebé výšňaho, prorók Avvakúm usmotrjája zovjáše: sláva síľi tvojéj Hóspodi."),
("", "", "Vzakónen sýj Izráiľ, tebé Christé vzakóňivšaho Bóha ne pozná: no jáko bezzakónnika, zakonoprestupája, na kresťí prihvozdí, íže zakonopoložéniju nedostójnyj."),
("", "", "Obožéna tvojá Spáse dúša, ádova sokróvišča pľinívši, jáže ot víka sovoskresí dúšy: živonósnoje že ťílo vsím netľínije istočí."),
("Bohoródičen", "", "Tebé prisnoďívu i ístinnuju Bohoródicu vsí slávim, júže proobrazováše bohovídcu Moiséju neopáľno prečístaja, kupiná, ohňú primisívšisja."),
),
"3": (
("", "", "Siďáj v slávi na prestóľi božestvá, vo óblaci léhci priíde Iisús prebožéstvennyj, netľínnoju dlániju, i spasé zovúščyja: sláva Christé síľi tvojéj."),
("", "", "Poživé s čelovíki, vídim býv nevídimyj, vo zráci sýj nepostižímaho Božestvá, i voobrážsja iz tebé otrokovíce v čuždéje, viduščich ťá čístuju Bohomáter spasájet."),
("", "", "Priját v veščéstvenňi Ďíva neveščéstvennaho, v pričástiji veščestvá, mladénca ot nejá bývša. Ťímže vo dvú suščestvú, jedín poznavájetsja plotonósec Bóh, i čelovík presúščestvennyj."),
("", "", "Po roždeství ťa Ďívu, íže v Ďívu ťá vselísja, i róžďsja bez símene, Slóvo i Bóh prebýsť, i v roždeství Ďívu sochraní, jáko Vladýka i ziždíteľ vsejá tvári."),
)
),
"P5": (
"1": (
("", "", "Tý Hóspodi mój, svít v mír prišél jesí, svít svjatýj, obraščájaj iz mráčna nevíďinija víroju vospivájuščyja ťá."),
("", "", "Tý Hóspodi, k zemlí mílostivno sošél jesí: tý voznésl jesí pádšeje čelovíčeskoje suščestvó, na drévi vozdvizájem."),
("", "", "Tý vzjál mí jesí Christé, prehrišénij osuždénije: tý razrušíl jesí boľízni smértnyja ščédre, božéstvennym voskrésénijem tvojím."),
("Bohoródičen", "", "Ťá orúžije nepobidímoje na vrahí predlahájem, ťá utverždénije, i nadéždu nášeho spasénija Bohonevísto sťažáchom."),
),
"2": (
("", "", "Užasóšasja vsjáčeskaja o božéstvenňij slávi tvojéj: tý bo neiskusobráčnaja Ďívo, imíla jesí vo utróbi nad vsími Bóha, i rodilá jesí bezľítnaho Sýna, vsím vospivájuščym ťá mír podavájuščaja."),
("", "", "Priját ťá vsehó ustý ád bezúmnyj: na kresťí bo prihvoždéna ťá víďiv, kopijém probodéna, bezdychánna, živáho Bóha, prósta vmiňáše čelovíka. Razumí že iskusívyj kríposť tvojehó Božestvá."),
("", "", "Razrušényj, čelovikoľúbče, chrám tvojehó ťilesé, hrób razďilívyj i ád nevóleju óba sudá isťazújemi súť óv úbo svjatých tvojích dúšy, ťilesá že druhíj sootsylájušče, bezsmértne."),
("Bohoródičen", "", "Sé nýňi ispólnisja proróčeskoje prorečénije: tý bo neiskusobráčnaja Ďívo, imíla jesí vo utróbi nad vsémi Bóha i rodilá jesí bezľítnaho Sýna, vsím vospivájuščym ťá, mír podavájušča."),
),
"3": (
("", "", "Nýňi vostánu, proróčeski rečé Bóh, nýňi proslávľusja, nýňi voznesúsja, pádšaho prijém ot Ďívy, i k svítu úmnomu voznosjáj mojehó Božestvá."),
("", "", "Dóm ťá slávy, hóru Bóžiju svjatúju čístaja, nevístu, čertóh, chrám osvjaščénija, Sýn Bóžij, v ťá vselívsja, i ráj sládosti prisnosúščnyja nám soďíla."),
("", "", "Plóť ot króve ďívstvennyja prijál jesí Christé, bezsímennu, prečístu, ipostásnu, i slovésnu i úmnu, oduševlénnu, ďíjstvennu, choťíteľnu, samovladýčnu i samovlástnu."),
("", "", "Mučítelej rázum ďívstvennoje posramí črévo: mladénec bo jázvu áspidnuju dušehúbnuju ispytá rukóju, i otstúpnika hórdaho nizlóž, vírnych pod nózi pokorí."),
)
),
"P6": (
"1": (
("", "", "Požrú ti so hlásom chvalénija Hóspodi, cérkov vopijét tí, ot bisóvskija króve očíščšisja, rádi mílosti ot rébr tvojích istékšeju króviju."),
("", "", "Vozšél jesí na krest, síloju prepojásavsja, i soplétsja s mučítelem jáko Bóh, s vysotý svérhl jesí, Adáma že nepobidímoju síloju voskrésíl jesí."),
("", "", "Voskrésl jesí blistájajsja krásnyj iz hróba Christé, i razhnál jesí vsjá vrahí božéstvennoju síloju tvojéju, i vsjá jáko Bóh, vesélija ispólnil jesí."),
("Bohoródičen", "", "O čúdo vsích čudés novíjšeje! Jáko Ďíva vo utróbi, vsjáčeskaja obderžáščaho neiskusomúžno začénši, ne ťisnovmistí."),
),
"2": (
("", "", "Prijdóch vo hlubiný morskíja, i potopíla mjá jésť búrja mnóhich hrichóv: no jáko Bóh iz hlubiný vozvedí živót mój, mnohomílostive."),
("", "", "Otvérze hortáň svój ád, i požré mja, i dúšu razširí bezúmnyj: no Christós sošéd, vozvedé žízň mojú, jáko čelovikoľúbec."),
("", "", "Pohíbe smértiju smérť, uméryj bo voskrése, netľínije mňí dáruja: jávľsja že ženám proviščá rádosť bezsmértnyj."),
("Bohoródičen", "", "Nesterpímaho Božestvá vmistílišče čístoje utróba tvojá javísja, o Bohoródice! Jéže bez strácha nebésniji čínove vozzríti ne vozmohóša."),
),
"3": (
("", "", "Prijdóch vo hlubiný morskíja, i potopíla mjá jésť búrja mnóhich hrichóv: no jáko Bóh iz hlubiný vozvedí živót mój, mnohomílostive."),
("", "", "Drévle úbo preľstí mja zmíj, i umorí mja, pramáteriju mojéju Jévoju: nýňi že čístaja, tobóju sozdávyj mjá iz istľínija vozzvá."),
("", "", "Bézdna ťá bézdnu neizrečénno blahoutróbija otrokovíce, izbránnuju pokazá čudés: íbo iz tebé mólnijeju Božestvá, bíser Christós vozsijá."),
)
),
"K": (
("", "Javílsja jesí dnés", "Spás i izbáviteľ mój, iz hróba jáko Bóh voskresí ot úz zemnoródnyja, i vratá ádova sokruší, i jáko Vladýka voskrése tridnéven."),
("", "", "Voskrésšaho iz mértvych, Christá žiznodávca tridnévna iz hróba, i vratá smértnaja dnés sokrúššaho síloju svojéju, i áda umertvívšaho, i žálo smértnoje stéršaho, i Adáma so Jévoju svobodívšaho, vospojím vsí zemnoródniji, vopijúšče chvalú priľížno: tój bo jáko jedín krípkij, Bóh i Vladýka, voskrése tridnéven."),
),
"P7": (
"1": (
("", "", "V peščí avraámstiji ótrocy persídsťij ľubóviju blahočéstija páče, néželi plámenem opaľájemi vzyváchu: blahoslovén jesí v chrámi slávy tvojejá Hóspodi."),
("", "", "K netľíniju čelovíčestvo prizvásja, božéstvennoju izmovéno króviju Christóvoju, blahodárno vospivájuščeje: blahoslovén jesí v chrámi slávy tvojejá Hóspodi."),
("", "", "Jáko živonósec, jáko rajá krasňijšij voístinnu, i čertóha vsjákaho cárskaho pokazásja svetľíjšij Christé, hrób tvój, istóčnik nášeho voskresénija."),
("Bohoródičen", "", "Výšňaho osvjaščénnoje božéstvennoje selénije rádujsja, tobóju bo dadésja rádosť Bohoródice, zovúščym: blahoslovéna tý v ženách jesí vseneporóčnaja Vladýčice."),
),
"2": (
("", "", "Ne poslužíša tvári bohomúdriji páče sozdávšaho, no óhnennoje preščénije múžeski poprávše, rádovachusja pojúšče: prepítyj otcév Hospóď i Bóh blahoslovén jesí."),
("", "", "Smiríl jesí na drévo vozdvizájem, óko vysókoje, i prevoznesénnuju bróv na zémľu nizložíl jesí, spasýj čelovíka: prepítyj otcév Hospóď i Bóh blahoslovén jesí."),
("", "", "Síloju tvojéju róh náš vozvýsi služáščich tí, voskresýj iz mértvych, i ádovo istoščívyj préžde mnohočelovíčnoje bohátstvo, Vladýko: prepítyj otcév Hospóď i Bóh blahoslovén jesí."),
("Tróičen", "", "Rečénijem božéstvennym posľídujušče, slávim jedíno Božestvó, jáko v trijéch svíťich neslijánno, nepresikómo, plámeň víčnyj prosviščájuščij vsjú tvár, zovúščuju: Bóže blahoslovén jesí."),
),
"3": (
("", "", "Júnoši trí vo Vavilóňi, veľínije mučítelevo na bújstvo prelóžše, posreďí plámene vopijáchu: blahoslovén jesí Hóspodi Bóže otéc nášich."),
("", "", "Privlačít mjá k píniju ľubóv ďívstvennaja, óhň íže v sérdci, vopíti Máteri i Ďívi: blahoslovénnaja, Hospóď sílam s tobóju."),
("", "", "Prevýšši tvári javílasja jesí, jáko tvorcá róždši i Hóspoda. Ťímže tí vopijú Bohoródice: blahoslovénnaja, Hospóď sílam s tobóju."),
("Tróičen", "", "Hospóďstvo ťá jedíno čtýj, v trijéch svjaščénijich nerazďíľno, vospiváju trijipostásnoje jestestvó, blahoslovénnaja, vzyvája tebí, jáže vsjá upravľájuščaja."),
)
),
"P8": (
"1": (
("", "", "Rúci rasprostér Danijíl, ľvóv zijánija v róvi zatčé: óhnennuju že sílu uhasíša, dobroďíteliju prepojásavšesja, blahočéstija račíteli ótrocy, vzyvájušče: blahoslovíte vsjá ďilá Hospódňa Hóspoda."),
("", "", "Rúci rasprostér na kresťí, jazýki vsjá sobrál jesí, i jedínu javíl jesí Vladýko cérkov vospivájuščuju ťá, zemnúju i nebésnuju, sohlásno pojúščym: blahoslovíte vsjá ďilá Hospódňa Hóspoda, pójte i prevoznosíte jehó vo víki."),
("", "", "Biloobrázen javísja ženám, nepristúpnym svítom voskresénija blistájajsja ánhel, čtó živáho vo hróbi, vopijá, íščete jáko mértva? Voístinnu vostá Christós, jemúže vopijém: vsjá ďilá pójte Hóspoda, i prevoznosíte vo vsjá víki."),
("Bohoródičen", "", "Tý jedína vo vsích róďich Ďívo prečístaja, Máti javílasja jesí Bóžija: tý Božestvá bylá jesí žilíšče vseneporóčnaja, ne opáľšisja ohném nepristúpnaho svíta. Ťímže vsí ťa blahoslovím, Maríje Bohonevísto."),
),
"2": (
("", "", "Ótroki blahočestívyja v peščí, roždestvó Bohoródičo spasló jésť: tohdá úbo obrazújemoje, nýňi že ďíjstvujemoje, vselénnuju vsjú vozdvizájet píti tebí: Hóspoda pójte ďilá, i prevoznosíte jehó vo vsjá víki."),
("", "", "Neprávednoje víďašči zakolénije tvojé tvár, omračájuščisja rydáše: zemlí bo smuščájuščejsja, vo mrák jáko v rízu čérnu sólnce oblečésja: mý že ťá neprestánno pojém, i prevoznósim Christé, vo víki."),
("", "", "Sšédyj ko mňí dáže do áda, i vsím putesotvorívyj voskresénije, páki vozšél jesí, vzém mjá na rámu tvojéju, i Otcú privél jesí. Ťímže zovú ti: Hóspoda pójte ďilá, i prevoznosíte vo vsjá víki."),
("Tróičen", "", "Umá pérvaho i vinóvnaho vsích, Otcá jedínaho bezvinóvnaho slávim, Slóva že beznačálnaho, i Dúcha Uťíšiteľa, jedínaho Bóha vsích, Tróici sráslenňij poklaňájuščesja, i prevoznosjášče vo vsjá víki."),
),
"3": (
("", "", "Izbáviteľu vsích vsesíľne, posreďí plámene blahočéstvovavšyja, snizšéd orosíl jesí, i naučíl jesí píti: vsjá ďilá blahoslovíte , pójte Hóspoda."),
("", "", "Ot rebrá Adámova sozdávyj ťá, ot tvojehó ďívstva voplotísja, íže vsích Hospóď, jehóže pojúšče, vopijém: vsjá ďilá blahoslovíte , pójte Hóspoda, i prevoznosíte jehó vo víki."),
("", "", "V síni Avraám uzrí, jéže v tebí Bohoródice, táinstvo, Sýna bo tvojehó bezplótnaho priját, pojá: vsjá ďilá blahoslovíte , pójte Hóspoda, i prevoznosíte jehó vo víki."),
("", "", "Ravnočíslennyja Tróicy spasló jésť tvojehó ďívstva proobražénije: v ďívstvennych bo ťilesích popiráchu plámeň otrokovíce, vopijúšče: blahoslovíte , pójte Hóspoda, i prevoznosíte jehó vo víki."),
)
),
"P9": (
"1": (
("", "", "Kámeň nerukosíčnyj, ot nesikómyja horý tebé Ďívo kraeuhóľnyj otsečésja, Christós, sovokupívyj razstojáščajasja jestestvá. Ťím veseľáščesja ťá Bohoródice veličájem."),
("", "", "Vsehó mja vosprijál jesí vés v sovokupléniji neslítno, vsemú mi dajá Bóže mój, spasénije strástiju tvojéju, júže na kresťí preterpíl jesí telésňi, blahoutróbija rádi mnóhaho."),
("", "", "Tvojí učenicý zrjášče otvérzen hrób tvój, i Bohonósnyja plaščanícy ispražnény voskresénijem tvojím, so ánhelom hlahólachu: voístinnu vostá Hospóď."),
("Tróičen", "", "Jedínici úbo božéstvennaho suščestvá, no ipostásmi Tróici, vsí vírniji poklaňájuščesja, v neslijánnych ipostásich ravnosíľnuju jedinočéstnuju nýňi blahočtúšče veličájem."),
),
"2": (
("", "", "Vsják zemnoródnyj da vzyhrájetsja dúchom prosviščájem, da toržestvújet že bezplótnych umóv jestestvó, počitájuščeje svjaščénnoje toržestvó Bohomátere, i da vopijét: rádujsja vseblažénnaja Bohoródice, čístaja prisnoďívo."),
("", "", "Ľstívno popólz zmíj, iz Jedéma poját mjá pľinéna: na kránijevem že tvérďim kámeni razbí sehó vsederžítel Hospóď, jákože mladénca: i sládosti páki mňí vchód drévom kréstnym otvérze."),
("", "", "Položíl jesí krípkija vrážija tverdýni nýňi v zapusťínije: vsesílňijšeju že rukóju bohátstvo jehó raschítil jesí iz istoščánij ádovych sovoskresívyj mjá Christé, i drévle bezmírno chváľaščahosja jáko smích ruhájema javíl jesí."),
("", "", "Prijidí, níščich ľudéj tvojích ozloblénije posiščája, mílostivnoju že i deržávnoju tvojéju rukóju ukripí krestonósnyja ľúdi, tvojé izrjádnoje dostojánije, Christé, jáko čelovikoľúbec."),
),
"3": (
("", "", "Sokrovénnoje Bóžije neizrečénnoje v tebí soveršájetsja, jávstvennoje tájinstvo, Ďívo prečístaja: íbo Bóh iz tebé voplotísja za milosérdije. ťímže ťá jáko Bohoródicu veličájem."),
("", "", "Zrím jáko krín ťá rízoju obahrénoju ukrášenu, prečístaja, božéstvennaho Dúcha, posreďí térnija sijájušču, i blahouchánija ispolňájušču, íže tebé ískrenno veličájuščich."),
("", "", "Tľínnoje prijím čelovíčeskoje jestestvó iz tvojehó, vseneporóčnaja, čréva netľínnyj. V sebí pokazá netľínno, za blahoutróbije: ťímže ťá jáko Bohoródicu veličájem."),
("", "", "Jáže vsími Vladýčestvujušči tvármi, ľúdem tvojím dáruj pobídnoje odoľínije, vrahá polahájušči primiríteľna cérkvi: da ťá jáko Bohoródicu veličájem."),
)
),
),
"CH": (
("", "", "Krest preterpévyj i smérť, i voskrésýj iz mértvych vsesíľne Hóspodi, slávim tvojé voskresénije."),
("", "", "Krestóm tvojím Christé, ot drévnija kľátvy svobodíl jesí nás, i smértiju tvojéju jestestvó náše múčaščaho dijávola uprazdníl jesí: vostánijem že tvojím rádosti vsjá ispólnil jesí. Ťímže vopijém tí: voskrésýj iz mértvych Hóspodi, sláva tebí."),
("", "", "Tvojím krestóm Christé Spasé, nastávi nás na ístinu tvojú, i izbávi nás ot sítej vrážijich, voskrésýj iz mértvych, vozstávi ný pádšyjasja hrichóm, prostér rúku tvojú čelovikoľúbče Hóspodi, molítvami svjatých tvojích."),
("", "", "Otéčeskich tvojích ňídr ne razlučívsja, jedinoródnyj <NAME>ij, prišél jesí na zémľu za čelovikoľúbije, čelovík býv neprelóžen, i krest i smérť preterpíl jesí plótiju, bezstrástnyj Božestvóm: voskrés že iz mértvych, bezsmértije pódal jesí ródu čelovíčeskomu, jáko jedín vsesílen."),
("", "", "Smérť prijál jesí plótiju, nám bezsmértije chodátajstvuja Spáse, i vo hrób vselílsja jesí, da nás ot áda svobodíši, voskrésív s sobóju: postradá úbo jáko čelovík, no voskrés jáko Bóh. Sehó rádi vopijém: sláva tebí žiznodávče Hóspodi, jedíne čelovikoľúbče."),
("", "", "Kámenije raspadášesja Spáse, jehdá na lóbňim krest tvój vodruzísja, ustrašíšasja ádovy vrátnicy, jehdá vo hróbi jáko mértv položén býl jesí: íbo smértnuju uprazdnívyj kríposť, uméršym vsím netľínije pódal jesí voskresénijem tvojím Spáse, žiznodávče Hóspodi, sláva tebí."),
("", "", "Vozžeľíša žený víďíti tvojé voskresénije, Christé Bóže, priíde predvárši <NAME>, obríte kámeň otvalén ot hróba, i ánhela siďášča, i hlahóľušča: čtó íščete živáho s mértvymi: voskrése jáko Bóh, da spasét vsjáčeskaja."),
("", "", "Hďí jésť Iisús, jehóže vminíste streščí, rcýte iudéi? Hďí jésť, jehóže položíste vo hróbi, kámeň zapečatľívše? Dadíte mértva, íže životá otvérhšijisja: Dadíte pohrebénnaho, ilí vírujte voskrésšemu. Ášče i vý umolčité Hospódne vostánije, kámenije vozopijét, páče že otvalénnyj ot hróba. Velíkaja tvojá mílosť, vélije tájinstvo smotrénija tvojehó Spáse náš, sláva tebí."),
)
)
#let L = (
"B": (
("", "", "Drévom Adám rajá býsť izselén: drévom že kréstnym razbójnik v ráj vselísja. Óv úbo vkúš, zápoviď otvérže sotvóršaho: óv že sraspinájem, Bóha ispovída tajáščahosja, pomjaní mja, vopijá, vo cárstviji tvojém."),
("", "", "Voznesýjsja na krest, smértnuju razrušívyj sílu, i zahládivyj jáko Bóh jéže na ný rukopisánije Hóspodi, razbójniče pokajánije i nám podážď jedíne čelovikoľúbče, víroju služáščym, Christé Bóže náš, i vopijúščym tí: pomjaní i nás vo cárstviji tvojém."),
("", "", "Rukopisánije náše na kresťí kopijém razdrál jesí, i vminívsja v mértvych, támošňaho mučíteľa svjazál jesí, izbávivyj vsích ot úz ádovych voskresénijem tvojím, ímže prosvitíchomsja čelovikoľúbče Hóspodi, i vopijém tí: pomjaní i nás vo cárstviji tvojém."),
("", "", "Raspnýjsja i voskrésýj jáko sílen iz hróba tridnéven, i pervozdánnaho Adáma voskresívyj jedíne bezsmértne: i mené na pokajánije obratítisja Hóspodi, spodóbi ot vsehó sérdca mojehó, i téploju víroju prísno vzyváti tí: pomjaní mja Spáse vo cárstviji tvojém."),
("", "", "Nás rádi íže bezstrásten strástnyj býsť čelovík, i vóleju na kresťí prihvoždéjsja, nás sovoskresí, ťímže i slávim so krestóm strásť i voskresénije, ímiže vozsozdáchomsja, ímiže i spasájemsja, vzyvájušče: pomjaní i nás vo cárstviji tvojém."),
("", "", "Voskrésšaho iz mértvych, i ádovu deržávu pľinívšaho, i vídima ženámi mironósicami, rádujtesja, hlahóľuščaho, vírniji umólim, ot istľínija izbáviti dúšy náša, zovúšče vsehdá razbójnika blahorazúmnaho hlásom k nemú: pomjaní i nás vo cárstviji tvojém."),
("Tróičen", "", "Otcá, i Sýna, i svjatáho Dúcha, vsí jedinomúdrenno vírniji slavoslóviti dostójno pomólimsja: jedínstvo Božestvá, v trijéch súščeje ipostásich, neslijánno prebyvájuščeje, prósto, nerazďílno i nepristúpno, ímže izbavľájemsja óhnennaho mučénija."),
("Bohoródičen", "", "Máter tvojú Christé, plótiju bez símene róždšuju ťá, i Ďívu voístinnu, i po roždeství prebývšu netľínnu, sijú tí privódim v molítvu, Vladýko mnohomílostive, prehrišénij proščénije dáruj, vsehdá vopijúščym tí: pomjaní i nás vo cárstviji tvojém."),
),
"TKB": (
("", "", "Svítluju voskrésnija própoviď ot ánhela uvíďivša Hospódni učenícy, i práďidneje osuždénije otvérhša, apóstolom chváľaščjasja hlahólachu: isprovéržesja smérť, voskrése Christós Bóh, dárujaj mírovi véliju mílosť."),
("", "Javílsja jesí dnés", "Spás i izbáviteľ mój, iz hróba jáko Bóh voskresí ot úz zemnoródnyja, i vratá ádova sokruší, i jáko Vladýka voskrése tridnéven."),
("Bohoródičen", "", "Jéže ot víka utajénoje, i ánhelom nesvídomoje tájinstvo: tobóju Bohoródice súščym na zemlí javísja Bóh, v neslítnom sojedinéniji voploščájem, i krest vóleju nás rádi vosprijím, ímže voskresív pervozdánnaho, spasé ot smérti dúšy náša."),
),
"P": (
("", "", "Jáko vozvelíčišasja ďilá tvojá Hóspodi, vsjá premúdrostiju sotvoríl jesí."),
("", "", "Blahosloví dušé mojá Hóspoda, Hóspodi Bóže mój, vozvelíčilsja jesí ziló."),
("", "", "Naľacý, i uspiváj, i cárstvuj ístiny rádi, i krótosti, i právdy."),
("", "", "Vozľubíl jesí právdu, i voznenavíďil jesí bezzakónije."),
)
) |
|
https://github.com/typst-community/mantodea | https://raw.githubusercontent.com/typst-community/mantodea/main/src/component/title-page.typ | typst | MIT License | #import "/src/_pkg.typ"
#import "/src/_valid.typ"
#import "/src/theme.typ" as _theme
#let _version = version
/// Generate the default title page.
///
/// - title (str, content): The title for of this document.
/// - subtitle (str, content, none): A subtitle shown below the title.
/// - authors (str, content, array): The authors of the document.
/// - urls (str, array, none): One or more URLs relevant to this document.
/// - version (str, version): The version of this document. A string can be
/// passed explicitly to avoid the automatic `v` prefix.
/// - date (datetime): The date at which this document was created.
/// - abstract (str, content, none): An abstract outlining the purpose and
/// contents of this document.
/// - license (str, content, none): The license of this document or a related
/// piece of intellectual property.
/// - theme (theme): The color theme to use for the title page.
/// -> content
#let make-title-page(
title: [Title],
subtitle: [Subtitle],
authors: "<NAME> <<EMAIL>>",
urls: "https://github.com/typst-community/mantodea",
version: version(0, 1, 0),
date: datetime(year: 1970, month: 1, day: 1),
abstract: lorem(100),
license: "MIT",
theme: _theme.default,
_validate: true,
) = {
if _validate {
import _valid as z
_ = z.parse(title, z.content(), scope: ("title",))
_ = z.parse(subtitle, z.content(optional: true), scope: ("subtitle",))
_ = z.parse(abstract, z.content(optional: true), scope: ("abstract",))
_ = z.parse(license, z.content(optional: true), scope: ("license",))
_ = z.parse(theme, _theme.schema(), scope: ("theme",))
authors = z.parse(
authors,
z.array(z.string(), min: 1, pre-transform: z.coerce.array),
scope: ("authors",),
)
urls = z.parse(
urls,
z.array(
z.string(),
pre-transform: z.coerce.array,
post-transform: (self, it) => if it == (none,) { none } else { it },
optional: true,
),
scope: ("urls",),
)
_pkg.t4t.assert.any-type(_version, version)
} else {
authors = if type(authors) == str { (authors,) } else { authors }
urls = if type(urls) == str { (urls,) } else { urls }
}
pad(y: 10em, x: 5em, {
set align(center)
set block(spacing: 2em)
block({
set text(2.5em, theme.colors.primary)
title
})
if subtitle != none {
block(above: 1em, {
set text(size: 1.2em)
subtitle
})
}
let info = (
if version != none {
if type(version) == str { version } else [ v#version ]
},
if date != none { date.display() },
// TODO: license link
if license != none { license } else { "UNLICENSED" },
).filter(it => it != none)
if info.len() != 0 {
set text(size: 1.2em)
grid(columns: info.len(), gutter: 4em, ..info)
}
// TODO: author formatting
block(authors.join(linebreak()))
if urls != none {
block(urls.map(link).join(linebreak()))
}
if abstract != none {
set align(left)
set par(justify: true)
// show par: set block(spacing: 1.3em)
abstract
}
})
pagebreak(weak: true)
}
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-31C0.typ | typst | Apache License 2.0 | #let data = (
("CJK STROKE T", "So", 0),
("CJK STROKE WG", "So", 0),
("CJK STROKE XG", "So", 0),
("CJK STROKE BXG", "So", 0),
("CJK STROKE SW", "So", 0),
("CJK STROKE HZZ", "So", 0),
("CJK STROKE HZG", "So", 0),
("CJK STROKE HP", "So", 0),
("CJK STROKE HZWG", "So", 0),
("CJK STROKE SZWG", "So", 0),
("CJK STROKE HZT", "So", 0),
("CJK STROKE HZZP", "So", 0),
("CJK STROKE HPWG", "So", 0),
("CJK STROKE HZW", "So", 0),
("CJK STROKE HZZZ", "So", 0),
("CJK STROKE N", "So", 0),
("CJK STROKE H", "So", 0),
("CJK STROKE S", "So", 0),
("CJK STROKE P", "So", 0),
("CJK STROKE SP", "So", 0),
("CJK STROKE D", "So", 0),
("CJK STROKE HZ", "So", 0),
("CJK STROKE HG", "So", 0),
("CJK STROKE SZ", "So", 0),
("CJK STROKE SWZ", "So", 0),
("CJK STROKE ST", "So", 0),
("CJK STROKE SG", "So", 0),
("CJK STROKE PD", "So", 0),
("CJK STROKE PZ", "So", 0),
("CJK STROKE TN", "So", 0),
("CJK STROKE SZZ", "So", 0),
("CJK STROKE SWG", "So", 0),
("CJK STROKE HXWG", "So", 0),
("CJK STROKE HZZZG", "So", 0),
("CJK STROKE PG", "So", 0),
("CJK STROKE Q", "So", 0),
("CJK STROKE HXG", "So", 0),
("CJK STROKE SZP", "So", 0),
(),
(),
(),
(),
(),
(),
(),
(),
(),
("IDEOGRAPHIC DESCRIPTION CHARACTER SUBTRACTION", "So", 0),
)
|
https://github.com/protohaven/printed_materials | https://raw.githubusercontent.com/protohaven/printed_materials/main/meta-environments/env-templates.typ | typst |
#import "@preview/hydra:0.5.1": hydra, anchor
#import "/meta-environments/env-features.typ": *
#import "/meta-environments/env-branding.typ": *
/*
* TEXT STYLES
*
* Renders `content` with the module's text styling. This is useful for content
* that is outside of the `template` container but which should be visually consistent.
*/
#let apply-text-styles(content) = {
set text(
font: font.sans
)
set par(
leading: 0.8em,
)
show heading.where(level: 1): it => [
#pagebreak(weak: true)
#set text(size: 24pt, font: font.sans, number-type: "lining", weight: "bold",)
#block(it.body)
]
show heading.where(level: 2): it => text(
size: 18pt,
font: font.sans,
number-type: "lining",
weight: "semibold",
{
v(0.6em)
it.body
}
)
show heading.where(level: 3): it => text(
size: 14pt,
font: font.sans,
number-type: "lining",
weight: "semibold",
it.body
)
show heading.where(level: 4): it => text(
size: 12pt,
font: font.sans,
number-type: "lining",
weight: "semibold",
it.body
)
show figure: it => align(center)[
#set text(size: 9pt, font: font.sans)
#it.body
/*#it.supplement*/ #it.caption
]
// Link support
show link: it => {
if type(it.dest) == str and it.dest.contains("http"){
set text(font: font.link, size: 9pt)
it
} else if type(it.dest) != str {
set text(color.link)
it
} else {
set text(color.link)
it
}
}
// Reference support
show ref: it => {
if it.element.numbering == none {
// Use your custom scheme
link(it.target, it.element.body)
} else {
// Default `ref`
it
}
}
// Enums
set enum(numbering: "1.a.")
content
}
/*
* Templates
*
* Templates for various documents
*/
#let class_handout(
title: "Handout",
category: "CAT",
number: "NUM",
clearances: ("Oobler", "Spanger"),
instructors: ("Someone",),
authors: ("Someone","Someone Else"),
date: datetime.today(),
draft: false,
wrapper: apply-text-styles,
doc,
) = {
set page(
background: if draft {rotate(-44deg,
{text(160pt, fill: rgb("EEEEEE"), [*DRAFT*])
linebreak()
text(60pt, fill: rgb("EEEEEE"), date.display())}
)})
set document(title: title,
author: authors,
keywords: ("protohaven", "class"),
date: date,
)
// Title page
set text(
font: font.sans,
)
align(center, image("/common-graphics/branding/logo-protohaven-color.svg"))
v(1in)
stack(dir: ttb,
text(weight: "bold", size: 20pt, color.midgrey, smallcaps("Class Notes")),
v(1.2em),
text(weight: "bold", size: 24pt, [#category #number: #title]),
// v(3em),
// if instructors.len() == 1 {
// text(weight: "bold", size: 18pt, mid_grey, smallcaps("Instructor"))
// } else {
// text(weight: "bold", size: 18pt, mid_grey, smallcaps("Instructors"))
// },
// v(1.1em),
// text(weight: "bold", size: 20pt, instructors.join(", ")),
v(15em),
// Clearances
text(weight: "bold", size: 18pt, color.midgrey, smallcaps("Clearances")),
v(1em),
text(size: 14pt, clearances.sorted().join(linebreak())),
)
v(1fr)
license_block()
pagebreak()
// Table of Contents Page(s)
set page( numbering: "i",)
counter(page).update(1)
show outline.entry.where(
level: 1
): it => {
v(12pt, weak: true)
strong(it)
}
outline(depth: 2)
pagebreak()
// The rest of the content
set page(
margin: (top: 1in, left: 1in, bottom: 1in, right: 1in),
numbering: "1",
// header: anchor(),
header: context { [
#let footer_section = hydra(skip-starting: false, 1)
#let footer_subsection = hydra(skip-starting: false, 2)
#set text(9pt, style: "italic")
#h(1fr)
#title
#if (footer_section != none) [ \/ #footer_section]
#if (footer_subsection != none) [ \/ #footer_subsection]
] },
footer: [
#set text(9pt, style: "italic")
#h(1fr) Page
#counter(page).display(
"1 of 1",
both: true,
)
]
)
counter(page).update(1)
wrapper(doc)
}
#let guide_document(
title: "Guide Document",
authors: ("Someone","Someone Else"),
date: datetime.today(),
draft: false,
wrapper: apply-text-styles,
doc,
) = {
set page(
background: if draft {rotate(-44deg,
{text(160pt, fill: rgb("EEEEEE"), [*DRAFT*])
linebreak()
text(60pt, fill: rgb("EEEEEE"), date.display())}
)})
set document(title: title,
author: authors,
keywords: ("protohaven", "guide"),
date: date,
)
set text(
font: font.sans,
)
// Title page
align(center, image("/common-graphics/branding/Protohaven-Logo-Horizontal-Color.png"))
v(1in)
stack(dir: ttb,
text(weight: "bold", size: 32pt, title),
v(2em),
text(size: 24pt, date.display())
)
v(1fr)
license_block()
pagebreak()
// Table of Contents Page(s)
set page( numbering: "i",)
counter(page).update(1)
show outline.entry.where(
level: 1
): it => {
v(12pt, weak: true)
strong(it)
}
outline(depth: 2)
pagebreak()
// The rest of the content
set page(
margin: (top: 1in, left: 1in, bottom: 1in, right: 1in),
numbering: "1",
// header: anchor(),
header: context { [
#let footer_section = hydra(skip-starting: false, 1)
#let footer_subsection = hydra(skip-starting: false, 2)
#set text(9pt, style: "italic")
#h(1fr)
#title
#if (footer_section != none) [ \/ #footer_section]
#if (footer_subsection != none) [ \/ #footer_subsection]
] },
footer: [
#set text(9pt, style: "italic")
#h(1fr) Page
#counter(page).display(
"1 of 1",
both: true,
)
]
)
counter(page).update(1)
wrapper(doc)
}
#let policy_document(
title: "Policy Document",
authors: ("Someone","Someone Else"),
date: datetime.today(),
draft: false,
wrapper: apply-text-styles,
doc,
) = {
set page(
background: if draft {rotate(-44deg,
{text(160pt, fill: rgb("EEEEEE"), [*DRAFT*])
linebreak()
text(60pt, fill: rgb("EEEEEE"), date.display())}
)})
set document(title: title,
author: authors,
keywords: ("protohaven", "policy"),
date: date,
)
show outline.entry.where(
level: 1
): it => {
v(12pt, weak: true)
strong(it)
}
// Title page
set text(
font: font.sans,
)
align(center, image("/common-graphics/branding/Protohaven-Logo-Horizontal-Color.png"))
v(1in)
stack(dir: ttb,
// text(weight: "bold", size: 18pt, mid_grey, smallcaps("Policy Document")),
// v(1.2em),
text(weight: "bold", size: 36pt, [#title]),
v(3em),
text(weight: "bold", size: 14pt, [Adoption Date: #date.display("[month repr:long] [day padding:none], [year]")]),
v(15em),
outline(depth: 2)
)
v(1fr)
rect(width: 100%, inset: 2em, align(center, "License Information"))
pagebreak()
// The rest of the content
set page(
margin: (top: 1in, left: 1in, bottom: 1in, right: 1in),
numbering: "1",
footer: [
#set text(9pt, style: "italic")
#h(1fr)
Protohaven Policy Document — #title —
#counter(page).display(
"1 of 1",
both: true,
)
],
)
counter(page).update(1)
wrapper(doc)
}
#let tool_single(
title: "Tool Name",
authors: ("Someone","Someone Else"),
date: datetime.today(),
draft: true,
inclusion: false,
wrapper: apply-text-styles,
doc,
) = {
set page(
background: if draft {rotate(-44deg,
{text(160pt, fill: rgb("EEEEEE"), [*DRAFT*])
linebreak()
text(60pt, fill: rgb("EEEEEE"), date.display())}
)})
set document(title: title,
author: authors,
keywords: ("protohaven", "tool"),
date: date,
)
set text(
font: font.sans,
)
// Title page
align(center, image("/common-graphics/branding/Protohaven-Logo-Horizontal-Color.png"))
v(1in)
stack(dir: ttb,
text(weight: "bold", size: 32pt, title),
v(2em),
text(size: 24pt, date.display())
)
v(1fr)
show outline.entry.where(
level: 1
): it => {
v(12pt, weak: true)
strong(it)
}
outline(depth: 2)
license_block()
pagebreak()
// The rest of the content
set page(
margin: (top: 1in, left: 1in, bottom: 1in, right: 1in),
numbering: "1",
// header: anchor(),
header: context { [
#let footer_section = hydra(skip-starting: false, 1)
#let footer_subsection = hydra(skip-starting: false, 2)
#set text(9pt, style: "italic")
#h(1fr)
#title
#if (footer_section != none) [ \/ #footer_section]
#if (footer_subsection != none) [ \/ #footer_subsection]
] },
footer: [
#set text(9pt, style: "italic")
#h(1fr) Page
#counter(page).display(
"1 of 1",
both: true,
)
]
)
counter(page).update(1)
wrapper(doc)
}
#let tools_all(
title: "Tool Reference",
authors: ("Someone","Someone Else"),
date: datetime.today(),
draft: false,
wrapper: apply-text-styles,
doc,
) = {
set page(
background: if draft {rotate(-44deg,
{text(160pt, fill: rgb("EEEEEE"), [*DRAFT*])
linebreak()
text(60pt, fill: rgb("EEEEEE"), date.display())}
)})
set document(title: title,
author: authors,
keywords: ("protohaven", "policy"),
date: date,
)
show outline.entry.where(
level: 1
): it => {
v(12pt, weak: true)
strong(it)
}
// Title page
set text(
font: font.sans,
)
align(center, image("/common-graphics/branding/Protohaven-Logo-Horizontal-Color.png"))
v(1in)
stack(dir: ttb,
// text(weight: "bold", size: 18pt, mid_grey, smallcaps("Policy Document")),
// v(1.2em),
text(weight: "bold", size: 36pt, [#title]),
v(3em),
text(weight: "bold", size: 14pt, [Adoption Date: #date.display("[month repr:long] [day padding:none], [year]")]),
v(15em),
outline(depth: 2)
)
v(1fr)
rect(width: 100%, inset: 2em, align(center, "License Information"))
pagebreak()
// The rest of the content
set page(
margin: (top: 1in, left: 1in, bottom: 1in, right: 1in),
numbering: "1",
footer: [
#set text(9pt, style: "italic")
#h(1fr)
Protohaven Policy Document — #title —
#counter(page).display(
"1 of 1",
both: true,
)
],
)
counter(page).update(1)
wrapper(doc)
}
|
|
https://github.com/quarto-ext/typst-templates | https://raw.githubusercontent.com/quarto-ext/typst-templates/main/dept-news/_extensions/dept-news/typst-show.typ | typst | Creative Commons Zero v1.0 Universal | #show: dept-news.with(
$if(title)$
title: "$title$",
$endif$
$if(edition)$
edition: [$edition$],
$endif$
$if(hero-image)$
hero-image: (
path: "$hero-image.path$",
caption: [$hero-image.caption$]
),
$endif$
$if(dedication)$
dedication: [$dedication$],
$endif$
$if(publication-info)$
publication-info: [$publication-info$],
$endif$
)
|
https://github.com/awsomearvinder/resume | https://raw.githubusercontent.com/awsomearvinder/resume/master/resume.typ | typst | #import "moderncv.typ": *
#show: project.with(
author: "<NAME>",
github: "awsomearvinder",
phone: "+01 651 367 9347",
email: "<EMAIL>",
website: "www.arvinderd.com"
)
#show link: underline
#show link: set text(blue)
= Description
#cvcol[
A Software Developer with a passion for Systems tooling,
operating systems, compilers, and security. Adept at diving
into how things work, and solving technical problems.
]
= Work Experience
#cventry(
start: (month: "October", year: 2021),
end: (month: "December", year: 2024),
role: [Student System Administrator],
place: "Winona State University",
)[
Managed Debian Linux servers using Ansible. Created an automated deployment
pipeline with proper secret handling for servers, using a self-hosted CI runner.
Created a REST API web service to create snapshots for servers prior to upgrades.
Hosted servers include: a monitoring service, a learning management service,
a CI runner, source forge, email relay, and more.
Automated TLS certificate rollout using DNS-01 ACME challenges, with azure DNS
and letsencrypt. No certificate expiration since rollout.
]
= Projects
#let project(name, url, body) = {
link(url)[#text(size: 12pt)[** #name **]]
body
}
#cvcol[
- #project("Code Forge", "https://github.com/awsomearvinder/code-forge")[
- A work in progress source code forge.
- Svelte frontend and Rust backend.
- Can view and read commit metadata, commit log.
- Can browse source of repos.
]
- #project("doas", "https://github.com/awsomearvinder/doas/")[
- Project to learn about how `sudo` worked.
- Clone of the popular doas project which originated in OpenBSD.
- Can parse entirety of official `doas` configuration syntax.
- Working CI with parser unit tests.
]
- #project("ffmpeg-idler", "https://github.com/awsomearvinder/idle-ffmpeg-runner")[
- Runs ffmpeg encodes when user is idle
- Pauses ffmpeg process using win32's `debugapi` on user activity.
]
]
= Education
#cventry(
start: (month: "August", year: 2021),
end: (month: "", year: "Present"),
role: "Student",
place: "Winona State University",
)[
Pursuing a B.S. degree for Computer Science in WSU. Courses include
operating systems, database management, AI, data structures and software
engineering practices.
]
#pagebreak()
= Technical Skills
#cvcol[
#let skill(name, body) = {
heading(level: 4)[#text(size: 12pt)[#name]]
body
}
- #skill("Rust")[
- Continuous use since 2018
- Strong understanding of the ecosystem.
- Can write networking code on top of i.e. HTTPS.
- Use low level (potentially unsafe) libraries such as `libgit2`, `windows-rs`.
- CLI apps, backend code.
]
- #skill("Python")[
- Primary scripting language of choice.
- Web services
- Automating linux tasks, manipulating processes and data.
]
- #skill("Linux")[
- Can use, and manage docker containers through e.g. Dockerfile
- Bash scripting.
- Networking (static routes, NAT, firewall rule management)
- Nix package management
]
- #skill("CI/CD")[
- Can automatically deploy code, manage secrets, and test code.
- Use CI/CD to automate building releases, run test builds on
all currently developed repos.
]
]
|
|
https://github.com/kdog3682/2024-typst | https://raw.githubusercontent.com/kdog3682/2024-typst/main/src/code-printer.typ | typst | #set page(margin: 1in, paper: "us-letter", columns: 2)
#set text(font: "IBM Plex Mono")
#let heading-function(it) = {
text(size: 12pt, it)
v(-12pt)
line(length: 100%)
}
#let create(o) = {
show heading: heading-function
let title = o.title
let body = o.body
heading(title)
raw(body)
}
#{
let data = json("/home/kdog3682/2024/temp.json")
let items = data.map(create).flatten().join()
items
}
|
|
https://github.com/astrale-sharp/typst-assignement-template | https://raw.githubusercontent.com/astrale-sharp/typst-assignement-template/main/libs/withlabels.typ | typst | MIT License | #import "expression.typ" : node,expression
#let oldnode = node
#let oldexpr = expression
#let state = state("expr",("type":"exprstate"))
#let node(x,data) = {
state.update(
i => {
i.insert(x,oldnode(x,data))
i
}
)
}
#let expression(x,..y) = {
locate(loc => {
oldexpr(x,..y,
nodes : state.at(loc))
})
}
#node("a",40)
#node("b",50)
#expression(
":a^2 * :b^2",
digit : 0,
) |
https://github.com/DashieTM/ost-5semester | https://raw.githubusercontent.com/DashieTM/ost-5semester/main/web3/weeks/week6.typ | typst | #import "../../utils.typ": *
#section("Angular")
#align(
center,
[#image("../../Screenshots/2023_10_26_02_01_15.png", width: 70%)],
)
- typescript based
- reduces boilerplate code
- Comes with *dependency injection* mechanism
- increases testability and maintainability
- framework templating etc.
#subsection("CLI")
#align(
center,
[#image("../../Screenshots/2023_10_26_02_25_51.png", width: 80%)],
)
Much like creating something with a compiled language, the best way to create an
angular project is with the angular cli, which handles building, testing and
deploying the package.
- npm install \@angular/cli
- npx ng new my-app
- npx ng serve --open
- npx ng build
- npx ng test
#subsection("Architecture")
#align(
center,
[#image("../../Screenshots/2023_10_26_02_05_36.png", width: 80%)],
)
- ngModules
- A cohesive block of code dedicated to closely related set of capabilities.
- Directives
- Provides instructions to transform the DOM.
- Components
- A component is a directive-with-a-template; it controls a section of the view.
- Templates
- A template is a form of HTML that tells Angular how to render the component.
- Metadata
- Metadata describes a class and tells Angular how to process it.
- Services
- Provides logic of any value, function, or feature that your application needs.
#subsubsection("Angular Modules")
- logical block of typscript modules together
- may provide a \<\<barrel\>\> (intex.ts) which exports public API
- may contain multiple-sub modules
- contain and export classes, functions etc.
- all public typscript memebers are exported as an overall \<\<barrel\>\>
- Angular provides library modules
- \@angular/core
- \@angular/common
- \@angular/router
Example module declaration: ```ts
@NgModule({
imports: [
CommonModule
],
declarations: []
exports: []
})
export class CoreModule { }
``` Declarations and notation:
- declarations: [ Type1, Type2, Type3]
- specifies what types will be used in this module ->
- exports: [ Type1, Type2, … Module1, Module2 ]
- what exports
- imports: [ Module1, Module2, …]
- what imports
- providers: [ Provider1, Provider2, …]
- services that this module provides for the global application -> always visible
and accessible
- bootstrap: [ Component ]
- root component
#subsubsection("Components")
Consists of:
- A controller (MVC)
- provides logic for the component
- a typescript class with \@component annotation
- An additional HTML file
- declares the visual interface in HTML and a mustache-based template expression
syntax -> handlebars
- an scss file for styling
- Lifecycle managed by Angular
- Create (Hydration)
- Update
- Destroy (Dehydration)
- hooks for lifecycle events
Components are similar to react with a few key differences like annotation
instead of inheritance -> likely because angular is older, lol.\
- components can be nested -> tree just like jsx
- reusability
- components are part of an ngModule which usually declare multiple components
Example component://typstfmt::off
```ts
import { Component } from '@angular/core';
@Component({
selector: 'wed-navigation',
templateUrl: './navigation.component.html',
styleUrls: ['./navigation.component.css']
})
export class NavigationComponent {
// logic
}
```
//typstfmt::on
Usage in Module:
//typstfmt::off
```ts
@NgModule({
declarations: [
NavigationComponent
],
imports: [
CommonModule
] ,
exports: [
NavigationComponent
],
providers: []
})
export class SharedModule { }
```
//typstfmt::on
#subsubsection("Code Example")
HTML://typstfmt::off
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>WE3 Angular / [adv1-demo1-final] - Samples</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<wed-root>Please wait while loading your angular app...</wed-root>
</body>
</html>
```
//typstfmt::on
main:
//typstfmt::off
```ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
```
//typstfmt::on
Component:
//typstfmt::off
```ts
import {Component} from '@angular/core';
@Component({
selector: 'wed-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
}
```
//typstfmt::on
Component HTML:
//typstfmt::off
```html
<router-outlet></router-outlet>
```
//typstfmt::on
Router:
//typstfmt::off
```ts
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
const appRoutes: Routes = [
{path: '', redirectTo: '/welcome', pathMatch: 'full'}
];
@NgModule({
imports: [
RouterModule.forRoot(appRoutes)
],
exports: [
RouterModule
]
})
export class AppRoutingModule {
}
code
```
//typstfmt::on
BaseModule:
//typstfmt::off
```ts
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {CoreModule} from './core/core.module';
import {WelcomeModule} from './welcome/welcome.module';
import {AppComponent} from './app.component';
import {AppRoutingModule} from './app-routing.module';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CoreModule.forRoot(),
WelcomeModule.forRoot(),
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
```
//typstfmt::on
#text(teal)[Note, scss files and environment ts files are omitted.]
|
|
https://github.com/pku-typst/ichigo | https://raw.githubusercontent.com/pku-typst/ichigo/main/src/title.typ | typst | MIT License | #import "@preview/valkyrie:0.2.1" as z
/// Title content denerator, the result will be inserted into the document.
///
/// - meta (dict): document meta information
/// - theme (dict): theme obj
/// - title-style (str | none): expected to be `"whole-page"`, `none` or `"simple"`, default to `"whole-page"`
/// -> content
#let title-content(
meta,
theme,
title-style,
..opt,
) = {
z.parse(title-style, z.string())
if title-style == "whole-page" {
return (theme.title.whole-page)()
} else if title-style == "simple" {
return (theme.title.simple)()
} else if title-style == "none" {
return []
}
return []
} |
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-10900.typ | typst | Apache License 2.0 | #let data = (
("PHOENICIAN LETTER ALF", "Lo", 0),
("PHOENICIAN LETTER BET", "Lo", 0),
("PHOENICIAN LETTER GAML", "Lo", 0),
("PHOENICIAN LETTER DELT", "Lo", 0),
("PHOENICIAN LETTER HE", "Lo", 0),
("PHOENICIAN LETTER WAU", "Lo", 0),
("PHOENICIAN LETTER ZAI", "Lo", 0),
("PHOENICIAN LETTER HET", "Lo", 0),
("PHOENICIAN LETTER TET", "Lo", 0),
("PHOENICIAN LETTER YOD", "Lo", 0),
("PHOENICIAN LETTER KAF", "Lo", 0),
("PHOENICIAN LETTER LAMD", "Lo", 0),
("PHOENICIAN LETTER MEM", "Lo", 0),
("PHOENICIAN LETTER NUN", "Lo", 0),
("PHOENICIAN LETTER SEMK", "Lo", 0),
("PHOENICIAN LETTER AIN", "Lo", 0),
("PHOENICIAN LETTER PE", "Lo", 0),
("PHOENICIAN LETTER SADE", "Lo", 0),
("PHOENICIAN LETTER QOF", "Lo", 0),
("PHOENICIAN LETTER ROSH", "Lo", 0),
("PHOENICIAN LETTER SHIN", "Lo", 0),
("PHOENICIAN LETTER TAU", "Lo", 0),
("PHOENICIAN NUMBER ONE", "No", 0),
("PHOENICIAN NUMBER TEN", "No", 0),
("PHOENICIAN NUMBER TWENTY", "No", 0),
("PHOENICIAN NUMBER ONE HUNDRED", "No", 0),
("PHOENICIAN NUMBER TWO", "No", 0),
("PHOENICIAN NUMBER THREE", "No", 0),
(),
(),
(),
("PHOENICIAN WORD SEPARATOR", "Po", 0),
)
|
https://github.com/Area-53-Robotics/53B-Notebook-Over-Under-2023-2024 | https://raw.githubusercontent.com/Area-53-Robotics/53B-Notebook-Over-Under-2023-2024/master/entries/competitions/dulaney.typ | typst | Creative Commons Attribution Share Alike 4.0 International | #import "/templates/entries.typ": *
#import "/templates/headers.typ": *
#import "/templates/text.typ": *
#import "/templates/competition.typ": *
#create_default_entry(
title: [Dulaney Royal Rumble],
date: [November 4th, 2023],
witness: [Jin],
design: [Deb],
content: [
#entry_text()
#tournament(matches: (
(
match: "Qualification #8",
red_alliance: (teams: ("53B", "53C"), score: 84),
blue_alliance: (teams: ("53D", "768A"), score: 27),
won: true,
auton: false,
awp: false,
notes: none,
),
(
match: "Qualification #17",
red_alliance: (teams: ("1727B", "18391B"), score: 81),
blue_alliance: (teams: ("53B", "5588E"), score: 87),
won: true,
auton: false,
awp: false,
notes: none,
),
(
match: "Qualification #23",
red_alliance: (teams: ("1727A", "1893X"), score: 87),
blue_alliance: (teams: ("9290B", "53B"), score: 75),
won: false,
auton: false,
awp: false,
notes: none,
),
(
match: "Qualification #35",
red_alliance: (teams: ("53B", "18391A"), score: 135),
blue_alliance: (teams: ("23098B", "21146S"), score: 45),
won: true,
auton: false,
awp: false,
notes: none,
),
(
match: "Qualification #41",
red_alliance: (teams: ("7135Z", "98719A"), score: 70),
blue_alliance: (teams: ("53E", "53B"), score: 60),
won: false,
auton: false,
awp: false,
notes: none,
),
(
match: "Qualification #45",
red_alliance: (teams: ("98719C", "53B"), score: 86),
blue_alliance: (teams: ("5588B", "23382A"), score: 100),
won: false,
auton: false,
awp: false,
notes: none,
),
(
match: "Qualification #53",
red_alliance: (teams: ("768G", "7135D"), score: 76),
blue_alliance: (teams: ("5839B", "53B"), score: 59),
won: false,
auton: false,
awp: false,
notes: none,
),
(
match: "Round of 16",
red_alliance: (teams: ("99009A", "1727D"), score: 65),
blue_alliance: (teams: ("53B", "5588H"), score: 49),
won: false,
auton: false,
awp: false,
notes: none,
),
))
#let cell = rect.with(width: 100%, inset: 5pt)
#grid(
columns: (1fr, 1fr),
column-gutter: 4pt,
cell(fill: green, radius: (top: 1.5pt))[*Pros*],
cell(fill: red, radius: (top: 1.5pt))[*Cons*],
cell(fill: green.lighten(80%), radius: (bottom: 1.5pt))[
- Inspiration from different designs
- Made auton
- Made it to elims
- First comp of season
],
cell(fill: red.lighten(80%), radius: (bottom: 1.5pt))[
- Not enough driver practice
- Not putting the cata down and flipping
- Coding Discrepancies
- Lack of organization
],
)
]
) |
https://github.com/sdsc-ordes/modos-poster | https://raw.githubusercontent.com/sdsc-ordes/modos-poster/main/src/utils/scripts.typ | typst | Creative Commons Attribution 4.0 International | /*
MIT License
Copyright (c) 2024 <NAME>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Color and size states
#let color-primary = state("color-primary", teal)
#let color-background = state("color-background", white)
#let color-accent = state("color-accent", yellow)
#let color-titletext = state("color-titletext", black)
#let size-titletext = state("size-titletext", 2em)
// Content states
#let title-content = state("title-body")
#let subtitle-content = state("subtitle-body")
#let author-content = state("author-body")
#let affiliation-content = state("affiliation-body")
#let logo-1-content = state("logo-1-body")
#let logo-2-content = state("logo-2-body")
#let focus-content = state("focus-body")
#let footer-content = state("footer-body")
#let theme(
primary-color: rgb("#262262ff"), // Dark blue
background-color: white,
accent-color: rgb(243,163,30), // Yellow
titletext-color: white,
titletext-size: 2em,
body,
) = {
set page(
margin: 0pt,
)
color-primary.update(primary-color)
color-background.update(background-color)
color-accent.update(accent-color)
color-titletext.update(color-titletext => titletext-color)
size-titletext.update(size-titletext => titletext-size)
body
}
#let poster-header(
title: none,
subtitle: none,
authors: none,
affiliation: none,
logo-1: none,
logo-2: none,
// text-color: none,
// body
) = {
title-content.update(title-body => title)
subtitle-content.update(subtitle-body => subtitle)
author-content.update(author-body => authors)
affiliation-content.update(affiliation-body => affiliation)
logo-1-content.update(logo-1-body => logo-1)
logo-2-content.update(logo-2-body => logo-2)
}
#let poster-footer(
footer-kwargs: none,
body
) = {
footer-content.update(footer-body => body)
}
|
https://github.com/binhtran432k/ungrammar-docs | https://raw.githubusercontent.com/binhtran432k/ungrammar-docs/main/contents/literature-review/vscode.typ | typst | #import "/components/glossary.typ": gls
== Visual Studio Code
<sec-vscode>
#gls("vscode", mode: "full"), an open-source code editor developed by
Microsoft, has rapidly gained traction within the developer community due to
its robust feature set, cross-platform compatibility, and extensive
customization options. Its emphasis on user experience, coupled with a thriving
extension ecosystem, has solidified its position as a preferred code editor for
many programmers @bib-vscode.
This section delves into the core components and architectural underpinnings of
#gls("vscode"), examining how these elements contribute to its overall
effectiveness. By understanding the design principles and implementation
strategies employed in #gls("vscode"), we can gain valuable insights into
building high-quality tools for code editors and #gls("ides").
=== Architectural Overview
#gls("vscode")'s architecture is centered around a multi-process, event-driven design, leveraging the Electron framework to bridge web technologies with native platform capabilities. This architectural choice enables cross-platform compatibility while maintaining a responsive and fluid user interface.
The Monaco editor (@sec-monaco), a core component of #gls("vscode"), provides the foundation for text editing and code intelligence. Its integration with the #gls("electron", mode: "short") framework allows for seamless interaction between web-based rendering and native platform features. The efficiency and performance optimizations implemented within the Monaco editor have significantly contributed to #gls("vscode")'s overall responsiveness.
Beyond the core editor, #gls("vscode") incorporates a rich set of features and services, including debugging, #gls("git", mode: "short") integration, and an extensive extension marketplace. These components are often implemented as distinct modules or extensions, promoting modularity and extensibility.
The architecture's emphasis on modularity and separation of concerns facilitates the development of custom extensions and integrations. This flexibility has been a key factor in #gls("vscode")'s rapid adoption and growth within the developer community.
=== VS Code Extension Ecosystem
#gls("vscode", mode: "long") is architected with extensibility as a core principle. From the #gls("ui") to the editing experience, nearly every aspect of #gls("vscode") can be customized and enhanced through the Extension #gls("api", mode: "short"). This flexibility has fostered a vibrant ecosystem of extensions, catering to a wide range of developer preferences and project requirements.
==== Building and Publishing Extensions
Developing a #gls("vscode") extension involves several key stages:
- *Core Concepts*: Grasping fundamental extension concepts, such as activation events, commands, and contributions.
- *Extension #gls("api")*: Leveraging the rich set of #gls("apis") provided by #gls("vscode") to access editor features, language services, and the workspace.
- *Development and Debugging*: Utilizing the extension development environment to build, test, and debug extensions efficiently.
- *Packaging and Publishing*: Preparing extensions for distribution through the #gls("vscode") Marketplace.
==== Extension Capabilities
#gls("vscode") extensions offer a wide range of possibilities:
- *#gls("ui") Customization*: Create custom themes, color schemes, and #gls("ui") elements to personalize the editor.
- *Language Support*: Add support for new programming languages, including syntax highlighting, code completion, and debugging.
- *New Features*: Introduce entirely new features and functionalities to the editor.
- *Integration with External Services*: Connect #gls("vscode") to external tools and services.
=== Challenges and Opportunities in VS Code Extension Development
While #gls("vscode") offers a robust platform for extension development, creators encounter several challenges. Performance optimization, particularly when dealing with large datasets or complex language features, remains a critical area. Debugging extensions can also be intricate due to the asynchronous nature of the #gls("vscode") architecture. Ensuring compatibility across different #gls("vscode") versions and operating systems presents additional hurdles.
Moreover, the extension marketplace is becoming increasingly competitive. To stand out, developers must focus on creating high-quality extensions that address specific user needs and provide exceptional user experiences. This requires a deep understanding of user workflows and preferences.
On the other hand, the #gls("vscode") extension ecosystem presents numerous opportunities for innovation. Developers can create extensions that automate repetitive tasks, integrate with external tools and services, and enhance collaboration. By addressing emerging trends and technologies, extension creators can position themselves at the forefront of the developer tool landscape.
=== VS Code and Language Servers
#gls("vscode") has seamlessly integrated #gls("lsp") support, significantly enhancing its language intelligence capabilities. By leveraging #gls("lsp"), #gls("vscode") offers a wide range of features, including code completion, diagnostics, refactoring, and navigation, across multiple programming languages.
To effectively integrate #gls("lsp", mode: "long") within #gls("vscode", mode: "long"), several key aspects must be considered:
- *Performance optimization*: Strategies for efficiently handling #gls("lsp") communication and processing language server responses.
- *Extension management*: Challenges and best practices for managing multiple #gls("lsp") extensions within #gls("vscode").
- *User experience*: The impact of #gls("lsp") features on developer productivity and satisfaction, as well as user expectations for language support.
- *#gls("lsp") extensions*: Opportunities for extending #gls("lsp") capabilities with custom features and protocols, tailoring the language service to specific development needs.
|
|
https://github.com/AHaliq/DependentTypeTheoryReport | https://raw.githubusercontent.com/AHaliq/DependentTypeTheoryReport/main/preamble/catt.typ | typst | #import "@preview/fletcher:0.5.1" as fletcher: diagram, node, edge
#let Ob(category) = $attach(br: category, upright(bold("Ob")))$
#let Hom(category,s:none,t:none) = $attach(br: category, upright(bold("Hom")))#if s != none and t != none { $(#s,#t)$ }$
#let arr(f,a,b) = $#f: #a -> #b$
#let comp = $compose$
#let iso = $tilde.equiv$
#let op(category) = $attach(tr: "op", category)$
#let slice(category,obj) = $#category slash #obj$
#let coslice(category,obj) = $#category backslash #obj$
#let Set = $upright(bold("Sets"))$
#let Rel = $upright(bold("Rel"))$
#let Mon = $upright(bold("Monoids"))$
#let Pos = $upright(bold("Posets"))$
#let dom = $upright(bold("dom"))$
// diagram macros
#let sstroke = 1pt + silver
#let corner-mark = (
inherit: "straight",
sharpness: 45deg,
stroke: black,
rev: false,
)
#let corner(..a) = edge(..a, stroke: white, marks: (corner-mark,))
|
|
https://github.com/hitszosa/universal-hit-thesis | https://raw.githubusercontent.com/hitszosa/universal-hit-thesis/main/common/components/table.typ | typst | MIT License | /*
旧版三线表已弃用,推荐使用新版原生写法
#table(
columns: (1fr, 1fr, 1fr, 1fr),
stroke: none,
table.hline(),
[t], [1], [2], [3],
table.hline(stroke: .5pt),
[y], [0.3s], [0.4s], [0.8s],
table.hline(),
)
*/
#let three-line-table(..args) = {
let values = args.pos()
let header-values = if values.len() > 0 {
values.at(0)
} else {
()
}
let content-values = if values.len() > 1 {
values.slice(1)
} else {
()
}
let table-cell(content: none) = {
set align(center)
rect(
width: 100%,
stroke: none,
)[
#content
]
}
line(length: 100%, stroke: 0.3mm)
v(0em, weak: true)
pad(y: 0.25em)[
#grid(
columns: header-values.len(),
..header-values.map(content => table-cell(content: content)).flatten(),
)
]
v(0em, weak: true)
line(length: 100%, stroke: 0.05mm)
if content-values.len() > 0 {
v(0em, weak: true)
pad(y: 0.25em)[
#grid(
columns: header-values.len(),
row-gutter: 0.25em,
..content-values.map(line-content => {
(..line-content.map(content => table-cell(content: content)).flatten(),)
}).flatten(),
)
]
v(0em, weak: true)
line(length: 100%, stroke: 0.3mm)
}
} |
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/cetz/0.2.0/src/hobby.typ | typst | Apache License 2.0 | #import "/src/vector.typ"
#import "/src/complex.typ"
// Implementation by @Enivex
//
// Notation comes from https://tug.org/TUGboat/tb34-2/tb107jackowski.pdf
//
// points = (P_0, P_1, ... , P_n)
//
// ta = (tau_(a,0),tau_(a,1), ... , tau_(a,n-1))
// ta(i) = tau_(a,i) is the outgoing tension at P_i on the curve from P_i to P_(i+1)
//
// tb = (tau_(b,0),tau(b,1), ..., tau_(b,n-1))
// tb(i) = tau_(b,i) is the incoming tension at P_(i+1) on the curve from P_i to P_(i+1)
//
// omega = (omega_0,omega_n)
// curl at the start and end of curve (size of mock curvature relative to nearest point)
//
// v(i) = P_(i+1) - P_i
// vector pointing from point i to point i + 1 (direction of ith chord)
//
// d(i) = |v(i)|
// length of the ith chord
//
// gamma(i) = signed angle from v(i - 1) to v(i) (change in angle at P_i)
// Note: gamma(0) = gamma(n) = 0
//
// ca(i) = first control point on chord i
// cb(i) = second control point on chord i
//
// alpha(i) = signed angle from v(i) to ca(i) - P(i)
// beta(i) = signed angle from P(i + 1) - cb(i) to v(i)
// Solve tridiagonal system
//
// - a,b,c,d have the same length, n + 1
// - a(0) and c(n) are not used
//
// Solves Ax=d
// where A=
// [ b_0 c_0
// a_1 b_1 c_1
// ......
// a_(n-1) b_(n-1) c_(n-1)
// a_n b_n ]
#let thomas(a, b, c, d) = {
let n = a.len() - 1
for i in range(1,n + 1) {
let w = a.at(i) / b.at(i - 1)
b.at(i) = b.at(i) - w*c.at(i - 1)
d.at(i) = d.at(i) - w*d.at(i - 1)
}
let x = (0,)*(n + 1)
x.last() = d.last() / b.last()
for i in range(n - 1, -1 , step: -1) {
x.at(i) = (d.at(i) - c.at(i)*x.at(i + 1)) / b.at(i)
}
return x
}
// Solve cyclic tridiagonal system
//
// - a,b,c,d have the same length, n+1
//
// Solves Ax=d
// where A=
// [ b_0 c_0 a_0
// a_1 b_1 c_1
// ......
// a_(n-1) b_(n-1) c_(n-1)
// c_n a_n b_n ]
#let thomas-cyclic(a, b, c, d) = {
let n = a.len() - 1
let u = (a.first(),) + (0,)*(n - 1) + (c.last(),)
let v = (1,) + (0,)*(n - 1) + (1,)
let bp = array.zip(b,u).map(((s,t)) => s - t)
let y = thomas(a, bp, c, d)
let z = thomas(a, bp, c, u)
// Sherman-Morrison formula
return vector.sub(y, vector.scale(z, vector.dot(v,y) / (1 + vector.dot(v, z))))
}
/// Calculate bezier spline for open Hobby curve through a list of points
///
/// - points (array): List of points
/// - ta (auto,array): Outgoing tension per point
/// - tb (auto,array): Incoming tension per point
/// - rho (auto,array): The rho function of the form `(a, b) => <float>`
/// - omega (auto,array): Tuple of the curl at the start end end of the curve `(start, end)` as floats
///
/// -> array List of cubic bezier curves (start, end, c0, c1)
#let hobby-to-cubic-open(points, ta: auto, tb: auto, rho: auto, omega: auto) = {
let n = points.len() - 1
if ta == auto {
ta = (1,)*n
} else {
assert.eq(type(ta), array, message: "ta must be an array")
assert.eq(ta.len(), n, message: "ta must have length n for n + 1 points")
assert(ta.all(x => x > 0), message: "ta must contain only positive numbers")
}
if tb == auto {
tb = (1,)*n
} else {
assert.eq(type(tb), array, message: "tb must be an array")
assert.eq(tb.len(), n, message: "tb must have length n for n + 1 points")
assert(tb.all(x => x > 0), message: "tb must contain only positive numbers")
}
if rho == auto {
rho = (a,b) => {
(2 + calc.sqrt(2)*(calc.sin(a) - calc.sin(b)/16)*(calc.sin(b)-calc.sin(a)/16)*(calc.cos(a)-calc.cos(b)))/(1 + calc.cos(a)*(calc.sqrt(5)-1)/2 + calc.cos(b)*(3-calc.sqrt(5))/2)
}
} else {
assert.eq(type(rho), function,
message: "rho must be a function")
}
let v = range(n).map(i => complex.sub(points.at(i + 1),points.at(i)))
let d = v.map(complex.norm)
let gamma = (0,) + range(n - 1).map(i => complex.ang(v.at(i),v.at(i + 1))) + (0,)
let ita = ta.map(x => 1/x)
let itasq = ita.map(x => x*x)
let itb = tb.map(x => 1/x)
let itbsq = itb.map(x => x*x)
let (omega0, omegan) = omega
let A = (0,) * (n + 1); let B = A; let C = A; let D = A; let E = A
C.at(0) = omega0 * ita.at(0) * itasq.at(0) / itbsq.at(0) + 3 - itb.at(0)
D.at(0) = omega0 * itasq.at(0) / itbsq.at(0) * (3 - ita.at(0)) + itb.at(0)
E.at(0) = - D.at(0) * gamma.at(1)
for i in range(1, n) {
A.at(i) = ita.at(i - 1) / (d.at(i - 1) * itbsq.at(i - 1))
B.at(i) = (3 - ita.at(i - 1))/(d.at(i - 1) * itbsq.at(i - 1))
C.at(i) = (3 - itb.at(i))/(d.at(i) * itasq.at(i))
D.at(i) = itb.at(i) / (d.at(i) * itasq.at(i))
E.at(i) = - B.at(i) * gamma.at(i) - D.at(i) * gamma.at(i + 1)
}
A.at(n) = omegan * itbsq.at(n - 1) / itasq.at(n - 1) * ( 3 - itb.at(n - 1)) + ita.at(n - 1)
B.at(n) = omegan * itb.at(n - 1) * itbsq.at(n - 1) / itasq.at(n - 1) + 3 - ita.at(n - 1)
let alpha = thomas(A,vector.add(B,C), D, E)
let beta = vector.scale(vector.add(alpha,gamma).slice(1), -1)
let ca = (0,)*n; let cb = ca
for i in range(n) {
let a = rho(alpha.at(i),beta.at(i)) * d.at(i) / 3
let b = rho(beta.at(i),alpha.at(i)) * d.at(i) / 3
ca.at(i) = complex.add(points.at(i), complex.scale(complex.unit(complex.rot(v.at(i),alpha.at(i))), a))
cb.at(i) = complex.sub(points.at(i + 1), complex.scale(complex.unit(complex.rot(v.at(i),-beta.at(i))), b))
}
return range(n).map(i => (points.at(i), points.at(i+1), ca.at(i), cb.at(i)))
}
/// Calculate bezier spline for closed Hobby curve through a list of points
///
/// - points (array): List of points
/// - ta (auto,array): Outgoing tension per point
/// - tb (auto,array): Incoming tension per point
/// - rho (auto,array): The rho function of the form `(a, b) => <float>`
///
/// -> array List of cubic bezier curves (start, end, c0, c1)
#let hobby-to-cubic-closed(points, ta: auto, tb: auto, rho: auto) = {
if points.first() != points.last() {
points.push(points.first())
}
let n = points.len() - 1
points.push(points.at(1))
if ta == auto {
ta = (1,)*n
} else {
assert.eq(type(ta), array, message: "ta must be an array")
assert.eq(ta.len(), n, message: "ta must have length n for n + 1 points")
assert(ta.all(x => x > 0), message: "ta must contain only positive numbers")
}
if tb == auto {
tb = (1,)*n
} else {
assert.eq(type(tb), array, message: "tb must be an array")
assert.eq(tb.len(), n, message: "tb must have length n for n + 1 points")
assert(tb.all(x => x > 0), message: "tb must contain only positive numbers")
}
if rho == auto {
rho = (a,b) => {
(2 + calc.sqrt(2)*(calc.sin(a) - calc.sin(b)/16)*(calc.sin(b)-calc.sin(a)/16)*(calc.cos(a)-calc.cos(b)))/(1 + calc.cos(a)*(calc.sqrt(5)-1)/2 + calc.cos(b)*(3-calc.sqrt(5))/2)
}
} else {
assert.eq(type(rho), function,
message: "rho must be a function")
}
let v = range(n + 1).map(i => complex.sub(points.at(i + 1),points.at(i)))
let d = v.map(complex.norm)
let gamma = range(n).map(i => complex.ang(v.at(i),v.at(i + 1)))
gamma = (gamma.last(),..gamma)
let ita = ta.map(x => 1/x)
let itasq = ita.map(x => x*x)
let itb = tb.map(x => 1/x)
let itbsq = itb.map(x => x*x)
let A = (0,) * n; let B = A; let C = A; let D = A; let E = A
A.at(0) = ita.at(n - 1) / (d.at(n - 1) * itbsq.at(n - 1))
B.at(0) = (3 - ita.at(n - 1))/(d.at(n - 1) * itbsq.at(n - 1))
C.at(0) = (3 - itb.at(0))/(d.at(0) * itasq.at(0))
D.at(0) = itb.at(0) / (d.at(0) * itasq.at(0))
E.at(0) = - B.at(0) * gamma.at(0) - D.at(0) * gamma.at(1)
for i in range(1, n) {
A.at(i) = ita.at(i - 1) / (d.at(i - 1) * itbsq.at(i - 1))
B.at(i) = (3 - ita.at(i - 1))/(d.at(i - 1) * itbsq.at(i - 1))
C.at(i) = (3 - itb.at(i))/(d.at(i) * itasq.at(i))
D.at(i) = itb.at(i) / (d.at(i) * itasq.at(i))
E.at(i) = - B.at(i) * gamma.at(i) - D.at(i) * gamma.at(i + 1)
}
let alpha = thomas-cyclic(A,vector.add(B,C), D, E)
alpha.push(alpha.at(0))
let beta = vector.scale(vector.add(alpha,gamma), -1)
beta = (..beta.slice(1),beta.at(0))
let ca = (0,) * n; let cb = ca
for i in range(n) {
let a = rho(alpha.at(i),beta.at(i)) * d.at(i) / 3
let b = rho(beta.at(i),alpha.at(i)) * d.at(i) / 3
ca.at(i) = complex.add(points.at(i), complex.scale(complex.unit(complex.rot(v.at(i),alpha.at(i))), a))
cb.at(i) = complex.sub(points.at(i + 1), complex.scale(complex.unit(complex.rot(v.at(i),-beta.at(i))), b))
}
return range(n).map(i => (points.at(i), points.at(i+1), ca.at(i), cb.at(i)))
}
/// Calculate bezier spline for open Hobby curve through a list of points
///
/// - points (array): List of points
/// - ta (auto,array): Outgoing tension per point
/// - tb (auto,array): Incoming tension per point
/// - rho (auto,array): The rho function of the form `(a, b) => <float>`
/// - omega (auto,array): Tuple of the curl at the start end end of the curve `(start, end)` as floats
/// - close (bool): Close the curve
///
/// -> array List of cubic bezier curves (start, end, c0, c1)
#let hobby-to-cubic(points, ta: auto, tb: auto, rho: auto, omega: auto, close: false) = {
let omega = if omega == auto {
(1, 1)
} else if type(omega) == array {
omega
} else {
(omega, omega)
}
assert.eq(type(omega), array,
message: "Omega must be of type array")
assert.eq(omega.len(), 2,
message: "Omega must be of length 2")
assert(omega.all(x => x >= 0),
message: "Omega must contain positive values only")
if points.len() == 2 {
let (a, b) = points
return ((a, b, a, b),)
}
return if close {
hobby-to-cubic-closed(points, ta: ta, tb: tb, rho: rho)
} else {
hobby-to-cubic-open(points, ta: ta, tb: tb, rho: rho, omega: omega)
}
}
|
https://github.com/jamesrswift/pixel-pipeline | https://raw.githubusercontent.com/jamesrswift/pixel-pipeline/main/src/layers/lib.typ | typst | The Unlicense | #import "debug.typ": layer as debug
#import "drawing/lib.typ" as drawing |
https://github.com/TomVer99/FHICT-typst-template | https://raw.githubusercontent.com/TomVer99/FHICT-typst-template/main/template/fhict-template.typ | typst | MIT License | #import "@preview/codly:1.0.0": *
#import "@preview/glossarium:0.4.1": make-glossary, print-glossary, gls, glspl
#import "@preview/in-dexter:0.4.2": *
#import "@preview/hydra:0.5.1": hydra
#let fontys-purple-1 = rgb("663366")
#let fontys-purple-2 = rgb("B59DB5")
#let fontys-pink-1 = rgb("E5007D")
#let fontys-blue-1 = rgb("1F3763")
#let fontys-blue-2 = rgb("2F5496")
#let code-name-color = fontys-purple-1
#let code-zebra-color = fontys-purple-1.lighten(85%)
// States
#let censored-state = state("style", "0")
// Misc functions
#let hlink(url, content: none) = {
link(url)[
#underline[#text(
[
#if content == none {
url
} else {
content
}
],
fill: fontys-blue-2,
)]
]
}
#let sensitive(textl) = {
context [
#if (censored-state.at(here()) == 1) {
text(
textl.replace(regex("."), "█"),
fill: black,
font: "Arial",
)
} else {
textl
}
]
}
// 1: Fill the top row and left column
// 2: Fill the top row
// 3: Fill the left column
// 4: No fill
// 5: Fill the top row and left column w/ border
// 6: Fill the top row w/ border
// 7: Fill the left column w/ border
// 8: No fill w/ border
#let ftable(style: 2, columns: none, ..tablec) = {
set table(
inset: 8pt - if (style > 4) {
1pt
} else {
0pt
},
gutter: -1pt + if (style > 4) {
1pt
} else {
0pt
},
align: horizon,
stroke: if (style <= 4) {
none
} else {
1pt + black
},
fill: (x, y) => if (x == 0 and (style == 1 or style == 3 or style == 5 or style == 7)) or (
y == 0 and (style == 1 or style == 2 or style == 5 or style == 6)
) {
fontys-purple-1
} else if (calc.even(y) and style <= 4) {
code-zebra-color
} else {
white
},
)
show table.cell: it => {
if (it.x == 0 and (style == 1 or style == 3 or style == 5 or style == 7)) or (
it.y == 0 and (style == 1 or style == 2 or style == 5 or style == 6)
) {
set text(white)
strong(it)
} else {
it
}
}
table(
columns: columns,
..tablec
)
}
#let set-code-line-nr(start: 1) = {
if (start == -1) {
codly(number-format: none)
} else {
codly(number-format: number => [ #(number + start - 1) ])
}
}
#let text-box(background-color: luma(240), stroke-color: black, text-color: black, content) = {
rect(fill: background-color, width: 100%, stroke: (left: 0.25em + stroke-color))[
#text(
fill: text-color,
content,
)
]
}
#let lined-box(title, body, line-color: red) = block(
above: 2em,
stroke: 0.5pt + line-color,
width: 100%,
inset: 14pt,
breakable: false,
)[
#set text(font: "Roboto", fill: line-color)
#place(
top + left,
dy: -6pt - 14pt,
dx: 6pt - 14pt,
block(fill: white, inset: 2pt)[*#title*],
)
#body
]
#let page-intentionally-left-blank-sub(newpage, force) = {
block(height: 100%, width: 100%)[
#align(center + horizon)[
#text(fill: black, font: "Arial", size: 12pt)[
*This page is intentionally left blank.*
]
]
]
if newpage {
pagebreak()
}
}
#let page-intentionally-left-blank(newpage: true, force: false, odd: true) = {
context [
#if odd == true {
if calc.odd(counter(page).get().at(0)) or force == true {
page-intentionally-left-blank-sub(newpage, force)
}
} else {
if calc.even(counter(page).get().at(0)) or force == true {
page-intentionally-left-blank-sub(newpage, force)
}
}
]
}
// Document
#let fhict-doc(
title: "Document Title",
subtitle: none,
language: "en",
available-languages: none,
date: none,
authors-title: none,
authors: none,
assessors-title: none,
assessors: none,
version-history: none,
glossary-terms: none,
glossary-front: false,
bibliography-file: none,
citation-style: "ieee",
toc-depth: 3,
disable-toc: false,
disable-chapter-numbering: false,
disable-version-on-cover: false,
chapter-on-new-page: false,
pre-toc: none,
table-of-figures: none,
table-of-listings: none,
table-of-tables: none,
appendix: none,
watermark: none,
censored: 0,
print-extra-white-page: false,
secondary-organisation-color: none,
secondary-organisation-logo: none,
secondary-organisation-logo-height: 6%,
enable-index: false,
index-columns: 2,
body,
) = {
show: make-glossary
let meta-authors = ""
let index-main(..args) = index(fmt: strong, ..args)
// Load language data
let language-data = yaml("assets/language.yml")
let language-dict = language-data.at(upper(language)).at("localization")
set text(lang: language)
// Set metadata
if authors != none and censored == 0 {
if type(authors.at(0).name) == dictionary {
meta-authors = authors.map(author => author.name.string)
} else {
meta-authors = authors.map(author => author.name)
}
}
set document(
title: title,
author: meta-authors,
)
// Set the document's style
set text(font: "Roboto", size: 11pt, fill: black)
set cite(style: citation-style)
// Set inline block style
show raw.where(block: false): it => (
h(0.5em) + box(fill: code-zebra-color, radius: 0.2em, outset: 0.2em, it) + h(0.5em)
)
// Set the header style
let numbering-set = none
if disable-chapter-numbering == false {
numbering-set = "1.1"
} else {
numbering-set = none
}
set heading(numbering: numbering-set)
show heading.where(level: 1): h => (
if (chapter-on-new-page == true) {
pagebreak(weak: true)
} + {
text(strong(upper(h)), size: 18pt, fill: fontys-purple-1)
}
)
show heading.where(level: 2): h => {
text(strong(upper(h)), size: 14pt, fill: fontys-pink-1)
}
show heading.where(level: 3): h => {
text(upper(h), size: 12pt, fill: fontys-blue-1)
}
show heading.where(level: 4): h => {
text(upper(h), size: 11pt, fill: fontys-blue-2)
}
show heading.where(level: 5): h => {
text(emph(upper(h)), size: 11pt, fill: fontys-blue-2, font: "Calibri")
}
// Set the listing style
show figure.where(kind: raw): it => {
set align(left)
it.body
set align(center)
it.caption
}
// Set Cover Page
set page(
"a4",
background: [
// Main background triangle
#place(
top + left,
path(
fill: fontys-purple-2,
closed: true,
(0%, 0%),
(5%, 0%),
((70%, 45%), (-20pt, -20pt)),
((75%, 50%), (0%, -15pt)),
((70%, 55%), (20pt, -20pt)),
(5%, 100%),
(0%, 100%),
),
)
#if secondary-organisation-color != none {
// Secondary organisation triangle
place(
top + left,
path(
fill: secondary-organisation-color,
closed: true,
(10%, 100%),
(101%, 37%),
(101%, 100%),
),
)
}
#if secondary-organisation-logo != none {
// Secondary organisation logo
place(
bottom + right,
dx: -30pt,
dy: -120pt,
image.decode(
secondary-organisation-logo,
height: secondary-organisation-logo-height,
),
)
}
// For scociety image
#place(
top + left,
dx: 70pt,
dy: 70pt,
image(
"assets/fontys-for-society.png",
height: 9%,
),
)
// Language boxes
#if available-languages != none {
place(
right + top,
dy: 0pt,
dx: -10pt,
box[
#for l-language in language-data.keys() {
if lower(l-language) in available-languages {
if l-language == upper(language) {
box(height: 25pt + 5pt, width: 37.5pt + 5pt + 2.5pt, fill: fontys-pink-1.lighten(50%))
} else {
box(height: 25pt + 5pt, width: 37.5pt + 5pt + 2.5pt, fill: rgb("#ffffff00"), radius: 1pt)
}
h(5pt)
}
}
],
)
place(
right + top,
dy: 15pt,
dx: -10pt,
box[
#for l-language in language-data.keys() {
if lower(l-language) in available-languages {
let path = ""
path = "assets/" + l-language + "-flag.svg"
box(height: 25pt + 5pt, width: 37.5pt + 5pt + 2.5pt, fill: fontys-pink-1.lighten(50%), radius: 1pt)[
#place(
center + horizon,
image(path, height: 25pt, width: 37.5pt),
)
]
h(5pt)
}
}
],
)
}
// Title, Subtitle, Authors, Assessors
#censored-state.update(censored)
#set text(fill: fontys-purple-1)
#place(
left + top,
dy: 380pt,
dx: 40pt,
grid(
columns: (25%, 60%),
rows: (auto),
stroke: none,
gutter: 5pt,
if (title != none) {
grid.cell(
colspan: 2,
box(
height: auto,
inset: 10pt,
fill: fontys-pink-1,
text(30pt, fill: white, font: "Roboto")[
*#upper(title)*
],
),
)
} else {
grid.cell(colspan: 2)
},
if (subtitle != none) {
grid.cell(
colspan: 2,
box(
height: auto,
inset: 10pt,
fill: white,
text(20pt, fill: fontys-purple-1, font: "Roboto")[
*#upper(subtitle)*
],
),
)
} else {
grid.cell(colspan: 2, [#h(-20pt)])
},
if (authors != none) {
rect(
height: auto,
width: if (assessors == none) {
auto
} else {
100%
},
stroke: none,
fill: white,
inset: 7pt,
)[
#set text(size: 9pt)
#if authors-title != none {
text(11pt)[*#authors-title:*#linebreak()]
}
#if authors.all(x => "email" in x) {
if type(authors.at(0).name) == dictionary {
authors
.map(author => (
strong(author.name.content) + linebreak() + text(size: 6pt)[#{
" " * 4
}#link("mailto:" + author.email)[#author.email]]
))
.join("\n")
} else {
authors
.map(author => (
author.name + linebreak() + text(size: 7pt)[#{
" " * 4
}#link("mailto:" + author.email)[#author.email]]
))
.join("\n")
}
} else {
if type(authors.at(0).name) == dictionary {
[#authors.map(author => author.name.content).join("\n")]
} else {
[#authors.map(author => author.name).join("\n")]
}
}
]
},
if (assessors != none) {
rect(height: auto, width: auto, stroke: none, fill: white, inset: 7pt)[
#set text(size: 9pt)
#if assessors-title != none {
text(11pt)[*#assessors-title:*#linebreak()]
}
#text(size: 8pt)[
#for assessor in assessors {
if "title" in assessor {
strong(assessor.title) + strong(": ")
}
if "name" in assessor and "email" in assessor {
link("mailto:" + assessor.email)[#assessor.name]
} else if "name" in assessor {
assessor.name
}
if (assessors.at(assessors.len() - 1) != assessor) {
", "
}
}
]
]
},
),
)
#set text(size: 11pt, fill: black)
// Date
#if secondary-organisation-color == none {
place(
right + horizon,
dy: 330pt,
box(
height: 40pt,
inset: 10pt,
fill: fontys-pink-1,
text(30pt, fill: white, font: "Roboto")[
#if (date != none) {
strong(date)
} else {
strong(datetime.today().display())
}
],
),
)
} else {
place(
right + horizon,
dy: 330pt,
box(
height: 40pt,
inset: 10pt,
fill: white,
text(30pt, fill: secondary-organisation-color, font: "Roboto")[
#if (date != none) {
strong(upper(date))
} else {
strong(datetime.today().display())
}
],
),
)
}
// Version
#if secondary-organisation-color == none and version-history != none and version-history.len() > 0 and disable-version-on-cover == false {
place(
right + horizon,
dy: 370pt,
box(
height: 30pt,
inset: 10pt,
fill: fontys-pink-1,
text(20pt, fill: white, font: "Roboto")[
#version-history.at(version-history.len() - 1).at("version")
],
),
)
} else if version-history != none and version-history.len() > 0 and disable-version-on-cover == false {
place(
right + horizon,
dy: 370pt,
box(
height: 30pt,
inset: 10pt,
fill: white,
text(20pt, fill: secondary-organisation-color, font: "Roboto")[
#version-history.at(version-history.len() - 1).at("version")
],
),
)
}
],
foreground: [
#if watermark != none [
#place(
center + horizon,
rotate(
24deg,
text(60pt, fill: rgb(0, 0, 0, 70), font: "Roboto")[
*#upper(watermark)*
],
),
)
]
],
)
// Show the cover page
censored-state.update(censored)
box()
pagebreak()
let pre-toc-numbering = "1"
if (version-history != none) or (pre-toc != none) or (disable-toc == false) or (disable-toc == false) or (
glossary-terms != none and glossary-front == true
) or ((table-of-figures != none) and (table-of-figures != false)) or (
(table-of-listings != none) and (table-of-listings != false)
) or (print-extra-white-page == true) {
pre-toc-numbering = "I"
}
// Set the page style for non body pages
set page(
"a4",
background: [],
header: [
#place(right + horizon, dy: 15pt)[
#text(10pt, fill: fontys-purple-1, font: "Roboto")[
#upper[*#title*]
]
]
#place(
left + horizon,
dy: 15pt,
[#context [
#let chapter = hydra(1)
#if chapter != none {
text(10pt, fill: fontys-purple-1, font: "Roboto")[
*#upper(chapter)*
]
}
]],
)
#place(
left + bottom,
line(length: 100%, stroke: 1pt + fontys-purple-1),
)
],
footer: [
#place(left + horizon, dy: -10pt, dx: -15pt, image("assets/for-society.png", height: 200%))
#place(
right + horizon,
dy: -10pt,
text(15pt, fill: fontys-purple-1, font: "Roboto")[
*#counter(page).display(pre-toc-numbering)*
],
)
#place(
left + top,
line(length: 100%, stroke: 1pt + fontys-purple-1),
)
],
numbering: pre-toc-numbering,
)
counter(page).update(1)
show: codly-init.with()
codly(
languages: (
rust: (name: "Rust", color: code-name-color),
rs: (name: "Rust", color: code-name-color),
cmake: (name: "CMake", color: code-name-color),
cpp: (name: "C++", color: code-name-color),
c: (name: "C", color: code-name-color),
py: (name: "Python", color: code-name-color),
java: (name: "Java", color: code-name-color),
js: (name: "JavaScript", color: code-name-color),
sh: (name: "Shell", color: code-name-color),
bash: (name: "Bash", color: code-name-color),
json: (name: "JSON", color: code-name-color),
xml: (name: "XML", color: code-name-color),
yaml: (name: "YAML", color: code-name-color),
typst: (name: "Typst", color: code-name-color),
),
number-format: none,
display-icon: false,
zebra-fill: code-zebra-color,
stroke: 1pt + code-zebra-color,
)
if print-extra-white-page == true {
page-intentionally-left-blank(newpage: false)
}
// Show the version history
if version-history != none {
heading(language-dict.at("version-history"), outlined: false, numbering: none)
ftable(
columns: (auto, auto, auto, 1fr),
[#language-dict.at("version")],
[#language-dict.at("date")],
[#language-dict.at("author")],
[#language-dict.at("changes")],
..for entry in version-history {
([#entry.version], [#entry.date], [#entry.author], [#entry.changes])
},
)
pagebreak()
if print-extra-white-page == true {
page-intentionally-left-blank(newpage: false)
}
}
if pre-toc != none {
// Show the pre-toc
// Disable heading numbering and appearing in the TOC
set heading(numbering: none, outlined: false)
pre-toc
pagebreak()
set heading(numbering: numbering-set, outlined: true)
// if disable-toc == false or (glossary-terms != none and glossary-front == true) or table-of-figures == true or table-of-listings == true {
// pagebreak()
// }
if print-extra-white-page == true {
page-intentionally-left-blank(newpage: false)
}
}
if disable-toc == false {
// Show the table of contents
show outline.entry: it => {
let body = [#it.body #box(width: 1fr, it.fill) #it.page]
if it.level == 1 {
if it.element.supplement == [#language-dict.at("appendix")] {
[#language-dict.at("appendix") #body]
} else {
body
}
} else {
body
}
}
outline(
title: language-dict.at("table-of-contents"),
depth: toc-depth,
indent: n => [#h(1em)] * n,
)
if (
glossary-terms != none and glossary-front == true
) or table-of-figures == true or table-of-listings == true or table-of-tables == true {
if print-extra-white-page == false {
pagebreak()
}
}
if print-extra-white-page == true {
pagebreak()
page-intentionally-left-blank(newpage: false)
}
}
// Show the Glossary in the front
if glossary-terms != none and glossary-front == true {
heading(language-dict.at("glossary"), numbering: none, outlined: false)
print-glossary((glossary-terms))
if table-of-figures == true or table-of-listings == true or table-of-tables == true {
pagebreak()
}
if print-extra-white-page == true {
page-intentionally-left-blank(newpage: false)
}
}
// Show the table of figures if requested
if table-of-figures == true {
outline(
title: language-dict.at("table-of-figures"),
target: figure.where(kind: image),
)
if table-of-listings == true or table-of-tables == true {
pagebreak()
}
if print-extra-white-page == true {
page-intentionally-left-blank(newpage: false)
}
}
// Show the table of listings if requested
if table-of-listings == true {
outline(
title: language-dict.at("table-of-listings"),
target: figure.where(kind: raw),
)
if table-of-tables == true {
pagebreak()
}
if print-extra-white-page == true {
page-intentionally-left-blank(newpage: false)
}
}
// Show the table of tables if requested
if table-of-tables == true {
outline(
title: language-dict.at("table-of-tables"),
target: figure.where(kind: table),
)
if print-extra-white-page == true {
pagebreak()
page-intentionally-left-blank(newpage: false)
}
}
// Set the page style for body pages'
// block()
set page(
"a4",
background: [],
footer: [
#place(left + horizon, dy: -10pt, dx: -15pt, image("assets/for-society.png", height: 200%))
#place(
right + horizon,
dy: -10pt,
text(15pt, fill: fontys-purple-1, font: "Roboto")[
*#counter(page).display()*
],
)
#place(
left + top,
line(length: 100%, stroke: 1pt + fontys-purple-1),
)
],
numbering: "1",
)
counter(page).update(1)
// Show the page's contents
body
if (
glossary-terms != none and glossary-front == false
) or bibliography-file != none or appendix != none or enable-index == true {
pagebreak()
}
if print-extra-white-page == true {
page-intentionally-left-blank(odd: false)
}
// Show the Glossary in the back
if glossary-terms != none and glossary-front == false {
set heading(numbering: none, outlined: false)
heading(language-dict.at("glossary"))
print-glossary((glossary-terms))
if (bibliography-file != none or appendix != none or enable-index == true) {
pagebreak()
}
if print-extra-white-page == true and (bibliography-file != none or appendix != none or enable-index == true) {
page-intentionally-left-blank(odd: false)
}
}
// Show the bibliography
if bibliography-file != none {
set bibliography(title: language-dict.at("references"), style: "ieee")
bibliography-file
if appendix != none or enable-index == true {
pagebreak()
}
if print-extra-white-page == true and (appendix != none or enable-index == true) {
page-intentionally-left-blank(odd: false)
}
}
// Show the appendix
if appendix != none {
// Set appendix page style
counter(heading).update(0)
set heading(numbering: "A.A", outlined: false)
show heading.where(level: 1): set heading(
numbering: "A.A:",
outlined: true,
supplement: language-dict.at("appendix"),
)
show heading.where(level: 1): it => block(
text(
strong[#upper[
#if it.numbering != none [ #language-dict.at("appendix") #counter(heading).display(it.numbering)]
#it.body
]],
size: 18pt,
fill: fontys-purple-1,
),
)
appendix
if enable-index == true {
pagebreak()
}
if print-extra-white-page == true and enable-index == true {
page-intentionally-left-blank(odd: false)
}
}
// Show the index
if enable-index == true {
show heading.where(level: 1): h => {
text(strong(upper(h)), size: 18pt, fill: fontys-purple-1)
}
heading(language-dict.at("index"), numbering: none)
columns(index-columns)[
#make-index()
]
}
}
|
https://github.com/kaarmu/typst-kth-exam | https://raw.githubusercontent.com/kaarmu/typst-kth-exam/main/main.typ | typst | #import "lib/typst-palette/src/palette.typ": xcolor
// Functions
#let red(body) = text(fill: xcolor.red, body)
#let hrule(length) = line(start: ((100% - length)/2, 0pt), length: length)
#let question(points, body) = {
body
h(1fr)
if points > 1 [
\[#points pts\]
] else [
\[#points pt\]
]
}
#let make-title(
logo: none,
title: none,
subtitle: none,
affiliations: none,
body,
) = {
set par(justify: true)
set align(center)
set text(font: "CMU Sans Serif")
// Logotype
image(
width: 2.5cm,
height: 2.5cm,
logo,
)
v(2cm)
{
set par(leading: 1em)
// Title: Course code and name
text(size: 16pt, title)
linebreak()
// Subtitle: Type of examination and date
text(size: 14pt, subtitle)
linebreak()
}
v(1.5cm)
// Horizontal ruler
hrule(70%)
// Affiliations
text(size: 12pt, affiliations)
v(0.5cm)
{
set text(font: "Computer Modern", 10pt)
set align(left)
body
}
}
// Begin document
#set page(margin: (y: 3cm))
// Title page
#make-title(
logo: "assets/KTH_Logotyp_RGB_2013.png",
title: "XY1234 Course Name",
subtitle: "Exam -- Jan 1970",
affiliations: [
Division of Decision and Control Systems \
School of Electrical Engineering and Computer Science \
KTH Royal Institute of Technology \
],
)[
#set terms(separator: ". ", hanging-indent: 0pt, spacing: 2em)
Re-exam (omtentamen), #red[January 1#super[st], 1970, kl 00.00 - 05.00]
#v(1em)
/ Aids:
Slides of the lectures (#red[not exercises]),
lecture notes (summary.pdf),
mathematical tables.
/ Observe:
Do not treat more than one problem on each page. Each step
in your solutions must be motivated. Write a clear answer
to each question. Write name and personal number on each
page. Please only use one side of each sheet. Mark the total
number of pages on the cover.
/ Grading: \
Grade A: $>= 43$ #h(1em) Grade B: $>= 38$ \
Grade C: $>= 33$ #h(1em) Grade D: $>= 28$ \
Grade E: $>= 23$ #h(1em) Grade Fx: $>= 21$ \
/ Responsible:
<NAME> #red[aaaxxxyyzz]
/ Results:
Posted no later than #red[January 15#super[th], 1970]
#v(1em)
#emph[Good luck!]
]
// Problem page -- Quiz
#{
pagebreak(weak: true)
set par(justify: true)
set text(font: "CMU Serif", size: 10pt)
heading(level: 1)[Problem 1 - Quiz]
v(1.5em)
enum(numbering: "(a)", indent: 0pt, tight: false, spacing: 1.5em,
question(1)[Why can’t we use the Policy Gradient approach for off-policy
learning?],
question(1)[Consider the following problem: in each round you choose a
scalar $theta$ and you observe a random variable $f(theta)$
such that $EE[f(theta)] = g(theta)$. Which technique would
you use to solve in $theta$ the equation
$g(theta) − alpha = 0$? (for some given $alpha$)],
question(1)[What is the complexity (number of operations) of solving the
Bellman’s equations in a finite time-horizon MDP with S
states, A actions, and time-horizon T ?],
question(1)[Is the SARSA algorithm based on the stochastic approximation
algorithm or the stochastic gradient algorithm?],
question(1)[Is the Q-learning algorithm with function approximation
based on the stochastic approximation algorithm or the
stochastic gradient algorithm?],
question(1)[In SARSA, we propose to use $epsilon$-greedy policy with a
value of $epsilon$ decreasing over time. More precisely, we
select $epsilon_t = 1/t^2$. The algorithm does not seem to
converge. Can you explain why?],
question(1)[In actor-critic algorithms, how many parameters do we need
to update? What do they correspond to?],
question(1)[Suppose we take the step-size $alpha_t = 1/log(t)$ in the
Q-learning algorithm. Are the iterates guaranteed to converge
almost surely to the true Q-function?],
question(2)[Let $X_1, X_2, ...$ be an homogenous Markov chain with finite
state space. Is the reverse process starting at time $N$ also a
Markov chain?
(The reverse process is $(X_N , X_(N−1), ..., X_1)$)],
)
}
// Problem page
|
|
https://github.com/luiswirth/numpde-slides | https://raw.githubusercontent.com/luiswirth/numpde-slides/main/src/setup.typ | typst | #import "@preview/polylux:0.3.1": *
#import "@preview/cetz:0.2.1"
#import "math.typ": *
#import "layout.typ": *
#let titleslide(nweek) = page(
background: image("res/numpde-art0.jpg", width: 100%)
)[
#set text(black)
#box(fill: rgb(255, 255, 255, 200), radius: 0pt, outset: 40pt)[
#align(center)[
#text(size: 100pt)[
NumPDE
] \
#text(size: 17pt)[
Numerical Methods for Partial Differential Equations
]
#v(1cm)
#text(size: 45pt)[
Week \##nweek
] \
#text(size: 20pt)[
Tutorial Class 2024
]
#v(2cm)
#text(size: 30pt)[
<NAME>
]
\
#link("mailto:<EMAIL>") \
#link("ethz.lwirth.com")
]
]
]
#import "@preview/codetastic:0.2.2": qrcode
#let numpde-link-qr = [
#qrcode("http://numpde.lwirth.com")
]
#let githubref = page(
//fill: white.darken(10%),
fill: white,
)[
#set text(black)
#align(horizon + center, grid(
columns: (auto, auto),
gutter: 0pt,
box(align(horizon, image("res/github-banner.png", height: 70%)), stroke: black)
))
#v(1em)
#align(center, text(size: 40pt, link("http://numpde.lwirth.com")[numpde.lwirth.com]))
]
#let this-template(doc) = [
#set page(paper: "presentation-16-9")
#set page(fill: black)
#set page(margin: 2cm)
#set text(white)
#set text(size: 18pt)
#set par(justify: true)
#show link: underline
#show: math-template
#doc
]
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/suiji/0.2.1/src/lib.typ | typst | Apache License 2.0 | #import "random.typ": gen-rng, integers, random, uniform, normal, discrete-preproc, discrete, shuffle, choice
|
https://github.com/Mc-Zen/tidy | https://raw.githubusercontent.com/Mc-Zen/tidy/main/src/show-module.typ | typst | MIT License | #import "styles.typ"
#import "utilities.typ"
#import "testing.typ"
/// Show given module in the given style.
/// This displays all (documented) functions in the module.
///
/// - module-doc (dictionary): Module documentation information as returned by
/// @@parse-module().
/// - first-heading-level (int): Level for the module heading. Function
/// names are created as second-level headings and the "Parameters"
/// heading is two levels below the first heading level.
/// - show-module-name (boolean): Whether to output the name of the module at
/// the top.
/// - break-param-descriptions (boolean): Whether to allow breaking of parameter
/// description blocks.
/// - omit-empty-param-descriptions (boolean): Whether to omit description blocks
/// for parameters with empty description.
/// - omit-private-definitions (boolean): Whether to omit functions and variables
/// starting with an underscore.
/// - omit-private-parameters (boolean): Whether to omit named function arguments
/// starting with an underscore.
/// - show-outline (boolean): Whether to output an outline of all functions in
/// the module at the beginning.
/// - sort-functions (auto, none, function): Function to use to sort the function
/// documentations. With `auto`, they are sorted alphabetically by
/// name and with `none` they are not sorted. Otherwise a function can
/// be passed that each function documentation object is passed to and
/// that should return some key to sort the functions by.
/// - style (module, dictionary): The output style to use. This can be a module
/// defining the functions `show-outline`, `show-type`, `show-function`,
/// `show-parameter-list` and `show-parameter-block` or a dictionary with
/// functions for the same keys.
/// - enable-tests (boolean): Whether to run docstring tests.
/// - enable-cross-references (boolean): Whether to enable links for cross-references.
/// - colors (auto, dictionary): Give a dictionary for type and colors and other colors.
/// If set to auto, the style will select its default color set.
/// - local-names (dictionary): Language-specific names for strings used in the output. Currently, these are `parameters` and `default`. You can for example use: `local-names: (parameters: [Paramètres], default: [défault])`
/// -> content
#let show-module(
module-doc,
style: styles.default,
first-heading-level: 2,
show-module-name: true,
break-param-descriptions: false,
omit-empty-param-descriptions: true,
omit-private-definitions: false,
omit-private-parameters: false,
show-outline: true,
sort-functions: auto,
enable-tests: true,
enable-cross-references: true,
colors: auto,
local-names: (parameters: [Parameters], default: [Default])
) = block({
let label-prefix = module-doc.label-prefix
if sort-functions == auto {
module-doc.functions = module-doc.functions.sorted(key: x => x.name)
} else if type(sort-functions) == "function" {
module-doc.functions = module-doc.functions.sorted(key: sort-functions)
}
if omit-private-definitions {
let filter = x => not x.name.starts-with("_")
module-doc.functions = module-doc.functions.filter(filter)
module-doc.variables = module-doc.variables.filter(filter)
}
let style-functions = utilities.get-style-functions(style)
let style-args = (
style: style-functions,
label-prefix: label-prefix,
first-heading-level: first-heading-level,
break-param-descriptions: break-param-descriptions,
omit-empty-param-descriptions: omit-empty-param-descriptions,
omit-private-parameters: omit-private-parameters,
colors: colors,
enable-cross-references: enable-cross-references,
local-names: local-names,
)
let eval-scope = (
// Predefined functions that may be called by the user in docstring code
example: style-functions.show-example.with(
inherited-scope: module-doc.scope,
preamble: module-doc.preamble
),
test: testing.test.with(
inherited-scope: testing.assertations + module-doc.scope,
enable: enable-tests
),
// Internally generated functions
tidy: (
show-reference: style-functions.show-reference.with(style-args: style-args)
)
)
eval-scope += module-doc.scope
style-args.scope = eval-scope
// Show the docs
if "name" in module-doc and show-module-name and module-doc.name != "" {
heading(module-doc.name, level: first-heading-level)
parbreak()
}
if show-outline {
(style-functions.show-outline)(module-doc, style-args: style-args)
}
for (index, fn) in module-doc.functions.enumerate() {
(style-functions.show-function)(fn, style-args)
}
for (index, fn) in module-doc.variables.enumerate() {
(style-functions.show-variable)(fn, style-args)
}
})
|
https://github.com/mem-courses/linear-algebra | https://raw.githubusercontent.com/mem-courses/linear-algebra/main/homework/linear-algebra-homework11.typ | typst | #import "../template.typ": *
#show: project.with(
title: "Linear Algebra Homework #11",
authors: (
(name: "<NAME> (#95)", email: "<EMAIL>", phone: "3230104585"),
),
date: "December 16, 2023",
)
#let AA = math.bold("A")
#let BB = math.bold("B")
#let EE = math.bold("E")
#let TT = math.upright("T")
#let alpha = math.bold(math.alpha)
#let beta = math.bold(math.beta)
#let gamma = math.bold(math.gamma)
#let eta = math.bold(math.eta)
#let theta = math.bold(math.theta)
#let epsilon = math.bold(math.epsilon)
#let xi = math.bold(math.xi)
#let dx = math.upright("d") + math.italic("x")
= P110 补充题四 1(2) #ac
#prob[试证明:若 $PP^(n)$ 中的由 $n$ 个不同向量所形成的向量组和 $PP^n$ 的一个基等价,则该向量组的任何一个排列也是 $PP^n$ 的一个基.]
即证明该向量组线性无关.
反设该向量组(不放设为 $seqn(alpha,n)$)线性相关,则 $dim L(seqn(alpha,n)) < n$,则必不可能与 $PP^n$ 的基等价,矛盾.
= P110 补充题四 3 #ac
#prob[
设 $AA,BB$ 是两个 $n$ 阶正交矩阵,且 $|AA BB| = -1$,试证明:
(1) $|AA^TT BB| = |AA BB^TT| = |AA^TT BB^TT| = -1$.
]
$
|AA BB| = |AA| dot |BB| = |AA^TT| dot |BB| = |AA^TT BB| = -1
$
其余两项同理.
#prob[
(2) $|AA + BB| = 0$.
]
根据正交矩阵的性质,有 $AA^TT AA = AA^(-1)AA = EE$.
$
|AA BB| dot |AA + BB|
= |AA^TT AA BB^TT + AA^TT BB BB^TT|
= |BB^TT + AA^TT|
= |(BB + AA)^TT|
= |AA + BB|
$
由于 $|AA + BB| = -|AA + BB|$,故只可能 $|AA + BB| = 0$.
= P183 习题八 2(1) #ac
#prob[判断如下定义的映射是不是一个内积:$ (alpha,beta) = display(sqrt(sum_(i=1)^n a_i^2 b_i^2)) $]
$
(alpha+beta, gamma) &= sqrt(sum_(i=1)^n (a_i + b_i)^2 y_i^2)\
(alpha,gamma) + (beta,gamma) &= sqrt(sum_(i=1)^n a_i^2 y_i^2) + sqrt(sum_(i=1)^n b_i^2 y_i^2)
$
考虑
$
&(alpha+beta,gamma)^2 - ((alpha,gamma) + (beta,gamma))^2 \
=& sum_(i=1)^n (a_i^2 + 2 a_i b_i + b_i^2) y_i^2
- sum_(i=1)^n a_i^2 y_i^2
- sum_(i=1)^n b_i^2 y_i^2
- 2 sqrt((sum_(i=1)^n a_i^2 y_i^2)(sum_(i=1)^n b_i^2 y_i^2) )\
=& 2 (sum_(i=1)^n a_i b_i y_i^2 - sqrt((sum_(i=1)^n a_i^2 y_i^2)(sum_(i=1)^n b_i^2 y_i^2)))
$
不一定为 $0$,故该映射不是内积.
= P183 习题八 2(2) #wa
#prob[判断如下定义的映射是不是一个内积:$ (alpha,beta) = display((sum_(i=1)^n a_i) (sum_(j=1)^n b_j)) $]
$
(alpha,beta) = (sum_(i=1)^n a_i) (sum_(j=1)^n b_j) = (sum_(j=1)^n b_j) (sum_(i=1)^n a_i) = (beta,alpha)\
(alpha,alpha) = (sum_(i=1)^n a_i) (sum_(j=1)^n a_j) = (sum_(i=1)^n a_i)^2 >= 0\
(k alpha, beta) = (sum_(i=1)^n k a_i) (sum_(j=1)^n b_j) = k (sum_(i=1)^n a_i) (sum_(j=1)^n b_j) = k (alpha, beta)\
(alpha+beta, gamma) = (sum_(i=1)^n (a_i + b_i)) (sum_(j=1)^n y_j) = (sum_(i=1)^n a_i + sum_(i=1)^n b_i) (sum_(j=1)^n y_j) = (alpha,gamma) + (beta,gamma)\
$
故该映射是内积.
#warn[
不满足 $(alpha,alpha) = 0$ 时 $alpha = theta$.所以该映射不是内积.
]
= P183 习题八 2(3) #ac
#prob[判断如下定义的映射是不是一个内积:$ (alpha,beta) = display(sum_(i=1)^n c_i a_i b_i) sp (c_i>0,sp i=1,2,dots.c,n) $]
$
(alpha,beta) = sum_(i=1)^n c_i a_i b_i = sum_(i=1)^n c_i b_i a_i = (beta,alpha)\
(alpha,alpha) = sum_(i=1)^n c_i a_i a_i = sum_(i=1)^n c_i a_i^2 >= 0\
(k alpha, beta) = sum_(i=1)^n c_i (k a_i) b_i = k sum_(i=1)^n c_i a_i b_i = k (alpha,beta)\
(alpha+beta,gamma) = sum_(i=1)^n c_i (a_i+b_i) y_i = sum_(i=1)^n c_i a_i y_i + sum_(i=1)^n c_i b_i y_i = (alpha,gamma) + (beta,gamma)
$
故该映射是内积.
= P184 习题八 4 #ac
#prob[
欧式空间 $V$ 中的两个向量 $alpha$ 和 $beta$ 的距离定义为 $d(alpha,beta) = |alpha-beta|$,证明:
$
d(alpha,gamma) <= d(alpha, beta) + d(beta, gamma)
$
]
即证:
$
||alpha - gamma|| <= ||alpha - beta|| + ||beta - gamma||
$
取 $eta_1 = (alpha-beta),sp eta_2 = (beta - gamma)$,即证三角不等式:
$
||eta_1 + eta_2|| <= ||eta_1|| + ||eta_2||
$
有
$
&||eta_1+eta_2||^2 = (eta_1+eta_2,eta_1+eta_2) = (eta_1,eta_1) + 2(eta_1,eta_2) + (eta_2,eta_2)\
<=& ||eta_1||^2 + 2 ||eta_1||||eta_2|| + ||eta_2||^2 = (||eta_1|| + ||eta_2||)^2
$
= P184 习题八 5 #ac
#prob[
证明:在一个具有内积 $(dot,dot)$ 的欧式空间内,对任意向量 $alpha,beta$,以下等式成立:
(1) $||alpha+beta||^2 + ||alpha-beta||^2 = 2 ||alpha||^2 + 2 ||beta||^2$.
(2) $(alpha,beta) = display(1/4 ||alpha+beta||^2 - 1/4 ||alpha-beta||^2)$.
]
$
||alpha+beta||^2 = (alpha+beta,alpha+beta) = (alpha,alpha) + 2 (alpha,beta) + (beta,beta)\
||alpha-beta||^2 = (alpha+beta,alpha+beta) = (alpha,alpha) - 2 (alpha,beta) + (beta,beta)\
$
两式相加得:
$
||alpha+beta||^2 + ||alpha-beta||^2 = 2 ||alpha||^2 + 2 ||beta||^2
$
两式相减得
$
||alpha+beta||^2 - ||alpha-beta||^2 = 4 (alpha,beta)
=> (alpha,beta) = 1/4 ||alpha+beta||^2 - 1/4 ||alpha-beta||^2
$
= P184 习题八 6 #ac
#prob[
(1) 证明:线性空间 $RR[x]_3$ 在如下定义的映射下成为内积空间:
$
(f(x),g(x)) = integral_(-1)^1 f(x) g(x) dx,quad
forall f(x),g(x) in RR[x]_3
$
]
$
(f(x), g(x)) &= integral_(-1)^1 f(x) g(x) dx = integral_(-1)^1 g(x) f(x) dx = (g(x), f(x))\
(f(x), f(x)) &= integral_(-1)^1 f^2(x) dx >= 0\
(k f(x), g(x)) &= integral_(-1)^1 (k f(x)) g(x) dx = k integral_(-1)^1 f(x) g(x) dx = k (f(x), g(x))\
(f(x) + g(x), h(x)) &= integral_(-1)^1 (f(x) + g(x)) h(x) dx\
&= integral_(-1)^1 f(x) h(x) dx + integral_(-1)^1 g(x) h(x) dx\
&= (f(x),h(x)) + (g(x),h(x))\
$
综上所述,线性空间 $RR[x]_3$ 在如题设定义的映射下可以成为一个欧氏空间.
#prob[(2) 在如 (1) 定义的内积空间中求一个多项式 $f(x)$ 使得 $f(x)$ 与 $1+x,1-x$ 均正交.]
设该多项式为 $f(x) = a_0 + a_1 x + a_2 x^2$,考虑
$
&integral_(-1)^1 (1+x)(a_0 + a_1 x + a_2 x^2) dx
= integral_(-1)^1 (a_0 + (a_0+a_1) x + (a_1+a_2) x^2 + a_2 x^3) dx = 0\
=>& a_0 + 1/3(a_1 + a_2) = 0 => 3a_0 + a_1 + a_2 = 0\
&integral_(-1)^1 (1+x)(a_0 + a_1 x + a_2 x^2) dx
= integral_(-1)^1 (a_0 + (-a_0+a_1) x + (-a_1+a_2) x^2 - a_2 x^3) dx = 0\
=>& a_0 + 1/3(-a_1 + a_2) = 0 => 3a_0 - a_1 + a_2 = 0\
$
取 $a_0 = -1,sp a_1 = 0,sp a_2 = 3$,可得 $f(x) = 3x^2 - 1$.
= P184 习题八 7 #pc
#prob[
设 $seqn(alpha,n)$ 是具有内积 $(dot,dot)$ 的欧式空间 $V$ 的一个基,证明:
(1) 如果 $gamma in V$,且 $(gamma,alpha_i)=0 sp(i=1,2,dots.c,n)$,那么 $gamma = theta$.
]
#answer[
由于 $gamma in V$,故可以表示为 $gamma = k_1 alpha_1 + k_2 alpha_2 + dots.c + k_n alpha_n$,故
$
(gamma,gamma) &= (gamma,k_1 alpha_1 + k_2 alpha_2 + dots.c + k_n alpha_n)\
&= k_1 (gamma,alpha_1) + k_2 (gamma,alpha_2) + dots.c + k_n (gamma,alpha_n) = 0
$
所以 $gamma = theta$.
]
#prob[(2) 如果 $gamma_1,gamma_2 in V$,且 $forall alpha in V$ 有 $(gamma_1,alpha) = (gamma_2,alpha)$,那么 $gamma_1=gamma_2$.]
有 $forall alpha in V$,$(gamma_1 - gamma_2, alpha) = 0$,由 (1) 的结论得 $gamma_1 - gamma_2 = theta$ 即 $gamma_1 = gamma_2$.
= P184 习题八 8 #ac
#prob[在例 2 定义的内积空间 $C_([-1,1])$ 中,利用 Schmidt 正交化过程将向量组 $epsilon_1=1,sp epsilon_2=x, epsilon_3=x^2$ 改造成一个标准正交向量组.]
$
&eta_1 = epsilon_1 = 1\
&eta_2 = epsilon_2 - ((epsilon_2,eta_1))/((eta_1,eta_1)) eta_1 = epsilon_2 - 0 eta_1 = epsilon_2 = x\
&eta_3 = epsilon_3 - ((epsilon_3,eta_1))/((eta_1,eta_1)) eta_1 - ((epsilon_3,eta_2))/((eta_2,eta_2)) eta_2 = epsilon_3 - 1/3 eta_1 - 0eta_2 = x^2 - 1/3
$
= P184 习题八 10(1) #ac
#prob[
设 $xi_1,xi_2,xi_3$ 是三维欧式空间中的一个标准正交基,证明:
$
alpha_1 = 1/3 (2 xi_1 + 2 xi_2 - xi_3)\
alpha_2 = 1/3 (2 xi_1 - xi_2 + 2 xi_3)\
alpha_3 = 1/3 (xi_1 - 2 xi_2 - 2 xi_3)\
$
也是一个标准正交基.
]
由于 $xi_1,xi_2,xi_3$ 是一组标准正交基,所以
$
(alpha_1,alpha_1) = 1/9 (4 + 4 + 1) = 1, quad
(alpha_2,alpha_2) = 1/9 (4 + 1 + 4) = 1, quad
(alpha_3,alpha_3) = 1/9 (1 + 4 + 4) = 1\
(alpha_1,alpha_2) = 1/9 (4 - 2 - 2) = 0, quad
(alpha_1,alpha_3) = 1/9 (2 - 4 + 2) = 0, quad
(alpha_2,alpha_3) = 1/9 (2 + 2 - 4) = 0\
$
故 $alpha_1,alpha_2,alpha_3$ 也是一组标准正交基.
= P184 习题八 10(2) #ac
#prob[
设 $xi_1,xi_2,xi_3,xi_4,xi_5$ 是五维欧式空间 $V$ 中的一个标准正交基,令:
$
alpha_1 = xi_1 + xi_5,quad
alpha_2 = xi_1 - xi_2 + xi_4,quad
alpha_3 = 2 xi_1 + xi_2 + xi_3
$
求 $V_1 = L(alpha_1,alpha_2,alpha_3)$ 的一个标准正交基.
]
写出 $alpha_1,alpha_2,alpha_3$ 在 $seqn(xi,5)$ 下对应的下标所构成的矩阵为:
$
mat(
1,1,2;
0,-1,1;
0,0,1;
0,1,0;
1,0,0;
) -> mat(
1,0,0;
0,1,0;
0,0,1;
0,0,0;
0,0,0;
)
$
故 $dim(V_1) = 3$.通过 Schmidt 正交化法得一组正交基
$
beta_1 &= alpha_1 = xi_1 + xi_5\
beta_2 &= alpha_2 - ((alpha_2,beta_1))/((beta_1,beta_1)) beta_1 = alpha_2 - 1/2 beta_1 = 1/2 xi_1 - xi_2 + xi_4 - 1/2 xi_5\
beta_3 &= alpha_3 - ((alpha_3,beta_1))/((beta_1,beta_1)) beta_1 - ((alpha_3,beta_2))/((beta_2,beta_2)) beta_2 = alpha_3 - 2/2 beta_1 - 0 beta_2 = xi_1 + xi_2 + xi_3 - xi_5
$
对其标准化得标准正交基
$
eta_1 &= 1/sqrt(2) (xi_1 + xi_5)\
eta_2 &= 1/sqrt(10) (xi_1 - 2 xi_2 + 2 xi_4 - xi_5)\
eta_3 &= 1/2 (xi_1 + xi_2 + xi_3 - xi_5)\
$
= P185 补充题八 1 #pc
#prob[
设 $seqn(alpha,m)$ 是具有内积 $(dot,dot)$ 的 $n$ 维欧式空间 $V$ 中的一组向量,称
#set math.mat(delim: "|")
$
G(seqn(alpha,m)) = mat(
(alpha_1,alpha_1),(alpha_1,alpha_2),dots.c,(alpha_1,alpha_m);
(alpha_2,alpha_1),(alpha_2,alpha_2),dots.c,(alpha_2,alpha_m);
dots.v,dots.v,,dots.v;
(alpha_m,alpha_1),(alpha_m,alpha_2),dots.c,(alpha_m,alpha_m);
)
$
#set math.mat(delim: "(")
为 Gram 行列式,试证明:$seqn(alpha,m)$ 线性相关当且仅当 $G(seqn(alpha,m)) = 0$.
]
$=>$:线性相关:$alpha_m = k_1 alpha_1 + k_2 alpha_2 + dots.c + k_(m-1) alpha_(m-1)$,可通过初等行变换将最后一行消成 $0$.
$arrow.double.l$:由于 $G(seqn(alpha,m)) = 0$,可知矩阵不满秩,即存在不为 $0$ 的一组 $seqn(k,m)$ 使得 $forall j in [1,m],sp sum_(i=1)^m k_i (alpha_j, alpha_i) = 0$,即 $forall j in [1,m],sp (alpha_j, sum_(i=1)^m k_i alpha_i) = 0$.可以进一步得到:$(sum_(j=1)^m k_j alpha_j, sum_(i=1)^m k_i alpha_i) = 0$,根据欧氏空间的正定性,有 $sum_(i=1)^m k_i alpha_i = 0$,即 $seqn(alpha,m)$ 线性相关.
#note[看了点提示做出来的.]
= P185 补充题八 3 #wa
#prob[
设 $seqn(alpha,n)$ 是具有内积 $(dot,dot)$ 的 $n$ 维欧式空间 $V$ 的一个基,证明:这个基为 $V$ 的一个标准正交基的充分必要条件为对于 $V$ 中任意两个向量 $alpha,beta$,若
$
alpha &= x_1 alpha_1 + x_2 alpha_2 + dots.c + x_n alpha_n\
beta &= y_1 alpha_1 + y_2 alpha_2 + dots.c + y_n alpha_n\
$
则必有 $(alpha,beta) = x_1 y_1 + x_2 y_2 + dots.c + x_n y_n$.
]
$=>$:显然.
$arrow.double.l$:不会.
#answer[
$=>$:由题意,其度量矩阵为 $EE$,故 $(alpha,beta) = alpha^TT EE beta = alpha^TT beta$.
$arrow.double.l$:由于对于任意 $alpha,beta in V$ 都成立,代入可得 $display((alpha_i,alpha_j) = cases(1\,quad i!=j,0\,quad i=j))$.故 $seqn(alpha,n)$ 是一组标准正交基.
]
= P185 补充题八 4 #pc
#prob[
设 $seqn(alpha,n)$ 是具有内积 $(dot,dot)$ 的 $n$ 维欧式空间 $V$ 的一个基,证明:这个基是 $V$ 中的一个标准正交基当且仅当 $forall alpha in V$,有
$
alpha = (alpha,alpha_1) alpha_1 + (alpha,alpha_2) alpha_2 + dots.c + (alpha,alpha_n) alpha_n
$
]
设 $alpha = k_1 alpha_1 + k_2 alpha_2 + dots.c + k_n alpha_n$,$AA = ((alpha_i,alpha_j))_(n times n)$,则
$
alpha = AA alpha
$
对于任意 $alpha in V$ 都成立,故只可能 $AA$ 是单位矩阵,即设 $bold(U) = vecn(alpha,n)$ 有 $bold(U)^TT bold(U) = EE$,即 $seqn(alpha,n)$ 是 $V$ 的一组标准正交基.
#warn[这个不严谨,应用上面类似的方法,两个方向分别证明,反过来的时候取一些特殊值代入来得到想要的结果.]
= P185 补充题八 5 #ac
#prob[
设 $seqn(alpha,s) in RR^n$ 线性无关,令 $bold(A) = vecn(alpha,s)$.设 $seqn(beta,n-s)$ 为齐次线性方程组 $AA^TT bold(X) = bold(O)$ 的一个基础解系,证明:
$
seqn(alpha,s),seqn(beta,n-s)
$
为 $RR^n$ 的一个基.
]
设 $bold(X) = k_1 beta_1 + k_2 beta_2 + dots.c + k_(n-s) beta_(n-s)$,其中 $seqn(k,n-s)$ 是任意一组非全零的实数.由已知得:
$
alpha_i^TT bold(X) = (alpha_i, bold(X)) = k_1 (alpha_i,beta_1) + k_2 (alpha_i,beta_2) + dots.c + k_(n-s) (alpha_i,beta_(n-s)) = 0 sp (i=1,2,dots.c,s)
$
取 $k_1=1,k_2=k_3=dots.c=k_(n-s)=0$ 得 $(alpha_1,beta_j)=1 sp (j=1,2,dots.c,n-s)$.同理得:
$
forall 1<=i<=s and 1<=j<=n-s,sp (alpha_i,beta_j) = 0
$
反设 $seqn(alpha,s),seqn(beta,n-s)$ 线性相关,则 $alpha_1$ 可被表示为($l_2,l_3,dots.c,l_n$ 是一组不全为零的实数)
$
alpha_1 = l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s + l_(s+1) beta_1 + dots.c + l_n beta_(n-s)
$
则
$
(alpha_1,alpha_1)
&= (alpha_1,l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s + l_(s+1) beta_1 + dots.c + l_n beta_(n-s))\
&= (alpha_1, l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s)\
&= (l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s + l_(s+1) beta_1 + dots.c + l_n beta_(n-s),l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s)\
&= (l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s,l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s)\
$
故 $norm(alpha_1) = norm(l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s)$ 且 $cos <alpha,l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s> = 1$,即
$
alpha = l_2 alpha_2 + l_3 alpha_3 + dots.c + l_s alpha_s
$
与 $seqn(alpha,s)$ 是一组线性无关的向量矛盾,故 $seqn(alpha,s),seqn(beta,n-s)$ 线性无关.
= P185 补充题八 6 #ac
#prob[
设 $alpha,beta$ 是具有内积 $(dot,dot)$ 的 $n$ 维欧式空间 $V$ 中的两个不同的向量且 $|alpha| = |beta| = 1$,证明:$(alpha,beta) != 1$.
]
反设 $(alpha,beta) = 1$,那么两向量夹角 $display(theta = arccos ((alpha,beta))/(||alpha|| dot ||beta||) = arccos 1 = 0)$,此时两向量重合.
故两向量不重合时,$(alpha,beta) != 1$.
#warn[没答案.] |
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/hydra/0.3.0/src/util.typ | typst | Apache License 2.0 | #import "/src/util/assert.typ"
#import "/src/util/core.typ"
#import "/src/util/core.typ": fmt
#import "/src/util/page-sizes.typ": page-sizes
#import "/src/util/queryable-functions.typ": queryable-functions
|
https://github.com/jamesrswift/pixel-pipeline | https://raw.githubusercontent.com/jamesrswift/pixel-pipeline/main/src/pipeline/middleware.typ | typst | The Unlicense | #let apply(input, output, layers) = {
if layers.len() == 0 {return output}
(layers.first())(input, output,
(input, output) => apply(input, output, layers.slice(1))
)
}
#let stack(layers, key) = {
layers.map(layer=>layer.at(key, default: none))
.filter(it=>it!=none)
}
#let through-layers(layers, key) = (input, output) => apply(
input,
output,
stack(layers, key)
) |
https://github.com/francescoo22/masters-thesis | https://raw.githubusercontent.com/francescoo22/masters-thesis/main/chapters/3-Related-Work.typ | typst | #pagebreak(to:"odd")
= Related Work<cap:related-work>
This chapter first outlines the foundational principles established in _the Geneva Convention on the Treatment of Object Aliasing_ @GenevaConvention, which serves as a fundamental reference for any work addressing aliasing issues.
Then, it provides an overview of existing approaches to managing uniqueness in programming languages, focusing on the design choices that have influenced the development of the uniqueness system proposed in this work.
Finally, the chapter examines current systems that utilize Viper for verification, providing a critical analysis of their strengths and limitations.
== The Geneva Convention
The Geneva Convention @GenevaConvention examines the issues related to aliasing management in object-oriented programming languages.
After introducing the aliasing problem, the paper establishes four primary methods to manage aliasing: Detection, Advertisement, Prevention, and Control.
=== Detection
Alias detection is a retrospective process that identifies potential or actual alias patterns in a program using static or dynamic techniques. This is beneficial for compilers, static analysis tools, and programmers, as it helps detect aliasing conflicts, enables more efficient code generation, identifies cases where aliasing may invalidate predicates, and assists in resolving problematic conflicts. However, alias detection requires complex interprocedural analysis due to its non-local nature, which can make comprehensive analyses too slow to be practical.
For this reason, this approach is not adopted in this work.
=== Advertisement
Given the impracticality of global detection, it is essential to create techniques and constructs that enable a more modular approach to analysis. Constructs that improve the locality of analysis by annotating methods based on their resulting aliasing behaviors can be useful for both programmers and formalists.
One example of this concept is to specify that the output of a function is not aliased anywhere else in the program, signifying that it is unique. Additionally, an "uncaptured" qualifier could state that an object is never assigned to a variable that might lead to further modifications through side channels once the method has returned.
=== Prevention
Alias prevention techniques introduce constructs that ensure aliasing does not occur in specific contexts, in a way that can be statically verified.
This differs from alias advertisement, where annotations enable a modular analysis but are not checked.
For static checkability, constructs must be conservatively defined. For instance, a checkable version of "uncaptured" might restrict all variable bindings within a method, except when calling other methods that also have uncaptured attributes. This approach would forbid uses that programmers may happen to know as alias-free but cannot be statically checked to be safe.
As will be illustrated in @cap:annotations-kt and in @cap:annotation-system, the uniqueness system developed in this work falls into this category, as it employs conservative annotations to enforce alias prevention in a manner that can be statically verified.
=== Control
Aliasing prevention alone may not be sufficient because aliasing can be unavoidable in conventional object-oriented programming.
In aliasing control, the programmer determines that the system will never reach a state where unexpected aliasing occurs, even though this possibility cannot be ruled out when examining code components individually. This is verified through an analysis of state reachability.
== Systems for Controlling Aliasing
In recent decades, extensive research has been conducted to address the issue of aliasing. The book _Aliasing in Object-Oriented Programming_ @Aliasing-OOP provides a comprehensive survey of the latest techniques for managing aliasing in object-oriented programming.
=== Controlling Aliasing through Uniqueness<cap:control-alias-unique>
A uniqueness type system distinguishes values referenced no more than once from values that can be referenced multiple times in a program. Harrington's _Uniqueness Logic_ @uniqueness-logic provides a formalization of the concept of uniqueness.
While it may initially appear similar to the more widely known _Linear Logic_ @linear-logic, Marshall et al. @An-Entente-Cordiale clarify the differences between these two approaches and demonstrate how they can coexist.
The common trait of all systems based on uniqueness is that a reference declared as unique points to an object that is not accessible by any other reference, unless such references are explicitly tracked by the system. Moreover, the unique status of a reference can be dropped at any point in the program.
A first approach to ensuring uniqueness consists of using destructive reads. Aldrich et al. @aldrich2002alias have developed a system called AliasJava for controlling aliasing which uses this approach.
AliasJava is characterized by a strong uniqueness invariant asserting that "at a particular point in dynamic program execution, if a variable or field that refers to an object `o` is annotated unique, then no other field in the program refers to `o`, and all other local variables that refer to `o` are annotated lent".
This invariant is maintained by the fact that unique references can only be read in a destructive manner, meaning that immediately after being read, the value `null` is assigned to the reference.
Boyland @boyland2001alias proposes a system for controlling aliasing in Java that does not require to use destructive reads.
The system utilizes a set of annotations to distinguish between different types of references. Specifically, procedure parameters and return values can be annotated as unique, indicating that they are not aliased elsewhere. Conversely, parameters and return values that are not unique are classified as shared. Within the system, a shared parameter may also be declared as borrowed, meaning that the function will not create further aliases for that parameter. Finally, fields can be marked as unique; if not, they are treated as shared.
The main contribution of Boyland's work is the introduction of the "alias burying" rule: "When a unique field of an object is read, all aliases of the field are made undefined". This means that aliases of a unique field are allowed if they are assigned before being used again. The "alias burying" rule is important because it allows to avoid having destructive reads for unique references.
On the other hand, having a shared reference does not provide any guarantee on the uniqueness of that reference.
Finally the object referred to by a borrowed parameter may not be returned from a procedure, assigned to a field or passed as a non-borrowed parameter.
Zimmerman et al. @zimmerman2023latte propose an approach to reduce both the volume of annotations and the complexity of invariants necessary for reasoning about aliasing in an object-oriented language with mutation.
The system requires minimal annotations from the user: fields and return types can be annotated as unique or shared, while method parameters can be marked as unique, shared, or owned. For local variables, the system automatically infers the necessary information.
Furthermore, the system provides flexibility for uniqueness by permitting local variable aliasing, as long as this aliasing can be precisely determined.
A uniqueness invariant is defined as follows: "a unique object is stored at most once on the heap. In addition, all usable references to a unique object from the local environment are precisely inferred".
The system's analysis produces at each program point an "alias graph", that is an undirected graph whose nodes are syntactic paths and distinct paths $p_1$ and $p_2$ are connected iff $p_1$ and $p_2$ are aliased. Moreover a directed graph whose nodes are syntactic path called "reference graph" is also produced for every program point. Intuitively, having an edge from $p_1$ to $p_2$ in the reference graph means that the annotation of $p_1$ requires to be updated when $p_2$ is updated.
=== Programming Languages with Aliasing Guarantees
Recently, several programming languages have started to introduce type systems that provide strong guarantees regarding aliasing.
Rust is a modern programming language that prioritizes both high performance and static safety.
A key feature of Rust is its ownership-based type system @rustlang, which guarantees memory safety by preventing problems such as dangling pointers, data races, and unintended side effects from aliased references. The type system enforces strict rules, allowing memory to be either mutable or shared, but not both at the same time. This approach helps to avoid common memory errors and aligns Rust’s memory model with principles from separation logic, facilitating formal verification @jung2020understanding.
Swift is another language that has introduced constructs to manage aliasing effectively @swift-parameter-modifiers @swift-ownership-manifesto. By default, function arguments in Swift are passed by value, which means any modifications made within the function do not affect the original argument in the caller. However, parameters marked as `inout` behave differently. When a function is called with an `inout` parameter, the argument's value is copied. The function then works with this copy, and when it returns, the modified copy is assigned back to the original argument. Swift guarantees memory exclusivity, meaning that accessing an `inout` value from two different references simultaneously is prohibited, thereby preventing aliasing issues.
In addition to `inout`, Swift provides two other parameter modifiers to manage ownership more precisely. The `borrowing` modifier indicates that the function temporarily accesses the parameter's value without taking ownership, leaving the caller responsible for the object's lifetime. This approach minimizes overhead when the function uses the object only transiently. Conversely, the `consuming` modifier indicates that the function takes full ownership of the value, including the responsibility for either storing or destroying it before the function returns.
Finally, Granule @Granule is a language designed with a focus on fine-grained resource management. Its type system combines linear types, indexed types (lightweight dependent types), and graded modal types to enable advanced quantitative reasoning. This combination offers strong guarantees for memory management and aliasing, ensuring strict control over when and how resources can be accessed. Granule aims to demonstrate the reasoning power of combining linear, graded, and indexed types, particularly in the context of common language features such as data types, pattern matching, and recursion.
== Viper Verification Tools
Several verifiers have been built on top of Viper. The most relevant tools for this work are: Prusti, a verifier for the Rust programming language, Gobra, used to verify code written in Go, and Nagini, which can be used to verify Python programs.
All these tools require the user to add annotations to the code that has to be verified. However, the number of annotations needed is inversely proportional to the robustness of the language's type system. This is the reason why the verifier for the Rust language is able to verify significant properties even without annotations, while other verifiers cannot work without user-provided annotations.
=== Prusti
Based on the Viper infrastructure, Prusti @prusti1 @prusti2 is an automated verifier for Rust programs. It takes advantage of Rust's robust type system to make the specification and verification processes more straightforward.
By default, Prusti ensures that a Rust program will not encounter an unrecoverable error state causing it to terminate at runtime. This includes panics caused by explicit `panic!(...)` calls as well as those from bounds-checks or integer overflows.
In addition to use Prusti to ensure that programs are free from runtime panics, developers can gradually add annotations to their code, thereby achieving increasingly robust correctness guarantees and improving the overall reliability and safety of their software.
In terms of Viper encoding, Rust structs are represented as potentially nested and recursive predicates representing unique access to a type instance. Furthermore, moves and straightforward usages of Rust's shared and mutable borrows are akin to ownership transfers within the permission semantics of separation logic assertions. Reborrowing is directly modeled using magic wands, Viper's counterpart to the separating implication in separation logic. When a reborrowed reference is returned to the caller, it includes a magic wand denoting the ownership of all locations from which borrowing occurred, except those currently in the proof.
=== Gobra
Go is a programming language that combines typical characteristics of imperative languages, like mutable heap-based data structures, with more unique elements such as structural subtyping and efficient concurrency primitives. This mix of mutable data and sophisticated concurrency constructs presents unique challenges for static program verification.
Gobra @gobra is a tool designed for Go that allows modular verification of programs. It can ensure memory safety, crash resistance, absence of data races, and compliance with user-defined specifications.
Compared to Prusti, Gobra generally requires more user-provided annotations. Benchmarks by Wolf et al. @gobra indicate that the annotation overhead varies from 0.3 to 3.1 lines of annotations per line of code.
=== Nagini
Nagini @nagini is a verification tool for statically-typed, concurrent Python programs. Its capabilities include proving memory safety, freedom from data races, and user-defined assertions.
Programs must follow to the static, nominal type system described in PEP 484 and implemented by the Mypy type checker to be compatible with Nagini. This type system requires type annotations for function parameters and return types, while types for local variables are inferred.
The tool includes a library of specification functions to express preconditions and postconditions, loop invariants, and other assertions.
By default, Nagini verifies several safety properties, ensuring that validated programs do not emit runtime errors or undeclared exceptions. Its permission system ensures that validated code is memory safe and free of data races. Moreover, the tool can verify functional properties, input/output properties and can ensue that no thread is indefinitely blocked when acquiring a lock or joining another thread, thus including deadlock freedom and termination.
Similarly to Gobra, Nagini requires a significant amount of annotations provided by the user and requires users to write fold operations. |
|
https://github.com/OrangeX4/typst-cheq | https://raw.githubusercontent.com/OrangeX4/typst-cheq/main/lib.typ | typst | MIT License | /// `unchecked-sym` function.
///
/// - `fill`: [`string`] - The fill color for the unchecked symbol.
/// - `stroke`: [`string`] - The stroke color for the unchecked symbol.
/// - `radius`: [`string`] - The radius of the unchecked symbol.
#let unchecked-sym(fill: white, stroke: rgb("#616161"), radius: .1em) = move(
dy: -.08em,
box(stroke: .05em + stroke, fill: fill, height: .8em, width: .8em, radius: radius),
)
/// `checked-sym` function.
///
/// - `fill`: [`string`] - The fill color for the checked symbol.
/// - `stroke`: [`string`] - The stroke color for the checked symbol.
/// - `radius`: [`string`] - The radius of the checked symbol.
#let checked-sym(fill: white, stroke: rgb("#616161"), radius: .1em) = move(
dy: -.08em,
box(
stroke: .05em + stroke,
fill: stroke,
height: .8em,
width: .8em,
radius: radius,
{
box(move(dy: .48em, dx: 0.1em, rotate(45deg, reflow: false, line(length: 0.3em, stroke: fill + .1em))))
box(move(dy: .38em, dx: -0.05em, rotate(-45deg, reflow: false, line(length: 0.48em, stroke: fill + .1em))))
},
),
)
/// `incomplete-sym` function.
///
/// - `fill`: [`string`] - The fill color for the incomplete symbol.
/// - `stroke`: [`string`] - The stroke color for the incomplete symbol.
/// - `radius`: [`string`] - The radius of the incomplete symbol.
#let incomplete-sym(fill: white, stroke: rgb("#616161"), radius: .1em) = move(
dy: -.08em,
box(
stroke: .05em + stroke,
fill: fill,
height: .8em,
width: .8em,
radius: radius,
{
box(fill: stroke, height: .8em, width: .4em, radius: (top-left: radius, bottom-left: radius))
},
),
)
/// `canceled-sym` function.
///
/// - `fill`: [`string`] - The fill color for the canceled symbol.
/// - `stroke`: [`string`] - The stroke color for the canceled symbol.
/// - `radius`: [`string`] - The radius of the canceled symbol.
#let canceled-sym(fill: white, stroke: rgb("#616161"), radius: .1em) = move(
dy: -.08em,
box(
stroke: .05em + stroke,
fill: stroke,
height: .8em,
width: .8em,
radius: radius,
{
align(center + horizon, box(height: .125em, width: 0.55em, fill: fill))
},
),
)
/// `checklist` function.
///
/// Example: `#show: checklist.with(fill: luma(95%), stroke: blue, radius: .2em)`
///
/// **Arguments:**
///
/// - `fill`: [`string`] - The fill color for the checklist marker.
/// - `stroke`: [`string`] - The stroke color for the checklist marker.
/// - `radius`: [`string`] - The radius of the checklist marker.
/// - `marker-map`: [`map`] - The map of the checklist marker. It should be a map of character to symbol function, such as `(" ": sym.ballot, "x": sym.ballot.x, "-": sym.bar.h, "/": sym.slash.double)`.
/// - `show-list-set-block`: [`dictionary`] - The configuration of the block in list. It should be a dictionary of `above` and `below` keys, such as `(above: .5em)`.
/// - `body`: [`content`] - The main body from `#show: checklist` rule.
///
/// The default map is:
///
/// ```typ
/// #let default-map = (
/// "x": checked-sym(fill: fill, stroke: stroke, radius: radius),
/// " ": unchecked-sym(fill: fill, stroke: stroke, radius: radius),
/// "/": incomplete-sym(fill: fill, stroke: stroke, radius: radius),
/// "-": canceled-sym(fill: fill, stroke: stroke, radius: radius),
/// ">": "➡",
/// "<": "📆",
/// "?": "❓",
/// "!": "❗",
/// "*": "⭐",
/// "\"": "❝",
/// "l": "📍",
/// "b": "🔖",
/// "i": "ℹ️",
/// "S": "💰",
/// "I": "💡",
/// "p": "👍",
/// "c": "👎",
/// "f": "🔥",
/// "k": "🔑",
/// "w": "🏆",
/// "u": "🔼",
/// "d": "🔽",
/// )
/// ```
#let checklist(
fill: white,
stroke: rgb("#616161"),
radius: .1em,
marker-map: (:),
show-list-set-block: (above: .5em),
body,
) = {
let default-map = (
"x": checked-sym(fill: fill, stroke: stroke, radius: radius),
" ": unchecked-sym(fill: fill, stroke: stroke, radius: radius),
"/": incomplete-sym(fill: fill, stroke: stroke, radius: radius),
"-": canceled-sym(fill: fill, stroke: stroke, radius: radius),
">": "➡",
"<": "📆",
"?": "❓",
"!": "❗",
"*": "⭐",
"\"": "❝",
"l": "📍",
"b": "🔖",
"i": "ℹ️",
"S": "💰",
"I": "💡",
"p": "👍",
"c": "👎",
"f": "🔥",
"k": "🔑",
"w": "🏆",
"u": "🔼",
"d": "🔽",
)
let marker-map = default-map + marker-map
show: body => {
if show-list-set-block != none {
show list: set block(..show-list-set-block)
body
} else {
body
}
}
show list.item: it => {
// The body should be a sequence
if not (type(it.body) == content and it.body.func() == [].func()) {
return it
}
let children = it.body.children
// A checklist item has at least 5 children: `[`, markder, `]`, space, content
if children.len() < 5 or not (children.at(0) == [#"["] and children.at(2) == [#"]"] and children.at(3) == [ ]) {
return it
}
let marker-text = if children.at(1) == [ ] {
" "
} else if children.at(1) == ["] {
"\""
} else if children.at(1) == ['] {
"'"
} else if children.at(1).has("text") {
children.at(1).text
} else {
none
}
if marker-text != none and marker-text in marker-map and marker-map.at(marker-text) != none {
list(
marker: marker-map.at(marker-text),
children.slice(4).sum(),
)
} else {
it
}
}
body
}
|
https://github.com/jordanqt327/Typst-Pruebas | https://raw.githubusercontent.com/jordanqt327/Typst-Pruebas/main/Typst/prueba2.typ | typst | = Writing the right set rules
#set page(
paper: "us-letter",
header: align(right)[
A fluid dynamic model for
glacier flow
],
numbering: "1",
)
#set par(justify: true)
#set text(
font: "Linux Libertine",
size: 11pt,
)
#lorem(200)
= Creating a title and abstract
#align(center, text(17pt)[
*A fluid dynamic model
for glacier flow*
])
#grid(
columns: (1fr, 1fr),
align(center)[
<NAME> \
Artos Institute \
#link("mailto:<EMAIL>")
],
align(center)[
Dr. <NAME> \
Artos Institute \
#link("mailto:<EMAIL>")
]
)
#align(center)[
#set par(justify: false)
*Abstract* \
#lorem(80)
]
Guardar titulo en una variable:
#let title = [
A fluid dynamic model
for glacier flow
o varieble
]
...
#set page(
header: align(
right + horizon,
title
),
)
#align(center, text(17pt)[
*#title*
])
= Adding columns and headings
#show: rest => columns(2, rest)
= Introduction
#lorem(300)
= Related Work
#lorem(200)
#table(
columns: 3,
table.header( [ "Nombre"], ["Edad"], ["Ciudad"],),
[ "Alice"], [30], ["Nue<NAME>" ],
[ "Bob"], [25], ["Los Ángeles" ],
[ "Charlie"], [35], ["Chicago" ]
)
|
|
https://github.com/robertjndw/typst-tum-presentation | https://raw.githubusercontent.com/robertjndw/typst-tum-presentation/main/theme.typ | typst | #import "@preview/polylux:0.3.1": *
#import "colors.typ": *
// State definitions
#let title-state = state("title-state", none)
#let date-state = state("date-state", none)
#let location-state = state("location-state", none)
#let author-state = state("author-state", none)
#let university-state = state("university-state", none)
#let school-state = state("school-state", none)
#let chair-state = state("chair-state", none)
#let footer-state = state("footer-state", none)
// Dictionary for translations
#let university-name = (en: "Technical University Munich", de: "Technische Universität München")
#let default-location = (en: "Munich", de: "München")
#let tum-theme(
aspect-ratio: "16-9",
lang: "en",
title: "Title of the TUM presentation",
location: none,
date: datetime.today(),
authors: (),
school: "TUM School of Musterverfahren",
chair: "Lehrstuhl für Mustertechnik",
footer-infos: (),
body
) = {
set document(
title: title,
author: authors,
date: datetime.today()
)
set page(
paper: "presentation-" + aspect-ratio,
margin: 0em,
header: none,
footer: none,
background: place(top + right,
pad(1cm, image("/resources/TUM-logo.svg", height: 1cm))
)
)
set text(lang: lang, font: "Arial", size: 14pt)
set block(spacing: 1em )
university-state.update(university-name.at(lang))
if location == none {
location-state.update(default-location.at(lang))
} else {
location-state.update(location)
}
title-state.update(title)
date-state.update(date.display("[day]. [month repr:long] [year]"))
author-state.update(authors.join(", "))
school-state.update(school)
chair-state.update(chair)
let complete_footer = authors + footer-infos
footer-state.update(complete_footer.join(" | "))
body
}
#let title-slide(flags: false) = {
polylux-slide({
if flags {
// TUM Background
place(center,
pad(image("/resources/TUM-flags.jpg", width: 100%, height: 100%))
)
place(top + right,
pad(1cm, image("/resources/TUM-logo-white.svg", height: 1cm))
)
} else {
// TUM Watermark
place(right + bottom,
pad(1cm, image("/resources/TUM-turm.jpg", height: 12cm))
)
}
set text(white) if flags
// Presentation information
pad(
x: 2cm,
y: 3cm,
{
text(title-state.display(), size: 25pt)
v(1cm)
stack(
dir: ttb,
spacing: 0.5cm,
author-state.display(),
university-state.display(),
school-state.display(),
chair-state.display(),
location-state.display() + ", " + date-state.display(),
)
}
)
})
}
#let empty-slide(body) = {
// Footer styling
let footer = {
set align(left + bottom)
set text(size: 11pt)
pad(
bottom: 0.4cm,
{
footer-state.display()
h(1fr)
logic.logical-slide.display()
}
)
}
// Page setup
set page(
margin: ( top: 3cm, bottom: 1cm, x: 1cm ),
footer: footer,
)
polylux-slide({
body
})
}
#let title-content-slide(title: "Title", body) = {
// Reuse empty-slide with predefined layout
empty-slide({
text(title, size: 25pt)
v(0.8cm)
body
})
}
#let title-image-slide(title: "Title", image_path: none) = {
// Reuse empty-slide with predefined layout
title-content-slide(title: title, {
if image != none {
align(center, image(image_path))
}
}
)
} |
|
https://github.com/7sDream/typst-easy-pinyin | https://raw.githubusercontent.com/7sDream/typst-easy-pinyin/master/README.md | markdown | MIT License | # Easy Pinyin
Write Chinese pinyin easily.
## Usage
Import the package:
```typst
#import "@preview/easy-pinyin:0.1.0": pinyin, zhuyin
```
With the `pinyin` function, you can use `a2` to write an `ɑ́`, `o3` to write an `ǒ`, `v4` to represent `ǜ`, etc.
With `zhuyin` function,you can put pinyin above the text easily, with parameters:
- position parameters:
- `doc: content|string`: main characters
- `ruby: content|string`: zhuyin characters
- named parameters:
- `scale: number = 0.7`: font size scale of `ruby`, default `0.7`
- `gutter: length = 0.3em`: spacing between `doc` and `ruby`, default `0.3em`
- `delimiter: string|none = none`: if not none, use this character to split `doc` and `ruby` into parts
- `spacing: length|none = none`: spacing between each parts
See example bellow.
## Example
```typst
汉(#pinyin[ha4n])语(#pinyin[yu3])拼(#pinyin[pi1n])音(#pinyin[yi1n])。
#let per-char(f) = [#f(delimiter: "|")[汉|语|拼|音][ha4n|yu3|pi1n|yi1n]]
#let per-word(f) = [#f(delimiter: "|")[汉语|拼音][ha4nyu3|pi1nyi1n]]
#let all-in-one(f) = [#f[汉语拼音][ha4nyu3pi1nyi1n]]
#let example(f) = (per-char(f), per-word(f), all-in-one(f))
// argument of scale and spacing
#let arguments = ((0.5, none), (0.7, none), (0.7, 0.1em), (1.0, none), (1.0, 0.2em))
#table(
columns: (auto, auto, auto, auto),
align: (center + horizon, center, center, center),
[arguments], [per char], [per word], [all in one],
..arguments.map(((scale, spacing)) => (
text(size: 0.7em)[#scale,#repr(spacing)],
..example(zhuyin.with(scale: scale, spacing: spacing))
)).flatten(),
)
```

## LICENSE
MIT, see License file.
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/layout/columns_01.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test the `columns` function.
#set page(width: auto)
#rect(width: 180pt, height: 100pt, inset: 8pt, columns(2, [
A special plight has befallen our document.
Columns in text boxes reigned down unto the soil
to waste a year's crop of rich layouts.
The columns at least were graciously balanced.
]))
|
https://github.com/suspenss/Undergraduate-mathematics | https://raw.githubusercontent.com/suspenss/Undergraduate-mathematics/main/Calculus/main.typ | typst | #import "./../setup/templates.typ": *
#import "./../setup/theorem.typ": *
#show: thmrules
// #show math.equation: set text(font: "New Computer Modern Math")
// #show math.equation: set text(font: "Libertinus Math")
#show math.ast: math.thin
#let obey = math.tilde
#show: project.with(
title: "Note on Calculus",
authors: (
"epoche",
),
language: "ch",
outl: [
#outline(indent: true, title: "目录", depth: 2)
],
)
//#show math.equation: set text(font: "New Computer Modern Math")
//#show math.equation: set text(font: "Libertinus Math")
// = 不定积分
// = 微分方程
// = 多元函数的微分学
= 重积分
== 二重积分
#definition()[
$ limits(integral.double)_D f(x, y) dif sigma = lim_(lambda -> 0) sum_(i = 1)^n f(xi_i, eta_i) sigma_i $
]
=== 直角坐标系
$ dif sigma = dif x dif y $
#formula()[
先横切再竖切 $
D := lr({ (x, y) | y in [c, d], x in [phi_1(y), phi_2(y)] }) \
limits(integral.double)_D f(x, y) dif x dif y
=
integral_c^d [integral_(phi_1(y))^(phi_2(y)) f(x, y) dif x] dif y \
$
Also represented as $
integral_(c)^(d) dif y integral_(phi_1(y))^(phi_1(y)) f(x, y) dif x
$
]
#formula()[
先竖切再横切 $
D := lr({ (x, y) | x in [a, b], y in [phi_1(x), phi_2(x)] }) \
limits(integral.double)_D f(x, y) dif x dif y
=
integral_(a)^(b) dif x integral_(phi_1(x))^(phi_1(x)) f(x, y) dif y
$
]
=== 极坐标系
#formula()[
$ limits(integral.double)_D f(rho cos theta , rho sin theta) rho dif rho dif theta
=
integral_alpha^beta dif theta integral_(phi_1(theta))^(phi_2(theta)) f(rho cos theta, rho sin theta) rho dif rho
$
]
== 三重积分
#definition()[
三重积分 \ $
limits(integral.triple)_Omega f(x, y, z) dif v
=
lim_(lambda -> 0) sum_(i = 1)^n f(xi_i, eta_i, zeta_i) Delta v_i
$
]
=== 直角坐标系
$
limits(integral.triple)_Omega f(x, y, z) dif v
=
limits(integral.triple)_Omega f(x, y, z) dif x dif y dif z
$
#formula()[
投影穿线法 : (先对 $z$ 积分, 再对 $x, y$ 做二重积分的处理)
将 封闭区域 $Omega$ 投影至 $x O y$ 面上得到封闭面 $D_(x y)$,因此: $
Omega := {(x, y, z) | z_1(x, y) <= z <= z_2(x, y), (x, y) in D_(x y)} \
D_(x y) := {(x, y) | y_1(x) <= y <= y_2(x), a <= x <= b} \
$
则 $
limits(integral.triple)_Omega f(x, y, z) dif v
=
integral_a^b dif x integral_(y_1(x))^(y_2(x)) dif y integral_(z_1(x, y))^(z_2(x, y)) f(x, y, z) dif z
$
]
#formula()[
投影切面法 :
记 $l$ 为 $Omega$ 在 $z$ 轴上的投影, $D_z$ 为 $Omega$ 在 $z = z$ 的截面: $
Omega := {(x, y, z) | x, y in D_z, a <= z <= b} \
limits(integral.triple)_Omega f(x, y, z) dif v = integral_a^b dif z limits(integral.double)_D_x f(x, y, z) dif x dif y
$
]
=== 柱坐标系
圆柱,圆锥,旋转体
#formula()[
$
limits(integral.triple)_Omega f(rho cos theta, rho sin theta, z) rho * dif rho * dif theta * dif z
= integral_alpha^beta dif theta integral_(phi_1(theta))^(phi_2(theta)) rho dif rho integral_(z_1)^(z_2) f(x, y, z) dif z
$
]
=== 球坐标系
积分区域与球有关
#definition()[
在球面坐标系中,球半径设为 $r$,$r$ 与 $z$ 轴的夹角设为 $phi$,$r$ 在 $x o y$ 面上的投影距离 $x$ 轴的夹角设为 $theta$,有:
$
cases(
z = r cos phi,
x = r sin phi cos theta,
y = r sin phi sin theta
)
$
体积元 $dif x dif y dif z = r^2 sin phi dif r dif phi dif theta$
]
#formula()[
$
I &= limits(integral.triple)_Omega f(r sin phi cos theta, r sin phi sin theta, r cos phi) * r^2 * sin phi * dif r * dif phi * dif theta \
&= integral_(theta_1)^(theta_2) dif theta integral_(phi_1)^(phi_2) dif phi integral_(r_1)^(r_2) F(r, phi, theta) * r^2 * sin phi * dif r
$
]
= 曲线积分和曲面积分
== 曲线积分
=== 对弧长的曲线积分
#definition()[ $
integral_L f(x, y) dif s = lim_(lambda -> 0) sum f(xi_i, eta_i) Delta s_i
$
]
#formula()[
有参数方程:$
L := cases( x = phi(t), y = psi(t) ) space space space space (alpha <= t <= beta) $
所以: $
integral_L f(x, y) dif s = integral_alpha^beta f[phi(t), psi(t)] sqrt(phi'^2(t) + psi'^2(t)) dif t space space (alpha < beta)
$
]
=== 对坐标的曲面积分
#definition()[
$
integral_L F(x, y) dot dif bold(r) & = integral_L P(x, y) dif x + Q(x, y) dif y \
& = lim_(lambda -> 0) sum_(i = 1)^n [Q (xi_i, eta_i) Delta y_i + P (xi_i, eta_i) Delta x_i]
$
]
#formula()[
有参数方程 $
cases(x = phi(t), y = psi(t))
$
则 $
I = &integral_L P(x, y) dif x + Q(x, y) dif y \
=
& integral_alpha^beta {P[phi(t), psi(t)] phi'(t) + Q[phi(t), psi(t)] psi'(t)} dif t
$
]
=== 格林公式
#formula()[
$
integral.cont_L P(x, y) dif x + Q(x, y) dif y = plus.minus limits(integral.double)_D ((diff Q)/(diff x) - (diff P)/(diff y)) dif x dif y
$
]
== 曲面积分
=== 对面积的曲面积分
#formula()[
$
& limits(integral.double)_Sigma f(x, y, z) dif S \
= & limits(integral.double)_(D_(x y)) f[x, y, z(x, y)] sqrt(1 + z_(x)^2 + z_(y)^2) dif x dif y
$
]
=== 对坐标的曲面积分
#formula()[
$
& limits(integral.double)_Sigma f(x, y, z) dif x dif y \
= & plus.minus limits(integral.double)_(D_(x y)) f[x, y, z(x, y)] dif x dif y
$
]
=== 高斯公式
#formula()[
$
& limits(integral.surf)_Sigma P dif y dif z + Q dif z dif x + R dif x dif y
= & limits(integral.triple)_Omega ((diff P)/(diff x) + (diff Q)/(diff y) + (diff R)/(diff z)) dif v
$
] |
|
https://github.com/Pegacraft/typst-plotting | https://raw.githubusercontent.com/Pegacraft/typst-plotting/master/example/main.typ | typst | MIT License | #import "/lib.typ": * // For local testing
//#import "@preview/plotst:0.1.0": *
#let print(desc: "", content) = {
desc
repr(content)
[ \ ]
}
#let scatter_plot_test() = {
let gender_data = (
("w", 1), ("w", 3), ("w", 5), ("w", 4), ("m", 2), ("m", 2), ("m", 4), ("m", 6), ("d", 1), ("d", 9), ("d", 5), ("d", 8), ("d", 3), ("d", 1)
)
let y_axis = axis(min: 0, max: 11, step: 1, location: "left", helper_lines: true, invert_markings: false, title: "foo", value_formatter: "{}€")
let y_axis_right = axis(min: 1, max: 11, step: 1, location: "right", helper_lines: false, invert_markings: false, title: "foo", stroke: 7pt + red, show_arrows: false, value_formatter: i => datetime(year: 1984, month: 1, day: i).display("[day].[month]."))
let gender_axis_x = axis(values: ("", "m", "w", "d"), location: "bottom", helper_lines: true, invert_markings: false, title: "Gender", show_arrows: false)
let pl = plot(data: gender_data, axes: (gender_axis_x, y_axis, y_axis_right))
scatter_plot(pl, (100%,50%))
let data = (
(0, 0), (2, 2), (3, 0), (4, 4), (5, 7), (6, 6), (7, 9), (8, 5), (9, 9), (10, 1)
)
let x_axis = axis(min: 0, max: 11, step: 2, location: "bottom")
let y_axis = axis(min: 0, max: 11, step: 2, location: "left", helper_lines: false, show_values: false)
let pl = plot(data: data, axes: (x_axis, y_axis))
scatter_plot(pl, (100%, 25%))
}
#let graph_plot_test() = {
let data = (
(0, 4), (2, 2), (3, 0), (4, 4), (5, 7), (6, 6), (7, 9), (8, 5), (9, 9), (10, 1)
)
let data2 = (
(0, 0), (2, 2), (3, 1), (4, 4), (5, 2), (6, 6), (7, 5), (8, 7), (9, 10), (10, 3)
)
let x_axis = axis(min: 0, max: 11, step: 2, location: "bottom")
let y_axis = axis(min: 0, max: 11, step: 2, location: "left", helper_lines: false)
let pl = plot(data: data, axes: (x_axis, y_axis))
graph_plot(pl, (100%, 25%), markings: [])
graph_plot(pl, (100%, 25%), rounding: 30%, caption: "Graph Plot with caption and rounding", markings: [#emoji.rocket])
}
#let histogram_test() = {
let data = (
18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000,28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 35000, 46000, 75000, 95000
)
let classes = class_generator(10000, 50000, 4)
classes.push(class(50000, 100000))
classes = classify(data, classes)
let x_axis = axis(min: 0, max: 100000, step: 10000, location: "bottom")
let y_axis = axis(min: 0, max: 31, step: 5, location: "left", helper_lines: true)
let pl = plot(data: classes, axes: (x_axis, y_axis))
histogram(pl, (100%, 40%), stroke: black, fill: (purple, blue, red, green, yellow))
}
#let histogram_test_2() = {
let classes = ()
classes.push(class(11, 13))
classes.push(class(13, 15))
classes.push(class(1, 6))
classes.push(class(6, 11))
classes.push(class(15, 30))
let data = ((20, 2), (30, 7), (16, 12), (40, 13), (5, 17))
let x_axis = axis(min: 0, max: 31, step: 1, location: "bottom", show_markings: false)
let y_axis = axis(min: 0, max: 41, step: 5, location: "left", helper_lines: true)
classes = classify(data, classes)
let pl = plot(axes: (x_axis, y_axis), data: classes)
histogram(pl, (100%, 40%))
}
#let pie_chart_test() = {
show: r => columns(2, r)
let data = ((10, "Male"), (20, "Female"), (15, "Divers"), (2, "Other"))
let data2 = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
let p = plot(data: data)
pie_chart(p, (100%, 20%), display_style: "legend-inside-chart")
pie_chart(p, (100%, 20%), display_style: "hor-chart-legend")
pie_chart(p, (100%, 20%), display_style: "hor-legend-chart")
pie_chart(p, (100%, 20%), display_style: "vert-chart-legend")
pie_chart(p, (100%, 20%), display_style: "vert-legend-chart")
}
#let bar_chart_test() = {
let data = ((10, "Monday"), (5, "Tuesday"), (15, "Wednesday"), (9, "Thursday"), (11, "Friday"))
let y_axis = axis(values: ("", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"), location: "left", show_markings: true)
let x_axis = axis(min: 0, max: 20, step: 2, location: "bottom", helper_lines: true)
let pl = plot(axes: (x_axis, y_axis), data: data)
bar_chart(pl, (100%, 33%), fill: (purple, blue, red, green, yellow), bar_width: 70%, rotated: true)
let data_2 = ((20, 2), (30, 7), (16, 12), (40, 13), (5, 17))
let y_axis_2 = axis(min: 0, max: 41, step: 5, location: "left", show_markings: true, helper_lines: true)
let x_axis_2 = axis(min: 0, max: 21, step: 1, location: "bottom")
let pl_2 = plot(axes: (x_axis_2, y_axis_2), data: data_2)
bar_chart(pl_2, (100%, 60%), bar_width: 100%)
}
// TODO
#let overlay_test() = {
let data_scatter = (
(0, 0), (2, 2), (3, 0), (4, 4), (5, 7), (6, 6), (7, 9), (8, 5), (9, 9), (10, 1)
)
let data_graph = (
(0, 3), (1, 5), (2, 1), (3, 7), (4, 3), (5, 5), (6, 7),(7, 4),(11, 6)
)
let x_axis = axis(min: 0, max: 11, step: 2, location: "bottom")
let y_axis = axis(min: 0, max: 11, step: 2, location: "left", helper_lines: false)
let pl_scatter = plot(data: data_scatter, axes: (x_axis, y_axis))
let scatter_display = scatter_plot(pl_scatter, (100%, 25%), stroke: red)
let pl_graph = plot(data: data_graph, axes: (x_axis, y_axis))
let graph_display = graph_plot(pl_graph, (100%, 25%), stroke: blue)
scatter_display
graph_display
overlay((scatter_display, graph_display), (100%, 25%))
x_axis = axis(min: 0, max: 11, step: 2, location: "bottom", show_values: false)
y_axis = axis(min: 0, max: 11, step: 2, location: "left", show_values: false)
let ice = (data: ((0,0),(3,3),(0,10)), axes: (x_axis, y_axis))
let a = graph_plot(ice, (100%, 25%), fill: blue.lighten(50%), markings: none, stroke: none, caption: "foo")
let water = (data: ((0,0),(3,3),(10,7), (10,0)), axes: (x_axis, y_axis))
let b = graph_plot(water, (100%, 25%), fill: blue, markings: none, stroke: none)
let steam = (data: ((3,3),(10,7),(10,10),(0,10)), axes: (x_axis, y_axis))
let c = graph_plot(steam, (100%, 25%), fill: yellow, markings: none, stroke: none)
overlay((a, b, c), (50%, 25%))
}
#let radar_test() = {
let data = (
(0,6),(1,7),(2,5),(3,4),(4,4),(5,7),(6,6),(7,6),
)
let y_axis = axis(min:0, max: 8, location: "left", helper_lines: true)
let x_axis = axis(min:0, max: 8, location: "bottom")
let pl = plot(data: data, axes: (x_axis, y_axis))
radar_chart(pl, (100%,60%))
}
#let function_test() = {
let data = function_plotter(x => {2*(x*x) + 3*x + 3}, 0, 8.3, precision: 100)
let data2 = function_plotter(x => {1*(x*x) + 3*x + 3}, 0, 11.4, precision: 100)
let x_axis = axis(min: 0, max: 20, step: 1, location: "bottom")
let y_axis = axis(min: 0, max: 151, step: 50, location: "left", helper_lines: true)
let p1 = graph_plot(plot(axes: (x_axis, y_axis), data: data), (100%, 50%), markings: [], stroke: red)
let p2 = graph_plot(plot(axes: (x_axis, y_axis), data: data2), (100%, 50%), markings: [], stroke: green)
overlay((p1, p2), (100%, 50%))
}
#let box_plot_test() = {
box_plot(box_width: 70%, pre_calculated: false, plot(axes: (
axis(values: ("", "(a)", "(b)", "(c)"), location: "bottom", show_markings: false),
axis(min: 0, max: 10, step: 1, location: "left", helper_lines: true),
),
data:((1, 3, 4, 4, 5, 6, 7, 8), (1, 3, 4, 4, 5, 7, 8), (1, 3, 4, 5, 7))
), (100%, 40%), caption: none)
}
#let cumsum_test() = {
datetime(year: 2023, month: 1, day: 20) - datetime.today()
let data = range(1,31).map(i=> (datetime(year: 2023, month: 1, day: i),2))
let dates = data.map(it => it.at(0))
let newdata = ()
let sum = 0
for d in data {
sum += d.at(1)
newdata.push((d.at(0).display(), sum))
}
let _ = newdata.remove(0)
let x_axis = axis(values: dates.map(it=> it.display()), location: "bottom")
let y_axis = axis(min: 0, max: sum, step: 10, location: "left")
graph_plot(plot(axes: (x_axis, y_axis), data: newdata), (100%, 50%))
}
#let box_plot_test() = {
box_plot(box_width: 70%, pre_calculated: false, plot(axes: (
axis(values: ("", "(a)", "(b)", "(c)"), location: "bottom", show_markings: false),
axis(min: -5, max: 100, step: 10, location: "left"),
),
data:((10, 20, 30, 50, 60), (5, 20, 25, 30, 45), (6, 19, 23, 37, 98))
), (100%, 40%), caption: none)
}
#let paper_test() = {
set par(justify: true)
pagebreak()
[
#set align(center)
= This is my paper
#set align(left)
#show: r => columns(2, r)
#lorem(100)
== Scatter plots
#lorem(50)
#{
let data = (
(0, 0), (1, 2), (2, 4), (3, 6), (4, 8), (5, 3), (6, 6),(7, 9),(11, 12)
)
let x_axis = axis(min: 0, max: 11, step: 1, location: "bottom")
let y_axis = axis(min: 0, max: 13, step: 2, location: "left", helper_lines: true)
let p = plot(data: data, axes: (x_axis, y_axis))
scatter_plot(p, (100%, 20%))
}
== Histograms
#lorem(150)
#{
let data = (
18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000,28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 28000, 35000, 46000, 75000, 95000
)
let classes = class_generator(10000, 50000, 4)
classes.push(class(50000, 100000))
classes = classify(data, classes)
let x_axis = axis(min: 0, max: 100000, step: 20000, location: "bottom", show_markings: false, title: "Wert x", )
let y_axis = axis(min: 0, max: 26, step: 3, location: "left", helper_lines: true, title: "Wert y und anderes Zeug", )
let pl = plot(data: classes, axes: (x_axis, y_axis))
histogram(pl, (100%, 20%), stroke: black, fill: gray)
}
== Pie charts
#{
lorem(120)
let data = ((10, "Male"), (20, "Female"), (15, "Divers"), (2, "Other"))
let pl = plot(data: data)
pie_chart(pl, (100%, 20%), display_style: "hor-chart-legend")
}
#{
let data = ((5, "0-18"), (9, "18-30"), (25, "30-60"), (7, "60+"))
let pl = plot(data: data)
pie_chart(pl, (100%, 20%), display_style: "hor-chart-legend")
lorem(200)
}
== Bar charts
#{
lorem(50)
let data = ((10, "Monday"), (5, "Tuesday"), (15, "Wednesday"), (9, "Thursday"), (11, "Friday"))
let y_axis = axis(values: ("", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"), location: "left", show_markings: true)
let x_axis = axis(min: 0, max: 20, step: 2, location: "bottom", helper_lines: true, title: "Visitors")
let pl = plot(axes: (x_axis, y_axis), data: data)
bar_chart(pl, (100%, 140pt), fill: (purple, blue, red, green, yellow), bar_width: 70%, rotated: true)
let data_2 = ((20, 2), (30, 3), (16, 4), (40, 6), (5, 7))
let y_axis_2 = axis(min: 0, max: 41, step: 10, location: "left", show_markings: true, helper_lines: true)
let x_axis_2 = axis(min: 0, max: 9, step: 1, location: "bottom")
let pl_2 = plot(axes: (x_axis_2, y_axis_2), data: data_2)
bar_chart(pl_2, (100%, 120pt), fill: (purple, blue, red, green, yellow), bar_width: 70%)
lorem(95)
}
]
}
#{
scatter_plot_test()
graph_plot_test()
pagebreak()
histogram_test()
histogram_test_2()
pagebreak()
pie_chart_test()
pagebreak()
bar_chart_test()
overlay_test()
radar_test()
function_test()
box_plot_test()
//cumsum_test()
paper_test()
}
// TODO:
// fix points when choosing rounding in graph plot <- Gewi
// bar chart <- Karla
// - make bars realign on right/top
// box plot <- Karla
// math graph (to display equations)
// graph overlapping. Should make it possible to lay one graph onto another. Usefull when wanting to draw mathematical equations into a scatter plot
// util for mean, median, quartil <- Karla
// titles for axes (partly done) <- Karla, Gewi
// fix axis titles being on wrong side
// xyarea chart gewi //done by fill: red i guess |
https://github.com/yhtq/Notes | https://raw.githubusercontent.com/yhtq/Notes/main/计算方法B/code/hw4/hw4.typ | typst | #import "../../../template.typ": *
#show: note.with(
title: "作业4",
author: "YHTQ",
date: datetime.today().display(),
logo: none,
withOutlined : false,
withTitle : false,
withHeadingNumbering: false
)
= 1.
Jacobi 迭代的迭代矩阵分别为:
$
M_1 = - diag{1/2, 1, -1/2} mat(0, -1, 1;1, 0, 1;1, 1, 0) = mat(0, -1/2, 1/2;1, 0, 1;-1/2, -1/2, 0)\
M_2 = - diag{1, 1, 1} mat(0, 2, -2;1, 0, 1;2, 2, 0)
$
计算可得 $M_1$ 有特征值 $-5/4$,而 $M_2$ 特征值只有 $0$,因此 Jacobi 迭代对于 $M_1$ 不收敛,对于 $M_2$ 收敛。
G-S 迭代的迭代矩阵分别为:
$
M_1 = - mat(2, 0, 0;1, 1, 0;1, 1, -2)^(-1) mat(0, 1, 1;0, 0, 1;0, 0, 0)\
= - mat(1/2, 0, 0;-1/2, 1, 0;0, 1/2, -1/2) mat(0, 1, 1;0, 0, 1;0, 0, 0)\
= mat(0, 1/2, 1/2;0, -1/2, 1/2; 0, 0, 1/2)\
M_2 = - mat(1, 0, 0;1, 1, 0;2, 2, 1)^(-1) mat(0, 2, -2;0, 0, 1;0, 0, 0)\
= -mat(1, 0, 0;-1, 1, 0;0, -2, 1)mat(0, 2, -2;0, 0, 1;0, 0, 0)\
= - mat(0, 2, -2;0, -2, 3;0, 0, -2)
$
$M_1$ 的特征值为 $0, plus.minus 1/2$,因此 G-S 迭代收敛。$M_2$ 的特征值为 $0, plus.minus 2$,因此 G-S 迭代不收敛。
= 2.
注意到 $B$ 的特征多项式为:
$
x^n
$
因此 $B^n = 0$。此外,假设 $x$ 是精确解,熟知:
$
(x_(k+1) - x) = B^k (x_1 - x)
$
因此取 $k = n$ 立得:
$
x_(n + 1) = x
$
= 3.
== (1)
使用顺序主子式的判别法,矩阵正定当且仅当所有顺序主子式均正,也即当且仅当:
$
1 - a^2 > 0 <=> a in (-1, 1)
$
== (2)
迭代矩阵为:
$
M = - diag{1, 1, 1}mat(0, 0, a;0, 0, 0;a, 0, 0) = - mat(0, 0, a;0, 0, 0;a, 0, 0)
$
特征多项式为 $lambda (lambda - a)(lambda + a)$,可见收敛当且仅当 $a in (-1, 1)$
== (3)
迭代矩阵为:
$
M = - mat(1, 0, 0;0, 1, 0;a, 0, 1)^(-1) mat(0, 0, a;0, 0, 0;0, 0, 0)\
= - mat(1, 0, 0;0, 1, 0;-a, 0, 1) mat(0, 0, a;0, 0, 0;0, 0, 0)\
= - mat(0, 0, a;0, 0, 0;0, 0, -a^2)
$
特征多项式为 $lambda^2 (lambda + a^2)$,收敛当且仅当 $a in (-1, 1)$
= 5.
注意到严格对角占优或不可约对角占优矩阵的 $abs(a_(i i)) > 0$,因此下三角矩阵 $D - L$ 是可逆的。假设迭代矩阵有特征值 $lambda$,即:
$
Inv((D - L)) U x = lambda x\
U x = lambda (D - L) x\
(lambda D - lambda L - U) x = 0
$
然而,假若 $abs(lambda) > 1$,将有 $lambda D - lambda L - U$ 仍是严格对角占优/不可约对角占优的,因此它非奇异,进而 $x = 0$,这是荒谬的。
|
|
https://github.com/justinvulz/typst_packages | https://raw.githubusercontent.com/justinvulz/typst_packages/main/poster.typ | typst | #import "@preview/cetz:0.2.2"
#import "@preview/fletcher:0.4.5" as fletcher: diagram,node,edge
#import fletcher.shapes:circle
#let margin_size = 2cm
#let body_font_size = 30pt
#let conf(
title,
author,
advisor: none,
logo: none,
main_color: rgb(35,80,120),
doc
) = {
set page(
paper: "a0",
margin: 0pt,
)
set text(size:body_font_size)
show stack: set block(spacing: 2em)
show grid: set block(spacing: 2em)
show par: set block(spacing: 1em)
show block: set block(spacing: 1em)
show figure: set block(spacing: 2em)
show list: set block(spacing: 1em)
// title
block(
width: 100%,
fill: main_color,
inset:margin_size,
)[
#align(center+horizon)[
#set text(fill: white)
#show par: set block(spacing: 0.5em)
#text(size:85pt)[
*#title*
]
#text(size: 56pt)[
*#author*
]
#if (advisor != none){
text(size: 56pt)[
, *Advisor: #advisor*
]
}
]
#if (logo != none){
place(top+right)[
#image(logo, width: 6em)
]
}
]
// block for heading
show heading.where(level: 1): h => {
align(center)[
#block(width: 100%,fill: main_color,inset: 0.45em)[
#text(size: 36pt,fill:white)[
*#h*
]
]
]
}
show heading.where(level:2): h => {
align(center)[
#block(width: 100%,fill: main_color,inset: 0.45em)[
#text(size: 30pt,fill:white)[
*#h*
]
]
]
}
show math.equation.where(block: true): e => [
// #set block(fill: lime)
#block(width: 100%, inset: 0.3em)[
#set align(center)
#set par(leading: 0.65em)
#e
]
]
// content
block(inset: margin_size)[
#columns(2)[
#doc
]
]
} |
|
https://github.com/Tiggax/zakljucna_naloga | https://raw.githubusercontent.com/Tiggax/zakljucna_naloga/main/src/additional.typ | typst | #let todo(body) = text(
fill: navy,
weight: "black",
//lang: "sl",
body
)
#let zahvala = [
I would like to thank my work mentor <NAME>, PhD, for offering me the opportunity to delve into the field of mathematical modeling of bioreactors.
His guidance, insights, and encouragement have been instrumental in shaping the direction and quality of this research.
I am also grateful to Assoc. Prof. <NAME>, PhD, who stepped in last minute and ensured that everything was prepared for my thesis.
His dedication and support was crucial in bringing this project to fruition in such a short timeframe.
]
#let izvleček = [
#set text(lang: "sl")
Zaključna naloga predstavlja podroben matematični model bioreaktorja z dovajanjem in uporabo celic kitajskega hrčka (CHO), ki so ključne za proizvodnjo biofarmacevtskih izdelkov.
Glavni cilj je optimizirati delovanje bioreaktorja s simulacijami, ki analizirajo vpliv različnih pogojev na rast celic in tvorbo produktov.
Diferencialne enačbe razmerji, rešene z metodo Runge-Kutta, natančno napovedujejo gostoto celic, porabo hranil in koncentracijo produktov skozi čas.
Optimizacija parametrov je dosežena z algoritmom Nelder-Mead, kar zagotavlja zanesljivost modela s prilagajanjem eksperimentalnim podatkom.
Naloga predstavi kompleksnost prileganja dinamike delovanja snovi v bioreaktorju z realnimi podatki v bioreaktorjih, in predstavi enostavni model za prihodnje delo modeliranja bioreaktorjev.
]
#let abstract = [
The final thesis presents a detailed mathematical model of a fed-batch bioreactor with use of Chinese Hamster (CHO) cells, which are crucial for the production of biopharmaceutical products.
The main goal is to optimize the operation of the bioreactor through simulations that analyze the influence of different conditions on cell growth and product formation.
The proportional differential equations solved by the Runge-Kutta method accurately predict cell density, nutrient consumption, and product concentration over time.
Parameter optimization is achieved using the Nelder-Mead algorithm, which ensures the reliability of the model by fitting experimental data.
The task presents the complexity of fitting the dynamics of substance action in a bioreactor with real data in bioreactors, and presents a simple model for future bioreactor modeling work.
]
#let git = [
Link to the Github repository of the app:
https://github.com/tiggax/bion
Key contents:
- *`src/model.rs`* - implementation of the bioreactor model
- *`src/regressor.rs`* - implementation of a regression cost function for the model
Link to the Github repository of the data:
https://github.com/tiggax/zakljucna_naloga
Key contents:
- *`podatki`* folder with the test data used for fitting in the thesis
- *`data`* folder with all of the generated data for the figures. This folder contains all of the data outputs of the results of the different system fits. It also contains `json` files needed to reload the state into the app.
- *`R-Scripts`* folder with scripts for result generation figures
Link to the Github repository of the `ode-solvers` library:
https://github.com/tiggax/ode-solvers
The branched use was `thesis_fix`
Key contents:
- *`src/dop_shared.rs`* contains the System trait, needed to be modified for mutable values to work
- *`src/rk4.rs`* contains the Runge-Kutta implementation, with two additional function with `mut_` prepend that were modified for system to work.
]
#import "@preview/sourcerer:0.2.1": code
#let source = figure(
caption: [Trait implementation],
kind: image,
code(raw(read("/data/model.rs"), lang: "Rust"), lines: (236,300), )
) |
|
https://github.com/liuguangxi/fractusist | https://raw.githubusercontent.com/liuguangxi/fractusist/main/README.md | markdown | MIT License | # Fractusist
Create a variety of wonderful fractals in Typst.
## Examples
The example below creates a dragon curve of the 12th iteration with the `dragon-curve` function.

<details>
<summary>Show code</summary>
```typ
#set page(width: auto, height: auto, margin: 0pt)
#dragon-curve(
12,
step-size: 6,
stroke-style: stroke(
paint: gradient.linear(..color.map.crest, angle: 45deg),
thickness: 3pt,
cap: "square"
)
)
```
</details>
## Features
- Use SVG backend for image rendering.
- Generate fractals using [L-system](https://en.wikipedia.org/wiki/L-system).
- The number of iterations, step size, fill and stroke styles, etc. of generated fractals could be customized.
## Usage
Import the latest version of this package with:
```typ
#import "@preview/fractusist:0.1.0": *
```
Each function generates a specific fractal. The input and output arguments of all functions have a similar style. Typical input arguments are as follows:
- `n`: the number of iterations (**the valid range of values depends on the specific function**).
- _`step-size`_: step size (in pt).
- _`fill-style`_: fill style, can be `none` or color or gradient (**exists only when the curve is closed**).
- _`stroke-style`_: stroke style, can be `none` or color or gradient or stroke object.
- _`width`_: the width of the image.
- _`height`_: the height of the image.
- _`fit`_: how the image should adjust itself to a given area, "cover" / "contain" / "stretch".
The content returned is the `image` element.
For more codes with these functions see [tests](./tests).
## Reference
### Dragon
- `dragon-curve`: Generate dragon curve (n: range **[0, 16]**).
```typ
#let dragon-curve(n, step-size: 10, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
### Hilbert
- `hilbert-curve`: Generate 2D Hilbert curve. (n: range **[1, 8]**).
```typ
#let hilbert-curve(n, step-size: 10, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
- `peano-curve`: Generate 2D Peano curve (n: range **[1, 5]**).
```typ
#let peano-curve(n, step-size: 10, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
### Koch
- `koch-curve`: Generate Koch curve (n: range **[0, 6]**).
```typ
#let koch-curve(n, step-size: 10, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
- `koch-snowflake`: Generate Koch snowflake (n: range **[0, 6]**).
```typ
#let koch-snowflake(n, step-size: 10, fill-style: none, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
### Sierpiński
- `sierpinski-curve`: Generate classic Sierpiński curve (n: range **[0, 7]**).
```typ
#let sierpinski-curve(n, step-size: 10, fill-style: none, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
- `sierpinski-square-curve`: Generate Sierpiński square curve (n: range **[0, 7]**).
```typ
#let sierpinski-square-curve(n, step-size: 10, fill-style: none, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
- `sierpinski-arrowhead-curve`: Generate Sierpiński arrowhead curve (n: range **[0, 8]**).
```typ
#let sierpinski-arrowhead-curve(n, step-size: 10, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
- `sierpinski-triangle`: Generate 2D Sierpiński triangle (n: range **[0, 6]**).
```typ
#let sierpinski-triangle(n, step-size: 10, fill-style: none, stroke-style: black + 1pt, width: auto, height: auto, fit: "cover") = {...}
```
|
https://github.com/crd2333/template-report | https://raw.githubusercontent.com/crd2333/template-report/master/lib.typ | typst | MIT License | #import "fonts.typ": *
#import "utils.typ": *
#import "covers.typ": show_cover
#import "figures.typ": *
#import "math.typ": *
#let project(
title: "Title1",
title_2: "Title2",
title_3: "Title3",
author: ("author1", "author2"),
date: (2023, 5, 14),
cover_style: "normal",
class: "your class",
major: "your major",
mentor: "your mentor",
mailbox: "your mailbox",
department: "your department",
id: "your student ID",
lang: "en",
show_toc: true,
show_name: true,
header: true,
footer: true,
toc_break: true,
toc_depth: 4,
body
) = {
// 信息处理和打包
if type(author) == "array" {author = author.join(", ")} // 多作者(array)时,分隔为字符串
let infos = (
title: title,
title_2: title_2,
title_3: title_3,
author: author,
date: date,
class: class,
major: major,
mentor: mentor,
mailbox: mailbox,
department: department,
id: id,
) + (lang: lang, cover_style: cover_style, show_name: show_name)
// 设置 page
let header1 = context { // ignore cover and toc
if (counter(page).get().first() <= 2) {none}
else {align(right, text(size: 10pt, weight: "bold", title))}
}
let header2 = { // all
align(right, text(size: 10pt, weight: "bold", title))
}
let header3 = { // header with more information
place(left+horizon, text(size: 10pt, title))
place(center+horizon, text(size: 10pt, title_2))
place(right+horizon, date_format(date: date, lang: lang, size: 10pt))
pad(y: 8pt, hline())
}
let footer1 = context { // ignore cover and toc
set align(center)
set text(10pt)
if (counter(page).get().first() <= 2) {none}
else {"Page " + counter(page).display("1 of 1", both: true)}
}
let footer2 = context { // all
set align(center)
set text(10pt)
"Page " + counter(page).display("1 of 1", both: true)
}
set document(title: title, author: author)
set page(
paper: "a4",
numbering: "1",
margin: (x: 2cm, y: 1.5cm),
header:
if (header == true or header == "type1") {header1}
else if (header == "type2") {header2}
else if (header == "type3") {header3}
else {none},
footer:
if (footer == true or footer == "type1") {footer1}
else if (footer == "type2") {footer2}
else {none},
)
set-page-properties() // drafting
// 导入 show 规则
show: process_figure_and_equation.with(unnumbered-label: "-")
show: checklist.with(fill: luma(95%), stroke: blue, radius: .2em)
show: thmrules // 导入 theorem 环境
show: shorthand // 导入 math shorthand
show: codly-init.with()
// 行内公式与文字之间的自动空格
show math.equation.where(block: false): it => h(0.25em, weak: true) + it + h(0.25em, weak: true)
// 矩阵用方括号显示
set math.mat(delim: "[")
set math.vec(delim: "[")
// 引用与链接字体蓝色显示
show ref: set text(colors.blue)
show link: set text(colors.blue)
// 设置字体与语言
set text(font: 字体.宋体, size: 字号.小四, lang: lang)
set par(first-line-indent: 2em)
set list(marker: ([●], [○], [■], [□], [►])) // 设置 bullet list 的 marker,相比默认更像 markdown,另外刻意调大了一点(适合老年人
set enum(numbering: numbly("{1}.", "{2:a}.", "{3:i}."), full: true)
show emph: text.with(font: 字体.楷体) // 中文斜体显示为楷体
// 设置标题
show heading.where(level: 1): it => {
set block(spacing: 1em)
align(center, text(weight: "bold", font: 字体.黑体, size: 18pt, it))
}
show heading.where(level: 2): set text(weight: "bold", font: 字体.黑体, size: 17pt)
show heading.where(level: 3): set text(weight: "bold", font: 字体.黑体, size: 16pt)
show heading.where(level: 4): set text(weight: "bold", font: 字体.黑体, size: 15pt)
show heading.where(level: 5): set text(weight: "bold", font: 字体.黑体, size: 14pt)
set heading(numbering: (..nums) => { // 设置标题编号
nums.pos().map(str).join(".") + " "
})
// 代码相关设置
codly(
languages: (
c: (name: "", icon: h(2pt)+c_svg, color: rgb("#A8B9CC")),
C: (name: "", icon: h(2pt)+c_svg, color: rgb("#A8B9CC")),
cpp: (name: "Cpp", icon: cpp_svg, color: rgb("#00599C")),
Cpp: (name: "Cpp", icon: cpp_svg, color: rgb("#00599C")),
py: (name: "Python", icon: python_svg, color: rgb(("#3D8FD1"))),
python: (name: "Python", icon: python_svg, color: rgb(("#3D8FD1"))),
rust: (name: "Rust", icon: rust_svg, color: rgb("#CE412B")),
java: (name: "Java", icon: java_svg, color: rgb("#5382A1")),
typ: (name: "Typst", icon: typst_svg, color: rgb("#FFD700")),
sql: (name: "SQL", icon: sql_svg, color: rgb("#F0A103")),
SQL: (name: "SQL", icon: sql_svg, color: rgb("#F0A103")),
verilog: (name: "Verilog", icon: verilog_svg, color: rgb("#FF6666")),
Verilog: (name: "Verilog", icon: verilog_svg, color: rgb("#FF6666")),
),
// zebra-color: luma(250),
fill: luma(250),
// stroke: 1pt,
// display-name: false,
// display-icon: false
)
// 行内代码,灰色背景
show raw.where(block: false): box.with(
fill: colors.gray,
inset: (x: 3pt, y: 0pt),
outset: (y: 3pt),
radius: 2pt,
)
// 行内代码与文字之间的自动空格
show raw.where(block: false): it => h(0.25em, weak: true) + it + h(0.25em, weak: true)
show raw: set text(font: (字体.meslo-mono, 字体.思源宋体)) // 代码中文字体
show raw: it => {
show regex("pin\d"): it => pin(eval(it.text.slice(3))) // pinit package for raw
it
}
// show raw: comment_process // maybe bugs
set raw(syntaxes: "assets/Assembly.sublime-syntax") // 汇编代码的语法高亮
show: fix-indent() // 一个很 tricky 的包,需放在所有 show 规则的最后
show_cover(infos: infos) // 封面
if show_toc {toc(toc_break: toc_break, depth: toc_depth)} // 目录
body
}
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-11680.typ | typst | Apache License 2.0 | #let data = (
("TAKRI LETTER A", "Lo", 0),
("TAKRI LETTER AA", "Lo", 0),
("TAKRI LETTER I", "Lo", 0),
("TAKRI LETTER II", "Lo", 0),
("TAKRI LETTER U", "Lo", 0),
("TAKRI LETTER UU", "Lo", 0),
("TAKRI LETTER E", "Lo", 0),
("TAKRI LETTER AI", "Lo", 0),
("TAKRI LETTER O", "Lo", 0),
("TAKRI LETTER AU", "Lo", 0),
("TAKRI LETTER KA", "Lo", 0),
("TAKRI LETTER KHA", "Lo", 0),
("TAKRI LETTER GA", "Lo", 0),
("TAKRI LETTER GHA", "Lo", 0),
("TAKRI LETTER NGA", "Lo", 0),
("TAKRI LETTER CA", "Lo", 0),
("TAKRI LETTER CHA", "Lo", 0),
("TAKRI LETTER JA", "Lo", 0),
("TAKRI LETTER JHA", "Lo", 0),
("TAKRI LETTER NYA", "Lo", 0),
("TAKRI LETTER TTA", "Lo", 0),
("TAKRI LETTER TTHA", "Lo", 0),
("TAKRI LETTER DDA", "Lo", 0),
("TAKRI LETTER DDHA", "Lo", 0),
("TAKRI LETTER NNA", "Lo", 0),
("TAKRI LETTER TA", "Lo", 0),
("TAKRI LETTER THA", "Lo", 0),
("TAKRI LETTER DA", "Lo", 0),
("TAKRI LETTER DHA", "Lo", 0),
("TAKRI LETTER NA", "Lo", 0),
("TAKRI LETTER PA", "Lo", 0),
("TAKRI LETTER PHA", "Lo", 0),
("TAKRI LETTER BA", "Lo", 0),
("TAKRI LETTER BHA", "Lo", 0),
("TAKRI LETTER MA", "Lo", 0),
("TAKRI LETTER YA", "Lo", 0),
("TAKRI LETTER RA", "Lo", 0),
("TAKRI LETTER LA", "Lo", 0),
("TAKRI LETTER VA", "Lo", 0),
("TAKRI LETTER SHA", "Lo", 0),
("TAKRI LETTER SA", "Lo", 0),
("TAKRI LETTER HA", "Lo", 0),
("TAKRI LETTER RRA", "Lo", 0),
("TAKRI SIGN ANUSVARA", "Mn", 0),
("TAKRI SIGN VISARGA", "Mc", 0),
("TAKRI VOWEL SIGN AA", "Mn", 0),
("TAKRI VOWEL SIGN I", "Mc", 0),
("TAKRI VOWEL SIGN II", "Mc", 0),
("TAKRI VOWEL SIGN U", "Mn", 0),
("TAKRI VOWEL SIGN UU", "Mn", 0),
("TAKRI VOWEL SIGN E", "Mn", 0),
("TAKRI VOWEL SIGN AI", "Mn", 0),
("TAKRI VOWEL SIGN O", "Mn", 0),
("TAKRI VOWEL SIGN AU", "Mn", 0),
("TAKRI SIGN VIRAMA", "Mc", 9),
("TAKRI SIGN NUKTA", "Mn", 7),
("TAKRI LETTER ARCHAIC KHA", "Lo", 0),
("TAKRI ABBREVIATION SIGN", "Po", 0),
(),
(),
(),
(),
(),
(),
("TAKRI DIGIT ZERO", "Nd", 0),
("TAKRI DIGIT ONE", "Nd", 0),
("TAKRI DIGIT TWO", "Nd", 0),
("TAKRI DIGIT THREE", "Nd", 0),
("TAKRI DIGIT FOUR", "Nd", 0),
("TAKRI DIGIT FIVE", "Nd", 0),
("TAKRI DIGIT SIX", "Nd", 0),
("TAKRI DIGIT SEVEN", "Nd", 0),
("TAKRI DIGIT EIGHT", "Nd", 0),
("TAKRI DIGIT NINE", "Nd", 0),
)
|
https://github.com/NOOBDY/formal-language | https://raw.githubusercontent.com/NOOBDY/formal-language/main/q10.typ | typst | The Unlicense | #import "@preview/finite:0.3.0": automaton, layout
#let q10 = [
10. Given two `DFA`s $M_i = (Q_i, Sigma, delta_i, q_(0i), F_i)$, $i = 1, 2$, a _morphism_ $h : M_1 -> M_2$ of `DFA`s is a function $h : Q_1 -> Q_2$ satisfying the following:
- $h(delta_1(p, a)) = delta_2(h(p), a), "for all" p in Q_1 "and all" a in Sigma$.
- $h(q_(01)) = q_(02)$.
An $F$-map $h : M_1 -> M_2$ is a morphism $h$ satisfying $h(F_1) subset.eq F_2$.
A $B$-map $h : M_1 -> M_2$ is a morphism $h$ satisfying $h^(−1)(F_2) subset.eq F_1$.
A _proper homomorphism_ of `DFA`s is an $F$-map and also a $B$-map, i.e. $h^(−1)(F_2) = F_1$.
+ Prove that if $f : M_1 -> M_2$ and $g : M_2 -> M_3$ are morphisms (resp. $F$-maps, resp. $B$-maps) of `DFA`s, then $g compose f : M_1 -> M_3$ is also a morphism (resp. $F$-map, resp. $B$-map).
$ because h(F_1) &subset.eq F_2, h(F_2) subset.eq F_3 \
therefore h(F_1) &subset.eq F_3 \
because h^(-1)(F_2) &subset.eq F_1, h^(-1)(F_3) subset.eq F_2 \
therefore h^(-1)(F_3) &subset.eq F_1 $
+ If $h : M_1 -> M_2$ is a morphism, prove that
$ h(hat(delta)_1(p, w)) = hat(delta)_2(h(p), w) $
for all $p in Q_1$ and all $w in Sigma^ast$.
#automaton(
(
q00:(q01:"1", q10:"2"),
q01:(q11:"2"),
q10:(q11:"1"),
q11:(),
),
labels: (
q00: $Q_1$,
q01: $Q_1 '$,
q10: $Q_2$,
q11: $Q_2 '$,
),
initial: (),
final: (),
style: (
state: (
stroke: 0.0pt,
radius: 1.0,
label: (
size: 15pt
)
),
transition: (
stroke: 0.5pt,
curve: 0,
label: (
angle: 0deg
)
),
q00-q01: (label: $hat(delta)_1$),
q00-q10: (label: $h$),
q10-q11: (label: $hat(delta)_2$),
q01-q11: (label: $h$),
),
layout: layout.custom.with(
positions: (..) => (
q00: (3, 3),
q01: (6, 3),
q10: (3, 0),
q11: (6, 0),
)
)
)
+ Prove that if $h : M_1 -> M_2$ is a proper homomorphism, then $L(M_1) = L(M_2)$.
$ because h^(-1)(F_2) &= F_1 \
therefore L(M_1) &= L(M_2) $
]
|
https://github.com/Hobr/njust_thesis_typst_template | https://raw.githubusercontent.com/Hobr/njust_thesis_typst_template/main/util/package.typ | typst | MIT License | // ---------- 基本
// 定理
#import "@preview/ctheorems:1.1.2": *
// 表格
#import "@preview/tablex:0.0.8": tablex, rowspanx, colspanx
// 注释
#import "@preview/drafting:0.2.0"
// 术语表
#import "@preview/glossarium:0.4.0": make-glossary, print-glossary, gls, glspl
// 提示框
#import "@preview/gentle-clues:0.8.0": *
// 正文伪粗体
#import "@preview/cuti:0.2.1": show-cn-fakebold
// ---------- 图形
// 制图
#import "@preview/cetz:0.2.2"
// CeTZ箭头
#import "@preview/fletcher:0.4.4" as fletcher: diagram, node, edge
// 节点图
#import "@preview/commute:0.2.0": node, arr, commutative-diagram
// 甘特图
#import "@preview/timeliney:0.0.1"
// 图片环绕
#import "@preview/wrap-it:0.1.0": wrap-content
// 图表编号
#import "@preview/i-figured:0.2.4": show-figure, show-equation
// 推理
#import "@preview/curryst:0.3.0": rule, proof-tree
// ---------- 数学
// 数学模板
#import "@preview/quick-maths:0.1.0": shorthands
// 简化数学
#import "@preview/unify:0.5.0": num, qty, numrange, qtyrange
// 公式编号
#import "@preview/equate:0.1.0": equate
// ---------- 计算机
// 代码
#import "@preview/codly:0.2.0": *
// 算法
#import "@preview/algo:0.3.3": algo, i, d, comment, code
// 寄存器图
#import "@preview/bytefield:0.0.5": *
// 伪代码
#import "@preview/lovelace:0.2.0": *
// C/Java堆栈可视化
#import "@preview/stack-pointer:0.1.0"
// ---------- 电路
// 量子电路
#import "@preview/quill:0.2.1": *
// 自动机
#import "@preview/finite:0.3.0": automaton
// ---------- 演示
// PPT
#import "@preview/polylux:0.3.1": *
// PPT强调
#import "@preview/pinit:0.1.4": *
// ---------- 物理
// 物理
#import "@preview/physica:0.9.3": *
|
https://github.com/floriandejonckheere/utu-thesis | https://raw.githubusercontent.com/floriandejonckheere/utu-thesis/master/thesis/figures/08-case-study/contributors.typ | typst | #import "@preview/cetz:0.2.2": canvas, chart, draw
#let data = (
([Developer A], 139),
([Developer B], 83),
([Developer C], 15),
([Developer D], 14),
([Developer E], 8),
([Developer F], 7),
([Developer G], 6),
([Developer H], 5),
([Developer I], 1),
([Developer J], 1),
)
#let total = data.map(p => p.at(1)).sum()
#canvas(length: .75cm, {
let colors = (
cmyk(0%, 75%, 79%, 0%),
cmyk(0%, 32%, 23%, 26%),
cmyk(29%, 26%, 0%, 28%),
cmyk(80%, 29%, 0%, 20%),
cmyk(65%, 0%, 2%, 35%),
cmyk(64%, 0%, 38%, 24%),
cmyk(34%, 0%, 60%, 18%),
cmyk(8%, 0%, 68%, 15%),
)
chart.piechart(
data,
clockwise: false,
value-key: 1,
label-key: 0,
radius: 3,
slice-style: colors,
inner-radius: 1,
inner-label: (content: (value, label) => if value > 12 [#text(size: 10pt, white, str(calc.round(100 * value / total, digits: 0)) + "%")] else [], radius: 100%),
outer-label: (content: (value, label) => if value <= 12 and value > 1 [#text(size: 9pt, str(calc.round(100 * value / total, digits: 0)) + "%")] else [], radius: 120%))
})
|
|
https://github.com/zyxdenny/my-cv | https://raw.githubusercontent.com/zyxdenny/my-cv/master/cv.typ | typst | #set page (
paper: "us-letter",
margin: (x: 35pt, y: 35pt),
)
#set text(
size: 12pt,
font: (
"linux libertine",
"TW-Kai",
"Symbols Nerd Font"
)
)
#show heading.where(level: 1): it => [
#set text(
fill: eastern,
weight: "bold",
size: 26pt,
)
#smallcaps(
it.body
)
]
#show heading.where(level: 2): it => [
#set text(
fill: eastern,
weight: "bold",
size: 18pt,
)
#block(
it.body,
)
]
#let item(leader, body) = {
text(weight: "semibold")[#leader: ]
body
}
#let school(degree, school, time_start, time_end) = {
set text(
size: 12pt,
)
block[
#text(fill: black)[
#emph[#degree] \@ #emph[#school]
#h(1fr)
#time_start -- #time_end
]
]
}
#let work(title, company, place, time_start, time_end) = {
block[
#text(
size: 12pt,
)[
#emph[#company]
#h(1fr)
#place \
#text(weight: "semibold")[#title]
#h(1fr)
#time_start -- #time_end
]
]
}
#let project(title) = {
block[
#text(
size: 12pt,
)[
#text(weight: "semibold")[#title]
]
]
}
#let title(name_en, name_zh) = {
set text(
fill: eastern,
)
block[
#text(
weight: "bold",
size: 26pt,
)[
#smallcaps(
name_en,
)
]
#h(10pt)
#text(
size: 20pt,
)[
#name_zh
]
]
}
#let info(email, phone, github, blog, linkedin) = {
set text(font: "JetBrains Mono", size: 10pt)
block[
#h(1pt) #link("mailto:" + email)[#email]
#h(1fr)
#h(1pt) #phone
#h(1fr)
#h(1pt) #link("https://github.com/" + github)[#github]
#h(1fr)
#h(1pt) #link("https://" + blog)[#blog]
// #h(1fr)
// #h(1pt) #linkedin
]
}
#let skills(class, sarray) = {
let skill(s) = {
set text(
fill: white,
size: 10pt,
font: "JetBrains Mono",
)
box(
fill: eastern,
height: 15pt,
radius: 5pt,
inset: 5pt,
)[
#set align(center + horizon)
#s
]
}
block[
*#class* \
#{
for s in sarray {
[#skill(s) #h(1pt)]
}
}
]
}
#let main = {block[
== Education
#school[M.S. in CS][New York Univerty][01/2024][Exp 12/2025]
- #item[GPA][3.8/4.0]
- #item[Courses][Algorithms, Programming Languages, Cloud \& Machine Learning, Operating Systems, Big Data Application Development, Multicore CPU]
#school[B.E. in CE][Shanghai Jiao Tong University][09/2019][08/2023]
- #item[Senior Year GPA][3.7/4.0]
- #item[Courses][Data Structures, Cryptography, Computer Organization, Discrete Math, Linear Algebra]
- #item[Awards][SJTU Scholarship Third Prize, Award of Academic Progress]
== Work Experience
#work[Full Stack Dev Intern][SuXiang Automobile Tech Ltd. (Startup)][Shanghai, China][08/2023][12/2023]
- Developed a high-performance #emph[single-page web app] using #emph[Elm] (frontend), #emph[Go] with #emph[Gin] (backend), and #emph[MariaDB] (database) to support 10 employees.
- Deployed mail server, Mattermost, and Nextcloud using #emph[Docker], integrating Authentik for #emph[SSO] management (LDAP, OAuth, SAML).
- Automated CI/CD pipeline using #emph[Drone] with Gitea, improving development and deployment efficiency.
- Implemented security measures including MFA, encrypted communication, and RBAC for better access control.
- Wrote documentation for system usage and SSO sign-in across services, simplifying employee onboarding.
#work[Data Analyst Intern][Samoyed Cloud Tech, Ltd.][Shanghai, China][06/2022][09/2022]
- Retrieved and analyzed large-scale datasets using #emph[Hive], optimizing data processing for actionable insights.
- Built clustering algorithm served as an extra feature to predict user risk.
- Developed and optimized scripts in #emph[SQL] and #emph[Python], automating data extraction and transformation processes.
== Projects
#project[Million Song Dataset Analysis]
- Developed a music recommendation system on big data with #emph[Hadoop] and #emph[Spark].
- Parallelized BFS to search on the Million Song Dataset.
- Ensured flexibility and extensibility.
]}
#let side = {
block[
#set par(justify: true)
#emph["Passionate programmer with a deep love for cutting-edge technology and open-source software. Skilled in software development, data analysis, and DevOps, with a strong focus on building stable, efficient solutions."]
]
block[
#v(5pt)
== Skills
#skills([Programming Languages], ("C++", "C", "Go", "Python", "Shell", "Elm"))
#skills([Operating Systems], ("Linux", "MacOS"))
#skills([Tools \& DevOps], ("Git", "Docker", "Kubernetes", "CI/CD", "Cloud (AWS, GCP)", "Nginx"))
#skills([Database], ("MySQL", "Mariadb", "SQLite", "Hive"))
#skills([Documentaion \& Writing], ("LaTeX", "Typst", "Markdown"))
#skills([Big Data \& Distributed Systems], ("Hadoop", "Spark", "Ray", "Hive"))
#skills([Machine Learning \& AI], ("AI Signal Processing", "SVM", "CNN"))
#skills([Efficiency \& Extensibility], ("Vim", "Bash", "All in Linux"))
]
}
#let body = {
grid(
columns: (1fr, 2fr),
column-gutter: 12pt,
block(
width: 100%,
height: 93%,
inset: 10pt,
fill: luma(230),
radius: 4pt,
)[#side],
main,
)
}
#grid(
rows: (auto, auto, auto),
row-gutter: 12pt,
title[Yuxuan Zheng][郑宇轩],
info("<EMAIL>", "(551)226-3046", "zyxdenny", "yuxuanzheng.com", "zyxdenny.linkedin"),
body,
)
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/conchord/0.1.1/examples/tabs.typ | typst | Apache License 2.0 | #set page(height: auto, width: auto, margin: 1em)
#import "../lib.typ": tabs, new-chordgen
#let chord = new-chordgen(scale-length: 0.6pt)
#let ending(n) = {
rect(stroke: (left: black, top: black), inset: 0.2em, n + h(3em))
v(0.5em)
}
#tabs.new(eval-scope: (chord: chord, ending: ending), tabs.gen[```
2/4 2/4-3 2/4-2 2/4-3 |
2/4-2 2/4-3 2/4 2/4 2/4 |
2/4-2 p 0/2-3 3/2-2
|:
##
chord("022000", name: "Em")
v(4em)
##
0/1+0/6 0/1 0/1-3 2/1 | 3/1+3/5-2 3/1 3/1-3 5/1 | 2/1+0/4-2 2/1 0/1-3 3/2-3 | \
3/2-2 `5/2-3 p-2 0/2-3 3/2 | | ## [...] ## p-2 | | 7/1-3 0/1-2 p-3 0/1 3/1 |
2/1-3
2/1
##
ending[1.]
##
3/1 0/1 2/1-2 p-3 0/2-3 3/2-3 |
2/1-2
##
ending[2.]
##
2/1 0/1-3 3/2 :| 0/6-2 | ^0/6-2 ||
```])
Not a lot customization is available yet, but something is already possible:
#show raw: set text(red, font: "Comic Sans MS")
#tabs.new(tabs.gen(s-num: 5, "0/1+2/5-1 ^0/1+`3/5-2.."), scale: 0.2cm, one-beat-length: 12, s-num: 5)
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/layout/columns_11.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test colbreak after only out-of-flow elements.
#set page(width: 7.05cm, columns: 2)
#place[OOF]
#colbreak()
In flow.
|
https://github.com/jdupak/lang-talk-borrow-checker | https://raw.githubusercontent.com/jdupak/lang-talk-borrow-checker/master/main.typ | typst | #import "@preview/polylux:0.3.1": *
#import "@preview/fletcher:0.3.0" as fletcher: node, edge
#import "theme/ctu.typ": *
#show: ctu-theme.with()
#title-slide[
#set text(size: 1.3em)
#v(6em)
= Inside the Rust Borrow Checker
<NAME>
#v(2em)
#text(size: 0.7em)[
\#lang-talk meetup
19. 2. 2024
]
]
#slide[
= Borrow Checker Rules
#only("1-2")[
- Move
]
#only("3-")[#text(fill: luma(50%))[
- Move
]]
#only(2)[
```rust
let mut v1 = Vec::new();
v1.push(42)
let mut v2 = v1; // <- Move
println!(v1[0]); // <- Error
```
#v(0.5em)
]
#only("1-3")[
- Lifetime subset relation
- Borrow must outlive borrowee
]
#only("4-")[#text(fill: luma(50%))[
- Lifetime subset relation
- Borrow must outlive borrowee
]]
#only(3)[
```rust
fn f() -> &i32 {
&(1+1)
} // <- Error
```
#v(0.5em)
]
- One mutable borrow or multiple immutable borrows
- No modification of immutable borrow data
#only(4)[
```rust
let mut counter = 0;
let ref1 = &mut counter;
// ...
let ref2 = &mut counter; // <- Error
```
]
]
#slide[
= Checking Functions
#let f = ```rust
struct Vec<'a> { ... }
impl<'a> Vec<'a> {
fn push<'b> where 'b: 'a (&mut self, x: &'b i32) {
// ...
}
}
```
#only("1")[#f]
#only("2-")[
#text(size: 0.7em, f)
```rust
let a = 5; // 'a 'b 'b: 'a
{ //
let mut v = Vec::new(); // *
v.push(&a); // * * OK
let x = v[0]; // * * OK
} // * OK
```
]
#notes(
```md
Protože analýza celého programu by měla extrémní výpočetní nároky, provádí borrow checker pouze analýzu uvnitř funkce.
Na hranicích funkce musí programátor popsat popsat invarianty platnosti referencí a to pomocí lifetime anotací, na slidu apostrof `a` a apostrof `b`.
Na příkladu zde máme vektor referencí, jejihž platnost v rámci programu je zdola omezena regionem apostrof `a`. Pokud chceme vložit fo vektoru novou referenci s platností apostrof `b`, musíme říci, že oblast programu apostrof `b` je alespoň tak velká, jako apostrof `a`.
Zde na konrétním příkladu, můžete vidět dosazené časti programu.
```
)
]
#title-slide[
= Borrow checker evolution
Lexical, NLL, Polonius
]
#slide[
= Lexical borrow checker
#only(1)[
```rust
fn foo() {
let mut data = vec!['a', 'b', 'c'];
capitalize(&mut data[..]);
data.push('d');
data.push('e');
data.push('f');
}
```
]
#only(2)[
```rust
fn foo() {
let mut data = vec!['a', 'b', 'c']; // --+ 'scope
capitalize(&mut data[..]); // |
// ^~~~~~~~~~~~~~~~~~~~~~ 'lifetime // |
data.push('d'); // |
data.push('e'); // |
data.push('f'); // |
} // <-------------------------------------+
```
]
]
#slide[
= Lexical borrow checker
```rust
fn bar() {
let mut data = vec!['a', 'b', 'c'];
let slice = &mut data[..]; // <-+ 'lifetime
capitalize(slice); // |
data.push('d'); // ERROR! // |
data.push('e'); // ERROR! // |
data.push('f'); // ERROR! // |
} // <----------------------------+
```
]
#slide[
= Lexical borrow checker
```rust
fn process_or_default() {
let mut map = ...;
let key = ...;
match map.get_mut(&key) { // -------------+ 'lifetime
Some(value) => process(value), // |
None => { // |
map.insert(key, V::default()); // |
// ^~~~~~ ERROR. // |
} // |
}; // <------------------------------------+
}
```
]
#slide[
= Non-lexical lifetimes (NLL)
#align(center + horizon)[#text(size: 2em, weight: "bold", [
lifetime = set of CFG nodes
])]
]
#slide[
= Non-lexical lifetimes (NLL)
#grid(columns: (3fr, 1fr))[
```rust
fn f<'a>(map: &'r mut HashMap<K, V>) {
...
match map.get_mut(&key) {
Some(value) => process(value),
None => {
map.insert(key, V::default());
}
}
}
```
][
#set text(size: 0.75em, font: "Roboto Mono")
#only(1)[
#fletcher.diagram(
{
let (start, match, s, n, end, ret) = ((0,0), (0,-1), (-0.5, -2), (0.5, -2), (0, -3), (0, -4))
node(start, "Start")
node(match, "Match")
node(s, "Some")
node(n, "None")
node(end, "End")
node(ret, "Return")
edge(start, match, "->")
edge(match, s, "->")
edge(match, n, "->")
edge(s, end, "->")
edge(n, end, "->")
edge(end, ret, "->")
})]
#only("2-")[
#fletcher.diagram(
{
let (start, match, s, n, end, ret) = ((0,0), (0,-1), (-0.5, -2), (0.5, -2), (0, -3), (0, -4))
node(start, "Start")
node(match, text(fill:blue, "Match"))
node(s, text(fill:green, "Some"))
node(n, text(fill:red, "None"))
node(end, text(fill:red, "End"))
node(ret, "Return")
edge(start, match, "->")
edge(match, s, "->")
edge(match, n, "-->")
edge(s, end, "-->")
edge(n, end, "-->")
edge(end, ret, "-->")
})]
]
#only(3)[
=== NLL #sym.arrow lifetimes are CFG nodes
]
]
#slide[
= Breaking NLL
#grid(columns: (3fr, 1fr))[
#let c = ```rust
fn f<'a>(map: &'a mut Map<K, V>) -> &'a V {
...
match map.get_mut(&key) {
Some(value) => process(value),
None => {
map.insert(key, V::default())
}
}
}
```
#only(1, code((1,8), c))
#only(2, code((3,), c))
#only(3, code((3,4), c))
#only(4, code((3,4,8), c))
#only(5, code((1,3,4,8,9), c))
#only(6, code((5,6,7), c))
#only(6)[ === Error! ]
][
#set text(size: 0.75em, font: "Roboto Mono")
#let cfg(step) = {
fletcher.diagram(
{
let (start, match, s, n, end, ret) = ((0,0), (0,-1), (-0.5, -2), (0.5, -2), (0, -3), (0, -4))
node(start, text(fill: if step >= 5 { red } else { black }, "Start"))
node(match, text(fill: if step >= 2 { red } else { black }, "Match"))
node(s, text(fill: if step >= 3 { red } else { black },"Some"))
node(n, text(fill: if step >= 5 { red } else { black },
weight: if step >= 6 { 900 } else { "regular" }
,"None"))
node(end, text(fill: if step >= 4 { red } else { black}, "End"))
node(ret, text(fill: if step >= 4 { red } else { black},"Return"))
edge(start, match, "->")
edge(match, s, "->")
edge(match, n, "->")
edge(s, end, "->")
edge(n, end, "->")
edge(end, ret, "->")
})}
#for step in range(7) {
only(step, cfg(step))
}
]
]
#slide[
= Polonius
#align(center + horizon)[#text(size: 2em, weight: "bold", [
Lifetime = set of loans
])]
]
#slide[
= Polonius
#grid(columns: (3fr, 1fr))[
#let c = ```rust
fn f<'a>(map: Map<K, V>) -> &'a V {
...
match map.get_mut(&key) {
Some(value) => process(value),
None => {
map.insert(key, V::default());
}
}
}
```
#only(1, code((5,6,7), c))
][
#set text(size: 0.75em, font: "Roboto Mono")
#let cfg(step) = {
fletcher.diagram(
{
let (start, match, s, n, end, ret) = ((0,0), (0,-1), (-0.5, -2), (0.5, -2), (0, -3), (0, -4))
node(start, text(fill: if step >= 5 { red } else { black}, "Start"))
node(match, text(fill: if step >= 2 { red } else { black}, "Match"))
node(s, text(fill: if step >= 3 { red } else { black},"Some"))
node(n, text(fill: if step >= 5 { red } else { black},"None"))
node(end, text(fill: if step >= 4 { red } else { black}, "End"))
node(ret, text(fill: if step >= 4 { red } else { black},"Return"))
edge(start, match, "->")
edge(match, s, "->")
edge(match, n, "->")
edge(s, end, "->")
edge(n, end, "->")
edge(end, ret, "->")
})}
#for step in range(2) {
only(step, cfg(step))
}
]
]
#slide[
= Polonius
```rust
let r: &'0 i32 = if (cond) {
&x /* Loan L0 */
} else {
&y /* Loan L1 */
};
```
]
#title-slide[
= How does the program look?
Internal representations
]
#slide[
= Internal representations
- AST = abstract syntax tree
- HIR = high-level IR
- Ty = type IR
- THIR = typed HIR
- *MIR* = mid-level IR
#v(2em)
```rust
struct Foo(i31);
fn foo(x: i31) -> Foo {
Foo(x)
}
```
]
#slide[
= HIR
```
Fn {
generics: Generics { ... },
sig: FnSig {
header: FnHeader { ... },
decl: FnDecl {
inputs: [
Param {
ty: Ty {
Path { segments: [ PathSegment {
ident: i32#0 } ] }
}
pat: Pat { Ident(x#0) }
},
],
output: Ty { Path { segments: [ PathSegment {
ident: Foo#0 } ] }
```
]
#slide[
= MIR
```
fn foo(_1: i32) -> Foo {
debug x => _1;
let mut _0: Foo;
bb0: {
_0 = Foo(_1);
return;
}
}
```
]
#slide[
= MIR: Fibonacci
#set text(size: 0.5em)
#columns(2, gutter: 11pt)[
```
fn fib(_2: u32) -> u32 {
bb0: {
0 StorageLive(_3);
1 StorageLive(_5);
2 _5 = _2;
3 StorageLive(_6);
4 _6 = Operator(move _5, const u32);
5 switchInt(move _6) -> [bb1, bb2];
}
bb1: {
0 _3 = const bool;
1 goto -> bb3;
}
bb2: {
0 StorageLive(_8);
1 _8 = _2;
2 StorageLive(_9);
3 _9 = Operator(move _8, const u32);
4 _3 = move _9;
5 goto -> bb3;
}
bb3: {
0 switchInt(move _3) -> [bb4, bb5];
}
bb4: {
0 _1 = const u32;
1 goto -> bb8;
}
bb5: {
0 StorageLive(_14);
1 _14 = _2;
2 StorageLive(_15);
3 _15 = Operator(move _14, const u32);
4 StorageLive(_16);
5 _16 = Call(fib)(move _15) -> [bb6];
}
bb6: {
1 _19 = _2;
3 _20 = Operator(move _19, const u32);
5 _21 = Call(fib)(move _20) -> [bb7];
}
bb7: {
0 _1 = Operator(move _16, move _21);
7 goto -> bb8;
}
bb8: {
5 return;
}
}
```]
]
#title-slide[
= Computing!
Steps of the borrow checker
]
#slide[
= What do we need?
#only(1)[ #box(width: 100%, height: 100%, clip: true, inset: (top: 0pt), align(center, image("media/polonius.svg", height: 100%))) ]
#only(2)[ #box(width: 100%, height: 100%, clip: true, inset: (top: 0pt), align(center, image("media/polonius.svg", height: 200%))) ]
#only(3)[ #box(width: 100%, height: 100%, clip: true, inset: (top: -50%, bottom: 50%), align(center, image("media/polonius.svg", height: 200%))) ]
#only(4)[ #box(width: 100%, height: 100%, clip: true, inset: (top: -100%, bottom: 100%), align(center, image("media/polonius.svg", height: 200%))) ]
#only(5)[ #box(width: 100%, height: 100%, clip: true, inset: (top: 0pt), align(center, image("media/polonius.svg", height: 100%))) ]
]
#title-slide[
= What about lifetime annotations?
```rust
let x: &'a i32;
```
]
#slide[
= Lifetime annotations everywhere
#only(1, ```rust
fn max_ref(a: &i32, b: &i32) -> &i32 {
let mut max = a;
if (*max < *b) {
max = b;
}
max
}
```)
#only(2, code((1,),```rust
fn max_ref(a: &'a i32, b: &'a i32) -> &'a i32 {
let mut max = a;
if (*max < *b) {
max = b;
}
max
}
```))
#only(3, code((1,),```rust
fn max_ref(a: &'a i32, b: &'b i32) -> &'c i32 {
let mut max = a;
if (*max < *b) {
max = b;
}
max
}
```))
#only(4, code((2,),```rust
fn max_ref(a: &'a i32, b: &'b i32) -> &'c i32 {
let mut max: &i32 = a;
if (*max < *b) {
max = b;
}
max
}
```))
#only(5, {
code((2,3,4,5,5,6),```rust
fn max_ref(a: &'a i32, b: &'b i32) -> &'c i32 {
let mut max: &'?1 i32 = a;
if (*max < *b) {
max = b;
}
max
}
```)
set align(horizon + center)
set text(size: 1.5em, )
table(columns: 2, column-gutter: 50pt, row-gutter: 10pt, stroke: none,
[`max = a`],[ `'a: '?1` ],
[`max = b`], [ `'b: '?1` ],
[`return max`], [ `'?1: 'c` ],
)
})
]
#slide[
#only(1)[ #box(width: 100%, height: 100%, clip: true, inset: (top: -50%, bottom: 50%), align(center, image("media/polonius.svg", height: 200%))) ]
]
#title-slide[
= Is it that simple?
`Customer<'&a, Vec<(Box<dyn Dealer>, &'b mut i32)>>`
]
#slide[
= Variance
#set align(center + horizon)
```rust
struct T<'a> {
a: &'a i32,
f: fn(&'a i32),
}
```
$T angle.l 'a angle.r subset.eq T angle.l 'b angle.r$
$'a lt quest gt 'b$
]
#slide[
= Variance
#set align(center + horizon)
#fletcher.diagram({
let (b,co,ct, i) = ((0,0), (-1,-1), (1,-1), (0, -2));
node(b, "bivariant")
node(co, "covariant")
node(ct, "contravariant")
node(i, "invariant")
edge(b, co, "->")
edge(b, ct, "->")
edge(co, i, "->")
edge(ct, i, "->")
})
]
#slide[
= Example: Variance Computation
```rust
struct Foo<'a, 'b, T> {
x: &'a T,
y: Bar<T>,
}
```
#v(2em)
#only(1)[
- *Collect variance info*
- $f_0=o$, $f_1=o$, $f_2=o$
- `x` in the covariant position:
- `&'a T` in the covariant position: $f_0=+$ and $f_2=+$
- `y` in the covariant position:
- $f_2 = "join"(f_2, "transform"(+, b_0))$
]
#only(2)[
- *Iteration 1*:
- $f_0=+$, $f_1=o$, $f_2=+$.
- $"transform"(+, b_0) = -$
- $"join"(*, -) = *$
]
#only(3)[
- *Iteration 2*:
- $f_0=+$, $f_1=o$, $f_2=*$.
- $"transform"(+, b_0) = -$
- $"join"(*, -) = *$
]
#only(4)[
- Final variances: $f_0=+$, $f_1=o$, $f_2=*$:
- f0 is evident.
- f1 remains bivariant, as it is not mentioned in the type.
- f2 is invariant due to its usage in both covariant and contravariant positions.
]
]
#slide[
= Why is it useful?
```rust
fn main() {
let s = String::new();
let x: &'static str = "hello world";
let mut y = &*s;
y = x;
}
```
]
#slide[
= Example: Variance in rustc
#let c = ```rust
fn write_scope_tree(
tcx: TyCtxt<'_>,
body: &Body<'_>,
scope_tree: &FxHashMap<...>,
w: &mut dyn io::Write,
parent: SourceScope,
depth: usize,
) -> io::Result<()> { ... }
```
#let c2 = ```rust
fn write_scope_tree<'a>(
tcx: TyCtxt<'a>,
body: &Body<'a>,
scope_tree: &FxHashMap<...>,
w: &mut dyn io::Write,
parent: SourceScope,
depth: usize,
) -> io::Result<()> { ... }
```
#only(1, code((1,2,3,4,5,6,7,8,9), c))
#only(2, code((), c))
#only(3, code((1,2,3), c2))
#only(2)[
```rust
if let ty::Adt(_, _) = local_decl.ty.kind() {
display_adt(tcx, &mut indented_decl, local_decl.ty);
}
```
```rust
pub fn display_adt<'tcx>(tcx: TyCtxt<'tcx>, w: &mut String, ty: Ty<'tcx>) {...}
```
]
]
#title-slide[
= But how?
Dataflow, datalog, Polonius
]
#slide[
= Dataflow
#grid(columns: (3fr, 2fr))[
- Semilattice
- State
- IN
- OUT
- Transform function
- Iteration
][
#fletcher.diagram(
{
let (start, match, s, n, end, ret) = ((0,0), (0,-1), (-0.5, -2), (0.5, -2), (0, -3), (0, -4))
node(start, "Start")
node(match, "Match")
node(s, "Some")
node(n, "None")
node(end, "End")
node(ret, "Return")
edge(start, match, "->")
edge(match, s, "->")
edge(match, n, "->")
edge(s, end, "->")
edge(n, end, "->")
edge(end, ret, "->")
})
]
]
#slide[
= Datalog Polonius
#set text(size: .95em)
```
origin_contains_loan_on_entry(Origin, Loan, Point) :-
loan_issued_at(Origin, Loan, Point).
origin_contains_loan_on_entry(Origin2, Loan, Point) :-
origin_contains_loan_on_entry(Origin1, Loan, Point),
subset(Origin1, Origin2, Point).
origin_contains_loan_on_entry(Origin, Loan, TargetPoint) :-
origin_contains_loan_on_entry(Origin, Loan, SourcePoint),
!loan_killed_at(Loan, SourcePoint),
cfg_edge(SourcePoint, TargetPoint),
(origin_live_on_entry(Origin, TargetPoint); placeholder(Origin, _)).
```
]
#title-slide[
#image("media/gccrs.png", height: 7em)
#v(-3em)
= Bonus: Rust GCC
]
#slide[
= Rust GCC
#set align(center+horizon)
#image("media/pipeline.svg")
]
#slide[
= Rust GCC
#set align(center+horizon)
#image("media/bir.svg")
]
#slide[
= References
#set text(size: 0.7em)
- MATSAKIS, Niko. 2094-nll. In : The Rust RFC Book. Online. Rust Foundation, 2017. [Accessed 18 December 2023]. Available from https: rust-lang.github.io/rfcs/2094-nll.html
- STJERNA, Amanda. Modelling Rust’s Reference Ownership Analysis Declaratively in Datalog. Online. Master’s thesis. Uppsala University, 2020. [Accessed 28 December 2023]. Available from: https://www.diva-portal.org/smash/get/diva2:1684081/fulltext01.pdf
- MATSAKIS, Niko, RAKIC, Rémy and OTHERS. The Polonius Book. 2021. Rust Foundation.
- GJENGSET, Jon. Crust of Rust: Subtyping and Variance. 2022. [Accessed 19 February 2024]. Available from https://www.youtube.com/watch?v=iVYWDIW71jk
- Rust Compiler Development Guide. Online. Rust Foundation, 2023. [Accessed 18 December 2023]. Available from https://rustc-dev-guide.rust-lang.org/index.html
- TOLVA, <NAME>. Original Ferris.svg. Available from https://en.wikipedia.org/wiki/File:Original_Ferris.svg
]
#title-slide[
#move(dy: 6em,image("media/ferris-happy.svg", height: 40%))
#v(3em)
#text(size: 3em, weight: 800)[That's all Folks!]
] |
|
https://github.com/Zarox28/TypstTemplate | https://raw.githubusercontent.com/Zarox28/TypstTemplate/main/README.md | markdown | <div align="center">
<h1>Typst Template</h1>
</div>
<br />
---
## Table of Contents
- [About](#about)
- [Usage](#usage)
- [Features](#features)
- [Todo](#todo)
- [Changelog](#changelog)
- [Authors](#authors)
## About
This is my custom template for [typst](www.github.com/typst/typst). It is designed to be used for my personal notes and class notes.
## Usage
1. Import `Base.typ` into your project
2. Add `show: conf` to your project for the basic configuration
## Features
- [x] Code inlining & blocks
- [x] Terminal blocks
- [x] Various callout blocks
- [x] Underline
- [x] Indentation
- [x] Table of contents
- [x] Scale
- [x] Headings
- [x] Lists
- [x] Colors
- [x] Links
- [x] Tables
## Todo
- [ ] Images
## Changelog
See [CHANGELOG.md](CHANGELOG.md) for more info
## Authors
- **[**@Zarox28**](https://github.com/Zarox28)**
|
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/meta/link_10.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
//
// // Error: 2-20 label `<hey>` does not exist in the document
// #link(<hey>)[Nope.] |
https://github.com/hitszosa/universal-hit-thesis | https://raw.githubusercontent.com/hitszosa/universal-hit-thesis/main/harbin/bachelor/pages/bibliography.typ | typst | MIT License | #import "../config/constants.typ": special-chapter-titles
#import "../utils/states.typ": bibliography-state
#import "../utils/bilingual-bibliography.typ": bilingual-bibliography
#let bibliography-page() = context [
#let bibliography = bibliography-state.get()
#assert(bibliography != none, message: "请在 doc.with 调用处传入合法的 bibliography 函数。")
#heading(special-chapter-titles.参考文献, level: 1, numbering: none)
#bilingual-bibliography(bibliography: bibliography, title: none)
// #bibliography(title: none)
] |
https://github.com/drupol/ipc2023 | https://raw.githubusercontent.com/drupol/ipc2023/main/src/ipc2023/reproducibility.typ | typst | #import "imports/preamble.typ": *
#focus-slide[
#set align(center + horizon)
#text(font: "Virgil 3 YOFF")[A few words about reproducibility]
]
#focus-slide[
#set align(left + horizon)
#set text(fill: white, size: .6em)
#set par(justify: true)
A software is reproducible if given the same source code, build environment
and build instructions, any party can recreate bit-by-bit identical copies
of all specified artifacts.
-- reproducible-builds.org @ReproducibleBuilds
#pdfpc.speaker-note(```md
Let's start with a formal definition of reproducibility.
Of course, we are here to talk about Nix and PHP, how about checking if
the PHP package manager "Composer" is able to make reproducible builds of
a PHP application?
Let's try with the first demo... And in order to avoid bad surprises, I
recorded each demos in advance, hope you don't mind it!
How about checking if Composer version 2.6.3 is able to make reproducible
builds of a PHP application?
```)
]
#screencast-slide(
title: "Reproducibility",
url: "https://asciinema.org/a/wCNKjF8Rj4lvn1NdXN5UTc1rb",
preview: "../../../resources/screenshots/Screenshot_20231014_211453.png",
caption: "Is Composer 2.6.3 reproducible?"
)[
#pdfpc.speaker-note(```md
<play the video>
As we can see in this video, the answer is no, Composer 2.6.3 is not
reproducible. The content of the `vendor` directory changes at each run.
There is absolutely no way to tell which one is valid since they are all
the time different.
Let's retry the experiment with Composer 2.6.4.
```)
]
#screencast-slide(
title: "Reproducibility",
url: "https://asciinema.org/a/9mjyTWPenRzkFq0qP4zn12ifx",
preview: "../../../resources/screenshots/Screenshot_20231014_211453.png",
caption: "Is Composer 2.6.4 reproducible?"
)[
#pdfpc.speaker-note(```md
In this demo, we see that the `vendor` directory produced by Composer is
reproducable. The content of the `vendor` directory is the same at each
run. It means that the `vendor` directory will be exactly the same for
anyone running this command on any machine!
This is a very good news for Composer users, and this is paving the way for
a better quality and security in the packaging of PHP applications.
This change was introduced in Composer 2.6.4, by me. It is a one-line change
in Composer and Jordi decided to make it the default behaviour. Needless to
say that I was very happy to see this change being accepted and released so
quickly.
```)
]
#slide(title: "Reproducibility")[
#set align(center + horizon)
#set text(size: .6em)
#figure(
image("../../resources/images/essawy-triangle.png", height: 90%),
caption: [
Adapted from Essawy et al. 2020 @ESSAWY2020104753
]
)
#pdfpc.speaker-note(```md
This slide shows a graphic from a paper published in 2020 by Essawy.
It shows the difference between something repeatable and reproducable.
Basically, repeatability is what you're all probably doing everyday.
You run multiple time the same command on your PHP application.
Reproducibility is when you can run the same command on your PHP
application, but on a different machine, and get the same result.
As we can see, reproducibility is a stronger property than repeatability and
reaching reproducibility is not an easy task. It requires time and effort.
Nix is actually the best existing tool to reach that reproducibility, and
this is at a very light cost.
Let's continue exploring Nix...
Oh by the way, let me do a quick parenthesys...
This presentation was made with Typst, a powerful new opensource typesetting
system written in rust initially created by two german students during their
master thesis. It will be available on my Github account today or tomorrow
and will be totally reproducable, bit-per-bit, and for anyone.
```)
]
|
Subsets and Splits