repo
stringlengths 26
115
| file
stringlengths 54
212
| language
stringclasses 2
values | license
stringclasses 16
values | content
stringlengths 19
1.07M
|
---|---|---|---|---|
https://github.com/Myriad-Dreamin/tinymist | https://raw.githubusercontent.com/Myriad-Dreamin/tinymist/main/crates/tinymist-query/src/fixtures/signature/builtin.typ | typst | Apache License 2.0 | #(/* ident after */ rgb);
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/layout/enum-numbering-01.typ | typst | Other | // Test full numbering.
#set enum(numbering: "1.a.", full: true)
+ First
+ Nested
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-2E00.typ | typst | Apache License 2.0 | #let data = (
("RIGHT ANGLE SUBSTITUTION MARKER", "Po", 0),
("RIGHT ANGLE DOTTED SUBSTITUTION MARKER", "Po", 0),
("LEFT SUBSTITUTION BRACKET", "Pi", 0),
("RIGHT SUBSTITUTION BRACKET", "Pf", 0),
("LEFT DOTTED SUBSTITUTION BRACKET", "Pi", 0),
("RIGHT DOTTED SUBSTITUTION BRACKET", "Pf", 0),
("RAISED INTERPOLATION MARKER", "Po", 0),
("RAISED DOTTED INTERPOLATION MARKER", "Po", 0),
("DOTTED TRANSPOSITION MARKER", "Po", 0),
("LEFT TRANSPOSITION BRACKET", "Pi", 0),
("RIGHT TRANSPOSITION BRACKET", "Pf", 0),
("RAISED SQUARE", "Po", 0),
("LEFT RAISED OMISSION BRACKET", "Pi", 0),
("RIGHT RAISED OMISSION BRACKET", "Pf", 0),
("EDITORIAL CORONIS", "Po", 0),
("PARAGRAPHOS", "Po", 0),
("FORKED PARAGRAPHOS", "Po", 0),
("REVERSED FORKED PARAGRAPHOS", "Po", 0),
("HYPODIASTOLE", "Po", 0),
("DOTTED OBELOS", "Po", 0),
("DOWNWARDS ANCORA", "Po", 0),
("UPWARDS ANCORA", "Po", 0),
("DOTTED RIGHT-POINTING ANGLE", "Po", 0),
("DOUBLE OBLIQUE HYPHEN", "Pd", 0),
("INVERTED INTERROBANG", "Po", 0),
("PALM BRANCH", "Po", 0),
("HYPHEN WITH DIAERESIS", "Pd", 0),
("TILDE WITH RING ABOVE", "Po", 0),
("LEFT LOW PARAPHRASE BRACKET", "Pi", 0),
("RIGHT LOW PARAPHRASE BRACKET", "Pf", 0),
("TILDE WITH DOT ABOVE", "Po", 0),
("TILDE WITH DOT BELOW", "Po", 0),
("LEFT VERTICAL BAR WITH QUILL", "Pi", 0),
("RIGHT VERTICAL BAR WITH QUILL", "Pf", 0),
("TOP LEFT HALF BRACKET", "Ps", 0),
("TOP RIGHT HALF BRACKET", "Pe", 0),
("BOTTOM LEFT HALF BRACKET", "Ps", 0),
("BOTTOM RIGHT HALF BRACKET", "Pe", 0),
("LEFT SIDEWAYS U BRACKET", "Ps", 0),
("RIGHT SIDEWAYS U BRACKET", "Pe", 0),
("LEFT DOUBLE PARENTHESIS", "Ps", 0),
("RIGHT DOUBLE PARENTHESIS", "Pe", 0),
("TWO DOTS OVER ONE DOT PUNCTUATION", "Po", 0),
("ONE DOT OVER TWO DOTS PUNCTUATION", "Po", 0),
("SQUARED FOUR DOT PUNCTUATION", "Po", 0),
("FIVE DOT MARK", "Po", 0),
("REVERSED QUESTION MARK", "Po", 0),
("VERTICAL TILDE", "Lm", 0),
("RING POINT", "Po", 0),
("WORD SEPARATOR MIDDLE DOT", "Po", 0),
("TURNED COMMA", "Po", 0),
("RAISED DOT", "Po", 0),
("RAISED COMMA", "Po", 0),
("TURNED SEMICOLON", "Po", 0),
("DAGGER WITH LEFT GUARD", "Po", 0),
("DAGGER WITH RIGHT GUARD", "Po", 0),
("TURNED DAGGER", "Po", 0),
("TOP HALF SECTION SIGN", "Po", 0),
("TWO-EM DASH", "Pd", 0),
("THREE-EM DASH", "Pd", 0),
("STENOGRAPHIC FULL STOP", "Po", 0),
("VERTICAL SIX DOTS", "Po", 0),
("WIGGLY VERTICAL LINE", "Po", 0),
("CAPITULUM", "Po", 0),
("DOUBLE HYPHEN", "Pd", 0),
("REVERSED COMMA", "Po", 0),
("DOUBLE LOW-REVERSED-9 QUOTATION MARK", "Ps", 0),
("DASH WITH LEFT UPTURN", "Po", 0),
("DOUBLE SUSPENSION MARK", "Po", 0),
("INVERTED LOW KAVYKA", "Po", 0),
("INVERTED LOW KAVYKA WITH KAVYKA ABOVE", "Po", 0),
("LOW KAVYKA", "Po", 0),
("LOW KAVYKA WITH DOT", "Po", 0),
("DOUBLE STACKED COMMA", "Po", 0),
("DOTTED SOLIDUS", "Po", 0),
("TRIPLE DAGGER", "Po", 0),
("MEDIEVAL COMMA", "Po", 0),
("PARAGRAPHUS MARK", "Po", 0),
("PUNCTUS ELEVATUS MARK", "Po", 0),
("CORNISH VERSE DIVIDER", "Po", 0),
("CROSS PATTY WITH RIGHT CROSSBAR", "So", 0),
("CROSS PATTY WITH LEFT CROSSBAR", "So", 0),
("TIRONIAN SIGN CAPITAL ET", "Po", 0),
("MEDIEVAL EXCLAMATION MARK", "Po", 0),
("MEDIEVAL QUESTION MARK", "Po", 0),
("LEFT SQUARE BRACKET WITH STROKE", "Ps", 0),
("RIGHT SQUARE BRACKET WITH STROKE", "Pe", 0),
("LEFT SQUARE BRACKET WITH DOUBLE STROKE", "Ps", 0),
("RIGHT SQUARE BRACKET WITH DOUBLE STROKE", "Pe", 0),
("TOP HALF LEFT PARENTHESIS", "Ps", 0),
("TOP HALF RIGHT PARENTHESIS", "Pe", 0),
("BOTTOM HALF LEFT PARENTHESIS", "Ps", 0),
("BOTTOM HALF RIGHT PARENTHESIS", "Pe", 0),
("OBLIQUE HYPHEN", "Pd", 0),
)
|
https://github.com/Wh4rp/Presentacion-Typst | https://raw.githubusercontent.com/Wh4rp/Presentacion-Typst/master/ejemplos/4_image.typ | typst | Y con ustedes, la #text(blue)[capybara] más famosa de #text(blue)[Typst]
#image("../src/capybara.jpg", width: 50%)" |
|
https://github.com/yhtq/Notes | https://raw.githubusercontent.com/yhtq/Notes/main/抽象代数/作业/hw7.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.
#show: note.with(
title: "作业7",
author: "YHTQ ",
date: none,
logo: none,
withOutlined: false
)
= 1.
#answer[
+ 对 $d$ 做素因数分解,得:
$
d = p_1^(alpha_1)p_2^(alpha_2)...p_k^(alpha_k)
$
+ 容易看出 $p_i^(alpha_i) | n$,因此取每个素因数对应的 $Sylow(p)$ 子群,在其中找出阶为 $p_i^(alpha_i)$ 的子群。这些子群的积(由于它们交为平凡群)的阶就为 $d$。不妨设 $p_i$ 是所有 $n$ 的素因子,$d$ 中不含的设其指数为零。
+ 另一方面,设群 $G = P_1 times P_2 times ... times P_k$。显然 $p_i^(alpha_i) | |P_i|$,因此只需证明每个有限交换 $p$ 群都满足拉格朗日定理的逆定理即可。
+ 由有限交换群的分类,$P_i$ 形如:
$
ZZ_(p_i^(lambda_1)) times ZZ_(p_i^(lambda_2)) times ... times ZZ_(p_i^(lambda_k))
$
其中 $lambda_1 + lambda_2 +... +lambda_k = n$。从左往右选取若干子群,直至 $lambda_s$ 使得:
$
lambda_1 + lambda_2 + ... + lambda_s <= alpha_i\
lambda_1 + lambda_2 + ... + lambda_s + lambda_(s+1) > alpha_i\
$
- 若上面前式取等,则 $ZZ_(p_i^(lambda_1)) times ZZ_(p_i^(lambda_2)) times ... times ZZ_(p_i^(lambda_s))$ 即符合要求。
- 若不然,设 $t = alpha_i - lambda_1 + lambda_2 + ... + lambda_s < lambda_(s+1)$,因此在 $ZZ_(p_i^(lambda_(s+1)))$ 中容易找到子群 $H$ 使得 $|H| = p_i^t$,因此:
$
ZZ_(p_i^(lambda_1)) times ZZ_(p_i^(lambda_2)) times ... times ZZ_(p_i^(lambda_s)) times H
$
即满足要求。
]
= 2.
#answer[
设:
$
G = ZZ_(p^(lambda_1)) times ZZ_(p^(lambda_2)) times ... times ZZ_(p^(lambda_s))
$
并设:
$
a = (a_1, a_2, ..., a_s)
$
只需证明在每个循环群中:
$
x^n = a_i
$
都有解即可。
- 注意到:
$
x^n = y^n => (x Inv(y))^n = e => p | n or x = y => x = y
$
因此对每个循环群中的 $p^(lambda_i)$ 个元素,这些元素的 $n$ 次方互不相同,因而必可取遍所有元素。
- 因此在每个循环群中均存在 $x_i$ 使得 $x_i^n = a_i$,由此:
$
(x_1, x_2, ..., x_s)^n = (a_1, a_2, ..., a_s) = a
$
这就证明了结论。
]
= 3.
#answer[
- $360 = 2^3 dot 3^2 dot 5$
- $3$ 的所有分拆有:
$
(3)\
(2, 1)\
(1, 1, 1)
$
$2$ 的所有分拆为:
$
(2)\
(1, 1)
$
- 初等因子共有六个,分别是:
$
{2^3, 3^2, 5}\
{2^2, 2, 3^2, 5}\
{2, 2, 2, 3^2, 5}\
{2^3, 3, 3, 5}\
{2^2, 2, 3, 3, 5}\
{2, 2, 2, 3, 3, 5}\
$
- 不变因子分别为:
$
{2^3 dot 3^2 dot 5}\
{2, 2^2 dot 3^2 dot 5}\
{2, 2, 2 dot 3^2 dot 5}\
{3, 2^3 dot 3 dot 5}\
{3 dot 2, 2^2 dot 3 dot 5}\
{2, 2 dot 3, 2 dot 3 dot 5}\
$
- 所有可能结构为:
$
ZZ_(2^3) times ZZ_(3^2) times ZZ_(5)\
ZZ_(2^2) times ZZ_2 times ZZ_(3^2) times ZZ_(5)\
ZZ_2 times ZZ_2 times ZZ_2 times ZZ_(3^2) times ZZ_(5)\
ZZ_(2^3) times ZZ_3 times ZZ_3 times ZZ_5\
ZZ_(2^2) times ZZ_2 times ZZ_3 times ZZ_3 times ZZ_5\
ZZ_2 times ZZ_2 times ZZ_2 times ZZ_3 times ZZ_3 times ZZ_5\
$
]
= 4.
#answer[
- $16 = 2^4$
- $4$ 的所有分拆有:
$
(4)\
(3, 1)\
(2, 2)\
(2, 1, 1)\
(1, 1, 1, 1)
$
- 所有可能交换群结构为:
$
ZZ_(2^4)\
ZZ_(2^3) times ZZ_2\
ZZ_(2^2) times ZZ_(2^2)\
ZZ_(2^2) times ZZ_2 times ZZ_2\
ZZ_2 times ZZ_2 times ZZ_2 times ZZ_2\
$
- 其中
- $ZZ_(2^4)$ 恰有两个二阶元
- $ZZ_(2^3) times ZZ_2$ 恰有三个二阶元
- $ZZ_(2^2) times ZZ_(2^2)$ 恰有三个二阶元
- $ZZ_(2^2) times ZZ_2 times ZZ_2$ 恰有七个二阶元
- $ZZ_2 times ZZ_2 times ZZ_2 times ZZ_2$ 恰有十五个二阶元
]
= 5.
#answer[
(1) \
- 对 175 阶群利用 Sylow 定理:
$
5 | n_5-1, n_5 | 7 => n_5 = 1\
7 | n_7-1, n_7 | 25 => n_7 = 1
$
- 注意到两个 Sylow 子群不交且都正规,因此:
$
G = P_5 times P_7
$
注意到 $P_7 = ZZ_7$,$|P_5| = 25 = 5^2$,而 $p^2$ 阶群一定交换,因此 $P_7, P_5$ 都交换,进而 $G$ 交换。
- 它的所有可能结构为:
$
ZZ_25 times ZZ_7\
ZZ_5 times ZZ_5 times ZZ_7\
$
(2)\
- 同样利用 Sylow 定理:
$
13 | n_13 - 1, n_13 | 11^2 => n_13 = 1\
11 | n_11 - 1, n_11 | 13^2 => n_11 = 1
$
- 其余类似可以证明 $G$ 交换,它的所有可能结构为:
$
ZZ_(11^2) times ZZ_(13^2)\
ZZ_(11^2) times ZZ_13 times ZZ_13\
ZZ_11 times ZZ_11 times ZZ_(13^2)\
ZZ_11 times ZZ_11 times ZZ_13 times ZZ_13\
$
]
= 6.
#answer[
注意到 $A times B$ 的不变因子即 $A, B$ 不变因子的并,$A times C$ 类似,因此题设给出 $B, C$ 具有相同的不变因子,即 $B, C$ 同构。
]
= 7.
#answer[
取 $a, b$ 分别是两个循环群的生成元,显然:
$
a' = phi(a, 1), b' = phi(1, b)
$
唯一决定一个同构映射 $phi$。
- 由于 $phi$ 是同构,因此有:
$
ord(a') = p\
ord(b') = p\
generatedBy(a') sect generatedBy(b') = {e}
$
- 注意到若 $generatedBy(a') sect generatedBy(b') != {e}$,则它们将有公共非平凡元素 $x$,由 $p$ 是素数,$x$ 一定同时是两者的生成元,即有 $generatedBy(a') = generatedBy(b')$
- 这意味着,只要在 $Z_p times Z_p$ 中任找两个不在同一循环群中的非平凡元素作为两元素的像,都可以唯一确定一个同构映射。
- 同时,这表明 $|Aut(ZZ_p times ZZ_p)| = (p^2 - 1)(p^2 - p) = p(p - 1)^2(p + 1)$
]
= 8.
#answer[
不妨设 $m <= n$
设 $x = (a, b)$,显有:
$
ord(x) = lcm(ord(a), ord(b))
$
设 $ord(x) = p^r, ord(a) = p^(r_1), ord(b) = p^(r_2)$,则有:
$
max(r_1, r_2) = r
$
另一方面,$ZZ_(p^m)$ 中阶为 $p^r$ 的元素恰有 $p^(r-1)(p-1)$ 或 $1 (r=0)$ 个,故只需考虑 $r_1, r_2$ 的可能取值即可:
- 当 $r <= m$ 时,在一个群中取定 $p^r$ 阶元素,另一个元素的取法恰好取遍唯一的 $p^r$ 阶子群的取法共有:
$
p^(r-1)(p-1)p^r + p^(r-1)(p-1)p^r - (p^(r-1)(p-1))^2 = p^(r-1)(p-1)(2p^r - p^r + p^(r-1)) \
= p^(r-1)(p-1)(p^r + p^(r-1))
$
- 当 $m < r <= n$ 时,可能取值共有
$
p^(r-1)(p-1)p^m
$
上面两数显然将每个子群重复计算了 $p^(r-1)(p-1)$ 次,因此最后答案为:
- $p^r + p^(r-1)$ 或
- $p^m$
//对于非循环子群,我们首先证明:
// #lemma[][
// $G$ 的所有子群都是不超过两个循环群的直积
// ]
// #proof[
// 设 $H <= G$。若 $H$ 是循环群,结论显然成立,下设 $H$ 不是循环群。\
// //记 $pi_1, pi_2$ 分别为两个投影映射,断言:
// //- 存在 $a, b$ 使得 $a, b$ 分别为 $Inv(pi_1)(H),Inv(pi_2)(H)$ 中最高阶元素,且 $(a, b) in H$
////
// // 事实上,取 $a, b$ 分别为两者中的最高阶元素,设:
// // $
// // pi_1(x) = pi_1(a, b') = a\
// // pi_2(y) = pi_2(a', b) = b
// // $
// // 不妨设 $ord(a) <= ord(b)$,进而 $ord(a') < ord(b)$(若等于则结论已成立)\
// // 我们有:
// // $
// // y^ord(a') = (e, b^(ord(a'))) in H\
// // x y^ord(a') = (a, b' b^(ord(a'))) in H
// // $
// // 由于 $ord(b') | ord(b) => b' = generatedBy(b)$,可设 $b' = b^k$,并不妨设 $k = p^(r_1)$,从而上式变为:
// // $
// // (a, b^(k + ord(a'))) in H
// // $
// 设 $x = (a, b)$ 是 $H$ 中最高阶元素,阶为 $p^r$,并不妨设 $ord(a) = p^r$。显有 $H$ 中所有元素的阶都是 $p^r$ 的因子。\
// 若结论不成立,则将存在非平凡元素:
// $
// x_1 = (a_1, b_1)\
// x_2 = (a_2, b_2)
// $
// 使得$H' <= H, H' = generatedBy(x)generatedBy(x_1)generatedBy(x_2) tilde.eq generatedBy(x) times generatedBy(x_1) times generatedBy(x_2)$
// - 注意到 $ord(x_i) | p^r$,故有:
// $
// ord(a_i) | p^r
// $
// 进而:
// $
// a_i in generatedBy(a)
// $
// 从而不妨设 $a_1 = a^(k_1), a_2 = a^(k_2)$,我们有:
// $
// (a_1, b_1)Inv(((a, b)^(k_1))) = (1, b_1 b^(k_1)) in generatedBy(x) generatedBy(x_1)\
// (a_2, b_2)Inv(((a, b)^(k_2))) = (1, b_2 b^(k_2)) in generatedBy(x) generatedBy(x_2)
// $
// - 由假设,应有:
// $
// generatedBy((e, b_1 b^(k_1))) sect generatedBy((e, b_2 b^(k_2))) subset generatedBy(x) generatedBy(x_1) sect generatedBy(x) generatedBy(x_2) = generatedBy(x)
// $
// 然而在 $generatedBy(x)$ 中,第一分量为单位元的元素只有 $(e, e)$,进而:
// $
// generatedBy((e, b_1 b^(k_1))) sect generatedBy((e, b_2 b^(k_2))) = {(e, e)}\
// => generatedBy(b_1 b^(k_1)) sect generatedBy(b_2 b^(k_2)) = {e}
// $
// - 除非 $b_1 b^(k_1) = b_2 b^(k_2) = e $,否则这是不可能的,而若前式成立,将有:
// $
// (a_1, b_1)Inv(((a, b)^(k_1))) = e => (a_1, b_1) in generatedBy(x)\
// (a_2, b_2)Inv(((a, b)^(k_2))) = e => (a_2, b_2) in generatedBy(x)
// $
// 这也与假设不符!
// ]
//由引理,我们只需考虑 $G$ 的形如 $ZZ_(p^(r_1)) times ZZ_(p^(r_2))$ 型子群即可。
//
//另一方面,对任意 $H <= G$,注意到在两个投影映射 $pi_1, pi_2$ 下,有:
// $
// pi_1(H) <= pi_1(G) = ZZ_(p^m)\
// pi_2(H) <= pi_2(G) = ZZ_(p^n)
// $
//这表明:
// - $H$ 中必然存在形如
] //
= 9.
#answer[
+ 若有限生成交换群是有限群,显然它的生成元都是有限阶元素。
+ 设生成元都是有限阶元素,显有:
$
generatedBy(a_1\, a_2\, ...\,a_n ) = {a_1^k_1 a_2^k_2 ... a_n^k_n | k_i in ZZ_+, k_i < max(ord(a_i))}
$
这当然是有限群
]
= 10.
#answer[
$75 = 3 dot 25$,利用 Sylow 定理:
$
3 | n_3 - 1, n_3 | 25 => n_3 = 1, 25\
5 | n_5 - 1 , n_5 | 3 => n_5 = 1
$
- 若 $n_3 = 1$,仿照之前习题可知 $G$ 交换,此时唯二的可能为 $ZZ_25 times ZZ_3$ 或 $ZZ_5 times ZZ_5 times ZZ_3$
- 若 $n_3 = 25$,我们有 $normalSub(P_5, G)$,进而:
$
G tilde.eq P_5 times.r ZZ_3
$
换言之,存在 $ZZ_3 -> Aut(P_5)$ 的非平凡同态(否则群将交换),而 $Aut(ZZ_25) tilde.eq ZZ_(20)$ 其中没有三阶子群,因此 $P_5 = ZZ_5 times ZZ_5$。
- 考虑 $Aut(ZZ_5 times ZZ_5)$ 中的三阶元素 $phi$,事实上这等同于找一个 $ZZ_5$ 上的线性变换 $A$ 满足:
$
A^3 = I <=> (A - I)(A^2 + A + I) = 0
$
由于二阶矩阵的最小多项式至多二次,而 $A^2 + A + I$ 已经不可约,故 $A$ 的最小多项式一定为 $A^2 + A + I$,且这样的矩阵都相似于有理标准型:
$
mat(0, -1;1, -1)
$
从而 $Aut(ZZ_5 times ZZ_5)$ 中的三阶元素都共轭于同一个元素,它们将给出相同的 $(ZZ_5 times ZZ_5) times.r ZZ_3$ 结构
]
= P58
== 17.
#answer[
取自然同态:$pi: G -> quotient(G, G')$,由于 $N sect ker(pi) = {e}$,因此:
$
pi|_N : N -> pi(N)
$
将成为同构映射,进而 $N$ 交换。更进一步,对 $forall x in G, n in N$,有:
$
pi(x n Inv(x)) = pi(n)
$
由 $pi$ 是同构即得 $x n Inv(x) = n$,也即 $n in Z(G)$,证毕。
]
== 19.
#answer[
考虑群同态:
$
funcDef(phi, G, quotient(G, H) times quotient(G, K), g, (g H, g K))
$
显有:
$
ker(phi) = H sect K
$
因此:
$
quotient(G, H sect K) tilde.eq im(phi) <= quotient(G, H) times quotient(G, K)
$
另一方面,显然 $quotient(G, H) times quotient(G, K)$ 可解,因此 $im(phi)$ 也可解,故 $G$ 可解。
]
= P65
== 14.
#answer[
//+ 注意到有限 $p$ 群可解,故 $G' != G$,因此 $G'$ 的阶至多为 $p^2$。这就给出 $G'$ 交换。
//
+ 注意到 $p$ 群的中心非平凡,因此 $|quotient(G, Z(G))|=p, p^2$,前者代表 $quotient(G, Z(G))$ 循环,这将导致 $G$ 交换,后者可以导出 $quotient(G, Z(G))$ 交换。
+ 这意味着自然同态:
$
pi: G -> quotient(G, Z(G))
$
是群到交换群的同态,故 $G' <= Z(G)$
+ 然而 $|Z(G)| = p$,而 $G'$ 也不是平凡群(否则 $G$ 交换),故 $G' = Z(G)$
]
== 15.
#answer[
考虑 $G$ 在 $N$ 上的共轭作用,这将自然诱导出 $G -> Aut(N)$ 的同态。\
但 $|Aut(N)| = p - 1$,它与 $p$ 互素,进而作用只能是平凡作用,故 $N <= Z(G)$
]
== 17.
#answer[
由 $G' tilde.eq S_4$ 得 $G'' tilde.eq A_4, G''' tilde.eq V_4, G'''' tilde.eq {e}$。并有显然 $G != S_4$
+ 取自然同态 $pi : G -> quotient(G, G''')$,将有:
$
quotient(G', G''') = pi(G') = (pi(G))' = (quotient(G, G'''))'
$
故上式同构于 $quotient(S_4, V_4)$。
+ 注意到 $6$ 阶群只有两种,交换的 $ZZ_2 times ZZ_3$ 与不交换的 $S_3$。$quotient(S_4, V_4)$ 交换将给出 $G' <= V_4$,这是荒谬的,因此 $quotient(S_4, V_4) tilde.eq S_3$。
+ 记 $quotient(G, G''') = G_1$,有:
$
G_1 ' tilde.eq S_3, G_1 '' tilde.eq A_3 tilde.eq ZZ_3, G_1 ''' = {e}
$
+ 考虑 $G_1$ 在 $G_1 ''$ 上的共轭作用,这将给出 $phi: G_1 -> Aut(ZZ_3)$ 的同态,而 $Aut(ZZ_3) tilde.eq ZZ_2$ 交换,进而:
$
ker(phi) >= G_1 ' = S_3
$
换言之,将有 $phi(S_3) = I$,然而:
$
(12)(123)Inv((12)) = (213) != (123)
$
因此这是荒谬的
]
== 18.
#answer[
设 $a_i$ 互不相同,注意到:
$
(a_1 a_2 a_3)(a_3 a_4 a_5)Inv((a_1 a_2 a_3))Inv((a_3 a_4 a_5)) = (a_1 a_4 a_5)Inv((a_3 a_4 a_5)) = (a_4 a_3 a_1)
$
由 $a_i$ 的任意性知结论成立。又因为 $A_n$ 可被三轮换生成,故 $A_n ' = A_n$
]
= 1.
#answer[
+ 注意到 $quotient(G, G')$ 交换,故显有 $normalSub(quotient(H, G'), quotient(G, G'))$
+ 由商群的对应定理,这就说明 $normalSub(H, G)$
]
= 2.
#answer[
显然对于任意换位子 $[x, y]$,$[alpha(x), alpha(y)]$ 也是换位子,反之亦然,进而群的同构产生换位子上的一一对应,不改变换位子的集合,因此结论显然成立。
]
= 3.
#answer[
- 注意到在换位子:$[x, y]$ 中,一定有偶数个 $s$,也即结果中一定不含 $s$,故 $D'_n subset generatedBy(r)$。
- 同时:
$
r s Inv(r) s = r^2
$
因此 $generatedBy(r^2) <= D'_n$
- 若 $n$ 为奇数,这就表明 $D'_n = generatedBy(r)$
- 若 $n$ 为偶数,断言 $D'_n = generatedBy(r^2)$。事实上:
$
quotient(D_n, generatedBy(r^2))
$
是四阶群,必然交换,故 $D'_n <= generatedBy(r^2)$,这就证明了 $D'_n = generatedBy(r^2)$
]
= 4.
#answer[
前面习题证明自同构不改变换位子,共轭作用作为自同构同样成立。取 $alpha$ 是任意共轭作用,则有:
$
alpha|_G' : G' -> G'
$
是 $G'$ 的自同构,自然有:
$
alpha(G'') = alpha|_G'((G')') = (G')' = G''
$
以此类推易知结论成立
]
= 5.
#answer[
对 $|H|$ 的阶做归纳法,当 $|H| = 1$ 时,由于 $K$ 可解,结论显然成立。\
由 $H$ 可解,有 $H' < H, normalSub(H', H)$,进而:
$
normalSub(H' times.r K, H times.r K)
$
由归纳法,$H' times.r K$ 可解。另一方面,$quotient(H times.r K, H' times.r K) tilde.eq quotient(H, H')$ 也可解,进而 $H times.r K$,证毕。
]
= 6.
#answer[
(1) 由 $quotient(G, N)$ 的正规子群与包含 $N$ 的正规子群间的一一对应,结论显然成立。
(2)使用归纳法对群的阶进行归纳,$|G| = 1$ 时显然成立。
+ 若 $G$ 是单群,则 ${e}$ 就是极大正规子群
+ 若 $G$ 不是单群,则存在非平凡正规子群 $N$。由归纳法,取 $quotient(G, N)$ 的极大正规子群 $quotient(N_1, N)$,由对应法则 $N_1$ 一定就是极大正规子群。
(3)若存在符合要求的子群列,$G$ 可解是显然的。反之,若 $G$ 可解,只需将 $quotient(G, G')$ 分解成题目要求的子群列即可。
事实上,由上面的证明过程,我们可以取得一个包含 $G'$ 的极大正规子群 $N$。
- 注意到 $quotient(G, N)$ 是交换单群,进而是素数阶循环群。
- 进一步,再在 $N$ 中取得一个包含 $G'$ 的极大正规子群 $N_1$,类似可得 $quotient(N, N_1)$ 是交换单群,进而是素数阶循环群。
- 以此类推,容易找到一列 $N$ 使得:
$
G' = N_k triangle.l N_(k_1) triangle.l ... triangle.l N_1 triangle.l N triangle.l G
$
满足任意前后两项的商群都是素数阶循环群,这就是所求的子群列。
]
= P35
== 4
#answer[
加法构成交换群,乘法构成幺半群是显然的,只需验证分配律:
$
phi dot (f + g)(x) = phi((f + g )(x)) = phi(f(x) + g(x)) = phi(f(x)) + phi(g(x)) \
= (phi dot f)(x) + (phi dot g)(x)
$
右分配同理可得。
]
== 6.
#answer[
设 $n$ 阶循环群为 $ZZ_n$,显然 $1$ 的像唯一确定一个自同态。\
定义:
$
funcDef(phi, ZZ_n, End(ZZ_n), a, [x | x -> a x])
$
容易验证 $phi$ 是一一对应。断言它是环之间(将 $ZZ_n$ 看作环)同构:
- 保持单位元:显然
- 保持加法:
$
phi(a + b) = [x | x -> (a + b) x] = [x | x -> a x + b x]\
= [x | x -> a x] + [x | x -> b x]
= phi(a) + phi(b)
$
- 保持乘法:
$
phi(a b) = [x | x -> (a b) x] = [x | x -> a (b x)]\
= [x | x -> a x] dot [x | x -> b x]\
= phi(a) dot phi(b)
$
因此 $End(ZZ_n)$ 就是环 $ZZ_n$
]
== 7.
#answer[
注意到 $ZZ_n times ZZ_n$ 上的自同态就是线性空间 $ZZ_n times ZZ_n$ 上的线性变换,因此:
$
End(ZZ_n times ZZ_n) tilde.eq M_(2 times 2) (ZZ_n)
$
//定义:
//$
//funcDef(phi, ZZ_n times ZZ_n, End(ZZ_n times ZZ_n), (a, b), [(x, y) | (x, y) -> (a x, b y)])
//$
//断言它是环同构:
//- 保持单位元:显然
//- 保持加法:
// $
// phi((a, b) + (c, d)) = [(x, y) | (x, y) -> ((a + c) x, (b + d) y)]\
// = [(x, y) | (x, y) -> (a x, b y)] + [(x, y) | (x, y) -> (c x, d y)]\
// = phi((a, b)) + phi((c, d))
// $
//- 保持乘法:
// $
// phi((a, b) (c, d)) = [(x, y) | (x, y) -> ((a c) x, (b d) y)]\
// = [(x, y) | (x, y) -> (a x, b y)] dot [(x, y) | (x, y) -> (c x, d y)]\
// = phi((a, b)) dot phi((c, d))
// $
//- 是单射:
// $
// ker(phi) = {(a, b) | (a x, b y) = (x, y), forall (x, y) in ZZ_n times ZZ_n} = {(1, 1)}
// $
//- 是满射:
// $
//
// $
]
== 13.
#answer[
注意到:
$
(1 - a)(1 + a + a^2 + ... + a^(n-1)) = 1 - a^n = 1
$
这表明 $1 - a$ 与 $1 + a + a^2 + ... + a^(n-1)$ 互为逆元。
]
= P45
== 9.
#answer[
$HH_0$ 是加法群的子群显然,只需验证:
- 乘法封闭:
$
(a + b I + c J + d K)(x + y I + z J + w K) \
= (a x - b y - c z - d w) + (a y + b x + c w - d z) I \ + (a z - b w + c x + d y) J + (a w + b z - c y + d x) K
$
显然这些系数都是有理数
- 有乘法逆元:
$
(a + b I + c J + d K)(a - b I - c J - d K) = a^2 + b^2 + c^2 + d^2 \
=> (a + b I + c J + d K)(1/(a^2 + b^2 + c^2 + d^2) (a - b I - c J - d K)) = 1
$
它的逆的各系数是有理数,因此 $HH_0$ 是乘法群的子群
]
== $R = {a + b I + c J + d K | a, b, c, d in ZZ}$ 是子环并确定乘法群
#answer[
前面的验证也表明 $R$ 对乘法封闭且有幺元,但其元素未必有乘法逆。
事实上,可以看出有乘法逆当且仅当 $a^2 + b^2 + c^2 + d^2 = 1$,因此可逆元仅有 $plus.minus 1, plus.minus I, plus.minus J, plus.minus K$
]
== 10.
#answer[
设 $x = a + b I + c J + d K$ 在中心之中,则有:
- $x I = I x$,表明:
$
- b - c K + d J = -b + c K - d J => c = d = 0
$
- $x K = K x$,表明:
$
a K + c I = a K - c I => c = 0
$
从而 $x = a$。同时,显然 $a$ 在中心之中,因此 $Z(HH_0) = ZZ$
]
= 在 $H$ 中 $x^2 + 1 = 0$ 有无穷多解
#answer[
$
(a + b I + c J + d K)^2 = \
(a^2 - b^2 - c^2 - d^2) + (2 a b) I + (2 a c) J + (2 a d) K
$
可见只需取 $a = 0$,任何满足:
$
b^2 + c^2 + d^2 = 1
$
的四元数 $x$ 均满足 $x^2 = -1$。这是一个球面,当然有无穷多元素
]
= 1.
#answer[
$200 = 2^3 * 5^2$,显然其中所有含有素因子 $2, 5$ 的数都是幂零元,包括:
$
2 * 5 = 10\
2^2 * 5 = 20\
2^3 * 5 = 40\
2 * 5^2 = 50\
2^2 * 5^2 = 100\
2^3 * 5^2 = 200
$
]
= 2.
#answer[
验证:
- 加法结合:
$
(X + Y) + Z = ((X union Y) union Z) \/ ((X sect Y) sect Y) \ = (X union (Y union Z)) \/ ((X sect Y) sect Z) = X + (Y + Z)
$
- 加法交换:显然
- 加法单位元:显然 $X + emptyset = X$
- 加法逆元:显然 $X + (A \/ X) = emptyset = e$
- 乘法结合:显然
- 乘法幺元:显然 $A$ 就是幺元
- 分配律:(由于交换,只验证左结合即可)
$
X (Y + Z) \
= X sect ((Y union Z) \/ (Y sect Z))\
= (X sect (Y union Z)) \/ (X sect (Y sect Z)) \
= ((X sect Y) union (X sect Z)) \/ ((X sect Y) union (X sect Z)) \
= X Y + X Z
$
- $X^2 = X sect X = X$,表明他是布尔环
]
= 3.
#answer[
考虑 $M_2(RR)$ 的由下面若干元素生成的子环:
$
{mat(plus.minus 1, 0;0 ,plus.minus 1)}
$
这是交换环,因为生成元间皆交换,并且满足 $x^2 = 1$ 恰为四个生成元
对于第二个结论,类似的考虑无穷维线性空间上的线性变换即可。\
例如,在 $Hom(RR[x], RR[x])$ 上,考虑如下的元素:
$
f_i (x^j) = cases(x^j " if " j!=i, -x^j " if " j=i)\ forall i in ZZ_+
$
这无穷个元素均满足 $x^2 = 1$,且它们之间皆交换,因此生成的子环就是满足要求的交换环。
]
= 4.
#answer[
$
a + 1 = (a + 1)^3 = a^3 + 3a^2 + 3a + 1 => a^3 + 3a^2 + 2a = 0 => 3a^2 + 3a = 0\
0 = 3(a+1)^2 + 3(a+1) = 3a^2 + 6 a + 3 + 3a + 3 = 6a + 6
$
取 $a = 1$,得:
$
6 + 6 = 0 => 12 = 0
$
取 $a = 2$,得:
$
12 + 6 = 0 => 6 = 0
$
从而 $6a = 0$
同时:
$
a - b = (a - b)^3 = (a - b)(a^2 -a b -b a +b^2)\
= a^3 - a^2 b - a b a + a b^2 - b a^2 + b a b + b^2 a - b^3\
=> - a^2 b - a b a + a b^2 - b a^2 + b a b + b^2 a = 0
$
$
a + b = (a + b)^3 = (a + b)(a^2 + a b + b a + b^2)\
= a^3 + a^2 b + a b a + a b^2 + b a^2 + b a b + b^2 a + b^3\
=> a^2 b + a b a + a b^2 + b a^2 + b a b + b^2 a = 0
$
两式相加减,得:
$
2(a b^2 + b a b + b^2 a) = 0\
2(a^2 b + a b a + b a^2) = 0
$
这表明:
$
0 = 2 a(a^2 b + a b a + b a^2) - 2 (a^2 b + a b a + b a^2)a = 2 a b - 2 b a = 0 => 2 a b = 2 b a
$
另一方面:
$
0 = 3(a+b)^2 + 3(a + b) = 3 a^2 + 3 a b + 3 b a + 3 b^2 + 3 a + 3 b \
= 3 a b + 3 b a = 3(a b + b a)
$
注意到 $6 a = 3 a + 3 a = 0 => 3a = -3a$,因此有:
$
3 a b = 3 b a
$
两式结合便得 $a b = b a$
]
= 5.
#answer[
#lemma[][
若环 $R$ 的加法群循环,则 $R tilde.eq ZZ_(|R|)$
]
#proof[
设 $|R| = n$,记其加法群为 $ZZ_n$,定义:
$
funcDef(phi, R, ZZ_n, x = n dot 1, n)
$
验证:
- 保持幺元:显然
- 保持加法:
$
phi(n dot 1 + m dot 1) = (n + m) dot 1 = phi(n dot 1) + phi(m dot 1)
$
- 保持乘法:
$
phi((n dot 1) (m dot 1)) = phi((n m) dot 1) = n m = phi(n dot 1) phi(m dot 1)
$
这就表明结论成立。
]
设环 $R$ 的元素少于八个,考虑以下几种情况:
- $|R| = 1, 2, 3, 5, 7$,它们都是素数,从而加法群将成为循环群。由引理这些环交换,
- $|R| = 4 = 2 dot 2$。若加法群是 $ZZ_4$,则类似的环交换。除 $ZZ_4$ 外的 $4$ 阶群只有一种 $ZZ_2 times ZZ_2$
此时在加法群中四个元素是对称的,不妨设 $(1, 1)$ 是乘法单位元,从而:
$
(0, 1)(1, 0) = (0, 1)((1, 1) - (0, 1)) = (0, 1) - (0, 1)^2 \
= ((1, 1) - (0, 1))(0, 1) = (1, 0)(0, 1)
$
足以表明 $R$ 交换
- $|R| = 6 = 2 dot 3$,这时除循环群外的交换群只有 $ZZ_2 times ZZ_3$
由对称性,不妨设 $(1, x)$ 是单位元,从而:
$
(0, 1)(0, -1) = ((0, 0) + (0, 1))((0, 0) - (0, 1)) = - (0, 1)^2\
(0, -1)(0, 1) = ((0, 0) - (0, 1))((0, 0) + (0, 1)) = - (0, 1)^2 = (0, 1)(0, -1)\
(1, x - 1) dot (1, x + 1) = (1, x)^2 - (0, -1)(0, 1) + (0, 1)(0, -1) - (0, 1)^2\
= (1, x)^2 - (0, 1)^2 = (1, x + 1) dot (1, x - 1)
$
上面两个式子足以验证所有第一分量相等的两数乘法可交换(注意到第一分量为 $1$ 的元素只有 $(1, x), (1, x-1), (1, x+1)$\
再验证:
$
(0, a)(1, b) = ((1, x) - (1, x - a))(1, b) = (1,x)(1, b) - (1, x-a)(1, b) \
= (1, b) - (1, x-a)(1, b) = (1, b) - (1, b)(1, x-a)\
= (1, b)(0, a)
$
表明 $R$ 是交换环。
对于八元非交换环,考虑 $R = M_(2 times 2)(ZZ_2)$ 中的上三角矩阵构成的子环:
$
{mat(a, b;0, c) | a, b, c in ZZ_2}
$
注意到:
$
mat(1, 1;0, 1)mat(1, 0;0, 0) = mat(1, 0;0, 0)\
mat(1, 0;0, 0)mat(1, 1;0, 1) = mat(1, 1;0, 0)
$
从而它确实不是交换环。
]
= 6.
#answer[
我们的目标是证明 $omega^2 != a + b omega, a, b in ZZ$,进而它不是子环。只需证明不存在 $f(x) in ZZ[x]$ 使得 $f(omega) = 0$ 即可。\
事实上,设 $g(x) = x^3 - 2 = (x - omega)(x^2 + omega x + omega^2)$,则显有 $g(omega) = 0$。若二次多项式 $f(x) in ZZ[x]$ 满足 $f(omega) = 0$,则有 $f'(omega) = gcd(f,g)(omega) = 0$:
- $f'(omega) = f(x)$,这表明 $f(x)$ 是 $g(x)$ 的因式。从而(在 $RR[x]$ 中) $omega$ 是 $g(x)$ 的重根,但 $omega^2 + omega^2 + omega^2 = 3 omega^2 !=0$,与事实不符。
- $deg(f') < deg (f)$,从而 $deg(f') <= 1$。注意到 $f'(x) in ZZ[x]$,这意味着 $omega in ZZ$,而这是荒谬的。
]
= 7.
#answer[
- 加法群的子群关系是显然的
- 对于乘法:
$
(a_1 + b_1 sqrt(2))(a_2 + b_2 sqrt(2)) = (a_1 a_2 + 2 b_1 b_2) + (a_1 b_2 + a_2 b_1) sqrt(2) in ZZ[sqrt(2)]
$
因此对乘法也封闭。
- $1 in ZZ[sqrt(2)]$ 显然。
令 $overline(a + b sqrt(2)) = a - b sqrt(2)$,注意到:
$
(a + b sqrt(2))(overline(a + b sqrt(2))) = a^2 - 2 b^2
$
故只要 $a^2 = 2 b^2$,该元素即可逆,而这样的元素当然有无穷多个。
]
= 8.
#answer[
$
&a u + b v = 1\
=>& a^2 u + b (a v) = a\
=>& a^2 (u^2) + b (a u v) = a u\
=>& a^2 (u^2) + b (a u v) = 1 - b v\
=>& a^2 (u^2) + b (a u v + v) = 1 \
$
这表明 $a^2 x + b y = 1$ 有解。同理可得 $a x + b^2 y = 1$ 有解,反复进行立得 $a^m x + b^n y = 1$ 有解。
0
]
|
|
https://github.com/ludwig-austermann/typst-ouset | https://raw.githubusercontent.com/ludwig-austermann/typst-ouset/main/CHANGELOG.md | markdown | MIT License | # Version 0.2
- fixed an issue with typst version 0.11+.
- exchanged styles usage to context usage as intended for typst v0.11+
- improved readme |
https://github.com/OverflowCat/BUAA-Digital-Image-Processing-Sp2024 | https://raw.githubusercontent.com/OverflowCat/BUAA-Digital-Image-Processing-Sp2024/master/expt01/blockcode.typ | typst | #import "@preview/codelst:2.0.1": sourcecode
#import "@preview/showybox:2.0.1": showybox
#let bc = (body, filename: "", type: "normal") => {
let color = {
if type == "wrong" {
red.lighten(92%)
} else if type == "right" {
green.lighten(92%)
} else {
black.lighten(98%)
}
}
showybox(
breakable: true,
frame: (
title-color: black.lighten(25%),
body-color: color,
border-color: black.lighten(80%),
thickness: 1pt,
radius: 3pt,
),
title: if filename == "" { "" } else [
#set text(font: "Roboto Slab", size: .85em)
#filename
],
)[
#show raw: set text(font: ("IBM Plex Mono", "JetBrains Mono", "Noto Sans Mono CJK SC"), size: 1.01em)
#sourcecode(frame: none)[#body]
]
}
|
|
https://github.com/Mufanc/hnuslides-typst | https://raw.githubusercontent.com/Mufanc/hnuslides-typst/master/utils/fonts.typ | typst | #let font = (
FZHT: "FZHei-B01S", // 方正黑体
FZKT: "FZKai-Z03S", // 方正楷体
HYSH: "HYShuHunJ", // 汉仪书魂
HYYK: "HYYanKaiF", // 汉仪颜楷
HYZK: "HYZhongKaiJ", // 汉仪中楷
MSYH: "Microsoft YaHei", // 微软雅黑
GYGK: "YeGenYouGuKeTi3.0", // 叶根友古刻体
KABEL: "Kabel" // Kabel
)
#let fontsize = (
初号: 42pt,
小初: 36pt,
一号: 26pt,
小一: 24pt,
二号: 22pt,
小二: 18pt,
三号: 16pt,
小三: 15pt,
四号: 14pt,
小四: 12pt,
五号: 10.5pt,
小五: 9pt,
六号: 7.5pt,
小六: 6.5pt,
七号: 5.5pt,
八号: 5pt,
)
|
|
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/009%20-%20Born%20of%20the%20Gods/006_The%20Walls%20of%20Akros.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"The Walls of Akros",
set_name: "Born of the Gods",
story_date: datetime(day: 26, month: 02, year: 2014),
author: "<NAME>",
doc
)
#figure(image("006_The Walls of Akros/01.jpg", width: 100%), caption: [Peregrination | Art by Jonas De Ro], supplement: none, numbering: none)
Beneath the two stone monoliths known as the Horns, ten soldiers stood, sweat glistening on their skin. Heliod's light beat down on them, the shadows of the Horns falling ahead of and behind the line where they stood at attention. The shadow ahead of them had crawled tantalizingly closer as they waited, but it still stood a sword's length out of reach.
Leandros desperately wanted to settle into that shade and take a nap. Well, what he #emph[wanted] was to go back to Akros for a bath and some pleasant company, but he'd gladly take the shadow—or a fight, if it came to that. Anything was better than waiting.
Captain Kyrillos stepped out of line. He was sweating just like the rest of them.
"That's long enough," said Kyrillos. He pointed to three of the men. "You three, with me. Bardas, Borias—climb the Horns and see what you can see. Everyone else, take a rest."
Bardas and Borias grinned and bolted toward the Horns, shucking their armor. The two men were not brothers, nor, as far as Leandros had ever determined, lovers. But they were undeniably a pair, and they liked nothing as much as competing with one another. Grunting, sweating, and exchanging colorful insults, they hauled themselves up the great standing stones.
#figure(image("006_The Walls of Akros/04.jpg", width: 100%), caption: [Mountain | Art by <NAME>], supplement: none, numbering: none)
Kyrillos took young Haemon, handsome Nikasios, and steadfast Xanthos to secure a perimeter. Leandros gratefully settled down in the shadow of one of the stones, setting his sword within arm's reach and taking a long pull from his water skin. Mnesos sat, leaning against the stone, his well-worn copy of Perisophia's #emph[Essays on Logic] already in hand. White-bearded Diocles took off his helmet and set it on a rock, running his hand through his thinning hair. And Pallas started doing stretches, the bastard. He was taller and more muscular than any of them save Nikasios, and he liked to show off.
"They're not coming," he said, bent double to touch his palms to the ground.
"Quiet," said Diocles. "Eumalos is a good captain. Not the type to miss a meet-up. If they don't arrive, it's because they're all dead. And you've no right to be so flippant about that."
Both their squad and Eumalos's were part of the Alamon, the wandering soldiers who were as vital to the defense of the polis of Akros as the city walls. The many small squads of the Alamon met up regularly to exchange information and supplies. Missing a rendezvous meant nothing good.
"Ha!" cried Bardas, or maybe Borias, having won their race.
"What do you think, O great scholar?" asked Pallas, now upright again but twisted almost all the way around to look at Mnesos.
"I think there are many possible solutions to the problem of universals, of which the theory of ideal forms is only one," said Mnesos, without looking up.
Pallas snorted.
"Cyclops!" shouted Borias, or Bardas. "Cyclops, from the northeast! Arm yourselves!"
Leandros regained his feet, sword in hand.
Bardas and Borias scrambled down the sides of the Horns as the others rearmed themselves. Mnesos's book disappeared, replaced by a sling and stone. Diocles had his helmet back on within less than a second, and Pallas picked up his spear and wheeled to face the attacker.
The perimeter team made it back around the same time, and the ten soldiers fell into formation as the hulking form of a cyclops lumbered into view from the northeast.
#figure(image("006_The Walls of Akros/05.jpg", width: 100%), caption: [Ill-Tempered Cyclops | Art by <NAME>], supplement: none, numbering: none)
The cyclops was already wounded, dragging one leg and leaving a trail of blood. It gave a cry that was more wail than roar and turned to lope around them.
Pallas reached it first, plunging his spear deep into the thigh of its good leg. It wailed again and backhanded him, sending him sprawling. Borias ran past it to catch its attention while Bardas lunged in to slice across its belly—a wound, although not a deep one. The cyclops lurched past them.
Beside Leandros, behind a wall of shields, Nikasios hefted his spear to throw. If the cyclops had been fighting back, he might have had a shot. But it was still trying to go around them. Taking down a cyclops, even a wounded one, without taking its eye would be a long, bloody business.
"Mnesos!" said Leandros. "Get its attention! Nikasios, be ready."
Nikasios nodded.
The scholar backed off from the group, loaded his sling, and whirled a stone around his head.
There was a crack as Mnesos's stone met the cyclops's skull, and the creature roared. It whirled around to spot its attacker—and found the point of Nikasios's spear instead. It screamed, clutching at the spear, blood streaming down its face, and the squad surged forward.
#figure(image("006_The Walls of Akros/06.jpg", width: 100%), caption: [Coordinated Assault | Art by <NAME>], supplement: none, numbering: none)
Leandros rushed forward, ducked beneath flailing arms, and sliced the tendon on the cyclops's good leg as he passed. The cyclops dropped to its knees, and the squad surrounded it and finished it off. Leandros didn't see who landed the final blow, but the kill was Nikasios's if it was anyone's.
"Anyone wounded?" asked the captain.
"Bruised," said Pallas, wheezing. "Gave me a good swat."
"Don't be a hero," said Kyrillos. "Mnesos, take a look at him."
Pallas grumbled, but let Mnesos check him over for serious injury.
Nikasios and Xanthos trotted out around the perimeter while Haemon, the youngest of them, stared at the cyclops.
"Hungry?" asked Bardas, clapping Haemon on the back.
"You eat... cyclops?" asked Haemon.
"Gotta take what you can get out here," said Borias.
Haemon turned pale.
"You don't eat cyclops," said Diocles, scowling at Bardas and Borias. "Unless you're starving. And even then it might kill you. They're noxious things."
Xanthos returned from the perimeter.
"That's the only one," he said. "And nothing gave chase. Looks like this fellow came all the way from One-Eyed Pass."
"So what's it doing out here?" asked Leandros. "They're pretty territorial, aren't they?"
"Very," said Mnesos, nodding to Pallas. "And a wounded cyclops usually goes to ground."
"Who cares?" said Pallas, who stood and stretched. "It's just a cyclops."
"I don't think these wounds were inflicted by Akroans," said Nikasios. He was shifting the cyclops's body with his spear to get a better look at it. "This other leg was mauled, not cut."
"Another cyclops?" asked Leandros.
"No," said Diocles. "Something smaller. Another cyclops would've just brained him with a boulder."
"I've heard enough," said Kyrillos. The rest of the squad fell silent. "Eumalos's squad missed the rendezvous, and there's something besides our soldiers in One-Eyed Pass that can drive off a cyclops. We're going to check it out."
Nikasios nodded. Pallas scowled. Diocles frowned. No one spoke.
"Mnesos, leave a sign," said Kyrillos. "Then let's get moving."
The scholar pulled out a charcoal and wrote the time and date in his impeccable handwriting on the near side of one of the Horns, so the next squad of Alamon who passed this way would know they had been here.
The ten soldiers marched in formation, leaving the dead cyclops behind.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
The squad camped restlessly for the night on a rocky outcropping. Above it, where glowing constellations had once acted out the stories of the gods, there were only stars.
Mnesos sat apart from the group, staring up at the sky. Leandros came and sat beside him, staying silent for a time.
#figure(image("006_The Walls of Akros/07.jpg", width: 100%), caption: [], supplement: none, numbering: none)
"Why have the gods abandoned us?" asked Leandros.
"On that," said Mnesos, "no one seems able to agree. For their own reasons, no doubt."
"Will they return?"
"The historians tell us that this is not the first time the gods have retreated into Nyx," said Mnesos. "I doubt it will be the last."
Leandros nodded.
"Should I still pray?" he asked.
"Hard to say," said Mnesos. He turned toward Leandros. "But I do."
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
They followed the cyclops's trail up into the hills, a winding path that took them into narrow gullies and winding canyons. The blood trail dried up, and with no footprints to follow on the windswept stone, they marched on toward One-Eyed Pass.
#figure(image("006_The Walls of Akros/08.jpg", width: 100%), caption: [Mountain | Art by Adam Paquette], supplement: none, numbering: none)
That afternoon, in the shadows of the sheer rock faces that marked the entrance to the pass itself, they found a scene of carnage. There were nine Akroans lying on the ground, their bodies already bloating in the heat. The smell of blood and putrescence was oppressive.
The bodies had been butchered, their battered armor scattered around the pass. The heads were all missing.
Mnesos covered his mouth and nose with a cloth. Haemon looked as though he might faint. Leandros felt sick with fury.
"That's Eumalos," said Diocles quietly, pointing to one of the bodies. "I recognize his sword."
"Tracks," said Xanthos, pointing past the bodies, where the blood had marked the assailants' passage. "Minotaurs."
The far edge of the mess was a tangle of bloody hoofprints the size of dinner plates.
"Keep moving," said Kyrillos. "We need to get to the outpost."
"But the bodies—" stammered Haemon.
"They're not getting any deader," said Kyrillos. "Come on."
The squad formed up. Leandros muttered a prayer to Athreos, who ferried souls to the Underworld, and hoped that the River Guide was still listening.
"Better vengeance than remembrance," said Mnesos. It sounded like he was quoting something, although Leandros didn't know what.
Haemon lingered by the body of Captain Eumalos. Nikasios put a hand on his shoulder.
"We'll come back for them," he said.
Haemon nodded, and the ten living soldiers moved on.
In the pass itself, the scattered bodies of cyclopes and minotaurs made grim decoration. The minotaurs had been flattened by boulders or smashed against the stone walls, and a few looked like they'd been set upon by their fellows. The cyclopes had fared worse.
Behind them, rocks crashed. Leandros spun to see boulders tumbling into the canyon behind them, blocking their exit.
#figure(image("006_The Walls of Akros/09.jpg", width: 100%), caption: [Boulderfall | Art by <NAME>], supplement: none, numbering: none)
From ahead of them came the sound of savage cries and thundering hooves, and then the first minotaurs rounded the corner.
At the head of the minotaur horde was a hulking brute carrying a sword. It bellowed insensibly, driving the others forward.
"Ready for charge!" yelled Kyrillos.
The squad was already forming up around him, shields up and spears out. The close quarters would buy them some time, but they were sorely outnumbered.
"They trapped us!" said Bardas.
"Minotaurs don't set traps," said Mnesos.
"Did you read that in a book?" snapped Pallas.
#figure(image("006_The Walls of Akros/10.jpg", width: 100%), caption: [<NAME> | Art by <NAME>], supplement: none, numbering: none)
Nikasios and Bardas skewered the first minotaurs to reach them. Another got past the spears, and Haemon got his sword up in time for the creature to impale itself. Then the horde was upon them, and tactics fell by the wayside.
A slavering minotaur that was already missing an arm lunged at Leandros, its remaining hand outstretched. Leandros bashed it in the face with his shield, then sliced one of its legs. It went down under the crush of hooves.
Kyrillos was barking orders from behind Leandros, fighting from the rear to keep a full view of the situation. Bardas and Borias fought back to back, shielding each other and hacking at the minotaurs around them. But they were being surrounded, cut off from the group.
Mnesos fought beside Leandros, muttering to himself about minotaurs, their tactics, and their supposed lack of intelligence. Pallas took risk after risk, throwing himself into the fray whenever he saw an opening and being fast enough, so far, to make it out again. Xanthos and Diocles flanked Haemon, covering any missteps. And Nikasios seemed to appear wherever he was needed, a quick spear thrust here and there buying crucial moments for his companions.
One of the minotaurs raised a stone sledge to batter Leandros, but Diocles got his shield up, and instead the axe came down on his shield-arm with a splintering sound. Diocles cried out but kept his feet, and Nikasios rammed his spear into the minotaur's chest.
Haemon stepped forward to finish the job, but another minotaur loomed, raising a massive axe. Then Xanthos was there, sword in hand. He lunged toward the minotaur, but he was too slow. The axe fell, and split him from shoulder to thigh.
Pallas roared and ran forward, batting aside the minotaur's clumsy backswing, and disemboweled it. Diocles dropped his sword and pulled Haemon back with his good hand. Leandros took a defensive stance, to cover their escape.
Another cry, to his left, and Mnesos was bent double around a minotaur's clawed hand. Leandros took the hand off, and the minotaur bellowed in pain. A quick, clumsy thrust from Nikasios was too wild to hit, but it got the thing to step back. Mnesos fell to the ground, moaning, blood seeping from his stomach.
From out of sight, Bardas or Borias cried out in rage.
They had killed dozens of minotaurs, but they were losing ground, backing toward the wall of fallen stone. Leandros tried to drag Mnesos with them, but every time he bent down, he had to straighten to block another blow. The scholar vanished behind a wall of matted fur and stomping hooves.
Haemon was back on his feet, weeping openly, taking chances. Nikasios's omnipresent defense was finally being overwhelmed. Kyrillos had stopped giving orders, focusing on the fight at hand. Pallas was panting, covered in blood, and his swings were getting slower.
Leandros's arms ached. He tried not to think about Mnesos.
#figure(image("006_The Walls of Akros/11.jpg", width: 100%), caption: [], supplement: none, numbering: none)
The brute who had led the horde into the canyon finally stepped into the fight. It was easily ten feet tall, snarling defiance. It raised its blade and attacked.
Nikasios's spear skidded off its chest, taking only a strip of skin, and the blade came down at him. Nikasios lurched to one side, but the minotaur struck his leg, severing it. Nikasios cried out. Haemon ran forward, but the brute grabbed him by the head and threw him against the canyon wall with a sickening crack.
The minotaur swung at Pallas, who dodged. Now it was off balance, arms flung wide. Leandros and Pallas hacked at its sword arm, but its thick hide and makeshift armor deflected their blows. Diocles dragged Nikasios away from the stamping hooves.
Kyrillos had the opening, and he went for it. He stepped forward and rammed his sword up to the hilt in the minotaur's gut.
The minotaur howled and slammed Kyrillos to the ground with one huge fist, then brought one hoof down on his chest. It leered down at him, drooling.
#figure(image("006_The Walls of Akros/12.jpg", width: 100%), caption: [Hero's Downfall | Art by <NAME>ancoast], supplement: none, numbering: none)
Leandros cut the tendons in its leg, and it fell to its knees. Pallas's sword made a great arc and severed the minotaur's head. Its body slumped onto the fallen captain, spurting blood.
More minotaurs came, the last stragglers, but they had seen their leader fall, and they were scattering. Nikasios bound his own leg as Diocles, working with one arm, tried to push the massive minotaur's body off of the captain.
Pallas hacked at the fleeing minotaurs, shouting his rage, and Leandros tried to keep up. Soon they were alone, awash in blood, although the sound of growling voices and trampling hooves told them there were more minotaurs nearby.
Leandros found Mnesos's body, trampled and barely recognizable. He reached into the scholar's pack and pulled out #emph[Essays on Logic] , hoping to save it. The book was soaked in blood, useless. He left it on Mnesos's body.
Pallas helped Diocles heave the minotaur leader's body off of the captain. Kyrillos was dead, his eyes glassy, helm askew, staring up into the sun.
Leandros found Borias next, slumped over next to the still form of Bardas. He'd been run through the shoulder with one of their own spears, and both of his legs were broken. Leandros bent down next to him.
"We had a b—" stammered Borias, staring down at Bardas's body. "A b-bet. Who'd live longer. There's a jar of, of money. In m-my quarters back home. We added to it every time we left. I guess... I guess I won."
He looked up at Leandros.
"You can have it," he mumbled. "The money. I don't think... I'll have... much use for it."
He shuddered, and his eyes went glassy. His ragged breathing slowed and stopped.
Leandros straightened.
There were four of them left. Nikasios was still conscious, leaning against a rock and gripping his spear with white knuckles. Diocles, his beard streaked with red, had gotten the battered shield off his left arm, which hung uselessly at his side. Pallas was still standing, but he couldn't seem to catch his breath. Leandros himself was untouched, through luck or fortune.
"Minotaurs don't act like this," said Diocles, sounding more weary than pained. "Something's wrong. They lured us, and they trapped us."
He looked down at the captain, and his eyes focused.
"We need to warn Akros," he said. "The minotaurs are hunting the Alamon, deliberately. If they can plan that, they can plan an attack on the city. Who can still run?"
Nikasios stared down at the stump of his leg.
"I can," said Leandros.
"Nope," said Pallas, his breath coming fast and shallow. "Not happening."
"What's wrong?" asked Leandros. "I didn't see you take a blow."
"Didn't," said Pallas. "Felt something pop, during the fight. Right where the cyclops got me yesterday. I wouldn't make it a mile."
He managed a grin.
"I can buy you some time, though," he said.
The sounds of rumbling voices and hooves scraping on stone grew louder.
"I can't just leave you here," said Leandros.
"Go," said Diocles. "Whoever stays, dies. But it might not be too late to warn Akros. Climb out of here, and run."
Nikasios hauled himself up onto a rock. He nodded to Leandros, spear at the ready.
"Get out of here," said Pallas.
He turned to face the far end of the canyon, then turned back.
"Tell them we went down fighting, will you?"
"I will," said Leandros.
Then more minotaurs poured into the canyon, and Leandros turned to climb the tumbled boulders.
#figure(image("006_The Walls of Akros/13.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none)
Behind him, Nikasios banged his spear against his shield, and Pallas yelled insults at the minotaurs, until the sound of hooves on stone drowned them out.
Leandros reached the top, and ran, and did not look back.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
He ran for a full day and more, dodging roving bands of minotaurs and fighting to keep his eyes open. Occasionally he came upon squads of fallen Alamon, and signs that large bands of minotaurs had passed this way.
By the time he caught sight of Akros, night had fallen for a second time. In the darkness, it took him a moment to realize that something was wrong. He slowed, then stopped, a vast blankness blotting out what should have been view of the city.
A wall. Someone—#emph[minotaurs] —had built a wall around Akros, to keep the Alamon out while they besieged the city. It was a ramshackle thing, ugly and probably flimsy, but the Alamon were lightly armed and had no siege equipment. Even if any of them had survived the onslaught out in the wilds, they would have to besiege the siege camp themselves.
In the skies directly above Akros, stars flared to sudden, brilliant life, regaining color and motion for the first time in many weeks. Slowly, two figures took shape: brave Iroas and savage Mogis, the twin gods of warfare, respective patrons of the Akroans and the minotaurs. They grappled in the sky, fighting the latest battle in their long and brutal conflict.
#figure(image("006_The Walls of Akros/14.jpg", width: 100%), caption: [], supplement: none, numbering: none)
But the gods had not returned to #emph[Theros] . The twins were interested in each other, not mortals. There would be no help from that quarter.
Leandros fell to his knees.
He was too late. Even the gods could not stop this disaster.
The siege of Akros had begun.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#figure(image("006_The Walls of Akros/15.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none)
|
|
https://github.com/Myriad-Dreamin/tinymist | https://raw.githubusercontent.com/Myriad-Dreamin/tinymist/main/crates/tinymist-query/src/fixtures/modules/may_import.typ | typst | Apache License 2.0 | // path: base.typ
-----
// this may happens in cetz
#let evil_import() = import "base.typ"
|
https://github.com/herbertskyper/HITsz_Proposal_report_Template | https://raw.githubusercontent.com/herbertskyper/HITsz_Proposal_report_Template/main/README.md | markdown | MIT License | ## ⚠️ 警告
本模板仅适合尝鲜 Typst 特性,暂不适用于正式的写作
## 1.用途
本项目适用于哈尔滨工业大学(深圳)大一立项项目的开题报告,是typst模板
## 2.使用方法
clone本项目后在Vscode中安装Typst LSP和Typst Prview后直接预览main.typ即可
本项目提供两种立项报告(第二部分)的页面,一种是`#block_content`,可以跟随文本调整页面框的高矮(默认),第二种是`#rect_content`,可以自定义页面框的大小
## 3.待解决问题
1.中文无法加粗的问题(现官方已支持)
2.封装以简化main.typ
3.美化
## 4.参考项目
https://github.com/chosertech/HIT-Thesis-Typst
https://github.com/nju-lug/nju-thesis-typst
## 5.预览效果
[main.pdf](https://github.com/herbertskyper/HITsz_Proposal_report_Template/blob/document/main.pdf)
|
https://github.com/crd2333/crd2333.github.io | https://raw.githubusercontent.com/crd2333/crd2333.github.io/main/src/components/TypstTemplate/template.typ | typst | #import "/src/components/TypstTemplate/lib.typ": *
#show: project.with(
title: "",
lang: "zh",
) |
|
https://github.com/pku-typst/unilab | https://raw.githubusercontent.com/pku-typst/unilab/main/template.typ | typst | MIT License | #import "@preview/chic-hdr:0.4.0": *
#import "@preview/unify:0.4.3": *
#import "@preview/linguify:0.4.0": *
#import "@preview/oxifmt:0.2.0": strfmt
#import "titlepage.typ": title-page
#let 宋体 = "SimSun"
#let 黑体 = "SimHei"
#let TITLE-FONT = 黑体
#let SUBTITLE-FONT = 黑体
#let TEXT-FONT = 宋体
#let supportedLanguages = ("zh", "en")
#let __template_db = eval(load_ftl_data("./L10n", supportedLanguages))
#let objectives = [
= #linguify("objectives", from: __template_db)
]
#let principles = [
= #linguify("principles", from: __template_db)
]
#let apparatus = [
= #linguify("apparatus", from: __template_db)
]
#let procedure = [
= #linguify("procedure", from: __template_db)
]
#let data = [
= #linguify("data", from: __template_db)
]
#let analysis = [
= #linguify("analysis", from: __template_db)
]
/// Setup the lab report document
/// - `course-name`: The name of the course
/// - `exper-name`: The name of the experiment
/// - `exper-date`: The date of the experiment
/// - `handin-date`: The date of handing in the report
/// - `week-no`: The week number of the experiment
/// - `exper-no`: The ordinal number of the experiment
/// - `student-no`: The student number
/// - `student-name`: The student name
/// - `faculty`: The faculty name
/// - `class`: The class name
#let labreport(
course-name: none,
exper-name: none,
exper-date: none,
handin-date: none,
week-no: none,
exper-no: none,
student-no: none,
student-name: none,
faculty: none,
class: none,
logos: (none, none),
doc,
) = {
let ord-str = [
#if exper-no != none {
linguify("exper-ord", args: (exper-no: exper-no), from: __template_db)
} else if week-no != none {
linguify("exper-week", args: (week-no: week-no), from: __template_db)
} else {
none
}
]
// Generate title page
title-page(
title: course-name,
subtitle: [
#ord-str \
#exper-name
],
author: [
#{
let from = if class != none {
if faculty != none {
[#faculty #h(1em) #class]
} else {
[#class ]
}
} else {
if faculty != none {
[#faculty ]
} else {
none
}
}
if from != none [
#from \
] else {
none
}
} #student-name \ #student-no
],
bottom-text: [
#linguify("exper-date", args: (exper-date: exper-date), from: __template_db) \
#linguify("handin-date", args: (handin-date: handin-date), from: __template_db)
],
logos: logos,
)
// Set header & footer
show: chic.with(
chic-footer(),
chic-header(
left-side: text(course-name, size: 9pt),
center-side: text(ord-str, size: 9pt),
right-side: text(exper-name, size: 9pt),
),
chic-separator(0.5pt),
chic-offset(16pt),
chic-height(64pt),
)
// Miscellanous settings
// Numbering
set math.equation(numbering: "(1)")
set heading(numbering: "1.1.")
// Spacing
set list(indent: 2em)
set enum(
indent: 2em,
spacing: 2em,
)
set par(first-line-indent: 2em)
show heading: content => [
#content
#if content.level <= 1 {
v(0.5em)
}
]
// Fonts
set text(
font: TEXT-FONT,
style: "normal",
weight: "regular",
)
// Table
set table(stroke: (thickness: 0.5pt, paint: black))
doc
}
|
https://github.com/Mufanc/hnuthss-template | https://raw.githubusercontent.com/Mufanc/hnuthss-template/main/pages/substance.typ | typst | #import "@preview/i-figured:0.2.4"
#import "/configs.typ": font, fontsize
#import "/components.typ": paragraph, fp, rfp, hstack
#let number(..nums) = [
#text(
// 略微放大编号字体以适应 Word 中的视觉效果
size: 1.05em,
// 一级标题编号需要加粗
weight: if nums.pos().len() == 1 { "bold" } else { "regular" } ,
nums.pos().map(str).join(".") + " "
)
]
#let main = paragraph[
// 图表样式
#show figure: i-figured.show-figure
// 图下五号宋体加粗
#show figure.where(kind: image): set text(size: fontsize.L5, weight: "bold")
#show figure.where(kind: image): fig => [
#show figure.caption: cap => pad(top: 0.5em, cap)
#fig
]
// 表上五号宋体加粗
#show figure.where(kind: table): set figure.caption(position: top)
#show figure.where(kind: table): set text(size: fontsize.L5, weight: "bold")
// 重设代码框内的行距
#show figure.where(kind: raw): set par(leading: 1em)
// 代码框样式
#show figure.where(kind: raw): fig => [
#show figure.caption: cap => pad(top: 0.5em, cap)
#fig
]
// 三线表
#show figure.where(kind: table): fig => [
#show table: set table(stroke: (x, y) => if y == 0 { (bottom: 0.5pt) } else { none })
#show table: tbl => [
#v(-0.8em)
#box(stroke: (top: 1pt, bottom: 1pt), tbl)
]
#fig
]
// 标题字号
#show heading: set text(size: fontsize.L4s)
#show heading.where(depth: 1): set text(size: fontsize.L3)
// 标题字体
#show heading: set text(font: font.sans, weight: "regular")
// 处理逆天需求
#set heading(numbering: number)
#v(-4em)
= 绪论
== 中西文混排测试
在「原神」的世界里,我们被带入了一个神秘而古老的大陆 —— Teyvat(提瓦特)。This is a world full of magic and wonders, 每一个角落都蕴藏着无尽的探索与冒险。
在这个充满魔法的世界中,我们与各种各样的角色相遇。There are adventurers from different nations, 有些 wield extraordinary elemental abilities。而其他人则隐藏在阴影中。Their stories intertwine across the continent, 每一个人都有自己的故事与使命。
在 Teyvat 大陆上,people are closely connected to the power of elements. 风、火、水、雷等元素在大陆上流动,塑造着丰富多彩的自然景观。The seven Archons, or gods, of Teyvat are the guardians of the continent, each wielding control over a different elemental power, maintaining balance and order in the world.
#figure(caption: "示例图表")[
// #let A = table.cell(fill: green.lighten(60%))[A]
// #let B = table.cell(fill: aqua.lighten(60%))[B]
#show table.cell: set text(weight: "regular")
#table(
columns: 4,
[], [Exam 1], [Exam 2], [Exam 3],
[John], [--], [A], [--],
[Mary], [--], [A], [A],
[Robert], [B], [A], [B],
)
]
#fp
然而,在这个世界中,我们也可以感受到生活的美好与平静。From bustling cities to serene villages, 每一个地方都散发着独特的魅力。And our companions who accompany us are the true treasures of this world.
However, Teyvat is not only about adventure and battle. In this world, 我们也可以体验到生活的美好与平静。无论是在忙碌的城市还是宁静的乡村,每一个地方都散发着独特的魅力。与我们相伴的 companions 是这个世界的真正 treasures。
在这个充满奇迹的世界中,every adventure in life is worth cherishing. Whether it's exploring the unknown or sharing laughter with friends, every moment is a precious memory. 让我们抛开烦恼,let our spirits soar, and immerse ourselves in this world full of wonders!
== 你说得对
你说的对,但是《原神》是由米哈游自主研发的一款全新开放世界冒险游戏。游戏发生在一个被称作「提瓦特」的幻想世界,在这里,被神选中的人将被授予「神之眼」,导引元素之力。你将扮演一位名为「旅行者」的神秘角色,在自由的旅行中邂逅性格各异、能力独特的同伴们,和他们一起击败强敌,找回失散的亲人——同时,逐步发掘「原神」的真相。
#figure(caption: "不是原神")[
#image("/assets/images/example.jpg", width: 70%)
]
= 高等元素论
== 附着元素和触发元素
游戏中的元素可以大体分为两种情况:
*只存在一瞬的触发元素*:即触发反应的元素(包括反应破盾)。例如对一个附着水的目标上火会触发蒸发反应,此时火元素便为触发元素;*会持续存在的附着元素*:附着到目标身上可持续存在的元素即为附着元素
#figure(caption: "玩舟玩的")[
#hstack(
image("/assets/images/figure-1.jpg", width: 25%),
image("/assets/images/figure-2.jpg", width: 25%),
image("/assets/images/figure-3.jpg", width: 25%),
)
]
#fp
游戏中带有伤害的元素大多具有与角色对敌对单位施加元素相同的规律(称为伤害元素),即附着元素最多只具有约 80% 的最大元素量,伤害元素的最大元素量与最长附着时间符合公式关系。但对于角色自身附着(例如芭芭拉的水环给角色上水)和一些不带伤害的元素(例如海水),这些元素无论作为触发元素还是附着元素所可以拥有的最大元素量都为 100% 的最大元素量,且他们的最大元素量与最长附着时间之间无明显公式关系。
== 元素量与消耗量
元素量为元素本身所具有的且确切存在于游戏中的一种数值,是量化元素的必要工具。同种元素的反复叠加附着不存在反应,为附着元素间的元素量叠加覆盖。元素反应中,触发元素会消耗附着元素的元素量,我们称附着元素被消耗的元素量数值为反应消耗量,这一点对反应破盾的情况同样适用。“强度”不同的元素所对应的最长持续时间与最大元素量不同,最大元素量为元素作为触发元素时所具有的元素量,最长附着时间为元素作为附着元素所能单独存在的最长时间。
= 结论
玩原神玩的
垫
垫
#v(-0.7em)
== 换页测试
#rfp
壹
贰
叁
肆
伍
在这个寂静的午后,阳光透过窗户洒在书桌上,一本书静静地躺在那里,等待着被翻阅。房间里弥漫着淡淡的咖啡香,仿佛时间在这一刻停滞了。窗外的风吹动着树叶,发出微弱的沙沙声,如同一首悠扬的小夜曲,轻柔地拂过耳畔。在这个宁静的时刻,心也变得安静下来,沉浸在这片宁静之中,享受着片刻的宁谧。
#figure(caption: "跳板函数")[
```rust
unsafe extern "C" fn trampoline() {
asm!(
"push {ra}", // 1. backup return address
"push 0", // 2. keep stack aligned (*)
"call {hook}", // 3. call hook callback
"pop rax", // 4. (*) skip
"pop rax", // 5. restore return address
"jmp rax", // 6. jump out!
hook = sym hook,
ra = in(reg) RETURN_ADDR,
options(nostack)
)
}
```
]
我超,引用了好多!
@mao2001
@mao2003
@liu1979
@mao2001ai
@zhang1998
@feng1997
@jiang1983
@gb1996
@mao2000
@wang1998
]
|
|
https://github.com/stephane-klein/asdf-typst | https://raw.githubusercontent.com/stephane-klein/asdf-typst/main/contributing.md | markdown | MIT License | # Contributing
Testing Locally:
```shell
asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]
asdf plugin test typst https://github.com/stephane-klein/asdf-typst.git "typst --help"
```
Tests are automatically run in GitHub Actions on push and PR.
|
https://github.com/yan-aint-nickname/uni | https://raw.githubusercontent.com/yan-aint-nickname/uni/main/oop-matrix-cli/diagrams/count_values.typ | typst | MIT License | // https://xkcd.com/1195/
#import "@preview/fletcher:0.4.3" as fletcher: diagram, node, edge
#import fletcher.shapes: diamond, parallelogram
#set text(font: "Comic Neue", weight: 600)
#let count_values = diagram(
node-stroke: 1pt,
edge-stroke: 1pt,
node((0,0), [Посчитать кол-во элементов\ матриц A, B больше D, Q], extrude: (-2, 0)),
edge("--"),
node((0,1), [Начало], corner-radius: 10pt),
edge("-|>"),
node((0,2), [`count = 0`]),
edge("-|>"),
node((0,3), align(center)[
`i < rows`
], shape: diamond),
edge("-|>", [Да]),
node((0,4), [`j = 0`]),
edge("-|>"),
node((0,5), align(center)[
`j < columns`
], shape: diamond),
edge("-|>", [Да]),
node((0,6), align(center)[
`values[i][j] > X`
], shape: diamond),
edge("-|>", [Да]),
node((0,7), [`count = count + 1`]),
edge("-|>"),
node((0,8), [`j = j + 1`]),
node((0,9), [`i = i + 1`]),
edge((0,5), (-2,5), (-2,9), (0,9), "-|>", [Нет], label-pos: 0.1),
edge((0,8), (1,8), (1,5), (0,5), "-|>"),
edge((0,3), (-3,3), (-3,10), (0,10), (0,11), "-|>", [Нет], label-pos: 0.1),
edge((0,6), (-1,6), (-1,8), (0,8), "-|>", [Нет], label-pos: 0.1),
edge((0,9), (2,9), (2,3), (0,3), "-|>"),
node((0,11), [Вернуть `count`]),
edge("-|>"),
node((0,12), [Конец], corner-radius: 10pt),
) |
https://github.com/kdog3682/mathematical | https://raw.githubusercontent.com/kdog3682/mathematical/main/0.1.0/src/fletcher-canvas.typ | typst | #import "@preview/fletcher:0.5.0" as fletcher: edge, cetz
#let CANVAS_LENGTH = 1cm
#let node(a, b, ..sink) = {
let kwargs = sink.named()
let pos = sink.pos()
let c = a * CANVAS_LENGTH
let d = b * CANVAS_LENGTH
let location = (c, d)
fletcher.node(location, ..pos, ..kwargs)
}
#let cetz-renderer(items) = {
let lib = dictionary(cetz.draw)
for item in items {
lib.at(item.shape)(..item.args, ..item.at("kwargs", default: (:)))
}
}
#let fletcher-canvas(body, background) = {
fletcher.diagram(
debug: 2,
node-outset: 5pt,
render: (grid, nodes, edges, options) => {
cetz.canvas(length: CANVAS_LENGTH, {
cetz-renderer(background)
fletcher.draw-diagram(grid, nodes, edges, debug: options.debug)
})
}, body
)
}
|
|
https://github.com/Functional-Bus-Description-Language/Specification | https://raw.githubusercontent.com/Functional-Bus-Description-Language/Specification/master/src/overview.typ | typst | = Overview
== Scope
This document specifies the syntax and semantics of the Functional Bus Description Language (FBDL).
== Purpose
This document is intended for the implementers of tools supporting the language and for users of the language.
The focus is on defining the valid language constructs, their meanings and implications for the hardware and software that is specified or configured, how compliant tools are required to behave, and how to use the language.
== Motivation
Describing and managing registers can be a tedious and error-prone task.
The information about registers is utilized by software, hardware, and verification engineers.
Typically a specification of the registers is designed by the hardware designer or system architect.
During the design and implementation phases, it changes multiple times due to different reasons such as bugs, requirement changes, technical limitations, or user feedback.
A simple change in a single register may imply adjustments in both hardware and software.
These adjustments cost money and time.
Several formal and informal tools exist to address issues related to register management.
However, they all share the same concept of describing registers at a very low level.
That is, the user has to implicitly define the layout of the registers.
For example, in the case of a register containing multiple statuses, its the user responsibility to specify the bit position for every status.
The FBDL is different in this term.
The user specifies the functionalities that must be provided by the data stored in the registers.
The register layout is automatically generated based on the functional requirements.
Such an approach increases the amount of automatically generated hardware description and software code and decreases the amount of code requiring manual implementation compared to the register-centric approach.
Not only the register masks, addresses, and single read and write functions can be generated, but complete custom functions with optimized access methods.
This, in turn, leads to shorter design iterations and fewer bugs.
== Word usage
The terms #quote[must], #quote[must not], #quote[required], #quote[shall], #quote[shall not], #quote[should], #quote[should not], #quote[recommended], #quote[may], and #quote[optional] in this document are to be interpreted as described in the IETF Best Practices Document 14, RFC 2119.1.
== Syntactic description
The formal syntax of the FBDL is described by means of context-free syntax using a simple variant of the Backus-Naur Form (BNF).
In particular:
#set enum(numbering: "a)")
+ Lowercase words in `constant-width` font, some containing embedded underscores, are used to denote syntactic categories, for example: \
#h(1em) `single_import_statement` \
Whenever the name of a syntactic category is used, apart from the syntax rules themselves, underscores are replaced with spaces thus, "single import statement" would appear in the narrative description when referring to the syntactic category.
+ Boldface words are used to denote keywords, for example: \
#h(1em) *mask* \
Keywords shall be used only in those places indicated by the syntax.
+ A production consists of a left-hand side, the symbol #quote[::=] (which is read as can be replaced by), and a right-hand side.
The left-hand side of a production is always a syntactic category, the right-hand side is a replacement rule.
The meaning of a production is a textual-replacement rule.
Any occurrence of the left-hand side may be replaced by an instance of the right-hand side.
+ A vertical bar ( | ) separates alternative items on the right-hand side of a production unless it occurs immediately after an opening brace, in which case it stands for itself, for example: \
#h(1em) `decimal_digit ::= zero_digit | non_zero_decimal_digit` \
#h(1em) `choices ::= choice { | choice }` \
In the first instance, an occurrence of decimal digit can be replaced by either zero digit or non zero decimal digit.
In the second case, "choices" can be replaced by a list of "choice", separated by vertical bars, see item f) for the meaning of braces.
+ Square brackets [ ] enclose optional items on the right-hand side of a production.
Note, however, sometimes square brackets in the right-hand side of the production are part of the syntax.
In such cases bold font is used.
+ Braces { } enclose a repeated item or items on the right-hand side of a production.
The items may appear zero or more times.
+ The term _declared identifier_ is used for any occurrence of an identifier that already denotes some declared item (declared by a user or by specification, for example, built-in function name).
|
|
https://github.com/RiccardoTonioloDev/Bachelor-Thesis | https://raw.githubusercontent.com/RiccardoTonioloDev/Bachelor-Thesis/main/preface/acknowledgements.typ | typst | Other | #import "../config/variables.typ" : profTitle, myProf, myLocation, myTime, myName
#import "../config/constants.typ" : acknlowledgements
#set par(first-line-indent: 0pt)
#set page(numbering: none)
#pagebreak(to: "odd")
#let acknowledgements_content() = {
align(right, [
#text(style: "italic", [Ogni mattina, alzandoti, pensa a quale prezioso privilegio è essere vivo - #linebreak() respirare, pensare, provare gioia, amare.])
#v(6pt)
#sym.dash <NAME>
])
v(10em)
text(24pt, weight: "semibold", acknlowledgements)
v(3em)
text(style: "italic", "Innanzitutto, vorrei sentitamente ringraziare il " + profTitle + myProf + ", relatore della mia tesi, per la sua disponibilità e per la bellissima esperienza che mi ha permesso di fare.")
linebreak()
text(style: "italic", "Ti ringrazio di cuore Elena, per essere stata un preziosissimo mentore durante tutta questa esperienza, per il tempo dedicatomi, per i tuoi consigli e per la conoscenza che mi hai dispensato.")
linebreak()
text(style: "italic", "Ringrazio profondamente la mia famiglia, il cui supporto è stato inestimabile, per avermi sostenuto in ogni mia scelta.")
linebreak()
text(style: "italic", "Ti ringrazio Alessandro per essere stato la mia costante da quando abbiamo deciso che saremo stati migliori amici, iscrivendoci a quel corso di teatro in inglese. Tu sei la dimostrazione che si può essere fratelli anche se si viene da due mamme diverse.")
linebreak()
text(style: "italic", "Ringrazio infine i miei amici, che sono stati compagni di avventure e hanno condiviso con me sia i momenti belli che quelli più difficili. Un ringraziamento particolare a: Alberto, Anna, Davide, Dennis, <NAME>.")
linebreak()
text(style: "italic","Vi voglio bene, e se la vita è un viaggio, spero continuerete ad essere i miei compagni.")
v(2em)
text(style: "italic", myLocation + ", " + myTime + h(1fr) + myName)
v(1fr)
}
#acknowledgements_content()
|
https://github.com/vsheg/intermediate-ml | https://raw.githubusercontent.com/vsheg/intermediate-ml/main/05-exploratory/01-pca.typ | typst | #import "@preview/physica:0.9.3": *
#import "../defs.typ": *
#import "../template.typ": *
#show: template
= Principal Component Analysis (PCA)
== Intro
#note(
title: [Сrumbs on the floor],
)[
Each data point is represented by three coordinates $x, y, z$, but $z$ is always $0$.
Therefore, the data can be represented by just two coordinates:
$ bold(f) = vec(x, y, 0) quad ->^A quad bold(p) = vec(x, y) quad ->^B quad hat(bold(f)) = vec(x, y, 0). $
It is straightforward to find the linear transformations $A$ and $B$:
$ ub(mat(1, 0, ?;0, 1, ?), A) vec(x, y, 0) = vec(x, y), quad ub(mat(1, 0;0, 1;0, 0), B) vec(x, y) = vec(x, y, 0) $
]
#note(
title: [NB],
)[
In the example above:
- The last column of $A$ is arbitrary, so the choice of transformations is not unique.
- $A$ and $B$ are related: $hat(bold(f)) = B A bold(f)$, thus $B A = I$.
- Since $A$ and $B$ are non-square, they are non-invertible, so $A = B^(-1)$ does *not*
hold.
]
- Principal Component Analysis (PCA) is a feature transformation method that converts the
original features $bold(f)$ into a new set of transformed features $bold(p)$, ensuring
their linear independence:
$
bold(f) = vec(f_1, dots.v, f_k) quad &-> quad bold(p) = vec(p_1, dots.v, p_m),
$
If the original features are linearly dependent, the data resides in a lower-dimensional
space, meaning $m < k$. For clarity, we will assume $m < k$ explicitly.
- The new representation $p_1, ..., p_m$ is constructed as a linear combination of the
original features $f_1, ..., f_k$:
$
p_s = sum_(j=1)^k alpha_(s,j) dot f_j,
$
the coefficients $alpha_(s,j)$ form the matrix $A$, which defines the linear
transformation from $bold(f)$ to $bold(p)$.
- The new, usually lower-dimensional, representation $bold(p)$ must still be informative.
This is achieved by ensuring that $bold(p)$ can approximately restore the original
features $bold(f)$ linearly and with minimal error:
$
hat(f)_j = sum_(s=1)^m beta_(j,s) dot p_s approx f_j,
$
the coefficients $beta_(j,s)$ form the matrix $B$, which defines the linear transformation
from $bold(p)$ back to $bold(f)$.
- The objective of PCA is to minimize the reconstruction error $bold(hat(f)) - bold(f)$ by
finding the optimal linear transformations $A: bold(f) -> bold(p)$ and $B: bold(p) -> bold(f)$:
$
R = sum_(bold(x) in X^ell) norm(hat(bold(f)) - bold(f))^2 = sum_(bold(x) in X^ell) norm(B A bold(f) - bold(f))^2 -> min_(A, B).
$
#note(
title: [Сrumbs on the table.],
)[
Now, the third coordinate equals the table height $h = 1$:
$ vec(x, y, 1) ->^A vec(x, y), quad vec(x, y) ->^B vec(x, y, 1) $
Here, $A$ is the same as before, but no $B$ can restore the original vector exactly.
Formally, if $B$ exists, we could write the system of equations:
$ mat(beta_(1,1), beta_(1,2);beta_(2,1), beta_(2,2);beta_(3,1), beta_(3,2)) vec(x, y) = vec(x, y, 1) => cases(1 x + 0 y = x, 0 x + 1 y = y, beta_(3,1) x + beta_(3,2) y = 1). $
- The coefficients in the first two equations are determined by the identities $x = x$ and $y = y$.
- The third equation cannot yield $1$ for all $x, y$ since it lacks a bias term.
]
#note(
title: [Approximate solution.],
)[
In the example above, we could find $B$ as the pseudoinverse $B = A^+ = (A^Tr A)^(-1) A^Tr$,
but:
- The original vector will only be restored approximately, so $A B approx I$.
- Since the choice of $A$ is arbitrary, the choice of $B$ is also arbitrary. This freedom
allows us to impose additional constraints on the transformations.
]
== Formalism
=== Linear Maps
Matrices $A$ (dimension reducer) and $B$ (dimension adder) are linear maps that work
oppositely: $A$ reduces the dimension of the original features $bold(f)$ to the dimension
of the principal components $bold(p)$, and $B$ restores, as closely as possible, the
original features from the principal components.
$
bold(f) &= vec(f_1, dots.v, f_k) quad &->^A quad bold(p) &= vec(p_1, dots.v, p_m) quad ->^B quad bold(hat(f)) &= vec(hat(f)_1, dots.v, hat(f)_k)
$
This can be written as:
$
bold(p) = A bold(f), wide
hat(bold(f)) = B bold(p).
$
=== Matrix Formulation
The feature matrix $F$ and the principal component matrix $P$ are formed by stacking the
row vectors $bold(f)^Tr = (f_1, ..., f_k)$ and $bold(p)^Tr = (p_1, ..., p_m)$:
$
F := vec(bold(f)_1^Tr, dots.v, bold(f)_ell^Tr), quad P :=
vec(bold(p)_1^Tr, dots.v, bold(p)_ell^Tr)
$
In matrix form, the linear maps $A$ and $B$ are applied as follows:
$
P^Tr = A F^Tr, wide hat(F)^Tr = B P^Tr,
$
or equivalently, by transposing:
$ P = F A^Tr, quad hat(F) = P B^Tr. $
Substituting $P$ into $hat(F)$ yields the following equation:
$
hat(F) = F A^Tr B^Tr = F (A B)^Tr,
$
The approximation $hat(F)$ equals $F$ exactly if $A B = I$. Ideally, $A$ would equal $B^(-1)$,
but in general, $A$ and $B$ are non-square and therefore non-invertible.
=== Pseudoinverse Matrix
$A B = I$ holds if $B$ is the pseudoinverse of $A$:
#note[
$B A = A^+ A = (A^Tr A)^(-1) (A^Tr A) = I$
]
$
B = A^+ = (A^Tr A)^(-1) A^Tr.
$
$A^+$ is exact if $A$ has full rank, but in general, it does not, so the solution is only
approximate:
$ A B approx I. $
== Geometric Interpretation
#note(
title: [Basis Transition Matrix.],
)[
If in vector space $V$, there are two bases: the old one $cal(O): bold(omega)_1, ..., bold(omega)_n$ and
the new one $cal(N): bold(nu)_1, ..., bold(nu)_n$, the vectors of the new basis can be
represented as linear combinations of the old basis vectors:
$ cases(
bold(nu)_1 = hg(alpha_(1,1)) bold(omega)_1 + ... + hg(alpha_(1,n)) bold(omega)_n,
dots.v,
bold(nu)_n = alpha_(n,1) bold(omega)_1 + ... + alpha_(n,n) bold(omega)_n,
) $
The coefficients $alpha_(s,j)$ are the coordinates of the new basis vectors in the
coordinate system of the old basis. These coefficients form the basis transition matrix
(by columns!):
$ A = mat(
hg(alpha_(1,1)), ..., alpha_(n,1);dots.v, dots.down, dots.v;hg(alpha_(1,n)), ..., alpha_(n,n)
) $
This matrix transforms coordinates between bases:
$ {bold(nu)_1}_cal(O) = vec(hg(alpha_(1,1)), dots.v, hg(alpha_(1,n)))_cal(O) = A vec(1, 0, dots.v)_cal(N) = A{bold(nu)_1}_cal(N) $
$ {bold(v)}_cal(O) = A {bold(v)}_cal(N), quad {bold(v)}_cal(N) = A^(-1) {bold(v)}_cal(O) $
]
Matrices $A$ and $B$ resemble transition matrices between bases:
- $A$ transforms vectors from the original basis of features $f_1, ..., f_k$ into a new
space with the basis of principal components $p_1, ..., p_m$. However, since these bases
are in different dimensional spaces, this is only an analogy.
- $B$ performs the reverse transformation, converting from the principal component basis
back to the original basis (approximately).
Since $A$ and $B$ are related by the pseudoinverse operation and perform inverse
transformations, we can focus on one of the matrices. Let it be $B$.
The basis transition matrix stores the vectors of the new basis in the coordinates of the
old basis. As the linear map $B$ transforms principal components into the original
features (approximately):
$ bold(f) approx B bold(p), $
it acts similarly to a basis transition matrix from $bold(f)$ to $bold(p)$, storing the
orthogonal basis of principal axes in the coordinates of the original space.
#note[
The choice of matrix $B$ is flexible, allowing us to impose additional constraints. For
example, we can require that $B^T B$ be diagonal or even the identity matrix:
$ B^T B = mat(1, 0, 0;0, 1, 0) mat(1, 0;0, 1;0, 0) = mat(1, 0;0, 1) $
]
Any basis consists of linearly independent, or orthogonal, vectors, meaning that $B$ stores
orthogonal vectors, and $B^Tr B = Lambda$ is diagonal.
Since the choice of $B$ is not unique, we can use this freedom to demand that $B^Tr B$ be
not just diagonal $Lambda$, but the identity matrix $I$:
$ exists B: B^Tr B = I, $
This implies that $B$ stores not just orthogonal vectors but an *orthonormal* basis of
principal components.
== Risk Minimization
The objective of PCA is to minimize the restoration error.
In this notation, the empirical risk depends on $A$ and $B$:
$
R :&= norm(hat(F) - F)^2 \
&= norm(F A^Tr B^Tr - F)^2 -> min_(A, B).
$
We can reformulate the objective in terms of the new coordinates $P$ and the transition
matrix $B$ by substituting $P = F A^Tr$, which at least reduces one matrix multiplication:
$
R = norm(P B^Tr - F)^2 -> min_(P, B).
$
By differentiating $R$ with respect to $P$ and $B$, we can find the values of $P$ and $B$ at
the extremum:
#columns(2)[
$ pdv(R, P) = 2 (P B^Tr - F) B = 0 \
arrow.b.double \
P = F B (B^Tr B)^(-1) $
#colbreak()
$ pdv(R, B) = 2 P^Tr (P B^Tr - F) = 0 \
arrow.b.double \
B^Tr = (P^Tr P)^(-1)P^Tr F $
$
B
&= F^Tr P ((P^Tr P)^(-1))^Tr \
&= F^Tr P ((P^Tr P)^Tr)^(-1) \
&= F^Tr P (P^Tr P)^(-1)
$
]
#note[
$S = P^Tr P$ is symmetric, i.e. $S^T = S$
]
The objective $R$ depends only on the product $P B^T$, which can result from multiplying
any number of different pairs of matrices:
$ P B^Tr = P I B^Tr = ub((P^* R), P) ub((R^(-1) B^*^Tr), B^Tr) $
#note[
Earlier, we showed that $B$ could be chosen to store an orthonormal basis, but this wasn't
strictly necessary.
It can be demonstrated analytically that it is sufficient to choose $R$ such that $B^T B$ is
diagonal, which is enough to ensure $B^T B = I$. This will determine the form of $B$,
which can then be interpreted as a matrix storing an orthonormal basis.
As the proof involves boring linear algebra, we relied on geometric intuition instead
(though formal proof is possible!). //TODO: add reference.
]
We will use the freedom in choosing $R$ and let $P^Tr P$ and $B^Tr B$ be diagonal:
- $P$ stores the principal components in their respective coordinates.
- $B$ stores the orthonormal "basis" of principal components in the coordinates of the
original space, so $B^Tr B = I$.
$
cases(P^Tr P = Lambda, B^Tr B = I)
$
Now, we can further simplify the expressions for $P$ and $B$:
$
P = F B (B^Tr B)^(-1) = F B I, \
B = F^Tr P (P^Tr P)^(-1) = F^Tr P Lambda^(-1).
$
#columns(2)[
Eliminate $P$:
$ B Lambda = F^Tr F B $
This means that the columns of $B$ are eigenvectors of $F^Tr F$:
$ bold(b)_j dot lambda_j = (F^Tr F) bold(b)_j. $
#colbreak()
Eliminate $B$:
$ P Lambda = F F^Tr P $
This means that the columns of $P$ are eigenvectors of $F F^Tr$:
$ bold(p)_j dot lambda_j = (F F^Tr) bold(p)_j. $
]
|
|
https://github.com/ilsubyeega/circuits-dalaby | https://raw.githubusercontent.com/ilsubyeega/circuits-dalaby/master/Type%201/1/mod.typ | typst | #include "4.typ"
#include "14.typ"
#include "15.typ"
#include "18.typ"
#include "25.typ" |
|
https://github.com/protohaven/printed_materials | https://raw.githubusercontent.com/protohaven/printed_materials/main/class-handouts/class-laser_101-basic_operation.typ | typst |
#import "/meta-environments/env-templates.typ": *
#show: doc => class_handout(
title: "Basic Operation",
category: "Laser",
number: "101",
clearances: ("Rabbit Large Format Laser",),
instructors: ("Someone",),
authors: ("<NAME> <<EMAIL>>",),
draft: true,
doc
)
// Content goes here
= Welcome
Welcome to the Laser Basic Operation class at Protohaven!
#set heading(offset:1)
#include "/common-policy/shop_rules.typ"
#include "/common-policy/tool_status_tags.typ"
#include "/common-policy/filing_a_tool_report.typ"
#set heading(offset:0)
#pagebreak()
= Introduction
This class is an introduction to the large format lasers. The large format lasers can make precise parts out of flat stock, and etch graphics and text onto flat surfaces. The large format lasers are handy when you need a complicated shape cut with precision.
Some example large format laser projects:
- Make a custom wooden box
- Design a jigsaw puzzle
- Put a logo on a surface
== Learning Objectives
After this class, you will be able to:
- Set up and safely operate the large format lasers
- Use LightBurn software to load and control a job
- Handle emergency situations
- Choose appropriate materials for your projects
== Safety
// Important safety notes for this particular class
Large format laser cutters use a very power laser to precisely cut and etch material on the laser bed. The lasers generate enough heat to create a fire risk with some materials, and some materials by release fumes when cut or etched.
Never leave a job running unattended: always be ready to stop the laser if something goes wrong.
If you feel unsure of something, feel free to ask!
== Terminology
// Use new glossary system for this
= Tools
#set heading(offset:1)
#include "/common-tools/laser-large_format.typ"
#set heading(offset:0)
= Software
#set heading(offset:1)
#include "/common-software/inkscape.typ"
#include "/common-software/lightburn.typ"
#set heading(offset:0)
= Concepts
#set heading(offset:1)
#include "/common-concepts/image_types.typ"
#set heading(offset:0)
= Resources
== Internet Forums
- https://forum.laseruser.com/
- https://sawmillcreek.org/forumdisplay.php?8-Laser-Engraving-General-Topics
// == Acknowledgments |
|
https://github.com/Wuvist/typstnotes | https://raw.githubusercontent.com/Wuvist/typstnotes/main/pandoc_tpl.typ | typst | // Some definitions presupposed by pandoc's typst output.
#let blockquote(body) = [
#set text( size: 0.92em )
#block(inset: (left: 1.5em, top: 0.2em, bottom: 0.2em))[#body]
]
#let horizontalrule = [
#line(start: (25%,0%), end: (75%,0%))
]
#let endnote(num, contents) = [
#stack(dir: ltr, spacing: 3pt, super[#num], contents)
]
#show terms: it => {
it.children
.map(child => [
#strong[#child.term]
#block(inset: (left: 1.5em, top: -0.4em))[#child.description]
])
.join()
}
// Some quarto-specific definitions.
#show raw: it => {
if it.block {
if it.lang == "julia" or it.lang =="python" {
let top_right(lang) = style(styles => {
let body = "Python"
if lang == "julia" {
body = "Julia"
}
let w = measure(body, styles).width
place(
dy:-8pt,
dx: 100%- w,
block(fill: luma(255), inset: 4pt, body),
)
})
block(fill: luma(250), width: 100%, inset: 8pt, radius: 2pt, [
#top_right(it.lang)
#it
], )
} else {
block(fill: luma(230), width: 100%, inset: 7pt, radius: 1pt, it)
}
} else {
it
}
}
$body$
|
|
https://github.com/shenxiangzhuang/typst-cn-book | https://raw.githubusercontent.com/shenxiangzhuang/typst-cn-book/master/template/chapters/chap1.typ | typst | MIT License | #import "../../lib.typ": amazed
= Tpyst环境安装 <chapter1>
@chapter1[章节]介绍本地配置#amazed[Tpyst]环境,
#lorem(30)
== Linux系统安装
TODO
#lorem(100)
== Mac系统安装
TODO
#lorem(100)
|
https://github.com/wagaaa/HZAU_Typst | https://raw.githubusercontent.com/wagaaa/HZAU_Typst/main/main.typ | typst | MIT License | #import "dependents/style.typ": *
#import "dependents/figures.typ": *
#import "dependents/appendix.typ": *
#show: project.with(
title: "论文标题",
title_en: "Title",
degree: "硕士",
class: "2222",
abstract_cn: "为进一步规范学位(毕业)论文写作和装订,促进研究生学位(毕业)论文形式标准化,特制订本规范,其各项要求适用于答辩前后的论文,各位研究生在论文写作时务必认真阅读,严格执行。论文组成:一本完整的论文包括:封面、扉页、论文独创性声明及使用授权书、目录、中文摘要、英文摘要、缩略表、正文、参考文献、附录、致谢几个部分。其中正文由前言、材料与方法、结果与分析、讨论等几个部分组成。“论文独创性声明及使用授权书”置于扉页与目录之间。",
abstract_en: "In order to further standardize the writing and binding of degree (graduation) thesis and promote the standardization of the form of graduate degree (graduation) thesis, this specification is specially formulated. Its various requirements are applicable to the thesis before and after the defense. All graduate students must read it carefully and strictly implement it when writing the thesis. Thesis Composition: A complete thesis includes: cover page, title page, thesis originality statement and use authorization letter, table of contents, Chinese abstract, English abstract, abbreviation table, main text, references, appendix, and thanks. The main text consists of several parts such as preface, materials and methods, results and analysis, discussion, etc. \"thesis originality statement and use authorization letter\" is placed between the title page and the table of contents.",
keywords_zh: ("论文","写作","格式","装订"),
keywords_en: ("Essay", "Writing", "Format", "Binding"),
colleage: "华中农业大学理学院", //因为理学院不存在了
candidate: "张三",
candidate_en: "<NAME>",
id: "2021301987654",
major: "应用化学",
major_en: "PRACTICAL CHEMISTRY",
supervisor: "<NAME>",
supervisor_en: "<NAME>",
)
= 前言
前言应包括:研究问题的由来、文献综述、研究目的等基本内容。
研究问题的由来应明确地提出论文研究所针对的科学、生产和经济建设的问题,指出研究这些问题的意义。
== 文献综述
主要回顾与所研究课题相关的学科背景,相关领域的研究进展和存在的问题等,是作者对相关文献阅读、消化后的综合、提炼与升华,反映作者对国内外相关进展的了解和理解的程度。因此,文献综述在叙述前人工作的同时,应有自己的看法和观点。*不应将文献综述写成前人工作的堆砌,也不应象教科书一样写成知识性介绍*。
注意:过去已多次发现在学位论文的“文献综述”和科研论文的“前言”部分整段和部分照抄前人文章的现象,这种现象叫“抄袭”,在文献综述中尤其容易出现,写作时应注意避免。否则被发现后可能会导致不授予学位#cite(<HZAU.Std.>)。
== 研究目的
是在提出问题和综述文献的基础上,阐述学术思想,提出科学假设和假说,提出论文研究要实现的目标或达到的目的。
= 材料与方法
== 试验设计
研究所用的材料应详尽地列出,如生物材料及拉丁文学名、品种名称、菌株名称,实验材料与课题研究有关的各种特征特性,由实验材料所得到的各种衍生材料、实验群体、世代、数量等,清楚地说明各种材料的来源。
== 测定项目与方法
实验方法的描述也应详尽,以能将实验材料与实验结果贯通为准。描述的详尽程度应能使必要时,他人能重复出这一实验。对一些常用的实验方法,可在引用他人文献的基础上,简要加以描述,不必花大量篇幅去交待细节。但对于方法的改进和自己发明的新方法则需要作详细的交待。要注意说明所用的是他人的方法,还是自己发明的方法,还是在前人方法基础上有改进,有什么改进等。
== 数据分析
实验方法还应包括实验设计、田间种植方式、田间管理、试验时间、地点、数据采集(考种)、统计分析方法、所用统计软件、计算机程序等。
= 结果与分析
详尽陈述课题研究结果,在写作时力求条理清晰,层次分明,做到环环相扣,具有严密的逻辑性。避免重复叙述实验方法,也不要作过多的讨论。
对于单表行的表格,可以通过\#简单表格,使用Markdown表格语法快速完成表格。
#简单表格(caption:"成绩分布表", cap_en:"Score Table")[
| *姓名* | *地址* | *身高* | *分数* |
| ------ | ---------- | -------- | ------- |
| John | Second St. | 180 cm | 5 |
| Wally | Third Av. | 160 cm | 10 |
]
#block()[
#show: fix-indent()
若遇到图标后不锁进的情况,请使用`#block`函数包裹文段,并在block内使用`#show: fix-indent()`函数修复。这是Typst渲染的Bug。
]
#图片(caption:"图片示例", cap_en:"Example of Image")[
#image("./assets/sample_image.jpg", height: 40%)
]
= 讨论
详尽陈述课题研究结果,在写作时力求条理清晰,层次分明,做到环环相扣,具有严密的逻辑性。避免重复叙述实验方法,也不要作过多的讨论#bib_cite(<Barber.Olson2012>)。
// 自动生成参考文献
// 请填入你的bib文件路径
#references("/assets/ref.bib")
#附录()
附录出现在“参考文献”的后面。可以包括两部分的内容:(1) 论文的补充材料,如 实验方法、试剂配方、实验数据、公式推导等;(2) 作者简历、在读期间与课题有关的 研究成果,包括发表的论文、出版专著、参加国际会议及论文等。
#致谢()
致谢是发自内心的对论文的完成起到指导和帮助作用的人和单位的感谢,不赞成在 此对导师或其他个人进行赞扬或吹捧。无关的人或单位不要罗列上去。致谢出现在论文的最后。
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/ttt-utils/0.1.0/lib/grading.typ | typst | Apache License 2.0 | #import "assignments.typ": get-questions, _question_counter
/// Fetch the total points which can be reached from the questions metadata
/// ! needs context.
///
/// -> integer
#let total-points() = get-questions().map(q => q.points).sum(default: 0)
/// Sums up all question points, grouped by assignments.
/// ! needs context.
///
/// -> array
#let get_points() = {
let a_count = _question_counter.final().first()
let list = ()
for i in range(a_count) {
let filter = q => (q.points != none and q.num.first() == i+1)
list.push(
get-questions(filter: filter).map(q => q.points ).sum(default: 0)
)
}
return list
}
/// Generate a grade distribution with upper and lower point limits.
///
/// - step (integer): smallest unit of a point. 0.5 for half points and 1 for full points.
/// - max (integer): total points which can be reached.
/// ..args (float, integer, string, content): excepts conditional arguments with a lower bound followed by the grade as content or string.
/// -> array
#let grades(step: 1, max: none, ..args) = {
assert(args.named().len() == 0)
assert(step in (0.5,1), message: "only steps of [0.5] or [1] is supported.")
let args = args.pos()
assert(calc.odd(args.len()))
range(0, args.len(), step: 2).map((i) => (
grade: args.at(i),
lower-limit: if i > 0 { calc.round(args.at(i - 1)) } else { 0 },
upper-limit: if i < args.len() - 1 { calc.round(args.at(i + 1)) - step } else { max },
))
}
/// The german IHK grading distribution
///
/// - total (integer): total points which can be reached
/// - step: smallest unit of a point. 0.5 for half points and 1 for full points.
/// -> array
#let ihk-grades(total, step: 1) = grades(
max: total,
step: step,
[6],
0.3 * total, [5],
0.5 * total, [4],
0.67 * total, [3],
0.81 * total, [2],
0.91 * total, [1],
) |
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/show-bare-05.typ | typst | Other | // Error: 6 expected colon
#show it => {}
|
https://github.com/christopherkenny/typst-function | https://raw.githubusercontent.com/christopherkenny/typst-function/main/README.md | markdown | Other | # typst-function Extension For Quarto
`typst-function` is a designed to be an analogous extension to Quarto's `latex-filter` extension [(quarto-ext/latex-environment)](https://github.com/quarto-ext/latex-environment).
It allows `divs` and `spans` to be converted to `typst` functions from within Quarto.
The syntax is similar to `latex-environment`, where you can specify argument's in a document's metadata to control which divs/spans are converted to function calls.
This uses the `functions` key in the YAML metadata to avoid conflicts with the familiar LaTeX extension.
If you have suggestions or problems, please open an issue.
## Installing
To add this filter, run:
```bash
quarto add christopherkenny/typst-function
```
## Using
### Basic use
Divs that match names listed in the `functions` key are translated to Typst functions of the same name.
Adding this to your metadata:
```yaml
functions: align
```
Allows you to write:
```md
::: {.align arguments="right"}
this
:::
```
Spans function similarly, so you can style like:
```md
[other text]{.align arguments=right}
```
### Spreading arguments (experimental)
One harder case to work with is when arguments are spread.
In those cases, the function takes the form `#function(args, ..spread[body])`
This is currently and only experimentally supported by adding `spread=true`.
The filter inserts the body before the closing parentheses. In the case where the `..spread` involves an open `map()`, it uses the mismatchingnumber of parentheses to insert 2 parentheses.
Note that this may be removed or changed (hopefully improved) in the future as it is not the cleanest syntax.
This currently functions as below.
Here, the call to `map()` is not closed, so two `)`s will be inserted after the block.
```md
::: {.stack arguments="dir: ltr, spacing:1fr, ..range(16).map(i=>rotate(24deg*i)" spread=true}
Hi
:::
```
### Linking (experimental)
Another feature is support for linking to arbitrary elements.
If `label=some-label` is set, then it can be linked using the Typst linking syntax.
Assuming we have `highlight` listed under `functions:`, we could write:
```md
::: {.highlight label=block-highlight}
Look at how yellow this gets.
:::
```
This is not currently a crossref in Quarto's sense.
Instead, link with the following inline.
```md
`#link(<block-highlight>)[like so]`{=typst}
```
This feature is also experimental and only supported because I have a use case in mind.
This may be removed or changed in the future, likely to use Quarto-style crossrefs.
You can also use spans here, which is at least feels less ugly, though is still worse than crossreferences.
```md
[some linked text]{.link arguments=<block-highlight>}
```
Note that a "happy" solution to linking/references is at the tradeoff of Quarto and Typst currenltly, as only floats or built in types can be crossreferenced in Quarto, whereas arbitrary elements can be linked in Typst.
## Example
A full example is available in [example.qmd](example.qmd).
## Common issues
```md
:::{.align arguments = "center"}
This will not be processed because of the spaces after `arguments` and the `=` sign.
:::
:::{.align arguments="center"}
It should look like this instead.
:::
```
## License
This extension is licensed under the MIT license.
The extension builds from [(quarto-dev/latex-environment)](https://github.com/quarto-ext/latex-environment) which is licensed under MIT by Posit, PBC.
All modifications by me are licensed under the MIT license.
See the [license file](LICENSE) for futher details.
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/touying/0.1.0/lib.typ | typst | Apache License 2.0 | #import "slide.typ": s, pause
#import "utils/utils.typ"
#import "utils/states.typ"
#import "utils/pdfpc.typ"
#import "themes/themes.typ" |
https://github.com/remigerme/typst-polytechnique | https://raw.githubusercontent.com/remigerme/typst-polytechnique/main/CONTRIBUTING.md | markdown | MIT License | # Contributing to the package or template
You can simply fork this repo and work on it on your own. Feel free to PR if this repo is still active !
If you plan to distribute your version of the package, please make sure you pay respect to both [Typst packages guidelines](https://github.com/typst/packages?tab=readme-ov-file#submission-guidelines) and [École polytechnique corporate identity](https://www.polytechnique.edu/presse/kit-media).
## Pushing to Typst packages
Check out [Typst packages repo](https://github.com/typst/packages) to learn more about packages release pipeline.
I personally suggest the following steps :
- fork the Typst packages repo
- in the root directory, for every `x.y.z` version (if the `main` branch currently contains the `x.y.z` release) :
```bash
git subtree add --prefix=packages/preview/typographix-polytechnique-reports/x.y.z [email protected]:remigerme/typst-polytechnique.git main
```
You may need to pull sometimes (if the release wasn't fully ready) :
```bash
git subtree pull --prefix=packages/preview/typographix-polytechnique-reports/x.y.z <EMAIL>:remigerme/typst-polytechnique.git main
```
- PR your fork to publish the package.
You do not need to squash the commit history at anytime because Typst packages will do it on merge.
|
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/002%20-%20Return%20to%20Ravnica/002_The%20Shadows%20of%20Prahv%2C%20Part%202.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"The Shadows of Prahv, Part 2",
set_name: "Return to Ravnica",
story_date: datetime(day: 05, month: 09, year: 2012),
author: "<NAME>",
doc
)
Javy's cryptic note led Relov to a disreputable tenement building. Fourth floor. East End. Javy was waiting for him in a dim corridor that smelled of rat poison. Despite the sordid surroundings, she looked as immaculate as always. Her Boros uniform fitted her as if it had been sewn by the best on Tailor's Row.
"Javy, so good to see you," he said. He kissed her on her cheek. She smiled faintly and then punched him lightly on the shoulder. She looked thinner than he remembered, but there were no other signs of the ordeal that had kept her in the healing wards for months. He was relieved to see that her face hadn't been scarred in the beating.
"Any word on the executions statute?" Javy asked.
"Not yet," Relov lied. At Javy's request, he'd suggested stricter limitations on executions, but his proposal had been killed by Grand Arbiter Leonos a year ago. He hadn't the heart to tell her.
#figure(image("002_The Shadows of Prahv, Part 2/01.jpg", width: 100%), caption: [Art by Scott Chou], supplement: none, numbering: none)
Javy motioned to the room behind them. "See if you recognize him."
The windowless room was worse than the building itself. Gray mold streaked the walls and the cracks crisscrossed the ceiling. A gilded bed frame almost filled the space, which smelled like rotting potatoes. The hump in the middle of the bed was almost unrecognizable as a corpse. In life, he had been a fat man. In death, he looked deflated—marooned—like a fish washed onto unfamiliar shores. Large puddles of sticky blood dotted the uneven floor.
"I'm not going in there," Relov retorted. Javy thrust her hand-lamp in his direction.
"Stay to the edge," she said. "And pay close attention to the skin."
Relov muttered something unkind under his breath and entered into the hideous little room. He tiptoed to the bedside and peered at the corpse. The skin looked splotchy, but in a strangely mathematical way. Despite his disgust, he leaned closer. Words had been magically imprinted over every inch of the dead man's body. The words were tiny, almost too small to decipher. But they were deep enough for blood to empty through the open wounds. The victim's skin sagged disturbingly but Relov could make out a few words: #emph[law] ; #emph[judge] ; #emph[proof] .
"Buckets of blood indeed," Relov said when he returned to the corridor. "That's horrific."
"His name is Zivan," Javy said. "An Arbiter like yourself, or so I've been told. I was hoping you could give me something on him."
Zivan had been a legendary legislator, but Relov only knew the man by his reputation. Once, Zivan had talked for sixteen hours straight, just to stonewall a request for refugee assistance. Relov had heard rumors of Zivan's fall from grace, but this was, well, humbling.
#figure(image("002_The Shadows of Prahv, Part 2/02.jpg", width: 100%), caption: [Transguild Promenade | Art by Noah Bradley], supplement: none, numbering: none)
Later, Relov sat with Javy on a bench in the Transguild Promenade. Light streamed through gaps in the ceremonial archways and a cool breeze rustled the trees along the footpath. It was a workday afternoon, and pedestrian traffic was light. Relov loved the promenade, where the bustle of the city was muted by Azorius noise wards.
Javy listened attentively as he recounted everything he remembered about Arbiter Zivan, which honestly wasn't much.
"He was well respected in his day," Relov finished. "An exquisite debater with sound legal reasoning. But he squandered it in Rakdos pleasure houses and hasn't been one of us for quite some time."
"You don't know which pleasure house, by any chance?" Javy asked.
Relov laughed. "Not my area of expertise." He had no interest in what Rakdos offered.
"Did you ever work with Zivan?" Javy asked.
"Not directly," Relov told her.
"Are you sure?" She opened her document case and handed him a faded parchment. It was an old Mass Arrest Order, dated from when Relov had just been promoted to Arbiter. His own signature was among a handful of his peers, including Arbiter Zivan's.
"I sign hundreds of documents a day," he explained. "That doesn't mean I knew him personally."
"Read the rest of the names," she said. "Notice anything about them?"
"No, should I?" Relov asked with irritation. He hated the feeling that someone knew something he didn't.
"They're all dead," she said. "Except for you."
Relov looked more closely and saw that she was correct. They were all deceased. Two of them in the past year alone.
#figure(image("002_The Shadows of Prahv, Part 2/03.jpg", width: 100%), caption: [Art by Johannes Voss], supplement: none, numbering: none)
"Some of these gentlemen were quite old..."
"This document authorized a sweep of the Golgari Undercity," Javy interrupted him. "It was the largest the Azorius had ever attempted. It turned violent and nearly a hundred were killed, many while in custody."
Relov thought hard. "I remember it. There was a public outcry over a couple of guards. They were accused of butchery or some such nonsense."
He noticed that Javy was clenching her fist. In the sunlight, the back of her hand was a spider web of fine white scars. She closed her eyes and tipped her face toward the sun. He waited for a few moments, but she didn't move.
"Javy, how have you been since the attack?" Relov asked bluntly. "I heard the perpetrator was released on a technicality."
Javy whipped her head toward him and bared her teeth, like a little dog about to tear into the meat of his leg. "If by 'technicality' you mean 'bribe,' then yes, yes he did."
"Now, Javy..." Relov said soothingly.
"Someone is killing Azorius," she said calmly, her face again a mask of professionalism. "Someone with a grudge against you, specifically."
#figure(image("002_The Shadows of Prahv, Part 2/04.jpg", width: 100%), caption: [Hallowed Fountain | Art by Jung Park], supplement: none, numbering: none)
"Why do you think that?" Relov asked. "Based on this document? How did you find this anyway?"
Javy shrugged. "I didn't. It was provided to me. I'm investigating a series of murders."
"What murders?" Relov asked with alarm.
"Someone is... slaughtering people in the manner in which they lived their lives," she replied.
Relov looked at her with exasperation. "Try to be less vague, will you? Meaning what?"
"If they were selfish, then they die of that urge. If they were vicious, they face that judgment in death. You see what I mean?"
"No," Relov said honestly. "I really don't."
"Well, last week a man was hung from a pillar in the forum. I'm told he loved the public eye. The week before that, a judge's heart was removed and sent to the victims he denied justice. Or your Mr. Zivan. He lived by the power of words, and died of the same. "
"Well," Relov said. He'd heard nothing about this, and felt a little rattled. "I appreciate your warning."
"Watch out for yourself," she said, brushing against his arm with the back of her hand.
As soon as Relov got back to New Prahv, he filled out an Application for Constant Protection.
Branko One-Ear left the Azorius after the raid. With the help of his father, he purchased a rickety tenement near Keyhole Downs. Over the years, the building became part of Rakdos territory. People only lived there if they could afford nowhere else. Even after the Rakdos moved on, Branko showed no interest in fixing the broken Izzet heat-pipes or cleaning out the rubbish from the stairwells.
A tenant found him propped up against the cornerstone in the filthy alley behind his tenement. The top of his skull has been neatly removed by magical incision. His brain removed and placed in his lap, and there it sat, like a pet dog. The empty skull jammed full with worthless coins.
"A fitting end," Javy mused, casting a quick glance around Relov's library. It was dark outside the great glass window, or else she could have seen the new house-garden he had recently commissioned from Selesnya.
"Gruesome," was Relov's reply. "But what does it have to do with me?"
"That's it, isn't it?" Javy said quietly. "Everything is about you."
Her comment annoyed him, but he held his tongue. It was near midnight, and somehow she had convinced his doorman to let her into his townhouse. She wasn't in uniform tonight. She wore loose black pants and a tunic, like a commoner. She had arrived bearing a strange collection of emotions, of which he couldn't quite decipher. So he sat behind his enormous mahogany desk and waited.
#figure(image("002_The Shadows of Prahv, Part 2/05.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none)
"He was one of the guards during the Golgari raid. He should've faced trial and been held accountable."
"So, he's another in your series of murders?" Relov guessed.
"Tell me about the raid," Javy said.
"I don't know anything about it," Relov told her.
"You ordered it," Javy reminded him.
"That's not entirely accurate," Relov protested. "I just signed the paper. And I wasn't there. I've never been to the Detention Compound in my life."
"When you put your little mark on one of those edicts, do you ever think about what it means?" Javy demanded. "There are people on the other end of them, Relov. People's lives are affected terribly by your signature."
"Of course I think about them," Relov retorted. But even as he said it, he knew it wasn't true.
#figure(image("002_The Shadows of Prahv, Part 2/06.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none)
"You used to," Javy agreed. "But not anymore. Do you remember those people we helped? Ever think about them? Wonder if you're just killing them now, instead of then?"
"What do they have to do with anything?" Relov asked. "We have rules. The Boros have rules. I suppose even the Golgari have rules. #emph[Rules] are not the problem."
"So what is the problem?" Javy asked.
"I don't #emph[see] a problem," Relov said pointedly. But he did. And it had barged uninvited into his home at midnight.
"No, not from your pretty mansion, you wouldn't," Javy said sadly. "She was right about you. I disagreed at first, but she was right."
"Who, your guildmaster?" Relov asked. He'd heard rumors that Guildmaster Aurelia was radicalizing her Boros soldiers, and if so, the Azorius couldn't let it stand.
"I have found a new teacher, and she eclipses my work with the Boros," Javy told him. "She holds the truth. Life into death and death into life. It's an eternal circle, and those who disturb it with their own ambitions must experience a profound death. "
Relov stared at Javy and decided she must have lost her mind.
"A person's existence cycle should be punctuated by the nature in which they lived," Javy continued earnestly. "Only that will incite reiteration in the darkest roots."
"You're scaring me, Javy," he told her. He disliked metaphysical nonsense, but coming from one of his oldest friends, it was downright repugnant.
"Am I?" she mused. "For the first time, #emph[I] feel no fear. You sign away people's lives like they're rats to be exterminated. You cozy up to men like the one who... hurt me. Yet you're safe behind your endless wall of words. At least you think you are."
There was a loud thud outside in the hall. He jumped to his feet. Javy didn't move.
"That will be your doorman falling dead to the floor. Next, your door will open. And you'll see the face of your judge."
#figure(image("002_The Shadows of Prahv, Part 2/08.jpg", width: 100%), caption: [Vraska the Unseen | Art by <NAME>], supplement: none, numbering: none)
"Don't look her in the face," Javy ordered Relov as the gorgon swept into the room.
Relov backed away in horror, keeping his eyes on the floor. He'd never seen a gorgon before, but every child in Ravnica had heard horror stories of what they could do.
"You should be honored," Javy said. "Of all the killings I've done in her name, she's never wanted to be a part of one before."
Vraska grabbed him by the throat, and he squeezed his eyelids tight. Her face was so close to the side of his head that he could feel her cold lips against his ear. Her voice was a strange guttural growl.
"Just before your 'guard' would have killed me, I was torn from this world. I was cast into a dark tomb with no way out."
Relov tried to protest. He knew nothing of the raid! Nothing of tombs or anything she was saying. But she was choking the breath out of him and whispering words only he could hear.
"It felt like lifetimes before I learned how to escape, to slip the confines of a world. But during the eternity I was trapped, I resolved that all should receive the death they deserve."
The gorgon placed her thumbs on Relov's eyelids. "Javy. Name a profound death. It's yours to decide."
Javy didn't hesitate. "Inaction," she said.
The gorgon smiled thinly. "Perfect."
By morning the new statue had already been installed near the main gate, much to the surprise of the Stewards, who weren't expecting it for another week. There was some kerfuffle among the Arbiters, who said it didn't really look like Grand Arbiter Leonos. See the unpleasant gaping of the lips? And there was entirely too much hair. But the craftsmanship was exquisite, so the chatter ended soon enough.
No one looked long enough to see the uncanny resemblance to the missing Relov or the terror in his unblinking eyes.
|
|
https://github.com/brainworkup/neurotyp-adult | https://raw.githubusercontent.com/brainworkup/neurotyp-adult/main/_extensions/neurotyp-adult/typst-show.typ | typst | MIT License | #show: report.with(
$if(title)$
title: "$title$",
$endif$
$if(name)$
name: [$name$],
$endif$
$if(doe)$
doe: [$doe$],
$endif$
$if(patient)$
patient: [$patient$],
$endif$
$if(papersize)$
paper: "$papersize$",
$endif$
$if(mainfont)$
font: ("$mainfont$"),
$endif$
$if(bodyfont)$
body-font: ("$bodyfont$"),
$endif$
$if(sansfont)$
sans-font: ("$sansfont$"),
$endif$
$if(fontsize)$
fontsize: $fontsize$,
$endif$
$if(section-numbering)$
sectionnumbering: "$section-numbering$",
$endif$
)
|
https://github.com/Wybxc/typst-nix | https://raw.githubusercontent.com/Wybxc/typst-nix/main/README.md | markdown | Apache License 2.0 | # Typst in Nix


[](https://github.com/Wybxc/typst-nix/actions/workflows/test.yml)
Typst's humble yet comprehensive environment: an accommodating space for crafting papers and presentations, offering a range of fonts and templates.
## Usage
```sh
nix develop github:Wybxc/typst-nix
```
Then enjoy it!
### Cachix binary cache (optional)
During each GitHub Actions run, a pre-built binary cache is pushed to my Cachix cache. If you trust its reliability, feel free to utilize it to expedite the installation process.
```sh
cachix use wybxc
```
## Features / Todos
- Fonts
- [x] 思源宋体 (Source Han Serif)
- [x] Inria Serif
- [x] 思源黑体 (Source Han Sans)
- [x] Inria Sans
- [x] Fira Code
- Templates
- [x] Slides
- [x] Handout
- [ ] Paper
## Known Issues
None yet.
<details>
<summary>Previous Issues</summary>
The following issues used to exist in the previous version of this repository. They have been fixed in 0.2.0.
- Currently, Typst does not have support for adding multiple font paths through environment variables (refer to [typst/typst#100](https://github.com/typst/typst/issues/100)). As a workaround, I have created a wrapper script that adds the font path to the command line arguments. Although this solution is not ideal, it does the job.
- Typst-lsp does not function properly with `TYPST_ROOT`. This issue is documented in [nvarner/typst-lsp#98](https://github.com/nvarner/typst-lsp/issues/98) and [nvarner/typst-lsp#120](https://github.com/nvarner/typst-lsp/issues/120). As a result, the language server fails to discover the templates, leading to the unavailability of the completion feature.
</details>
## Upgrading
### 0.1.0 -> 0.2.0
* Replace `#import "/slides/slide.typ"` with `#import "@preview/polylux:0.3.1"`. There may be API changes from typst-slides to polylux, so please refer to the [polylux documentation](https://andreaskroepelin.github.io/polylux/book/polylux.html).
* For typst-lsp VSCode extension, please modify the configuration file to use the wrapper script `typst-lsp`. Otherwise, the language server will not be able to discover the templates.
## Changelog
### 0.2.0
* Update to typst 0.7.0
* Add wrapper script for typst-lsp
* Templates: Slides([polylux](https://github.com/andreasKroepelin/polylux) from typst published packages), Handout
* **Breaking change**: now templates are imported via typst's package system
### 0.1.0
* Initial release
* Support typst 0.5.0
* Fonts: Source Han Serif, Inria Serif, Source Han Sans, Inria Sans, Fira Code
* Templates: Slides(from https://github.com/andreasKroepelin/typst-slides)
|
https://github.com/7sDream/fonts-and-layout-zhCN | https://raw.githubusercontent.com/7sDream/fonts-and-layout-zhCN/master/chapters/03-unicode/store/store.typ | typst | Other | #import "/template/template.typ": web-page-template
#import "/template/components.typ": note
#import "/lib/glossary.typ": tr
#show: web-page-template
// ## How data is stored
== 数据如何储存
// When computers store data in eight-bit bytes, representing numbers from 0 to 255, and your character set contains fewer than 255 characters, everything is easy. A character fits within a byte, so each byte in a file represents one character. One number maps to one letter, and you're done.
我们已经知道,计算机使用包含8个比特的字节来储存数据,每个字节可以表示数字0到255。如果我们的#tr[character set]中的#tr[character]数量小于255的话,事情就变得很简单:只需要每个字节储存相应#tr[character]所对应的数字即可。
// But when your character set has a potential 1,112,064 code points, you need a strategy for how you're going to store those code points in bytes of eight bits. This strategy is called a *character encoding*, and the Unicode Standard defines three of them: UTF-8, UTF-16 and UTF-32. (UTF stands for *Unicode Transformation Format*, because you're transforming code points into bytes and vice versa.)
但当这个字符集有1112064个#tr[codepoint]时,把它们储存成字节序列就需要一些策略了。我们将决定如何把#tr[character set]储存为字节序列的策略称为*#tr[character]#tr[encoding]*。Unicode 标准中定义了三种字符#tr[encoding]:UTF-8、UTF-16和UTF-32。这里UTF表示Unicode转换格式(Unicode Transformation Format),顾名思义,它就是用于Unicode#tr[codepoint]和字节序列之间的互相转换的。
#note[
// > There are a number of other character encodings in use, which are not part of the Standard, such as UTF-7, UTF-EBCDIC and the Chinese Unicode encoding GB18030. If you need them, you'll know about it.
在Unicode标准之外还有很多其他的#tr[character]#tr[encoding],比如 UTF-7、UTF-EBCDIC和中国国标中定义的基于Unicode的#tr[encoding] GB18030。这些#tr[encoding]可以随着实践按需了解。
]
// The names of the character encodings reflect the number of bits used in encoding. It's easiest to start with UTF-32: if you take a group of 32 bits, you have $$ 2^{32} = 4,294,967,296 $$ possible states, which is more than sufficient to represent every character that's ever likely to be in Unicode. Every character is represented as a group of 32 bits, stretched across four 8-bit bytes. To encode a code point in UTF-32, just turn it into binary, pad it out to four bytes, and you're done.
这些#tr[character]#tr[encoding]名称中的数字反映了它们使用多少比特进行#tr[encoding]。最简单的是 UTF-32:如果你按32个比特为一组,则一共有 $2^32=42,9496,7294$ 种不同的状态,这完全足以表示 Unicode 中的所有#tr[character]了。按这种方法,每个#tr[character]使用32个比特,也就是4个字节。具体来说,转换时把每个字符对应的#tr[codepoint]数字转换成二进制,然后用0填满不足32比特的剩余位置即可。
// For example, the character 🎅 (FATHER CHRISTMAS) lives in Finland, just inside the Arctic circle, and in the Unicode Standard, at codepoint 127877. In binary, this is 11111001110001111, which we can encode in four bytes using UTF-32 as follows:
据说圣诞老人住在芬兰的一个临近北极圈的地方,但 #box(image("/fonts/father-christmas.svg", alt: emoji.santa.man, height: 1em), baseline: 0.1em) 作为一个#tr[character],它位于Unicode中的127877#tr[codepoint]上。按照 UTF-32的方法,先把127877转换为二进制`11111001110001111`,再将它#tr[encoding]成四个字节,结果如下:
#let utf-32-example-table = c => {
let codepoint = str.to-unicode(c.text)
let bs = (0, 0, 0, 0)
while codepoint != 0 {
bs.insert(4, calc.rem(codepoint, 256))
codepoint = int(codepoint / 256)
}
bs = bs.slice(-4)
let binary = bs.map(it => if it == 0 {
""
} else {
str(it, base: 2)
})
let padded = binary.map(it => "0" * (8 - it.len()) + it)
let hex = bs.map(it => str(it, base: 16)).map(it => "0" * (2 - it.len()) + it)
let decimal = bs.map(str)
table(
columns: 5,
align: (start, end, end, end, end),
[二进制],
..binary.map(raw),
[前补0],
..padded.map(raw),
[十六进制],
..hex.map(raw),
[十进制],
..decimal.map(raw),
)
}
#align(center)[#utf-32-example-table[🎅]]
#note[
// > Hexadecimal is a number system which is often used in computer work: whereas decimal "rolls over" to the second place after each 9 (8, 9, 10, 11), hexadecimal counts up to fifteen before rolling over (8, 9, A, B, C, D, E, F, 10, 11). This means that two hexadecimal digits can encode numbers from 00 to FF (or 0 to 255 in decimal), which is precisely the same range as one byte.
十六进制是在计算机语境中常用的一种数字进制:我们日常用的十进制逢十进一(8、9、10、11),十六进制同理,会逢十六进一(8、9、A、B、C、D、E、F、10、11)。两位的十六进制数可以从00数到FF(按十进制就是0到255),正好和一个字节的数字范围一致。
]
#note[
// > There's only one slight complication: whether the bytes should appear in the order `00 01 F3 85` or in reverse order `85 F3 01 00`. By default, UTF-32 stores data "big-end first" (`00 01 F3 85`) but some systems prefer to put the "little-end" first. They let you know that they're doing this by encoding a special character (ZERO WIDTH NO BREAKING SPACE) at the start of the file. How this character is encoded tells you how the rest of the file is laid out: if you see `00 00 FE FF` at the start of the file, we're big-endian, and if the file starts `FF FE 00 00`, we're little-endian. When ZWNBS is used in this way, it's called a BOM (Byte Order Mark) and is not interpreted as the first character of a document.
还有最后一个略显复杂的步骤:我们需要决定这四个字节是按`00 01 F3 85`还是按`85 F3 01 00`的顺序出现。默认情况下,UTF-32按照大端序(`00 01 F3 85`)储存数据,但也有些系统会偏好使用小端序。为了区分这两种顺序,这些系统会在文件的起始位置添加一个特殊的零宽不折行空格(`ZERO WIDTH NO BREAKING SPACE`)#tr[character]。这个字符如何被#tr[encoding]就表示了后续文件使用何种顺序:如果你在文件开头看到`00 00 FE FF`,就表示后续文件内容使用大端序;同理,`FF FE 00 00`就表示小端序。当这个特殊的字符用于提示储存顺序时,我们把它叫做字节顺序标记(Byte Order Mark,BOM),此时它就不被视为文档内容的首个#tr[character]了。
]
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/quetta/0.1.0/src/quetta.typ | typst | Apache License 2.0 | #import "quenya.typ": quenya
|
https://github.com/MrToWy/Bachelorarbeit | https://raw.githubusercontent.com/MrToWy/Bachelorarbeit/master/Code/degree.controller.typ | typst | #import("../Template/customFunctions.typ"): *
#codly(
highlights:(
(line:0, fill:blue, label: <apiTags>),
(line:1, fill:green, label: <controllerDecorator>),
(line:7, fill:yellow, label: <getDecorator>),
),
annotations:(
(start: 3, end: 5, label: <constructor>),
)
)
```ts
@ApiTags('Degrees')
@Controller('degrees')
export class DegreeController {
constructor(
private degreeService: DegreeService
) {}
@Get('')
findAll() {
return this.degreeService.findAll();
}
@Get(':id')
findOne(@Param('id') id: string, @Req() request: Request): Promise<any> {
const language = (request.headers as any)['language'];
return this.degreeService.findById(+id, language);
}
}
``` |
|
https://github.com/yonatankremer/matrix-utils | https://raw.githubusercontent.com/yonatankremer/matrix-utils/main/src/lib.typ | typst | MIT License | // TODO - import non underscore methods only, either manually or by scripting
#import "complex.typ": *
#import "matrix.typ": *
|
https://github.com/TGM-HIT/typst-diploma-thesis | https://raw.githubusercontent.com/TGM-HIT/typst-diploma-thesis/main/template/lib.typ | typst | MIT License | #import "@preview/tgm-hit-thesis:0.2.0": *
#import "assets.typ"
|
https://github.com/Quaternijkon/notebook | https://raw.githubusercontent.com/Quaternijkon/notebook/main/content/数据结构与算法/.chapter-数据结构/数组/轮转数组.typ | typst | #import "../../../../lib.typ":*
=== #Title(
title: [轮转数组],
reflink: "https://leetcode.cn/problems/rotate-array/description/",
level: 2,
)<轮转数组>
#note(
title: [
轮转数组
],
description: [
给定一个整数数组 nums,将数组中的元素向右轮转 k 个位置,其中 k 是非负数。
],
examples: ([
输入: nums = [1,2,3,4,5,6,7], k = 3
输出: [5,6,7,1,2,3,4]
解释:
- 向右轮转 1 步: [7,1,2,3,4,5,6]
- 向右轮转 2 步: [6,7,1,2,3,4,5]
- 向右轮转 3 步: [5,6,7,1,2,3,4]
],[
输入:nums = [-1,-100,3,99], k = 2
输出:[3,99,-1,-100]
解释:
- 向右轮转 1 步: [99,-1,-100,3]
- 向右轮转 2 步: [3,99,-1,-100]
]
),
tips: [
- $1 <= "nums.length" <= 10^5$
- $-2^31 <= "nums"[i] <= 2^31 - 1$
- $0 <= k <= 10^5$
],
solutions: (
( name:[富有线性代数的美],
text:[
我们需要将 ab 变成 ba ,可以首先将ab翻转得到$b^(-1)a^(-1)$,然后将$b^(-1)a^(-1)$翻转得到ba。
- $("ab")^(-1) = b^(-1)a^(-1)$
- $(b^(-1))^(-1) = b$
- $(a^(-1))^(-1) = a$
],code:[
```cpp
class Solution {
public:
void rotate(vector<int>& nums, int k) {
reverse(nums.begin(), nums.end());
reverse(nums.begin(), nums.begin() + k % nums.size());
reverse(nums.begin() + k % nums.size(), nums.end());
}
};
```
]),
),
gain:none,
)
|
|
https://github.com/yhtq/Notes | https://raw.githubusercontent.com/yhtq/Notes/main/机器学习数学导引/main.typ | typst | #import "../template.typ": proof, note, corollary, lemma, theorem, definition, example, remark
#import "../template.typ": *
#show: note.with(
title: "机器学习数学导引",
author: "YHTQ",
date: datetime.today().display(),
logo: none,
withChapterNewPage: true
)
= 前言
- 教师:吴磊(<EMAIL>)
- 成绩:作业 40% + 大作业 60%(两到三人组)
- 作业晚交一天扣 20%
课程目的:提供有一定数学基础,综合的流行 ML 模型的介绍
== 机器学习的目标
抽象而言,一个 Learning Problem(有监督)就是给出一组数据 ${(x_i, y_i)}$,试图找到一个拟合函数使得 $y_i approx f(x_i)$
。常见情形中,往往:
- $y_i in RR$ ,此时称为回归问题(Regression)
- $y_i$ 取离散值,此时称为分类问题(Classification)
尽管往往我们可以认为 $x_i$ 在某个 $d$ 维的欧式空间,但此时 $d$ 可能相当大,例如对于一个 $244 times 244 times 3$ 的图片,$d = #(244 * 244 * 3)$。区分传统机器学习和现代机器学习的一个重要特征就是维度,传统的机器学习往往处理的是低维数据,而现代机器学习则处理高维数据。
通常而言,$f(x)$ 被分成两部分:
- 一个带有参数的表达式 $f(x; theta)$,这被称为*模型*,通常来自于人们的先验假设和设计
- 一个确定参数的过程,这被称为*学习*,通常通过最小化一个损失函数来实现
现代的机器学习通常是数据驱动的,也即模型的设计较为简单和通用,大部分信息来源于从数据拟合的参数;相对而言,传统的计算数学和传统机器学习往往是依赖于精心设计的模型。
== 误差分解
通常我们会将估计误差分为:
$
norm(f_(hat(theta)) - f^*) <= norm(f_(hat(theta)) - f_(hat(theta^*)) )+ norm(f_(hat(theta^*)) - f^*)
$
其中:
- $f^*$ 是真实函数
- $f_(hat(theta))$ 是我们的估计函数
- $f_(hat(theta^*))$ 是最优估计函数
- $norm(f_(hat(theta)) - f_(hat(theta^*)) )$ 通常称为 estimation error,来自于我们只有有限的数据,没有找到最优参数
- $norm(f_(hat(theta^*)) - f^*)$ 通常称为 approximation error,来自于我们的模型假设能表达的所有函数与真实函数的差距
通常而言,增大模型规模可以一定程度降低 approximation error,但可能会增大 estimation error
== 泛化与维度灾难
通过训练集得到的近似函数在训练集之外往往一定程度上有效,这被称为泛化。泛化的成立根本上依赖于问题本身具有的某些良好性质,例如连续性,可微性等等。然而随着提供的训练数据在高维空间中迅速变得稀疏,这些简单直观的性质提供的泛化能力往往会在维度升高时迅速衰减,这被称为维度灾难(curse of dimensionality)。
= 传统机器学习
== 线性回归
#let hR = $hat(cal(R))$
使用线性函数:
$
f_i (x) = beta^T x + beta_0
$
拟合目标函数,通常称 $beta$ 为权重,$beta_0$ 为偏置(bias)。也可简写成:
$
f_i (x) = (beta^T, beta_0) vec(x, 1)
$
定义均方误差:
$
hR_n (beta) = 1/n sum_(j=1)^n 1/2 (beta^T x_j - y_j)^2 = 1/(2 n) norm(vec(x_1^T, dots.v, x_n^T) beta - y)
$
#algorithm[OLS 普通最小二乘][
求解:
$
0 = nabla hR_n (beta)
$
得到:
$
1/n sum_(j=1)^n (beta^T x_j - y_j) x_j &= 0\
sum_(j=1)^n (beta^T x_j) x_j &= sum_(j=1)^n y_j x_j\
sum_(j=1)^n x_j (beta^T x_j) &= sum_(j=1)^n y_j x_j\
sum_(j=1)^n x_j x_j^T beta &= (x_1, ..., x_n) y\
(sum_(j=1)^n x_j x_j^T) beta &= (x_1, ..., x_n) y\
(x_1, ..., x_n) vec(x_1^T, dots.v, x_n^T) beta &= (x_1, ..., x_n) y\
$
记 $X = vec(x_1^T, dots.v, x_n^T)$,上式化为:
$
X^T X beta = X^T y
$
假设 $X$ 满秩,则上式有唯一解:
$
hat(beta) = (X^T X)^(-1) X^T y
$
否则,需要找到一个最优解。例如许多时候我们希望找到一个最小范数的解,这被称为 Ridge Regression,也就是求解以下问题:
$
min_(beta in RR^d) norm(beta) \
s.t. X beta = y
$
其中 $n < d, X in RR^(n times d) "满秩", y in RR^n$,此时可以解得解析解:
$
hb = X^T (X X^T)^(-1) by
$
#proof[
由条件,方程显然有解。设 $bbeta = X^T bu + bv$,代入方程有:
$
X (X^T bu + bv) &= by\
bu &= (X X^T)^(-1) (by - X bv)\
norm(bbeta)^2 &= (bu^T X + bv^T)(X^T bu + bv)\
&= bu^T X X^T bu + bu^T X bv + bv^T X^T bu + bv^T bv\
&= (by^T - bv^T X^T)(X X^T)^(-1)(by - X bv) + (by^T - bv^T X^T) (X X^T)^(-1) X bv + bv^T X^T (X X^T)^(-1) (by - X bv) + bv^T bv\
&= bv^T (I - X^T (X X^T)^(-1) X) bv + by^T (X X^T)^(-1) by
$
#lemmaLinear[][
$I - X^T (X X^T)^(-1) X$ 是半正定矩阵
]
#proof[
令 $P = X^T (X X^T)^(-1) X$,注意到:
- $P^2 = P$
- $P = P^T$
因此:
$
(I - P)^2 = I - 2P + P^2 = I - P\
x^T (I - P) x = x^T (I - P)^2 x = x^T (I -P)^T (I - P) x = norm((I- P) x) >= 0
$
]
由引理,显然上式取得最小值当且仅当 $bv = 0$,此时 $bbeta = x^T (X X^T)^(-1) by$
]
]
#example[][
通常情况下数据是有噪声的,这时需要采用正则化方法,例如:
- Ridge Regression:$min_(beta) sum_(i=1)^n (y_i - beta^T x_i)^2 + lambda norm(beta)_2^2$
- Lasso Regression:$min_(beta) sum_(i=1)^n (y_i - beta^T x_i)^2 + lambda norm(beta)_1^2$,往往用于参数非常稀疏时
]
== 分类问题
回归问题中,目标函数的值域是连续的实数域。而在分类问题中,值域只是离散的点。理论上讲,我们的损失函数尽可能多的准确拟合目标,但在实际上我们往往使用代替的损失函数,使得该损失函数降低时,确实意味着拟合更准确。
分类问题可以从概率和几何两个角度进行考虑,分别可以产生两类不同的损失函数:
- 从概率角度,我们认为我们不是拟合函数,而是拟合一个值域上的概率分布。
#definition[softmax][
对于一个 $d$ 维的输入 $x$,我们希望输出一个 $k$ 维的概率分布 $p$,其中 $p_i = P(y = i | x)$,这被称为 softmax 函数:
$
p_i (x) = "softmax"(x)_i = (e^(x_i))/(sum_j e^(x^T beta_j))
$
]
由此,我们的优化目标变为:
$
min_theta 1/n sum_(i=1)^n d(S(f_theta (x_i)), e_(y_i))
$<classfication-target>
其中 $d$ 用于度量两个概率分布的距离。
#example[KL divergence][
通常我们使用 KL 散度来度量两个概率分布的距离:
$
D(p, q) = sum_i p_i log(p_i/q_i) = -sum_i p_j log q_j - (-sum_i p_i log p_i)
$
或者连续情形:
$
D(p, q) = integral_()^() p(x) log(p(x)/q(x)) dif x
$
如果使用它作为 $d$,优化问题@classfication-target 恰好可以变形为:
$
max_theta 1/n sum_(i = 1)^n log F_(y_i) (x_i \; theta)
$
这事实上就是一种极大似然估计。
]
#remark[Label Smoothing][
有些分类问题中,类别的差异本身就很小。此时,我们可以对 label 进行平滑,替代原有的 one hot 分布,也即将:
$
(0, ..., 1,..., 0) -> (epsilon, ..., 1 - (n - 1) epsilon, epsilon)
$
之后再对@classfication-target 进行优化,可以让模型的输出更加平滑。
]
- 从几何角度,就是希望找到超平面将两种数据分离开。假设我们使用超平面:
$
H = {x | beta^T x + beta_0 = 0}
$
并且假设 $norm(beta) = 1$。直觉上来说,我们希望点离超平面尽量远,因此可以设计优化问题:
$
max (min_i abs(beta^T x_i + beta_0)) \
s.t. space y_i(beta^T x_i + beta_0) >= 0
$
这个形式并不方便求解。我们利用常见的技巧,将其化为等价的优化问题:
$
max t with beta in S^(d-1), beta_0 in RR, t in RR, t >= 0\
s.t. y_i (beta^T x_i + beta_0) >= t
$
进一步的:
$
max t with beta in S^(d-1), beta_0 in RR, t in RR, t >= 0\
s.t. y_i (beta^T/t x_i + beta_0/t) >= 1
$
令 $beta = beta/t, beta_0 = beta_0/t$,得到:
$
min norm(beta) with beta in RR^n, beta_0 in RR\
s.t. y_i (beta^T x_i + beta_0) >= 1
$
事实上,这就是在所有能够充分拟合数据的参数选择中,选取最简单的模型。这个思想可以推广到非线性中:
#algorithm[][
设 $cal(F)$ 是函数空间,$Omega: cal(F) -> RR^+$ 是复杂度,我们往往使用下面的模型:
$
min Omega(f) s.t. f(x_i) y_i >= 1
$
这里的 $f(x) y$ 往往称为 confidence 或者 margin。
]
这里我们使用的是硬约束,可以设计软约束的版本,称作 Soft-SVM:
$
min (norm(beta)^2 + 1/n sum_i xi_i) \
s.t. y_i (beta^T x_i + beta_0) >= 1 - xi_i, \
xi_i >= 0
$
以及相应的一般化版本:
$
min Omega(f) + 1/n sum_i xi_i\
s.t. f(x_i) y_i >= 1 - xi_i, xi_i >= 0
$
化简一下,事实上就是:
$
min_f Omega(f) + 1/n sum_i max(0, 1 - y_i f(x_i))
$
某种意义上,上式后者就是一个损失函数,而前者是一个正则化项。\
令:
$
l(z) = max(0, 1 - z)
$
往往将其称为 Hinge loss,它相当于在预测比较 confidence 时损失为零,否则施加线性的惩罚。不难看出,它是常见的 $0-1$ loss 的一个上界。
推广而言,我们可以调整损失函数获得其他算法。注意在分类问题中,决定结果的往往只是那些接近边缘的点。
== 无监督学习
无监督学习往往包括以下问题:
- density estimation:估计数据的分布,往往由于维数灾难难以在高维空间中进行
- dimension reduction:将高维数据映射到低维空间,同时尽可能保留结构
- clustering:将数据分成若干类,类似于无监督的分类问题
#let hrho = $hat(rho)$
#algorithm[Histogram][
估计密度的一种简单方法是直方图法。将数据空间划分为若干个小区间,然后统计每个区间的数据点数目,用每个区间的数据点数目除以总数据点数目,就得到了密度的估计。这个方法比较通用,但不能很好的利用光滑性。
]
#algorithm[Kernel density estimation,KDE][
一种更加光滑的方法是核密度估计。设 $K$ 是一个核函数,定义:
$
hrho(x) = 1/n sum_i K_h (x - x_i)
$
其中 $K$ 是一个光滑函数,且满足:
$
K_h -> delta ("Kronecker")
$
并且:
- $K(x) >= 0$
- $integral_()^() K(x) dif x = 1$
- $K(x) = K(-x)$
常见的一维 $K(x)$ 包括:
- $K(x) = bold(1) (x)$,类似于 Histogram
- $K(x) = max (0, 1 - abs(x))$
- $K(x) = 1/sqrt(2 pi) e^(- x^2 / 2) $
高维的核函数往往只是通过将一维的核函数乘积得到。这种核函数称为各向同性的。
]
#example[][
步长 $h$ 的选择往往是只能手工进行的。以高斯核为例,有:
$
K_h (x) = 1/h^d sum_i K((x - x_i)/ h)
$
若 $h$ 取得很小,则模型会失去泛化能力。我们进行一些误差分析,假设 $x_i$ 独立同分布:
$
E(hrho(x) - rho(x)) &= 1/n sum_i E(K_h (x - x_i)) - rho(x)\
&= E(K_h (x - X)) - rho(x)\
&= 1/h^d E(K((x - X)/h)) - rho(x)\
&= 1/h^d E(K((x - X)/h)) - rho(x)\
&= 1/h^d integral_()^() k(z) rho(x - z h) dif z - rho(x)\
&= 1/h^d integral_()^() k(z) (rho(x - z h) - rho(x)) dif z \
$
对 $rho$ 做泰勒展开,注意到 $k$ 的对称性,其一阶项直接消掉,因此有上式 $<= C_1 h^2$ 且
$
C_1 <= norm(nabla^2 rho) integral_()^() k(z) norm(z)^2 dif z
$
同时:
$
E(hrho(x) - rho(x))^2 = E(hrho(x) - E hrho(x) + E hrho(x) - rho(x))^2 \
= (E (hrho(x) - rho(x)))^2 + E (hrho(x) - E hrho(x))^2\
"Var" (hrho(x)) <= 1/n E(K_h^2 (x - x_i))\
= 1/n integral_()^() 1/(h^(2 d)) K^2 ((x - x')/h) rho(x') dif x'\
<= 1/n 1/h^d integral_()^() K^2 (z) rho(x - z h) dif z\
$
]
#algorithm[PCA][
主成分分析是常见的降维方法。假设我们的数据 $x_i$ 大约在一个 $k$ 维子空间中,也即存在 $k$ 个正交基 $v_i$,使得 $x_i approx sum_j beta_(i j) v_j$。也即化成下面的优化问题:
$
min_(V, z_i, c) 1/n sum_i norm(x_i - V z_i - c)^2\
$
其中 $V$ 是一个正交矩阵,同时可不妨设 $sum z_i = 0$,先固定 $V$,求导计算可得:
$
c = 1/n sum_i x_i\
V^T (x_i - V z_i - c) = 0 = V^T x_i - z_i -V^T c\
z_i = V^T (x_i - c)
$
问题再化为:
$
min 1/n sum_i norm(x_i - V V^T (x_i - c) - c)^2
$
做中心化后:
$
min 1/n sum_i norm(x_i - V V^T x_i)^2 = min 1/n norm(X = X W W^T) \
= 1/n tr (X^T X) - tr (X^T X W W^T)\
= 1/n tr (X^T X) - tr (W^T X^T X W)
$
而令 $tr (W^T X^T X W)$ 最大的 $W$ 就是 $X^T X$ 的前 $k$ 大的特征值对应的特征向量。
]
PCA 可以推广到一般的形式,也即对于矩阵 $X$,希望找到矩阵 $Y, E$ 使得 $X = Y + E$,其中 $Y$ 是低秩矩阵,而 $E$ 是较小的矩阵。这里的小可以有多种解释,例如:
#algorithm[Robust PCA][
如果认为上面的“小”指的是稀疏,这种算法被称为 Robust PCA。例如在监控视频中,背景几乎是不变的,因此我们希望将整个视频分解成低秩的背景和稀疏的前景。我们可以写出优化问题:
$
min norm(E)_0 + rank(Y)\
s.t. X = Y + E
$
然而这显然是不好解决的优化问题。为了解决,我们希望用一个凸问题代替。首先 $norm(E)_0$ 可以松弛到 $norm(E)_1$,其次 $rank(Y)$ 就是非零奇异值的个数,可以松弛到奇异值向量的 $L_1$ 范数(通常称为核范数,它确实是范数),因此问题变成:
$
min norm(E)_1 + norm(Y)_("ker")\
s.t. X = Y + E
$
这是个凸问题,我们总可以高效求解。
]
从另一个角度,PCA 可以认为是一个 $f: RR^m -> RR^n$ 的映射,其中 $m > n$,我们希望有另一个映射 $g: RR^n -> RR^m$,使得:
$
min 1/n sum_i norm(x_i - g(f(x_i)))^2
$
往往称 $f$ 为 encoder,$g$ 为 decoder。如果假设 $f, g$ 都是线性,得到的解就是 PCA。而如果选择非线性的函数,就可以得到 PCA 的另一种推广。
接下来我们介绍另一种线性降维的方法,称为 Random Projection。假设有一组数据 $x_1, ..., x_n$ ,希望通过投影函数 $f$ 投影到低维空间,并且使得:
$
norm(f(x_i) - f(x_j)) approx norm(x_i - x_j)
$<random-projection>
有趣的是,它的解法是取:
$
f (x_i) = 1/sqrt(K) W x_i
$
其中 $W in RR^(K times d)$ 是随机矩阵,其中每个元素都独立同分布到 $N(0, 1)$
#lemma[Johnson-linkoslvous][
设 $x_i in RR^d$ 是一组向量,对于任意 $delta > 0$,则以 $1 - delta$ 的概率:
$
max_i abs(norm(1/sqrt(K) W x_i)^2 / norm(x_i)^2 - 1) <= epsilon
$
只要 $K >= C (ln (n / delta))/(epsilon^2)$
]
#proof[
不妨设 $norm(x_i) = 1$,有:
$
norm(1/sqrt(K) W x_i)^2 = 1/K sum_k (W_k^T x_i)^2
$
注意到 $W_k^T x_i tilde N(0, 1)$,记其为 $xi_k$,将有:
$
norm(1/sqrt(K) W x_i)^2 = 1/K sum_k xi_k^2
$
不难发现:
$
E(1/K sum_k xi_k^2) = 1
$
又有概率集中不等式:
$
P(abs(1/K sum_k xi_k^2 - 1) > epsilon) <= C_1 e^(-C_2 K epsilon^2)
$
这就对每一个变量的误差做出了估计。最后:
$
P(max_i abs(norm(1/sqrt(K) W x_i)^2 - 1) > epsilon) <= sum_i P(abs(norm(1/sqrt(K) W x_i)^2 - 1) > epsilon) <= n C_1 e^(-C_2 K epsilon^2)
$
为了使:
$
n C_1 e^(-C_2 K epsilon^2) < delta
$
只需要 $K >= C (ln (n / delta))/(epsilon^2)$
]
#remark[][
- 上面的 $K$ 与 $d$ 无关,甚至 $d$ 为无穷时结果仍然成立。当然这并不奇怪,因为 $n$ 个点张成空间仅有 $n$ 维。
- 上面的证明中其实并没有用到高斯分布的特性,只要概率集中不等式成立(条件很弱)上面的性质都成立。实际计算时,可能会取:
$
W_(i j) tilde cases(
a space p_1,
0 space p_2,
b space p_1
)
$
使得期望和方差满足要求,最后得到的 $W$ 几乎是个稀疏矩阵,运算量较小。
]
回到@random-projection,只需在上面的引理中取约 $n^2$ 个向量 $x_i - x_j$ 即可,结论保证了 $n$ 个向量可以随机投影到约 $ln n$ 维空间,距离就可以几乎不变。
与 PCA 相比,Random Projection 必须在 $d$ 很高的时候才能有优势,也不能实现降低到很低的维度。同时,PCA 的分析建立于数据真的分布在一个较低维的空间上,而 Random Projection 并不假设这个信息。然而,Random Projection 的分析基于欧式距离,而在很多问题中欧氏距离并不是重要的度量。
= 现代机器学习(深度学习)
= 理论基础
|
|
https://github.com/floriandejonckheere/utu-thesis | https://raw.githubusercontent.com/floriandejonckheere/utu-thesis/master/thesis/figures/05-modular-monolith/distributedness.typ | typst | #import "@preview/cetz:0.2.2"
#set text(font: "Fira Sans", size: 7pt)
#cetz.canvas(length: 0.45cm, {
import cetz.draw: *
set-style(
content: (padding: .2),
stroke: black
)
rect(
(0, 0), (5, 5),
fill: red.lighten(90%),
stroke: none,
name: "traditional_monolith")
content("traditional_monolith", align(center, [Traditional\ monolith]))
rect(
(5, 0), (10, 5),
fill: green.lighten(90%),
stroke: none,
name: "modular_monolith")
content("modular_monolith", align(center, [Modular\ monolith]))
rect(
(0, 5), (5, 10),
fill: blue.lighten(90%),
stroke: none,
name: "distributed_monolith")
content("distributed_monolith", align(center, [Distributed\ monolith]))
rect(
(5, 5), (10, 10),
fill: yellow.lighten(90%),
stroke: none,
name: "microservice")
content("microservice", align(center, [Microservice]))
// X axis
line((-0.5, 5), (10.5, 5), mark: (start: ">", end: ">", fill: black))
content((-1.5, 5), align(center, [Logical\ monolith]))
content((11.5, 5), align(center, [Logical\ modular]))
// Y axis
line((5, -0.5), (5, 10.5), mark: (start: ">", end: ">", fill: black))
content((5, -1.5), align(center, [Physical\ monolith]))
content((5, 11.5), align(center, [Physical\ distributed]))
})
#v(2em)
|
|
https://github.com/mattfbacon/typst-egui | https://raw.githubusercontent.com/mattfbacon/typst-egui/main/README.md | markdown | Creative Commons Zero v1.0 Universal | # Typst + Egui
Very restricted proof-of-concept for showing Typst documents inside egui.
## License
CC0
|
https://github.com/FurryAcetylCoA/sgu-thesis-typst | https://raw.githubusercontent.com/FurryAcetylCoA/sgu-thesis-typst/main/nju-thesis/templates/acknowledgement.typ | typst | MIT License | #import "../utils/style.typ": 字号, 字体
// 致谢页
#let acknowledgement(
// documentclass 传入参数
fonts: (:),
anonymous: false,
twoside: false,
// 其他参数
title: "致谢",
outlined: true,
body,
) = {
fonts = 字体 + fonts
if (not anonymous) {
counter(heading).update(0)
pagebreak(weak: true, to: if twoside { "odd" })
[
#set text(font: fonts.黑体, size: 字号.小四, weight: "bold")
#set align(center)
#heading(level: 1, numbering: none, outlined: outlined, title) <no-auto-pagebreak>
]
text(font: fonts.宋体, size: 字号.五号)[#body]
}
}
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/fletcher/0.1.1/src/main.typ | typst | Apache License 2.0 | #import calc: floor, ceil, min, max
#import "utils.typ": *
#import "layout.typ": *
#import "draw.typ": *
/// Draw a labelled node in an arrow diagram.
///
/// - pos (point): Dimensionless "elastic coordinates" `(x, y)` of the node,
/// where `x` is the column and `y` is the row (increasing upwards). The
/// coordinates are usually integers, but can be fractional.
///
/// See the `arrow-diagram()` options to control the physical scale of elastic
/// coordinates.
///
/// - label (content): Node content to display.
/// - pad (length, none): Padding between the node's content and its bounding
/// box or bounding circle. If `auto`, defaults to the `node-pad` option of
/// `arrow-diagram()`.
/// - shape (string, auto): Shape of the node, one of `"rect"` or `"circle"`. If
/// `auto`, shape is automatically chosen depending on the aspect ratio of the
/// node's label.
/// - stroke (stroke): Stroke of the node. Defaults to the `node-stroke` option
/// of `arrow-diagram()`.
/// - fill (paint): Fill of the node. Defaults to the `node-fill` option of
/// `arrow-diagram()`.
/// - defocus (number): Strength of the "defocus" adjustment for connectors
/// incident with this node. If `auto`, defaults to the `node-defocus` option
/// of `arrow-diagram()` .
#let node(
pos,
label,
pad: auto,
outset: auto,
shape: auto,
stroke: auto,
fill: auto,
defocus: auto,
) = {
assert(type(pos) == array and pos.len() == 2)
if type(label) == content and label.func() == circle { panic(label) }
((
kind: "node",
pos: pos,
label: label,
pad: pad,
outset: outset,
shape: shape,
stroke: stroke,
fill: fill,
defocus: defocus,
),)
}
#let CONN_ARGUMENT_SHORTHANDS = (
"dashed": (dash: "dashed"),
"dotted": (dash: "dotted"),
"double": (double: true),
"crossing": (crossing: true),
)
#let interpret-conn-args(args) = {
let named-args = (:)
if args.named().len() > 0 {
panic("Unexpected named argument(s):", ..args.named().keys())
}
let pos = args.pos()
if pos.len() >= 1 and type(pos.at(0)) != str {
named-args.label = pos.remove(0)
}
if (pos.len() >= 1 and type(pos.at(0)) == str and
pos.at(0) not in CONN_ARGUMENT_SHORTHANDS) {
named-args.marks = pos.remove(0)
}
for arg in pos {
if type(arg) == str and arg in CONN_ARGUMENT_SHORTHANDS {
named-args += CONN_ARGUMENT_SHORTHANDS.at(arg)
} else {
panic(
"Unrecognised argument " + repr(arg) + ". Must be one of:",
CONN_ARGUMENT_SHORTHANDS.keys(),
)
}
}
named-args
}
/// Draw a connecting line or arc in an arrow diagram.
///
/// - from (elastic coord): Start coordinate `(x, y)` of connector. If there is
/// a node at that point, the connector is adjusted to begin at the node's
/// bounding rectangle/circle.
/// - to (elastic coord): End coordinate `(x, y)` of connector. If there is a
/// node at that point, the connector is adjusted to end at the node's bounding
/// rectangle/circle.
///
/// - ..args (any): The connector's `label` and `marks` named arguments can also
/// be specified as positional arguments. For example, the following are equivalent:
/// ```typc
/// conn((0,0), (1,0), $f$, "->")
/// conn((0,0), (1,0), $f$, marks: "->")
/// conn((0,0), (1,0), "->", label: $f$)
/// conn((0,0), (1,0), label: $f$, marks: "->")
/// ```
///
/// - label-pos (number): Position of the label along the connector, from the
/// start to end (from `0` to `1`).
///
/// #stack(
/// dir: ltr,
/// spacing: 1fr,
/// ..(0, 0.25, 0.5, 0.75, 1).map(p => arrow-diagram(
/// cell-size: 1cm,
/// conn((0,0), (1,0), p, "->", label-pos: p))
/// ),
/// )
/// - label-sep (number): Separation between the connector and the label anchor.
///
/// With the default anchor (`"bottom"`):
/// #arrow-diagram(
/// debug: 2,
/// cell-size: 8mm,
/// {
/// for (i, s) in (-5pt, 0pt, .4em, .8em).enumerate() {
/// conn((2*i,0), (2*i + 1,0), s, "->", label-sep: s)
/// }
/// })
///
/// With `label-anchor: "center"`:
/// #arrow-diagram(
/// debug: 2,
/// cell-size: 8mm,
/// {
/// for (i, s) in (-5pt, 0pt, .4em, .8em).enumerate() {
/// conn((2*i,0), (2*i + 1,0), s, "->", label-sep: s, label-anchor: "center")
/// }
/// })
///
/// - label (content): Content for connector label. See `label-side` to control
/// the position (and `label-sep`, `label-pos` and `label-anchor` for finer
/// control).
///
/// - label-side (left, right, center): Which side of the connector to place the
/// label on, viewed as you walk along it. If `center`, then the label is place
/// over the connector. When `auto`, a value of `left` or `right` is chosen to
/// automatically so that the label is
/// - roughly above the connector, in the case of straight lines; or
/// - on the outside of the curve, in the case of arcs.
///
/// - label-anchor (anchor): The anchor point to place the label at, such as
/// `"top-right"`, `"center"`, `"bottom"`, etc. If `auto`, the anchor is
/// automatically chosen based on `label-side` and the angle of the connector.
///
/// - paint (paint): Paint (color or gradient) of the connector stroke.
/// - thickness (length): Thickness the connector stroke. Marks (arrow heads)
/// scale with this thickness.
/// - dash (dash type): Dash style for the connector stroke.
/// - bend (angle): Curvature of the connector. If `0deg`, the connector is a
/// straight line; positive angles bend clockwise.
///
/// #arrow-diagram(debug: 0, {
/// node((0,0), $A$)
/// node((1,1), $B$)
/// let N = 4
/// range(N + 1)
/// .map(x => (x/N - 0.5)*2*100deg)
/// .map(θ => conn((0,0), (1,1), θ, bend: θ, ">->", label-side: center))
/// .join()
/// })
///
/// - marks (pair of strings):
/// The start and end marks or arrow heads of the connector. A shorthand such as
/// `"->"` can used instead. For example,
/// `conn(p1, p2, "->")` is short for `conn(p1, p2, marks: (none, "head"))`.
///
/// #table(
/// columns: 3,
/// align: horizon,
/// [Arrow], [Shorthand], [Arguments],
/// ..(
/// "-",
/// "--",
/// "..",
/// "->",
/// "<=>",
/// ">>-->",
/// "|..|",
/// "hook->>",
/// "hook'->>",
/// ">-harpoon",
/// ">-harpoon'",
/// ).map(str => (
/// arrow-diagram(conn((0,0), (1,0), str)),
/// raw(str, lang: none),
/// raw(repr(parse-arrow-shorthand(str))),
/// )).join()
/// )
///
/// - double (bool): Shortcut for `extrude: (-1.5, 1.5)`, showing a double stroke.
/// - extrude (array of numbers): Draw copies of the stroke extruded by the
/// given multiple of the stroke thickness. Used to obtain doubling effect.
/// Best explained by example:
///
/// #arrow-diagram({
/// (
/// (0,),
/// (-1.5,+1.5),
/// (-2,0,+2),
/// (-4.5,),
/// (4.5,),
/// ).enumerate().map(((i, e)) => {
/// conn(
/// (2*i, 0), (2*i + 1, 0), [#e], "|->",
/// extrude: e, thickness: 1pt, label-sep: 1em)
/// }).join()
/// })
///
/// Notice how the ends of the line need to shift a little depending on the
/// mark. For basic arrow heads, this offset is computed with
/// `round-arrow-cap-offset()`.
///
/// - crossing (bool): If `true`, draws a white backdrop to give the illusion of
/// lines crossing each other.
/// #arrow-diagram({
/// conn((0,1), (1,0), thickness: 1pt)
/// conn((0,0), (1,1), thickness: 1pt)
/// conn((2,1), (3,0), thickness: 1pt)
/// conn((2,0), (3,1), thickness: 1pt, crossing: true)
/// })
/// - crossing-thickness (number): Thickness of the white "crossing" background
/// stroke, if `crossing: true`, in multiples of the normal stroke's thickness.
///
/// #arrow-diagram({
/// (1, 2, 5, 8, 12).enumerate().map(((i, x)) => {
/// conn((2*i, 1), (2*i + 1, 0), thickness: 1pt, label-sep: 1em)
/// conn((2*i, 0), (2*i + 1, 1), raw(str(x)), thickness: 1pt, label-sep:
/// 1em, crossing: true, crossing-thickness: x)
/// }).join()
/// })
///
#let conn(
from,
to,
..args,
label: none,
label-side: auto,
label-pos: 0.5,
label-sep: 0.4em,
label-anchor: auto,
paint: black,
thickness: 0.6pt,
dash: none,
bend: none,
marks: (none, none),
double: false,
extrude: auto,
crossing: false,
crossing-thickness: 5,
) = {
let options = (
label: label,
label-pos: label-pos,
label-sep: label-sep,
label-anchor: label-anchor,
label-side: label-side,
paint: paint,
thickness: thickness,
dash: dash,
bend: bend,
marks: marks,
double: double,
extrude: extrude,
crossing: crossing,
crossing-thickness: crossing-thickness,
)
options += interpret-conn-args(args)
let mode = if bend in (none, 0deg) { "line" } else { "arc" }
if type(options.marks) == str {
options += parse-arrow-shorthand(options.marks)
}
if options.extrude == auto {
options.extrude = if options.double { (-1.5, +1.5) } else { (0,) }
}
let stroke = (
paint: options.paint,
cap: "round",
thickness: options.thickness,
dash: options.dash,
)
if options.label-side == center {
options.label-anchor = "center"
options.label-sep = 0pt
}
let obj = (
kind: "conn",
points: (from, to),
label: options.label,
label-pos: options.label-pos,
label-sep: options.label-sep,
label-anchor: options.label-anchor,
label-side: options.label-side,
paint: options.paint,
mode: mode,
bend: options.bend,
stroke: stroke,
marks: options.marks,
extrude: options.extrude,
)
// add empty nodes at terminal points
node(from, none)
node(to, none)
if options.crossing {
// duplicate connector with white stroke and place underneath
let understroke = (
..obj.stroke,
paint: white,
thickness: crossing-thickness*obj.stroke.thickness,
)
((
..obj,
stroke: understroke,
marks: (none, none),
extrude: obj.extrude.map(i => i/crossing-thickness)
),)
}
(obj,)
}
#let execute-callbacks(grid, nodes, callbacks, options) = {
for callback in callbacks {
let resolved-coords = callback.coords
.map(elastic-to-physical-coords.with(grid))
let result = (callback.callback)(..resolved-coords)
if type(result) != array {
panic("Callback should return an array of CeTZ element dictionaries; got " + type(result), result)
}
result
}
}
/// Draw an arrow diagram.
///
/// - ..objects (array): An array of dictionaries specifying the diagram's
/// nodes and connections.
///
/// - debug (bool, 1, 2, 3): Level of detail for drawing debug information.
/// Level 1 shows a coordinate grid; higher levels show bounding boxes and
/// anchors, etc.
///
/// - spacing (length, pair of lengths): Gaps between rows and columns. Ensures
/// that nodes at adjacent grid points are at least this far apart (measured as
/// the space between their bounding boxes).
///
/// Separate horizontal/vertical gutters can be specified with `(x, y)`. A
/// single length `d` is short for `(d, d)`.
///
/// - cell-size (length, pair of lengths): Minimum size of all rows and columns.
///
/// - node-pad (length, pair of lengths): Default padding between a node's
/// content and its bounding box.
/// - node-stroke (stroke): Default stroke for all nodes in diagram. Overridden
/// by individual node options.
/// - node-fill (paint): Default fill for all nodes in diagram. Overridden by
/// individual node options.
///
/// - node-defocus (number): Default strength of the "defocus" adjustment for
/// nodes. This affects how connectors attach to non-square nodes. If
/// `0`, the adjustment is disabled and connectors are always directed at the
/// node's exact center.
///
/// #stack(
/// dir: ltr,
/// spacing: 1fr,
/// ..(0.2, 0, -1).enumerate().map(((i, defocus)) => {
/// arrow-diagram(spacing: 8mm, {
/// node((i, 0), raw("defocus: "+str(defocus)), stroke: black, defocus: defocus)
/// for y in (-1, +1) {
/// conn((i - 1, y), (i, 0))
/// conn((i, y), (i, 0))
/// conn((i + 1, y), (i, 0))
/// }
/// })
/// })
/// )
///
/// - crossing-fill (paint): Color to use behind lines or labels to give the
/// illusion of crossing over other objects.
///
/// - render (function): After the node sizes and grid layout have been
/// determined, the `render` function is called with the following arguments:
/// - `grid`: a dictionary of the row and column widths and positions;
/// - `nodes`: an array of nodes (dictionaries) with computed attributes
/// (including size and physical coordinates);
/// - `conns`: an array of connectors (dictionaries) in the diagram; and
/// - `options`: other diagram attributes.
///
/// This callback is exposed so you can access the above data and draw things
/// directly with CeTZ.
#let arrow-diagram(
..objects,
debug: false,
spacing: 3em,
cell-size: 0pt,
node-pad: 15pt,
node-outset: 0pt,
node-stroke: none,
node-fill: none,
node-defocus: 0.2,
crossing-fill: white,
render: (grid, nodes, conns, options) => {
cetz.canvas(draw-diagram(grid, nodes, conns, options))
},
) = {
if type(spacing) != array { spacing = (spacing, spacing) }
if type(cell-size) != array { cell-size = (cell-size, cell-size) }
if objects.named().len() > 0 {
let args = objects.named().keys().join(", ")
panic("Unexpected named argument(s): " + args)
}
let options = (
spacing: spacing,
debug: int(debug),
node-pad: node-pad,
node-outset: node-outset,
node-stroke: node-stroke,
node-fill: node-fill,
node-defocus: node-defocus,
cell-size: cell-size,
crossing-fill: crossing-fill,
..objects.named(),
)
let positional-args = objects.pos().join()
let nodes = positional-args.filter(e => e.kind == "node")
let conns = positional-args.filter(e => e.kind == "conn")
let callbacks = positional-args.filter(e => e.kind == "coord")
box(style(styles => {
let em-size = measure(box(width: 1em), styles).width
let to-pt(len) = len.abs + len.em*em-size
let options = options
options.em-size = em-size
options.spacing = options.spacing.map(to-pt)
options.node-pad = to-pt(options.node-pad)
let nodes = compute-nodes(nodes, styles, options)
let grid = compute-grid(nodes, options)
let nodes = compute-node-positions(nodes, grid, options)
render(grid, nodes, conns, options)
}))
}
|
https://github.com/Kasci/LiturgicalBooks | https://raw.githubusercontent.com/Kasci/LiturgicalBooks/master/CU/minea/1_generated/00_all/08_april.typ | typst | #import "../../../all.typ": *
#show: book
= #translation.at("M_08_april")
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/keyle/0.1.0/src/keyle.typ | typst | Apache License 2.0 | #import "sym.typ": com-key, mac-key
#let _inset = 4pt
#let _outset = 2pt
#let _radius = 3pt
#let _kbd-stardard-style(sym) = box(rect(
inset: (x: _inset),
outset: (top: _outset),
stroke: rgb("#555"),
radius: _radius,
fill: rgb("#eee"),
text(fill: black, sym),
))
#let _kbd-deep-blue-style(sym) = box(rect(
inset: (x: _inset),
outset: (top: _outset),
stroke: rgb("#2a6596"),
radius: _radius,
fill: rgb("#4682b4"),
smallcaps(text(fill: white, sym)),
))
#let _kbd-type-writer-style(sym) = box(
rect(inset: (x: _inset), stroke: rgb("#2b2b2b"), radius: 50%, fill: rgb("#333"), smallcaps(text(fill: white, sym))),
)
#let _kbd-style-funcs = (standard: _kbd-stardard-style, deep-blue: _kbd-deep-blue-style, type-writer: _kbd-type-writer-style)
#let kbd-styles = (standard: "standard", deep-blue: "deep-blue", type-writer: "type-writer")
#let kbd-state = state("kbd-style-state", kbd-styles.standard)
/// Set the keyboard style.
///
/// #example(```typ
/// #keyle.kbd[A] // standard style
/// #keyle.kbd-set-style("deep-blue")
/// #keyle.kbd[A] // deep-blue style
/// #keyle.kbd-set-style(keyle.kbd-styles.standard) // back to standard style
/// ```)
///
/// - s (string): The style name. Use `kbd-styles` to get available styles.
#let kbd-set-style(s) = {
kbd-state.update(s)
}
/// Renders a keyboard key.
///
/// #example(```typ
/// #keyle.kbd("Ctrl", "A")
/// ```)
///
/// #example(```typ
/// #keyle.kbd("Ctrl", "A", compact: true)
/// ```)
///
/// #example(```typ
/// #keyle.kbd("Ctrl", "A", compact: true, delim: "-")
/// ```)
///
/// - ..keys (string): The key to render.
/// - compact (bool): If true, the keys will be rendered in a single box.
/// - delim (string): The delimiter to use when rendering in compact mode.
#let kbd(..keys, compact: false, delim: "+") = {
locate(loc => {
let style-str = kbd-state.at(loc)
let style-func = _kbd-style-funcs.at(style-str)
if compact {
style-func(keys.pos().join(delim))
} else {
keys.pos().map(k => [#style-func(k)]).join([ #box(height: 1.2em, delim) ])
}
})
}
#let kbd-example = align(center)[
#box([
#kbd[1] #kbd[2] #kbd[3] #kbd[4] #kbd[5] #kbd[6] #kbd[7] #kbd[8] #kbd[9] #kbd[0]\
#kbd[Q] #kbd[W] #kbd[E] #kbd[R] #kbd[T] #kbd[Y] #kbd[U] #kbd[I] #kbd[O] #kbd[P]\
#kbd[A] #kbd[S] #kbd[D] #kbd[F] #kbd[G] #kbd[H] #kbd[J] #kbd[K] #kbd[L]\
#kbd[Z] #kbd[X] #kbd[C] #kbd[V] #kbd[B] #kbd[N] #kbd[M]
])
]
#let kbd-mac-example = align(
center,
)[
#box(
[
#kbd(mac-key.command) #kbd(mac-key.shift) #kbd(mac-key.option) #kbd(mac-key.control) #kbd(mac-key.return) #kbd(mac-key.delete) #kbd(mac-key.forward-delete) #kbd(mac-key.escape) #kbd(mac-key.left) #kbd(mac-key.right) #kbd(mac-key.up) #kbd(mac-key.down) #kbd(mac-key.pageup) #kbd(mac-key.pagedown) #kbd(mac-key.home) #kbd(mac-key.end) #kbd(mac-key.tab-right) #kbd(mac-key.tab-left)
],
)
]
#let kbd-com-example = align(
center,
)[
#box(
[
#kbd(com-key.control) #kbd(com-key.shift) #kbd(com-key.alt) #kbd(com-key.return) #kbd(com-key.delete) #kbd(com-key.escape) #kbd(com-key.left) #kbd(com-key.right) #kbd(com-key.up) #kbd(com-key.down) #kbd(com-key.pageup) #kbd(com-key.pagedown) #kbd(com-key.home) #kbd(com-key.end) #kbd(com-key.tab)
],
)
] |
https://github.com/LucaCiucci/tesi-triennale | https://raw.githubusercontent.com/LucaCiucci/tesi-triennale/main/main.typ | typst | Creative Commons Zero v1.0 Universal | #import "slide.typ": *
#import "@preview/pinit:0.1.3": *
#set text(size: 9pt)
#set math.equation(supplement: "Eq.")
//#show math.equation: set text(9pt)
#set document(
title: title,
author: (
"<NAME>",
"Prof. <NAME>",
),
date: data-laurea,
)
#set text(lang: "it")
// ================================================================
// TITOLO
// ================================================================
// title page
#raw-slide(
//section: ([Cover],),
section: (),
counter-name: "intro-slides",
counter-display: "I",
)[
#place(
center + horizon,
rect(
stroke: none,
align(center, [
#text(15pt)[Tesi di Laurea Triennale - #data-laurea-d]\
#text(30pt, weight: "bold")[Monopoli Magnetici]\
#text(15pt)[Candidato: *<NAME>*]\
#text(15pt)[Relatore: Prof. Stefano Bolognesi]\
#text(10pt)[Università di Pisa]\
#text(10pt)[Dipartimento di Fisica]
#image(logo_path_2, width: 50pt)
#set quote(block: true)
//#text(10pt, style: "italic")[#quote(attribution: [Yakov M. Shni])[The theory of monopoles is rich in paradoxes, both real and fictional]]
])
),
)
]
// ================================
// ABSTRACT
// ================================
#abstract[
Sin dalla formulazione delle equazioni di Maxwell, l'esistenza dei monopoli magnetici è stata oggetto di ricerca teorica e sperimentale. Questo elaborato esplora alcuni aspetti teorici significativi sulle proprietà dei monopoli magnetici derivanti dalla consistenza della teoria dei potenziali elettromagnetici e delle loro proprietà topologiche, con particolare attenzione alla quantizzazione della carica elettrica e magnetica
Si osserva che la simmetria $U(1)$ delle equazioni di Maxwell sembra contemplare la presenza di cariche magnetiche. Viene quindi introdotto il problema della conservazione del momento angolare, che rimane costante considerando il contributo dato dal tensore degli stress del campo elettromagnetico oppure considerando un termine aggiuntivo $~e g$, con $e$ e $g$ rispettivamente le cariche elettrica e magnetica.
Successivamente si considera la soluzione di Dirac per il potenziale vettore di un monopolo magnetico, che risulta singolare su una stringa. Si osserva che, imponendo l'invarianza di gauge, il campo da essa generato non è fisico in quanto trasforma in base alla gauge scelta. In meccanica quantistica, si richiede che l'apporto all'azione dovuto a una trasformazione di gauge non comporti effetti osservabili, ottenendo così una condizione di quantizzazione delle cariche elettrica e magnetica.
Un risultato notevole è che la presenza di un singolo monopolo magnetico nell'universo impone, per consistenza, la quantizzazione della carica elettrica. La condizione è anche equivalente a richiedere che la fase accumulata /*nel path integral*/ dalla funzione d'onda intorno alla stringa sia $2 pi n$, oppure che il termine aggiuntivo al momento angolare conservato abbia autovalori semi-interi.\
Questa condizione può essere generalizzata a coppie di dyoni, trovando che la carica di un dyone risiede su un reticolo $(e, g)$, rompendo la simmetria $U(1)$ delle equazioni di Maxwell.
Un'altra formulazione notevole dei monopoli magnetici, proposta da Wu e Yang, richiede di rappresentare il potenziale vettore tramite un ricoprimento dello spazio con due potenziali di Dirac. Questo elimina la singolarità, mentre la condizione di quantizzazione si ritrova considerando il path integral nella regione di sovrapposizione.\
Tale trattazione si formalizza naturalmente tramite nozioni di topologia e geometria differenziale: le usuali equazioni di Maxwell vivono su fibrato triviale formato dallo spazio e dal campo. La singolarità in un punto invece implica una classificazione di tali fibrati tramite il primo numero di Chern ovvero la carica topologica.
Infine si considera una semplice trattazione relativistica, introducendo alla possibilità di avere due quadripotenziali per descrivere il campo elettromagnetico.
La ricerca di evidenze è stata oggetto di numerosi esperimenti in quanto tali particelle risultano inquadrate nelle GUTs. Sono state concepite diverse metodologie, come ad esepio la ricerca di tracce elettriche su di anelli superconduttori/* o SQUID*/, la radiazione di Cherenkov (/*esperimento MACRO e */AMANDA), l'analisi di segnali radio (ANITA) o l'analisi delle traiettorie sotto l'effetto di un campo magnetico (esperimento MoEDAL).\
Attualmente non sono stati osservati monopoli magnetici, e alcuni esperimenti si concentrano sul fornire limiti superiori alla loro esistenza.
]
#script[
Buongiorno, oggi vi parlerò del tema dei *monopoli magnetici* e di alcune delle loro *proprietà teoriche* deducibili dalle *equazioni di Maxwell* e dalla *Meccanica Qauntisitica*.
]
// ================================================================
// 1 / 5
// ================================================================
#slide(
section: ([Dualità $E <-> M$],),
cols[
- Apparente simmetria per l'equazione di Poisson: $
bold(nabla) dot bold(E) = rho_E space ; space bold(nabla) dot bold(B) = rho_B
$
- Momento angolare è globalmente conservato (invarianza per rotazioni): $
bold(tilde(L)) = bold(L) underbracket(cancel(+ space e text(#red.darken(30%), g) bold(hat(r))), bold(L)_(E M) = 1/(4 pi) integral bold(r) times bold(S) = -e g bold(hat(r)))
$
- Soluzione tipo del potenziale vettore (singolare su una _stringa_): $
bold(A)(bold(r), epsilon) = g/R (bold(r) times bold(n))/(R - bold(r) dot bold(n))
$
- In generale la conservazione del flusso implica che la trasformazione di Gauge deve essere a singolo valore @yakov:
$
delta Phi = integral.cont d bold(ell) dot bold(nabla) lambda = 0 space ==> space lambda(phi + 2 pi) = lambda(phi)
$
- La trasformazione della stringa ci dice che il suo campo non è fisico /*#strike[ma dovuto al fatto che usiamo un solo quadri-potenziale]*/
][
#figure[#rect(width: 80%, height: 40%, stroke: none)[
//figura, magari con #link("https://anvaka.github.io/fieldplay/?cx=0.0017000000000000348&cy=0&w=8.543199999999999&h=8.543199999999999&dt=0.01&fo=0.998&dp=0.009&cm=2&vf=%0A%2F%2F%20Regolarizzazione%20del%20modulo%2C%20da%20fare%20meglio%20con%20epsilon%20relativo%0Afloat%20R%28vec3%20p%29%20%7B%0A%20%20float%20epsilon%20%3D%200.05%3B%0A%20%20return%20sqrt%28p.x%20*%20p.x%20%2B%20p.y%20*%20p.y%20%2B%20p.z%20%2B%20p.z%20%2B%20epsilon%20*%20epsilon%29%3B%0A%7D%0A%0A%2F%2F%20Potenziale%20di%20Dirac%20REGOLARIZZATO%0Avec3%20A%28vec3%20p%29%20%7B%0A%20%20vec3%20n%20%3D%20vec3%280.%2C%20-1.%2C%200.%29%3B%0A%20%20return%201.%20%2F%20R%28p%29%20*%20cross%28p%2C%20n%29%20%2F%20%28R%28p%29%20-%20dot%28p%2C%20n%29%29%3B%0A%7D%0A%0A%2F%2F%20Campo%20magnetico%20come%20rotore%20di%20A%0Avec2%20B%28vec3%20p%29%20%7B%0A%20%20float%20h%20%3D%200.001%3B%0A%20%20vec3%20dx_A%20%3D%20%28A%28p%20%2B%20vec3%28h%2C%200.%2C%200.%29%29%20-%20A%28p%20-%20vec3%28h%2C%200.%2C%200.%29%29%29%20%2F%20%282.%20*%20h%29%3B%0A%20%20vec3%20dy_A%20%3D%20%28A%28p%20%2B%20vec3%280.%2C%20h%2C%200.%29%29%20-%20A%28p%20-%20vec3%280.%2C%20h%2C%200.%29%29%29%20%2F%20%282.%20*%20h%29%3B%0A%20%20vec3%20dz_A%20%3D%20%28A%28p%20%2B%20vec3%280.%2C%200.%2C%20h%29%29%20-%20A%28p%20-%20vec3%280.%2C%200.%2C%20h%29%29%29%20%2F%20%282.%20*%20h%29%3B%0A%20%20return%20vec2%28%0A%20%20%20%20dy_A.z%20-%20dz_A.y%2C%0A%20%20%20%20dz_A.x%20-%20dx_A.z%0A%20%20%29%3B%0A%7D%0A%0A%2F%2F%20main%0Avec2%20get_velocity%28vec2%20p%29%20%7B%0A%20%20vec2%20b%20%3D%20B%28vec3%28p.x%2C%20p.y%2C%200.%29%29%3B%0A%20%20%0A%20%20float%20intensity%20%3D%20length%28b%29%3B%0A%0A%20%20return%20normalize%28b%29%20*%20%28log%28intensity%29%20%2B%203.0%29*0.1%3B%0A%7D&code=%0A%2F%2F%20Regolarizzazione%20del%20modulo%2C%20da%20fare%20meglio%20con%20epsilon%20relativo%0Afloat%20R%28vec3%20p%29%20%7B%0A%20%20float%20epsilon%20%3D%200.05%3B%0A%20%20return%20sqrt%28p.x%20*%20p.x%20%2B%20p.y%20*%20p.y%20%2B%20p.z%20%2B%20p.z%20%2B%20epsilon%20*%20epsilon%29%3B%0A%7D%0A%0A%2F%2F%20Potenziale%20di%20Dirac%20REGOLARIZZATO%0Avec3%20A%28vec3%20p%29%20%7B%0A%20%20vec3%20n%20%3D%20vec3%280.%2C%20-1.%2C%200.%29%3B%0A%20%20return%201.%20%2F%20R%28p%29%20*%20cross%28p%2C%20n%29%20%2F%20%28R%28p%29%20-%20dot%28p%2C%20n%29%29%3B%0A%7D%0A%0A%2F%2F%20Campo%20magnetico%20come%20rotore%20di%20A%0Avec2%20B%28vec3%20p%29%20%7B%0A%20%20float%20h%20%3D%200.001%3B%0A%20%20vec3%20dx_A%20%3D%20%28A%28p%20%2B%20vec3%28h%2C%200.%2C%200.%29%29%20-%20A%28p%20-%20vec3%28h%2C%200.%2C%200.%29%29%29%20%2F%20%282.%20*%20h%29%3B%0A%20%20vec3%20dy_A%20%3D%20%28A%28p%20%2B%20vec3%280.%2C%20h%2C%200.%29%29%20-%20A%28p%20-%20vec3%280.%2C%20h%2C%200.%29%29%29%20%2F%20%282.%20*%20h%29%3B%0A%20%20vec3%20dz_A%20%3D%20%28A%28p%20%2B%20vec3%280.%2C%200.%2C%20h%29%29%20-%20A%28p%20-%20vec3%280.%2C%200.%2C%20h%29%29%29%20%2F%20%282.%20*%20h%29%3B%0A%20%20return%20vec2%28%0A%20%20%20%20dy_A.z%20-%20dz_A.y%2C%0A%20%20%20%20dz_A.x%20-%20dx_A.z%0A%20%20%29%3B%0A%7D%0A%0A%2F%2F%20main%0Avec2%20get_velocity%28vec2%20p%29%20%7B%0A%20%20vec2%20b%20%3D%20B%28vec3%28p.x%2C%20p.y%2C%200.%29%29%3B%0A%20%20%0A%20%20float%20intensity%20%3D%20length%28b%29%3B%0A%0A%20%20return%20normalize%28b%29%20*%20%28log%28intensity%29%20%2B%203.0%29*0.1%3B%0A%7D")[questo sfondo]
//#include "img/slide_1/monopolo.typ"
#image("img/slide_1/image_4.png")
]]
Equazioni di Maxwell con sorgente/*per il campo libero*/: $
bold(nabla) (bold(E) + i bold(B)) &= rho_e + i rho_g\
bold(nabla) times (bold(E) + i bold(B)) - i diff_t (bold(E) + i bold(B)) &= bold(j)_e + i bold(j)_g,
$ suggeriscono la simmetria: #math.equation(block: true, numbering: "(1)", $
D: space (bold(E) + i bold(B), rho_e + i rho_b) -> text(#red.darken(20%), e^(i theta)) (bold(E) + i bold(B), rho_e + i rho_b)
$)<todo-simm-1> che in particolare non modifica le equazioni di E.L. per il campo libero: $
cal(L) = - 1/(4 e^2) F_(mu nu) F^(mu nu) = F_(mu nu) = - 1/(2 e^2) (E^2 - B^2)
$
]
)
//#script[
// Le equazioni di Maxwell presentano una _dualità_ intrinseca che suggerisce una possibile simmetria tra carica elettrica e magnetica. #strike[In particolare viene quasi naturale chiedersi se è possibile scrivere l'*equazione di Poisson* per la *carica magnetica*, e questo lo possiamo fare.] In particolare è naturale chiedersi se è possibile scrivere e risolvere l'equazione di Poisson per la carica magnetica, questo non pone particolare problemi.
//
// In ambito classico la prima peculiarità che può venire in mente è la conservazione del *momento angolare*, che di fatti *non si conserva* come possiamo vedere analizzando un problema di *scattering $e-g$*. Infatti la posizione relativa di muove su di un cono, con un *potenziale efficacie sempre repulsivo* #strike[, quindi chiaramente non si può conservare.]
//
// In realtà #strike[con dei semplici conti #footnote[basta moltiplicare vettorialmente per $arrow(r)$ (RIVEDI)]] in meccanica classica si può trovare una *diversa definizione* del momento angolare *conservato*, comprendente un termine aggiuntivo/*$~e g hat(r)$*/.\
// //Comunque questo pezzo non propriamente piacevole non
// Comunque notiamo che *l'usuale momento angolare è conservato* se si considera anche il contributo del campo elettromagnetico #strike[tramite il formalismo del vettore di Poynting,], e questo *è* un aspetto *desiderabile* poiché il *sistema è invariante per rotazioni*.
//
// E' poi naturale chiedersi come sarebbe fatto il potenziale ti tale oggetto, ed una soluzione particolarmente semplice è il *potenziale di Dirac*, che però risulta singolare su di una stringa.\
// Altri potenziali uni-valori hanno tutti una singolarita su almeno una stringa e questo deriva dal fatto che la divergenza del rotore è nulla. Diverse soluzioni del potenziale #strike[(come ad esempio quello di #text(red)[?????????] che ha la singolarità su un piano)] sono comunque connesse a quello di Dirac tramite #strike[combinazioni di] trasformazioni di gauge.\
// Comunque il fatto che la stringa dipenda dalla gauge ci dice che non è fisica ma un artefatto della soluzione. #strike[se *richiediamo l'invarianza di gauge*].
//
// Un'altra osservazione interessante che ci spinge ad esplorare questo tema è il fatto che le equazioni di Maxwell presentano una simmetria $U(1)$ #strike[se combiniamo i campi come parte reale e immaginaria], #strike[o comunque $S O(2)$ se vogliamo vedere che le equazioni di Maxwell sono invarianti per nello spazio $(E, B)$].\
// Si può comunque dimostrare esplicitamente che le equazioni di Eulero Lagrange /*dell'usuale Lagrangiana*/ per il campo libero sono invarianti sotto tale simmetria #strike[(da qui il termine di elettrodinamica abeliana)].
//
// #place(bottom + right)[$approx$ 2 min]
//]
#script[
Buongiorno, oggi vi parlerò del tema dei *monopoli magnetici* e di alcune delle loro *proprietà teoriche* deducibili dalle *equazioni di Maxwell* e dalla *Meccanica Qauntisitica*.
#line(length: 100%)
Le equazioni di Maxwell presentano una _dualità_ intrinseca che suggerisce una possibile simmetria tra carica elettrica e magnetica. In particolare è naturale chiedersi se è possibile scrivere e risolvere l'equazione di Poisson per la carica magnetica e questo non pone particolare problemi.
In ambito classico la prima peculiarità che può venire in mente è la conservazione del *momento angolare*, che di fatti *non si conserva* come possiamo vedere analizzando un problema di *scattering $e-g$* dove la posizione relativa di muove su di un cono.
In realtà in meccanica classica si può trovare una *diversa definizione* del momento angolare *conservato*, comprendente un termine aggiuntivo.\
Comunque notiamo che *l'usuale momento angolare è conservato* se si considera anche il contributo del campo elettromagnetico#footnote[Poynting], e questo *è* un aspetto *desiderabile* poiché il *sistema è invariante per rotazioni*.
E' poi naturale chiedersi come sarebbe fatto il potenziale ti tale oggetto, ed una soluzione particolarmente semplice è il *potenziale di Dirac*, che però risulta singolare su di una stringa.\
Altri potenziali uni-valori hanno tutti una singolarita su almeno una stringa e questo deriva dal fatto che la divergenza del rotore è nulla.\
Comunque il fatto che la stringa dipenda dalla gauge ci dice che non è fisica ma un artefatto della soluzione.
Un'altra osservazione interessante che ci spinge ad esplorare questo tema è il fatto che le equazioni di Maxwell presentano una simmetria $U(1)$ e si può comunque mostrare esplicitamente che le equazioni di Eulero Lagrange per il campo sono invarianti sotto tale simmetria.
#place(bottom + right)[$approx$ 2 min]
]
//#note[
// Le equazioni di maxwell presentano una _dualità_ intrinseca che suggerisce una simmetria tra carica elettrica per l'equazione di poisson:
// $
// bold(nabla) dot bold(E) = rho_E space ; space bold(nabla) dot bold(B) = rho_B
// $
// sebbene una carica magnetica non sia mai stata osservata sperimentalmente.
//
// Il momento angolare in un sistema di due particelle non si conserva, ma dalla lagrangiana si conserva la seguente quantità:
// $
// bold(tilde(L)) = bold(L) + e text(#red.darken(30%), g) bold(hat(r))
// $
// Perché:
// $
// bold(L)_(E M) = 1/(4 pi) integral bold(r) times bold(S) = 1/(4 pi) integral bold(r) times bold(S) = ... = -e g bold(hat(r))
// $
//
// Poi parlo delle possibili soluzioni che si riescono a scrivere mantenendo un solo potenziale vettore, di cui tutte ricavabili come combinazioni di trasformazioni di gauge del potenziale di Dirac:
// $
// bold(A)(bold(r), epsilon) = g/R (bold(r) times bold(n))/(R - bold(r) dot bold(n))
// $
// dove $R$ usa la regolarizzazione per fare i calcoli, altrimenti servono dei campi ausiliari #footnote[https://en.wikipedia.org/wiki/Magnetic_monopole#Potential_formulation].
//
// Ma $bold(A)$ p definito a meno di una trasformazione di gauge:
// $
// bold(A) -> bold(A)' = bold(A) - i/e U^dagger bold(nabla) U; space U = e^(i e lambda(bold(r)))
// $
// Il flusso deve essere conservato:
// $
// delta Phi = integral.cont d bold(ell) dot bold(nabla) lambda = 0 space ==> space lambda(phi + 2 pi) = lambda(phi)
// $
// Quindi la trasformazione di gauge deve essere a singolo valore
//]
// ================================================================
// 2 / 5
// ================================================================
#slide(
section: ([Monopoli in QM],),
)[
#cols[
= Quantizzazione della carica
- Operatore momento angolare: $
hat(D) = bold(nabla) - i e hat(bold(A))(bold(r)) overbracket(-->, "gauge") hat(U) hat(D) = e^(i e lambda(bold(r))) hat(D)
$ per cui la lagrangiana trasforma: $
cal(L) -> cal(L) + e dot(bold(r)) bold(nabla) lambda(bold(r)) ==> S -> S + lr(e lambda(bold(r))|)_0^T
$ vogliamo che l'ampiezza $e^(i S)$ sia invariante di gauge: #math.equation(block: true, numbering: "(1)", $
delta S = e delta lambda = 2 pi n ==> #rect(radius: 3pt, stroke: red)[$mu eq.def e g = n\/2$]
$)<quantization-condition>
- La presenza di un singolo monopolo nell'universo impone la quantizzazione della carica! @yakov
- Un altro modo semplice è imporre la non fisicità della stringa di dirac, i.e. la fase accumulata nel path integral intorno ad essa deve essere $2 pi n$, si ritrova @quantization-condition.// (TODO forse è meglio riportare anche l'approccio eq. 2.9 dello Yakov).
- Approccio Saha: /*la correzione al momento angolare non deve essere osservabile*/ $
tilde(bold(L)) = bold(L) + text(#red.darken(20%), e g hat(r)) <-- #[imponendo auto [semi-]interi]
$
][
= Generalizzazione
- Condizione di Schwinger-Zwanzinger per una coppia di dyoni invece di una $e-g$: $
e_1 g_2 - e_2 g_1 = n in ZZ
$ impone la quantizzazione sia della carica elettrica che magnetica: #math.equation(numbering: "(1)", block: true, $
e + i g = e_0 (m tau + n); space tau = theta / (2 pi) + i n_0/e_0^2
$) <dyon-quantization>
- La simmetria $S O(2)$ è rotta e i dyoni giaciono su di un reticolo definito da @dyon-quantization, di cui le cariche elettriche corrispondono a $m = 0$
#figure[
//Da ridisegnare:
#place(bottom + center, dy: 38mm, image("img/slide_2/image_2.png", width: 75%))
]
]
]
#script[
*Se guardiamo il problema* dell'interazione tra una carica elettrica e magnetica *da un punto di vista quantistico*, troviamo dei *vincoli aggiuntivi*.\
Infatti calcolando la *variazione dell'azione*, e imponendo che *l'ampiezza $e^(i S)$* sia *invariante di gauge*, troviamo la seguente *regola di quantizzazione*.\
Questa è particolarmente *interessante* perché l'*esistenza di* anche solo *un monopolo* nell'universo *spiegherebbe* la quantizzazione della *carica elettrica*.\
Ci sono altri modi per giungere alla stessa conclusione, uno notevole è quello di calcolare il *Path Integral* intorno alla stringa, che abbiamo *richiesto non essere osservabile*, dunque la *fase accumulata* deve essere multipla di $2 pi$.\
Un'altro approccio semplice è quello di richiede che il *momento angolare sia intero o semi-intero*, e questo ci porta direttamente alla stesso risultato.
Ripetendo il ragionamento e considerando il problema dinamico tra due dyoni (ossia particelle con carica elettrica e magnetica), troviamo una *più generale condizione*, che impone *contemporaneamente* la *quantizzazione* della carica *sia elettrica che magnetica*.\
Scopriamo che stavolta la presenza di *un dyone nell'universo* impone la quantizzazione di entrambe le cariche: $e$ e $g$ *sono collegate* e giacciono su un *reticolo* come quello mostrato in figura.\
Può sorgere la domanda del perché uno dei due assi è proprio lungo la carica elettrica, ma come vedremo più avanti si può sempre rientrare in questo caso con una rotazione.
#place(bottom + right)[$approx$ 1.5 min]
]
// ================================================================
// 3 / 5
// ================================================================
#slide(
section: ([Soluzione topologica dei monopoli abeliani],),
cols[
== Monopolo di Wu-Yang
- Cerchiamo una soluzione non singolare
- dobbiamo rinunciare ad avere un solo set di coordinate
- possiamo usare ad esempio il ricoprimento: $
cases(
bold(A)^N = g (1 - cos theta)/(r sin theta) hat(bold(e))_phi,
bold(A)^S = -g (1 + cos theta)/(r sin theta) hat(bold(e))_phi,
)
$ connessi da una gauge
- calcolando la fase guadagnata da una funzione d'onda (a singolo valore) nella regione di sovrapposizione, si ha nuovamente la regola di quantizzazone della carica
#figure[
#image("img/slide_3/image_2.png", width: 37%)
]
- Formalizzabile in modo naturale tramite nozioni di topologia e geometria differenziale
][
=== Topologia
- Descriviamo lo spazio ed il campo come un fibrato: localmente $cal(M) = X times F$ (triviale se vale per tutto lo spazio)
- Punto chiave: globalmente, la topologia è definita dalle funzioni di transizione /*delle mappe*/ dei ricoprimenti
- La "forma geometrica" deve essere definita tramite la metrica e la connessione
- Una classificazione sono le classi caratteristiche di Chern $c_k$
- Per $c_0 = 0$ il fibrato è triviale e può essere ricoperto da una sola carta. Il pontenziale ed il tensore degli stress è definito globalmente. Questo è il caso delle equazioni di Maxwell usuali.
- La situazione cambia se togliamo un punto: $R^3\/{0}$ è omotopo a $S^2$ e servono almeno due ricoprimenti. Infatti/conseguenza $F$ è una forma chiusa ma non esatta.
- In questo caso la topologia è definita da $c_1 eq.def n$ (_carica topologica_), per $c_1 = 0$ siamo nel caso triviale usuale mentre $c_1 = 1$ ad esempio è descrivibile tramite il fibrato di Hopf
=== Conclusioni
- Un monopolo abeliano può esistere se la topologia dell'universo non è triviale
]
)
#script[
Un'altro approccio #underline[molto interessante]#footnote[meglio] è quello proposto da Wu e Yang che consiste nel rappresentare la soluzione tramite un ricoprimento dello spazio con due potenziali di Dirac al fine di eliminare la singolarità *ma* ciò è possibile solo rinunciando alla richiesta di avere un solo set di coordinate.\
Se ci chiediamo cosa ne è della regola di quantizzazione, scopriamo che rimane comunque, e si può ritrovare calcolando la fase guadagnata da una funzione d'onda nella regione di sovrapposizione.
Questo approccio è particolarmente interessante perché si formalizza in modo naturale tramite nozioni di topologia e geometria differenziale:\
In generale possiamo descrivere il "*bundle*" di *spazio* e *campo* come un *FIBRATO*. Qui ad esempio $X$ è lo spazio ed $F$ il campo.\
La topologia non è definita solo da questo prodotto, ma anche dalle funzioni di transizione dei ricoprimenti.\
In particolare se possiamo *scrivere* il fibrato *come prodotto cartesiano*, allora il fibrato è *triviale* e possiamo usare un solo set di coordinate.
Una cosa particolare succede se togliamo un punto dello spazio (la sorgente), in tal caso la topologia è definita da $c_1$ che corrisponde alla *carica topologica*, ossia $e$ per $g$.
La conclusione notevole è che la presenza di un monopolo rende la topologia dell'universo non triviale!
#place(bottom + right)[$approx$ 1.5 min]
]
// ================================================================
// 4 / 5
// ================================================================
/*#slide(
section: ([Monopoli abeliani], [Formulazione relativistica],),
cols[
- Possiamo generalizzare la costruzione riscrivendo le equazioni di maxwell e la dinamica in modo simmetrico: $
diff_mu F^(mu nu) = j^((e) nu), space & space diff_mu tilde(F)^(mu nu) = j^((g) nu),\
m_e (d u_mu^(e))/(d tau^(e)) = e F_(mu nu) u^((e) nu), space & space m_e (d u_mu^(g))/(d tau^(g)) = e F_(mu nu) u^((g) nu),
$
- la costruzione dei potenziali non è banale, dirac propone: $
F_(mu nu) = diff_mu A_nu - diff_nu A_mu text(#red.darken(40%), - tilde(G)_(mu nu)) space, space diff^(mu) G_(mu nu) = j_nu^((g))
$
- questo ci induce a pensare di introdurre due potenziali: $
cases(
F_(mu nu) = diff_mu A_nu - diff_nu A_mu - epsilon_(mu nu rho sigma) diff_sigma tilde(A)^sigma,
tilde(F)_(mu nu) = diff_mu tilde(A)_nu - diff_nu tilde(A)_mu + epsilon_(mu nu rho sigma) diff_sigma A^sigma,
)
$ con la condizione di consistenza per mantenere il numero di gradi di libertà $
diff_mu A_nu - diff_nu A_mu + epsilon_(mu nu rho sigma) diff^sigma tilde(A)^rho = 0
$
- ritroviamo il caso usuale con una rotazione di $theta = -arctan(g\/e)$ (cfr @todo-simm-1): $
D: cases(
A_mu -> A_mu cos theta - tilde(A)_mu sin theta,
tilde(A)_mu -> A_mu sin theta + tilde(A)_mu cos theta,
)
$
][
= TODO
- meccanica quantistica
- invarianza relativistica
]
)*/
#slide(
section: (/*[Monopoli abeliani], */[Formulazione relativistica],),
{
show math.equation: set text(11pt)
cols[
- Possiamo generalizzare la costruzione riscrivendo le equazioni di maxwell e la dinamica in modo simmetrico: $
diff_mu F^(mu nu) = j^((e) nu), space & space diff_mu tilde(F)^(mu nu) = j^((g) nu)
$ e la dinamica: $
m_e (d u_mu^((e)))/(d tau^((e))) = e F_(mu nu) u^((e) nu), space & space m_g (d u_mu^((g)))/(d tau^((g))) = e F_(mu nu) u^((g) nu),
$
- la costruzione dei potenziali non è banale, dirac propone: $
F_(mu nu) = diff_mu A_nu - diff_nu A_mu text(#red.darken(40%), - tilde(G)_(mu nu)) space, space diff^(mu) G_(mu nu) = j_nu^((g))
$ dove $G_(mu nu)$ è un tensore aggiuntivo per soddisfare la seconda equazione.
- esplicitando le componenti di $F_(mu nu)$ e $tilde(F)_(mu nu)$ si trovano le equazioni di maxwell con sorgente come scritte nella prima slide.
][
- questo ci induce a pensare di introdurre due potenziali: $
cases(
F_(mu nu) = diff_mu A_nu - diff_nu A_mu - epsilon_(mu nu rho sigma) diff_sigma tilde(A)^sigma,
tilde(F)_(mu nu) = diff_mu tilde(A)_nu - diff_nu tilde(A)_mu + epsilon_(mu nu rho sigma) diff_sigma A^sigma,
)
$
- è necessaria una condizione di consistenza per mantenere il numero di gradi di libertà $
diff_mu A_nu - diff_nu A_mu + epsilon_(mu nu rho sigma) diff^sigma tilde(A)^rho = 0
$
- Ritroviamo il caso usuale con una rotazione di $theta = -arctan(g\/e)$ (cfr @todo-simm-1): $
D: cases(
A_mu -> A_mu cos theta - tilde(A)_mu sin theta,
tilde(A)_mu -> A_mu sin theta + tilde(A)_mu cos theta,
)
$
]
}
)
#script[
Infine vorrei presentare un approccio differente che consiste nell'utilizzare due potenziali per eliminare il problema delle singolarità: si cerca prima di riscrivere le equazioni di Maxwell e la dinamica in modo simmetrico.\
Qui le prime due relazioni sono le equazioni di Maxwell con sorgente e quelle sotto rappresentano la dinamica.\
#strike[Queste relazioni si trovano esplicitando le varie componenti delle equazioni di Maxwell].
La costruzione dei potenziali non è banale, un approccio proposto da Dirac è quello di scrivere il tensore di campo come derivata dell'usuale quadri-potenziale e di un tensore aggiuntivo.\
Comunque si può dimostrare che in questo ambito altri approcci sono equivalenti.
Abbiamo così introdotto due potenziali che ci permettono di descrivere il campo senza singolarità; tuttavia, avendo ora delle variabili aggiuntive ($G_(mu nu)$), dobbiamo imporre un'equazione di consistenza per mantenere il numero di gradi di libertà. #footnote[Questo ricorda vagamente il caso della parametrizzazione del gruppo $S O(3)$ come accennato prima, infatti tutte le mappe con 3 parametri hanno qualche singolarità#footnote[DA RIVEDERE] ed in molti casi per comodità si preferisce eliminarla al costo di introdurre un'altra variabile ed una condizione di "normalizzazione", è questo un caso d'uso dei quaternioni.\
Analogamente tale trattazione che fa leva su due potenziali risulta particolarmente utile nelle trattazioni relativistiche. RIVEDERE MA FORSE MEGLIO USARE NOZIONI DI TOPOLOGIA]
Questa trattazione con due potenziali potrebbe sembrare artificiosa, ma risulta essere particolarmente adatta ad essere applicata in ambito relativistico.
Notiamo infine che in presenza di dyoni è possibile ritrovare il caso usuale con una rotazione, come accennato nella seconda slide.
//Una generalizzazione interessante è quella di riscrivere le equazioni di Maxwell e la dinamica in modo simmetrico, introducendo due set di equazioni per i campi e le correnti elettriche e magnetiche.\
//La costruzione dei potenziali non è banale, e Dirac propone una soluzione che introduce due potenziali, e questo ci induce a pensare di introdurre due potenziali.\
//La condizione di consistenza per mantenere il numero di gradi di libertà è data da una relazione tra i due potenziali, e ritroviamo il caso usuale con una rotazione di $theta = -arctan(g\/e)$.
#place(bottom + right)[$approx$ 1.5 min]
]
// ================================================================
// 5 / 5
// ================================================================
/*#slide(
section: ([Ricerche sperimentali],),
cols[
- TODO Cercare un po' in rete, ad esempio:
- HECOs https://atlas.cern/Updates/Physics-Briefing/Run2-Monopoles
- HECOs https://home.cern/news/news/physics/quest-curious-magnetic-monopole-continues
- MoEDAL https://www.home.cern/news/news/physics/moedal-zeroes-magnetic-monopoles
- MoEDAL https://arxiv.org/pdf/1604.06645 (vedi https://home.infn.it/it/comunicati-stampa-full/comunicati-stampa-2016/1951-ricerca-dei-monopoli-magnetici-l-esperimento-moedal-pubblica-i-primi-risultati-2) !!!
- https://arxiv.org/abs/1905.10130
- https://arxiv.org/abs/1905.10130
- https://iopscience.iop.org/article/10.1088/1742-6596/2375/1/012002/pdf
- Altri link da vedere:
- https://atlas.cern/Updates/Physics-Briefing/Run2-Monopoles
][
#text(gray)[cercando "<NAME>opoles"]: #link("https://cds.cern.ch/record/2744867/files/CERN%20THESES%202020%20191.pdf", text(red)[QUESTA TESI])
]
)*/
#slide(
section: ([Ricerche sperimentali],),
cols[
== Proprietà ricercate
- Alcune teorie "Beyond the Standard Model" (BSM) prevedono l'esistenza di monopoli magnetici @tesi-mai
- I monopoli avrebbero un forte coupling elettromagnetico e sono previste dalle teorie sotto forma di HIPs ("Highly Ionizing Particles"),
- I monopoli sono inquadrati in alcune "Grand Unified Theories" (GUTs), la cui scala di energia aspettata è tra la scala elettrodebole ($~10^2 space G e V$) e la scala di Planck ($~10^19 space G e V$)
== Alcuni esperimenti
- La ricerca di osservazioni dirette di tali particelle si concentra chiaramente sulle "Long Lived Particles"
- Alcuni esperimenti sono sfruttano i raggi cosmici per esplorare le energie più alte
- Una possibilità e quella di misurare direttamente i campi magnetici tramite anelli superconduttori oppure SQUIDs (Superconducting Quantum Interference Devices @squid)
][
- Ricerca tramite rivelatori Cherenkov (AMANDA) guardano particolari segnature dovute alla alta massa prevista dalle GUTs @tesi-mai ed all'alta energia persa per ionizzazione, considerando anche il filtraggio dovuto al campo magnetico terrestre @MACRO-giacomelli
//- TODO esperimento #link("https://arxiv.org/pdf/0707.1691")[MACRO] che devo ancora capire
- L'esperimento ANITA cerca invece segnali radio dovuti all'interazione con il ghiaccio Antartico di monopoli ultra-relativistici
=== Ricerca nei collisori
- L'LHC è il candidato più adatto poiché la scala di energia potrebbe essere elevata ma alcune teorie suggeriscono tali particelle anche ad energie $~T e V$ @tesi-mai
- Essendo HIPs, la ricerca di un'osservazione diretta di LLPs è possibile cercando delle tracce molto strette sui calorimetri elettromagnetici (ECAL), con la condizione che la traccia nei calorimetri adronici (HCAL) sia piccola o nulla
- essendo HIPs è possibile ricercare particolari traiettorie nei campi magnetici
]
)
#script[
Per quanto riguarda la ricerca di evidenze sperimentali, questo campo è stato attivo sin dalla prima proposta teorica di Dirac.\
Al giorno d'oggi alcune teorie oltre il modello standard ne prevedono l'esistenza e in particolare alcune "Grand Unified Theories" (GUTs) li contemplano in un range di energia tra la scala elettrodebole e la scala di Planck, quindi particelle pesanti.\
Da calcoli di elettrodinamica e considerando la regola di quantizzazione prima citata, si trova che questi avrebbero un *forte coupling elettromagnetico* e sarebbero particelle *altamente ionizzanti*.
Per ricercarli, una possibilità è quella di misurare direttamente i campi magnetici, e questo è possibile con apparati particolarmente sensibili costituiti da spire di materiale superconduttore
Altri esperimenti invece sfruttano la grande massa prevista e la loro alta energia persa per ionizzazione. Si può ad esempio ricercare segnali Cherenkov o segnali radio dovuti all'interazione con la materia.
Per quanto riguarda la ricerca nei collisori, l'LHC è un buon candidato perché la scala di energia potrebbe essere elevata.\
In particolare nei collisori di LHC sarebbe possibile osservarli direttamente guardando le traiettorie nel campo magnetico, oppure guardando le tracce sui calorimetri elettromagnetici.
Ad oggi comunque non sono state osservate evidenze dirette.
]
// ================================================================
// RINGRAZIAMENTI
// ================================================================
#raw-slide(
counter-name: "intro-slides",
counter-display: "I",
)[
= Ringraziamenti
#text(size: 1.25em)[Un sentito ringraziamento al Prof. <NAME> per la sua preziosa guida, agli amici per il loro sostegno e alla mia famiglia per il loro infinito supporto.]
#place(bottom, dy: -10pt, align(top, bibliography("bibliography.yaml")))
]
#script[
Vi ringrazio per l'attenzione.
]
//ciao |
https://github.com/mumblingdrunkard/mscs-thesis | https://raw.githubusercontent.com/mumblingdrunkard/mscs-thesis/master/src/utils/setup.typ | typst | #import "./latex.typ" as latex
#import "./acronyms.typ" as acronyms
#import "./config.typ" as config
#let setup = body => {
set text(size: 10pt)
set text(font: config.font)
set par(justify: true)
set par(linebreaks: "optimized")
//set par(first-line-indent: 1em, leading: .65em)
//show par: set block(spacing: .65em)
set page(paper: "a4", margin: (x: 30mm, top: 21mm, bottom: 28mm), number-align: bottom, header-ascent: 2em, footer-descent: 2em)
set page(header: {
counter(footnote).update(0)
}, footer: {
place(bottom + left, box(width: 100%, height: 28mm, {
align(center + horizon, {
locate(loc => {
if loc.page-numbering() != none {
(latex.size.normalsize)(weight: "regular", {
numbering(loc.page-numbering(), counter(page).get().first())
})
}
})
})
}))
})
set figure(numbering: num => {
// Get heading numbering at this point
let n = query(selector(heading.where(level: 1)).before(here())).last().numbering
numbering(n + ".1.", counter(heading).get().first(), num)
})
show figure.where(kind: table): set figure.caption(position: top)
// show figure.caption: set text(size: 9pt)
set math.equation(numbering: num => {
// Get heading numbering at this point
let n = query(selector(heading.where(level: 1)).before(here()))
if n.len() > 0 and n.last().numbering != none {
[(]
numbering(n.last().numbering + ".1", counter(heading).get().first(), num)
[)]
}
})
set math.equation(supplement: none)
set outline(fill: repeat(" ."), indent: true)
show outline.entry: it => {
let start = measure(it.body).width
let end = measure(it.page).width
link(it.element.location(), {
if it.element.func() == heading and it.level == 1 {
v(1em, weak: true)
set text(weight: 500, size: 12pt)
it.body
box(width: 1fr)
text(size: 10pt, it.page)
} else {
it.body
box(it.fill, width: 1fr)
box(width: 5pt)
it.page
}
})
}
// Fix the font in SVGs
show image: it => {
set text(font: "Fira Code")
it
}
show heading: set par(first-line-indent: 0pt)
show heading: set text(weight: 700)
set figure(placement: auto)
show ref: it => {
let el = it.element
if el != none and el.func() == figure {
text(weight: "black", it)
} else {
it
}
}
show heading: it => {
block(breakable: false, {
if it.numbering != none {
numbering(it.numbering, ..counter(heading).at(it.location()))
[ ]
}
// show text: underline
it.body
})
}
show heading.where(level: 1): set heading(supplement: "Chapter")
show heading.where(level: 1): it => {
pagebreak(to: "odd", weak: true)
block(breakable: false, {
counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: raw)).update(0)
counter(figure.where(kind: table)).update(0)
counter(math.equation).update(0)
v(3em)
locate(loc => {
if it.numbering != none {
counter(heading.where(level: 1)).display(me => {
text(size: 48pt, {
numbering("1.", me)
})
})
}
{
linebreak()
// v(2.7em, weak: true)
(latex.size.Huge)(it.body)
v(1em)
}
})
})
}
show heading.where(level: 2): set text(size: 14.4pt)
show heading.where(level: 3): set text(size: 12pt)
show heading.where(level: 4): set heading(numbering: none)
set heading(numbering: none, outlined: false)
// include "../frontmatter/front-page.typ"
set page(paper: "a4", margin: (inside: 36mm, outside: 24mm))
set page(numbering: "i")
counter(page).update(1)
set table(stroke: none, fill: (x, y) => {
if y.bit-and(1) != 1 {
silver.lighten(60%)
} else {
white
}
})
show raw.where(block: true): set text(font: "DejaVu Sans Mono", size: 8pt)
//set raw(theme: "../MultiMarkdown.tmTheme")
show raw.where(block: true): set par(leading: .4em)
include "../frontmatter/abstract.typ"
include "../frontmatter/acknowledgements.typ"
outline(target: heading, title: "Table of Contents", depth: 3)
[
= Glossary
#grid(
acronyms.listOfAcronyms()
)
]
{
show heading.where(level: 1): it => {
linebreak()
// v(2.7em, weak: true)
(latex.size.Huge)(it.body)
v(1em)
}
outline(target: figure.where(kind: image), title: "List of Figures")
pagebreak()
outline(target: figure.where(kind: raw), title: "List of Listings")
outline(target: figure.where(kind: table), title: "List of Tables")
}
set page(numbering: none)
pagebreak(to: "odd")
show: acronyms.enableAcronyms
set heading(outlined: true)
set page(numbering: "1")
counter(page).update(1)
set heading(numbering: "1.1")
body
{
set heading(numbering: none)
bibliography("../bibliography.yaml")
}
}
|
|
https://github.com/maxgraw/bachelor | https://raw.githubusercontent.com/maxgraw/bachelor/main/apps/document/src/1-introduction/goal.typ | typst | Das primäre Ziel dieser Arbeit besteht darin, eine Augmented Reality-Konstruktionsumgebung für Möbelsysteme zu konzipieren und zu entwickeln, die auf der WebXR-Technologie basiert. Die Anwendung soll es hierbei ermöglichen, Modelle in einer Augmented Reality-Umgebung zu visualisieren und mit diesen zu interagieren. Es sollen Modelle hinzugefügt und bearbeitet sowie Verbindungen zwischen einzelnen Modellen hergestellt werden können. Dadurch soll es innerhalb der Anwendung möglich sein komplexe Möbelsysteme zu erstellen.
Für die initiale Evaluation der Anwendung wird das Stackcube-System herangezogen, ein modulares Möbelsystem, das aus einzelnen, frei kombinierbaren Würfeln besteht. Die Verbindung der einzelnen Elemente erfolgt durch die Verzahnung der Zapfen. Dadurch können die Elemente schnell und kostengünstig miteinander verbunden werden. Durch die Möglichkeit des interaktiven Zusammenstellens von Möbeln sollen Anordnungen, wie im @cube dargestellt, in der Anwendung realisiert werden können.
#figure(
image("../media/stackcubes.png", width: 80%),
caption: [Beispielhafte Anordnung von Stackcube Elementen],
) <cube>
Neben der Unterstützung für das Stackcubes-System soll die Anwendung zukünftig auch andere Möbelsysteme integrieren können, um eine breite Anwendbarkeit und Anpassungsfähigkeit der entwickelten Technologie zu gewährleisten. Eine wichtige Komponente des Projekts ist die Integration der AR-Anwendung in bestehende Systeme wie Online-Shops, um den praktischen Nutzen der Anwendung in realen Verkaufssituationen zu demonstrieren.
Die Benutzeroberfläche und die User Experience spielen eine entscheidende Rolle für die Akzeptanz und Benutzbarkeit der Anwendung. Daher wird ein besonderer Fokus auf die Entwicklung einer intuitiven und leicht zugänglichen Benutzeroberfläche gelegt. Diese soll nicht nur funktional sein, sondern auch die Interaktion mit den Möbelsystemen in einer Weise unterstützen, die dem Nutzer eine natürliche und angenehme Erfahrung bietet.
Schließlich umfasst die Validierung der Anwendung sowohl die Überprüfung der Benutzeroberfläche und der User Experience als auch die Evaluierung der gewählten technologischen Lösungen. Durch die Überprüfung von Anforderungen soll die Funktionalität der Anwendung sichergestellt und die Nutzung von WebXR validiert werden. Die User Experience wird mithilfe einer Studie mit der Anwendung evaluiert, um Erkenntnisse über die Benutzerfreundlichkeit und das Benutzererlebnis zu gewinnen. |
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/math/matrix-alignment_05.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test #460 equations.
#let stop = {
math.class("punctuation",$.$)
}
$ mat(&a+b,c;&d, e) $
$ mat(&a+b&,c;&d&, e) $
$ mat(&&&a+b,c;&&&d, e) $
$ mat(stop &a+b&stop,c;...stop stop&d&...stop stop, e) $
|
https://github.com/cskeeters/novela-typst | https://raw.githubusercontent.com/cskeeters/novela-typst/master/test.typ | typst | = Display Regular
#text(font:"Novela")[ABC] (Should have lower contrast strokes than the line below)
#text(font:"NovelaDisplay")[ABC]
= Display Italic
#text(font:"Novela", style:"italic")[ABC] (Should have lower contrast strokes than the line below)
#text(font:"NovelaDisplay", style:"italic")[ABC]
= Ornaments
#text(font:"Novela")[✾✿❀]
= Ornaments in Display Fonts
#text(font:"NovelaDisplay")[✾✿❀]
#text(font:"NovelaDisplay", style: "italic")[✾✿❀]
|
|
https://github.com/kokkonisd/typst-cross | https://raw.githubusercontent.com/kokkonisd/typst-cross/main/src/lib.typ | typst | The Unlicense | #import "preprocessing.typ": *
#import "board.typ": *
#import "clues.typ": *
// Produce a single-page crossword.
//
// Parameters:
// - `data`: the data loaded from the crossword's TOML file. See `preprocessing.typ`.
// - `show-solution`: if `true`, show the solution to the crossword.
// - `show-cell-coordinates`: if `true` (and `show-solution` is also `true`), display the
// coordinates of the cells below the letters. This is useful when debugging or placing clues.
// - `cell-size`: the size of the cells of the board.
// - `letter-size`: the size of the letter of each cell.
// - `number-size`: the size of the number of each cell (if any).
// - `margin`: the page margin.
// - `clue-columns`: the number of columns to split the clues into.
#let single-page(
data,
show-solution: false,
show-cell-coordinates: false,
cell-size: 25pt,
letter-size: 8pt,
number-size: 5pt,
margin: 1cm,
clue-columns: 2,
) = {
set text(size: letter-size)
set page(paper: "presentation-16-9", margin: margin)
block(width: 100%, height: 100%)[
#set align(center)
= #data.title \
#emph[by #data.author]
#set align(center + horizon)
#grid(
columns: (auto, auto),
gutter: 20pt,
block(height: auto, width: 100%)[
#set align(center + horizon)
#board(
data,
show-solution: show-solution,
show-cell-coordinates: show-cell-coordinates,
cell-size: cell-size,
letter-size: letter-size,
number-size: number-size,
)
],
block(height: auto, width: 100%)[
#columns(clue-columns)[
#set align(left)
== Across
#clues-across(data)
== Down
#clues-down(data)
]
]
)
]
}
|
https://github.com/yhtq/Notes | https://raw.githubusercontent.com/yhtq/Notes/main/并行与分布式计算/上机报告/上机报告1.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.
#show: note.with(
title: "并行与分布式计算 第一次报告",
author: "郭子荀 2100012990",
date: datetime.today().display(),
logo: none,
withOutlined : false,
)
= 计算任务与实现方式
本次实现的计算任务是完成矩阵乘向量计算:
$
A x = b
$
其中
$
A = vec(A_1, dots.v, A_m)\
x = vec(x_1, dots.v, x_m)\
$
且 $A_i, x_i$ 不同的进程上完成初始化。
大致的实现思路是采用最简单的按行分割,每个进程存储若干 $m' times (m n)$ 的矩阵 ```c A_local``` 和 $m' times 1$ 的向量 ```c x_local```,每个进程将自己的 ```c x_local``` 通过 ```c Allgather``` 操作使得每个进程拥有一份完整的 ```c x```,之后各自使用自己拥有的矩阵乘 ```c x``` 即可。
另外,任务要求我们在规模较小时使用串行程序验证结果。我们规定 $m n < 1000$ 时,最终 rank 为零的进程将收集所有矩阵,串行计算结果,再将结果广播到每个进程。每个进程将自己的 ```c x_local``` 与广播的结果进行比对,如果不一致则输出错误信息。
= 编译/运行方式
== 编译选项
本次实验基于 cmake 进行编译,同时提供了两种编译选项,包括:
- ```-DCOMMUNICATION_AFTER_PARTIALLY_COMPUTE=1```
- ```-DCOMPUTE_AFTER_COMMUNICATION=1```
具体含义在实现细节部分会介绍。cmake 采取 Release 模式编译时,会关闭边界检查和运行时日志输出,同时开启若干用于优化的编译选项,以提高运行效率。
== 运行选项
程序接受两个运行时命令行参数 $-m [m], -n [n]$ (不依赖顺序),分别代表问题规模中的 $m, n$
== 完整脚本
完整的 slurm 脚本如下:
```bash
#!/bin/bash
#SBATCH --job-name=2100012990
#SBATCH --output=output
#SBATCH -p cpu
#SBATCH --ntasks-per-node=16
#SBATCH --cpus-per-task=1
#SBATCH -N 1
module add gcc/12.2.0
module add cmake/3.20.2
echo "Test ComputeBeforeCommunication"
cmake -DCOMMUNICATION_AFTER_PARTIALLY_COMPUTE=1 -DCMAKE_BUILD_TYPE=Release .
make
mpirun -np 16 hw1 -m 16 -n 500
echo "Test ComputeAfterCommunication"
cmake -DCOMPUTE_AFTER_COMMUNICATION=1 -UCOMMUNICATION_AFTER_PARTIALLY_COMPUTE -DCMAKE_BUILD_TYPE=Release .
make
mpirun -np 16 hw1 -m 16 -n 500
echo "Size 16 * 500, process 1"
mpirun -np 1 hw1 -m 16 -n 500
echo "Size 16 * 500, process 2"
mpirun -np 2 hw1 -m 16 -n 500
echo "Size 16 * 500, process 4"
mpirun -np 4 hw1 -m 16 -n 500
echo "Size 16 * 500, process 8"
mpirun -np 8 hw1 -m 16 -n 500
echo "Size 16 * 500, process 16"
mpirun -np 16 hw1 -m 16 -n 500
echo "Size 1 * 1000, process 1"
mpirun -np 1 hw1 -m 1 -n 1000
echo "Size 2 * 707, process 2"
mpirun -np 2 hw1 -m 2 -n 707
echo "Size 4 * 500, process 4"
mpirun -np 4 hw1 -m 4 -n 500
echo "Size 8 * 354, process 8"
mpirun -np 8 hw1 -m 8 -n 354
echo "Size 16 * 250, process 16"
mpirun -np 16 hw1 -m 16 -n 250
```
= 实现细节
== C++ 封装
为了内存管理方便,我们使用了基于 ```cpp unique_ptr``` 的矩阵/向量封装,避免了手动管理内存的同时不会影响运行效率。(所有的取值函数都会被 inline 展开到原始的内存访问)。同时,通过封装还可以轻易实现由宏控制的可选边界检查,方便进行调试。
#let size = "size"
== $m$ 的分配
任务要求中提示将 $m$ 分配到进程,但是并没有给出 $m$ 的取值限制,为了保证各种取值的正确性,我们做了如下处理:
- 首先,将 $m n$ padding 至 $size$ 的倍数,并记其为 ```c nrows```,同时令 ```c ncols = nrows``` 表示列数
- 其次,令:
```c
nrows_local = nrows / size
```
表示每个进程的行数
- 最后,每个进程初始化 nrows_local 行 ncols 列的矩阵 ```c A_local``` 和 nrows_local 行 1 列的向量 ```c x_local```,还需要额外将 ```c A_local``` 的 $m * n$ 列之后手动置零防止影响结果。
如此即可保证程序对于任意的 $m$ 取值均正确。
== 是否在通讯之前计算
从之前的初始化过程可以看出,每个进程在通信之前事实上可以完成一部分运算,即先将自己拥有的 $x$ 部分做运算的部分结果放在 $"res"$ 中,通讯完成后只需计算来自其他进程的部分即可。由于不确定这样实现的效率如何,实现时利用基于宏和 c++ constexpr 特性的条件编译,修改编译选项即可无运行开销的切换两种实现。两种实现的测试如下:
```bash
Test ComputeBeforeCommunication
-- {fmt} version: 11.0.2
-- Build type: Release
COMMUNICATION_AFTER_PARTIALLY_COMPUTE
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
COMMUNICATION_AFTER_PARTIALLY_COMPUTE
-- Build files have been written to: /mnt/lustrefs/home/fpdc2024_2100012990/code/hw1
Consolidate compiler generated dependencies of target fmt
[ 60%] Built target fmt
Consolidate compiler generated dependencies of target hw1
[ 80%] Building CXX object CMakeFiles/hw1.dir/main.cpp.o
[100%] Linking CXX executable hw1
[100%] Built target hw1
rank=0, start_row=0, nrows_local=500
args: m = 16, n = 500, size = 16
matrix size after padding: 8000 x 8000
Implementation mode: CommunicationAfterPariallyCompute
rank=2, start_row=1000, nrows_local=500
rank=3, start_row=1500, nrows_local=500
rank=7, start_row=3500, nrows_local=500
rank=8, start_row=4000, nrows_local=500
rank=9, start_row=4500, nrows_local=500
rank=10, start_row=5000, nrows_local=500
rank=14, start_row=7000, nrows_local=500
rank=15, start_row=7500, nrows_local=500
rank=4, start_row=2000, nrows_local=500
rank=6, start_row=3000, nrows_local=500
rank=11, start_row=5500, nrows_local=500
rank=12, start_row=6000, nrows_local=500
rank=5, start_row=2500, nrows_local=500
rank=13, start_row=6500, nrows_local=500
rank=1, start_row=500, nrows_local=500
Finish 100 compuation, per time cost: 10801 us
Test ComputeAfterCommunication
-- {fmt} version: 11.0.2
-- Build type: Release
COMPUTE_AFTER_COMMUNICATION
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/lustrefs/home/fpdc2024_2100012990/code/hw1
Consolidate compiler generated dependencies of target fmt
[ 60%] Built target fmt
Consolidate compiler generated dependencies of target hw1
[ 80%] Building CXX object CMakeFiles/hw1.dir/main.cpp.o
[100%] Linking CXX executable hw1
[100%] Built target hw1
rank=0, start_row=0, nrows_local=500
args: m = 16, n = 500, size = 16
matrix size after padding: 8000 x 8000
Implementation mode: ComputeAfterCommunication
rank=2, start_row=1000, nrows_local=500
rank=3, start_row=1500, nrows_local=500
rank=4, start_row=2000, nrows_local=500
rank=6, start_row=3000, nrows_local=500
rank=7, start_row=3500, nrows_local=500
rank=10, start_row=5000, nrows_local=500
rank=11, start_row=5500, nrows_local=500
rank=13, start_row=6500, nrows_local=500
rank=1, start_row=500, nrows_local=500
rank=14, start_row=7000, nrows_local=500
rank=5, start_row=2500, nrows_local=500
rank=8, start_row=4000, nrows_local=500
rank=9, start_row=4500, nrows_local=500
rank=12, start_row=6000, nrows_local=500
rank=15, start_row=7500, nrows_local=500
Finish 100 compuation, per time cost: 5560 us
```
可见使用简单的先通讯再整体计算的效率远高于上述调整。但直观上,上面的先部分计算再通讯的选项应该能一定程度上将计算和通讯交叉进行,可能导致效率降低的因素包括:
- 这里实现的粒度过粗,只是在计算完成后进行 ```c Allgather``` 操作,一旦某个进程没有完成之前的运算,进而集合通讯无法完成,可能会导致所有进程阻塞。如果细粒度到收到每个进程的数据后都立即计算,而不是等待收到所有数据,可能效率会更高。
- 最终进行矩阵乘向量的循环操作中,为了防止运算重复进行需要排除已经进行过的运算,使得控制流更为复杂,而乘加运算本身很简单,可能会导致计算量减少带来的效率提升并不明显。
= 结果
我们进行了两组测试,包括固定工作量,不同进程数和工作量与进程数成正比的测试,并分别考察两种情况的加速比。
== 固定工作量
本组测试结果如下:
```bash
Size 16 * 500, process 1
rank=0, start_row=0, nrows_local=8000
args: m = 16, n = 500, size = 1
matrix size after padding: 8000 x 8000
Implementation mode: ComputeAfterCommunication
Finish 100 compuation, per time cost: 42025 us
Size 16 * 500, process 2
rank=0, start_row=0, nrows_local=4000
args: m = 16, n = 500, size = 2
matrix size after padding: 8000 x 8000
Implementation mode: ComputeAfterCommunication
rank=1, start_row=4000, nrows_local=4000
Finish 100 compuation, per time cost: 22311 us
Size 16 * 500, process 4
rank=2, start_row=4000, nrows_local=2000
rank=1, start_row=2000, nrows_local=2000
rank=3, start_row=6000, nrows_local=2000
rank=0, start_row=0, nrows_local=2000
args: m = 16, n = 500, size = 4
matrix size after padding: 8000 x 8000
Implementation mode: ComputeAfterCommunication
Finish 100 compuation, per time cost: 11876 us
Size 16 * 500, process 8
rank=2, start_row=2000, nrows_local=1000
rank=4, start_row=4000, nrows_local=1000
rank=0, start_row=0, nrows_local=1000
args: m = 16, n = 500, size = 8
matrix size after padding: 8000 x 8000
Implementation mode: ComputeAfterCommunication
rank=1, start_row=1000, nrows_local=1000
rank=5, start_row=5000, nrows_local=1000
rank=7, start_row=7000, nrows_local=1000
rank=3, start_row=3000, nrows_local=1000
rank=6, start_row=6000, nrows_local=1000
Finish 100 compuation, per time cost: 6888 us
Size 16 * 500, process 16
rank=0, start_row=0, nrows_local=500
args: m = 16, n = 500, size = 16
matrix size after padding: 8000 x 8000
Implementation mode: ComputeAfterCommunication
rank=8, start_row=4000, nrows_local=500
rank=1, start_row=500, nrows_local=500
rank=2, start_row=1000, nrows_local=500
rank=3, start_row=1500, nrows_local=500
rank=6, start_row=3000, nrows_local=500
rank=7, start_row=3500, nrows_local=500
rank=14, start_row=7000, nrows_local=500
rank=15, start_row=7500, nrows_local=500
rank=4, start_row=2000, nrows_local=500
rank=9, start_row=4500, nrows_local=500
rank=10, start_row=5000, nrows_local=500
rank=12, start_row=6000, nrows_local=500
rank=5, start_row=2500, nrows_local=500
rank=13, start_row=6500, nrows_local=500
rank=11, start_row=5500, nrows_local=500
Finish 100 compuation, per time cost: 5596 us
```
不难看出,进程数较少时增加进程数的收益明显,加速比接近线性。而当进程数由 $8$ 增加至 $16$ 时,加速效果已经不太明显。这非常符合 Amdahl 定律的预期,受制于其中 ```c Allgather``` 操作无法完全并行化,在当前数据规模下进程数达到 $8$ 时加速效果已经接近上限了。
== 工作量与进程数成正比
本组测试结果如下(注意矩阵运算的总工作量为 $O((m n)^2)$,因此为了总工作量与进程数成正比, $n$ 并不是随着进程数线性增加的)
```bash
Size 1 * 1000, process 1
rank=0, start_row=0, nrows_local=1000
args: m = 1, n = 1000, size = 1
matrix size after padding: 1000 x 1000
Implementation mode: ComputeAfterCommunication
Finish 100 compuation, per time cost: 917 us
rank 0 check passed
Size 2 * 707, process 2
rank=0, start_row=0, nrows_local=707
args: m = 2, n = 707, size = 2
matrix size after padding: 1414 x 1414
Implementation mode: ComputeAfterCommunication
rank=1, start_row=707, nrows_local=707
Finish 100 compuation, per time cost: 879 us
Size 4 * 500, process 4
rank=1, start_row=500, nrows_local=500
rank=0, start_row=0, nrows_local=500
args: m = 4, n = 500, size = 4
rank=2, start_row=1000, nrows_local=500
rank=3, start_row=1500, nrows_local=500
matrix size after padding: 2000 x 2000
Implementation mode: ComputeAfterCommunication
Finish 100 compuation, per time cost: 1033 us
Size 8 * 354, process 8
rank=0, start_row=0, nrows_local=354
args: m = 8, n = 354, size = 8
matrix size after padding: 2832 x 2832
Implementation mode: ComputeAfterCommunication
rank=3, start_row=1062, nrows_local=354
rank=4, start_row=1416, nrows_local=354
rank=6, start_row=2124, nrows_local=354
rank=1, start_row=354, nrows_local=354
rank=5, start_row=1770, nrows_local=354
rank=2, start_row=708, nrows_local=354
rank=7, start_row=2478, nrows_local=354
Finish 100 compuation, per time cost: 1046 us
Size 16 * 250, process 16
rank=0, start_row=0, nrows_local=250
args: m = 16, n = 250, size = 16
matrix size after padding: 4000 x 4000
Implementation mode: ComputeAfterCommunication
rank=8, start_row=2000, nrows_local=250
rank=10, start_row=2500, nrows_local=250
rank=11, start_row=2750, nrows_local=250
rank=2, start_row=500, nrows_local=250
rank=3, start_row=750, nrows_local=250
rank=5, start_row=1250, nrows_local=250
rank=6, start_row=1500, nrows_local=250
rank=9, start_row=2250, nrows_local=250
rank=12, start_row=3000, nrows_local=250
rank=14, start_row=3500, nrows_local=250
rank=1, start_row=250, nrows_local=250
rank=4, start_row=1000, nrows_local=250
rank=7, start_row=1750, nrows_local=250
rank=13, start_row=3250, nrows_local=250
rank=15, start_row=3750, nrows_local=250
Finish 100 compuation, per time cost: 1291 us
```
可以看出当规模增加,进程数增加时,尽管加速比并未达到线性,但也非常接近线性,这符合 Gustafson 定律的预期。 |
|
https://github.com/Chwiggy/thesis_bachelor | https://raw.githubusercontent.com/Chwiggy/thesis_bachelor/main/src/thesis_temp.typ | typst | #let project(
title: "",
subtitle: "",
authors: (),
date: none,
logo: none,
bib: "",
body,
) = {
// set the document's basic properties
set document(author: authors.map(a => a.name), title: title)
let ht-first = state("page-first-section", [])
let ht-last = state("page-last-section", [])
set page(
paper: "a4",
margin: (left: 30mm, right: 25mm, top: 30mm, bottom: 30mm),
numbering: none,
number-align: center,
)
set text(font: "Crimson Text", lang: "en", size: 12pt)
set math.equation(numbering: "(1)")
set figure(placement: auto)
// paragraph spacing
show par: set block(above: 1.2em, below: 1.2em)
// caption rules
show figure: it => [
#block(it.body)
#set text (style: "italic", weight: "bold", size: 10pt)
#pad(
bottom: 0.75em,
left: 2em,
right: 2em,
block(it.caption))
]
set heading(numbering: "1.1")
show par: set block(spacing: 1em)
set par(leading: 1em)
// title page
v(0.6fr)
if logo != none {
align(right, image(logo, width: 26%))
}
v(9.6fr)
text(1.1em, date)
v(1.2em, weak: true)
text(2em, weight: 700, title)
v(1.5em, weak: true)
text(1.2em,weight: 600, subtitle)
//author info
pad(
top: 0.7em,
right: 20%,
grid(
columns: (1fr,) * calc.min(3, authors.len()),
gutter: 1em,
..authors.map(author => align(start)[
*#author.name* \
#author.matr \
#author.email \
#author.affiliation \
#author.betreuer
]),
),
)
v(2.4fr)
pagebreak()
set page(numbering: "i")
counter(page).update(1)
box(
[
#set text(lang: "de")
#set par(justify: true)
#set heading(numbering: none)
= Eidesstattliche Erklärung
Hiermit versichere ich, dass ich die vorliegende Arbeit selbstständig verfasst und keine anderen als die angegebenen Quellen und Hilfsmittel benutzt habe. Alle Ausführungen, die anderen veröffentlichten oder nicht veröffentlichten Schriften wörtlich oder sinngemäß entnommen wurden, habe ich kenntlich gemacht.
Die Arbeit hat in gleicher oder ähnlicher Fassung noch keiner anderen Prüfungsbehörde vorgelegen.
#box(height: 3em)
#grid(columns: 2, gutter: 5em,
box(
[
#line(length: 100%)
Ort, Datum
]
),
box(
[
#line(length: 100%)
Unterschrift
]
)
)
#box(height: 3em)
]
)
box(
[
#set text(lang: "en")
#set par(justify: true)
#set heading(numbering: none)
= Statutory Declaration
I declare that I have authored this thesis independently, that I have not used other than the declared sources / resources and that I have explicitly marked all material which has been quoted either literally or by content from the used sources.
This paper was not previously presented to another examination board and has not been published.
#box(height: 3em)
#grid(columns: 2, gutter: 5em,
box(
[
#line(length: 100%)
Date
]
),
box(
[
#line(length: 100%)
Signature
]
)
)
]
)
pagebreak()
// abstracts
heading([Abstracts], level: 1, numbering: none)
heading([English], level: 2, numbering: none, outlined: false)
set par(justify: true)
include "abstract_en.typ"
heading([German], level: 2, numbering: none, outlined: false)
set text(lang: "de")
include "abstract_de.typ"
set text(lang: "en")
pagebreak()
// table of contents
outline(depth: 3, indent: true)
pagebreak()
// body
set page(
numbering: "1",
header: align(
right,
[
#locate(
loc => [
// find first heading of level 1 on current page
#let first-heading = query(heading.where(level: 1), loc).find(h => h.location().page() == loc.page())
#let last-heading = query(heading.where(level: 1), loc).rev().find(h => h.location().page() == loc.page())
#{
if not first-heading == none {
ht-first.update([
// change style here if update needed section per section
(#counter(heading).at(first-heading.location()).at(0)) #first-heading.body
])
ht-last.update([
// change style here if update needed section per section
(#counter(heading).at(last-heading.location()).at(0)) #last-heading.body
])
// if one or more headings on the page, use first heading
// change style here if update needed page per page
[#ht-first.display()]
} else {
// no headings on the page, use last heading from variable
// change style here if update needed page per page
[#ht-last.display()]
}}
]
)
]
)
)
counter(page).update(1)
set block(above: 2em)
set par(justify: true, first-line-indent: 1em, leading: 1em)
body
}
|
|
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/038%20-%20War%20of%20the%20Spark/004_Desperate%20Operatives.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"Desperate Operatives",
set_name: "War of the Spark",
story_date: datetime(day: 29, month: 05, year: 2019),
author: "<NAME>",
doc
)
#align(center)[#strong[I.]]
Finding a way to recruit the Azorius Senate—with its evil-dragon-collaborating guildmaster, Dovin Baan—and to contact House Dimir—with its mysterious shapeshifting guildmaster, Lazav—was assigned, I suppose, to other volunteers.
But Master Zarek and <NAME> tasked Mistress Kaya with bringing the other four wayward guilds—the Golgari Swarm, the Cult of Rakdos, the Gruul Clans, and the Selesnya Conclave—to the table for Operation Desperation.
#emph[Whatever that is] ~
They claimed that as an outsider, she'd bring less baggage (and suspicion) to the endeavor than Master Zarek himself would. But as a guildmaster, she'd still bring enough authority and prestige to command—or at least be granted—the necessary audiences with each guild.
I could see Mistress Kaya was reluctant, dubious of her chances of success. I leaned over and whispered for her to accept. "I can help you with Gruul, Selesnya and—" I was about to add Rakdos, but stopped myself. With Hekara gone, I no longer had an in with the Cult. I finished awkwardly: "Yeah, with Gruul and Selesnya."
Our first stop would be Selesnya, which Mistress Kaya hoped would be the easiest of the four. Teyo and I were with her, of course.
#emph[I say, "Of course." But it's strange that it feels so automatic. We became her loyal entourage in a matter of hours.]
And <NAME> came along with us, too, as Mister Beleren hoped she'd get on well with <NAME>, elven champion and acting guildmaster of Selesnya.
Unfortunately, getting an audience with <NAME> was proving difficult. For starters, we had to avoid the substantial quantity of creepies being led by a God-Creepy named Rhonas that was just minutes shy of overrunning the packed Senate House and taking out all of Bolas's significant opposition in one fell swoop.
But I do come in handy sometimes. Like I told Mistress Kaya, I know most of the secret routes through Ravnica and was able to lead our little quartet down passages, alleyways, and shortcuts that the invaders from Amonkhet couldn't know.
<NAME>, who generally said very little—#emph[or next to nothing, really] —seemed impressed enough with the speed of our progress to actually speak a few words. "You know the city well," she said to Mistress Kaya, who was right behind me. I think Mistress Kaya thought M<NAME> was talking to me, so she didn't bother responding. For my own reasons, neither did I.
We did run into a single—and unavoidable—crop of Eternals, searching for more victims, I suppose. Teyo put up a shield, and from behind it, <NAME> asked permission of an old birch tree, which promptly grew multiple branches that spiked through the brains of each and every lazotep skull before retracting. The attack was so swift that two or three seconds passed before the creepies began dropping to the ground, well and truly dead.
We found the Conclave well and truly fortified. And unwelcoming. A long line of Ledev guardians and sagittar archers blocked our path. No one would let us pass, even on our diplomatic mission. Miss Revane, in particular, seemed to be public enemy number one for having awakened Vitu-Ghazi, resulting in the World-Tree's departure, dismemberment, and near-complete destruction.
#emph[So ] that's #emph[how Vitu-Ghazi got to Tenth District Plaza! Miss Revane's more impressive than she looks. And she looks pretty impressive to me already.]
I figured I'd better start doing something impressive—or at least semi-impressive—if I was going to live up to my earlier boasting. I skirted the Ledev line and then scurried inside between two unwary guardians. I didn't have to scurry too far.
He was already on his way out: my godfather, Keeper of my Life Pledge, the Selesnyan spearmaster Boruvo. The centaur had been Gruul once—and my parents' best friend—but he'd found a calling with Selesnya and had switched guilds about ten years ago. This created a hopefully-not-permanent rift with my folks, but for me, it was a boon. Spearmaster Boruvo was always trying to get me to commit to joining Selesnya. He made it very clear he didn't believe Gruul was the right fit for me. (Which also didn't do much for his relationship with my Ari and Gan Shokta.) I remained Gateless, but he and I grew very close. (Which #emph[specifically ] didn't do much for his relationship with my dad.) Now, needing his help, I called out, "Godfather!"
He turned, and his stern (normally Gruul-like) expression just lit up! "Goddaughter," he said. "You should not be out and about. These are dangerous times."
"I suppose I'm as safe as anyone. Safer than most."
"Yes, I suppose you are."
"I need a favor, Godfather."
"Anything, child."
"Come with me and greet the new Orzhov guildmaster, please."
He groaned.
"She's my friend, godfather."
He raised an eyebrow, intrigued. "Hmm. Climb up," he said.
"Really?"
He didn't answer but reached down and swung me up onto his back, like he used to do when I was a kid. I giggled gleefully like I was #emph[still] a kid. And he trotted out to the line.
I heard Teyo call out, "Where's Araithia?"
Miss Revane asked, "Who?"
Before it got messy, I called out, "Over here!"
Teyo and Mistress Kaya turned to see me riding on the centaur #emph[behind] the Ledev line. Mistress Kaya looked stunned. The Ledev guardians parted, bowing, to allow the centaur to pass.
I said, "Mistress Kaya, Teyo Verada~and M<NAME>, allow me to introduce you to my godfather, <NAME>."
The centaur bowed his head to Mistress Kaya and Teyo in turn, but seemed to make a point of #emph[not] bowing to the elf, who watched it all in silence, looking extremely uncomfortable the whole time.
I think I started babbling then: "Boruvo was <NAME> once, before joining Selesnya. He's a good friend of my parents. And they made him my godfather. I mean, he was the obvious choice, the only practical choice, when you think about it. I think my father's always been a little jealous of my relationship with Boruvo. Not that #emph[that's ] why Boruvo left the Clan. He had a calling, you see. He thinks I have one, too, and really wants me to leave the Gruul and join Selesnya. And sometimes that does feel like the right path for me. But I guess I'm pretty indecisive when it comes to—"
Spearmaster Boruvo cleared his throat and said, "Goddaughter."
"I'm rambling again, aren't I?"
"It's understandable. But I believe we have business to attend to." He turned to Mistress Kaya and Teyo, saying, "Anyone with the good taste to take notice of our Araithia deserves a chance to be heard."
Again, Miss Revane leaned in to whisper, "Who is this Araithia?"
#figure(image("004_Desperate Operatives/01.jpg", width: 100%), caption: [Nissa, Who Shakes the World | Art by: <NAME>], supplement: none, numbering: none)
I could see that Mistress Kaya was about to tell her that "Araithia" was me, the Rat. But I just grinned and shook my head, and Mistress Kaya turned to study Miss Revane. She was looking directly at me and yet looking right through me, as if I wasn't even there.
And then—#emph[boom] —it finally hit Mistress Kaya. It suddenly occurred to her that I was basically invisible to Miss Revane. I could practically see Mistress Kaya remembering back to all our recent interactions. (Plus, I could more or less read the gist of her thoughts.) She thought back to <NAME>'s reaction or #emph[non-] reaction to me—and the way everyone had combined my name and Teyo's name when Teyo had introduced us both. She was starting to figure out that I was kinda invisible to everyone except Teyo, Boruvo, and herself. Kinda invisible even to my own father.
I said, "It's not invisibility exactly. I'll explain later."
That was sort of another tip off. Now, Mistress Kaya was beginning to suspect I was a little bit psychic, which I am. Not that she was sure yet. She was used to mind-mages like <NAME> and his loudly shouted psychic commands and realistic psychic illusions, and I could tell she was wondering if the latter was what I was using now on Miss Revane.
#emph[Which of course I wasn't. I never would!]
"Send the elf away," Boruvo said, immediately commanding Mistress Kaya's full attention. He was glaring at Miss Revane with intense contempt. "Send her away, and I will escort the rest of you to speak with Emmara Tandris."
Mistress Kaya was about to protest. After all, Miss Revane was supposed to be our secret weapon to win Milady Emmara's favor.
But Miss Revane was already backing away, looking somewhat relieved. She said, "I've never been very good at talking. You two go with the centaur. I'll join Gideon."
Within seconds, she was gone.
I leaned forward and whispered, "That was very rude, Godfather."
"Child~"
"Very rude."
He grumbled out, "Well~I'm sorry."
"You're forgiven," I said with much satisfaction.
He grumbled something else unintelligible. But he also couldn't stop himself from smiling just a little.
#emph[I don't exactly hold that kind of power over a lot of folks, you know? So sure, maybe sometimes I abuse it just a little. Can you blame me?]
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#align(center)[#strong[II.]]
As we moved deeper into Selesnya, I watched Teyo's eyes get progressively wider and wider. I don't think he'd seen anything like this before on that desert world he came from. That Gobakhan. #emph[Everything] about Ravnica seemed to amaze him, which was adorable.
#emph[I think we take our worlds for granted sometimes—until we see them through someone else's eyes. Might be why I'm still Gateless. When I see Selesnya through my godfather's eyes, or Gruul through my mother's, or when I see—] saw#emph[—Rakdos through Hekara's eyes, it always seems—] seemed#emph[—new and rich and wondrous.]
Anyway, I was still riding on Spearmaster Boruvo's back as he led Mistress Kaya and Teyo to their audience with <NAME>. The corridors of almost-glowing marble were lined with archers and soldiers, all wearing armor decorated to look like leaves or blades of grass. Many were elves. All lowered their heads in slight bows to acknowledge their spearmaster. All of them eyed Mistress Kaya and Teyo with the slightest hint of a threat. None of them even glanced at me, of course. We passed through an arch guarded by two immense loxodons holding axes. Again, Teyo's eyes went wide.
#emph[No loxodons on Gobakhan, I guess.]
The loxodons also nodded to their spearmaster, glared at Mistress Kaya and Teyo, and took no notice of the Rat.
I could tell that light was just beginning to dawn for Teyo when Mistress Kaya spotted the look on his face and leaned over to whisper: "Only the centaur, you, and I can see Rat. Somehow, she's invisible to everyone else. Even her father."
It wasn't hard to read Teyo's feelings: #emph[It makes no sense, and yet it explains everything!]
He was staring at me now, so I grinned back at him and slipped off my godfather's back to slip in between my two new friends. I figured they deserved as much of an explanation as I could offer: "I'm not invisible. I'm #emph[insignificant] . A rat. A little rat. You see one, you look away. You try to pretend you didn't notice it. You try to forget about it until you #emph[do ] forget about it. Your mind rejects its presence."
"You're not insignificant," Mistress Kaya protested.
"You're sweet to say so, Mistress Kaya, but I am."
"It's magic," Teyo said.
"I suppose," I replied with a shrug and a smile. Although maybe I wasn't quite pulling off the smile. "Magic I was born with. Not many people can see me unless they know I'm there and concentrate. My father's good at that, but he has to know I'm around to manage it. Before today, there were only three people who consistently have been able to notice me on their own: my mother, Boruvo, and Hekara."
Mistress Kaya nodded. "That's why you were so upset when I told you Hekara was dead."
I shook my head emphatically. "No. Well, maybe that was part of it. But mostly I was upset because Hekara was wicked cool and wonderful. But yeah, I guess it hurts to know there's one less person who'll take notice. Of course, then I found the two of you."
They each took one of my hands and gave me reassuring squeezes.
At which point we all turned a corner and came face-to-face with <NAME>, standing before the dryad Trostani, the dormant Selesnya guildmaster with her three symbiotic identities growing from a single trunk. Her central figure, Mistress Cim, was asleep. The other two faced away from each other. On the left, Mistress Oba was crying hot tears. On the right, Mistress Ses crossed her arms angrily.
Spearmaster Boruvo bowed low, which was always an interesting sight to behold in a centaur. He said, "<NAME>, you know Guildmaster Kaya of the Orzhov Syndicate. With her are her associate <NAME> and my goddaughter, <NAME>, still Gateless."
<NAME> was squinting, scanning the room for me. She said, "Araithia is here?"
I waved, grinning. "Here, milady!"
Milady Emmara blinked twice and said, "One more time, please."
"I'm here, right between Teyo and Mistress Kaya."
Boruvo offered some help, too. "She's between the other two, milady."
"Ah, yes," <NAME>ara said, suddenly beaming with pleasure. "Oh, child, I wish this wasn't so difficult. It's such a joy to see your face and hear your voice."
"Only because each time is like the first. Trust me, Milady, if you saw me every day, you'd grow quite tired of both."
"I sincerely doubt that."
I shrugged again. "I could prove it with five minutes of conversation, Milady—but that's not why we're here."
Sighing heavily, she grew serious and turned her eyes on Mistress Kaya. "I know why you are here."
"Emmara, please," Kaya said. "We need to unite the guilds. Ral has a plan passed down by Niv to save Ravnica, but it won't work without all ten guilds cooperating."
"And it may not work even #emph[if] all ten guilds cooperate, correct?"
Mistress Kaya didn't respond, but her silence spoke volumes.
"Guildmaster Kaya, we both know <NAME> and Niv-Mizzet loved their plans, their strategies, their blueprints. So far, every one has been an unmitigated disaster for the guilds, for Ravnica, and especially for Selesnya."
"But this time—"
"The Izzet always have names for their projects. Nothing is real to them unless they name it, define it, give it limits. Which is why we have so little in common. What is Ral calling this one?"
Mistress Kaya hesitated, looking almost embarrassed. But then she straightened her back and said in a clear voice: "Operation Desperation."
<NAME> almost chuckled. She certainly smiled as she shook her head, the way my mother used to shake her head at me when I was being particularly silly.
#figure(image("004_Desperate Operatives/02.jpg", width: 100%), caption: [Emmara, Soul of the Accord | Art by: <NAME>], supplement: none, numbering: none)
But Mistress Kaya seemed ready for that. "I know what it sounds like, but desperate times do call for desperate measures. The Planeswalkers and the guilds must unite to defeat Bolas."
"I don't disagree, Kaya."
"Well, then—"
<NAME> interrupted her again. I was accustomed to this. She had a way of interrupting that didn't seem rude. She seemed to glide in, her voice growing up between Mistress Kaya's words the way blades of grass grew up between paving stones. She said, "I'm sorry, but there's little support for anything resembling unification within Selesnya. Things were bad enough before the loss of Vitu-Ghazi. But now~"
As she trailed off, I was already on the move, skittering up to my godfather. He leaned down for me, and I whispered into his ear.
Straightening, the spearmaster cleared his throat and said, "Milady, it was Bolas's creatures that devastated Vitu-Ghazi."
"Yes," Mistress Kaya said, "exactly. And this wouldn't be the first world where Bolas has wreaked havoc. Two Planeswalkers—<NAME> from Skalla, and Samut from Amonkhet—report that both their worlds were absolutely devastated by Bolas. Skalla is completely dead. And Amonkhet's few survivors are struggling to, well, #emph[survive] , while Bolas's monsters continue to ravage what's left of their home. In fact, I suspect the troubles on #emph[my world] may be Bolas's handiwork, as well. Make no mistake, Emmara. The dragon is turning all of Ravnica—if not the entire Multiverse—into a grave."
Suddenly, Mistress Cim awoke, keening.
Her sister forms turned toward her, as did <NAME> with a gasp and Boruvo with a low bow.
Teyo was looking pretty confused, so I slid up next to him to explain: "She is the dryad Trostani, the true guildmaster of Selesnya, the voices of its parun~um, you know, its founder, Mat'Selesnya. Mistress Cim, in the middle, is the dryad of Harmony. She has been asleep and unresponsive for months. Now she's awake."
"Yeah," Teyo said without a hint of sarcasm, "I got that last bit."
"The dryad on the left is Mistress Oba, the dryad of Life. On the right is Mistress Ses, the dryad of Order. Without Mistress Cim, they have been at odds, split and unable to reach a decision for their guild. <NAME> has been trying to keep Selesnya together during Trostani's~um, absence?"
The keening of Mistress Cim got louder, peaked, and fell away. Everyone waited with bated breath. Finally, she spoke—or it was almost like speaking—her words swirling through our minds, like a breeze playing through the leaves of a tree.
#emph[I have heard the song that plays in the wind, sisters.] The dryad of Harmony turned to the dryad of Order: #emph[Ses, Bolas's Order is the Order of the Grave. You have fought with your sister, but she is ] still #emph[your sister. Is it truly your wish to see her ended? To see all ] Life#emph[ ended?]
With that encouragement, Mistress Oba appealed to Mistress Ses, as well. #emph[There is a great Order to Life. Is that not enough?]
Mistress Ses was silent for a time. She looked away from her sisters. She looked up at the sky. She looked every which way but pleased.
But ultimately, Mistress Ses acquiesced with a nod: #emph[Trostani is once again in Harmony. It is the will of Mat'Selesnya that the Conclave join the other guilds to defeat <NAME>.]
So. One down. Three to go.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#align(center)[#strong[III.]]
"Something's changed," Teyo said.
"Yes," said Mistress Kaya, "I feel it, too. Ral must have succeeded in shutting down the Beacon."
"Planeswalkers can still come?" I asked.
"Yes, but they won't be drawn here. There's no summons to answer anymore."
"And that's a good thing?"
"I think so. We're enough to defeat the dragon. Or enough to die trying, at any rate."
I punched Mistress Kaya on the shoulder, saying, "Well aren't you a ray of sunshine?"
#emph[I don't know what I was thinking! You don't punch a guildmaster!!]
"Ow."
Mortally embarrassed, I scurried ahead, calling out, "This way."
She shushed me.
I don't know what was getting into me, but I actually stopped and rolled my eyes at her. "No one else hears me. No one else wants to. Besides, we've almost reached Skarrg. Now, when we get there, you guys should let me do the talking."
"I thought they can't hear you," Teyo said. Then he looked stricken, afraid he'd hurt my feelings.
#emph[He's so sweet!]
Anyway, just the fact that I have people to talk to about my situation makes it easier. Makes me kinda giddy, I think, what with all the punching and eye rolling and such. I said, "Most can't. But my mother, <NAME>, can. And my father can if he's paying attention. Same with Borborygmos. He thinks I'm adorable, which I am. I'm an adorable Rat!" I laughed, and the sound echoed off the curving walls of the tunnel. I #emph[was] giddy. I mean, look, I'm used to me. I have to be used to me 'cuz nearly every hour of every day I'm all I've got, you know? But the fact that Teyo and Mistress Kaya could hear me laugh and hear it echo was a magic all its own. I don't think I'd ever spent this much time with anyone who could see me since I was a very little girl with my mother. Even Hekara never spent an entire day with me like this.
Teyo was staring at me. I think I must have blushed a little, 'cuz he blushed, probably embarrassed for me, I guess.
I tried to pretend he hadn't caught me and continued on. We were moving through sewer tunnels like, well, #emph[like Rats! Hah!] It was dark and humid and close. Teyo, the desert baby, was dripping with sweat. I felt bad for him. Finally, we came to the end of the long brick tunnel. I approached the iron door and knelt before it to quickly pick the lock.
Quick enough to impress Mistress Kaya, who said, "You #emph[are ] good at that. Better than I am, and I'm something of an expert."
I actually rolled my eyes #emph[again!]
#emph[What is wrong with me?!]
"Please," I said—with way too much attitude. "I learned to do that when I was six. When no one knows you exist, they don't unlock #emph[anything] for you." I swung the door open and instantly heard the familiar, familial sounds of angry voices and weapons clashing.
I scurried up yet another tunnel, and Teyo and Mistress Kaya struggled to keep up.
This final tunnel soon opened up onto Skarrg, the Reunion Turf, an immense underground playground, the cratered remains of a massive ancient palace. Immediately, I sized up the situation and knew I'd need help. Gan Shokta was fighting with the cyclops Borborygmos, with thirty or forty other Gruul warriors gathering to watch. Multiple axes came flying toward our heads. One sailed just above my scalp.
#emph[Good thing I'm short. I don't even need to duck.]
Teyo instinctively raised a triangular shield, and another axe ricocheted off it. Mistress Kaya went incorporeal, and a third axe sailed right through her, sticking a good two inches deep into the wall behind. Seeing that my new friends could take care of themselves for at least a little while, I took off for home.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#align(center)[#strong[IV.]]
"Ari!" I yelled.
"Please, Araithia, no need to shout!"
"I thought Gruul warriors were supposed to shout!"
"In battle. Not at their mothers," she said and cuffed me hard. Then she pulled me in and hugged me tight. My mother has a real bear of a bear hug, but I love it. "You stay away too long, girl. I miss you, believe it or not."
"Not!" I barked out and laughed.
She cuffed me again.
"We have to go," I said. "<NAME> and Borborygmos are killing each other."
She faked a yawn. "Again?"
"Yes, but today, I need them to listen to my new friends."
"You have new friends, child?" she said with some giddy hope of her own.
"I—Yes. Two. But Ari~Hekara's dead."
"I know, Araithia. I heard. I'm so very sorry. She could kill with the best of them. And she was a good friend to you. A worthy friend."
We said nothing for a bit.
Then I grabbed her hand and pulled her after me. "C'mon, mother!"
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#align(center)[#strong[V.]]
I could hear my father's angry bark echoing through the tunnels as we approached Skarrg: "Borborygmos is half inclined to kill you right here and now, Ghost-Assassin. He holds you and the storm mage responsible for his fall."
"I understand," Mistress Kaya was saying carefully. And then more pointedly: "On the other hand, Teyo and I helped save your life. And besides, we're friends of your—"
Before Mistress Kaya could even mention my name, <NAME> barked out: "I need no reminders of my~#emph[momentary failing] . I owe you. I acknowledge that. But don't think for a moment I'm any happier to see you than the cyclops. Believe me, you couldn't have come at a worse time."
"We don't want to be here any more than you want us here. But there's no choice, <NAME>. There's no choice, Borborygmos. We need the Gruul to—"
By that time, we were in the chamber, and Ari called out to my father with a mixture of elation and urgency: "She's here, Gan!"
<NAME> turned: "#emph[Here? Where?] "
Ari stepped forward with her arms wrapped around me. My mom's considerably taller and considerably more muscular than I am. So her presence generally overwhelms mine, bear hug or no bear hug. She was also armed to the teeth, with a sword and an axe, two long daggers, and an iron chain around her waist like a belt, digging into my spine. But we have the same dark hair, and I'm told the same smile. She responded to my dad by saying, "Right here!"
All eyes around the bonfire turned toward <NAME>ta.
<NAME> squinted. He said, "Call out, girl!"
"I'm here, Father," I said.
"She's here in my arms, Gan," his wife said.
Then <NAME> smiled: "I see her."
Borborygmos grunted his own acknowledgement, and a few others in the crowd nodded too, though most were only pretending to see me to impress their betters.
#figure(image("004_Desperate Operatives/03.jpg", width: 100%), caption: [Borborygmos Enraged | Art by: <NAME>], supplement: none, numbering: none)
I addressed my father and the cyclops with all the formality the occasion required: "Great Borborygmos. Legendary Gan Shokta. You must unite the Clans and help the other guilds. Or it will be the end of us all."
Gan Shokta growled his response, pointing at Borborygmos: "That's what I've been telling him. But the stubborn fool won't listen."
Borborygmos lurched toward me and held out his huge hand. I slipped out of my mother's arms and into his grip, which closed around me, practically eclipsing me.
I saw Teyo take an involuntary step forward, unnecessarily protective.
#emph[Is it strange that makes me happy? I mean I don't ] need #emph[protection. Not from Borborygmos anyway. Really, not from much of anything. Still] ~
Mistress Kaya put a hand on Teyo's shoulder and whispered something to stop him.
The cyclops lifted me up so that I could whisper right into his huge (kinda waxy) ear. I said, "This is really important. The Gruul—all of Ravnica—depend on you."
He shook his head violently.
I cupped my hands and whispered again. Then I kissed his cheek.
He blushed a bit, and I knew I had the old softy~
Two down. Two to go.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#align(center)[#strong[VI.]]
"Please," <NAME> said. "Enough." He had caught up to the three of us, and we had all entered Korozda together. "I've just spent a full sixty-six minutes draining the Beacon. I'm tired, and I don't have patience for your games. Or your imaginary friend."
"It's not a game," Mistress Kaya retorted. "Rat's not imaginary, and by the way, open your bloody mind, Ral. You'd think you'd never encountered an invisibility spell before."
"Well, if she's using an invisibility spell, tell her to stop using it."
"It's not that simple with her. It's~innate. She can't turn it on and off."
I said, "It probably won't work, but~point his head at exactly where I'm standing." I was watching <NAME>, as Teyo and Mistress Kaya listened to me. He #emph[still ] thought they were teasing him, I guess, and he rolled his eyes at their pathetic "prank."
"Worth a try," Mistress Kaya said, then without warning she ghosted right through him, which I suppose felt mighty disconcerting.
"Damnit, Kaya, what the Krokt are you—"
From behind, Mistress Kaya literally grabbed his face in both of her once-again-solidified hands and aimed it at, well~me.
I waved and said, "Hi."
His mouth gaped open, and his mind said something along the lines of #emph[Where did she come from?]
"I came from the Gruul Clans, initially. But I'm Gateless, in case you were wondering. My name's <NAME>, but you can call me Rat. Everyone does. Well, not everyone. Not my parents or my godfather, but everyone else who knows about me. Hekara called me Rat. I miss her. I bet you miss her, too. I know you pretended not to care about her, but I also know you valued her friendship. She was #emph[such] a loyal friend, right? And so funny. She made me laugh and laugh and laugh. Not many people do that with me. Not on purpose, anyway."
He had to focus to see and hear me, which meant he could lose sight of me any second, which might explain why I was running on the way I was.
#emph[Except we know better, don't we?]
"Don't be offended. Hekara asked, and I'd have done anything for her. Absolutely anything. She knew you wouldn't notice me. I mean, I think initially she hoped you would, but it was pretty clear pretty quick that you didn't. And <NAME> had told her to stick with you, and you kept ditching her. So she #emph[had ] to ask for my help, really. That's kind of your fault. So I tracked you, pretty much everywhere you went."
I looked past him to Mistress Kaya and said, "That's why I'm surprised #emph[you ] didn't notice me."
She let go of <NAME>k and crossed over to me, saying, "The first time I saw you today, I thought you seemed vaguely familiar, like I had seen you around town. But I'm a stranger here, so I see a lot of locals that don't fully register, as long as they're not a threat."
"And there was no way you could know you weren't #emph[supposed] to be able to see me, so you never mentioned it. Or even said hello!"
"Yeah, well, I am sorry about that."
"Yeah, well, I do forgive you," I said, mimicking her cadence rather sassily and taking her hands.
Trying to catch up, Master Zarek interjected: "So you've been following me since I met Hekara?"
"On and off. She didn't need my services when #emph[she ] was with you. But I did try to stay in the vicinity, so I could pick up your trail and report back if and when you sent her packing."
Mistress Kaya smirked a bit, as Master Zarek ran through #emph[all ] the implications of what I was telling him. That caused him to lose focus and lose sight of me again.
Teyo noticed his confusion and offered, "She's still right beside Kaya."
Master Zarek focused—and there I was again! He said, "I guess I'm sorry I couldn't see you."
"I'm used to it. And really, I'm kinda impressed at what you're doing now. My mother says it took my father three months after I was born to master focusing on me. You've picked it up pretty much instantaneously. You're more open to new things than you think you are."
"I think I'm #emph[very] open to new things."
"No, you don't. You want to be. But you don't believe you are. But you are. Isn't that strange?"
Master Zarek seemed to notice then that his mouth was hanging open, so he closed it.
Mistress Kaya was #emph[still ] smirking as she said, "There's no time to dwell. We need to get a move on."
She led the three of us deeper into Korozda, the Maze of Decay, which meant by definition that we were walking in circles. Concentric circles leading deeper and deeper into Golgari Swarm territory. I let the two guildmasters lead, though I was ready to correct their path if they took a wrong turn. I'd been down to explore its decaying fungal hedgerows many, many times and had long ago solved its puzzle.
We—or rather the three of them, as no one noticed me, of course—had already been admitted into Korozda by passing beneath the fortress of Pevnar, the Hanging Keep, an upside-down castle with foundations fixed to the ceiling. Master Zarek had been prepared for opposition from the Krunstraz that garrisoned the keep. But the insect-like kraul warriors simply watched us (or, you know, the three of them) enter the maze.
#figure(image("004_Desperate Operatives/04.jpg", width: 100%), caption: [Kraul Harpooner | Art by: <NAME>], supplement: none, numbering: none)
Now, as we approached the center, it was clear that not only had we met no opposition, we had met no one #emph[at all.] Which meant we (they) were expected. Or perhaps that we (they) were walking into a trap. Or, you know, maybe both.
We all scanned back and forth for signs of an ambush. I watched <NAME> check the Accumulator he wore on his back. I leaned in and looked at the gauge. It was a few degrees past maximum capacity. Draining the Beacon must have meant sucking in a #emph[lot ] of juice.
He sped up, passing Kaya to enter the great circular amphitheater, with its many rows of stone seats, all covered by a soft downy moss.
Vraska's Erstwhile lich, an undead Golgari sorceress, was waiting to welcome us (them): "Greetings, Guildmaster Zarek. Greetings, Guildmaster Kaya. The Golgari Swarm welcomes you to Svogthos." Her voice sounded like dead leaves being blown across a grave.
I could tell <NAME> couldn't remember the lich's name, so I slid up to him and whispered, "Storrev."
He smiled a thin smile, and I distinctly heard him think, #emph[Thank you, Rat.]
"Don't mention it."
With some formality, he said, "We appreciate the greeting, Storrev." The Erstwhile looked mildly surprised and maybe a little flattered that <NAME>k knew her by name. And again, he gave off the clear thought—and this time, maybe a little less begrudgingly—#emph[Thank you, Rat.]
I giggled a little.
"This is a time of crisis," Mistress Kaya said. "We've come to meet with Mazirek." Mister Mazirek, leader of the kraul, had been Mistress Vraska's right-hand bug—and the most likely candidate to have replaced her as Golgari guildmaster.
<NAME> sighed, nodded, and said, "Follow me."
We crossed the amphitheater and followed the lich into Svogthos, the subterranean guildhall of the Golgari. Once a grand Orzhov cathedral, arched and magnificent, it had fallen through a sinkhole some centuries ago. The Orzhov abandoned it. The Golgari claimed its ruin as their own.
Madame Storrev led us into a cavernous chamber, known as the Statuary. A raised stone causeway ran through its center, with statues lining either side. Except the statues weren't truly statues. They were victims. Mistress Vraska's victims. Like Mistress Isperia, each was frozen in stone. But unlike Isperia, whose final expression was one of mild surprise, each of these trophies had been captured in a last look of terror, hands thrown up too late to protect them from the gorgon's deadly mystic stare.
A number of folks were gathered at the far end of the causeway around Mistress Vraska's—or I suppose I should say, Queen Vraska's—massive stone throne. It was interesting that none of these Golgari were actually seated on the throne. Was it because no one had yet taken Queen Vraska's place as guildmaster? Or was it because the throne was kinda scary, consisting as it did entirely of more of the queen's dead enemies, intertwined and posed before being permanently petrified in place.
As we got closer, I could see that Mister Mazirek was not among the gathered Golgari big shots.
Madame Storrev made a slight bow, and Master Zarek, Mistress Kaya, and Teyo (but not me, of course) were introduced to the kraul Krunstraz warrior Azdomas, the devkarin leader <NAME>, the troll Varolz, and the elf shaman Cevraya.
"Mazirek?" Master Zarek asked.
Mister Azdomas made a series of clicking noises in his throat before speaking. There was a dark anger in the clicking #emph[and] in his voice: "Mazirek was another Bolas collaborator, revealed by Queen Vraska before her departure."
"#emph[Vraska] revealed him?"
"Yes," said Madame Storrev, in her voice of leaves, "Vraska freed the Erstwhile and gave us our tormentor Mazirek."
"He has paid the ultimate price for betraying the Swarm," <NAME> added with finality.
Mistress Kaya glanced from <NAME>as to Madame Storrev to <NAME> to <NAME> and then up to meet the eyes of the huge fungal-hided troll, <NAME>. The ghost-assassin seemed to be taking each one's measure—and gauging just what it would take to bring each one down if necessary. "If I might ask~who is your new guildmaster? That is who we've come to address."
They all exchanged dangerous glances that revealed the answer even before Madame Storrev said, "Each of these individuals—myself excepted—has a claim to Vraska's throne."
"Vraska comes to claim Vraska's throne."
We all turned in time to see a figure emerging, fading up—planeswalking in, I guess—out of a silhouette.
It was Queen Vraska, herself.
As she came into focus, <NAME> remembered to throw a hand up before his own eyes. Mistress Kaya did the same. I pushed Teyo's hand up, myself. I liked Queen Vraska, but I liked Teyo more—and I didn't want him decorating the Statuary.
With one hand still raised, Master Zarek activated his Accumulator. Mistress Kaya drew one of her long knives. Both were as ready as they were going to get to face the gorgon who'd betrayed them.
Queen Vraska ignored them both and, addressing the Golgari, said, "Does anyone challenge my right to that throne?"
<NAME>, <NAME>, <NAME>, and <NAME> all bowed immediately, saying in unison, "No, my queen." <NAME> didn't look overly pleased, but she bowed and uttered the same assurance, only half a second later than the other Golgari folk.
<NAME> risked a glance at Queen Vraska and saw what I saw. Her eyes weren't glowing, which meant she hadn't summoned the magic to turn anyone to stone. It was a small relief, but we both knew she could summon that power rapidly. And she had other skills, other weapons, as well. For example, the cutlass hanging from her belt.
"You look ridiculous," <NAME>k said to her, trying to replace a certain tone of bitterness with something approximating contempt. "What are you supposed to be, a pirate?"
#emph[Wow, a pirate queen! That actually sounded pretty keen!]
She continued to ignore him, moving right past him to take a seat on her horror show of a throne.
"I'm surprised you returned to Ravnica," Mistress Kaya said evenly, "Shocked, really~"
"Appalled," Master Zarek corrected.
"Especially #emph[after ] the Beacon was turned off?" Queen Vraska asked, as if trying to get a rise out of her former friends, her former allies.
Master Zarek was charged up and ready for a fight. Static crackled through his spiky hair. "So which was it?" he growled. "Did you assume Bolas had already been #emph[defeated] —or that he had already #emph[triumphed] ?"
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#align(center)[#strong[VII.]]
Queen Vraska led us through the Golgari tunnels, clearly aware that her two former friends, <NAME> and Mistress Kaya, were right behind her, one charged and ready to fry her, the other drawn and ready to skewer her.
Master Zarek practically hissed at the Golgari queen's back: "Turn to look at me, and I won't hesitate."
It seemed like a fairly intolerable situation, so I skittered up to Mistress Kaya and whispered, "Hekara really liked Mistress Vraska deep down, you know? Maybe we should give her the benefit of the doubt? I mean, why do #emph[you] think she came back?"
Missing the point a little, Mistress Kaya said, "I don't know. I'll ask."
"Ask what?" Queen Vraska growled over her shoulder.
"My friend Rat wants to know why you came back. She's inclined to trust you because Hekara considered you a friend. Then again, I was inclined to trust you once, too~"
Phrasing it like that wasn't likely to give us any useful answers, and sure enough, Queen Vraska ignored the question and the judgments. Or at least she tried to. I scurried forward to read her face—and maybe get a general sense of her thoughts. She was definitely conflicted, but I felt certain she was determined to help~help us, help Ravnica, and certainly help the Golgari.
After her arrival, <NAME> had quickly updated her on Ravnica's current situation. I could tell then that she had neither advance knowledge of the crisis—nor much to be surprised about. Oh, except the part about <NAME> having lost the powers of the Living Guildpact. #emph[That] seemed to catch her quite off guard and revealed, to me at least, that his complicated feelings for her were reciprocated.
Mister Azdomas also reported that Golgari, Gateless, and other guilded civilians were trapped in various pockets of the city, at the mercy of the dragon's Eternals.
Queen Vraska had made an offer to help, which Master Zarek had instantly rejected. Mistress Kaya had started to reject it, too. But I kinda interjected, saying, "We need the Golgari; she rules the Golgari, so we don't have a lot of options."
"We can't trust her."
"And yet we #emph[still ] need her."
"You weren't there. You don't know. If she hadn't—"
"I know. I do know. Believe me, I know."
"Then how can I—"
"You test it, I guess. Give her the chance to prove she can be trusted. Or prove that she can't."
Then Mistress Kaya sighed heavily and turned to Queen Vraska to accept her help. And when <NAME> objected again, Kaya forced him to begrudgingly accept, as well.
So now those three guildmasters, along with me, Teyo, <NAME>, and <NAME>, were trudging through the subterranean waterways and sewers of Ravnica on a rescue mission.
Queen Vraska stopped beneath a massive iron grate. She gestured with one hand, careful not to look backward, since even her most harmless glance might trigger a preemptive strike from Master Zarek.
<NAME> approached and pulled off the grate. The scraping of iron against stone echoed through the tunnels.
A voice from above roared, "Who's there?"
Master Zarek, briefly forgetting his mistrust of the queen, stepped forward, saying, "Is that Goldmane?" in a fairly loud whisper.
Sure enough, <NAME> stuck his head down into view. "Zarek?" The leonine immediately spotted the Izzet guildmaster and spoke with some urgency: "I've been leading some of the other Planeswalkers to help evacuate civilians. But the Eternals got the drop on us. Six or seven crops. We've been pinned down inside this old chapel for over an hour. The building's completely surrounded. They're attracted to our Sparks and won't leave. We've kept the Dreadhorde at bay, but it's a losing battle. Khazi was harvested when an Eternal punched its hand right through the wall and grabbed her by the wrist."
Queen Vraska came up alongside Master Zarek and said, "This is the way out."
<NAME> squinted at her with his one good eye and said, "You must be Vraska. Jace was hoping you'd show up. He believes in you."
Queen Vraska frowned but said, "Bring everyone down. The Golgari will keep them safe. You have my word."
#figure(image("004_Desperate Operatives/05.jpg", width: 100%), caption: [Vraska, Swarm's Eminence | Art by: <NAME>], supplement: none, numbering: none)
Master Zarek scoffed loudly but managed to say nothing.
Without a sound, <NAME>'s face vanished from the opening. A minute passed. Then two. The queen and Master Zarek exchanged confused glances. I was just about to climb up and see if I could help, when <NAME> dropped down. He approached the gorgon without fear and said, "We haven't been introduced. I am <NAME> of the Gatewatch." He reached out his hand.
She grasped his thick furry forearm, and he grasped her smooth one. She said, "Welcome to Golgari territory, <NAME>. You are safe here."
He nodded, smiling. Then he turned back up toward the tunnel's ceiling and said, "Start lowering them."
One by one, Ravnicans—children, mostly—were lowered into the arms of <NAME>, of Mister Azdomas, of Mistress Kaya, of Teyo, and of Queen Vraska. I wanted to help, too, of course, but I could have stood there all day and no one would have handed a child to me. So I just tried to stay out of the way, you know?
A wary Master Zarek stood back, as well. Queen Vraska was handed a young elven girl—five or six years old—who buried herself in the gorgon's breast, heaving great sobs of fear and sorrow. The queen looked stricken. But she held the girl tight.
There was a noise from above. A voice yelled down, "They've breached the doors!"
The last of the Ravnicans descended, and they were followed by two of the Planeswalkers I had seen at the summit. <NAME> quickly introduced them as <NAME> and <NAME>. The latter called back up, "Mowu, come!"
A small dog leapt down into Mister Jiang's arms. This was a much smaller dog than I had seen at the Senate House.
#emph[Did they bring ] two #emph[dogs?]
Mister Jiang put the canine down on the tunnel floor, and it proceeded to grow, expanding into the three-tailed dog, as tall as its master, that I had seen before.
#emph[Krokt, I want a magic dog, too!]
<NAME> said, "Where's Huatli?"
"Here!" <NAME> called out as she dropped down. "I'm the last, but they're right behind me!" As if to prove her right, a lazotep-covered hand and arm reached down from above, sweeping the air and just missing Miss Huatli.
The hand vanished into the darkness above and was replaced by the heads of three Eternals. They started to climb down, delayed only because none of them waited for either of the other two.
That delay gave Queen Vraska the time she needed. She summoned her power—I watched it build up behind her eyes—which she kept focused on the ceiling to avoid triggering Master Zarek's wrath. The gorgon pulled the crying elf child closer to her bosom and covered the girl's eyes with one hand. Then as the three creepies filled the opening, Queen Vraska locked eyes with each of them in turn, transforming all three to stone. The sound of them calcifying was kinda satisfying, and the result was that she had not only stopped Miss Huatli's pursuers from attacking, but had also effectively sealed the hole and the Eternals' only way down from the chapel above.
<NAME> approached her queen and whispered in her ear. She listened and turned to <NAME>, who took a step back—but didn't try to electrocute her (which seemed like a good sign to me). Maybe it was because her eyes were no longer glowing, meaning she was no longer an immediate threat. Or maybe it was because she was still holding the small softly crying elf girl in her arms. Or maybe—just maybe—it was because she had begun to earn back a little of the lost trust they had once shared.
She said, "All across the city, the Golgari are opening up pathways to safety for every Ravnican they can find. We are fighting Bolas's army and preserving life." And then with some showy sarcasm, she added, "You're welcome."
<NAME> said nothing.
I thought, #emph[Three down. One to go.]
<NAME> said, "Good. Now, there's one more thing we need you to do~"
|
|
https://github.com/frectonz/the-pg-book | https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/115.%20segway.html.typ | typst | segway.html
The Trouble with the Segway
July 2009The Segway hasn't delivered on its initial promise, to put it mildly.
There are several reasons why, but one is that people don't want
to be seen riding them. Someone riding a Segway looks like a dork.My friend <NAME> built
his own Segway,
which we called
the Segwell. He also built a one-wheeled version,
the Eunicycle,
which looks exactly like a regular unicycle till you realize the
rider isn't pedaling. He has ridden them both to downtown Mountain
View to get coffee. When he rides the Eunicycle, people smile at
him. But when he rides the Segwell, they shout abuse from their
cars: "Too lazy to walk, ya fuckin homo?"Why do Segways provoke this reaction? The reason you look like a
dork riding a Segway is that you look smug. You don't seem to
be working hard enough.Someone riding a motorcycle isn't working any harder. But because
he's sitting astride it, he seems to be making an effort. When
you're riding a Segway you're just standing there. And someone who's
being whisked along while seeming to do no work — someone in a sedan
chair, for example — can't help but look smug.Try this thought experiment and it becomes clear: imagine something
that worked like the Segway, but that you rode with one foot in
front of the other, like a skateboard. That wouldn't seem nearly
as uncool.So there may be a way to capture more of the market Segway hoped
to reach: make a version that doesn't look so easy for the rider.
It would also be helpful if the styling was in the tradition of
skateboards or bicycles rather than medical devices.Curiously enough, what got Segway into this problem was that the
company was itself a kind of Segway. It was too easy for them;
they were too successful raising money. If they'd had to grow the
company gradually, by iterating through several versions they sold
to real users, they'd have learned pretty quickly that people looked
stupid riding them. Instead they had enough to work in secret. They
had focus groups aplenty, I'm sure, but they didn't have the people
yelling insults out of cars. So they never realized they were
zooming confidently down a blind alley.
|
|
https://github.com/pank-su/report_3 | https://raw.githubusercontent.com/pank-su/report_3/master/templates/utils.typ | typst | #let prilCount = counter("pril") // pril = приложение
#let alphabet = "а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я".split()
// center heading
#let ch(content) = {
show heading: it => {
text(it, size: 14pt)
}
align(heading(upper(content), numbering: none), center)
}
#let chn(content) = {
show heading: it => {
text(it, size: 14pt)
}
align(heading(content, numbering: none), center)
}
// false heading zero
#let cfh0(content) = {
show heading: it => {
text(it, size: 14pt)
}
align(heading(content, numbering:none, outlined: false,), center)
}
// false heading
#let fh(content) = {
show heading: it => {
text(it, size: 14pt)
}
heading(content, numbering: "1.1", outlined: false)
}
#let fhh(content) = {
show heading: it => {
text(it, size: 14pt)
}
heading(content, numbering: "1.1", outlined: false, level: 2)
}
// image path
#let ip(path) = {
return "images/" + path
}
// table fix
#let tf(content, caption) = {
figure(content, caption: caption, supplement: "Таблица", kind: table)
}
#let pril(name) = {
show heading: it => {
text(it, size: 14pt)
}
align(heading([
ПРИЛОЖЕНИЕ #upper(prilCount.display((..nums) => str(alphabet.at(nums.pos().last())))) #name
], numbering: none), center)
prilCount.step()
}
// Код всех файлов из json (созданный утилитой tree)
#let allFiles(files, language: "kotlin", path: "/src/") = {
if files.type == "file"{
text( [ \ ] )
text(files.name )
text( [ \ ] )
show raw: set text(hyphenate: false, size: 10pt)
show raw: set par(justify: false, leading: 1em)
raw(read(path + files.name), lang: language)
return
}
for content in (files.contents) {
if content.type == "directory"{
for content2 in (content.contents) {
allFiles(content2, path: path, language: language)
}
} else if content.type == "file"{
//allFiles()
}
}
}
|
|
https://github.com/emanuel-kopp/uzh-mnf-phd | https://raw.githubusercontent.com/emanuel-kopp/uzh-mnf-phd/main/template/chapters/chapter_2.typ | typst | #import "@local/uzh-mnf-phd:0.1.0": chapter
#show: chapter.with(
title: text()[Title of your first chapter, of which maybe a part must be _italic_],
authors: (
(name: "First Author", affiliation: [1, 2]),
(name: "Second Author", affiliation: 3),
(name: "Third Author", affiliation: 1),
(name: "Last Author", affiliation: 2),
),
affiliations: (
(num: 1, name: "First Affiliation"),
(num: 2, name: "Second Affiliation"),
(num:3, name: "Third Affiliation")
),
header: "Chapter 1: Short title as header",
abstract: lorem(100)
)
== Introduction
#lorem(100)
@Aarssen_1997
== Materials and Methods
#lorem(100)
|
|
https://github.com/PgBiel/typst-truthtable | https://raw.githubusercontent.com/PgBiel/typst-truthtable/main/README.md | markdown | MIT License | # typst-truthtable
A library for generating truth tables
## Usage
Compose logic expressions with the logic operators: `l-and(a, b)`, `l-or(a, b)`,
`l-imp(a, b)`, `l-iff(a, b)`, `l-not(a)`, where `a` and `b` can be either
other expressions created with operators, atomic variables/propositions
(which can be created with `"name"` or
`l-var("name", repr: $custom_representation$)`), and boolean values
(`true` or `false`).
Then, for any expression, you may write `#truth-table(expr)` to generate its
truth table.
Note that it gets ugly if there are too many columns, so make sure to mark any
excessive columns with `skip: true` (e.g. `l-and(a, b, skip: true))` will not show
the possible values for "a and b" in the table).
You may also create your own _n_-ary operator by invoking `l-operator("ITS_NAME", a, b, ..other_children, value: variable_mapping => {/* calculate truth value based on a dict (VARIABLE_NAME: true_or_false) */}, repr: $my_operators_appearance$)`. Regarding `value`, note that you may get your children's
truth value based on the given variable map with `(child.value)(variable_mapping)`.
See `examples/` for some examples.

|
https://github.com/teamdailypractice/pdf-tools | https://raw.githubusercontent.com/teamdailypractice/pdf-tools/main/typst-pdf/thirukkural-how-to-read/001-thr.typ | typst | #set page("a4")
#set text(
font: "TSCu_SaiIndira",
size: 16pt
)
#set align(center)
திருக்குறளை எப்படிப் படிப்பது?
\
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 12pt
)
எப்பொருள், யார்-யார்-வாய்க் கேட்பினும்; அப்பொருள் \
மெய்ப்பொருள், காண்பது; அறிவு. \
1. யார் சொல்வதையும், உண்மை என்று நம்பக்கூடாது.
2. கேள்விகள் கேட்க, கற்றுக் கொள்ள வேண்டும்.
3. என்ன கேள்விகள்? ஏன்? எப்பொழுது? எப்படி? எங்கு? உண்மை என்ன? ஆதாரம் எது? ஆதாரம் உண்மையா?
4. பயன் உடையவை - ஆராய்ந்து, தெளிய வேண்டும். எதை செய்ய வேண்டும்? எதை செய்ய கூடாது? ஏன்?
5. பயன் இல்லாதவை - ஆராய்ந்து, தெளிய தேவை-இல்லாதவை. எனக்குத் தெரியாது என்று ஒதுக்கி விட வேண்டும். அதைப் பற்றிப் பேசுவதையும், கேட்பதையும் தவிர்க்க வேண்டும்.
கற்க, கசடு-அற, கற்பவை; கற்ற-பின், \
நிற்க, அதற்குத் தக! \
1. கற்றுக் கொள்ள வேண்டும்.
2. நன்றாக கற்றுக் கொள்ள வேண்டும்.
3. நன்றாக கற்று (ஆராய்ந்து, முயற்சி செய்து, பயிற்சி செய்து), தெளிய வேண்டும்.
4. கற்றதை தினமும் பயன்படுத்த வேண்டும். அதன் வழியில் நடக்கவேண்டும்.
திருவள்ளுவர் திருக்குறளைக் கற்கும் ஒவ்வொருவரும்,
தத்தமக்குக் கிடைக்கும் உரைகளைத் துணையாகக் வைத்துக்கொண்டு,
குறள்களின் பொருள்களைத் தானே ஆராய வேண்டும் என்பது என் விருப்பம்.
வ. உ. சிதம்பரம் பிள்ளை
|
|
https://github.com/open-datakit/accs-finalreport-whitepaper | https://raw.githubusercontent.com/open-datakit/accs-finalreport-whitepaper/main/3-future/content.typ | typst | = Future direction
== Defining the opendata.fit datapackage profile as a git repository
== Closing the gap between analysis and publication
== HPC execution, data bookkeeping and transfer
== Local execution: #[#set text(font: "Inconsolata")
opendatafit-cli]
== Execution at the edge: WebAssembly
== Web application modernisation
|
|
https://github.com/dadn-dream-home/documents | https://raw.githubusercontent.com/dadn-dream-home/documents/main/main.typ | typst | #import "metadata.typ": meta
#set document(author: meta.students.values(), title: meta.title)
#set page(
header: include "template/header.typ",
footer: include "template/footer.typ",
margin: (
top: 30mm,
bottom: 20mm,
left: 30mm,
right: 20mm,
)
)
#set text(font: "LM Roman 10", lang: "vi", region: "VN")
#set heading(numbering: "1.1")
#show heading: it => block(inset: (top: 1em, bottom: .5em), it)
#set par(leading: 1.1em)
#set figure(gap: 1em)
#show raw: set text(font: "Iosevka NF")
#include "template/cover.typ"
#pagebreak()
#outline(
title: "Mục lục",
depth: 3,
indent: true,
)
#outline(
title: "Danh mục hình vẽ",
target: figure.where(kind: image),
)
#outline(
title: "Danh mục bảng biểu",
target: figure.where(kind: table),
)
#pagebreak()
#set par(justify: true)
#show par: set block(spacing: 2em)
#include "contents/index.typ"
#bibliography("bibliography.yml") |
|
https://github.com/sw1sh/QuantumPotatoChips | https://raw.githubusercontent.com/sw1sh/QuantumPotatoChips/main/typst/template.typ | typst | // based on https://typst.app/universe/package/arkheion
#let arxiv(
title: "",
abstract: [],
keywords: (),
authors: (),
date: none,
body,
) = {
// Set the document's basic properties.
set document(title: title, author: authors.flatten().map(a => a.name))
set page(
margin: {
(
x: (50pt / 216mm) * 100%,
top: (55pt / 279mm) * 100%,
bottom: (64pt / 279mm) * 100%,
)
},
numbering: "1",
number-align: center
)
set text(font: "New Computer Modern", lang: "en", size: 11pt)
show figure.caption: set text(size: 8pt)
set math.equation(numbering: "(1)")
show math.equation: eq => {
if eq.block and eq.numbering != none {
text(eq, size: 10pt)
} else {
eq
}
}
set heading(numbering: "1.1")
// Set run-in subheadings, starting at level 4.
show heading: it => {
// H1 and H2
if it.level == 1 {
pad(
bottom: 10pt,
it
)
}
else if it.level == 2 {
pad(
bottom: 8pt,
it
)
}
else if it.level > 3 {
text(11pt, weight: "bold", it.body + " ")
} else {
it
}
}
show ref: it => {
let eq = math.equation
let el = it.element
if el != none and el.func() == eq {
let isEq = str(it.target).starts-with("eq:")
// Override equation references.
link(el.location())[#if isEq [Eq.] else []#numbering(
el.numbering,
..counter(eq).at(el.location())
)]
} else {
// Other references as usual.
it
}
}
//line(length: 100%, stroke: 2pt)
// Title row.
pad(
bottom: 4pt,
top: 4pt,
align(center)[
#block(text(weight: 500, 1.75em, title))
#v(1em, weak: true)
]
)
//line(length: 100%, stroke: 2pt)
// Author information.
pad(
top: 1em,
bottom: 1em,
x: 3em,
grid(
rows: (3em,) * authors.len(),
gutter: 3em,
..authors.map(row =>
grid(
columns: (1fr,) * row.len(),
..row.map(author => align(center)[
#if author.keys().contains("orcid") {
link("http://orcid.org/" + author.orcid)[
#pad(bottom: -8pt,
grid(
columns: (8pt, auto, 8pt),
rows: 10pt,
[],
[*#author.name*],
[
#pad(left: 4pt, top: -4pt, image("orcid.svg", width: 8pt))
]
)
)
]
} else {
grid(
columns: (auto),
rows: 2pt,
[*#author.name*],
)
}
#author.email \
#author.affiliation
]
),
)
)
)
)
align(center)[#date]
// Abstract.
pad(
x: 3em,
top: 1em,
bottom: 0.4em,
align(center)[
#heading(
outlined: false,
numbering: none,
text(0.85em, smallcaps[Abstract]),
)
#set par(justify: true)
#set text(hyphenate: false, 9pt, weight: 700)
#abstract
],
)
// Keywords
if keywords.len() > 0 {
[*_Keywords_* #h(0.3cm)] + keywords.map(str).join(" · ")
}
// Main body.
set par(justify: true, first-line-indent: 1em)
[#body]
}
#let arxiv-appendices(body) = {
counter(heading).update(0)
counter("appendices").update(1)
set heading(
numbering: (..nums) => {
let vals = nums.pos()
let value = "ABCDEFGHIJ".at(vals.at(0) - 1)
if vals.len() == 1 {
return "APPENDIX " + value
}
else {
return value + "." + nums.pos().slice(1).map(str).join(".")
}
}
);
body
} |
|
https://github.com/VisualFP/docs | https://raw.githubusercontent.com/VisualFP/docs/main/SA/project_documentation/content/project_plan.typ | typst | = Project Plan <project_plan>
At the start of our project we created a rough plan, which can be seen in @initial_project_plan.
That plan intends to indicate progress at later stages of the project and not to set fixed deadlines.
The plan is reflected in the timeline feature of our Jira project,
the detailed planning is done weekly using a Kanban board, also in Jira.
#figure(
image("../static/initial_project_plan.png"),
caption: "Initial Project Plan"
)<initial_project_plan>
== Project Plan Retrospection
The project plan we defined at the start of the project worked out well.
We switched from the conceptual phase to the PoC phase in mid-November, consistent with the initial plan.
Towards the end of the conceptual phase, we were unsure if the remaining time was enough to build a presentable PoC application.
But, due to unexpectedly swift progress, we were able to include more features in the PoC than initially thought.
We met both project deadlines for the brochure abstract and the final submission.
We could even hand in the brochure abstract about half a week in advance.
However, the end phase of the project wasn't accurately displayed in the initial project plan.
While we finished the concept documentation, i.e., the description of the theoretical concept for function composition, as planned, we didn't include a phase to complete the rest of the documentation, i.e., documenting the PoC, the project documentation, proofreading, etc.
We did this documentation work during the last 1.5 weeks of the PoC phase.
In a future project, we would include another documentation phase at the end of the project in the initial plan. |
|
https://github.com/cran/tinytable | https://raw.githubusercontent.com/cran/tinytable/master/inst/templates/typst.typ | typst | #show figure: set block(breakable: true)
#figure( // start figure preamble
$TINYTABLE_TYPST_CAPTION
kind: "tinytable",
supplement: "Table", // end figure preamble
block[ // start block
#let nhead = $TINYTABLE_TYPST_NHEAD;
#let nrow = $TINYTABLE_TYPST_NROW;
#let ncol = $TINYTABLE_TYPST_NCOL;
#let style-array = (
// tinytable cell style after
)
// tinytable align-default-array before
#show table.cell: it => {
let tmp = it
let data = style-array.find(data => data.x.contains(it.x) and data.y.contains(it.y))
if data != none {
if data.fontsize != none { tmp = text(size: data.fontsize, tmp) }
if data.color != none { tmp = text(fill: data.color, tmp) }
if data.indent != none { tmp = pad(left: data.indent, tmp) }
if data.underline != none { tmp = underline(tmp) }
if data.italic != none { tmp = emph(tmp) }
if data.bold != none { tmp = strong(tmp) }
if data.mono != none { tmp = math.mono(tmp) }
if data.strikeout != none { tmp = strike(tmp) }
tmp
} else {
tmp
}
}
#align(center, [
#table( // tinytable table start
stroke: none,
align: (x, y) => {
let data = style-array.find(data => data.x.contains(x) and data.y.contains(y))
if data != none and data.align != none {
data.align
} else {
left
}
},
fill: (x, y) => {
let data = style-array.find(data => data.x.contains(x) and data.y.contains(y))
if data != none and data.background != none {
data.background
}
},
// tinytable lines before
table.header(
repeat: true,
),
// tinytable cell content after
// tinytable footer before
) // end table
]) // end align
] // end block
) // end figure
|
|
https://github.com/Error-418-SWE/Documenti | https://raw.githubusercontent.com/Error-418-SWE/Documenti/src/3%20-%20PB/Documentazione%20interna/Verbali/24-03-07/24-03-07.typ | typst | #import "/template.typ": *
#show: project.with(
date: "07/03/24",
subTitle: "Meeting post colloquio con Proponente",
docType: "verbale",
authors: (
"<NAME>",
),
timeStart: "16:40",
timeEnd: "17:00",
);
= Ordine del giorno
A seguito dell'incontro con il Proponente, il gruppo ha svolto un meeting interno riguardante:
- Considerazioni scaturite dal meeting esterno;
- Pianificazione.
== Considerazioni scaturite dal meeting esterno
Il gruppo si ritiene soddisfatto dell'incontro svolto, in quanto:
- è stato confermato lo schema ER aggiornato;
- è stato chiarito il meccanismo di scaling della planimetria da implementare;
- il Proponente ha chiarito quando è necessario chiamare le API RESTful per lo spostamento dei prodotti;
- i primi avanzamenti del MVP sono stati accolti positivamente dal Proponente.
== Pianificazione
Il gruppo ha fatto il punto sulla situazione dello sprint in corso, segnalando un andamento positivo riguardo la documentazione e l'implementazione del prodotto.
Sono sorti alcuni dubbi riguardo la gestione della Customer Acceptance (CA), revisione non obbligatoria svolgibile successivamente alla PB, e sono stati inseriti nella presentazione del Diario di Bordo che si terrà in data 08/03/2024.
Le task scaturite dall'esito di questo meeting riguardano:
+ proseguimento della revisione dell'#adr\;
+ proseguimento dei lavori nella repository WMS3 riguardanti:
- popolamento del database di supporto;
- implementazione della UI;
- risoluzione di bug riguardo la visualizzazione della planimetria.
|
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/import-16.typ | typst | Other | // Cyclic import in other file.
#import "./modules/cycle1.typ": *
This is never reached.
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/text/lang_05.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
//
// // Error: 17-21 expected string, found none
// #set text(lang: none) |
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/flyingcircus/3.0.0/src/FlyingCircus.typ | typst | Apache License 2.0 | #import "Impl.typ" : FlyingCircus, FCPlane, FCShip, FCVehicleFancy, FCVehicleSimple, FCWeapon, KochFont, HiddenHeading |
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/text/raw-01.typ | typst | Other | // Typst syntax inside.
```typ #let x = 1``` \
```typ #f(1)```
|
https://github.com/seapat/markup-resume-lib | https://raw.githubusercontent.com/seapat/markup-resume-lib/main/style.typ | typst | Apache License 2.0 | // set rules
#let format_page(render_settings, document) = {
set page(
paper: render_settings.page_type,
numbering: (..page_indices) => {
// accomodate 1 or 2 counting symbols
let numbers = (page_indices.pos().at(0) - 1,)
if render_settings.numbering.find(regex("1|a|A|i|I|い|イ|א|가|ㄱ")).len() >= 2 { numbers.push(page_indices.pos().last() - 1) }
// start indexing only the pages belonging to the cv
// assuming the cover letter is only 1 page
if page_indices.pos().at(0) != 1 {
// decrease count by 1 to start counting one page later
numbering(render_settings.numbering, ..numbers)
}
},
number-align: render_settings.number_align,
margin: render_settings.margin,
)
// Set Text settings
set text(font: render_settings.font_body, size: render_settings.font_size, hyphenate: false)
// Set Paragraph settings
set par(justify: true)
document
}
// show rules
#let format_sections(render_settings, document) = {
// Uppercase Section Headings
show heading.where(level: 2): item => [
#set align(left)
#set text(font: render_settings.font_head, size: 1em, weight: "bold")
#upper(item.body)
#if (render_settings.line_below) {
v(-0.75em)
line(length: 100%, stroke: 1pt + black) // Draw a line
} else {
box(
width: 1fr,
inset: (bottom: 0.3em),
line(length: 100%, stroke: 1pt + black),
)
}
]
// Name Title
show heading.where(level: 1): item => [
#set text(font: render_settings.font_head, size: 1.5em, weight: "bold")
#upper(item.body)
#v(2pt)
]
document
}
#let init(doc, render_settings) = {
doc = format_page(render_settings, doc)
doc = format_sections(render_settings, doc)
doc
} |
https://github.com/iceghost/resume | https://raw.githubusercontent.com/iceghost/resume/main/5-projects.typ | typst | #[
#let separator = line(length: 100%, stroke: 1pt + gray.lighten(80%))
#show heading.where(level: 3): it => [
#show "[": set text(fill: gray)
#show "]": set text(fill: gray)
[#it.body]
]
== Projects
#block(include("5-projects/1-bkalendar.typ"))
#separator
#block(include("5-projects/2-document-repo.typ"))
#separator
#block(include("5-projects/3-examinator.typ"))
#separator
#block(include("5-projects/4-monoticity.typ"))
] |
|
https://github.com/Jollywatt/typst-fletcher | https://raw.githubusercontent.com/Jollywatt/typst-fletcher/master/docs/gallery/uml-diagram.typ | typst | MIT License | #import "@preview/fletcher:0.5.1" as fletcher: diagram, node, edge
#set page(width: auto, height: auto, margin: 5mm, fill: white)
#diagram(
spacing: (18mm, 10mm),
node-stroke: luma(80%),
node((0.5,0), [*Diagram*], name: <d>),
node((0,1), [*Node*], name: <n>),
node((1,1), [*Edge*], name: <e>),
edge(<d>, ((), "|-", (0,0.5)), ((), "-|", <n>), <n>, "1!-n!"),
edge(<d>, ((), "|-", (0,0.5)), ((), "-|", <e>), <e>, "1!-n?"),
edge("1!-n?"),
node((1,2), [*Mark*], name: <m>),
edge(<e>, "-|>", <n>, stroke: teal, label: text(teal)[snap], left),
edge((rel: (-15pt, 0pt), to: <n>), <d>, "-|>", bend: 40deg, stroke: orange, text(orange)[layout], label-angle: auto)
) |
https://github.com/zurgl/typst-resume | https://raw.githubusercontent.com/zurgl/typst-resume/main/templates/resume/footer.typ | typst | /* Packages */
#import "../../metadata.typ": *
#import "../commun.typ": *
#import "@preview/fontawesome:0.1.0": *
/* Footer */
#let cvFooter() = {
place(bottom, table(
columns: (1fr, auto),
inset: 0pt,
stroke: none,
footerStyle([#firstName #lastName]),
footerStyle(languageSwitch(cvFooterInternational)),
))
}
|
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/text/features-04.typ | typst | Other | // Test number type.
#set text(number-type: "old-style")
0123456789 \
#text(number-type: auto)[0123456789]
|
https://github.com/piepert/philodidaktik-hro-phf-ifp | https://raw.githubusercontent.com/piepert/philodidaktik-hro-phf-ifp/main/src/parts/spue/anforderungen/checkliste_unterricht.typ | typst | Other | #import "/src/template.typ": *
== #ix("Checkliste", "Checkliste Unterrichtsplanung") <checkliste-unterrichtsplanung>
Trifft für Ihre Stundeplanung jeder folgende Punkt zu? Dann sind Sie auf einem guten Weg!
+ Es wird ein Problem aufgeworfen und gelöst.
+ Der Unterricht beschäftigen sich die SuS auf eine philosophische Art und Weise.
+ Es werden gezielt #ix("Kompetenzen", "Kompetenz") entwickelt.
+ Der Unterricht enthält #ix("EPA-operationalisierte", "Operator") #ix("Grob-", "Grobziel") und #ix("Feinziele", "Feinziel").
+ Jedem EPA-Ziel ist eine Aufgabe zugeordnet. |
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/closure-12.typ | typst | Other | // Named arguments.
#{
let greet(name, birthday: false) = {
if birthday { "Happy Birthday, " } else { "Hey, " } + name + "!"
}
test(greet("Typst"), "Hey, Typst!")
test(greet("Typst", birthday: true), "Happy Birthday, Typst!")
// Error: 23-35 unexpected argument: whatever
test(greet("Typst", whatever: 10))
}
|
https://github.com/mangkoran/utm-thesis-typst | https://raw.githubusercontent.com/mangkoran/utm-thesis-typst/main/09a_abstract_en.typ | typst | MIT License | #let content() = [
#align(center,
[= Abstract]
)
#v(4em)
#lorem(30)
#lorem(30)
#pagebreak(weak: true)
]
#content()
|
https://github.com/Error-418-SWE/Documenti | https://raw.githubusercontent.com/Error-418-SWE/Documenti/src/2%20-%20RTB/Documentazione%20interna/Verbali/24-01-14/24-01-14.typ | typst | #import "/template.typ": *
#show: project.with(
date: "14/01/24",
subTitle: "Meeting di retrospettiva e pianificazione",
docType: "verbale",
authors: (
"<NAME>",
),
timeStart: "15:00",
timeEnd: "16:15",
);
= Ordine del giorno
- Valutazione dell'avanzamento;
- Analisi di retrospettiva;
- Revisione RTB;
- Pianificazione.
== Valutazione dell'avanzamento <avanzamento>
Ogni membro del gruppo, supportato dall'evidenza della board Jira, ha esposto lo stato di avanzamento delle proprie attività assegnate. Per brevità sono omesse le considerazioni riguardo i documenti Norme di Progetto, Analisi dei rischi e Piano di Progetto, per i quali l'avanzamento è avvenuto nel rispetto della pianificazione precedente.
=== Piano di Qualifica
Per ragioni di tempo non è stato possibile ampliare la dashboard di monitoraggio con nuove visualizzazioni.
=== PoC
Sono stati individuati e corretti i problemi di prestazioni riscontrati alla fine dello sprint precedente.
A seguito di un colloquio informale con il Professor Cardin in data 12/01/24, è stato deciso di utilizzare Next.js per la realizzazione del _pattern middleware_. Poiché Next.js è la tecnologia scelta per la realizzazione del frontend, utilizzarlo anche per l'implementazione del middleware sembra, allo stato attuale, una scelta naturale. La rimozione di Express.js permetterà di semplificare lo stack tecnologico complessivo.
=== Automazioni
Sono stati corretti tutti i bug grazie ad un refactoring del codice delle GitHub Action.
È stata introdotto il rilascio automatico del documento in seguito all'aggiornamento manuale del changelog. La funzione risulterà utile per la rimozione delle linee erroneamente introdotte dall'automazione preposta.
=== Glossario
La lista dei termini di dominio è cresciuta rispetto al contenuto del documento.
== Analisi di retrospettiva
=== Keep doing <keep-doing>
Le revisioni effettuate nello scorso sprint si sono distinte per celerità e precisione.
=== Improvements <improvements>
La comunicazione tra membri è risultata non allineata (_siloed_) in alcune occasioni.
Si è inoltre riscontrato uno sbilanciamento dell'impegno dei singoli membri del gruppo, dovuto all'avvicinarsi della sessione d'esame invernale.
== Revisione RTB
Visto lo stato di avanzamento, il gruppo ha l'obiettivo di presentare la propria candidatura per la revisione RTB entro il 19/01/24.
== Pianificazione <pianificazione>
La pianificazione dello Sprint 11 tiene conto della prossimità della sessione di esame invernale.
- Procedere con la revisione dei documenti. Se necessario, l'incaricato alla revisione aggiornerà manualmente il log associato secondo le regole prestabilite;
- Redigere la lettera di presentazione per sostenere la revisione RTB;
- Ampliare la dashboard di monitoraggio;
- Revisionare, correggere ed espandere il Glossario;
- Preparare la presentazione a supporto della revisione RTB.
La candidatura sarà nuovamente discussa durante una riunione interna mercoledì 17/01/24 alle ore 10:00, secondo le modalità consuete. In tale sessione si stabilirà quando chiedere il colloquio di valutazione RTB con il Professor Cardin.
Si prevede, inoltre, che gli Sprint 12 e 13 avranno ambito ridotto a causa della concorrente sessione di esami. |
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/field-01.typ | typst | Other | // Test fields on elements.
#show list: it => {
test(it.children.len(), 3)
}
- A
- B
- C
|
https://github.com/alberto-lazari/cns-report | https://raw.githubusercontent.com/alberto-lazari/cns-report/main/report.typ | typst | #import "template.typ": *
#set page(
header: align(center)[Advanced Topics in Computer Network and Security exam, II call, February 2024],
numbering: "1"
)
#show: ieee.with(
title: "Virtualizing the Process of Fuzzing for the Testing of QR Codes on Android Applications",
abstract: [
#include "abstract.typ"
],
authors: (
(
name: "<NAME>",
department: [Department of Mathematics],
organization: [University of Padua],
location: [Padua, Italy],
email: "<EMAIL>"
),
(
name: "<NAME>",
department: [Department of Mathematics],
organization: [University of Padua],
location: [Padua, Italy],
email: "<EMAIL>"
),
(
name: "<NAME>",
department: [Department of Mathematics],
organization: [University of Padua],
location: [Padua, Italy],
email: "<EMAIL>"
),
),
index-terms: ([QR code], [Fuzzing], [Android security], [Virtualization], [Mobile applications]),
bibliography-file: "refs.bib",
)
#show heading.where(level: 2): it => {
v(.5em)
set text(size: 10pt)
set par(first-line-indent: 0em)
emph(strong(it.body))
v(.5em)
}
#show heading.where(level: 3): it => {
v(.5em)
set par(first-line-indent: 0em)
text(weight: "medium", emph(it.body))
}
#include "introduction.typ"
#include "previous-architecture.typ"
#include "critical-aspects.typ"
#include "our-approach.typ"
#include "webcam.typ"
#include "device.typ"
#include "automation.typ"
#include "test.typ"
#include "conclusions.typ"
#include "future-work.typ"
|
|
https://github.com/Quaternijkon/notebook | https://raw.githubusercontent.com/Quaternijkon/notebook/main/content/数据结构与算法/.chapter-数据结构/数组/数组中的重复元素.typ | typst | #import "../../../../lib.typ":*
// === 数组中的重复元素 #Link("https://leetcode.cn/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/description/")
=== #Title(
title: [数组中的重复元素],
reflink: "https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/description/",
level: 1,
)<数组中的重复元素>
#note(
title: [寻找文件副本],
description: [设备中存有 n 个文件,文件 id 记于数组 documents。若文件 id 相同,则定义为该文件存在副本。请返回任一存在副本的文件 id。],
examples: (
[
输入:documents = [2, 5, 3, 0, 5, 0]
输出:0 或 5
],
),
tips: [0 ≤ documents[i] ≤ n-1
2 <= n <= 100000],
solutions: (
(name:[遍历],
text:[
遍历中,第一次遇到数字 x 时,将其交换至索引 x 处;而当第二次遇到数字 x 时,一定有 documents[x]=x ,此时即可得到一组重复数字。
],code:
[
```cpp
class Solution {
public:
int findRepeatDocument(vector<int>& documents) {
int i = 0;
while(i < documents.size()) {
if(documents[i] == i) {
i++;
continue;
}
if(documents[documents[i]] == documents[i])
return documents[i];
swap(documents[i],documents[documents[i]]);
}
return -1;
}
};
```
]
),
),
gain:none,
)
// #BlueText("数组中的重复元素") |
|
https://github.com/DVDTSB/dvdtyp | https://raw.githubusercontent.com/DVDTSB/dvdtyp/main/template/main.typ | typst | MIT License | #import "@preview/dvdtyp:1.0.0": *
#show: dvdtyp.with(
title: "dvd.typ",
subtitle: [potato, tomato, banana],
author: "among us",
abstract: lorem(50),
)
#outline()
= Lorem ipsum is my favourite
#lorem(50)
== Colorful wooo!!
#problem[
Prove that $1+1=3$.
]
#example("addition")[$ 1+1=3 $
]
#theorem("Euclid")[ infinite primes what???
]
#definition("hi")[ i define hi as a greeting
]
#proof[
$ "hi"="hello"="greeting" $
]
= new page cuz why not
#lorem(100) |
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/bugs/place-pagebreak_00.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
#set page(height: 40pt)
#block(height: 100%)
#place(bottom + right)[Hello world]
|
https://github.com/antonWetzel/Masterarbeit | https://raw.githubusercontent.com/antonWetzel/Masterarbeit/main/arbeit/implementierung.typ | typst | #import "setup.typ": *
= Implementierung <implementierung>
== Technik
Das Softwareprojekt ist auf #link-footnote("https://github.com/antonWetzel/treee", [GitHub]) verfügbar. Als Programmiersprache wird Rust und als Grafikkartenschnittstelle WebGPU verwendet. Rust ist eine performante Programmiersprache mit einfacher Integration für WebGPU. WebGPU bildet eine Abstraktionsebene über der nativen Grafikkartenschnittstelle, dadurch ist die Implementierung unabhängig vom Betriebssystem. Alle verwendeten Bibliotheken sind in @implementierung_bilbiotheken gelistet.
#{
show table.cell: set text(size: 0.8em)
[#figure(
caption: [Benutzte Bibliotheken],
table(
columns: (auto, auto, 1fr),
align: (x, y) => if y == 0 { center } else { (left, right, left).at(x) },
[*Name*], [*Version*], [*Funktionalität*],
`nalgebra`, `0.32.4`, [Lineare Algebra],
`pollster`, `0.3`, [Auf asynchrone Berechnungen warten],
`rfd`, `0.14`, [Dialogfenster zum Öffnen und Speichern von Dateien],
`crossbeam`, `0.8`, [Synchronisierung zwischen Threads],
`log`, `0.4`, [Logs erzeugen],
`env_logger`, `0.11`, [Wiedergabe von Logs],
`image`, `0.24`, [Laden und Speichern von Bildern],
`wgpu`, `0.19`, [WebGPU Implementierung],
`winit`, `0.29`, [Fenstermanagement],
`bytemuck`, `1.14`, [Konversation von Daten zu Bytes],
`serde`, `1.0`, [Serialisierung von Datentypen],
`serde_json`, `1.0`, [Serialisierung als JSON],
`rand`, `0.8`, [Generierung von Zufallszahlen],
`num_cpus`, `1.15`, [Anzahl von Prozessorkernen bestimmen],
`laz`, `0.8`, [Dekomprimieren von LASzip Dateien],
`thiserror`, `1.0`, [Fehlermanagement],
`tempfile`, `3.8.1`, [Temporäre Dateien erstellen],
`rayon`, `1.8.0`, [Multithreading],
`termsize`, `0.1`, [Größe vom Terminal bestimmen],
`egui`, `0.26`, [Benutzerinterface],
`egui-winit`, `0.26`, [Systemereignisse zum Interface weiterleiten],
`egui-wgpu`, `0.26`, [Interface rendern],
`clap`, `4.4`, [Kommandozeilenargumente verarbeiten],
`voronator`, `0.2.1`, [Voronoi-Diagramm bestimmen],
`cfg-if`, `1.0.0`, [Konditionales Kompilieren von Quelltext],
`static_assertions`, `1.1.0`, [Systemeigenschaften überprüfen],
`colored`, `2.1.0`, [Farben für Text im Terminal],
),
) <implementierung_bilbiotheken>]
}
Als Eingabe werden Datensätze im LASzip-Format verwendet. Weitere Formate können einfach eingebunden werden, solange eine Rust-Bibliothek existiert, welche das Format einlesen kann.
== Benutzung
=== Installation
Für den Import und die Visualisierung wird das kompilierte Programm `treee` benötigt. Dieses kann mit dem Quelltext selber kompiliert werden oder bereits kompilierte Versionen können vom #link-footnote("https://github.com/antonWetzel/treee/releases", [GitHub-Release]) heruntergeladen werden. Die Schritte zum selber kompilieren sind im #link-footnote("https://github.com/antonWetzel/treee?tab=readme-ov-file#treee", [Readme]) verfügbar.
=== Ausführen
In @implementierung_befehle sind die Befehle gelistet, um den Importer und die Visualisierung zu starten. Um `treee` von der Befehlszeile auszuführen, muss das Programm im `PATH` verfügbar sein oder anstelle von `treee` muss der absolute Pfad vom Programm verwendet werden.
#figure(
caption: [Mögliche Befehle für das Programm.],
table(
align: (x, y) => if y == 0 { center } else { left },
columns: (auto, 1fr),
[*Befehl*], [*Funktion*],
`treee`, [Interaktive Umgebung starten],
`treee importer`, [Importer starten],
`treee help importer`, [Verfügbare Optionen für den Importer anzeigen],
`treee viewer`, [Visualisierung starten],
),
) <implementierung_befehle>
Wenn das Programm ohne Argumente oder außerhalb vom Terminal gestartet wird, kann die gewünschte Funktion interaktiv ausgewählt werden. Für den Import können weitere Optionen mit der Befehlszeile angegeben werden, um den Ablauf an den Datensatz anzupassen.
=== Import
Für den Import wird der Datensatz und der Ordner zum Speichern der Ergebnisse benötigt. Beide können in der Befehlszeile angegeben werden oder über ein Dialogfenster ausgewählt werden. Alle weiteren Optionen mit der zugehörigen Funktion sind in @implementierung_import_optionen gelistet. Am Ende vom Import wird im Ordner für die Ergebnisse die `project.json` Datei und zugehörige Daten abgespeichert, welche von der Visualisierung geöffnet werden können.
#figure(
caption: [Optionen für den Import.],
table(
align: (x, y) => if y == 0 { horizon + center } else { horizon + (left, right, left).at(x) },
columns: (1fr, auto, 2fr),
[*Flag*], [*Standardwert*], [*Funktion*],
`--max-threads`, [unbegrenzt], [Maximale Anzahl an parallelen Threads],
`--min-segment-size`, $100$, [Mindestanzahl von Punkten für ein Segment],
`--segmenting-slice-width`, [#number(1) m], [Breite der horizontalen Scheiben für die Segmentierung],
`--segmenting-max-distance`, [#number(1) m], [Mindestabstand zwischen Bereichen für die Segmentierung],
`--calculations-slice-width`, [#number(0.1) m], [Breite der horizontalen Scheiben für die Analyse von einem Baum],
`--ground-min-area-scale`, number(1.5), [Mindestgröße vom Boden im Vergleich zu der kleinsten Scheibe],
`--ground-max-search-height`, [#number(1.0) m], [Maximale Suchhöhe für den Anfang vom Boden],
`--trunk-diameter-height`, [#number(1.3) m], [Höhe für den Durchmesser vom Stamm],
`--trunk-diameter-range`, [#number(0.2) m], [Bereich für den Durchmesser vom Stamm],
`--crown-diameter-difference`, [#number(1.0) m], [Unterschied vom Durchmesser zwischen dem Stamm und dem Anfang von der Baumkrone],
`--neighbors-count`, number(31), [Maximale Punktanzahl in der Nachbarschaft für die Analyse von Punkten],
`--neighbors-max-distance`, [#number(1.0) m], [Maximale Distanz vom Punkt zu den Punkten in der Nachbarschaft],
`--lod-size-scale`, number(0.95), [Skalierungsfaktor für die Fläche der kombinierten Punkte für die Detailstufen],
`--proj-location`, [`+proj=utm`\
`+ellps=GRS80`\
`+zone=32`], [Region für die geographischen Koordinaten],
),
) <implementierung_import_optionen>
=== Visualisierung
Um eine Punktwolke zu öffnen, wird die `project.json` Datei eingelesen. In der Datei ist die Struktur vom Octree und Informationen über die Segmente enthalten. Die Punktdaten sind in separaten Dateien gespeichert und werden noch nicht geladen.
Je nach Position der Kamera werden die benötigten Punkte geladen, welche momentan sichtbar sind. Dadurch können auch Punktwolken angezeigt werden, die mehr Punkte enthalten als gleichzeitig interaktiv anzeigbar sind. Auch wenn ein einzelnes Segment angezeigt wird, ist nur das Segment geladen, welches ausgewählt wurde.
Mit dem Benutzerinterface kann die Visualisierung angepasst und Informationen angezeigt werden. Die Optionen und einsehbare Informationen sind in @implementierung_ui erklärt.
#figure(
caption: [Benutzerinterface mit den verfügbaren Optionen und Informationen. ],
box(width: 80%, grid(
gutter: 2em,
columns: 1 * (1fr, 1.4fr),
rect(image("../images/ui.png"), radius: 4pt, inset: 2pt, stroke: rgb(27, 27, 27) + 4pt),
align(horizon + left)[
- *Load Project*
- Andere Punktwolke öffnen
- *Property*
- Die angezeigte Eigenschaft ändern
- *Segment*
- Punkte, Linien oder Dreiecke anzeigen
- Triangulation starten
- Informationen über das ausgewählte Segment anzeigen
- Segment speichern
- *Visual*
- Punktgröße ändern
- Punkte basierend auf der ausgewählten Eigenschaft filtern
- Farbpalette wechseln
- Hintergrundfarbe ändern
- Screenshot speichern
- Unterteilung der Detailstufen anzeigen
- *Eye Dome*
- Stärke und Farbe vom Eye-Dome-Lighting ändern
- *Level of Detail*
- Auswahl und Qualität der Detailstufen anpassen
- *Camera*
- Steuerung der Kamera ändern
- Kameraposition speichern oder wiederherstellen
],
)),
) <implementierung_ui>
== Struktur vom Quelltext
Das Softwareprojekt ist in mehrere Module unterteilt, um den Quelltext zu strukturieren. In @appendix_crates und @appendix_crates_abhängigkeiten sind die Module mit zugehöriger Funktionalität und Abhängigkeiten gelistet. Die wichtigsten Module sind `importer` und `viewer`, welche den Import und die Visualisierung beinhalten. Das Modul `treee` ist ein gemeinsames Interface für `importer` und `viewer`, wodurch ein ausführbares Programm für das ganze Projekt erstellt werden kann.
#figure(
caption: [Module vom Projekt mit zugehöriger Funktionalität.],
table(
columns: (auto, 1fr),
align: (x, y) => if y == 0 { center } else { (left, left).at(x) },
[*Name*], [*Funktionalität*],
`input`, [Maus- und Tastatureingaben verarbeiten],
`data-file`, [Daten zusammengefasst in einer Datei speichern],
`project`, [Format für eine Punktwolke und zugehörige Daten],
`k-nearest`, [Nachbarschaftssuche mit KD-Bäumen],
`render`, [Rendern von Punktwolken, Linien und Dreiecken mit `wgpu`],
`viewer`, [Visualisierung von Punktwolken],
`triangulation`, [Triangulation von einer Punktwolke],
`importer`, [Import von Punktwolken],
`treee`, [Gemeinsames Interface für `importer` und `viewer`],
),
) <appendix_crates>
#figure(
caption: [Abhängigkeiten der Module untereinander.],
cetz.canvas(length: 1.0cm, {
import cetz.draw: *
let box(x, y, name) = {
rect((x, y), (x + 3, y + 1), name: name)
content(name, raw(name))
}
set-style(mark: (end: ">", fill: black, scale: 1.4, width: 3.5pt), stroke: black)
box(4, -1, "project")
box(4, 1, "data-file")
box(4, -3, "k-nearest")
box(4, 3, "input")
box(9, -1, "triangulation")
box(9, 3, "render")
box(9, -3, "importer")
box(9, 1, "viewer")
box(14, -1, "treee")
line("k-nearest.east", "triangulation.west")
line("project.east", "render.west")
line("input.east", "render.west")
line("data-file.east", "importer.west")
line("data-file.east", "viewer.west")
line("render.south", "viewer.north")
line("triangulation.north", "viewer.south")
line("k-nearest.east", "importer.west")
line("project.east", "importer.west")
line("importer.east", "treee.west")
line("viewer.east", "treee.west")
}),
) <appendix_crates_abhängigkeiten>
== Import
Um einen Datensatz zu analysieren, muss dieser zuerst importiert werden, bevor er von der Visualisierung angezeigt werden kann. Der Import wird in mehreren getrennten Phasen durchgeführt. Dabei wird der Berechnungsaufwand für eine Phase so weit wie möglich parallelisiert. Die Phasen sind:
#align(center, box(width: 80%, align(left, [
+ Daten laden
+ Segmente bestimmen
+ Segmente analysieren und den Octree erstellen
+ Detailstufen bestimmten und Octree speichern
])))
Der zugehörige Datenfluss ist in @überblick_datenfluss zu sehen. Nach der ersten Phase sind die Punktdaten bekannt und nach der zweiten Phase auf die Segmente aufgeteilt. In der dritten Phase werden dann die Segmente verarbeiten und der Octree aufgebaut. Nach der vierten Phase ist auch der Octree vollständig und die Punktwolke wird abgespeichert.
#figure(
caption: [Datenfluss beim Import.],
cetz.canvas(length: 1cm, {
import cetz.draw: *
set-style(mark: (end: ">", fill: black, scale: 1.4, width: 3.5pt), stroke: black)
rect((0, 2), (3, 3), name: "daten")
content("daten", [Punktdaten])
rect((5, 4), (8, 5), name: "seg0");
content("seg0", [Segment 1])
line("daten.east", "seg0.west")
rect((5, 2), (8, 3), name: "seg1");
content("seg1", [Segment 2])
line("daten.east", "seg1.west")
rect((5, 0), (8, 1), name: "seg2");
content("seg2", [Segment ...])
line("daten.east", "seg2.west")
rect((10, 3), (14, 4), name: "octree")
content("octree", [Octree])
line("seg0.east", "octree.west")
line("seg1.east", "octree.west")
line("seg2.east", "octree.west")
rect((10, 1), (14, 2), name: "punktwolke")
content("punktwolke", [Punktwolke])
line("seg0.east", "punktwolke.west")
line("seg1.east", "punktwolke.west")
line("seg2.east", "punktwolke.west")
line("octree.south", "punktwolke.north")
}),
) <überblick_datenfluss>
=== Parallelisierung
Die Punktdaten werden in LASzip Dateien zu Blöcken zusammengefasst. Jeder Block wird separat komprimiert, wodurch mehrere Blöcke auch parallel dekomprimiert werden können. Ein weiterer Thread sammelt die dekomprimierten Blöcke für die Segmentierung.
Für die Segmentierung wird über die einzelnen horizontalen Scheiben parallelisiert. Der genaue Ablauf ist in @implementierung_segment_parallel erklärt. Mit einem weiteren Thread werden die Segmente gesammelt.
Die Analyse der Segmente und die Berechnung der Detailstufen sind trivial parallelisierbar. Die Segmente haben untereinander keine Datenabhängigkeiten, wodurch diese parallel verarbeitete werden können. Bei den Detailstufen haben die Kinderknoten untereinander keine Abhängigkeiten.
#figure(
caption: [
Parallelisierung der Segmentierung.
],
grid(
columns: (1fr,) + (2fr,),
gutter: 2em,
rect(image("../images/segmentierung_parallel.svg"), inset: 0pt, stroke: gray),
align(top + left)[
Bei der Segmentierung werden die Punkte von oben nach unten in Scheiben verarbeitet. Jede Scheibe wird in den folgenden Stufen verarbeitet.
+ Zusammenhängenden Bereiche von den Punkten bestimmen.
+ Mit den Bereichen und den Koordinaten der vorherigen Scheibe die Koordinaten für die momentane Scheibe berechnen.
+ Punkte auf die Koordinaten verteilen.
Dabei wird für die zweite Stufe die Koordinaten aus der vorherigen Scheibe benötigt.
In der Grafik ist der Arbeitsaufwand dargestellt. Von oben nach unten sind die Scheiben und von links nach rechts die Zeit abgebildet. Die erste Stufe ist in Blau, das Warten auf die vorherige Scheibe in Rot und die dritte Stufe in Orange. Der Berechnungsaufwand der zweiten Stufe ist sehr kurz, wodurch diese nicht in der Grafik sichtbar ist.
Die Berechnung wurde mit sieben Threads durchgeführt, wodurch bis zu sieben Scheiben in parallel verarbeitet werden können. Durch die Datenabhängigkeit kann aber die zweite Stufe erst verarbeitet werden, wenn von der vorherigen Scheibe die zweite Stufe beendet ist. Wenn die erste Stufe länger dauert, müssen deshalb andere Threads warten.
]
),
) <implementierung_segment_parallel>
== Format für eine Punktwolke
Die Struktur von einer Punktwolke ist in der `project.json` Datei gespeichert. Dazu gehören die verfügbaren Eigenschaften und der Octree. Alle benötigten Daten für `project.json` werden in #link-footnote("https://github.com/antonWetzel/treee/blob/main/project/src/lib.rs", `project/src/lib.rs`) definiert.
=== Daten
In separaten Dateien werden die Daten für die Punkte oder Eigenschaften gespeichert. Das verwendete Dateiformat ermöglicht es, die Dateien inkrementell zu erstellen. Am Anfang wird nur benötigt, wie viele Einträge die Datei speichern kann. Danach können die Einträge in beliebiger Reihenfolge abgespeichert werden.
Die Struktur ist in @implementierung_datafile gegeben. Am Anfang der Datei wird für jeden Eintrag die Startposition $s_i$ und die Länge $l_i$ vom zugehörigen Datensegment $d_i$ gespeichert. Danach folgen die Datensegmente in beliebiger Reihenfolge $pi$.
#figure(
caption: [Struktur einer Datei zum Speichern von Daten.],
table(
align: center + horizon,
columns: 11 *(1fr,),
table.cell(colspan: 7)[*Informationen*],
table.cell(colspan: 4)[*Daten*],
$s_0$,
$l_0$,
$s_1$,
$l_1$,
[...],
$s_(n-1)$,
$l_(n-1)$,
$d_(pi(0))$,
$d_(pi(1))$,
[...],
$d_(pi(n-1))$
),
) <implementierung_datafile>
Um den Eintrag $i$ mit den Daten $d$ zur Datei hinzufügen, wird zuerst $s_i$ auf das momentane Ende der Datei und $l_i$ auf die Länge von $d$ gesetzt. Danach wird $d$ am Ende der Datei hinzugefügt. Um die Daten für den Eintrag $i$ zu lesen, wird zuerst $s_i$ und $l_i$ ausgelesen und danach der zugehörige Bereich geladen.
== Visualisierung
=== Punkte
Die benötigten Daten für die Visualisierung von einem Punkt sind das verwendete Polygon, Position, Normale, Größe und ausgewählte Eigenschaft. Das Polygon ist gleich für alle Punkte und muss deshalb nur einmal zur Grafikkarte übertragen werden und wird für alle Punkte wiederverwendet.
Für die Grafikpipeline wird das Polygon in Dreiecke zerlegt. In @implementierung_polygon_zerlegung sind die getesteten Varianten gegeben. Die Dreiecke werden dann mit der Kamera projiziert und es werden alle Pixel bestimmt, welche in den Dreiecken liegen. Für jedes Pixel kann entschieden werden, ob dieser im Ergebnis gespeichert wird. Dafür wird bei den Eckpunkten die Koordinaten ohne die Transformation der Kamera abgespeichert, dass diese später verfügbar sind. Für jedes Pixel wird von der Pipeline die interpolierten Koordinaten berechnet. Nur wenn der Betrag der interpolierten Koordinaten kleiner als eins ist, wird der Pixel im Ergebnis abgespeichert.
#figure(caption: [Zerlegung von unterschiedlichen Polygonen in Dreiecke.], grid(
columns: 1 * 3,
subfigure(
caption: [Dreieck],
cetz.canvas(length: 1cm, {
import cetz.draw: *
let x = calc.tan(60deg);
circle((0, 0), radius: 1, stroke: none, fill: gray)
line((-x, -1), (x, -1), (0, 2), close: true)
}),
),
subfigure(
caption: [Viereck],
cetz.canvas(length: 1cm, {
import cetz.draw: *
circle((0, 0), radius: 1, stroke: none, fill: gray)
line((-1, -1), (1, -1), (1, 1), (-1, 1), close: true)
line((1, 1), (-1, -1))
}),
),
subfigure(
caption: [Achteck],
cetz.canvas(length: 1cm, {
import cetz.draw: *
let x = calc.tan(22.5deg);
circle((0, 0), radius: 1, stroke: none, fill: gray)
line((x, -1), (-x, -1), (-1, -x), (-1, x), (-x, 1), (x, 1), (1, x), (1, -x), close: true)
line((x, -1), (-1, -x), (1, -x), (-1, x), (1, x), (-x, 1))
}),
),
)) <implementierung_polygon_zerlegung>
In @implementierung_polygon sind die Zeiten für das Rendern von Punkten mit unterschiedlichen Polygonen gegeben. Die beste Option ist das Dreieck als Polygon. Für die Zerlegung vom Polygon mit $n$ Ecken in Dreiecke werden $n-2$ Dreiecke und somit $3n-6$ Ecken benötigt. Der benötigte Aufwand entsteht größtenteils durch die Ecken, wodurch das Quadrat circa doppelt und das Achteck sechsmal so lange zum Rendern benötigen.
#figure(
caption: [Renderzeit bei unterschiedlichen Polygonen abhängig von der Anzahl der Punkte.],
image("../data/polygon.svg"),
) <implementierung_polygon>
Die ausgewählte Eigenschaft wird durch das Einfärbung der Punkte angezeigt. Dabei kann die ausgewählte Eigenschaft geändert werden, ohne die anderen Informationen über die Punkte neu zu laden. Dafür wird die Eigenschaften separat als Wert zwischen $0$ und $n$ gespeichert und mit einer Farbpalette in einen Farbverlauf umgewandelt. $n$ kann dabei maximal $2^32-1$ sein, weil $32$ Bit für das Speichern der Eigenschaften verwendet werden. Mit $n$ und einer Farbpalette unabhängig von den Daten wird der Wert in die Farbe für den Punkt umgewandelt. Die verfügbaren Farbpaletten sind in @implementierung_farbpaletten zu sehen.
#figure(
caption: [Verfügbare Farbpaletten.],
grid(
columns: 1,
gutter: 1.5em,
subfigure(caption: [Warm], rect(image("../images/grad_warm.png"), inset: 0pt)),
subfigure(caption: [Kalt], rect(image("../images/grad_cold.png"), inset: 0pt)),
subfigure(caption: [Turbo], rect(image("../images/grad_turbo.png"), inset: 0pt)),
),
) <implementierung_farbpaletten>
=== Segmente
==== Auswahl
Um ein bestimmtes Segment auszuwählen, wird das momentan sichtbare Segment bei der Mausposition berechnet. Als Erstes werden die Koordinaten der Maus mit der Position und Orientierung der Kamera in einen dreidimensionalen Ursprung und Richtung umgewandelt. Der Ursprung und die Richtung bilden zusammen einen Strahl.
Im Octree wird vom Root-Knoten aus die Leaf-Knoten gesucht, welche den Strahl enthalten. Dafür wird bei einem Branch-Knoten die acht Kinderknoten betrachtet. Für jeden Kinderknoten wird überprüft, ob der Strahl den Bereich vom Knoten scheidet und gegebenenfalls wird der Abstand zur Kamera berechnet. Weil der Voxel zugehörig zum Knoten entlang der Achsen vom Koordinatensystem ausgerichtet ist, kann mit dem Algorithmus in @implementierung_ray_aabb überprüft werden, ob der Strahl den Voxel berührt @ray_aabb. Zuerst wird für jede Achse der Bereich bestimmt, für den der Strahl im Quadrat liegen kann. Die Schnittmenge ist die Überschneidung von den Bereichen für alle Achsen.
#figure(
caption: [
Schnittmenge von Strahl und Quadrat in 2D.
],
grid(
columns: 1 * 2,
subfigure(caption: [Bereich für jede Achse bestimmen], cetz.canvas(length: 0.5cm, {
import cetz.draw: *
for i in range(1, 11) {
let x = -2.0 + i * 1.0
let y = -0.5 + i * 0.5
line((x, -0.5), (x, y), stroke: silver)
line((-2.0, y), (x, y), stroke: silver)
}
rect((0, 0), (4, 4), stroke: 2pt)
line((-2.0, -0.5), (8, 4.5), mark: (end: ">", fill: black), stroke: 2pt)
line((-2.0, -0.5), (8.5, -0.5), mark: (end: ">", fill: black))
line((-2.0, -0.5), (-2.0, 5.0), mark: (end: ">", fill: black))
line((-0.0, -0.5), (-0.0, 0))
content((0.0, -0.5), $x_0=2$, anchor: "north", padding: 5pt)
line((4.0, -0.5), (4.0, 0))
content((4.0, -0.5), $x_1=6$, anchor: "north", padding: 5pt)
line((-2.0, 0.0), (-0.0, 0))
content((-2.0, -0.0), $y_0=1$, anchor: "east", padding: 5pt)
line((-2.0, 4.0), (0.0, 4.0))
content((-2.0, 4.0), $y_1=9$, anchor: "east", padding: 5pt)
})),
subfigure(caption: [Bereiche kombinieren], cetz.canvas(length: 0.5cm, {
import cetz.draw: *
line((0, 0), (0, -3.5), stroke: white)
rect((2, 1), (6, -2), stroke: none, fill: gray)
line((0.0, 0.0), (10.0, 0.0))
content((0.0, 0.0), $X$, anchor: "east", padding: 5pt)
line((0.0, -1.0), (10.0, -1.0))
content((0.0, -1.0), $Y$, anchor: "east", padding: 5pt)
line((0.0, 1.0), (0.0, -2.0))
content((0.0, 1.0), $0$, anchor: "south", padding: 5pt)
line((10.0, 1.0), (10.0, -2.0))
content((10.0, 1.0), $10$, anchor: "south", padding: 5pt)
line((2, 0), (6, 0), stroke: 5pt)
line((1, -1), (9, -1), stroke: 5pt)
line((2.0, 1.0), (2.0, -2.0))
content((2.0, 1.0), $s_0 = 2$, anchor: "south", padding: 5pt)
line((6.0, 1.0), (6.0, -2.0))
content((6.0, 1.0), $s_1 = 6$, anchor: "south", padding: 5pt)
})),
),
) <implementierung_ray_aabb>
Nachdem alle Kinderknoten gefunden wurden, die den Strahl enthalten, werden diese nach Abstand zur Kamera sortiert. Die weitere Suche wird zuerst für die näheren Knoten durchgeführt.
Für einen Leaf-Knoten wird der Punkt gesucht, welcher zuerst vom Strahl berührt wird. Dafür werden alle Punkte im Knoten betrachtet. Für jeden Punkt wird zuerst die Distanz vom Strahl bestimmt. Wenn die Distanz kleiner als der Radius vom Punkt ist, wird der Abstand zum Ursprung vom Strahl berechnet. Der Punkt mit dem kleinsten Abstand zum Ursprung ist der ausgewählte Punkt. Wenn kein Punkt gefunden wird, wird der nächste Knoten entlang des Strahls betrachtet.
Weil die Knoten nach Distanz sortiert betrachtet werden, kann die Suche abgebrochen werden, sobald ein Punkt gefunden wurde. Alle weiteren Knoten sind weiter entfernt, wodurch die enthaltenen Punkte nicht näher zum Ursprung vom Strahl liegen können.
==== Visualisierung
Im Octree kann zu den Punkten in einem Leaf-Knoten mehrere Segmente gehören. Um die Segmente einzeln anzuzeigen, wird jedes Segment zusätzlich separat abgespeichert. Sobald ein Segment ausgewählt wurde, wird dieses geladen und anstatt des Octrees angezeigt. Dabei werden alle Punkte des Segments ohne vereinfachte Detailstufen verwendet.
Die momentan sichtbaren Knoten vom Octree bleiben dabei geladen, um einen schnellen Wechsel zurück zur vollständigen Punktwolke zu ermöglichen.
==== Exportieren
Die Segmente können im Stanford Polygon Format (PLY) exportiert werden. Jeder Punkt wird dabei so transformiert, dass die Höhe entlang der z-Achse mit $0$ für den tiefsten Punkt gespeichert wird. Die horizontale Position der Punkte wird entlang der x- und y-Achse so verschoben, dass die Ausdehnung vom Segment in der positiven und negativen Richtung gleich ist.
=== Detailstufen
Beim Anzeigen vom Octree wird vom Root-Knoten aus zuerst geprüft, ob der momentane Knoten von der Kamera aus sichtbar ist. Wenn ein Knoten nicht sichtbar ist, so wird dieser nicht geladen und angezeigt. In @implementierung_culling ist ein Beispiel für das Filtern bei unterschiedlichen Detailstufen gegeben. Weil nur ein Teil vom Knoten von der Kamera aus sichtbar sein muss, können bei größeren Knoten der Großteil der Punkte außerhalb der Kamera liegen und werden trotzdem angezeigt.
#figure(
caption: [Sichtbare Knoten für unterschiedliche Detailstufen.],
grid(
columns: 1 * 2,
column-gutter: 3em,
row-gutter: 1em,
box(image("../images/culling_0.png"), stroke: 1pt),
box(image("../images/culling_1.png"), stroke: 1pt),
box(image("../images/culling_2.png"), stroke: 1pt),
box(image("../images/culling_3.png"), stroke: 1pt),
box(image("../images/culling_4.png"), stroke: 1pt),
box(image("../images/culling_5.png"), stroke: 1pt),
),
) <implementierung_culling>
Die Auswahl der Detailstufen kann dabei geändert werden. Im Normalfall wird die gewünschte Detailstufe abhängig vom Abstand zur Kamera ausgewählt. Dadurch werden in der Nähe der Kamera genauere Detailstufen oder die originalen Punkte angezeigt und weit von der Kamera entfernt werden die Detailstufen immer weiter vereinfacht. Eine andere Option ist es, die gleiche Detailstufe für alle Knoten zu verwenden.
|
|
https://github.com/nobel-sh/typst-report | https://raw.githubusercontent.com/nobel-sh/typst-report/main/main.typ | typst | #import "assignment.typ": assignment, note, todo
#set text(font: "New Computer Modern")
#show raw: set text(font: "New Computer Modern Mono")
// Might need sometimes
//#set text(font: "Times New Roman")
//#show raw: set text(font: "New Computer Modern")
#show: assignment
#set align(left)
#set text(size: 12pt)
#set par(leading: 0.55em, first-line-indent: 1.8em, justify: true)
#show par: set block(spacing: 0.55em)
#set page(margin: 1.75in)
#show heading: set block(above: 1.4em, below: 1em)
// start page numbering after
// first page and table of content
#set page(numbering: "1",number-align: center)
#counter(page).update(1)
= Introduction
#lorem(60)
#note[This is an important note about the assignment.]
= Implementation
#lorem(60)
== Sub header 1
#lorem(60)
#todo[Add more details about the data collection process.]
== Sub header 2
#lorem(60)
#todo[Add more details about the data collection process.]
=== Sub sub header
#lorem(60)
= Results
#lorem(60)
= Discussion
#lorem(60)
#lorem(60)
= Conclusion
#lorem(60)
|
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/return-03.typ | typst | Other | // Test return outside of function.
#for x in range(5) {
// Error: 3-9 cannot return outside of function
return
}
|
https://github.com/soul667/typst | https://raw.githubusercontent.com/soul667/typst/main/PPT/MATLAB/touying/docs/docs/progress/sections.md | markdown | ---
sidebar_position: 2
---
# Touying Sections
Touying maintains its own sections state to record the sections and subsections of slides.
## touying-outline
`#touying-outline(enum-args: (:), padding: 0pt)` is used to display a simple outline.
## touying-final-sections
`#states.touying-final-sections(final-sections => ..)` is used to customize the display of the outline.
## touying-progress-with-sections
```typst
#states.touying-progress-with-sections((current-sections: .., final-sections: .., current-slide-number: .., last-slide-number: ..) => ..)
```
This is the most powerful one, allowing you to build any complex progress display with its functionalities. |
|
https://github.com/exdevutem/taller-git | https://raw.githubusercontent.com/exdevutem/taller-git/main/src/instalacion.typ | typst | = Instalando Git
Se provee un pequeño resumen del proceso de instalación en el siguiente espacio. Se recomienda leer #link("https://www.atlassian.com/git/tutorials/install-git")[la siguiente guía] provista por Atlassian para más información, problemas y otros.
== Mac y Linux
En Linux y Mac, lo común es que este programa ya se encuentre instalado, y es verificable con el comando `git --version`
En caso de no estar instalado, favor de revisar un tutorial para tu sistema operativo correspondiente. En la mayoría de casos, puedes hacerlo de la siguiente manera:
```bash
# Para MacOS
$ brew install git
# Derivados de Debian (o de Ubuntu)
$ sudo apt install git
# Derivados de Arch
$ sudo pacman -Sy git
```
== Windows <windows-install>
Windows es un poco especial en el caso de Git, porque no viene por defecto. Su instalación es relativamente sencilla. Se debe #link("https://git-scm.com/download/win")[descargar el instalador desde el sitio oficial].
En general, se recomienda "apretar siguiente" durante todo el proceso de instalación, pues los valores por defecto son perfectamente razonables para la gran mayoría de usuarios. El único valor que si les recomiendo cambiar es *el editor por defecto*, pues git opta por vim como opción. Lo que deberían usar ustedes, a menos de que se sientan cómodos con vim, es probablemente nano. De todas formas, la opción de editor se puede cambiar luego.
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/rivet/0.1.0/src/config.typ | typst | Apache License 2.0 | #let config(
default-font-family: "Ubuntu Mono",
default-font-size: 15pt,
italic-font-family: "Ubuntu Mono",
italic-font-size: 12pt,
background: white,
text-color: black,
link-color: black,
bit-i-color: black,
border-color: black,
bit-width: 30,
bit-height: 30,
description-margin: 10,
dash-length: 6,
dash-space: 4,
arrow-size: 10,
margins: (20, 20, 20, 20),
arrow-margin: 4,
values-gap: 5,
arrow-label-distance: 5,
force-descs-on-side: false,
left-labels: false,
width: 1200,
height: 800,
full-page: false,
all-bit-i: true
) = {
return (
default-font-family: default-font-family,
default-font-size: default-font-size,
italic-font-family: italic-font-family,
italic-font-size: italic-font-size,
background: background,
text-color: text-color,
link-color: link-color,
bit-i-color: bit-i-color,
border-color: border-color,
bit-width: bit-width,
bit-height: bit-height,
description-margin: description-margin,
dash-length: dash-length,
dash-space: dash-space,
arrow-size: arrow-size,
margins: margins,
arrow-margin: arrow-margin,
values-gap: values-gap,
arrow-label-distance: arrow-label-distance,
force-descs-on-side: force-descs-on-side,
left-labels: left-labels,
width: width,
height: height,
full-page: full-page,
all-bit-i: all-bit-i
)
}
#let dark = config.with(
background: rgb(24, 24, 24),
text-color: rgb(216, 216, 216),
link-color: rgb(150, 150, 150),
bit-i-color: rgb(180, 180, 180),
border-color: rgb(180, 180, 180)
)
#let blueprint = config.with(
background: rgb(53, 77, 158),
text-color: rgb(231, 236, 249),
link-color: rgb(169, 193, 228),
bit-i-color: rgb(214, 223, 244),
border-color: rgb(214, 223, 244)
)
#let transparent = config.with(
background: rgb(0, 0, 0, 0),
text-color: rgb(128, 128, 128),
link-color: rgb(128, 128, 128),
bit-i-color: rgb(128, 128, 128),
border-color: rgb(128, 128, 128)
)
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/babel/0.1.1/docs/manual.typ | typst | Apache License 2.0 | #import "@preview/fontawesome:0.4.0": *
#import "@preview/mantys:0.1.4": *
#import "@preview/metalogo:1.0.2": LaTeX
#import "@preview/suiji:0.3.0"
#import "@preview/wrap-it:0.1.0": *
#import "@preview/babel:0.1.1": *
#import "../assets/logo.typ": logo
#import "../src/alphabets.typ": alphabets, maze
#let redcell = table.cell.with(fill: rgb("#FFCCCC"))
#let grncell = table.cell.with(fill: rgb("#CCDDAA"))
#let ylwcell = table.cell.with(fill: rgb("#EEEEBB"))
// By default Mantys sets the font on the title page; this is a way around that.
#let gentium-titlepage(..args) = {
set text(font: ("Gentium Plus", "Noto Emoji"))
show raw: set text(font: "Iosevka") // https://typeof.net/Iosevka/
titlepage(..args, toc: false)
}
#show: mantys.with(
titlepage: gentium-titlepage,
title: "Babel",
..toml("../typst.toml"),
abstract: [
#align(center, text(size: 32pt, logo()))
This package provides functions that replace actual text with random characters, which is useful for redacting confidential information or sharing the design and structure of an existing document without disclosing the content itself.
A variety of ready-made sets of characters for replacement are available (#alphabets.len() in total), representing diverse writing systems, codes, notations and symbols.
Some of these are more conservative (such as emulating redaction using a wide black pen) and many are more whimsical, as demonstrated by the following example:
#example[```
#baffle(alphabet: "welsh")[Hello]. My #tippex[name] is #baffle(alphabet: "underscore")[Inigo Montoya]. You #baffle(alphabet: "alchemy")[killed] my #baffle(alphabet: "shavian")[father]. Prepare to #redact[die].
Using show rules strings, regular expressions and other selectors can be redacted automatically:
#show "<NAME>": baffle.with(alphabet: "sitelen-pona")
#show regex("[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*"): baffle.with(alphabet: "maze-3")
I’m <NAME>, and my email is `<EMAIL>`.
```]
],
examples-scope: (
baffle: baffle,
redact: redact,
tippex: tippex,
redcell: redcell,
grncell: grncell,
ylwcell: ylwcell,
alert: mty.alert,
),
)
#set text(font: (("Gentium Plus", "Noto Emoji")))
#show regex("[⟨⟩]"): it => {text(font: "Gentium Basic", it)} // for some reason the Gentium Plus glyphs look horrible 𓂜
#show raw: set text(font: "Iosevka") // https://typeof.net/Iosevka/
#set raw(theme: "tokyonight_day.tmTheme") // https://github.com/folke/tokyonight.nvim/blob/main/extras/sublime/tokyonight_day.tmTheme
#show link: it => [#it#text(fill: rgb("#993333"))[°]]
#show figure.where(kind: table): set figure.caption(position: top)
#set heading(supplement: "§")
#set table(stroke: none)
#let hbo = text.with(font: "SBL Hebrew", lang: "he")
= Introduction
== Purpose and usage scenarios
At times one wishes to make portions of text (or the whole text) hidden from the recipient:
- The most common case is when redacting confidential information.
Traditionally this is done by overwriting portions of text with a wide black pen and photocopying the result.
- Another usage scenario is sharing the design and structure of a document, but not the text itself.
While _lorem ipsum_#footnote[
Typst provides a built-in function for this, #link("https://typst.app/docs/reference/text/lorem/")[`lorem()`], which outputs pseudo-Latin.
For a Japanese blind text generator, see #link("https://typst.app/universe/package/roremu")[#package[roremu]].
] blocks help when demonstrating the design of a template~— replacing places where actual text would go with placeholder text~— when sharing the way a particular existing document looks they are less helpful, since in order to use them one would have to make a copy of the document and manually substitute text with placeholder text of more or less the same length, which is tiresome and prone to errors.
In addition, playing with various contemporary, historical and constructed writing systems is a special kind of geeky fun…
While the package does have serious, practical use, most of the provided alphabets (@alphabets) are there just for fun.
One thing I ask you to avoid is using #package[Babel] for mocking cultures, as often done with mimicry typefaces such as #link("https://en.wikipedia.org/wiki/Faux_Cyrillic")[Faux Cyrillic], #link("https://en.wikipedia.org/wiki/Faux_Hebrew")[Faux Hebrew] or #link("https://en.wikipedia.org/wiki/Wonton_font")[Wonton font], which have more than subtle racist undertone. This package is a celebration of the variety and diversity of writing#footnote[
Just look at @alphabets! Human beings~— as well as Klingons and Elves…~— came up with so many different graphic symbols to represent sounds and ideas it’s mind-boggling.
].
If you wish to share the Typst source files of your document, not just the precompiled output, a tool called #link("https://github.com/frozolotl/typst-mutilate")[_Typst Mutilate_] might be useful for you.
Unlike #package[Babel], it is not a Typst package but an external tool, written in Rust.
It replaces the content of a Typst document with random words selected from a wordlist or random characters (similarly to Babel), changing the document in place (so make sure to run it on a _copy_!).
As a package for Typst, #package[Babel] cannot change your source files.
== Name
Have a seat, it’s story time.
#package[Babel] is named so as a wordplay on two things: the Biblical myth of the Tower of Babel and the #link("https://ctan.org/pkg/babel")[#LaTeX package] sharing the same name.
For anyone who isn’t familiar with the story, here is the full fragment (Genesis 11.1–9):
#let verse(number) = [#super(number) ]
#let hl = highlight.with(fill: eastern.transparentize(85%), radius: 1pt)
#[
#set text(size: 10pt)
#table(
columns: (65%, 35%),
gutter: 0.75em,
[
#show "YHWH": smallcaps[Yhwh]
#verse("1")Now all the earth was of one language and one set-of-words.
#verse("2")And it was when they migrated to the east that they found a valley in the land of Shin’ar and settled there.
#verse("3")They said, each one to his neighbor: Come-now! Let us bake bricks and let us burn them well-burnt! —;For them brick-stone was like building-stone, and raw-bitumen was for them like red-mortar.
#verse("4")And they said: Come-now! Let us build ourselves a city and a tower, its top in the heavens, and let us make ourselves a name, lest we be scattered over the face of all the earth!
#verse("5")But YHWH came down to look over the city and the tower that the humans were building.
#verse("6")YHWH said: Here, [they are] one people with one language for them all, and this is [merely] the first of their doings— now there will be no barrier for them in all that they scheme to do!
#verse("7")#hl[Come-now! Let us go down and there let us baffle their language, so that no one will understand the language of his neighbor.]
#verse("8")So YHWH scattered them from there over the face of all the earth, and they had to stop building the city.
#verse("9")#hl[Therefore its name was called Bavel/Babble, for there YHWH baffled the language of all the earth-folk, and from there, YHWH scattered them over the face of all the earth.]
],
hbo[
#verse("1")וַיְהִ֥י כׇל־הָאָ֖רֶץ שָׂפָ֣ה אֶחָ֑ת וּדְבָרִ֖ים אֲחָדִֽים׃
#verse("2")וַיְהִ֖י בְּנׇסְעָ֣ם מִקֶּ֑דֶם וַֽיִּמְצְא֥וּ בִקְעָ֛ה בְּאֶ֥רֶץ שִׁנְעָ֖ר וַיֵּ֥שְׁבוּ שָֽׁם׃
#verse("3")וַיֹּאמְר֞וּ אִ֣ישׁ אֶל־רֵעֵ֗הוּ הָ֚בָה נִלְבְּנָ֣ה לְבֵנִ֔ים וְנִשְׂרְפָ֖ה לִשְׂרֵפָ֑ה וַתְּהִ֨י לָהֶ֤ם הַלְּבֵנָה֙ לְאָ֔בֶן וְהַ֣חֵמָ֔ר הָיָ֥ה לָהֶ֖ם לַחֹֽמֶר׃
#verse("4")וַיֹּאמְר֞וּ הָ֣בָה ׀ נִבְנֶה־לָּ֣נוּ עִ֗יר וּמִגְדָּל֙ וְרֹאשׁ֣וֹ בַשָּׁמַ֔יִם וְנַֽעֲשֶׂה־לָּ֖נוּ שֵׁ֑ם פֶּן־נָפ֖וּץ עַל־פְּנֵ֥י כׇל־הָאָֽרֶץ׃
#verse("5")וַיֵּ֣רֶד יְהֹוָ֔ה לִרְאֹ֥ת אֶת־הָעִ֖יר וְאֶת־הַמִּגְדָּ֑ל אֲשֶׁ֥ר בָּנ֖וּ בְּנֵ֥י הָאָדָֽם׃
#verse("6")וַיֹּ֣אמֶר יְהֹוָ֗ה הֵ֣ן עַ֤ם אֶחָד֙ וְשָׂפָ֤ה אַחַת֙ לְכֻלָּ֔ם וְזֶ֖ה הַחִלָּ֣ם לַעֲשׂ֑וֹת וְעַתָּה֙ לֹֽא־יִבָּצֵ֣ר מֵהֶ֔ם כֹּ֛ל אֲשֶׁ֥ר יָזְמ֖וּ לַֽעֲשֽׂוֹת׃
#verse("7")#hl[הָ֚בָה נֵֽרְדָ֔ה וְנָבְלָ֥ה שָׁ֖ם שְׂפָתָ֑ם אֲשֶׁר֙ לֹ֣א יִשְׁמְע֔וּ אִ֖ישׁ שְׂפַ֥ת רֵעֵֽהוּ׃]
#verse("8")וַיָּ֨פֶץ יְהֹוָ֥ה אֹתָ֛ם מִשָּׁ֖ם עַל־פְּנֵ֣י כׇל־הָאָ֑רֶץ וַֽיַּחְדְּל֖וּ לִבְנֹ֥ת הָעִֽיר׃
#verse("9")#hl[עַל־כֵּ֞ן קָרָ֤א שְׁמָהּ֙ בָּבֶ֔ל כִּי־שָׁ֛ם בָּלַ֥ל יְהֹוָ֖ה שְׂפַ֣ת כׇּל־הָאָ֑רֶץ וּמִשָּׁם֙ הֱפִיצָ֣ם יְהֹוָ֔ה עַל־פְּנֵ֖י כׇּל־הָאָֽרֶץ׃]
]
)
]
The myth explains why people are scattered everywhere and why they speak different languages, and it also provides folk etymology for the name of the city of Babylon (#hbo[בָּבֶל] _Bāḇel_): #hbo[בָּלַ֥ל] _bālal_ ‘he mixed, he confounded’ in verse~9 and #hbo[וְנָבְלָ֥ה] _wə-nāḇlâ_ ‘and let us mix, and let us confound’ in verse~7 (both from the root #hbo[ב־ל־ל] _√BLL_ ‘to mix, to confound, to confuse’) sounds a bit like #hbo[בָּבֶל] _Bāḇel_ ‘Babel’.#footnote[
Interestingly, the Babylonian Akkadian name which is the basis for the Hebrew name is 𒆍𒀭𒊏𒆠 _Bābilim_ ‘(lit.) the gate of the gods’.
Even more interestingly, there is evidence this Akkadian interpretation of the name (as ‘the gate of the gods’) itself was a Semitic folk etymology on a non-Semitic name!
This is all very… confusing, how people mix up things.
]
Everett Fox translated these verbs brilliantly in the #link("https://www.sefaria.org.il/Genesis.11?ven=The_Five_Books_of_Moses,_by_Everett_Fox._New_York,_Schocken_Books,_1995&lang=bi")[_Schocken Bible_], with the English verb _baffle_, where all other translation I looked at have _confound_ or _confuse_.
This is the reason for choosing that translation for the above excerpt and the name #cmd("baffle") for the main function provided by #package[Babel].
Now, idea of the Tower of Babel as the explanatory myth behind linguistic diversity still persists in contemporary culture, as demonstrated by the Babel fish in Douglas Adams’s _the Hitchhiker's Guide to the Galaxy_, the dictionary and machine-translation software _Babylon_ and the #LaTeX package #link("https://ctan.org/pkg/babel")[_Babel_].
Fittingly, the Babel #LaTeX package enhances the capabilities of localisation and internationalisation.
With our Typst #package[Babel] I chose to take the other connotation, of confusion, bafflement and mixing 🙃
== Logo
#wrap-content(
column-gutter: 0.5em,
text(size: 16pt, logo()),
[
The logo features a minimalist icon of the Tower of Babel or a ziggurat; see @licence for attribution.
The background colour is the same shade of turquoise used by #package[Mantys].
]
)
== Copyright and licence <licence>
The this package is released under #link("https://spdx.org/licenses/MIT-0.html")[MIT-0].
#package[Babel]’s logo features an #link("https://thenounproject.com/icon/babel-2526388/")[image] by #link("https://andrejskirma.com/")[<NAME>] which is released under CC~BY-3.0.
I attribute them willingly, as I find the graphics very fitting for the logo.
Go check #link("https://thenounproject.com/creator/andrejs/")[their other icons].
== Versioning and stability <ver>
#package[Babel] follows the Semantic Versioning scheme (#link("https://semver.org/spec/v2.0.0.html")[SemVer 2.0.0]).
While it is fully usable in its current form (version `0.*.*`), changes to the API might occur in future versions.
This should not pose a problem:
- When you import a package in Typst you can indicate the version (for example, `#import "@preview/example:0.1.0"`), so no surprises should occur.
- Changes to the API will be clearly indicated in the documentation.#footnote[
If the characters replaced by the package change between versions, this is not counted as a change: the whole point is the actual identity of the random characters is, well, random.
Changes to the alphabets (@alphabets) are also considered minor.
]
== Participation and contact <contact>
If there is anything that doesn’t work well or any feature you want added or changed, don’t hesitate to #link("https://codeberg.org/afiaith/babel/issues")[open an issue] on the Git repository, and I will do my best to make the package more useful for you and others.
If you want to contribute code/documentation (changes, additions, corrections, improvements, etc. no matter how small or large), #link("https://codeberg.org/afiaith/babel/pulls")[pull requests] are very welcome; thanks!
In particular, contributions of alphabets (`src/alphabets.yaml`) are welcome.
This version contains #alphabets.len()~(!) alphabets, but like Pokémon, you gotta catch ’em all… When choosing a font for the script of your alphabet:
- If only basic Latin characters are used, don’t set a font.
- If the new alphabet uses a script already represented on #package[Babel], prefer the font already in use (for example, Gentium Plus for Latin, Greek and Cyrillic, SBL Hebrew for Hebrew,~…).
- Prefer free, gratis and libre open-source fonts (FLOSS).
- Prefer serif#footnote[
Admittedly, for many scripts Noto Sans is the only good FLOSS option.
] fonts (wherever serif makes sense) that go well with Gentium Plus.
Not everyone is familiar with Git, so if that is a problem feel free to contact me in any other way; see #link("https://me.digitalwords.net/")[`https://me.digitalwords.net/`] for contact information.
== Disclaimer
I hold no responsibility for anything that may occur as a result of using this package, nor can I guarantee there are no edge cases where text that should have been redacted stays readable (please do report such cases; see @contact).
If you use this package with actual confidential information, please read the manual (especially @limitations), check the results and understand the risks.
= Usage
== Provided functions <functions>
#import "../src/baffle.typ": punctuation
#tidy-module(
read("../src/baffle.typ"),
include-examples-scope: true,
name: "fonts",
show-outline: false,
scope: (
punctuation: punctuation
)
)
If you frequently use #cmd("baffle") with certain parameters, defining an alias of your own makes things simpler, easier, and more elegant; for example:
#example(```
#let tp = baffle.with(alphabet: "sitelen-pona", punctuate: false, output-word-divider: "\u{200b}")
Hi! #tp[this!] and #tp[that…] are confidential.
```)
=== Using show rules <show-rules>
While surrounding segments of commands is useful for short amounts of text, applying commands to long segments~— or even the whole document~— is cumbersome.
Fortunately, Typst provides us with a clever solution for that: show rules.
Consider the following example:
#example[```
This text is shown as plaintext.
#show: baffle.with(alphabet: "astrology")
Now from here on the text is baffled!
```]
Show rules can be used for redacting strings, regular expressions and other selectors automatically (see the #link("https://typst.app/docs/reference/styling/#show-rules")[documentation]):
#example[```
#show "<NAME>": baffle.with(alphabet: "redaction")
#show regex("[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*"): baffle.with(alphabet: "maze-3")
Her name is <NAME>, and her email is `<EMAIL>`.
```]
At the moment (version 0.11.0) there is no way to revoke show rules#footnote[
It is planned, though.
See the #link("https://typst.app/docs/roadmap/")[roadmap] and #link("https://github.com/typst/typst/issues/420")[this issue].
].
As a workaround, bracketing the relevant segments can limit the scope of a show rule:
#example[```
This is plaintext.
#[
#show: baffle
A baffled part of the document.
]
Plaintext again.
```]
=== Limitations and considerations <limitations>
==== General matters
===== Educated guesses
From an information-theoretical point of view, the #cmd("baffle") loses a lot of information: it may retain only the length of each word, capitalisation, and punctuation, and each of the three can be turned off.
Unlike encryption, where by definition the plaintext can be deciphered using the proper technique and secret information, here the original text cannot be recovered algorithmically.
Given certain conditions, educated guesses can be made though: for example (and an extreme one at that…), if you see a baffled word that is 27 letters long, you can assume with confidence that it is _electroencephalographically_ if the text deals with neurology or _ethylenediaminetetraacetate_ if it deals with chemistry.
In more realistic scenarios contextual information and the nature of the text (rigid forms are more predictable than literary prose, for example) can assist in making educated guesses.
For maximal obfuscation, turn word division, capitalisation and punctuation off, but realistically I don’t think this is needed, and the result might be less aesthetically pleasing, depending on the alphabet used.
Note that #cmd("baffle") retain information about the length of words in characters#footnote[
Some alphabets may increase the number of characters, as they include multi-character ‘letters’ (e.g. digraphs).
], not in horizontal length.
This covers some attack vectors involving proportional fonts and kerning, but opens others, based on counting characters.
===== Unintended meanings
Letters are chosen from the alphabets randomly.
In theory, unintended meanings may occur, especially with relatively short words.
Also, note that some scripts (Egyptian hieroglyphs and Phaistos Disc, sitelen sitelen,~…) contain pictograms which might be taboo in your culture.
==== Particular, implementation-dependant matters <particular-limitations>
Limitations concerning the #arg("as-string") argument are discussed in @functions, and those concerning particular alphabets are discussed in @alphabets.
If elements which are included in the table of contents appear within #cmd("baffle"), they appear in plaintext in the PDF table of contents#footnote[
This is the one accessible using a sidebar or the tab key, depending on the PDF reader, not the one typeset in the document itself.
] unless they are bound within a #cmd("baffle") command with #arg("as-string") set to #value(true), in which case the bound text disappears from the PDF table of contents.
The baffled text in a typeset table of contents (#cmd("outline")) is different to the one used in the headings.
== Provided alphabets <alphabets>
In total #alphabets.len() alphabets are provided by #package[Babel].
‘Alphabet’ is used here in the sense used in formal language theory, not linguistics (neither in the narrow nor the wide sense).#footnote[
If these distinctions are not clear to you, read the following Wikipedia articles if you’d like to learn about them: #link("https://en.wikipedia.org/wiki/Alphabet")[Alphabet] (linguistics, both senses) and #link("https://en.wikipedia.org/wiki/Alphabet_(formal_languages)")[Alphabet (formal languages)].
]
Many of the ‘alphabets’ below are not alphabets in the linguistic sense.
#let font-icon = text(font: "Linux Libertine", size: 15pt)[_Aa_]
=== Legend
#table(
columns: 2,
align: (x, y) => if x == 0 { center } else { left },
fa-icon("wikipedia-w"),
[a link to the relevant article in Wikipedia. If anything piques your interest, down to the rabbit hole you go.],
font-icon,
[a link to the font used in the example.],
[`slug`],
[the string you provide the #arg("alphabet") argument with (`arabic` for Arabic, `alchemy` for Alchemical symbols, …).],
)
=== Notes
- The characters from the output alphabet are chosen at random, which has several implications:
- Phonotactics is not taken into consideration.
- The output contains mostly non-words which defy the rules of how words look in the alphabet in question.
- Letter frequency is also not taken into consideration.
At most, the vowels or consonants are superficially doubled in order to account for severe disparity in the type:token ratio.
Because characters are chosen at random final letters have been removed from the Hebrew script and the Canadian Aboriginal syllabics, so they will not occur in incorrect positions.#footnote[
It’s a better compromise not to represent the final forms than to have them occur in incorrect positions.
]
- Some of the scripts~— such as Egyptian and Anatolian hieroglyphs or the sitelen pona and sitelen sitelen scripts~— are normally written with grouping of characters in a non-linear manner. This is not done here, where the glyphs are stringed one after the other in a linear manner.
=== A menu of alphabets
#let rng = suiji.gen-rng(0)
#let sample = "Ni malleviĝu do, kaj Ni konfuzu tie ilian lingvon, por ke unu ne komprenu la parolon de alia. Kaj la Eternulo disigis ilin de tie sur la supraĵon de la tuta tero, kaj ili ĉesis konstrui la urbon."//Tial oni donis al ĝi la nomon Babel, ĉar tie la Eternulo konfuzis la lingvon de la tuta tero kaj de tie la Eternulo disigis ilin sur la supraĵon de la tuta tero."
#let describe-alphabet(slug, alphabet) = [
#box(
fill: luma(245),
inset: 0.75em,
radius: 0.75em,
)[
#strong(alphabet.at("name"))
#if "native" in alphabet.keys() [
#h(1em)#[#set text(font: alphabet.at("font")) if "font" in alphabet.keys();#alphabet.at("native")]
]
#h(1fr)
#text(font: "Iosevka", slug)
#h(1em)
#link("https://en.wikipedia.org/wiki/" + alphabet.at("wiki"), fa-icon("wikipedia-w"))
#if "fonturl" in alphabet.keys() {link(alphabet.at("fonturl"), font-icon)}
\
#[
#set text(lang: alphabet.at("lang")) if "lang" in alphabet.keys()
#box(
width: 100%, height: 1.5em, clip: true, baseline: -0.2em,
// TODO Make less hackish and ugly
box(width: 1000%, baseline: 1.2em)[
#baffle(
sample,
alphabet: slug,
punctuate: if "punctuate" in alphabet.keys() {alphabet.at("punctuate")} else {true},
output-word-divider: if "word-divider" in alphabet.keys() {alphabet.at("word-divider")} else {" "},
as-string: true,
)
]
)
]
#v(-0.5em)#if "note" in alphabet.keys() {
eval(
mode: "markup",
alphabet.at("note"),
scope: (
maze: maze,
arg: arg,
cmd: cmd,
baffle: baffle,
))
}
]
#v(0.5em)
]
#for pair in alphabets.pairs() {
describe-alphabet(pair.at(0), pair.at(1))
}
|
https://github.com/ningvin/typst-resume-template | https://raw.githubusercontent.com/ningvin/typst-resume-template/main/README.md | markdown | Apache License 2.0 | # Typst Resume Template
---
A simple resume template for [typst](https://github.com/typst/typst).
|  |  |  |
| --- | --- | --- |
| [example 1](example-1.typ) | [example 2](example-2.typ) | [example 3](example-3.typ) |
## Getting Started
First clone or download this repository. Then either:
- Upload the files in this repository into a project inside the online [typst app](https://typst.app/) (without the `preview` folder).
- Install typst on your local machine as described [here](https://github.com/typst/typst#install-and-use). Afterwards, you have to invoke typst to convert a `.typ` file to pdf, e.g. like so: `typst example-1.typ`
- Open the repository in VS Code and install the [typst-lsp](https://github.com/nvarner/typst-lsp) extension.
When using typst locally, you need to ensure that the fonts used in your document are installed on your machine. The default font used in this template is [*Roboto*](https://fonts.google.com/specimen/Roboto), but you can easily change that.
## Customizing
Have a look at the examples to see what the template offers and how to use it.
If you want to whip up a quick resume, you can take the example that suits you best and just change the data.
If you need special formatting or want to dig deeper, have a look at [resume.typ](resume.typ). It is littered with comments that hopefully make sense of the mess :-)
## Known Issues
- Transparency of the name box seems to work in the online preview, but is not present in the final pdf
## Acknowledgements
The design is based on a resume I found [here](https://lebenslauf.netlify.app/max-mustermann-lebenslauf.html).
The inner workings are heavily inspired by the official *Department News* template found in the typst app.
## Licensing
This project is licensed under the [Apache 2.0 license](LICENSE), with the these exceptions:
- The following icons are taken from [*Font Awesome Free*](https://github.com/FortAwesome/Font-Awesome) and are licensed under the [CC BY 4.0 License](https://fontawesome.com/license/free):
- [angle-right-solid.svg](angle-right-solid.svg)
- [envelope-solid-white.svg](envelope-solid-white.svg)
- [location-dot-solid-white.svg](location-dot-solid-white.svg)
- [mobile-solid-white.svg](mobile-solid-white.svg)
- [phone-solid-white.svg](phone-solid-white.svg)
- The following images were created by me and are licensed under the [CC BY 4.0 License](https://creativecommons.org/licenses/by/4.0/):
- [user-banner.png](user-banner.png)
- [user.png](user.png)
|
https://github.com/jinhao-huang/SimplePaper | https://raw.githubusercontent.com/jinhao-huang/SimplePaper/main/examples/homework.typ | typst | MIT License | #import "simplepaper.typ": *
#show: project.with(
title: "编译原理作业",
authors: (
(
name: "张三",
),
),
)
#problem[
下列文法是一个无符号二进制浮点数的文法。试根据该文法,编写一个语法制导定义,描述由 S 生成的二进制数(浮点数)的数值计算。
$
S -> L . L \
L -> L B | B \
B -> 0 | 1
$
]
#solution[
设L具有继承属性side和综合属性m
L.side表示小数点的左边或右边(1表示左边0表示右边),L.m二进制串的长度即幂次。
#table(
columns: (auto, 1fr),
inset: 10pt,
align: center,
[产生式], [语义规则],
[$S -> L_1 . L_2$], [
$
L_1 . "side" = 1 \
L_2 . "side" = 0 \
S . "val" = L . "val"
$
],
[$S -> L$], [
$
L . "side" = 1, \
S . "val" = L . "val"
$
],
[$L -> L_1 B$], [
$
L_1 . "side" = L . "side" \
L . m = L_1 . m + 1 \
L . "val" = L_1 . "side" ? L_1 . "val" * 2 + B . "val" : L_1 . "val" + (B . "val" >> m)
$
],
[$L -> B$], [
$
L . m = 1 \
L . "val" = L . "side" ? B . "val" : B . "val" \/ 2
$
],
[$B -> 0$], [
$
B . "val" = 0
$
],
[$B -> 1$], [
$
B . "val" = 1
$
]
)
]
#problem[
设下列文法生成变量的类型说明:
$
D -> "id" L \
L -> , "id" L | : T \
T -> "integer" | "real"
$
构造一个翻译模式,把每个标识符的类型存入符号表。
]
#solution[
设 D, L, T 有综合属性 type。
addtype(id, type)将标识符 id 及其类型 type 填入符号表中。
翻译模式如下:
#table(
columns: (auto, 1fr),
inset: 10pt,
align: center,
[$D -> "id" L$], [${"addtype"("id" . "entry", L . "type")}$],
[$L -> , "id" L_1$], [${"addtype"("id" . "entry", L_1 . "type" ; L . "type" := L_1 . "type")}$],
[$L -> :T$], [${L . "type" := T . "type"}$],
[$T -> "integer"$], [${T . "type" := "integer"}$],
[$T -> "real"$], [${T . "type" := "real"}$]
)
]
#problem[
文法G的产生式如下:
$
S -> (L) | a \
L -> L , S | S
$
+ 试写出一个语法制导定义,它输出配对括号个数;
+ 写一个翻译方案,打印每个a的嵌套深度。如((a),a),打印2,1。(思考:如果要求出a出现的次数,怎么办?)
]
#solution[
1.
#table(
columns: (auto, 1fr),
inset: 10pt,
align: center,
[产生式], [语法规则],
[$S -> (L)$], [$S.h := L.h + 1$],
[$S -> a$], [$S.h := 0$],
[$L -> L_1 , S$], [$L.h := L_1.h + S.h$],
[$L->S$], [$L.h := S.h$],
[$S' -> S$], [$"print"(S.h)$]
)
2.
$
S'->{S.d:=0;}S \
S -> ({L.d := S.d + 1} L) \
S -> a {"print"(S.d)} \
L -> {L_1.d := L.d} L_1 , {S.d := L.d}S \
L -> {S.d := L.d} S
$
] |
https://github.com/SnO2WMaN/typst-tarski-undefinability-report | https://raw.githubusercontent.com/SnO2WMaN/typst-tarski-undefinability-report/main/main.typ | typst | Creative Commons Zero v1.0 Universal | #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: project.with(
title: "Tarskiの真理定義不可能性定理について",
authors: (
"SnO2WMaN",
),
)
//空きすぎなのでなんとかする
#let to = $arrow$
#let power = $arrow.t$
= 中学生の算数 <jha>
次の<EMAIL>[問題] と@jha.j[問題] は日本の中学生なら出来るらしい.
なおここでは,数とは$0,1,2,3,dots$とします.
== 計算 <jha.c>
次の式を計算してください.$+$は数の足し算,$times$は数の掛け算,$power$は数の冪算とします.
なお,普通は冪算$2 power 3$は$2^3$のように表記されるでしょう.
+ $2$の次の数
+ $1 + 2$
+ $4 + 0$
+ $3 times 2$
+ $7 times 0$
+ $2 power 3$
+ $4 power 0$
== 判定 <jha.j>
次の主張が正しいか誤っているかを確かめてください.ただし,$x$は数であるとします.
+ $1 + 1 = 2$である.
+ $2 + 4 = 5$である.
+ $4 + 5 = 9$ではない.(この主張は「$4 + 5 eq.not 9$である」と同等である.)
+ $11 < 4 times 3$である.
+ $x times 4 = 12$となるような$x$が存在する.
+ $x times 7 = 23$となるような$x$が存在する.
+ 全ての$x$について,$0 < 2^x $である.
+ $x times 3 = 129$となるような$x$は存在しない.(この主張は「全ての数$x$について$x times 3 eq.not 129$である」と同等である.)
+ $x$の次の数が$0$であるような$x$が存在する.
== 数 <Num>
#let Num = $cal(N)$
ここで考えた数$0,1,2,3,dots$の加算無限集合を,数の集合,または単に,数と呼び,$Num$と表すことにする.
すなわち,$Num = {0,1,2,dots}$である.
=== 中学生の算数
#let nextnum = $sans("succ")$
@jha.c[問題] と@jha.j[問題] で行った「次の数」演算$nextnum$,足し算$+$,掛け算$times$,冪算$power$,等価判定$=$,大小判定$<$について考える.
「どうやって計算,判定するのか」の厳密な定義は一旦棚上げし,我々のよく知っている方法で計算できるとする.以下を注意しておく.
- $nextnum$は$Num$上の1項演算$Num to Num$である.
- $+,times,power$は$Num$上の2項演算$Num^2 to Num$である.
$BB eq.def { top,bot }$とする.$=,<$は関数$Num^2 to BB$である.例えば$1$と$3$について$1 = 3$を判定したとき,正しいなら$top$を,誤っているなら$bot$を返す関数であると考える.
$nextnum,+,times,power,=,<$をまとめて中学生の算数と呼ぶことにする.
=== 素数は中学生の算数の範囲なのか?
一般に,素数とは1と自分自身を除いた全ての数で割り切ることが出来ない2以上の数であると定義される.
素数は,中学生の算数の範囲で十分に定義出来ることを示す.
+ 「$x$が$y$を割り切る」という判定$x|y$は「$y = x times z$となるような$z$が存在する」と言い換えることが出来るので,中学生の算数の範囲である.
+ 「$x$が$y$を割り切ることは出来ない」という判定も中学生の算数の範囲である.
3. 「$x$は2以上である」という判定は「$x=2$または$2 < x$である」と言い換えられるので,中学生の算数の範囲である.
+ 「$x$を割り切る$y$は存在しない」という判定は中学生の算数の範囲である.
5. 任意の$n in Num$について「$n$は2以上であり,なおかつ,全ての$y$について$y$が1と$n$ではないならば$y$が$n$を割り切ることは出来ない」という判定は中学生の算数の範囲である.
最後に定義した判定は,まさに素数の定義である.
ところで上の,日本語における定義には「または」「なおかつ」「ならば」「ではない」「〜となるものが存在する」「全ての〜について」という論理的な操作が自然に登場して,またこれらは日本語話者として自然な形で扱えた.これらをより形式的に扱えないだろうか,という要請に答えるものが,以下で定義する1階論理である.
= 1階論理
1階論理とは @1stlogic[定義] で定義されるシステムである.そしてこの文書では2階論理などを考えないので,以降は単に論理と呼ぶ.
== 言語について
最も土台となる言語という概念を考える.言語とは記号列を生成するシステムであり,項と論理式という概念はあるルールを満たした特定の記号列であると考えられる.
=== 言語
#let lang = $cal(L)$
#let alphabet = $Sigma$
言語#lang は,次の2つの要素で構成される概念である.
+ アルファベット$alphabet_lang$
+ 記号$f_0,dots,f_(n-1),P_0,dots,P_(m-1)$に対して何個までプライム$'$を付けてよいか?の宣言
==== アルファベット
言語#lang のアルファベット$alphabet_lang$とは,次の8個以上の記号の集まりのことである.
わかりやすくするため,赤文字であるものが一つの記号である.
#let alphabetelm(elm) = [#text(fill: red)[#elm]]
+ #alphabetelm[$'$](プライムと呼ぶ.)
+ #alphabetelm[$v$]
+ #alphabetelm[$f_0$],#alphabetelm[$f_1$],(中略),#alphabetelm[$f_(n-1)$](ただし$f_2$はあるが$f_1$はないといったケースも許す.)
+ #alphabetelm[$P_0$],#alphabetelm[$P_1$],(中略),#alphabetelm[$P_(m-1)$](ただし$P_2$はあるが$P_1$はないといったケースも許す.)
+ #alphabetelm[$not$]
+ #alphabetelm[$arrow$]
+ #alphabetelm[$exists$]
+ #alphabetelm[$($](左カッコと呼ぶ.)
+ #alphabetelm[$)$](右カッコと呼ぶ.)
+ #alphabetelm[$,$](コンマと呼ぶ.)
==== プライムの個数の宣言
言語#lang のアルファベット $alphabet_lang$が記号$f_i$および$P_j$を持っているとき,$f_i$と$P_j$に何個までプライム$'$を付けることが出来るかは,#lang の要素として宣言されていなければならない.
「$f_0$にはプライムを0個付けることが出来る.」すなわち「$f_0$にはプライムを付けてはならない.」という宣言も可能である.
===== プライムの個数宣言の例
例えば,ある言語 $lang_1$のアルファベット$alphabet_(lang_1)$が$f_2$を持っているとき,「$lang_1$では$f_2$にプライム$'$を2個まで付けることが出来る.」と宣言しなければならない.
他方,別の言語 $lang_2$のアルファベット$alphabet_(lang_2)$も$f_2$を持っていたとしても,「$lang_2$では$f_2$にプライム$'$を付けてはならない.」と宣言されているなら,言語$lang_1$と$lang_2$は区別される.
=== #lang の記号列
言語 #lang のアルファベット $alphabet_(lang)$ の要素を任意個並べたものは#strong[#lang の記号列]と呼ばれる.
#let strings(l) = $Sigma^*_#l$
#lang の記号列を全て集めたものは #strings(lang) と表記する.
=== #lang の項 <term>
言語 #lang の記号列のうち,次の条件を満たすものは#strong[#lang の項]と呼ばれる.
// TODO:
=== #lang の論理式 <formula>
言語 #lang の記号列のうち,次の条件を満たすものは#strong[#lang の論理式]と呼ばれる.
// TODO:
=== #lang の略記
以下の略記は,#lang を問わず用いて良いものとする.$phi,psi$は#lang の論理式とし,$w$は#lang の変項であるとする.
- $phi or psi$は$phi to psi$の略記とする.
- $phi and psi$は$not (not phi and not psi)$の略記とする.
- $phi arrow.l.r psi$は$(phi to psi) and (psi to phi)$の略記とする.
- $forall_w phi$は$not exists_w not phi$の略記とする.
- $v_m$はプライム$'$が$0 lt.eq m$個付いた$v$,すなわち$v^(overbrace(prime dots.h.c prime, 0 lt.eq m))$の略記とする.
== 構造と解釈について
言語#lang は単なる記号列の生成システムであり,それ自体では何も意味しない.#lang の記号列,より正確には#lang の項と論理式を意味を持たせるためには,構造と解釈と呼ばれる概念を考える必要がある.
#lang の項や論理式は,#lang の解釈によって,意味のあるものとして扱うことが出来るのである.
=== 構造
#let structure = $cal(M)$
#let domain = $D$
#let assignment = $F$
言語#lang の上の構造 $cal(M)_(lang)$ とは,次の2つの要素で構成される概念である.
+ 領域 $domain_(cal(M))$
+ 対応付け $assignment_(cal(M))$
このことを,$structure_lang colon.eq angle.l domain_(cal(M)),assignment_(cal(M)) angle.r$と表記する.
==== 領域
構造$structure_lang$の領域$domain_(cal(M))$ とは,何らかの集合であるとする.
==== 対応付け
構造$structure_lang$の対応付け$assignment_(cal(M))$とは,特定の#lang の記号列に対して$domain_(cal(M))$ および$BB$上の関数を対応付けるものであるとする.なお,$BB eq.def { top,bot }$とする.
+ #lang の記号列 $f_i^(overbrace(prime dots.h.c prime, 0 lt.eq m))$に対して,関数$f^m_i:(domain_(cal(M)))^i arrow domain_(cal(M))$を対応付ける.特に$i=0$のとき$f^m_0 in domain_(cal(M))$である.
+ #lang の記号列 $P_i^(overbrace(prime dots.h.c prime, 0 lt.eq m))$に対して,関数$P^m_i:(domain_(cal(M)))^i arrow BB$を対応付ける.特に$i=0$のとき$P^m_0 in BB$である.
+ それ以外の記号列に対しては,$assignment_(cal(M))$は何も対応付けない.
#lang の記号列$sigma$が1または2の条件を満たすなら,対応付けられる関数を$assignment_(cal(M))(sigma)$と表す.
=== 解釈
#let interpret = $cal(I)$
#let eval = $epsilon$
#lang 上の解釈 $interpret_lang$とは,次の2つの要素で構成される概念である.
+ 言語#lang の上の構造 $structure_lang colon.eq angle.l domain_(cal(M)),assignment_(cal(M)) angle.r$
+ 付値 $eval_(cal(I))$
このことを,$interpret(lang) colon.eq angle.l structure_lang, eval_(cal(I)) angle.r$と表記する.
==== 付値
構造$interpret_lang$の付値 $eval_(cal(I))$ とは,特定の#lang の記号列に対して$d in domain$を割り当てるものとする.なお,$BB eq.def { top,bot }$とする.
==== 付値の変異
// TODO:
==== 解釈の変異
// TODO:
#let IP(expr) = $bracket.l.double #expr bracket.r.double_(interpret_lang)$
==== 項の解釈
#lang の項$tau$を解釈$interpret_lang$で解釈することを,$IP(tau)$と表記する.
@term[項の定義] に沿って,項の解釈を以下のように定める.
==== 論理式の解釈
#lang の項$phi$を解釈$interpret_lang$ で解釈することを,$IP(phi)$と表記する.
@formula[論理式の定義] に沿って,論理式の解釈を以下のように定める.
==== 真,偽,充足
論理式$phi$が$top$として解釈されることを,$phi$は真として解釈される,あるいは単に,$phi$は真であるという.
逆に,論理式$phi$が$bot$として解釈されることは,$phi$は偽として解釈される,あるいは単に,$phi$は真であるという.
論理式$phi$がある解釈$interpret_lang$ で真であるとき,$interpret_lang$ は$phi$を充足するという.
== 論理 <1stlogic>
#let logic(l) = $sans(#l)$
=== 定義
論理$logic(L)$とは,ある言語$lang_(logic(L))$と,$lang_(logic(L))$上に定まる構造$structure_(lang_(logic(L)))$の2つの要素からなる概念である.
=== 略称
正確に言ったり表記するとあまりにも長く煩雑なので,以下の略称を定める.
- 言語$lang_(logic(L))$のアルファベット$alphabet_(lang_(logic(L)))$を,$logic(L)$のアルファベット$alphabet_(logic(L))$と呼ぶ.
- 言語$lang_(logic(L))$で定まる項を,$logic(L)$の項と呼ぶ.
- 言語$lang_(logic(L))$で定まる論理式を,$logic(L)$の論理式と呼ぶ.
- 構造$structure_(lang_(logic(L)))$を,$logic(L)$の構造$structure_(logic(L))$と呼ぶ.
- 構造$structure_(logic(L))$の領域$domain_(cal(M))$を,$logic(L)$の領域$domain_(logic(L))$と呼ぶ.
- 構造$structure_(logic(L))$の対応付け$assignment_(cal(M))$を,$logic(L)$の対応付け$assignment_(logic(L))$と呼ぶ.
- 言語$lang_(logic(L))$の解釈$interpret_(lang_(logic(L))) colon.eq angle.l structure_(logic(L)), eval_(cal(I)) angle.r$を,$logic(L)$の解釈と呼ぶ.
また,論理$logic(L)$について考えていることが明らかなら,$logic(L)$は省略することもある.
=== 開論理式
=== 文
$logic(L)$の論理式$phi$が開論理式ではないなら,$phi$は$logic(L)$の文であるという.
==== 文についての注意
$logic(L)$の文は,任意の$logic(L)$の解釈で必ず真か偽のどちらかである.
すなわち,何も付値が固定されていない解釈で解釈したとしても,必ず真偽が言えるということである.
また当然ながら,$logic(L)$の文がある$logic(L)$の解釈$interpret_1$で真なら,別の$logic(L)$の解釈$interpret_2$でも真である.同様に,$interpret_1$で偽なら$interpret_2$でも偽である.
この観点から,文$phi$は$logic(L)$は真である,または,文$phi$は$logic(L)$で偽である,という.
=== 条件付き文
$logic(L)$の論理式が$v_0,dots,v_(n-1)$に開いた開論理式であるとする.この全ての自由変項$v_0,dots,v_(n-1)$をそれぞれ$d_0,dots,d_(n-1) in domain_(logic(L))$で閉じた論理式は,$logic(L)$の$v_0 colon.eq d_0,dots,v_(n-1) colon.eq d_(n-1)$での条件付き文であるという.
すなわち,$phi$が$v_0,dots,v_(n-1)$に開いているとき,$phi bracket.l v_0 colon.eq d_0,dots.h.c, v_(n-1) colon.eq d_(n-1) bracket.r$が$v_0 colon.eq d_0,dots,v_(n-1) colon.eq d_(n-1)$での条件付き文である.ただし,$d_0,dots,d_(n-1) in domain_(logic(L))$とする.
定義より明らかだが,条件付き文$phi bracket.l v_0 colon.eq d_0,dots.h.c, v_(n-1) colon.eq d_(n-1) bracket.r$の解釈を行う解釈$interpret$には「少なくとも$v_0,dots,v_(n-1)$を$d_0,dots,d_(n-1) in domain_(logic(L))$に割り当てる付値$eval$を持つ」という制約が付く.
==== 条件付き文の注意
注意をもう一度踏まえるが,条件付き文はあくまでも解釈に制約を付けるというだけであって,実際に論理式を書き換えているわけではない.
しかし,直感的にも分かるとおり,論理式$phi$を条件付き文として解釈した結果と,$phi$に現れる$v_0,dots,v_(n-1)$を実際に$d_0,dots,d_(n-1) in domain_(logic(L))$に書き換えた新しい文$phi'$の解釈の結果は一致する.
= 冪乗付き算術
#let AE = $logic("AE")$
これから,冪乗付き算術 #AE と呼ばれる論理を定義する.
=== 冪乗付き算術 <AE>
論理#AE は冪乗付き算術と呼ばれる.
=== 冪乗付き算術の言語 $lang_AE$ <AE.lang>
次のように定める$lang_AE$は冪乗付き算術の言語と呼ばれる.
+ $lang_AE$のアルファベット$alphabet_AE$は記号$f_0,f_1,f_2,P_2$を含んだ12個の記号の集まりであるとする.
+ $f_0,f_1$には,プライムを付けてはならない.
+ $f_2$には,プライムを2個まで付けて良い.
+ $P_2$には,プライムを1個まで付けて良い.
==== $lang_AE$での略記 <AE.lang.abbrev>
非常に煩雑になるため,以下の略記を用いる.以下,$tau_0,tau_1$は項,$phi$は論理式,$w$は変項であるとする.
#let zero = $mono(0)$
#let suc = $mono(s)$
+ $zero$は$f_0$の略記とする.
+ $suc(tau_0)$は$f_1(tau_0)$の略記とする.
+ $mono(1)$は$suc(zero)$の略記,$mono(2)$は$suc(mono(1))$の略記,$mono(3)$は$suc(mono(2))$の略記のように再帰的に略記を定める.
+ $+$は$f_2$の略記とする.また,$(tau_0 + tau_1)$は$f_2(tau_0,tau_1)$の略記とする.
+ $times$は$f_2'$の略記とする.また,$(tau_0 times tau_1)$は$f_2'(tau_0,tau_1)$の略記とする.
+ $power$は$f_2''$の略記とする.また,$(tau_0 power tau_1)$は$f_2''(tau_0,tau_1)$の略記とする.
+ $=$は$P_2$の略記とする.また,$(tau_0 = tau_1)$は$P_2(tau_0,tau_1)$の略記とする.
+ $<$は$P_2'$の略記とする.また,$(tau_0 < tau_1)$は$P_2'(tau_0,tau_1)$の略記とする.
+ $(tau_0 eq.not tau_1)$は$not(tau_0 = tau_1)$の略記とする.
+ $(tau_0 lt.eq tau_1)$は$((tau_0 < tau_1) or (tau_0 = tau_1))$の略記とする.
+ $exists_(w < tau_0) phi$は$exists_w ((w < tau_0) and phi)$の略記とする.
+ $exists_(w lt.eq tau_0) phi$は$exists_w ((w lt.eq tau_0) and phi)$の略記とする.
+ $forall_(w < tau_0) phi$は$forall_w ((w < tau_0) and phi)$の略記とする.
+ $forall_(w lt.eq tau_0) phi$は$forall_w ((w lt.eq tau_0) and phi)$の略記とする.
+ カッコ$(,)$は,論理式の解釈を変えない範囲で自由に省略できるとする.
==== $lang_AE$での項や論理式の例
// TODO:
=== 冪乗付き算術の構造 $structure_AE$ <AE.structure>
次のように定める$structure_AE$は冪乗付き算術の標準構造と呼ばれる.
+ $structure_AE$の領域$domain_AE$は@Num[定義]で定義した数$Num$であるとする.
+ $structure_AE$の割り当て$assignment_AE$を次のように定義する.ただし,ここでは混乱を避けるため,@AE.lang.abbrev[定義]で定めた略記$zero,suc,+,times,power,=,<$を$zero_(lang_AE),suc_(lang_AE),+_(lang_AE),times_(lang_AE),power_(lang_AE),=_(lang_AE),<_(lang_AE)$と書く.
+ $zero$は数$0$に対応させる.
+ $suc_(lang_AE)$は中学生の算数の「次の数」演算$nextnum$に対応させる.
+ $+_(lang_AE)$は中学生の算数の足し算$+$に対応させる.
+ $times_(lang_AE)$は中学生の算数の掛け算$times$に対応させる.
+ $power_(lang_AE)$は中学生の算数の冪算$power$に対応させる.
+ $=_(lang_AE)$は中学生の算数の等価判定$=$に対応させる.
+ $<_(lang_AE)$は中学生の算数の大小判定$<$に対応させる.
=== 冪乗付き算術の解釈の例
@AE.lang[定義]と@AE.structure[定義]より,適切な$AE$の解釈の元では,$AE$の項は数,$AE$の論理式は中学生の算数における何らかの式として解釈される.これを観察してみよう.
// TODO:
= Gödel数
ここからは,再び言語$lang$だけの世界に立ち戻り,$lang$の記号列に一意に数$n in Num$を割り当てることを考える.このように一意に割り振られる数はGödel数と呼ばれる.また割り当てることはGödel数化やGödelナンバリングと呼ばれる.
== アルファベットのGödel数
#let goedelnumA(a) = if a == none [$g^alphabet$] else [$g^alphabet(#a)$]
言語$lang$のアルファベット$alphabet_lang$の要素に対して,以下のように数$n in Num$を割り振る写像$goedelnumA("_") : Sigma_lang to Num$を考える.// TODO: goedelnumA
+ $goedelnumA(') colon.eq 1$
+ $goedelnumA(not) colon.eq 2$
+ $goedelnumA(to) colon.eq 3$
+ $goedelnumA(exists) colon.eq 4$
+ $goedelnumA("(") colon.eq 5$
+ $goedelnumA(")") colon.eq 6$
+ $goedelnumA(",") colon.eq 7$
+ $goedelnumA(f_i) colon.eq 9+2i$
+ $goedelnumA(P_i) colon.eq 10+2i$
$lang$のアルファベットに割り当てられた以上の数は,$lang$のアルファベットのGödel数と呼ばれる.
== 記号列のGödel数
まず,$lang$のアルファベットのGödel数の中で最も大きい数を$m$とする.
$lang$のGödel数の基数$p_lang in Num$とは,$m$より大きい最小の素数である.
== $lang_AE$のGödel数の例
|
https://github.com/HowToGibbon/PF_exam_summary | https://raw.githubusercontent.com/HowToGibbon/PF_exam_summary/main/PF_exam_summary_HS23.typ | typst | #let is_cheat_sheet = true;
#set page(columns: 5, flipped: true, margin: 10pt) if is_cheat_sheet
#set columns(2, gutter: 2pt)
#set text(size: 12pt, font: "Arial")
#set text(size: 5pt, font: "Arial") if is_cheat_sheet
#set quote(block: true)
#show heading: it => {
if (it.level == 1 and is_cheat_sheet) {
block(
fill: navy,
above: 2pt,
below: 2pt,
width: 100%,
height: 7pt,
inset: 1pt)[
#text(fill: white, size: 6pt)[#it]
]
}
else if (it.level == 2) {
block(
fill: color.rgb("#c6edf6"),
above: 2pt,
below: 2pt,
width: 100%,
height: 7pt,
inset: 1pt)[
#text(fill: navy, size: 6pt)[#it]
]
}
else if (it.level == 3) {
block(
above: 2pt,
below: 2pt,
width: 100%,
height: 6pt,
inset: 1pt,
stroke: (bottom: 0.5pt + blue))[
#text(fill: blue, size: 6pt)[#it]
]
}
else {
it
}
}
#show raw: it => {
let backgroundColor = luma(0xF0)
if (it.block) {
block(
fill: backgroundColor,
inset: 5pt,
radius: 3pt,
it,
)
} else {
box(
fill: backgroundColor,
outset: 2pt,
radius: 2pt,
it,
)
}
}
#let pattern(intent, problem, solution, implementation: [], relations: [], example: []) = [
#if intent != [] {
[*Intent:* #intent]
}
#if problem != [] {
if intent != [] {
[\ *Problem:* #problem ]
} else {
[*Problem:* #problem ]
}
}
#if solution != []{
if intent != [] or problem != [] {
[\ *Solution:* #solution]
} else {
[*Solution:* #solution]
}
}
#if implementation != [] {
[\ *Implementation:* #implementation]
}
#if example != [] {
[\ *Example:* #example]
}
#if relations != [] {
[\ *Relations:* #relations]
}
]
#let benefit(term, color: color.rgb("#0da53a")) = {
text(color, box[👍 #term])
}
#let liability(term, color: color.rgb("#be0f12")) = {
text(color, box[👎 #term])
}
#let combine_with(term, color: orange) = {
box(
fill: color,
inset: 1pt,
baseline: 1.2pt,
radius: 1pt,
[🔗 #term]
)
}
#let colorbox(title: "title", color: none, radius: 2pt, width: auto, body) = {
let strokeColor = luma(70)
let backgroundColor = white
if color == "red" {
strokeColor = rgb(237, 32, 84)
backgroundColor = rgb(253, 228, 224)
} else if color == "green" {
strokeColor = rgb(102, 174, 62)
backgroundColor = rgb(235, 244, 222)
} else if color == "blue" {
strokeColor = rgb(29, 144, 208)
backgroundColor = rgb(232, 246, 253)
} else if color == "yellow" {
strokeColor = rgb(255, 170, 29)
backgroundColor = rgb(255, 255, 0)
}
return box(
fill: backgroundColor,
stroke: 1pt + strokeColor,
radius: radius,
width: width
)[
#block(
fill: strokeColor,
inset: 4pt,
radius: (top-left: radius, bottom-right: radius),
)[
#text(fill: white, weight: "bold")[#title]
]
#block(
width: 100%,
inset: (x: 3pt, bottom: 3pt, top: -4pt)
)[
#body
]
]
}
#let togglebox(body) = {
if is_cheat_sheet == false {
colorbox(
title: "Toggle",
color: "yellow",
body
)
}
}
#togglebox[
= GoF (Gang of Four) Patterns
Most commonly used GoF Patterns.
#table(
columns: (auto, auto, auto),
inset: 5pt,
[Creational],
[Structural],
[Behavioral],
[
- Abstract Factory
- Prototype
- Singleton
- Factory Method
],
[
- Adapter
- Composite
- Decorator
- Flyweight
- Facade
- Proxy
],
[
- Command
- Iterator
- Mediator
- Memento
- Observer
- State
- Strategy
- Visitor
]
)
]
= Pattern Overview
#togglebox[
#image("images/themenübersicht.png")
]
#image("images/guru_patterns.png")
= Creational
== Abstract Factory
#image("images/solution_abstract_factory.jpg")
Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
== Prototype (Clone)
#image("images/solution_prototype.png")
Specify the kinds of objects to create using a prototypical instance, and reate new objects by copying this prototype.
#liability[Does not describe how the manager is implemented]
== Factory Method
#image("images/solution_factory_method.png")
#pattern(
[Abstract creation, Improve Testability],
[Creation interface on super, implementation in child],
[Factory method to defer insanitation to subclass (allows superclass to alter type of objects that will be created)],
implementation: [Testing: override with Mock creation],
relations: [Setting Context by #combine_with[Template Method], #combine_with[Abstract Factory ]]
)
#colbreak()
== Singleton
#pattern(
[Guaranteeing that only one global object of class exists],
[Some classes should have only one instance],
[Private construction and static class factory method],
implementation: [`static Instance()` can use Lazy initialization],
relations: [Setting context by (Class Factory Method)]
)
#benefit[Sole instance, variable number of instances, flexibility]
#liability[Global variable, tight coupling, prevents polymorphism]
#togglebox[
=== Example
```java
public class Singleton {
private static class InstanceHolder {
// Singleton will be instantiated as soon as the
// ClassLoader instantiates the overlying class
private static final Singleton INSTANCE = new Singleton();
}
public static Singleton getInstance() {
return InstanceHolder.INSTANCE;
}
protected Singleton() { } // allow subclassing
}
```
]
== Registry (Singleton Mitigation)
#pattern(
[Guaranteeing that only one global object of class exists],
[Some classes should have only one instance],
[Classes register their "Singleton" in a well-known *registry*],
implementation: [Interface for contained "Singletons" for testability]
)
#benefit[More flexible than Singleton, Benefits of Singleton]
#liability[No object creation responsibility, Liabilities of Singleton]
== Monostate (Singleton Mitigation)
#pattern(
[Multiple instances in same state and behavior],
[Multiple instances should have the same behavior],
[Monostate object: all member variables as static members],
implementation: [Create monostate object and implement all member variables static],
relations: [Specialization of (Singleton)]
)
#benefit[Transparency, Drivability, Polymorphism, Testability]
#liability[Breaks inheritance hierarchy, no sharing,unexpected behavior]
== Service Locator (Singleton Mitigation)
#image("images/solution_service_locator.png")
#pattern(
[Manage dependencies and maintain loose coupling],
[Global service instance should be exchangeable],
[Locator locates services via Service Finders],
implementation: [],
relations: [Setting context by (Singleton)]
)
#benefit[Only one Singleton, Abstract interface of ServiceLocator]
#liability[ServiceLocator still Singleton, cant replace ServiceLocator]
= Structural
== Adapter (Wrapper)
#image("images/solution_adapter.png", width: 90%)
Convert the interface of a class into another interface expect.
Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
== Composite (Object Tree)
#image("images/solution_composite.png")
Composes objects into tree structures and let you work with these structures as if they were individual objects.
#combine_with[Visitor]
#colbreak()
== Decorator (Wrapper)
#image("images/solution_decorator.png", width: 70%)
Attach additional responsibilities to an object dynamically.
Decorators provide a flexible alternative subclassing for extending functionality.
== Flyweight (Cache)
#image("images/solution_flyweight.png", width: 100%)
#pattern(
[Avoid multiple copies of identical (constant/referenced) objects],
[Storage costs are high because the sheer quantity of objects],
[Use sharing to support large number of fine-grained objects],
implementation: [Manager maintains Flyweight, Flyweights immutable],
relations: [Setting Context by (Pooling), #combine_with[Composite]]
)
#benefit[Reduction of total Instances (Total number, state per object)]
#liability[Can’t rely on object identity,Finding Flyweight maybe costly]
== Facade
#image("images/solution_facade.jpg", width: 80%)
Provides a simplified interface to a library, a framework, or any other complex set of classes. Doesn't Include much logic.
== Pooling (Boxing)
#pattern(
[Fast, predictable access to resource with minimal complexity],
[Slow and unpredictable access to resources],
[Manage multiple instances of one type in a pool, allows reuse],
implementation: [Define max number of resources, Use lazy or eager],
relations: [Setting Context for (Flyweight), #combine_with[acts as Mediator]]
)
#benefit[Performance,Lookup predictable,Simple,Dynamic allocation]
#liability[Management overhead, Synchronization to avoid races]
== Proxy
#image("images/solution_proxy.png", width: 100%)
Provide a surrogate/placeholder for another object to control access to it.
#colbreak()
= Behavioral
== Mediator (Vermittler)
#image("images/solution_mediator_static_structure2.png", width: 80%)
#pattern(
[Promotion of loose coupling, stops explicit referral],
[Strong coupling and complex communication],
[Introduce mediator to abstract interaction of objects],
implementation: [Mediator as Observer, Colleages as subject],
relations: [Refinement(#combine_with[Observer])]
)
#togglebox[
#quote(attribution: [GoF])[Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.]
]
#togglebox[
=== Problem
- Object structures may result in many connections between objects
- Worst case, every object ends up knowing about every other
=== Participants
- *Mediator* (Observable) Encapsulates how a set of objects interact
- *Collegue(s)* (Observers) Refer to Mediator; this promotes loose coupling
=== Solution
Static Structure
#image("images/solution_mediator_static_structure.png", width: 70%)
#togglebox[
Dynamics
#image("images/solution_mediator_dynamics.png", width: 90%)
]
=== Summary
]
#benefit[Colleague classes may become more reusable, low coupling]
#benefit[Centralizes control of communication between objects]
#benefit[Encapsulates protocols]
#liability[Adds complexity]
#liability[Single point of failure]
== Memento (Snapshot)
#image("images/solution_memento_static_structure.png", width: 100%)
#togglebox[
#quote(attribution: [GoF])[Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.]
]
#pattern(
[It separates the serialization logic from the business logic.],
[Objects encapsulate their state, making it inaccessible, record internal state],
[Capture objects internal state in memento],
implementation: [originator creates memento with internals]
)
=== Participants
*Memento*: Stores some or all internal state of the Originator.
\ Allows only the Originator to access its internal information
\ *Originator*:
\ Creates Memento objects to store its internal state at strategic points.
\ Restores its own state to what the Memento object dictates
\ *Caretaker* (Filesystem, Database)
\ Stores the Memento object of the Originator.
\ Cannot explore the contents of or operate on the Memento object.
#togglebox[
#image("images/solution_memento_static_structure.png", width: 90%)
Dynamics
#image("images/solution_memento_dynamics.png", width: 70%)
]
#togglebox[=== Summary]
#benefit[Internal state of an object can be saved and restored at any time]
#benefit[Encapsulation of attributes is not harmed]
#benefit[State of objects can be restored later]
#liability[Creates a complete copy of the object every time, no diffs]
#liability[No direct access to saved state, it must be restored first]
#togglebox[
#colorbox(title: "Discussion")[
_How would it look without Memento?_
```java
class Originator {
private String name;
private String address;
private int age;
// ...
}
```
*Answer:*
Fields would be public so the `Caretaker` can directly access them.
```java
class Originator {
public String name;
public String address;
public int age;
// ...
}
```
_What more modern alternatives do you know?_Define
*Answer:*
- Serialization (Java / C\#)
- Similar to Future Pattern
_Usages of Memento?_
*Answer:*
- Save Files
]
]
== Command
#image("images/solution_command_static_structure.png", width: 95%)
#togglebox[
#quote(attribution: [GoF])[
Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.]
]
#pattern(
[*Encapsulates commands*, so that they can be parameterized *scheduled*, *logged* and/or *undone*.
=> pattern does not describe history/undo management #combine_with[Command Processor]],
[Executed Methods not identifiable in most languages],
[Encapsulate request as object, used for parameterization],
relations: [Setting Context for (Command Processor, Internal Iterator), Setting Context by (Strategy)]
)
#togglebox[
=== Problem
- Decouple the decision of what to execute from the decision of when to execute
- The execution needs an additional parameterization context
=== Solution
Static Structure
#image("images/solution_command_static_structure.png", width: 90%)
Dynamics
#image("images/solution_command_dynamics.png", width: 70%)
]
#togglebox[=== Summary]
#benefit[The same command can be activated from different objects]
#benefit[New commands can be introduced quickly and easily]
#benefit[Command objects can be saved in a command history]
#benefit[Gives inversion of control, encourages decoupling in time and space]
#liability[Large designs with many commands can introduce many small command classes mauling the design]
#colbreak()
== Command Processor (CP)
#pattern(
[Manage command objects so execution can be undone],
[History and undoing of method execution impossible],
[Command Processor manages requests as objects],
implementation: [Command Processor contains Command History],
relations: [Setting Context by (Command, Memento)]
)
#image("images/solution_command_processor_static_structure.png")
#image("images/solution_command_processor_dynamics.png", width: 80%)
#togglebox[
*Manage command objects*, so the execution is separated from the request and the execution can be undone later.
#quote(attribution: [POSA1])[
Separate the request for a service from its execution. A command processor component manages requests as separate objects, schedules their execution, and provides additional services such as the storing of request objects for later undo.
]
=== Problem
- Common UI applications support do and undo multiple undo steps
- Steps forward and backward are accessible in a history
=== Participants
- *Command Processor* a separate processor object can handle the responsibility for multiple command objects (should not clutter command hierarchy nor client code)
- *Command* uniform interface to execute functions
- *Controller* translates requests into commands and transfers commands to Command Processor
=== Solution
Static Structure
#image("images/solution_command_processor_static_structure.png", width: 90%)
Dynamics
#image("images/solution_command_processor_dynamics.png", width: 70%)
=== Implementation
- Command Processor contains a `Stack<Command>` which holds the Command history
- Controller creates the Commands and passes them to Command Processor
=== Summary
]
#benefit[Flexibility, CP and Controller are implemented independently of Cmds]
#benefit[Central CP allows addition of services related to Command execution]
#benefit[Enhances testability, CP can be used to execute regression tests]
#liability[Efficiency loss due additional indirection]
#togglebox[
#colorbox(title: "Discussion")[
_Represents the Command Processor an own Pattern? (or just an implementation detail?)_
*Answer:*
Is not only a simple variation of the Command pattern and is therefore its own pattern.
]
]
== Observer
#image("images/solution_observer.png")
Lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they're observing.
== Visitor
#image("images/solution_visitor_static_structure.jpg", width: 100%)
#pattern(
[Separate algorithms from the objects on which they operate],
[Different algorithms needed to process composite tree],
[New behavior in separate class instead integrating in original],
implementation: [Visitor interface with “visiting” methods e.g. accept()],
relations: [#combine_with[Composite, (Iterator), Chain of Responsibility, Interpreter]]
)
=== Criticism
Visitor can be overused
- Put important stuff into node classes, see Interpreter
Visitor bad when visited class hierarchy changes
- Hard to change or adapt existing visitors
Keeping state during visitation
- State is shared within the visitor object
- But hard when different visitors need to collaborate
#togglebox[
Changing/replacing the behavior on individual elements of a data structure *without changing the elements*.
#quote(attribution: [GoF])[
Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.
]
=== Problem
- Operations on specific classes needs to be changed/added without needing to modify these classes
- Different algorithms needed to process an object tree
=== Solution
Static Structure
#image("images/solution_visitor_static_structure.jpg", width: 80%)
]
#togglebox[=== Summary]
#benefit[Visitor makes adding new operations easy]
#benefit[Separates related operations from unrelated ones]
#liability[Adding new node classes is hard]
#liability[Visiting sequence fix defined within nodes]
#liability[Visitor breaks logic apart]
#togglebox[
#colorbox(title: "Discussion")[
_What other patterns combine naturally with Visitor?_
*Answer:*
- Composite
- Interpreter
- Chain of Responsibility
]
]
#colbreak()
== Iterator Patterns
#pattern(
[Avoid strong coupling between collection and iteration],
[Iteration of collection depends on target implementation],
[]
)
=== External Iterator
#pattern(
[],
[Knowledge for iteration is separate object from target],
[Four operations: create, hasNext, (access, next)],
relations: [Setting Context by (Plain Method Factory)]
)
#image("images/solution_external_iterator_static_structure.png", width: 90%)
#togglebox[
Avoid strong coupling between iteration and collection, generalized and provided in a collection-optimized manner.
#quote(attribution: [GoF])[
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
]
==== Problem
- Iteration through a collection dependents on the target implementation
- Separate logic of iteration into an object to allow multiple iteration strategies
==== Solution 1
- The knowledge for iteration is encapsulated in separate object from the target
- Rendered idiomatically in different languages, e.g.
- Java/C\# For-Each statement
- EcmaScript For-In / For-Of Statements
==== Solution 2
Static Structure
```java
Iterator it = new ArrayList().iterator(); // Initializing iteration
while(it.hasNext()) { // Checking a completion condition
// next() => move to next // Access a current target value
// & return that element // Moving to the next target value
String obj = (String)it.next();
}
```
]
#togglebox[==== Summary]
#benefit[Provides a single interface to loop through any kind of collection]
#liability[Multiple iterators may loop through a collection at the same time]
#liability[Life-cycle management of iterator objects]
#liability[Close coupling between Iterator and corresponding Collection class]
#liability[Indexing _might_ be more intuitive for programmers]
=== Internal Iterator
#pattern(
[],
[],
[Responsibility for iteration on collection, uses Command],
implementation: [Implemented by most Programming langs(`.forEach`)],
relations: [Setting Context by (Command, Strategy)]
)
#image("images/solution_internal_iterator_static_structure.png")
#togglebox[
Iterate collection considering the collection state with reduced state management.
#quote(attribution: "Henney")[
Support encapsulated iteration over a collection by placing responsibility for iteration in a method on the collection. The method takes a Command object that is applied to the elements of the collection.
]
==== Problem
- Iteration management is performed by the collection's user
- Avoid state management between collection and iteration
#togglebox[
==== Solution 1
Static Structure
]
==== Solution 2
- Programming languages already implement Enumeration Method as their loop construct
- Rendered idiomatically in different languages, e.g.
- `Collection.forEach()` / Stream.forEach() method in Java
- `List<T>.ForEach(Action<T>)` in C\#
- `Array.prototype.forEach()` in JavaScript (ES5)
]
#togglebox[==== Summary]
#benefit[Client is not responsible for loop housekeeping details]
#benefit[Synchronization can be provided at the level of the whole traversal rather than for each element access]
#liability[Functional approach, more complex syntax needed]
#liability[Often considered too abstract for programmers]
#liability[Leverages Command objects]
#togglebox[
#colorbox(title: "Discussion")[
_Which kind of iterator has been applied?_
```java
[ 1, 2, 3 ].forEach(
(n) => { console.log(`Item: ${n}\n`); }
);
```
*Answer:* Internal Iterator
_Are internal and external iterators just variants of the Iterator pattern by GoF? Explain:_
*Answer:* Separate Patterns
]
]
=== Batch Method
#pattern(
[],
[Collection and iterating client not on same machine],
[Group multiple collection accesses together],
implementation: [Data structure for calls, Access groups of elements],
relations: [Variation of (Remote Proxy)],
example: [String Builder, SQL Cursors]
)
#benefit[Less communication overhead]
#liability[Increased complexity]
#togglebox[
Iterate a collection over multiple tiers without spending more time in communication then in computation.
#quote(attribution: "Henney")[
Group multiple collection accesses together to reduce the cost of multiple individual accesses in a distributed environment.
]
==== Problem
- Collection and client (iterator user) are not on the same machine
- Operation invocations are no longer trivial
==== Solution
- Define a data structure which groups interface calls on client side
- More appropriate granularity that reduces communication and synchronization costs
- Provide an interface on servant to access groups of elements at once
#colorbox(title: "Discussion")[
_Where have you already encountered the Enumeration Method pattern?_
*Answer:*
- `.forEach` Method
- `for` loops
_Where have you already encountered the Batch Method pattern?_
*Answer:*
- Simplest case: String(Builder), `.toString()` Method
- SQL Cursors or result sets instead of many queries for individual objects
- ADO.NET
]
]
== Strategy
#image("images/solution_strategy.jpg")
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithms.
== Template Method
#image("images/solution_template_method.png", width: 70%)
Define the skeleton of an algorithm in a operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm structure.
e.g.: Document templates
#colbreak()
== State Patterns
*Intent:* Change Behavior based on state
*Problem:* An entity behaves differently depending on its state
=== State (Objects for State)
#image("images/solution_state_static_structure.png", width: 80%)
- Results in a lot of classes and structures
Object acts according to its state without multipart conditional statements.
#togglebox[
#quote(attribution: [GoF])[
Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
]
]
#pattern(
[],
[One class per state with behavior, switch state on context],
[Helper function to change state on context]
)
#togglebox[
==== Problem
- Object's behavior depends on its state, and it must change its behavior at run-time
- Operations have large, multipart conditional statements (flags) that depend on the object's state
==== Solution
One class per state with behavior, switch state on context.
Static Structure
#image("images/solution_state_static_structure.png")
]
#togglebox[==== Summary]
#benefit[Avoid bulky conditional, Single Responsibility, Open/Closed]
#liability[Overkill if only few states, Behavior not in one place]
=== Methods for State
- Propagates a single class with a lot of methods
#togglebox[
==== Solution
- Each state represents a table or record of method references
- The methods referenced lie on the State Machine (context) object
]
#togglebox[==== Summary]
#benefit[Allows a class to express all of its different behaviors in ordinary methods on itself]
#benefit[Behavior is coupled to the state machine, rather than fragmented across multiple small classes]
#benefit[Each distinct behavior is assigned its own method]
#benefit[No object context needs to be passed around, methods can already access the internal state of the state machine]
#liability[Requires an additional two levels of indirection to resolve method call]
#liability[The state machine may end up far longer than was intended or is manageable]
=== Collections for State
- Allows to manage multiple state machines with the same logic
- Splits logic and transaction management into two classes
#combine_with[Objects for State, Methods for State]
#togglebox[
==== Solution
Separate objects into collections according the object state
Dynamics
#image("images/solution_collection_of_state_dynamics.png")
]
#togglebox[==== Summary]
#benefit[No need to create a class per state]
#benefit[Optimized for multiple objects (state machines) in a particular state]
#benefit[Object's collection implicitly determines its state (No need to represent the state internally)]
#liability[Can lead to a more complex state manager]
= Value Patterns
== System Analysis (OOA = Object Oriented Analysis)
An individual is something that can be named and reliably distinguished from other individuals.
#image("images/individuals.png")
Kind of individuals:
- *Event* an individual happening, taking place at a particular point in time.
- *Entity* an individual that persists over time and can change its properties and states from one point in time to another. Some entities may initiate events; some may cause spontaneous changes to their own states; some may be passive
- *Value* an intangible individual that exists outside time and space, and is not subject to change.
#togglebox[
#colorbox(title: [Discussion])[
_Give examples for the following (Event, Entity, Value) categories of things:_
*Answer:*
- *Event:* e.g. User Action
- *Entity:* e.g. Person
- *Value:* e.g. Body Height
]
]
== Domain Driven Design
#image("images/ddd.png")
#colbreak()
== Software Design (OOD)
- *Identity:* significant, or transparent (=transient identity)
- *State:* object stateful or stateless
- *Behavior:* object has significant behavior independent of its state
#image("images/object_aspects.png")
Categories of objects:
\ *Entity:* Express system information (persistent). Distinguished by identity.
\ *Service:* Represents system activities. Distinguished by behavior.
\ *Value:* Content dominant characteristic. No significant enduring identity (transparent).
\ *Task:* Represent system activities. Distinguished by identity and state (e.g. command objects, threads)
#togglebox[
#colorbox(title: [Discussion])[
_Give examples for the following (Entity, Service, Value) categories of things:_
*Answer:*
- *Entity:* Classes e.g. `User.cs`
- *Service:* e.g. `UserService` (stateless, no identity)
- *Value:* Fields e.g. `int age;`
]
]
== Patterns of Value
Patterns of Value addressing value objects in “pure” OO languages.
#image("images/patternsOfValue.png")
== Whole Value
#pattern(
[Express the type of the quantity as a Value Class],
[Primitive quantities have no domain meaning],
[Recover meaning loss by providing dimension and range],
implementation: [Disallow inheritance to avoid slicingValue Object],
example: [`public final class Value{public Value(v){check range}}`]
)
#togglebox[
Represent primitive quantities from the problem domain without loss of meaning.
#quote(attribution: [Henney])[
Express the type of the quantity as a Value Class.
]
=== Problem
- Plain integers and floating-point numbers are not very useful as domain values
- Errors in dimension and intent communication should be addressed at compile time
=== Solution
- Recover loss of meaning and checking by providing a *dimension* and *range*
- Wraps simple types or attribute sets
- Disallows inheritance to avoid _slicing_
]
== Value Object (Value Class)
#pattern(
[Make Comparison based on the value],
[Values by default get compared by the “identity”],
[Override methods in object that should rely on content],
implementation: [Override equality methods e.g. `equals`, `hashCode`, implement Serializable]
)
#togglebox[
Define class to represent values in the system.
#quote(attribution: [Henney])[
Override the methods in Object whose action should be related to content and not identity and implement serializable.
]
=== Problem
- Comparison, indexing and ordering should not rely on objects identity but its content
=== Solution
- Override Object's methods who define equality (e.g. `equals`, `hasCode`)
- Override `toString()` can help using Value Object
]
== Conversion Method
#pattern(
[Convert from one (ctr:more generic) Value Object to another],
[Related value objects should be converted to each other],
[Constructor for Conversion, Conversion instance method (`toOtherType()`) or Class Factory Method (`fromOtherType()`)]
)
#togglebox[
Use different, related Value Objects together without depending on underlying primitive type.
#quote()[
Provide type conversion methods responsible for converting Value Objects into related formats.
]
=== Problem
- Values are strongly informational objects without a role for separate identity
- Often Value Objects are somehow related but cannot be used directly without conversion
=== Solution
- Provide a *constructor* which converts between types (e.g. `Year(int value)`, `String(char[] value)`)
- No additional method call needed
- Most intuitive when applied to convert from more generic to current type
- A *conversion instance method* converts from a user-defined type to another type (e.g. `Date.toInstant()`)
- Create a Class Factory Method with conversion characteristics (e.g. `Date.from(Instant instant`)
]
== Immutable Value
#pattern(
[No side-effects when sharing or aliasing Value Objects],
[Sharing of instances not corresponding to value definition],
[Set internals at construction and allow for no modification],
implementation: [declare all field private final, Mark class as final],
example: [`final class D{ private final Y y; }`]
)
#togglebox[
Share Value Objects and guarantee no side effect problems.
#quote(attribution: [Henney])[Set the internal state of the Value Class object at construction and allow no modifications]
=== Problem
- A value exists outside time and space, and is not subject to change
- Avoid side effect problems when sharing (or aliasing) Value Objects
- Sharing values across Threads requires thread safety
- Values are often threaded as key for associative tables
=== Solution
- Set internal state at construction and declare all fields `private final`
- Mark class as `final`
- no synchronization needed, since no race conditions on the object can occur
```java
public final class Date{
private final Year year;
private final Month month;
private final Day day;
public Date(Year year, Month month, Day day){
// range chekcs...
this.year = Year;
this.month = Month;
this.Day = day;
}
// ...
}
```
]
== Enumeration Values
#pattern(
[Represent a fixed set of constant values and preserve type safety.],
[Fixed range of values should be typed (e.g. months)],
[Whole Value and declare *enum* values as public read only]
)
#togglebox[
Represent a fixed set of constant values and preserve type safety.
#quote()[
Treat each constant as a Whole Value instance declaring it public.
]
=== Problem
A fixed range of values should be typed (e.g. months)
- Using just int constants doesn't help
- Whole Value only half of the solution; range should be constant
=== Solution
- Implement a Whole Value and declare the Enumeration Values as public read-only fields
- Prevent inadvertently changing the constants
```java
public enum Month {
JANUARY(1),
// …
DECEMBER(12);
private final int value;
private Month(int value) {
if (value < 1 || value > 12) {
// avoid careless mistakes, check value range throw new IllegalArgumentException();
}
this.value = value;
}
public int getValue() {
return value;
}
}
```
]
== Copied Value and Cloning
#pattern(
[Values should be modifiable without changing origins state],
[Values by Reference modify internal state],
[Create Copy when sharing so that internal state stays intact],
implementation: [For deep cloning: non-final fields, reassigned clone. `implements Cloneable`, override `clone()` ],
relations: [Setting context for (Prototype)]
)
#togglebox[
Pass a modifiable Value Object into and out of methods without permitting callers or called methods to affect the original object.
#quote()[
Implement Cloneable interface to be used whenever a value object needs to be returned or passed as a parameter.
]
=== Problem
Values should be modifiable without changing the origins internal state.
=== Solution
Create Copy when sharing so that internal state says intact
```java
public final class Date implements Cloneable {
private Year year;
// …
public void nextYear() {
year = new Year(year.getValue() + 1);
}
@Override
public Date clone() { /* … */ }
}
```
]
== Copy Constructor
#pattern(
[Copying without a clone method],
[Within Value Objects what to copy is clear→need no `clone()`],
[Copy constructor consuming instance of same type],
implementation: [final class, no inheritance, create copy constructor]
)
#togglebox[
Copy Objects without the need of implementing `clone` method.
#quote()[
Provide a way to construct an object based on another instance with exactly the same type.
]
=== Problem
Within Value Objects we often know exactly what to copy
=== Solution
- Declare the `class` as final and derive from Object only
- Create a copy constructor, which consumes an instance with same type
```java
public final class Date {
// …
public void nextYear() {
year = new Year(year.getValue() + 1);
}
public Date(Date other) {
// … this.year = new Year(other.year);
}
}
```
]
== Class Factory Method
#pattern(
[Simplification and optimization of construction of Value Objects],
[Construction of Value object sometimes expensive],
[Use static methods instead of ordinary constructor],
example: [`public final class Value {public static Value of (int v)}`],
relations: [Variation for (Flyweight)],
)
#togglebox[
Simplify and potentially optimize construction of Value Objects in expression without introducing new intrusive expressions.
#quote()[
Provide static methods to be used instead of ordinary constructors. The methods return either newly created Value Objects or cached Objects.
]
=== Problem
- Construction of Value Objects objects may be expensive
- But those objects often accommodate the same state
- Different construction logic is required which may result in huge amount of constructors
=== Solution
- Declare static one or more creation method on the `class`
- The static methods could also contain caching mechanisms
```java
Order firstOrder;
// ...
Date date = new Date(Year.of(2020));
firstOrder.setDeliveryDate(date);
public final class Year {
// …
public static Year of(int value) {
// … query cache for given year, otherwise: return new Year(value);
}
private Year(int value) {
// … this.value = value;
}
}
```
]
#colbreak()
== Mutable Companion
#pattern(
[Simplify complex construction of an immutable Value],
[Mutation of immutable object costly or impossible],
[Implement Companion class that supports modifier methods],
implementation: [Factory method on companion for modifications],
relations: [Setting Context for(Builder), Variation(Plain Factory Method)]
)
== Relative Values
#pattern(
[Comparison of value object based on their *state* instead of *identity*],
[Comparison of value objects per default by identity],
[Override/Implement Comparison and equality methods],
implementation: [Provide Bridge method (see value object example)]
)
= CHECKS Patterns
Separate good input from bad, (validation)
== Meaningful quantities
=== Exceptional Behavior
#pattern(
[Handle exceptional circumstances (missing/incorrect)],
[Missing or incorrect values impossible to avoid],
[Distinguished values for exceptional circumstances]
)
=== Meaningless Behavior
#pattern(
[Handle (missing/incorrect) data without overhead],
[How Exceptional behavior handled without throwing errors?],
[Write methods with minimalistic concern for possible failure]
)
= Meta Patterns (Reflection)
#benefit[Adapting software system is easy, Support many changes]
#liability[Non-transparent "black magic" APIs, typesafety, Efficiency]
\ *Dangers:* Overengineering, "Security" undermined, obscure API, config
== Type Object
#pattern(
[Keep common behavior and data in only one place],
[Need to identify instances, behavior depends on their Type],
[Categorize objects by another object instead of a class],
implementation: [Delegate calls to type object, change type -> keep id],
relations: [Setting context by(Strategy), Variation of (State)]
)
#benefit[Extensable categories, avoids explosion, multiple meta levels]
#liability[Mess of classes, lower efficiency, database schema change]
#togglebox[
*Example (Java):* \
Base Level
```java
public class Copy {
protected MediaType type; // typeof this
protected int copyid; // e.g. inventory no
// current identity of this copy
public int getId() {
return copyid;
}
// example of delegation
public String getTypeId() {
return type.getId();
}
public String getTitle() {
return type.getTitle();
}
//…
}
```
Metal Level
```java
public class MediaType {
protected String title;
protected String typeid;
public String getId() {
return typeid;
}
public String getTitle() {
return title;
}
//…
}
```
]
== Property List
#pattern(
[Make Attributes attachable / detachable after compilation],
[(At/De)tachable attributes shared across the class hierarchy],
[Provide objects with a property list that contains attributes]
)
#benefit[Extensibility, attribute iteration, attributes across hierarchies]
#liability[Typesafety, unchecked nameing, runtime overhead, access]
#togglebox[
*Example (Java):* \
```java
public class Graphics {
private Properties pl;
// generic access to properties
public String get(String prop) {
return pl.getProperty(prop, "");
}
public void set(String prop, Object value) {
pl.setProperty(prop, value);
}
}
```
Metal Level
```java
package java.util;
public class Properties {
// …
// Meta Level
public Set<String> stringPropertyNames() {
// …
}
public String getProperty(
String prop, String defaultValue) {
// …
}
public Object setProperty(
String prop, Object value) {
// …
}
}
```
]
== Bridge Method
=> Mitigates liabilities of Property List\
#pattern(
[Provide consistent naming and type safety to property list],
[Inconsistent naming and no type safety on property list],
[Bridge Methods with fixed name and return type]
)
#togglebox[
```java
public class Graphics {
private HashMap<String, Object> pl;
private static final NAME_PROP = "name";
// optional: Bridge Method for property name
public String getName() {
return (String)getProp(NAME_PROP, "name");
}
public void setName(String name) {
return setProp(NAME_PROP, name);
}
// protected access to properties
protected Object get(String prop, String def) {
return pl.getOrDefault(prop, def);
}
protected void set(String prop, Object value) {
pl.put(prop, value);
}
}
```
```java
package java.util;
public class HashMap<Key, Value> {
// …
// Meta Level
public Set<Key> keySet() {
// …
}
public Object get(Key key) {
// …
}
public Value put(Key key, Value value) {
// …
}
}
```
]
== Anything
#pattern(
[Data should be structured recursively],
[(At/De)tachable attributes with structure and recursion],
[Implement representation for simple/complex values],
relations: [Specialization of (Composite),Setting Context by (Property List), Setting Context by (Null Object)]
)
#benefit[Streamable format,flexible interchange across boundaries]
#liability[Typesafety, unapparent intent, lookup overhead]
=== When to use what?
Reflection
- Deep introspection and modification capabilities are needed
- Building frameworks or libraries that require dynamic behavior based on user-defined classes.
- The drawbacks are acceptable.
- Large number of similar obj. that differ in characteristics, not their behaviors.
Type Object
- When avoid extensive inheritance hierarchy for different types.
- Types are known at compile time, and properties don't change dynamically so new class is required.
Property List
- Flexibility in object's attributes needed, with ability CRUD properties at runtime.
- Type safety is not a primary concern or mechanisms to handle it effectively exists.
- Dealing with scenarios where objects can be very diverse and unpredictable, and you want to avoid rigid class structures.
#colbreak()
= Frameworks
#image("images/app_framework.png", width: 100%)
Object-oriented classes that work together, privides hooks for extension, keeps control flow.
*e.g.* Hibernate, Velocity, .NET Core & EF, React.js, Vue.js, MFC
== Application Framework
Object-oriented class library, `Main()` lives in the Application Framework, provide hooks to extend and callbacks, provides ready-made classes for use.
*e.g.* Spring, J2EE, ASP.NET, Angular, Office, Apache, httpd, quote
== Micro Frameworks
Represented by many Design Patterns *e.g.* Template Method, Strategy, Command Processor
== Meta Framework
*Framework adaption concerns:* Acquisition cost, Long-term effect, Training and support, future technology plans, Competitor responsible
*Key Ideas:* Difference to other technologies, different usage contexts.
= Frameworkers Dilemma
*Usage:* Framework users implement application code by
*Portability:* Code strongly coupled to overlying Framework
*Testability:* Hard to take single piece/package and write automated unit tests for application classes using Framework
*Evolution:* Framework users implementation might break in next version
=> Check out *functional* and *non-functional* requirements and *evaluate* Framework with care, *before* get locked-in.
*Ways out of dilemma:* 1. Think very hard up-front, 2. Don't care too much bout framework users, 3. Let framework users participate, 4. Use helping technology
= POSA 1 & 3
#image("images\forwarderReceiver.png")
#image("images\ResourceManager.png", width: 85%)
== Coordinator Pattern (two-phase prepare & commit)
#pattern(
[],
[Partial failure in systems involving multiple participants],
[Either all are successfull, or none are in case of any failure],
)
#image("images\Coordinator.png") |
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/circuiteria/0.1.0/gallery/test.typ | typst | Apache License 2.0 | #import "../src/lib.typ": circuit, element, util, wire
#set page(width: auto, height: auto, margin: .5cm)
#circuit({
element.block(
x: 0, y: 0, w: 1.5, h: 2.2,
id: "PCBuf",
fill: util.colors.orange,
ports: (
west: (
(id: "PCNext"),
),
north: (
(id: "CLK", clock: true),
),
east: (
(id: "PC"),
),
south: (
(id: "EN", name: "EN"),
)
)
)
wire.stub("PCBuf-port-CLK", "north", name: "CLK")
wire.stub("PCBuf-port-EN", "south", name: "PCWrite")
element.multiplexer(
x: 3, y: (from: "PCBuf-port-PC", to: "in0"), w: 1, h: 2,
id: "AdrSrc-MP",
fill: util.colors.orange,
entries: 2
)
wire.wire(
"wPCBuf-InstDataMgr", (
"PCBuf-port-PC",
"AdrSrc-MP-port-in0"
),
name: "PC",
bus: true
)
wire.stub("AdrSrc-MP.north", "north", name: "AdrSrc")
element.block(
x: 6, y: (from: "AdrSrc-MP-port-out", to: "A"), w: 3, h: 4,
id: "InstDataMgr",
fill: util.colors.yellow,
ports: (
west: (
(id: "A", name: "A"),
(id: "WD", name: "WD")
),
north: (
(id: "CLK", clock: true),
(id: "WE", name: "WE", vertical: true),
(id: "IRWrite", name: "IRWrite", vertical: true)
),
east: (
(id: "Instr", name: "Instr."),
(id: "RD", name: "RD")
)
),
ports-margins: (
west: (30%, 0%),
east: (40%, 0%)
)
)
wire.wire(
"wAdrSrcMP-InstDataMgr", (
"AdrSrc-MP-port-out",
"InstDataMgr-port-A"
),
name: "Adr",
name-pos: "end",
bus: true
)
wire.stub("InstDataMgr-port-CLK", "north", name: "CLK")
wire.stub("InstDataMgr-port-WE", "north")
wire.stub("InstDataMgr-port-IRWrite", "north")
wire.stub("InstDataMgr-port-WD", "west")
element.block(
x: 15, y: (from: "InstDataMgr-port-RD", to: "WD3"), w: 3, h: 4,
id: "RegFile",
fill: util.colors.pink,
ports: (
west: (
(id: "A1", name: "A1"),
(id: "A2", name: "A2"),
(id: "A3", name: "A3"),
(id: "WD3", name: "WD3"),
),
north: (
(id: "CLK", clock: true),
(id: "WE3", name: "WE3", vertical: true)
),
east: (
(id: "RD1", name: "RD1"),
(id: "RD2", name: "RD2"),
)
),
ports-margins: (
east: (20%, 20%)
)
)
wire.stub("RegFile-port-CLK", "north", name: "CLK")
wire.stub("RegFile-port-WE3", "north", name: "Regwrite", name-offset: 0.6)
wire.stub("RegFile-port-A2", "west")
wire.stub("RegFile-port-RD2", "east")
element.extender(
x: 15, y: -3.5, w: 3, h: 1,
id: "Extender",
fill: util.colors.green
)
wire.wire(
"wExtender-ImmSrc", (
"Extender.north",
(18, -2)
),
style: "zigzag",
zigzag-ratio: 0%,
name: "ImmSrc",
name-pos: "end",
bus: true
)
let mid = ("InstDataMgr.east", 50%, "RegFile.west")
wire.wire(
"wInstDataMgr-Bus", (
"InstDataMgr-port-Instr",
(vertical: (), horizontal: mid)
),
name: "Instr",
name-pos: "start",
bus: true
)
wire.wire(
"wBus", (
(v => (v.at(0), -3.5), mid),
(horizontal: (), vertical: (0, 3.5)),
),
bus: true
)
wire.wire(
"wBus-RegFile-A1", (
"RegFile-port-A1",
(horizontal: mid, vertical: ()),
),
name: "RS1",
name-pos: "end",
slice: (19, 15),
reverse: true,
bus: true
)
wire.wire(
"wBus-RegFile-A3", (
"RegFile-port-A3",
(horizontal: mid, vertical: ()),
),
name: "RD",
name-pos: "end",
slice: (11, 7),
reverse: true,
bus: true
)
wire.wire(
"wBus-Extender", (
"Extender-port-in",
(horizontal: mid, vertical: ()),
),
slice: (31, 7),
reverse: true,
bus: true
)
element.alu(
x: 22, y: (from: "RegFile-port-RD1", to: "in1"), w: 1, h: 2,
id: "ALU",
fill: util.colors.purple
)
wire.wire(
"wRegFile-ALU", (
"RegFile-port-RD1",
"ALU-port-in1"
),
name: ("A", "SrcA"),
bus: true
)
element.block(
x: 26, y: (from: "ALU-port-out", to: "in"), w: 1.5, h: 2,
id: "OutBuf",
fill: util.colors.orange,
ports: (
west: (
(id: "in"),
),
north: (
(id: "CLK", clock: true),
),
east: (
(id: "out"),
)
)
)
wire.stub("OutBuf-port-CLK", "north", name: "CLK")
wire.wire(
"wALU-OutBuf", (
"ALU-port-out",
"OutBuf-port-in"
),
name: "ALUResult",
bus: true
)
element.multiplexer(
x: 30, y: (from: "OutBuf-port-out", to: "in0"), w: 1, h: 2.5,
id: "Res-MP",
fill: util.colors.orange,
entries: 3
)
wire.stub("Res-MP.north", "north", name: "ResultSrc")
wire.stub("Res-MP-port-in2", "west")
wire.wire(
"wOutBuf-ResMP", (
"OutBuf-port-out",
"Res-MP-port-in0"
),
name: "ALUOut",
bus: true
)
wire.wire(
"wExt-ALU", (
"Extender-port-out",
"ALU-port-in2",
),
name: ("ImmExt", "SrcB"),
bus: true,
style: "zigzag",
zigzag-ratio: 60%
)
wire.wire(
"wInstDataMgr-ResMP", (
"InstDataMgr-port-RD",
"Res-MP-port-in1"
),
style: "dodge",
dodge-y: -4,
dodge-sides: ("east", "west"),
name: "Data",
name-pos: "start",
bus: true
)
wire.wire(
"wResMP-AdrSrc", (
"Res-MP-port-out",
"AdrSrc-MP-port-in1"
),
style: "dodge",
dodge-y: -5,
dodge-sides: ("east", "west"),
dodge-margins: (0.5, 1),
bus: true
)
wire.wire(
"wResMP-RegFile", (
"Res-MP-port-out",
"RegFile-port-WD3"
),
style: "dodge",
dodge-y: -5,
dodge-sides: ("east", "west"),
dodge-margins: (0.5, 1),
bus: true
)
wire.wire(
"wResMP-PCBuf", (
"Res-MP-port-out",
"PCBuf-port-PCNext"
),
style: "dodge",
dodge-y: -5,
dodge-sides: ("east", "west"),
dodge-margins: (0.5, 1.5),
name: "PCNext",
name-pos: "end",
bus: true
)
wire.intersection("wResMP-RegFile.dodge-end", radius: .2)
wire.intersection("wResMP-AdrSrc.dodge-end", radius: .2)
}) |
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/visualize/svg-text-00.typ | typst | Other | #set page(width: 250pt)
#figure(
image("test/assets/files/diagram.svg"),
caption: [A textful diagram],
)
|
https://github.com/luiswirth/diff-form-pres | https://raw.githubusercontent.com/luiswirth/diff-form-pres/main/src/setup.typ | typst | #let slides-config(doc) = {
set page(
paper: "presentation-16-9",
margin: 2cm,
)
set text(size: 20pt)
doc
}
#let my-config(doc) = {
// white on black
set page(fill: black)
set text(fill: white)
//set text(font: "New Computer Modern")
set par(justify: true)
show link: set text(fill: blue)
doc
}
|
|
https://github.com/liuguangxi/suiji | https://raw.githubusercontent.com/liuguangxi/suiji/main/tests/test-randi-f.typ | typst | MIT License | #set document(date: none)
#import "/src/lib.typ": *
#let print-arr(arr) = {
if type(arr) != array {
[#raw(str(arr) + " ")]
} else {
[#raw(arr.map(it => str(it)).join(" "))]
}
}
#{
let n = 500
let rng = gen-rng-f(42)
let arr = ()
for i in range(n) {
rng = randi-f(rng)
arr.push(rng.bit-rshift(23))
}
print-arr(arr); parbreak()
let amin = calc.min(..arr)
let amax = calc.max(..arr)
[*min* = #amin \ *max* = #amax]; parbreak()
}
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/ofbnote/0.2.0/README.md | markdown | Apache License 2.0 | # ofbnote
This is a Typst template to help formatting documents according to the French office for biodiversity design guidelines.
## Usage
You can use the CLI to kick this project off using the command
```
typst init @preview/ofbnote
```
Typst will create a new directory with all the files needed to get you started.
## Configuration
This template exports the `ofbnote` function with one named argument called `meta` which should be a dictionary of metadata for the document. The `meta` dictionary can contain the following fields:
- `title`: The document's title as a string or content.
- `authors`: The document's author(s) as a string.
- `date`: The document's date as a string or content.
- `version`: The document's version as a string.
It may contains other values, but they have no effect on the final document.
The function also accepts a single, positional argument for the body of the
paper.
The template will initialize your package with a sample call to the `ofbnote`
function in a show rule. If you want to change an existing project to use this
template, you can add a show rule like this at the top of your file:
```typ
#import "@preview/ofbnote:0.2.0": *
#show: ofbnote.with( meta:(
title: "My note",
authors: "Me",
date: "March 23rd, 2023",
version: "1.0"
))
// Your content goes below.
```
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.