repo
stringlengths 26
115
| file
stringlengths 54
212
| language
stringclasses 2
values | license
stringclasses 16
values | content
stringlengths 19
1.07M
|
---|---|---|---|---|
https://github.com/TypstApp-team/typst | https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/meta/footnote-columns.typ | typst | Apache License 2.0 | // Test footnotes in columns, even those
// that are not enabled via `set page`.
---
#set page(height: 120pt)
#align(center, strong[Title])
#show: columns.with(2)
#lorem(3) #footnote(lorem(6))
Hello there #footnote(lorem(2))
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/string-11.typ | typst | Other | // Test the `starts-with` and `ends-with` methods.
#test("Typst".starts-with("Ty"), true)
#test("Typst".starts-with(regex("[Tt]ys")), false)
#test("Typst".starts-with("st"), false)
#test("Typst".ends-with("st"), true)
#test("Typst".ends-with(regex("\d*")), true)
#test("Typst".ends-with(regex("\d+")), false)
#test("Typ12".ends-with(regex("\d+")), true)
|
https://github.com/kdog3682/typkit | https://raw.githubusercontent.com/kdog3682/typkit/main/0.1.0/src/headers/index.typ | typst |
// #import "chapter.typ": chapter
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/weave/0.1.0/tests/README.md | markdown | Apache License 2.0 | Run
```bash
typst compile tests.typ --root ..
```
to test the package
|
https://github.com/FlorentCLMichel/quetta | https://raw.githubusercontent.com/FlorentCLMichel/quetta/main/logo.typ | typst | MIT License | #import "src/quetta.typ": *
#set page(height: auto, width: auto, margin: 0pt, fill: black)
#set text(top-edge: "bounds", bottom-edge: "bounds", fill: white)
#quenya[Quetta]
|
https://github.com/sahasatvik/typst-theorems | https://raw.githubusercontent.com/sahasatvik/typst-theorems/main/manual.typ | typst | MIT License | #import "manual_template.typ": *
#import "theorems.typ": *
#show: thmrules
#show: project.with(
title: "typst-theorems",
authors: (
"sahasatvik",
),
url: "https://github.com/sahasatvik/typst-theorems"
)
= Introduction
The `typst-theorems` package provides `Typst` functions that help create
numbered `theorem` environments. This is heavily inspired by the `\newtheorem`
functionality of `LaTeX`.
A _theorem environment_ lets you wrap content together with automatically
updating _numbering_ information. Such environments use internal `state`
counters for this purpose. Environments can
- share the same counter (_Theorems_ and _Lemmas_ often do so)
- keep a global count, or be attached to
- other environments (_Corollaries_ are often numbered based upon the parent _Theorem_)
- headings
- have a numbering level depth fixed (for instance, use only top level heading
numbers)
- be referenced elsewhere in the document, via `label`s
= Using `typst-theorems`
Import all functions provided by `typst-theorems` using
```typst
#import "theorems.typ": *
#show: thmrules
```
The second line is crucial for displaying `thmenv`s and references correctly!
The core of this module consists of `thmenv`.
The functions `thmbox`, `thmplain`, and `thmproof` provide some simple
defaults for the appearance of `thmenv`s.
= Feature demonstration <feat>
Create box-like _theorem environments_ using `thmbox`, a wrapper around
`thmenv` which provides some simple defaults.
```typst
#let theorem = thmbox(
"theorem", // identifier
"Theorem", // head
fill: rgb("#e8e8f8")
)
```
#let theorem = thmbox(
"theorem",
"Theorem",
fill: rgb("#e8e8f8")
)
Such definitions are convenient to place in the preamble or a template; use
the environment in your document via
```typst
#theorem("Euclid")[
There are infinitely many primes.
] <euclid>
```
This produces the following.
#theorem("Euclid")[
There are infinitely many primes.
] <euclid>
Note that the `name` is optional. This `theorem` environment will be numbered
based on its parent `heading` counter, with successive `theorem`s
automatically updating the final index.
The `<euclid>` label can be used to refer to this Theorem via the reference
`@euclid`. Go to @references to read more.
You can create another environment which uses the same counter, say for
_Lemmas_, as follows.
```typst
#let lemma = thmbox(
"theorem", // identifier - same as that of theorem
"Lemma", // head
fill: rgb("#efe6ff")
)
#lemma[
If $n$ divides both $x$ and $y$, it also divides $x - y$.
]
```
#let lemma = thmbox(
"theorem",
"Lemma",
fill: rgb("#efe6ff")
)
#lemma[
If $n$ divides both $x$ and $y$, it also divides $x - y$.
]
You can _attach_ other environments to ones defined earlier. For instance,
_Corollaries_ can be created as follows.
```typst
#let corollary = thmbox(
"corollary", // identifier
"Corollary", // head
base: "theorem", // base - use the theorem counter
fill: rgb("#f8e8e8")
)
#corollary(numbering: "1.1")[
If $n$ divides two consecutive natural numbers, then $n = 1$.
]
```
#let corollary = thmbox(
"corollary",
"Corollary",
base: "theorem",
fill: rgb("#f8e8e8")
)
#corollary(numbering: "1.1")[
If $n$ divides two consecutive natural numbers, then $n = 1$.
]
Note that we have provided a `numbering` string; this can be any valid
numbering pattern as described in the
#link("https://typst.app/docs/reference/meta/numbering/")[numbering]
documentation.
== Proofs
The `thmproof` function gives nicer defaults for formatting proofs.
```typst
#let proof = thmproof("proof", "Proof")
#proof([of @euclid])[
Suppose to the contrary that $p_1, p_2, dots, p_n$ is a finite enumeration
of all primes. Set $P = p_1 p_2 dots p_n$. Since $P + 1$ is not in our list,
it cannot be prime. Thus, some prime factor $p_j$ divides $P + 1$. Since
$p_j$ also divides $P$, it must divide the difference $(P + 1) - P = 1$, a
contradiction.
]
```
#let proof = thmproof("proof", "Proof")
#proof([of @euclid])[
Suppose to the contrary that $p_1, p_2, dots, p_n$ is a finite enumeration
of all primes. Set $P = p_1 p_2 dots p_n$. Since $P + 1$ is not in our list,
it cannot be prime. Thus, some prime factor $p_j$ divides $P + 1$. Since
$p_j$ also divides $P$, it must divide the difference $(P + 1) - P = 1$, a
contradiction.
]
If your proof ends in a block equation, or a list/enum, you can place
`qedhere` to correctly position the qed symbol.
```typst
#theorem[
There are arbitrarily long stretches of composite numbers.
]
#proof[
For any $n > 2$, consider $
n! + 2, quad n! + 3, quad ..., quad n! + n #qedhere
$
]
```
#theorem[
There are arbitrarily long stretches of composite numbers.
]
#proof[
For any $n > 2$, consider $
n! + 2, quad n! + 3, quad ..., quad n! + n #qedhere
$
]
*Caution*: The `qedhere` symbol does not play well with numbered/multiline
equations!
You can set a custom qed symbol (say $square$) by setting the appropriate
option in `thmrules` as follows.
```typst
#show: thmrules.with(qed-symbol: $square$)
```
== Suppressing numbering
Supplying `numbering: none` to an environment suppresses numbering for that
block, and prevents it from updating its counter.
```typst
#let example = thmplain(
"example",
"Example"
).with(numbering: none)
#example[
The numbers $2$, $3$, and $17$ are prime.
]
```
#let example = thmplain(
"example",
"Example"
).with(numbering: none)
#example[
The numbers $2$, $3$, and $17$ are prime.
]
Here, we have used the `thmplain` function, which is identical to `thmbox` but
sets some plainer defaults. You can also write
```typst
#lemma(numbering: none)[
The square of any even number is divisible by $4$.
]
#lemma[
The square of any odd number is one more than a multiple of $4$.
]
```
#lemma(numbering: none)[
The square of any even number is divisible by $4$.
]
#lemma[
The square of any odd number is one more than a multiple of $4$.
]
Note that the last _Lemma_ is _not_ numbered 3.1.2!
You can also override the automatic numbering as follows.
```typst
#lemma(number: "42")[
The square of any natural number cannot be two more than a multiple of 4.
]
```
#lemma(number: "42")[
The square of any natural number cannot be two more than a multiple of 4.
]
Note that this does _not_ affect the counters either!
== Limiting depth
You can limit the number of levels of the `base` numbering used as follows.
```typst
#let definition = thmbox(
"definition",
"Definition",
base_level: 1, // take only the first level from the base
stroke: rgb("#68ff68") + 1pt
)
#definition("Prime numbers")[
A natural number is called a _prime number_ if it is greater than $1$ and
cannot be written as the product of two smaller natural numbers. <prime>
]
```
#let definition = thmbox(
"definition",
"Definition",
base_level: 1,
stroke: rgb("#68ff68") + 1pt
)
#definition("Prime numbers")[
A natural number is called a _prime number_ if it is greater than $1$ and
cannot be written as the product of two smaller natural numbers. <prime>
]
Note that this environment is _not_ numbered 3.2.1!
```typst
#definition("Composite numbers")[
A natural number is called a _composite number_ if it is greater than $1$
and not prime.
]
```
#definition("Composite numbers")[
A natural number is called a _composite number_ if it is greater than $1$
and not prime.
]
Setting a `base_level` higher than what `base` provides will introduce padded
zeroes.
```typst
#example(base_level: 4, numbering: "1.1")[
The numbers $4$, $6$, and $42$ are composite.
]
```
#example(base_level: 4, numbering: "1.1")[
The numbers $4$, $6$, and $42$ are composite.
]
== Custom formatting
The `thmbox` function lets you specify rules for formatting the `title`, the
`name`, and the `body` individually. Here, the `title` refers to the `head`
and `number` together.
```typst
#let proof-custom = thmplain(
"proof",
"Proof",
base: "theorem",
titlefmt: smallcaps,
bodyfmt: body => [
#body #h(1fr) $square$ // float a QED symbol to the right
]
).with(numbering: none)
#lemma[
All even natural numbers greater than 2 are composite.
]
#proof-custom[
Every even natural number $n$ can be written as the product of the natural
numbers $2$ and $n\/2$. When $n > 2$, both of these are smaller than $2$
itself.
]
```
#let proof-custom = thmplain(
"proof",
"Proof",
base: "theorem",
titlefmt: smallcaps,
bodyfmt: body => [
#body #h(1fr) $square$
]
).with(numbering: none)
#lemma[
All even natural numbers greater than 2 are composite.
]
#proof-custom[
Every even natural number $n$ can be written as the product of the natural
numbers $2$ and $n\/2$. When $n > 2$, both of these are smaller than $2$
itself.
]
You can go even further and use the `thmenv` function directly. It accepts an
`identifier`, a `base`, a `base_level`, and a `fmt` function.
```typst
#let notation = thmenv(
"notation", // identifier
none, // base - do not attach, count globally
none, // base_level - use the base as-is
(name, number, body, color: black) => [
// fmt - format content using the environment
// name, number, body, and an optional color
#text(color)[#h(1.2em) *Notation (#number) #name*]:
#h(0.2em)
#body
#v(0.5em)
]
).with(numbering: "I") // use Roman numerals
#notation[
The variable $p$ is reserved for prime numbers.
]
#notation("for Reals", color: green)[
The variable $x$ is reserved for real numbers.
]
```
#let notation = thmenv(
"notation", // identifier
none, // base - do not attach, count globally
none, // base_level - use the base as-is
(name, number, body, color: black) => [
// fmt - format content using the environment name, number, body, and an optional color
#text(color)[#h(1.2em) *Notation (#number) #name*]:
#h(0.2em)
#body
#v(0.5em)
]
).with(numbering: "I") // use Roman numerals
#notation[
The variable $p$ is reserved for prime numbers.
]
#notation("for Reals", color: green)[
The variable $x$ is reserved for real numbers.
]
Note that the `color: green` named argument supplied to the theorem
environment gets passed to the `fmt` function. In general, all extra named
arguments supplied to the theorem will be passed to `fmt`.
On the other hand, the positional argument `"for Reals"` will always be
interpreted as the `name` argument in `fmt`.
```typst
#lemma(title: "Lem.", stroke: 1pt)[
All multiples of 3 greater than 3 are composite.
]
```
#lemma(title: "Lem.", stroke: 1pt)[
All multiples of 3 greater than 3 are composite.
]
Here, we override the `title` (which defaults to the `head`) as well as the
`stroke` in the `fmt` produced by `thmbox`. All `block` arguments can be
overridden in `thmbox` environments in this way.
== Labels and references <references>
You can place a `<label>` outside a theorem environment, and reference it
later via `@` references! For example, go back to @euclid.
```typst
Recall that there are infinitely many prime numbers via @euclid.
```
#pad(
left: 1.2em,
[
Recall that there are infinitely many prime numbers via @euclid.
]
)
```typst
You can reference future environments too, like @oddprime[Cor.].
```
#pad(
left: 1.2em,
[
You can reference future environments too, like @oddprime[Cor.].
]
)
```typst
#lemma(supplement: "Lem.", refnumbering: "(1.1)")[
All primes apart from $2$ and $3$ are of the form $6k plus.minus 1$.
] <primeform>
You can modify the supplement and numbering to be used in references, like @primeform.
```
#lemma(supplement: "Lem.", refnumbering: "(1.1)")[
All primes apart from $2$ and $3$ are of the form $6k plus.minus 1$.
] <primeform>
You can modify the supplement and numbering to be used in references, like @primeform.
*Caution*: Links created by references to `thmenv`s will be styled according
to `#show link:` rules.
== Overriding `base`
```typst
#let remark = thmplain("remark", "Remark", base: "heading")
#remark[
There are infinitely many composite numbers.
]
#corollary[
All primes greater than $2$ are odd.
] <oddprime>
#remark(base: "corollary")[
Two is a _lone prime_.
]
```
#let remark = thmplain("remark", "Remark", base: "heading")
#remark[
There are infinitely many composite numbers.
]
#corollary[
All primes greater than $2$ are odd.
] <oddprime>
#remark(base: "corollary")[
Two is a _lone prime_.
]
This `remark` environment, which would normally be attached to the current
_heading_, now uses the `corollary` as a base.
#v(4em)
= Function reference
== `thmenv`
The `thmenv` function produces a _theorem environment_.
```typst
#let thmenv(
identifier, // environment counter name
base, // base counter name, can be "heading" or none
base_level, // number of base number levels to use
fmt // formatting function of the form
// (name, number, body, ..args) -> content
) = { ... }
```
The `fmt` function must accept a theorem `name`, `number`, `body`, and produce
formatted content. It may also accept additional positional arguments, via
`args`.
A _theorem environment_ is itself a map of the following form.
```typst
(
..args,
body, // body content
number: auto, // number, overrides numbering if present
numbering: "1.1", // numbering style, can be a function
refnumbering: auto, // numbering style used in references,
// defaults to "numbering"
supplement: identifier, // supplement used in references
base: base, // base counter name override
base_level: base_level // base_level override
) -> content
```
Positional arguments in `args` are as follows
- `name`: The name of the theorem, typically displayed after the title.
All additional named arguments in `args` will be passed on to the associated
`fmt` function supplied in `thmenv`.
== `thmbox` and `thmplain`
The `thmbox` wraps `thmenv`, supplying a box-like `fmt` function.
```typst
#let thmbox(
identifier, // identifier
head, // head - common name, used in the title
..blockargs, // named arguments, passed to #block
supplement: auto, // supplement for references, defaults to "head"
padding: (top: 0.5em, bottom: 0.5em),
// box padding, passed to #pad
namefmt: x => [(#x)], // formatting for name
titlefmt: strong, // formatting for title (head + number)
bodyfmt: x => x, // formatting for body
separator: [#h(0.1em):#h(0.2em)],
// separator inserted between name and body
base: "heading", // base - defaults to using headings
base_level: none, // base_level - defaults to using base as-is
) = { ... }
```
The `thmbox` function sets the following defaults for the `block`.
```typst
(
width: 100%,
inset: 1.2em,
radius: 0.3em,
breakable: false,
)
```
The `thmplain` function is identical to `thmbox`, except with plainer
defaults.
```typst
#let thmplain = thmbox.with(
padding: (top: 0em, bottom: 0em),
breakable: true,
inset: (top: 0em, left: 1.2em, right: 1.2em),
namefmt: name => emph([(#name)]),
titlefmt: emph,
)
```
== `thmproof`, `proof-bodyfmt` and `qedhere`
The `thmproof` function is identical to `thmplain`, except with defaults
appropriate for proofs.
```typst
#let thmproof(..args) = thmplain(
..args,
namefmt: emph,
bodyfmt: proof-bodyfmt,
..args.named()
).with(numbering: none)
```
The `proof-bodyfmt` function is a `bodyfmt` function that automatically places
a qed symbol at the end of the body.
You can place `#qedhere` inside a block equation, or at the end of a list/enum
item to place the qed symbol on the same line.
== `thmrules`
The `thmrules` show rule sets important styling rules for theorem
environments, references, and equations in proofs.
```typst
#let thmrules(
qed-symbol: $qed$, // QED symbol used in proofs
doc
) = { ... }
```
= Acknowledgements
Thanks to
- #link("https://github.com/MJHutchinson")[MJHutchinson] for suggesting and
implementing the `base_level` and `base: none` features,
- #link("https://github.com/rmolinari")[rmolinari] for suggesting and
implementing the `separator: ...` feature,
- #link("https://github.com/DVDTSB")[DVDTSB] for contributing
- the idea of passing named arguments from the theorem directly to the `fmt`
function.
- the `number: ...` override feature.
- the `title: ...` override feature in `thmbox`.
- The awesome devs of #link("https://typst.app/")[typst.app] for their
support.
|
https://github.com/0x1B05/english | https://raw.githubusercontent.com/0x1B05/english/main/cnn10/content/20240313.typ | typst | #import "../template.typ": *
#pagebreak()
= 20240313
== elections
Hello, #underline[and] Wonderful Wednesday #underline[to] you. I'm Coy Wire #strike[. We meet in ] #underline[, bringing you] best ten minutes in news right here on CNN10. It is your #underline[word] Wednesday, so #strike[listen to] #underline[to see if] your words submission made #underline[it] into today's show.
We start with the year of the election 2024. And not just here in United States, many countries around the world are having their own important national elections this year. Nations with people heading to the #underline[*polls*] this year include some of the most powerful and wealthiest country in the world, as well as the most #underline[*populous*] like Indian, South Africa, Mexico and in Europe#underline[, ]where United Kingdom #underline[is *leaning towards* elections later] this year. And countries with hundreds of millions of voters will be heading to the #underline[polls] to elect a new parliament for the European Union.
One of the major concerns with elections this year, is advanced technology, particularly Artificial Intelligence, and how #underline[it] has the potential to persuade and even mislead voters with disinfomation. AI generated fake videos#strike[. Deep fakes] #underline[, deepfakes,] could trigger voters into believing their watching and hearing a presidential candidate, *when in reality they're not*.
Yesterday in the U.S., voters in #underline[Georgia,] Hawaii, #underline[Mississippi] and State of Washington #underline[*cast their ballots* in their *respective primaries*.] It is #strike[respected] #underline[expected] the both president <NAME> and the former president <NAME> #underline[will clinch] their parties #underline[*nomination*].
Let's turn #strike[on] #underline[now] to out #underline[<NAME>,] who *breaks down* this crucial election this year for several nations across the world.
2024 is an election year like #underline[none other.]
(Trump)We will turn the page forever on the miserable #underline[nightmare] of the Biden #strike[presidence] #underline[presidency]
(Biden)D<NAME> sees the difference of the America, #strike[and] #underline[an] American story #underline[of resentment, revenge and retribution.]
While the U.S. presidential #underline[race] might be *the highest profile*, it's just one of dozens taking place internationally, covering more than half the world's population.
Many countries, the health #underline[of their] democracy #underline[itself] will be #strike[putting] #underline[being put] to the test. And the outcome has a potential to reshape international #underline[affairs] on #strike[the] #underline[a] scale rarely seen.
While the results of some elections are all #strike[by] #underline[but] guaranteed, others will be a #strike[genious] #underline[genuine] contest#strike[. Many] #underline[, meaning a] relatively small shift in #underline[voter] support could affect the outcome #strike[that] #underline[. That amplifies] the potential impact of disinformation. And experts #strike[on] #underline[warn] that #strike[risks] #underline[risk is] made even more significant, but the facts of these information are #strike[coincidently booming] #underline[are coinciding with a boom in] Artificial Intelligence.
That brings with the #strike[prospective] #underline[prospect of deepfake] content like this:
This is an AI generated video, showing just how far technology #strike[is come with recent use] #underline[has come in recent years].
Even Russian president #underline[Vladimir Putin] #strike[are mentally] #underline[appeared *momentarily*] surprised and confronted by a computer-generated version of himself.
People should be scared, because the technology is #strike[enable] #underline[enabling] the creation of fake videos. They could be very persuasive with the ordinary voters. People are not going to be able to distinguish the fake videos from real #strike[world's] #underline[ones].
Are governments ready for #strike[what's down...] #underline[what's coming down the line]?
Governments are not ready. There are #underline[literally] no #strike[guard reals] #underline[guardrails] in place.
That prompted dozens of technology companies to step in, signing #underline[an *accord* aimed at combating] the misuse of Artificial Intelligence in #strike[no] elections.
Democracies #strike[depend. On] #underline[depend on] free and fair elections. Free and fair elections depend on trustworthy information, and trustworthy information depends on transparency about the nature and the #underline[*provenance*] of that information.
The accord requires the world's leading tech companies to develop tools to help identify #underline[and label] AI generated content. #strike[They] #underline[They've] also agreed on the need to respond more quickly when #underline[*deceptive*] AI generated material #underline[spreads] online. But even they #underline[concede] the task #underline[ahead] won't be easy. We are combating not just #strike[individual's unfortunately] #underline[individuals, unfortunately], but well-resourced nation states including one in particular.
Even though the #underline[the Kremlin] denies it, #underline[*countless*] Intelligence reports confirm Russia's elections interference efforts. But the Microsoft president warns Russia's level of sophistication is growing, #strike[few] #underline[fueled] by advances in Artificial Intelligence.
=== words, phrases and sentences
==== words
- _presidency_
- _resentment_
- _retribution_
- _profile_
- _amplify_
==== phrases
- _break down_
- _on a scale rarely seen_
- _be fueled with_
==== sentences
- 2024 is an election year like none other.
- We will turn the page forever on the miserable #underline[nightmare] of the Biden presidency.
- That bring with it prospect of deepfake content.
=== 回译
==== 原文
Hello, and Wonderful Wednesday to you. I'm <NAME>, bringing you best ten minutes in news right here on CNN10. It is your word Wednesday, so to see if your words submission made it into today's show.
We start with the year of the election 2024. And not just here in United States, many countries around the world are having their own important national elections this year. Nations with people heading to the polls this year include some of the most powerful and wealthiest country in the world, as well as the most populous like Indian, South Africa, Mexico and in Europe, where United Kingdom is leaning towards elections later this year. And countries with hundreds of millions of voters will be heading to the polls to elect a new parliament for the European Union.
One of the major concerns with elections this year, is advanced technology, particularly Artificial Intelligence, and how it has the potential to persuade and even mislead voters with disinfomation. AI generated fake videos, deepfakes, could trigger voters into believing their watching and hearing a presidential candidate, when in reality they're not.
Yesterday in the U.S., voters in Georgia, Hawaii, Mississippi and State of Washington cast their ballots in their respective primaries. It is expected the both president <NAME> and the former president <NAME> will clinch their parties nomination.
Let's turn now to out <NAME>, who breaks down this crucial election this year for several nations across the world.
2024 is an election year like none other.
(Trump)We will turn the page forever on the miserable nightmare of the Biden presidency
(Biden)D<NAME>ump sees the difference of the America, an American story of resentment, revenge and retribution.
While the U.S. presidential race might be the highest profile, it's just one of dozens taking place internationally, covering more than half the world's population.
Many countries, the health of their democracy itself will be being put to the test. And the outcome has a potential to reshape international affairs on a scale rarely seen.
While the results of some elections are all but guaranteed, others will be a genuine contest, meaning a relatively small shift in voter support could affect the outcome. That amplifies the potential impact of disinformation. And experts warn that risk is made even more significant, because the facts of these information are coinciding with a boom in Artificial Intelligence.
That brings with the prospect of deepfake content like this:
This is an AI generated video, showing just how far technology has come in recent years.
Even Russian president <NAME> appeared momentarily surprised and when confronted by a computer-generated version of himself. People should be scared, because the technology is enabling the creation of fake videos. They could be very persuasive with the ordinary voters. People are not going to be able to distinguish the fake videos from real ones.
Are governments ready for what's coming down the line?
Governments are not ready. There are literally no guardrails in place.
That prompted dozens of technology companies to step in, signing an accord aimed at combating the misuse of Artificial Intelligence in elections.
Democracies depend on free and fair elections. Free and fair elections depend on trustworthy information, and trustworthy information depends on transparency about the nature and the provenance of that information.
The accord requires the world's leading tech companies to develop tools to help identify and label AI generated content. They've also agreed on the need to respond more quickly when deceptive AI generated material spreads online. But even they concede the task ahead won't be easy. We are combating not just individuals, unfortunately, but well-resourced nation states including one in particular.
Even though the Kremlin denies it, countless Intelligence reports confirm Russia's elections interference efforts. But the Microsoft president warns Russia's level of sophistication is growing, fueled by advances in Artificial Intelligence.
==== 参考翻译
你们好,祝你有个美好的周三。我是Coy Wire,欢迎收看CNN10,为您带来最精彩的十分钟新闻。今天是“你的词汇星期三”,看看你提交的词汇有没有出现在今天的节目中。
首先,让我们来看看2024年的选举。不仅美国,世界上许多国家今年都将举行重要的全国选举。这些国家包括一些最强大和最富有的国家,以及人口最多的国家,如印度、南非、墨西哥,以及欧洲的英国,后者可能会在今年晚些时候举行选举。此外,拥有数亿选民的国家还将前往投票站选举欧洲联盟的新议会。
今年选举的一个主要关切点是先进技术,尤其是人工智能,以及它如何有可能通过虚假信息来影响和误导选民。由AI生成的虚假视频,即“deepfakes”,可能会让选民相信他们正在观看和听到一位总统候选人的讲话,而实际上并非如此。
昨天,在美国,Georgia、Hawaii、Mississippi和State of Washington的选民投票选举了各自的初选候选人。预计总统<NAME>和前总统<NAME>都将赢得各自党派的提名。
现在,让我们听听<NAME>的解读,他将为我们分析今年世界各国的关键选举。
2024年是一个与众不同的选举年。
(Trump)我们将永远翻开Biden总统令人痛苦的噩梦一页。
(Biden)<NAME>看到了美国的不同,这是一个充满怨恨、复仇和报复的美国故事。
虽然美国总统竞选可能是最引人注目的,但这只是全球数十个选举之一,涵盖了超过世界人口的一半。
许多国家,甚至是民主本身的健康,都将面临考验。选举结果有可能在罕见的程度上重塑国际事务。
虽然某些选举的结果几乎可以预料,但其他选举将是真正的竞争,这意味着选民支持度上的微小变化也可能会影响结果。这加大了虚假信息的潜在影响。专家警告说,这种风险变得更加重要,因为这些信息的真相恰好与人工智能的蓬勃发展同时出现。
这就带来了深度伪造内容的前景,比如这个: 这是一个由人工智能生成的视频,展示了技术近年来的进步。即使是俄罗斯总统Vladimir Putin也会在电脑生成的自己面前感到短暂的惊讶和困惑。人们应该感到害怕,因为这项技术使制作虚假视频成为可能。这些视频可能对普通选民产生很大的说服力。人们将无法区分假视频和真实视频。 政府准备好应对即将到来的问题了吗? 政府并没有准备好。实际上,根本没有任何防范措施。 这促使数十家科技公司加入,签署了一项旨在打击选举中人工智能滥用的协议。
民主制度依赖于自由和公正的选举。自由和公正的选举依赖于可靠的信息,而可靠的信息则取决于对信息性质和来源的透明度。
这项协议要求全球领先的科技公司开发工具,以帮助识别和标记由人工智能生成的内容。他们还一致认为,在欺骗性的人工智能生成材料在网上传播时,需要更快地做出回应。但即使如此,他们也承认前方的任务并不容易。我们正在与不仅仅是个人,而且还包括一个资源充足的国家进行斗争。
尽管克里姆林宫否认了这一点,但无数的情报报告证实了俄罗斯干预选举的努力。但微软总裁警告说,俄罗斯的技术水平正在不断提高,这得益于人工智能的进步。
==== 1st
Hello, and wonderful Wednesday to you. I'm <NAME>, welcome to cnn10, bringing you the best fantastic #strike[ten-minute news] #underline[in news right here]. Today's your #strike[vocabulary] #underline[word] Wednesday#strike[. Let's see whether your vocabulary will appear in today's show.] #underline[, _so to see if your words submission *made it* into today's show._]
First, let's #strike[turned to the 2024 election] #underline[start with *the year of election 2024*]. #strike[More than America] #underline[Not just here in United States], many other countries in the world #strike[will have a] #underline[_are having_ their own important national] elections this year. #strike[Among these countries are] #underline[Nations with people heading to the polls this year *include* some of] the #strike[strongest] #underline[most powerful] and wealthiest countries #strike[and] #underline[*as well as*] the most *populous* countries such as India, South Africa, Mexico, and #strike[England in Europe. The later one will take the election later of this year.]#underline[in Europe, _where United Kingdom is *leaning towards* elections later this year_]. What's more, the country with hundreds million voters #strike[are going to the vote station to vote for the] #underline[will _be heading to_ the polls to elect a] new parliament #strike[of] #underline[for the] European Union.
One of the #strike[spotlight of this year's election] #underline[major concerns with elections this year] is #strike[on the] advanced technology, especially #strike[the] Artificial Intelligence and how it #strike[impact or misdirect voters through fake information] #underline[has the potential to persuade and even mislead voters this disinformation]. AI-generated fake videos as known as "deepfakes" #strike[are likely to have voters believe in] #underline[could *trigger* voters into believing] their watching and #strike[listening] #underline[hearing] the speeches given by a #strike[president] #underline[presidential] candidate, #strike[but it's not true in reality] #underline[when in reality they're not].
Yesterday, in the USA, voters in #underline[Georgia, Hawaii, Mississippi and State of Washington] #strike[voted for their initial candidates] #underline[*cast their ballots* in their respective primaries]. #strike[It is predicted that president <NAME> and pre-president <NAME> will win the *nomination* of their parties.] #underline[_It is expected_ the both president <NAME> and the former president <NAME> will *clinch their parties nomination*.]
Now, let's #strike[listen] #underline[turn] to #underline[out] <NAME> who will #strike[analyse the critical election of countries around the world] #underline[breaks down this crucial election this year for several nations *across the world*].
#strike[2024 is a distinctive election year.] #underline[2024 is an election year like *none other*.]
(Trump) We will turn the page forever #underline[on the *miserable*] nightmare of <NAME>'s presidency.
(Biden) <NAME> has seen the difference of the America, #strike[this is a American story filled with] #underline[an American story of] #underline[*resentment*], revenge, #underline[and *retribution*].
#strike[The election of American president may be the most focused, but it was only one of the tens of the elections all over the world covering more than a half population of the world.] #underline[_While the U.S. presidential race might be the highest profile, it's just one of dozens taking place internationally, covering more than half the world's population._]
Many countries even the health of #underline[their] democracy #underline[itself] will be #strike[challenged.] #underline[being put to the test.] #strike[The results of the elections could reconstructed the international matters in terms of the level of the] #underline[And the outcome has _a potential to reshape international affairs_ *on a scale rarely seen.*]
#strike[Although some results of the elections can almost be predicted] #underline[While some the results of some elections are all but *guaranteed*], #strike[but other elections] #underline[others] will be #strike[the truly competition] #underline[a *genuine* contest], #strike[which means even the faint changes of voters can impact on the result] #underline[meaning a relatively small shift in voter support could affect the outcome]. #underline[That ampplifies the potential impact of disinformation.] The experts warns, #strike[this kind of risk becomes more significant for the facts of these information comes along with the prosperous development of AI.] #underline[this risk is made more significant for the facts of these information are *coinciding* with a boom in AI.]
And #strike[this brings] #underline[that brings with] the future of "deepfakes", for example: this is an AI-generated video, showing #strike[the progress in technology] #underline[*how far technology has come in recent year*]. Even the Russian president Putin #strike[feels a bit surprised in front of himself generated by computer] #underline[appeared momentarily surprised when confronted by a computer-generated version of himself]. People should be scared for such technology, #strike[making it possible to generated fake videos] #underline[which is enabling the creation of fake videos] that could be persuasive to ordinary voters. People aren't #underline[going to be] able to distinguish #strike[the fake one and the real one] #underline[fake videos *from* reals ones.].
Have the governments prepared for #strike[the coming problems] #underline[what's coming down the line]?
No, they haven't. In fact, there are no #strike[any defence] #underline[literally guardrails], which #strike[urged] #underline[prompted] #strike[several] #underline[dozens of] technology companies to #underline[*step in*], signing #underline[an *accord* *aimed at*] #strike[prohibiting] #underline[combating] the abuse of AI in elections.
#strike[The democracy regulation is] #underline[Democracies are] based on free and fair elections. Free and fair elections depend on #strike[reliable] #underline[trustworthy] information, and trustworthy information is decided on the #strike[properties] #underline[provenance] of the information and the transparency #strike[of the source] #underline[about the source].
This accord #strike[asked] #underline[requires] the #strike[world-advanced technology companies] #underline[the *world's leading tech companies*] to develop tools to help identify and label the content generated by AI. They also #strike[reached a deal that rapid response need to made] #underline[have agreed on the need to respond more quickly] when deceptive fake material generated by AI #strike[transporting] #underline[*spreads*] on the Internet. In spite of this, they also #strike[acknowledged] #underline[*concede*] the tasks #underline[*ahead*] aren't easy. We are not only #strike[fighting] #underline[combating] with #strike[a person] #underline[*individuals*] but also a well-resourced country #underline[including one in particular].
Even though Kremlin denied this, #strike[but]countless reporters confirmed #strike[the efforts to interfere with the election] #underline[Russia's elections interference] efforts. But CEO of Microsoft warns that Russia's level of #strike[technology] #underline[sophistication] is #strike[now becoming higher and higher thanks to the progress of AI.] #underline[*growing*, *fueled by* advances in AI.]
== SAT(Scholastic Aptitude Test)
No need to bring your NO.2 pencils to #strike[the] #underline[an] SAT anymore, because this college admission#underline[s] test is now full digital. Test takers still #strike[ought] #underline[have] to be there in person and supervised, so no bad #underline[*badinage*] with friends #strike[doing] #underline[during] the test. The SAT will be taking on #strike[the] #underline[a] laptop or tablet. And the exam will be shorter#strike[ where] #underline[. Where] #strike[there] #underline[it] was three hours before, it now down to two. It will still be based on the #strike[60 hundred] #underline[16 hundred-point] scale and #underline[the] results will come back sooner, in a matter of days in stead of weeks. But #underline[a] concern for some, these digital version is also adaptive#strike[.Many were served] #underline[, meaning it will serve] #strike[hard] #underline[harder] questions#strike[,] the better you do, which some students say increases test anxiety and overthinking. This changes from the college #strike[border] #underline[board] #strike[on] #underline[are an] effort to make #strike[standard tests] #underline[this standardized test] more accessible to students, as many colleges make it optional to #underline[submit] standardized test scores especially during the pandemic. More #underline[elite] universities have announced a shift #strike[on] #underline[in now] requiring students to include this test scores with their applications. But on the other side, some #underline[critics] believe standardized tests can be a disadvantage for lower income students, because they may have limited resources to study and prepare for these tests.
=== words
- _badinage_
- _standardized_
- _college board_
- _elite_
- _critics_
|
|
https://github.com/mattyoung101/musicvis3d | https://raw.githubusercontent.com/mattyoung101/musicvis3d/master/README.md | markdown | ISC License | # 3D OpenGL Music Visualiser
### COSC3000 Computer Graphics Major Project
_by <NAME> <<EMAIL>>_
This is a semi real-time 3D audio visualisation using OpenGL. The visualisation consists of offline spectral
data that is rendered in real-time in the form of 3D bars. A multitude of graphics techniques are used,
including: quaternion camera animation, camera shake using Simplex noise under fractal Brownian motion, a
skybox, and a post-processing stage that implements chromatic aberration. The application is written in a mix
of C++ (for rendering) and Python (for DSP). The spectrum of bars is computed using the Fast Fourier
Transform.
This is my major project in computer graphics for COSC3000, done during UQ Sem 1 2024. The code itself is
based on a fork of the graphics minor project, completed earlier in the semester.
For more information, see [paper/major.pdf](paper/major.pdf).
## Building and running
You will need the following tools/libraries:
- CMake 3.20+
- Ninja
- LLVM
- Clang
- LLD
- SDL2
- glm
- Assimp
- spdlog
- Cap'n Proto
All the above dependencies are available on the AUR or main repos for Arch Linux. If you're using another
distro, you may have to compile from source to get the newer versions (especially if on Ubuntu). If you're
not on Linux, you're on your own! In particular, this may be challenging to build on MacOS due to their
deprecation of OpenGL.
Generate the project using:
```bash
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release # or Debug
```
Build (in `build` directory):
```bash
ninja
```
Run:
```bash
./musicvis ../data BandName_SongName
# for example:
./musicvis ../data LauraBrehm_PureSunlight
```
The application then has the following keybinds:
- ESCAPE: Quit
- F: Toggle freecam
- Right arrow: Skip current camera animation
- WASD: In freecam mode, move around
- Mouse: In freecam mode, look around
In the fish shell, use `set -x ASAN_OPTIONS detect_leaks=0` to silence LeakSanitizer which has false positives
under SDL2.
## Importing new audio
New songs can be imported into the visualiser.
First, make a new directory in `data/songs`, for example, `mkdir data/songs/Band_Name_Song_Name`.
Your song needs to be available as a FLAC file. Copy this into `data/songs/Band_Name_Song_Name/audio.flac`.
Finally, you can activate the virtual environment and run the process script:
```bash
python -m venv env
source env/bin/activate.fish
pip install -r requirements.txt
./scripts/process.py Band_Name_Song_Name
```
This will then write the `spectrum.bin` file in the Cap'n Proto format.
To double check this worked, run `./scripts/decoder.py Band_Name_Song_Name`. This will load the capnp message
in `spectrum.bin` and display it.
## Compiling the paper
The paper is written in [Typst](https://github.com/typst/typst). In the `paper` directory, you can run `typst
compile major.typ` to produce `major.pdf`.
## Libraries used
This project makes use of the following open-source libraries:
- SDL2: zlib licence
- glm: MIT licence
- Assimp: BSD 3-Clause
- spdlog: MIT licence
- Cap'n Proto: MIT licence
- dr_flac: Public domain
- stb_image: Public domain
- `camera.cpp`/`camera.hpp` derived from Cinder Project: BSD 2-Clause
- Upstream: https://github.com/cinder/Cinder/blob/master/src/cinder/Camera.cpp
- `Simplex.h`: BSD 3-Clause
- Upstream: https://github.com/simongeilfus/SimplexNoise
Some code based on code from LearnOpenGL https://learnopengl.com/ - however, given the generic nature of the
code (i.e. there is really only one way to instantiate a GL shader), I do not believe that their CC-BY-NC
licence applies to this repo. The LOGL content was used _as reference_ only.
## Licence
Code I wrote, including shaders, is available under the **ISC Licence** (see LICENSE.txt)
The paper is available under [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/).
Music remains copyrighted the respective artists. The two songs shipped with this version are snippets of
"Pure Sunlight" by Mr FijiWiji, <NAME> and AGNO3, and "Right of Passage" by Eastern Odyssey. This is
copyrighted material, and if any of the artists would like it removed, please contact me and I'll do so.
The space skybox was generated by https://tools.wwwtyro.net/space-3d/index.html. That website doesn't
explicitly licence it under any licence, but since you _can_ download it, I say do with the skybox whatever
you want until shown otherwise.
|
https://github.com/StanleyDINNE/php-devops-tp | https://raw.githubusercontent.com/StanleyDINNE/php-devops-tp/main/documents/Rapport/Typst/Util.typ | typst |
#let __constants_toml = toml("__private_tools/constants.toml")
#let add_title(content, bold: true, size: 17pt, small_capitals: false) = {
content = if small_capitals { smallcaps[#content] } else { content }
content = text(
size,
hyphenate: false,
weight: if bold { "bold" } else { "regular" }
)[#content]
content = par(justify: false)[#content]
content = align(center, content)
content
}
#let phantom_title_ref(arg) = {
[#heading(bookmarked: false, outlined: false, supplement: none, numbering: none)[#text(0pt, white)[.]] #label(arg)]
}
#let phantom_ref(arg) = {
[#text(0pt, white)[.] #label(arg)]
}
#let file_folder(data) = {
text(fill: rgb(__constants_toml.color.file_folder))[#raw(data)]
}
#let import_csv_filter_categories(path, categories, display_size: 11pt) = {
transpose(csv(path))
.filter(
category => categories.contains(category.first())
)
.sorted(key:
category => categories.position(
item => item == category.first()
)
)
.map(category => {
let t = category.first()
(text[*#t*],) + category.slice(1)
})
.map(
category => category.map(cell => text(size: display_size)[#cell])
)
}
#let part_included(folder: "") = {
if (folder != "") and (not folder.ends-with("/")) {
folder += "/"
}
return (file) => folder + file
}
#let insert_code-snippet(
title: "",
code,
border: true,
) = {
let code_snippet = par(justify: false)[#text(size: 8pt)[#code]]
figure(
kind: "Code snippet", supplement: "Code",
caption: [#title],
if border { rect[#code_snippet] }
else { code_snippet },
)
}
#let insert_figure(
title,
folder: "../" + __constants_toml.figures_folder,
width: 100%,
border: true,
) = {
let img = image(folder + "/" + title + ".png", width: width)
figure(
caption: [#title],
if border { rect[#img] }
else { img },
)
}
// Taken from https://github.com/typst/typst/issues/2196#issuecomment-1728135476
#let to_string(content) = {
if content.has("text") {
content.text
} else if content.has("children") {
content.children.map(to_string).join("")
} else if content.has("body") {
to_string(content.body)
} else if content == [ ] {
" "
}
}
#let insert_acronym(
acronym
) = {
let _type = "acronym"
[
#figure(
kind: _type, supplement: upper("*"), caption: none, acronym
) #label(
_type + "_" + to_string(acronym).replace(regex("[^0-9A-Za-z_\-]"), "_")
)
]
}
#let todo(data) = {
text(16pt, red)[TO\[] + " " + emph(text(12pt, black)[#data]) + text(16pt, red)[\]DO <todo>]
}
#let transpose(arr) = {
array.zip(..arr)
}
|
|
https://github.com/csunibo/linguaggi-di-programmazione | https://raw.githubusercontent.com/csunibo/linguaggi-di-programmazione/main/prove/totale/totale-2024-07-02-soluzione.typ | typst | #import "@preview/finite:0.3.0": automaton
#show link: underline
#set align(center)
= Soluzione Linguaggi Totale
==== 2024-07-02
#set align(left)
#set par(
justify: true
)
_NOTA: Questa è una soluzione proposta da me, non è detto che sia giusta. Se
trovate errori segnalateli o meglio correggeteli direttamente_ :)
+ Le due affermazioni sono entrambe false:
#set enum(numbering: "a)")
+ Supponiamo che A se sia la classe dei linguaggi regolari e che B sia la
classe dei linguaggi liberi deterministici. Ovviamente $A subset.eq B$. Tuttavia A
è chiusa rispetto all'unione mentre B non lo è.
+ Supponiamo che B sia la classe dei linguaggi liberi e che A sia la classe
dei linguaggi liberi deterministici. Ovviamente $A subset.eq B$. Tuttavia B è
chiusa rispetto all'unione mentre A non lo è.
+ Rappresentiamo l'NFA:
#align(
center,
automaton((
q0: (q1:"a", q2: "a"),
q1: (q3:"e", q4:"a"),
q2: (),
q3: (),
q4: (q1:"a", q5:"a"),
q5: (),
),
layout: (
q0: (-3, 0),
q1: (0, 0),
q2: (-3, -3),
q3: (0, -3),
q4: (3, 0),
q5: (3, -3),
),
style: (
q0-q2: (curve: 0),
q1-q3: (curve: 0),
q4-q5: (curve: 0),
),
initial: "q0",
final: "q2, q3"
)
)
Il DFA ottenuto per costruzione di sottoinsiemi:
#align(
center,
automaton((
A: (B:"a"),
B: (C:"a"),
C: (D:"a"),
D: (C:"a"),
),
initial: "A",
final: "B, D"
)
)
Controlliamo che sia minimo costruendo la tabella a scala:
#let empty_cell = table.cell(
stroke: none
)[]
#align(
center,
table(
columns: 4,
rows: 4,
[*B*], [$x_0$], empty_cell, empty_cell,
[*C*], [], [$x_0$], empty_cell,
[*D*], [$x_0$], [], [$x_0$],
empty_cell, [*A*], [*B*], [*C*]
)
)
Costruiamo il DFA minimo $M'$:
#align(
center,
automaton((
A: (B:"a"),
B: (A:"a"),
),
initial: "A",
final: "B"
)
)
Il linguaggio riconosciuto è $L[M'] = {a^(2n+1) | n >= 0}$. L'espressione
regolare associata: $a(\aa)^*$
+ Costruiamo la tabella dei first e dei follow:
#align(
center,
table(
columns: 3,
table.header(
empty_cell, [*First*], [*Follow*]
),
[S], [a, b, $epsilon$], [\$],
[A], [a, $epsilon$], [b, \$],
[B], [b, $epsilon$], [\$]
)
)
#set enum(numbering: "i)")
+ Verifichiamo che la grammatica è di classe $\LL(1)$:
#align(
center,
$
- "First"(a A b) sect "First"(epsilon) = emptyset \
{a} sect {epsilon} = emptyset \ \
- "First"(a A b) sect "Follow"(A) = emptyset \
{a} sect {b, \$} = emptyset \ \
- "First"(b B) sect "First"(epsilon) = emptyset \
{b} sect {epsilon} = emptyset \ \
- "First"(b B) sect "Follow"(B) = emptyset \
{b} sect {\$} = emptyset \ \
$
)
$G$ è di classe $\LL(1)$ per un noto teorema visto a lezione.
+ Costruiamo la tabella di parsing $\LL(1)$:
#align(
center,
table(
columns: 4,
table.header(
empty_cell, [*a*], [*b*], [*\$*]
),
[$S$], [$S -> A B$], [$S -> A B$], [$S -> A B$],
[$A$], [$A -> a A b$], [$A -> epsilon$], [$A -> epsilon$],
[$B$], [], [$b -> b B$], [$B -> epsilon$]
)
)
+ Facciamo vedere il parsing sull'input: $a b b$ \
#grid(
columns: (auto, 1cm, auto),
rows: 0.6cm,
[$a b b \$$], [], [$S\$$],
[$$], [], [$A B\$$],
[$$], [], [$a A b B\$$],
[$b b$], [], [$A b B\$$],
[$$], [], [$b B\$$],
[$b$], [], [$B\$$],
[$b$], [], [$b B\$$],
[$$], [], [$B\$$],
[$$], [], [$\$$],
)
Vediamo con la stringa $epsilon$: \
#grid(
columns: (auto, 1cm, auto),
rows: 0.6cm,
[$\$$], [], [$S\$$],
[$\$$], [], [$A B\$$],
[$\$$], [], [$B\$$],
[$\$$], [], [$\$$],
)
+ Costruiamo il parser $\LR(0)$. Non so come fare stati grandi con tutti gli
items in typst quindi scrivo l'automa e poi definisco gli stati a parte:
#align(
center,
automaton((
q0: (q1:"S", q2: "a"),
q1: (),
q2: (q2:"a", q3:"S", q5:"B", q7:"b", q9:"c"),
q3: (q4:"a"),
q4: (),
q5: (q6:"a"),
q6: (),
q7: (q7:"b", q8:"B", q9:"c"),
q8: (),
q9: (),
),
layout: (
q0: (-7, 0),
q1: (-3, 3),
q2: (-3, 0),
q3: (3, 2),
q4: (5, 3),
q5: (2, 0),
q6: (4, 0),
q7: (-2, -2),
q8: (0, -2),
q9: (-5, -2),
),
initial: "",
final: "",
style: (
q0-q1: (curve: 0.5),
q2-q9: (curve: -0.5),
q2-q7: (curve: 1.5),
q3-q4: (curve: 0),
q5-q6: (curve: 0),
q7-q8: (curve: 0),
)
)
)
#table(
columns: 2,
align: horizon,
[q0], [ $S' -> .S$ \ $S-> . a S a$ \ $S-> . a B a$ ],
[q1], [$S' -> S .$],
[q2], [$S -> a . S a $ \ $S -> a . B a$ \ $ S -> . a S a$ \ $S -> . a B a$ \
$B -> . b B$ \ $B -> . c$],
[q3], [$S -> a S . a$],
[q4], [$S -> a S a .$],
[q5], [$S -> a B . a$],
[q6], [$S -> a B a .$],
[q7], [$B -> b . B$ \ $B -> . b B$ \ $B -> . c$],
[q8], [$B -> b B .$],
[q9], [$B -> c .$]
)
Costruiamo la tabella $\LR(0)$ sapendo che $"Follow"(S) = {\$, a}$ e
$"Follow"(B) = {a}$:
#table(
columns: (1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
align: center,
table.header(
[], [*a*], [*b*], [*c*], [*\$*], [*S*], [*B*]
),
$0$, [S2], [], [], [], [G1], [],
$1$, [], [], [], [Acc], [], [],
$2$, [S2], [S7], [S9], [], [G3], [G5],
$3$, [S4], [], [], [], [], [],
$4$, [R1], [], [], [R1], [], [],
$5$, [S6], [], [], [], [], [],
$6$, [R2], [], [], [R2], [], [],
$7$, [], [S7], [S9], [], [], [G8],
$8$, [R3], [], [], [], [], [],
$9$, [R4], [], [], [], [], [],
)
Non essendoci conflitti $G$ è di classe SLR(1). Il Linguaggio generato da $G$ è:
#align(
center,
$L(G) = {a^n b ^m c a^n | n >= 1, m >= 0}$
)
Questo perché $L(B) = b^* c = {b^m c | m >= 0}$ e con la produzione $S -> a B a$
genero stringhe di tipo $a b^m c a$ e con la produzione $S -> a S a$ posso
aggiungere $a^k$ all'inizio e in coda con $k >= 0$.
+
+
+ Risposta:
```js
ListPersona { p: Persona, next: ListPersona } + None
ListOggetto { o: Oggetto, next: ListOggetto } + None
Persona { name: string, figli: ListPersona, averi: ListOggetto }
Oggetto { name: string, prop: ListPersona }
Oggetto scudo = { name: "scudo", prop: None }
Oggetto spada = { name: "spada", prop: None }
Oggetto lancia = { name: "lancia", prop: None }
Persona ares = { name: "Ares", figli: None, averi: {
o: scudo, next: {o: spada, next: None }}}
Persona atena = { name: "Atena", figli: None, averi: {
o: scudo, next: {o: lancia, next: None }}}
scudo.prop = { p: ares, next: { p: atena, next: None }}
spada.prop = { p: ares, next: None }
lancia.prop = { p: atena, next: None }
Persona Zeus = { name: "Zeus", figli: { p: ares, next: { p: atena, next: None }}}
```
+ Come possiamo vedere eseguendo il codice sottostante il risultato è *2* e *42*.
```java
class A {
int i = 0;
public A c(A a, int n) {
if (n <= 1) { i = 1; }
else {
int b = new B().c(new A(), a.i()).i;
int c = new B().c(new A(), n - 1 - a.i()).i;
i = i + b * c;
}
return this;
}
public int i() {
return i;
}
}
class B extends A {
int i = 0;
public A c(A a, int n) {
a.c(this, n);
if (++i < n) { c(a, n); }
return a;
}
public int i() {
return i;
}
}
class esercizio {
public static void main(String[] argv) {
A b = new B();
int x = 2;
System.out.println(b.c(new A(), x).i);
b = new B();
x = 5;
System.out.println(b.c(new A(), x).i);
}
}
```
Sinceramente è un esercizio complesso e molto lungo. Giallorenzo ha dato il
massimo dei punti anche se si rispondeva solo il risultato di $x = 2$ e non si
faceva $x = 5$. La soluzione che ha scritto alla lavagna è la seguente, però
non so quanto possa essere utile:
```java
c(..., 0) = 1
c(..., 1) = 1
c(..., 2) = 2
i0 = 0 + 1 * 1 = 1
i1 = 1 + 1 * 1 = 2
c(..., 3) =
i0 = 0 + 1 * 2 = 2
i1 = 2 + 1 * 1 = 3
i2 = 3 + 2 * 1 = 5
c(..., 4) =
i0 = 0 + 1 * 5 = 5
i1 = 5 + 1 * 2 = 7
i2 = 7 + 2 * 1 = 9
i3 = 9 + 5 * 1 = 14
c(..., 5) = 42
i0 = 0 + 1 * 14 = 14
i1 = 14 + 1 * 5 = 19
i2 = 19 + 2 * 2 = 23
i3 = 23 + 5 * 1 = 28
i4 = 28 + 14 * 1 = 42
```
Per i più curiosi è la seguenza di #link("https://en.wikipedia.org/wiki/Catalan_number")[Catalan]
|
|
https://github.com/antonWetzel/Masterarbeit | https://raw.githubusercontent.com/antonWetzel/Masterarbeit/main/expose/main.typ | typst | #let boxed(content) = rect(inset: 0pt, stroke: black + 3pt, content)
//https://home.uni-leipzig.de/~gsgas/fileadmin/Recommendations/Expose_Recommendations.pdf
//https://www.uni-bremen.de/fileadmin/user_upload/fachbereiche/fb7/gscm/Dokumente/Structure_of_an_Expose.pdf
#show: (document) => {
set text(lang: "de", font: "Noto Sans", region: "DE", size: 11pt, weight: 400, fallback: false)
show math.equation: set text(font: "Noto Sans Math", weight: 600, fallback: false)
set par(justify: true)
show heading: it => { v(5pt); it; v(5pt); }
// set page(columns: 2)
show raw: it => text(size: 1.2em, it)
set enum(numbering: "I.1.")
document
}
#align(center, {
set text(size: 1.25em)
text(size: 1.25em, [= Exposé])
{
set align(left)
set par(hanging-indent: 1cm)
align(left, pad(x: 2.5cm)[
*Arbeitstitel: Berechnung charakteristischen Eigenschaften von botanischen Bäumen mithilfe von 3D-Punktwolken.*
])
}
v(1fr)
table(
columns: (0.7fr, 1fr),
column-gutter: 0.2cm,
align: (right, left),
stroke: none,
[*Name:*], [*<NAME>*],
[E-Mail:], link("mailto:<EMAIL>", [<EMAIL>]),
[Matrikelnummer:], [60451],
[Studiengang:], [Informatik Master],
[], [],
[*Betreuer:*], [*<NAME>*],
[E-Mail:], link("mailto:<EMAIL>", [<EMAIL>]),
[], [],
[*Professor:*], [*Prof. Dr.-Ing. <NAME>*],
[E-Mail:], link("mailto:<EMAIL>", [<EMAIL>]),
[], [],
[Fachgebiet:], [Data-intensive Systems and Visualization Group],
[], [],
[Datum:], datetime.today().display("[day].[month].[year]"),
)
v(2fr)
image(width: 70%, "../images/logo_tui.svg")
pagebreak()
})
= Motivation
Größere Gebiete wie Teile von Wäldern können als 3D-Punktwolken gescannt werden, aber der Zustand vom Waldstück ist nicht direkt aus den Daten ersichtlich. Mit einer automatisierten Analyse der Daten kann das Waldstück digitalisiert werden, wodurch Informationen wie Artenbestand oder Gesundheit abgeschätzt werden können.
Diese Arbeit erkundet die Möglichkeiten einer automatisierten Auswertung von 3D-Punktwolken von Wäldern. Dazu gehört eine Analyse, welche charakteristischen Eigenschaften aus den Daten ermittelt werden können und wie diese geeignet Visualisiert werden können.
Durch die Kombination von Analyse und Visualisierung können die gefundenen Eigenschaften interaktive aufgearbeitete werden, was hoffentlich die Analyse von Waldstücken vereinfacht. Dabei kann die Visualisierung auf die genauen Anforderungen spezialisiert werden, um die Ergebnisse ideal zu präsentieren. Eine einfache Visualisierung ist in @overview zu sehen.
#figure(
caption: [Visualisierung von einem Waldstück | Datensatz @data, Datei `ALS-on_SP02_2019-07-05_140m.laz`],
boxed(image(width: 100%, "../images/overview.png")),
) <overview>
= Stand der Technik
Punktwolken können mit unterschiedlichen Lidar Scanverfahren aufgenommen werden. Aufnahmen vom Boden oder aus der Luft bieten dabei verschiedene Vor- und Nachteile @scantech. Bei einem Scan von Boden aus, kann nur eine kleinere Fläche abgetastet werden, dafür mit erhöhter Genauigkeit, um einzelne Bäume genau zu analysieren @terrestriallidar. Aus der Luft können größere Flächen erfasst werden, wodurch Waldstücke aufgenommen werden können, aber die Datenmenge pro Baum ist geringer @forestscan.
Nach der Datenerfassung können relevante Informationen aus den Punkten bestimmt werden, dazu gehört eine Segmentierung in einzelne Bäume @treeseg und die Berechnung von Baumhöhe oder Kronenhöhe @forestscan.
Ein häufiges Format für Lidar-Daten ist das LAS Dateiformat @las. Bei diesem werden die Messpunkte mit den bekannten Punkteigenschaften gespeichert. Je nach Messtechnologie können unterschiedliche Daten bei unterschiedlichen Punktwolken bekannt sein, aber die Position der Punkte ist immer gegeben. Aufgrund der großen Datenmengen werden LAS Dateien häufig im komprimierten LASzip Format @laz gespeichert. Die Kompression ist Verlustfrei und ermöglicht eine Kompressionsrate zwischen $5$ und $15$ je nach Eingabedaten.
_LASTools_ @lastools ist eine Sammlung von Software für die allgemeine Verarbeitung von LAS Dateien. Dazu gehört die Umwandlung in andere Dateiformate, Analyse der Daten und Visualisierung der Punkte. Durch den allgemeinen Fokus ist die Software nicht für die Verarbeitung von Waldteilen ausgelegt, wodurch Funktionalitäten wie Berechnungen von Baumeigenschaften mit zugehöriger Visualisierung nicht gegeben sind.
= Ziel
Das Ziel ist die Entwicklung von einem Softwareprojekt für die spezialisierte Auswertung und Visualisierung von 3D-Punktwolken von Wäldern. Als Eingabe soll nur die Punktwolken ohne weiteren Informationen ausreichen. Durch die Kombination von Auswertung und Visualisierung kann über eine allgemeine Visualisierung von LAS Dateien hinausgegangen werden.
Im Folgenden ist eine Auflistung der momentanen Ziele. Während der Entwicklung können die Ziele an neue Erkenntnisse und Anforderungen angepasst werden.
#box(height: 22.5em, columns(2)[
+ Datensatz in Bäume unterteilen
- Boden oder andere Objekte filtern
+ Bestimmung von Eigenschaften
- Baum- und Kronenhöhe
- Stamm- und Kronendurchmesser
+ Segmentierung von einem Baum
- Struktur als Graph
- Baum unterteilen in
- Stamm
- Äste
- Blätter
+ 3D-Modelle
- Punkte filtern und Triangulieren
- Farben aus der Visualisierung oder von generierten Texturen
- Vergleich zu synthetischen Modellen
+ Visualisierung
- ein oder mehrere Bäume
- Färbung von Punkten
- Farbverlauf mit Punkthöhe
- je nach Baum
- je nach Segment
- Punktgröße und -normale
- Detailstufen
- Eye-Dome Lighting @eyedome
+ weitere Verarbeitung
- Klassifikator für Baumarten
- Validierung der 3D-Modelle basierend auf synthetischen Bäumen
- Vergleich der unterschiedlichen Messmethoden
- Vergleich zu Verfahren basierend auf Bilddaten
])
Die berechneten Eigenschaften werden für die Visualisierung verwendet, aber können auch für weitere Projekte als Grundlage dienen. Dazu gehört das Trainieren von neuronalen Netzwerken für die Klassifikation von Bäumen oder die Analyse von Ökosystemen.
= Geplante Umsetzung
Für die technische Umsetzung wird die Programmiersprache Rust und die 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 von den Systemeigenschaften.
== Testdaten
Der benutze Datensatz @data beinhaltet $12$ Hektar Waldfläche in Deutschland, Baden-Württemberg. Die Daten sind mit Laserscans aufgenommen, wobei die Scans von Flugzeugen, Drohnen und vom Boden aus durchgeführt wurden. Dabei entstehen 3D-Punktwolken, welche im komprimiert LAS Dateiformat gegeben sind.
Der Datensatz ist bereits in einzelne Bäume unterteilt. Zusätzlich wurden für $6$ Hektar die Baumart, Höhe, Stammdurchmesser auf Brusthöhe und Anfangshöhe und Durchmesser der Krone gemessen. Mit den bereits bestimmten Eigenschaften können automatisch berechnete Ergebnisse validiert werden.
#bibliography("expose.bib")
|
|
https://github.com/TheWebDev27/Calc-II-Honors-Project | https://raw.githubusercontent.com/TheWebDev27/Calc-II-Honors-Project/main/part1.typ | typst | #set par(
leading: .75em
)
#set text(
font: "New Computer Modern",
size: 16pt
)
#set align(center)
#text(weight: "bold")[Real and Nonstandard Analyses: An Overview] \
#set text(
size: 12pt
)
Preston Vo \ \ \
#set text(
size: 10pt
)
#set align(center)
= Introduction
#set align(left)
A *set* is a collection of elements. These elements can be anything: numbers, shapes, colors, and so on. For instance, consider the set A of the primary colors:
#set align(center)
$A = {"red, blue, yellow"}.$
#set align(left)
A *function* is a mapping between the elements of two sets where each element from one set is assigned to exactly one element from the other. In the realm of single variable calculus, functions predominantly deal with sets of real numbers. For example, the function
#set align(center)
$f(x)=x^2$
#set align(left)
takes a set of inputs (x) and produces a corresponding set of their squares f(x) in the form of *ordered pairs*:
#set align(center)
#table(
columns: (auto, auto),
inset: 7pt,
align: center,
[x], [f(x)],
$-3$, $9$,
$-2$, $4$,
$-1$, $1$,
$0$, $0$,
$1$, $1$,
$2$, $4$,
$3$, $9$
)
#set align(left)
Plotting the points generated by $f(x)$ on the XY coordinate plane produces the following graph:
#set align(center)
#set text(9pt)
#figure(
image("images/parabola.png", width: 55%),
caption: [f(x) produces a parabolic curve]
)
#set text(10pt)
#set align(left)
*Limits* analyze how the outputs of such functions behave as their inputs ($x$) approach either a particular point or $infinity$. For example, the parabolic function above approaches 4 as $x$ approaches $2$ and is denoted like so:
#set align(center)
$lim_(x -> 2)x^2=4.$
#set align(left)
As $x$ approaches $infinity$, $x^2$ also approaches $infinity$:
#set align(center)
$lim_(x -> infinity)x^2 = infinity.$
#set align(left)
Limits are a result of *analysis*, an area of mathematics that deals with continuous change and continuous functions, broadly speaking. I intend to not only explore and compare two different branches of analysis that ultimately lead to the same results encountered in calculus, but to do so in a meticulously pedagogical manner. One branch relies on a rigorous definition of the limit, while the other abandons the idea of limits entirely in favor of a concept utilized in the upbringing of calculus over the past several centuries.
#set align(center)
#v(20pt)
= The Standard Approach
#set align(left)
#text(14pt)[
Introduction
]
*Real analysis* is the study of functions, sequences, and sets involving real numbers, and it is used as the traditional means of formalizing the mechanisms presented in calculus courses. This overview of how real analysis builds toward certain calculus principles will follow section A.2 of Appendix A in
#set align(center)
<NAME>. (1996). _Calculus With Analytic Geometry_ (2nd ed.), Mcgraw-Hill Education.
#set align(left)
Being mindful of the fact that the absolute value of the difference between any two values, $abs(a-b)$, represents the distance between them will help greatly in understanding the notation that follows. The limit is defined like so:
#set text(font: "Source Serif")
#set align(center)
#grid(
columns: 80%,
rows: auto,
[
#set align(left)
Let a function $f(x)$ be defined on some interval containing the number $c$ such that there are $x$'s in the domain of $f(x)$ where
#set align(center)
$0 < |x - c| < delta$
#set align(left)
for every positive number $delta$. The statement
#set align(center)
$lim_(x -> c)f(x) = L$
],
[
\
\
],
[
#set align(left)
is then defined like so: For every positive number $epsilon$, there exists a positive number $delta$ such that
#set align(center)
$|f(x) - L| < epsilon$
#set align(left)
for every $x$ in the domain of $f(x)$ where
#set align(center)
$0 < |x - c| < delta$
]
)
#set text(font: "New Computer Modern")
#set align(left)
This definition states that $f(x)$ approaches some value $L$ as $x$ approaches a some number $c$ if it can be shown that, for any set of outputs that lie within some distance $epsilon$ from $L$, there exists a corresponding set of inputs ($x$'s) that lie within some distance $delta$ from $c$ which _guarantees_ that $f(x)$ falls within $epsilon$ of $L$. In this sense, we can bring the range of outputs as close as we want to $L$ ($epsilon arrow 0$) while being absolutely sure that $f(x)$ lies within it. This is known as the *epsilon-delta definition* of the limit.
#set text(9pt)
#figure(
image("images/epsilon-delta limit.png", width: 65%),
caption: [Epsilon-delta definition of the limit visualized]
)
#set text(10pt)
The interval $(L-epsilon, L+epsilon)$ describes the range of outputs that lie within a distance $epsilon$ from $L$. One detail to note in Figure 2 is the presence of $delta_1$ and $delta_2$. This is because the $x$ corresponding to $L - epsilon$ does not necessarily lie the same distance away from $c$ as the $x$ corresponding to $L + epsilon$, since the rate at which $f(x)$ changes may vary as $x$ sweeps from $c - delta_1$ to $c + delta_2$. To illustrate this, notice how the curvature of the curve is steeper on the left-hand side of $c$ compared to that on the right-hand side. This means that sweeping through some range of outputs on the left requires a smaller increment of $x$ as opposed to sweeping through that same range of outputs on the right, since the output of the function increases at a faster rate on the left. Therefore, $delta_1 < delta_2$ for this particular graph, and keep in mind that they do not represent $x$ values but rather _distances_ from $x=c$.
This complication can be readily resolved by letting $delta$ equal the smaller of $delta_1$ and $delta_2$:
#set align(center)
$delta = min(delta_1 , delta_2)$.
#set align(left)
$min()$ is shorthand for taking the smallest value amongst the set of numbers present between the parentheses. For instance, if $x = min(1, 2, 3)$, then $x = 1$. Allowing $delta$ to be defined in this way works because of the following reasoning: Assume that $delta_1 < delta_2$ and that $|x - c| < delta_2$ implies $|f(x) - L| < epsilon$ for some input $x$. If $|x - c| < delta_1$, then $|x - c| < delta_2$ since $delta_1 < delta_2$. It is therefore assured that $|f(x) - L| < epsilon$. \ \
#text(14pt)[
Employing the Definition
]
The epsilon-delta definition of the limit can now be used to prove various properties of functions. As a basic example, consider the following theorem:
#set text(font: "Source Serif")
#set align(center)
#grid(
columns: 80%,
rows: auto,
[
#set align(left)
*Theorem 1* \
If f(x) = x, then $lim_(x -> a)f(x) = a$, or
#set align(center)
$lim_(x -> a)x = a$
]
)
#set text(font: "New Computer Modern")
#set align(left)
In order to prove this limit, we need to demonstrate that for any set of outputs that lie within $epsilon$ of the limit ($a$), there exists a corresponding set of inputs that lie within $delta$ of $x=a$ ensuring that the output of $f(x)=x$ lies within $epsilon$ from $a$.
To start, choose some $epsilon > 0$, and let $delta = epsilon$. For any $x$ satisfying the inequalities $0 < |x - a| < delta$, we know that $|f(x) - a| < epsilon$. This is because $f(x) = x$, and $delta = epsilon$. The theorem is therefore proven, as for any set of outputs that lie within $epsilon$ of $a$, we've found an appropriate value of $delta$ that satisfies the definition of the limit.
#pagebreak()
We can also prove some essential limit laws: their sums, differences, products, and quotients.
#set text(font: "Source Serif")
#set align(center)
#grid(
columns: 80%,
rows: auto,
[
#set align(left)
*Theorem 2 - Limit Laws* \
If $lim_(x -> a)f(x) = L$ and $lim_(x -> a)g(x) = M$, then
#table(
columns: (20pt, auto),
align: (right, left),
stroke: none,
[(i)], $lim_(x -> a)[f(x) + g(x)] = L + M$,
[(ii)], $lim_(x -> a)[f(x) - g(x)] = L - M$,
[(iii)], $lim_(x -> a)f(x)g(x) = L M$,
[(iv)], $display(lim_(x -> a)f(x)/g(x) = L/M)$
)
]
)
#set text(font: "New Computer Modern")
#set align(left)
To prove (i), we let $epsilon > 0$ be given and allow $delta_1, delta_2 > 0$ where
#set align(center)
$0 < |x - a| < delta_1 => |f(x) - L| < 1/2 epsilon$
#set align(left)
and
#set align(center)
$0 < |x - a| < delta_2 => |f(x) - M| < 1/2 epsilon$.
#set align(left)
For those unfamiliar with the $=>$ symbol, it means that the statement following it is implied (or logically follows) from the statement preceding the symbol.
The $1/2$'s in front of the $epsilon$'s may cause some confusion, but recall that when $lim_(x -> c)f(x) = L$, the epsilon-delta definition tells us that there exists a set of $x$'s lying within some distance $delta$ from $c$ such that the distance between $f(x)$ and $L$ is always less than $epsilon$. Knowing this, it then follows that if there exists $delta > 0$ such that $|f(x) - L| < 1/2 epsilon$ for some $epsilon > 0$, then $|f(x) - L| < epsilon$, because $1/2 epsilon$ is smaller than $epsilon$.
Continuing the proof, we let $delta = min(delta_1, delta_2)$. If $0 < |x - a| < delta$, then
#set align(center)
$abs([f(x) + g(x)] - (L + M)| &= |[f(x) - L] + [g(x) - M]) #h(40pt) &(1)\
&<= |f(x) - L| + |g(x) - M| &(2)\
&< 1/2 epsilon + 1/2 epsilon = epsilon, &(3)$
#set align(left)
proving (i). Analyzing the three-step sequence above in further detail: (1) takes advantage of the associative property of addition and moves terms around. (2) is a subtle application of the distances variation of the *triangle inequality* which states that, for real numbers $x$ and $y$,
#set align(center)
$|x + y| <= |x| + |y|$.
#set align(left)
It essentially says that the distance between 0 and the sum of two numbers can be no more than the combined distances of $x$ to 0 and $y$ to 0. For example, if $x=3$ and $y=-1$, then
#set align(center)
$abs(x+y)=abs(3-1)=2<4=abs(3)+abs(-1)=abs(x)+abs(y)$.
#set align(left)
While a formal proof is omitted, it may help to think of this inequality in terms of walking in two opposite directions. In particular, let positive numbers represent walking forward one way, while negative numbers represent walking backwards the other way. Therefore, if 0 is the position where you start, $abs(x+y)$ represents the distance you end at from 0 after some combination of walking forwards and backwards, while $abs(x) + abs(y)$ represents the #emph[total] distance walked. The distance you end at from 0 can only ever be as large as the total distance walked (by walking only forwards or only backwards), so $|x + y| <= |x| + |y|$. In the case of (2), the two values involved in the triangle inequality are $f(x) - L$ and $g(x) - M$.
Finally, (3) substitutes both $|f(x) - L|$ and $|g(x) - M|$ for $1/2 epsilon$. Since $|f(x) - L| < 1/2 epsilon$ and $|g(x) - M| < 1/2 epsilon$, it follows that $|f(x) - L| + |g(x) - M| < 1/2 epsilon + 1/2 epsilon$. The theorem is ultimately proven, because the difference between the function, $f(x) + g(x)$, and the desired limit, $L + M$, was shown to be less than any $epsilon > 0$ given an appropriate $delta$.
#pagebreak()
#set text(font: "Source Serif")
*(ii)* $lim_(x -> a)[f(x - g(x))] = L - M$
#set text(font: "New Computer Modern")
The proof of (ii) is similar to that of (i). We once again allow $delta_1, delta_2 > 0$ where
#set align(center)
$0 < |x - a| < delta_1 => |f(x) - L| < 1/2 epsilon$
#set align(left)
and
#set align(center)
$0 < |x - a| < delta_2 => |f(x) - M| < 1/2 epsilon$.
#set align(left)
Let $delta = min(delta_1, delta_2)$. If $0 < |x - c| < delta$, then
#set align(center)
$abs([f(x) - g(x)| - (L - M)]) &= abs([f(x) - L] + [M - g(x)]) \
&<= |f(x) - L| + |M - g(x)| \
&= |f(x) - L| + |g(x) - M| \
&< 1/2 epsilon + 1/2 epsilon = epsilon,$
#set align(left)
proving (ii). \ \
#set text(font: "Source Serif")
*(iii)* $lim_(x -> a)f(x)g(x) = L M$
#set text(font: "New Computer Modern")
Proving (iii) is more complicated. We begin by adding and subtracting $f(x)M$ to help relate the quantity $f(x)g(x) - L M$ to the differences $f(x) - L$ and $g(x) - M$:
#set align(center)
$|f(x)g(x) - L M| &= |[f(x)g(x)-f(x)M] + [f(x)M - L M]| \
&<= |f(x)g(x) - f(x)M| + |f(x)M - L M| (triangle.filled.t #text[ inequality]) \
&= |f(x)||g(x) - M| + |M||f(x) - L| \
&<= |f(x)||g(x) - M| + (|M| + 1)|f(x) - L|. #h(31pt) (4)$
#set align(left)
Provided some $epsilon > 0$, it is certain that $delta_1, delta_2, delta_3 > 0$ all exist where
#set align(center)
$0 < |x - a| < delta_1 &=> |f(x) - L| < 1 => |f(x)| < |L| + 1; #h(40pt) &(5)\
display(0 < |x - a| < delta_2 &=> |g(x) - M| < 1/2 epsilon(1 / (|L| + 1))); &(6)\
display(0 < |x - a| < delta_3 &=> |f(x) - L| < 1/2 epsilon(1/(|M| + 1))). &(7)$
#set align(left)
The first implication in (5) comes from the fact that $lim_(x -> a)f(x) = L$, so a $delta_1 > 0$ exists for every $epsilon > 0$, and $epsilon$ is set to 1. To see why the second implication in (5) is valid, consider this: We know by the expression $abs(f(x) - L) < 1$ that the distance between the quantities $f(x)$ and $L$ is less than 1. Now if we think of $abs(f(x))$ as the distance $f(x)$ lies from 0 and $abs(L)$ as the distance $L$ lies from 0, then $abs(L) + 1$ has to be larger than $abs(f(x))$, so $abs(f(x)) < abs(L) + 1$. The reader is encouraged to think about this carefully until they feel absolutely certain of the validity in this argument.
#set align(left)
While (6) and (7) may look confusing, they once again stem from the definition of the limit. For #v(-2pt)instance, since $lim_(x -> a)g(x) = M$, a $delta_2 > 0$ exists for every $epsilon > 0$. Since $display(1/2 dot 1/(abs(M) + 1) < 1)$, this means $display(1/2 epsilon(1/(abs(M) + 1)) < epsilon)$, so the inequalities are indeed valid.
\
#v(0pt)Resuming the proof, we let $delta = min(delta_1, delta_2, delta_3)$. Then
#set align(center)
$0 < |x - a| < delta => |f(x)g(x) - L M| < 1/2 epsilon + 1/2 epsilon = epsilon$,
#set align(left)
proving (iii). This final step is justified as so: (4) showed that
#set align(center)
$|f(x)g(x) - L M| <= |f(x)||g(x) - M| + (|M| + 1)|f(x) - L|.$
#set align(left)
#v(3pt) Since $|f(x)| < |L| + 1$ from (5), and $display(|g(x) - M| < 1/2 epsilon(1/(|L| + 1)))$ from (6),
#set align(center)
#v(5pt) $display(|f(x)||g(x) - M| < (|L| + 1)[1/2 epsilon(1/(|L| + 1))] = 1/2 epsilon)$.
#set align(left)
Since $|f(x) - L| < 1/2 epsilon(1/(|M| + 1))$,
#set align(center)
$display((|M| + 1)|f(x) - L| < (|M| + 1)[1/2 epsilon(1/(|M| + 1))] = 1/2 epsilon)$,
#set align(left)
justifying the final step. \ \
#set text(font: "Source Serif")
*(iv)* $display(lim_(x -> a)f(x)/g(x) = L/M)$
#set text(font: "New Computer Modern")
To prove (iv), we take advantage of the fact that
#set align(center)
$display(lim_(x -> a)[f(x)/g(x)] = lim_(x -> a)[f(x) dot 1/g(x)])$
#set align(left)
due to (iii), so all that is required is to show that
#set align(center)
$display(lim_(x -> a)[1/g(x)] = [1/M])$.
#set align(left)
If $g(x) != 0$, then
#set align(center)
$#h(78pt) display(abs(1/g(x) - 1/M) = abs(g(x) - M)/(|M||g(x)|)) #h(78pt)$ $(1)$
#set align(left)
Let $delta_1 > 0$ where
#set align(center)
$#h(50pt) 0 < |x - a| < delta_1 => |g(x) - M| < 1/2 |M| #h(50pt) (2)$
#set align(left)
so that
#set align(center)
$|g(x)| &> 1/2|M| \
display(1/(|g(x)|) &< 2/(|M|))$
#set align(left)
which means
#set align(center)
#h(65pt) $display(abs(1/g(x) - 1/M) < 2/(|M|^2) abs(g(x) - M))$. #h(65pt) (3)
#set align(left)
From (2), we know that the distance between $g(x)$ and $M$ is smaller than $1/2 |M|$. This means that
#v(0pt) $1/2 abs(M) < abs(g(x)) < 3/2 abs(M)$, so $abs(g(x)) > 1/2 abs(M)$. (3) is achieved by substituting $display(1/abs(g(x)))$ on the right hand side
#v(-3pt) of (1) with $display(2/abs(M))$.
Let $epsilon > 0$ be provided and $delta_2 > 0$ such that
#set align(center)
$0 < abs(x - a) < delta_2 => abs(g(x) - M) < display(abs(M)^2/2) epsilon$.
#set align(left)
If $delta = min(delta_1, delta_2)$, then
#set align(center)
$0 < abs(x - a) < delta =>display(abs(1/g(x) - 1/M)) < display(2/abs(M)^2) dot display(abs(M)^2/2) epsilon= epsilon$,
#set align(left)
#v(3pt) the final step coming from substituting $abs(g(x) - M)$ in (3) with $display(abs(M)^2/2 epsilon)$. This concludes the proof of (iv) #v(-3pt) and ultimately Theorem 2 in its entirety. It is interesting seeing how the limit laws are, in essence, results of sequences of subtle algebraic manipulations.
#pagebreak()
The final application of the epsilon-delta limit that will be analyzed is the classic *squeeze theorem*.
#set text(font: "Source Serif")
#set align(center)
#grid(
columns: 80%,
rows: auto,
[
#set align(left)
*Theorem 3 - Squeeze Theorem* \
If there exists a $p > 0$ where
#set align(center)
$g(x) <= f(x) <= h(x)$
#set align(left)
for all $x$ satisfying the inequalities $0 < abs(x - a) < p$, and if $lim_(x -> a)g(x) = L$ and $lim_(x -> a)h(x) = L$, then
#set align(center)
$lim_(x -> a)f(x) = L$
]
)
#set text(font: "New Computer Modern")
#set text(9pt)
#figure(
image("images/squeeze theorem.png", width: 70%),
caption: [Squeeze theorem visualized]
)
#set text(10pt)
#set align(left)
If a function $f(x)$ is bounded between two other functions $g(x)$ and $h(x)$, and $g(x)$ and $h(x)$ both approach the same limit $L$ as $x arrow a$, then $f(x)$ is "squeezed" toward $L$. For example, consider the functions $f(x)=x^2 cos (1/(x^2)), g(x) = x^2,$ and $h(x)=-x^2$ displayed in Figure 3. We can show that $x^2cos(1/(x^2))$ lies in between $x^2$ and $-x^2$ like so:
#set align(center)
$display(-1 <= cos(1/(x^2)) <= 1 \
-x^2 <= x^2cos(1/(x^2)) <= x^2).$
#set align(left)
Since $lim_(x -> 0)-x^2 = lim_(x -> 0)x^2 = 0$, the squeeze theorem tells us that $lim_(x -> 0)x^2cos(1/(x^2)) = 0$.
To prove the theorem, let $epsilon > 0$ be provided, and choose $delta_1, delta_2 > 0$ where
#set align(center)
$0 < abs(x - a) < delta_1 => L - epsilon < g(x) < L + epsilon$
#set align(left)
and
#set align(center)
$0 < abs(x - a) < delta_2 => L - epsilon < h(x) < L + epsilon$
#set align(left)
Let $delta = min(p, delta_1, delta_2)$. Then
#set align(center)
$0 < abs(x - a) < delta => L - epsilon < g(x) <= f(x) <= h(x) < L + epsilon \
L - epsilon < f(x) < L + epsilon \
abs(f(x) - L) < epsilon$
#set align(left)
and thus the theorem is proven.
#pagebreak()
As a whole, we see how real analysis employs a delicate system of distances and algebraic operations in order to concisely define what exactly a limit is and how its definition can be used to prove related theorems. This system is then used as a base to build up toward various other ideas in calculus including differentiation and integration. Such details will not be covered, as
#set align(center)
#grid(
columns: 90%,
rows: auto,
[
#set align(left)
1) The goal here is to merely gain a baseline understanding of the nature of the argumentation present in real analysis and \ 2) They warrant a deeper level of study far beyond the scope of my efforts. We will, however, get to see how the next field of analysis approaches calculus without the concept of limits. \ \
]
)
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/neoplot/0.0.1/neoplot.typ | typst | Apache License 2.0 | #let gp = plugin("neoplot.wasm")
#let gettext(it) = {
if type(it) == str {
it
} else if type(it) == content {
if it.has("text") {
it.text
} else {
panic("Content must contain field `text`")
}
} else {
panic("Invalid type `" + type(it) + "`")
}
}
#let getbytes(it) = {
if type(it) == bytes {
it
} else {
bytes(gettext(it))
}
}
#let exec(it) = str(gp.exec(getbytes(it)))
#let eval(it) = str(gp.eval(getbytes(it)))
|
https://github.com/tfachmann/unveiling-the-dark-arts-of-rotations | https://raw.githubusercontent.com/tfachmann/unveiling-the-dark-arts-of-rotations/main/README.md | markdown | # Unveiling the Dark Arts of Rotations
A short introduction to rotations, SO(3) and representations of rotations based on Geist's [Hitchhiker's Guide to SO(3)](https://github.com/martius-lab/hitchhiking-rotations).
## Build
This presentation can be built with [typst](https://github.com/typst/typst).
```sh
typst compile main.typ
```
|
|
https://github.com/IliHanSoLow/W-Seminar_typst_template | https://raw.githubusercontent.com/IliHanSoLow/W-Seminar_typst_template/main/README.md | markdown | Do What The F*ck You Want To Public License | # Typst W-Seminar Template
Dies ist ein Typst-Template für ein W-Seminar, dessen Deckblatt den Bayrischen Richtlinien entspricht.
Um das Template nutzen zu können, ladet die W-Semi-Template.typ und die W-Semi-Test.typ herrunter. Achtet darauf, dass beide Dateien im gleichen Ordner liegen. Ihr könnt die Test Datei umbenennen; sie dient nur zur Demonstration. Setzt statt den Mustertieteln, die für euch notwendigen ein und achtet darauf, dass wenn ihr die Datei kompelliert, ihr nicht die Template, sondern die ehemalige Test Datei kompelliert.
Die Bibliographie ist in einer seperaten Datei zu machen. sources.yaml [Hier das Dateiformat](https://github.com/typst/hayagriva/blob/main/docs/file-format.md). Ihr könnt auch in der offiziellen Typst Dokumentation nachschauen.
https://github.com/IliHanSoLow/W-Seminar_typst_template/assets/92159488/f94baff5-e16f-4123-919c-2d91941a3ec1
|
https://github.com/jomaway/typst-bytefield | https://raw.githubusercontent.com/jomaway/typst-bytefield/main/examples/example.typ | typst | MIT License | #import "../bytefield.typ": *
#import "../common.typ" as common
// #import "@local/bytefield:0.0.4": *
#import "@preview/codelst:2.0.0": sourcecode
#set text(font: "Rubik", weight: 300);
#let tag(value, fill: orange.lighten(45%)) = {
box(
inset: (x: 3pt, y: 0pt),
outset: (y: 3pt),
radius: 2pt,
fill: fill
)[#value]
}
#let v_ruler = grid(rows: 100%, columns: (1fr,1fr), gutter: 5pt)[
#set align(end + top);
#layout(size => {
box(height: size.height, inset: (top: 1pt, bottom: 2pt))[
#sym.arrow.t.stop;
#v(1fr)
#sym.arrow.b.stop;
]
})
][
#set align(start + horizon)
#layout(size => [
#calc.round(size.height.cm(), digits: 2) cm
])
]
#let default = tag[_default_]
#let positional = tag(fill: green.lighten(60%))[_positional_]
#let named = tag(fill: blue.lighten(60%))[_named_]
#let example(columns:1,source, showlines: none) = block(
grid(
columns:columns,
gutter: 1em,
box(align(horizon,sourcecode(showrange: showlines,source))),
box(align(horizon,eval(source.text, mode:"markup", scope: (
"bytefield" : bytefield,
"byte" : byte,
"bytes" : bytes,
"bit" : bit,
"bits" : bits,
"flag": flag,
"note" : note,
"group" : group,
"section": section,
"bitheader": bitheader,
"v_ruler": v_ruler,
"common": common,
"common.ipv4" : common.ipv4,
"common.ipv6": common.ipv6,
"common.icmp": common.icmp,
"common.icmpv6": common.icmpv6,
"common.dns": common.dns,
"common.tcp": common.tcp,
"common.tcp_detailed": common.tcp_detailed,
"common.udp": common.udp,
)))),
)
)
#set page(margin: 2cm)
= Bytefield gallery
== Colored Example
#set text(9.5pt);
#show: bf-config.with(
// field_font_size: 15.5pt,
// note_font_size: 6pt,
// header_font_size: 12pt,
// header_background: luma(200),
// header_border: luma(80),
)
#example(```typst
#bytefield(
// Config the header
bitheader(
"bytes", // adds every multiple of 8 to the header.
0, [start], // number with label
5, // number without label
-12, [#text(14pt, fill: red, "test")],
23, [end_test],
24, [start_break],
36, [Fix], // will not be shown
marker: false, // true or false or (true, false) or (false, true) (default: true)
angle: -50deg, // angle (default: -60deg)
),
// Add data fields (bit, bits, byte, bytes) and notes
// A note always aligns on the same row as the start of the next data field.
note(left)[#text(16pt, fill: blue, font: "Consolas", "Testing")],
bytes(3,fill: red.lighten(30%))[#text(8pt, "Test")],
note(right)[#set text(9pt); #sym.arrow.l This field \ breaks into 2 rows.],
bytes(2)[Break],
note(left)[#set text(9pt); and continues \ here #sym.arrow],
bits(24,fill: green.lighten(30%))[Fill],
group(right,3)[spanning 3 rows],
bytes(12)[#set text(20pt); *Multi* Row],
note(left, bracket: true)[Flags],
bits(4)[#text(8pt)[reserved]],
flag[#text(8pt)[SYN]],
flag(fill: orange.lighten(60%))[#text(8pt)[ACK]],
flag[#text(8pt)[BOB]],
bits(25, fill: purple.lighten(60%))[#v_ruler],
bytes(2)[Next],
bytes(8, fill: yellow.lighten(60%))[Multi break],
note(right)[#emoji.checkmark Finish],
bytes(2)[_End_],
)
```)
#pagebreak()
= Header Examples
#emoji.warning The new bitheader api is still a work in progress.
== Show all bits
#example(```typst
#bytefield(
bpr:16,
bitheader("all"),
..range(16).map(i => flag[B#i])
)
```)
#example(showlines: (3,4),```typst
#bytefield(
bpr:16,
msb: left,
bitheader("all"),
..range(16).map(i => flag[B#i]).rev(),
)
```)
== Show offsets
Show start and end bit of each bitbox with `bitheader("offsets")`.
#example(```typst
#bytefield(
bitheader("offsets"),
byte[LSB],
bytes(2)[Two],
flag("URG"),
bits(7)[MSB],
)
```)
#example(```typst
#bytefield(
msb: left,
bitheader("offsets"),
byte[MSB],
bytes(2)[Two],
flag("URG"),
bits(7)[LSB],
)
```, showlines: (2,3))
== Show bounds
Show start bit of each bitbox with `bitheader("bounds")`.
#example(showlines: (2,2), ```typst
#bytefield(
bitheader("bounds"),
byte[LSB],
bytes(2)[Two],
flag("URG"),
bits(7)[MSB],
)
```)
#example(```typst
#bytefield(
msb:left,
bitheader("bounds"),
byte[MSB],
bytes(2)[Two],
flag("URG"),
bits(7)[LSB],
)
```, showlines: (2,3))
== Custom bit header
#example(showlines: (2,2), ```typst
#bytefield(
bitheader(0,7,8, 24, 31),
byte[LSB],
bytes(2)[Two],
flag("URG"),
bits(7)[MSB],
)
```)
#example(showlines: (2,2), ```typst
#bytefield(
bitheader(..range(32,step:5)),
byte[LSB],
bytes(2)[Two],
flag("URG"),
bits(7)[MSB],
)
```)
== Numbers and Labels
You can also show labels and indexes by specifying a `content` after an `number` (`int`).
#example(showlines: (2,8), ```typst
#bytefield(
bitheader(
0,[LSB],
5, [test],
8, [next_field],
24, [important FLAG],
31, [MSB],
17,19,
text-size: 8pt,
),
byte[LSB],
bytes(2)[Two],
flag("URG"),
bits(7)[MSB],
)
```)
=== No numbers, only labels
You can omit numbers by setting `numbers: none` inside the bitheader function.
It's not possible to only omit numbers for certain labels right now.
#example(showlines: (2,9), ```typst
#bytefield(
bitheader(
0,[LSB],
5, [test],
8, [next_field],
24, [important_FLAG],
31, [MSB],
17, 19, // those get ommited as well.
numbers: none,
text-size: 8pt,
),
byte[LSB],
bytes(2)[Two],
flag("URG"),
bits(7)[MSB],
)
```)
#pagebreak()
== Styling the header
You can use #named arguments to adjust the header styling.
- `fill` argument adds an background color to the header.
- `text-size` sets the size of the text.
- `stroke` defines the border style.
=== Fancy orange header with big font
#example(showlines: (2,2), ```typst
#bytefield(
bitheader("bytes", fill: orange.lighten(60%), text-size: 16pt, stroke: red),
byte[LSB],
bytes(2)[Two],
flag("URG"),
bits(7)[MSB],
)
```)
=== Gray and boxed header
#example(showlines: (3,3),```typst
#bytefield(
bpr: 8,
bitheader("all", fill: luma(200), stroke: black),
bits(4)[Session Key Locator],
bits(4, fill: luma(200))[Reserved],
bytes(2)[MAC input data],
byte[...]
)
```)
_info: example taken from discord discussion (author: \_\_Warez)_
== Set row height
The height of the rows can be set with the `rows` argument.
#example(showlines: (2,2),```typst
#bytefield(
rows: (auto, 3cm, 2cm, 1cm, auto),
bitheader("bytes", fill: luma(200), stroke: luma(140)),
byte[LSB], bytes(2)[#v_ruler], byte[MSB],
byte[LSB], bytes(2)[#v_ruler], byte[MSB],
byte[LSB], bytes(2)[#v_ruler], byte[MSB],
byte[LSB], bytes(2)[#v_ruler], byte[MSB],
byte[LSB], bytes(2)[#v_ruler], byte[MSB],
)
```)
#pagebreak()
== Some predefined network protocols
=== IPv4
#example(
```typst
#common.ipv4
```)
=== IPv6
#example(
```typst
#common.ipv6
```)
=== ICMP
#example(
```typst
#common.icmp
```)
=== ICMPv6
#example(
```typst
#common.icmpv6
```)
=== DNS
#example(
```typst
#common.dns
```)
=== TCP
#example(
```typst
#common.tcp
```)
#example(
```typst
#common.tcp_detailed
```)
=== UDP
#example(
```typst
#common.udp
```)
|
https://github.com/jdupak/cv | https://raw.githubusercontent.com/jdupak/cv/master/main.typ | typst | #import "cv.template.typ" : cv, chronological, plain, event
#show: doc => cv(
"<NAME>",
[
#link("https://jakubdupak.com", "jakubdupak.com") \
#link("mailto:<EMAIL>") \
Prague, Czech Republic
],
doc
)
= Work
#chronological((
(
start: "05/2024",
end: "present",
title: "Software Engineer",
note: " ",
location: "Microsoft",
content: [
Contributing to the design and implementation of Rust compiler front-ends, back-ends, and analysis tools.
]
),
(
start: "03/2024",
end: "04/2024",
title: "Guest Lecturer",
location: "Luleå University of Technology",
note: "Microcomputer engineering with space applications",
content: [
Teaching the computer achitecture principles segment.
]
),
(
start: "09/2021",
end: "02/2024",
title: "External Teacher",
location: "Faculty of Electrical Engineering, CTU in Prague",
content: [
- Algorithms (_winter 2023/2024_)
- Computer Architectures (_summer 2022/2023_)
- Procedural Programming (_winter 2021/2022--2023/2024_)
]
),
(
start: "07/2022",
end: "11/2022",
title: "Collaborator",
note: "Department of Control Engineering",
location: "Faculty of Electrical Engineering, CTU in Prague",
content: [
Development and propagation of RISC-V graphical simulator QtRvSim.
]
),
(
start: "09/2020",
end: "01/2021",
title: "Tutor",
note: "Problem Solving and other Games",
location: "Faculty of Electrical Engineering, CTU in Prague",
content: [
Additional consulatitons.
]
),
(
start: "09/2016",
end: "12/2022",
title: "Front-End Web Developer",
note: "(part-time)",
location: "PragueBest s.r.o."
),
))
= Education
#chronological(((
start: "07/2021",
end: "02/2024",
title: "Masters's Degree",
note: "with honours",
location: [
Faculty of Electrical Engineering, CTU in Prague
],
content: [
Open Informatics -- Computer Engineering
*Thesis:* _Memory Safety Analysis in Rust GCC._ \
An initial effort to enable borrow checking in the Rust GCC compiler. The project included design and implementation of a new MIR-like IR, lifetime handling throughout the compilation, and extraction of facts for the borrowchecker computation using the borrowchecker engine. All the changes are part of upstream GCC.
Available at: _#link("https://jakubdupak.com/msc-thesis", "jakubdupak.com/msc-thesis")_ \
Received _Dean’s Award for an Extraordinary Thesis_. \
],
),(
start: "02/2022",
end: "07/2022",
title: "Exchange Program",
location: [
Tel Aviv University, Israel
],
note: "Computer Science"
),(
start: "06/2018",
end: "06/2021",
title: "Bachelor's Degree",
note: "with honours",
location: [
Faculty of Electrical Engineering, CTU in Prague
],
content: [
Open Informatics -- Computer Science and AI
*Thesis:* _Graphical RISC-V Architecture Simulator_ \
Available at: #link("https://jakubdupak.com/thesis", "jakubdupak.com/thesis") \
Received _Dean’s Award for an Extraordinary Thesis_. \
],
),))
= Contributions
#plain[
*Rust GCC*, *QtRvSim*
]
= Publications
#plain[
_<NAME>.; <NAME>.; <NAME>.; <NAME>. \
QtRVSim RISC-V Simulator for Computer Architectures Classes \
In: embedded world Conference 2022. Haar: WEKA FACHMEDIEN GmbH, 2022. p. 775-778. ISBN 978-3-645-50194-1._
]
= Conferences
#event((
(
date: "02/2023",
title: "FOSDEM 2023 Speaker",
location: "Brussels",
content: [ QtRVSim—Education from Assembly to Pipeline, Cache Performance, and C Level Programming ]
),
(
date: "11/2022",
title: "DevConf.CZ MINI Speaker",
location: "Brno",
content: [
QtRVSim - RISC-V Simulator for Computer Architectures Classes
]
),
(
date: "05/2022",
title: "Embedded World Conference 2022 Speaker",
location: "Nuremberg",
content: [
QtRVSim - RISC-V Simulator for Computer Architectures Classes \
]
),
))
= Volunteering
#chronological((
(
start: "07/2023",
end: "present",
title: "Humanitarian Unit Member",
location: "Czech Red Cross",
),
(
start: "04/2020",
end: "05/2020",
title: "Code In Place -- Section Leader",
location: "Stanford University",
),
))
= Human Languages
#plain[
*Czech* (native), *English* (advanced), *German* (intermediate)
]
= Programming Languages
#plain[
*Regular Use:* C++, Rust, Python, C, PowerShell, x64 assembly \
*Other:* JavaScript, Zig, Kotlin, SystemVerilog, Lisp (R5RS, Racket), RISC-V assembly, Bash, Fish
]
= Technical Interests
#plain[
compilers, programming languages, high-performance programming, computer architectures, operating systems, Rust, Zig
]
= Links
#plain[
*GitHub*: #link("https://github.com/jdupak", "github.com/jdupak") \
*LinkedIn*: #link("https://www.linkedin.com/in/jakub-dupak/", "linkedin.com/in/jakub-dupak/") \
*ORCID*: #link("https://orcid.org/0000-0002-7876-8883", "0000-0002-7876-8883")
]
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/fauve-cdb/0.1.0/template/main.typ | typst | Apache License 2.0 | #import "@preview/fauve-cdb:0.1.0": matisse-thesis
#let jury-content = [
#text(size: 1.3em)[*Rapporteurs avant soutenance :*]
#v(-1em)
#table(
columns: 2,
column-gutter: 1.5em,
stroke: 0pt,
inset: (x: 0pt, y: .2em),
"<NAME>", "M.Sc. -- Oxford",
"<NAME>", "Professeur des Universités -- Univ. Rennes",
)
#text(size: 1.3em)[*Composition du jury :*]
#v(-1em)
#table(
columns: 3,
column-gutter: 2em,
stroke: 0pt,
inset: (x: 0pt, y: .2em),
"Président :", "<NAME>", "<NAME> -- UCLA",
"Examinateurs :", "Archimède", "Expert comptable -------- Durand & Durant",
"", "E<NAME>", "BEP sabotier -- à son compte",
"Dir. de thèse :", "<NAME>", "Eleveur d'huîtres -- CNRS",
"Co-dir. de thèse :", "<NAME>", "Manutentionnaire -- Total",
)
#text(size: 1.3em)[*Invité(s) :*]
#v(-1em)
#table(
columns: 2,
column-gutter: 1.5em,
stroke: 0pt,
inset: (x: 0pt, y: .2em),
"Jean-René", "Au chômage",
)
]
#show: matisse-thesis.with(
author: "<NAME>",
affiliation: "IRISA (UMR 6074)",
jury-content: jury-content,
acknowledgements: [
],
defense-place: "Rennes",
defense-date: "23 octobre 2024",
draft: true,
// french info
title-fr: "La quadrature du cercle. Parfois nous, les scientifiques, avons tendance à faire des titres très longs. Trop long. Absolument !",
keywords-fr: lorem(12),
abstract-fr: lorem(80),
// english info
title-en: "Squaring the circle.",
keywords-en: lorem(12),
abstract-en: lorem(60),
)
#heading(numbering: none, outlined: false)[Remerciements]
J'aimerais remercier Jean-René.
#pagebreak()
// table of contents
#outline(indent: auto)
#pagebreak()
= Introduction
== Le couscous
buenos dias #footnote[Bonjour in French]
#lorem(1500)
#pagebreak()
= La sauce de soja
#smallcaps[Hello World]
#lorem(1500)
|
https://github.com/oldrev/tids | https://raw.githubusercontent.com/oldrev/tids/master/demo-ds.typ | typst | Apache License 2.0 | #import "tids.typ": tids
#import "@preview/gentle-clues:0.6.0": warning
#let metadata = (
title: [FXC1117 Flux Capacitor],
product: "FXC1117",
product_url: "https://github.com/oldrev/tids",
)
#let features = [
- Capacity: 1.21 gigawatts
- Operating Voltage: 88 billion volts
- Dimensions: Standard size, suitable for most electronic devices
- Material: Advanced alloys and insulating materials
- Frequency Response: Exceeds 1.21 kilohertz
- Temperature Range: -40°C to 150°C
- Stability: High stability, suitable for extreme environments
]
#let applications = [
The FXC1117 Flux Capacitor is an advanced electronic component widely used in the following fields:
- Time travel technology
- Energy conversion
- Electronics enhancement
- Space deformation techniques
- Quantum communication
#figure(
rect(image("./assets/741.svg"), stroke: 0.5pt), caption: "Typical Application"
)
]
#let desc = [
The Flux Capacitor is a revolutionary electronic technology utilizing advanced alloys and insulating materials, enabling it to operate in extreme conditions. Its high capacity and operating voltage make it an ideal choice for time travel technology and energy conversion fields.
Additionally, Flux Capacitors can be applied in electronics enhancement, space deformation techniques, and quantum communication. Their stability and frequency response make them an innovative product in the future of electronic components.
]
#let rev_list = (
(rev: [REV2], date: [2024/12/12], body: [
- #lorem(10)
- #lorem(8)
- #lorem(8)
]),
(rev: [REV1], date: [2012/12/12], body: [
- #lorem(10)
- #lorem(18)
- #lorem(18)
- #lorem(18)
]),
)
#show: doc => tids(
ds_metadata: metadata,
features: features,
applications: applications,
desc: desc,
rev_list: rev_list,
doc: doc
)
= Specifications
== Pin Configuration and Functions
<PinConfigAndFunctions>
#lorem(30)
#lorem(30)
== Specifications
<Specifications>
#table(
columns: (1fr, auto, auto, auto, auto, auto, 1fr),
align: (left,center,right,right,right,left,left,),
table.header([Parameters], [Symbol], [Minimum], [Typical], [Maximum], [Unit], [Condition]),
[Rated Voltage], [$V_(upright("IN"))$], [5], [—], [24], [V], [—],
[Rated Current], [$I$], [100], [150], [1,000], [mA], [Using 5V Supply],
[High-Level Voltage], [$V_(upright("OH"))$], [4.5], [—], [—], [V], [—],
[Low-Level Voltage], [$V_(upright("OL"))$], [—], [—], [0.5], [V], [—],
[Output High-Level Current], [$I_(upright("OH"))$], [—], [20], [—], [mA], [—],
)
== Absolute Maximum Ratings
<AbsoluteMaximumRatings>
#table(
columns: (auto, auto, auto, auto, auto, 1fr),
align: (left,center,right,right,center,left),
table.header([Parameter], [Symbol], [Minimum Value], [Maximum Value], [Unit], [Note]),
[Power Supply Voltage], [$V_(upright("IN"))$], [0], [30], [V],[],
[Ambient Temperature], [$T_A$], [-25], [85], [°C],[],
)
#warning(title: "Warning")[
Before start it you must be sure you have enough garbage.
]
#pagebreak()
= Detailed Description
<DetailedDescription>
== Overview
#lorem(200)
#lorem(200)
== Functional Block Diagram
#lorem(200)
#pagebreak()
= Application and Implementation
=== Application Information
#lorem(200)
=== Typical Applications
#lorem(200)
=== Design Requirements
#lorem(200)
= Power Supply Recommendations
#lorem(200)
=== PCB Layout
#lorem(200)
#pagebreak()
= Device and Documentation Support
=== Device Support
=== Related Links
#lorem(200)
#pagebreak()
= Mechanical, Packaging, and Orderable Information
#lorem(30)
#lorem(30)
|
https://github.com/julius2718/tempura | https://raw.githubusercontent.com/julius2718/tempura/main/0.0.1/example/doc_example.typ | typst | MIT License | #import "@local/tempura:0.0.1": *
#import "@local/wareki:1.0.0": *
#show: doc => jpdoc(doc)
#signature(title: "tempura: 日本語文書のためのTypstテンプレート", date: wareki_today, author: "julius2718")
= 日本国憲法
日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、政府の行為によつて再び戦争の惨禍が起ることのないやうにすることを決意し、ここに主権が国民に存することを宣言し、この憲法を確定する。そもそも国政は、国民の厳粛な信託によるものであつて、その権威は国民に由来し、その権力は国民の代表者がこれを行使し、その福利は国民がこれを享受する。これは人類普遍の原理であり、この憲法は、かかる原理に基くものである。われらは、これに反する一切の憲法、法令及び詔勅を排除する。
日本国民は、恒久の平和を念願し、人間相互の関係を支配する崇高な理想を深く自覚するのであつて、平和を愛する諸国民の公正と信義に信頼して、われらの安全と生存を保持しようと決意した。われらは、平和を維持し、専制と隷従、圧迫と偏狭を地上から永遠に除去しようと努めてゐる国際社会において、名誉ある地位を占めたいと思ふ。われらは、全世界の国民が、ひとしく恐怖と欠乏から免かれ、平和のうちに生存する権利を有することを確認する。
われらは、いづれの国家も、自国のことのみに専念して他国を無視してはならないのであつて、政治道徳の法則は、普遍的なものであり、この法則に従ふことは、自国の主権を維持し、他国と対等関係に立たうとする各国の責務であると信ずる。
日本国民は、国家の名誉にかけ、全力をあげてこの崇高な理想と目的を達成することを誓ふ。
== 日本国憲法第29条
+ 財産権は、これを侵してはならない。
+ 財産権の内容は、公共の福祉に適合するやうに、法律でこれを定める。
+ 私有財産は、正当な補償の下に、これを公共のために用ひることができる。
= `Python`によるプログラミング
以下のコードは、コンソールに`hello world`と出力させる命令です。
```python
print("hello world")
```
実際にこのコードを実行してみましょう。
= 区分求積法
$
lim_(n -> infinity) 1/n sum_(k = 0)^(n - 1) f(a + (b - a)/n k) = integral_a^b f(x) d x
$
#gtheading[問題] 次の各問に答えよ。
#sans[ただし、この文章はゴシック体である。]
- 我々はどこから来たのか?
- 我々は何者か?
- 我々はどこへ行くのか?
= Universal Declaration of Human rights
Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world,
Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people,
Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law,
Whereas it is essential to promote the development of friendly relations between nations,
Whereas the peoples of the United Nations have in the Charter reaffirmed their faith in fundamental human rights, in the dignity and worth of the human person and in the equal rights of men and women and have determined to promote social progress and better standards of life in larger freedom,
Whereas Member States have pledged themselves to achieve, in co-operation with the United Nations, the promotion of universal respect for and observance of human rights and fundamental freedoms,
Whereas a common understanding of these rights and freedoms is of the greatest importance for the full realization of this pledge,
Now, therefore,
The General Assembly,
Proclaims this Universal Declaration of Human Rights as a common standard of achievement for all peoples and all nations, to the end that every individual and every organ of society, keeping this Declaration constantly in mind, shall strive by teaching and education to promote respect for these rights and freedoms and by progressive measures, national and international, to secure their universal and effective recognition and observance, both among the peoples of Member States themselves and among the peoples of territories under their jurisdiction.
== Article 17
+ Everyone has the right to own property alone as well as in association with others.
+ No one shall be arbitrarily deprived of his property.
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/lint/markup_02.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Warning: 1-3 no text within underscores
// Hint: 1-3 using multiple consecutive underscores (e.g. __) has no additional effect
__
|
https://github.com/matthew-e-brown/assignmatts | https://raw.githubusercontent.com/matthew-e-brown/assignmatts/main/example/example1.typ | typst | MIT License | #import "../src/lib.typ" as assignmatts
#import assignmatts: assignment
#show: assignment.with(
title: [Example Assignment],
author: [<NAME>],
course-code: [CODE-1234],
course-name: [Assignmatts],
pdf-author: "<NAME>",
pdf-title: "MATH-3630H - Assignment 1",
)
// -------------------------------------------------------------------------------------------------
#lorem(20) #footnote[This is a footnote.]
#lorem(10) #footnote(numbering: "*")[This is a second footnote.]
#lorem(5)
#figure(
// cspell:disable-next-line
image("./img/francesco-ungaro-l3tA9-uFhtg-unsplash.jpg", width: 60%),
caption: [
A snow-covered mountain with a bright blue sky behind it.
#set text(size: 0.75em)
#let author-url = "https://unsplash.com/@francesco_ungaro?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash"
#let image-url = "https://unsplash.com/photos/a-snow-covered-mountain-with-a-sky-background-l3tA9-uFhtg?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash"
#v(8pt, weak: true)
// cspell:disable-next-line
Photo by #link(author-url)[<NAME>] on #link(image-url)[Unsplash].
],
)
#lorem(25)
#lorem(50)
|
https://github.com/typst-community/guidelines | https://raw.githubusercontent.com/typst-community/guidelines/main/src/chapters/style.typ | typst | Creative Commons Attribution Share Alike 4.0 International | #set heading(offset: 1)
#include "style/naming.typ"
#include "style/indentation.typ"
#include "style/delimiters.typ"
#include "style/modes.typ"
#include "style/joining.typ"
#include "style/sugar.typ"
#include "style/trailing.typ"
#include "style/linebreaks.typ"
|
https://github.com/typst-community/guidelines | https://raw.githubusercontent.com/typst-community/guidelines/main/src/chapters/api/flexibility.typ | typst | Creative Commons Attribution Share Alike 4.0 International | #import "/src/util.typ": *
#import mantys: *
= Flexibility <sec:api:flex>
Good APIs must be flexible enough to allow users to use them in situations a developer might not have anticipated directly.
== requiring or providing `context`
Starting with Typst 0.11, the #link("https://typst.app/docs/reference/context/")[context] feature allows certain functions to access information about the current location inside the document. The documentation gives the following example:
#example(
```typst
#let value = context text.lang
#value
--
#set text(lang: "de"); #value
--
#set text(lang: "fr"); #value
```
)
The same `value` is rendered three times, but with different results. This is of course a powerful tool for library authors! However, there is an important restriction that `context` needs to impose to be able to do that: `context` values are opaque content; the above does not result in a string such as `"en"`, it just renders that way:
#example(
```typst
#let value = context text.lang
Rendered: #value
Type/representation: #type(value)/#raw(repr(value))
```
)
This means that returning a context expression limits what can be done with a function's result. As a rule of thumb, if it's useful for a user to do more with your function than just render its result, you likely want to require the user of your function to use context instead of providing it yourself:
#do-dont[
```typst
/// Returns the current language. This function requires context.
///
/// -> string
#let fancy-get-language() = { text.lang }
#context fancy-get-language()
// Ok: the length of the language code should be 2
#context fancy-get-language().len()
```
][
```typst
/// Returns the current language as opaque content.
///
/// -> content
#let fancy-get-language() = context { text.lang }
#fancy-get-language()
// Doesn't work: type content has no method `len`
// #fancy-get-language().len()
```
]
The first variant of the `fancy-get-language` function allows the caller to do something with the returned language code (which, with this simplistic function is _necessary_ to domething useful); the latter one can only be rendered.
There are of course exceptions to the rule: requiring using `context` is _a bit_ more complicated to call for users, so if there is no benefit (e.g. the function returns complex content where inspecting it doesn't make sense anyway) it may be more useful to just return opaque content so that the user does not need to think about context.
|
https://github.com/HPDell/typst-cineca | https://raw.githubusercontent.com/HPDell/typst-cineca/main/test/day-view.typ | typst | MIT License | #import "@preview/cineca:0.2.0": calendar, events-to-calendar-items
#set page(margin: 0.5in, height: 15cm)
#let events = (
(1, 8.00, 10.00, [Lecture 1]),
(1, 10.00, 11.00, [Tutorial]),
(1, 11.30, 12.30, [Shopping]),
(1, 13.55, 15.00, [Lecture 2]),
(1, 15.00, 16.20, [Project 1]),
(2, 9.30, 11.30, [Lecture 2]),
(2, 13.45, 14.30, [Tutorial]),
(2, 18.00, 20.00, [Dinner with friends]),
)
#calendar(events, hour-range: (8, 14))
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/break-continue-01.typ | typst | Other | // Test joining with break.
#let i = 0
#let x = while true {
i += 1
str(i)
if i >= 5 {
"."
break
}
}
#test(x, "12345.")
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/linguify/0.2.0/linguify.typ | typst | Apache License 2.0 | // linguify
#let __lang_setting = state("lang-setting", auto);
#let __lang_dict = state("lang-dict", (default-lang: "en"));
#let __lang_fallback = state("lang-fallback", true);
#let linguify_config(data: auto, lang: auto, fallback: true, content) = {
//deprecated: set language
if lang != auto {
assert.eq(type(lang), str, message: "The lang parameter needs to be a string")
}
__lang_setting.update(lang);
// set language data dictionary
if data != auto {
assert.eq(type(data), dictionary, message: "The data parameter needs to be of type dict.")
__lang_dict.update(data);
}
// set fallback mode.
assert.eq(type(fallback), bool, message: "fallback can only be [true] or [false]")
__lang_fallback.update(fallback)
content
}
#let _get_default_lang(data) = {
let default_lang = data.at("default-lang", default: "en")
assert(default_lang in data, message: "No entry for the `default-lang` (" + default_lang + ") could be found in the lang data.")
default_lang
}
#let linguify(key) = {
context {
// get current state.
let selected_lang = if (__lang_setting.get() == auto) { text.lang } else { __lang_setting.get() } // __lang_setting.at(loc)
let data = __lang_dict.get()
let should-fallback = __lang_fallback.get()
// process.
if (should-fallback) {
let default_lang = _get_default_lang(data);
if (not selected_lang in data) {selected_lang = default_lang}
return data.at(selected_lang).at(key, default: data.at(default_lang).at(key))
} else {
assert(data.at(selected_lang, default: none) != none, message: "the language data file does not contain an entry for \"" + selected_lang + "\"")
assert(data.at(selected_lang).at(key, default: none) != none, message: "the section for the language \"" + selected_lang + "\" does not contain an entry for \"" + key + "\"")
return data.at(selected_lang).at(key)
}
}
}
|
https://github.com/joshuabeny1999/unisg-thesis-template-typst | https://raw.githubusercontent.com/joshuabeny1999/unisg-thesis-template-typst/main/metadata.typ | typst | Other | // Enter your thesis data here:
#let language = "en" // "en" or "de"
#let title = "Title of paper"
#let subtitle = "Subtitle of paper"
#let type = "Type of paper"
#let professor = "Name and full title of professor"
#let author = "<NAME>"
#let matriculationNumber = "Matriculation number"
#let submissionDate = datetime(day: 1, month: 1, year: 2024) |
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/text/lorem-02.typ | typst | Other | // Error: 7-9 missing argument: words
#lorem()
|
https://github.com/XcantloadX/TypstMomoTalk | https://raw.githubusercontent.com/XcantloadX/TypstMomoTalk/main/momotalk/momotalk.typ | typst | // 模板
// @param title str|none 标题
// @param author str|none 作者
// @param credit bool 是否显示制作器水印
// @param width str|number 页面宽度
// @param height str|number 页面高度
// @param margin str|number|array[margin] 页面边距
// @param doc content 页面内容
#let chat(
title: none,
author: none,
credit: true,
width: 300pt,
height: 841.89pt,
margin: (left: 10pt, right: 10pt, top: 10pt),
doc
) = {
set raw(theme: "assets/vs-dark.tmTheme")
set text(font: (
"BlueakaBetaGBK",
"/momotalk/assets/font.ttf",
"Cascadia Code",
"SimHei"
))
show raw: set text(font: ("Cascadia Code", "SimHei"))
// TODO 无法设置英文字体为 BlueakaBetaGBK
page(
width: width,
height: height,
margin: margin,
[
// 制作器水印
#if (credit) {
align(text(
fill: rgb("#ccc"),
size: 0.8em,
"Powered by TypstMomoTalk",
), right)
}
// 标题
#if (title != none) {
align(text(
fill: black,
size: 1.3em,
weight: "bold",
title
), center)
}
// 作者
#if (author != none) {
align(text(
fill: black,
size: 1em,
"——" + author
), right)
}
#doc
]
)
}
#let COLOR_MSGBOX_STU_BG = rgb("#4c5b6f")
#let COLOR_MSGBOX_SENSEI_BG = rgb("#4a8ac6")
#let COLOR_MESSAGE_NAME_FG = rgb("#4b5055")
#let COLOR_SYS_FG = rgb("#e1e7ec")
#let style = (
msgbox: (
inset: (x: 5pt, y: 7pt),
)
)
// 产生一条分割线
#let hr = align(line(stroke: rgb("#ccc"), length: 90%), center)
// 产生一个消息框
// @param direction 消息框方向。可选 left、right、none
// @param no_box bool 是否显示消息框背景。
#let msgbox(
direction: "left", // left/right/none
background_color: COLOR_MSGBOX_STU_BG,
no_box: false,
content
) = {
let color = background_color
let triangle = polygon.regular(vertices: 3, fill: color)
triangle = scale(triangle, x: 50%, y: 50%)
if (no_box){
return text(content)
}
if (direction == "left") {
triangle = rotate(triangle, 270deg)
rect(
radius: 5pt,
inset: style.at("msgbox").at("inset"),
fill: color,
{
text(fill: white, content)
place(triangle, dx: -11pt, dy: -100% - 2pt)
}
)
}
else if (direction == "right") {
triangle = rotate(triangle, 90deg)
align(rect(
radius: 5pt,
inset: style.at("msgbox").at("inset"),
fill: color,
{
text(fill: white, content)
place(triangle, dx: 100% + 2pt, dy: -100% - 2pt)
}
), right)
}
else {
rect(
radius: 5pt,
inset: style.at("msgbox").at("inset"),
fill: color,
text(fill: white, content)
)
}
}
// 产生一条或多条消息
// @param name str|none 发送者名字。可空。
// @param avatar_path str|none 头像图片路径。可空
// @param direction str 消息方向。可选 left、right。
// @param contents any|arguments|array[any|arguments]
// 消息内容。可以为空,或 content/str 对象。
// 也可以是一个 arguments 对象,相当于传入给 `msgbox` 函数的参数。
#let messages(
name,
avatar_path,
direction: "left",
background_color: COLOR_MSGBOX_STU_BG,
contents
) = {
// 空消息检查
if (contents == none) {
panic("contents is empty! contents 参数不能为空!")
}
if (type(contents) != array) {
contents = (contents,)
}
if (contents.len() <= 0) {
panic("contents is empty! contents 参数不能为空!")
}
// 布局:一行两列的 Grid
// 伪代码:Grid(左: 头像, 右: Stack(名字, ..内容))
let rendered_contents = ()
// 先把名字放进去
rendered_contents.push(text(
fill: COLOR_MESSAGE_NAME_FG,
weight: "bold",
name
))
// 然后渲染消息框
let render(_content, _direction) = {
if (type(_content) == arguments) {
msgbox(.._content)
}
else {
msgbox(
direction: _direction,
background_color: background_color,
_content
)
}
}
// 第一个消息框有小三角,后续的没有
rendered_contents.push(render(contents.remove(0), direction))
for c in contents {
rendered_contents.push(render(c, "none"))
}
// 头像部分
let avatar_content = {
if (avatar_path != none) {
block(
inset: 0pt,
outset: 0pt,
clip: true,
width: 40pt,
height: 40pt,
radius: 20pt,
align(image(avatar_path, fit: "cover", width: 40pt), center + horizon),
)
}else {
}
}
// 消息部分
let message_content = stack(spacing: 4pt, ..rendered_contents)
// 组装在一起
if (direction == "left") {
block()[
#grid(
rows: (auto),
columns: (auto, 1fr),
column-gutter: 4pt,
avatar_content,
message_content
)
]
}
else {
align(block()[
#grid(
rows: (auto),
columns: (1fr, auto),
column-gutter: 4pt,
message_content,
avatar_content,
)
], right)
}
}
// 产生一条系统消息
// @param width 宽度
// @param height 高度
// @param content 内容
#let system(width: 85%, height: auto, content) = [
#align(
rect(
fill: COLOR_SYS_FG,
inset: (x: 1em, y: 0.5em),
radius: 5pt,
height: height,
width: width)[#content]
,center)
]
// ----------- 消息卡片 -----------
// 产生一个消息卡片(例如“羁绊剧情”卡片)
// @param title str 标题
// @param body none|content 卡片内容
// @param options none|content|array[content] 卡片选项
// @param title_color str 标题方块颜色
// @param background_color str 卡片背景颜色
// @param background_image str|none 卡片背景图片(WIP)
// @param option_fore_color str 选项文字颜色
// @param option_back_color str 选项背景颜色
#let card(
title,
body,
options,
title_color: rgb("#3493f9"),
background_color: rgb("#f3f7f8"),
background_image: none,
option_fore_color: black,
option_back_color: white
) = {
// 处理 options 参数
// bug: https://github.com/typst/typst/issues/2747
// type(none) 输出为 none
// 但是 type(none) == none 输出为 false
if (options == none) {
options = ()
}
else if (type(options) != array) {
options = (options,)
}
let ret = rect(
fill: background_color,
stroke: rgb("#cdd3dc") + 0.5pt,
inset: 1em,
radius: 5pt,
width: 85%
)[
#align(left)[
#rect(
height: 1.5em,
fill: none,
stroke: (left: title_color + 2pt, rest: none)
)[#title]
]
#place(
dy: -1em + 2pt,
line(length: 100%, stroke: 0.5pt + rgb("#87929e"))
)
#align(body, left)
// 处理选项
#for option in options {
rect(
fill: option_back_color,
height: 2em,
width: 100%,
stroke: rgb("#ccc") + 0.5pt,
radius: 4pt,
outset: (y: 1pt, x: 0pt),
inset: 0pt,
align(horizon, text(option, fill: option_fore_color))
)
// TODO 选项框阴影(Typst 貌似目前不支持 Rect 的 Shadow)
}
// 无选项时要输出一个空文本占位,
// 否则会让标题的分割线错位
#if options.len() == 0 {
""
}
]
align(ret, center)
}
#let story_card = (name) => card(
"好感剧情",
none,
"进入" + name + "的剧情",
title_color: rgb("#fc96ab"),
background_color: rgb("#ffedf1"),
option_back_color: rgb("#fc96ab"),
option_fore_color: white,
)
#let reply_card = card.with(
"回复"
)
// ----------- 扩展消息 -----------
#let voice(seconds, color: white) = {
// 参数检查
if (type(seconds) != int) {
panic("voice(seconds) 参数必须为整数!")
}
if (seconds <= 0) {
panic("voice(seconds) 参数必须大于 0!")
}
if (color != white and color != black) {
panic("voice(seconds, color) color 参数必须为 white 或 black!")
}
// TODO 改用 SVG/自定义字体,支持自定义颜色
let img_path
if (color == white) {
img_path = "assets/misc/voice_white.png"
}
else {
img_path = "assets/misc/voice_black.png"
}
let msg_width = calc.min(seconds * 3pt, 100pt)
[
#box(image(img_path, width: 0.7em, height: 1em), baseline: 10%)
#h(1em)
#text(str(seconds) + ["])
#h(msg_width)
]
}
// 语音通话
// @param angle angle 图标旋转角度
// @param contents str|content 提示文本。若为空内容/空字符串,默认为“语音通话”
#let voice_call(
angle: 0deg,
content
) = {
// TODO 改用 SVG/自定义字体,支持自定义颜色
angle += 135deg
if (content == [] or content == "") {
content = "语音通话"
}
[
#box(
rotate(image("assets/misc/receiver.svg", width: 1em, height: 1em), angle),
baseline: 10%)
#content
]
}
#let action(
size: 1em,
color: COLOR_MSGBOX_STU_BG,
content
) = {
align(text(
fill: color,
size: size
)[#content], center)
}
#let small = action.with(
size: 0.8em,
color: rgb("#999")
)
#let time = small
#let unsend = (name) => small[“#name”撤回了一条消息] |
|
https://github.com/typst-community/valkyrie | https://raw.githubusercontent.com/typst-community/valkyrie/main/docs/manual.typ | typst | Other | #import "@preview/mantys:0.1.4": *
#import "/src/lib.typ" as z
#let package = toml("/typst.toml").package
#show: mantys.with(
..package,
title: [Valkyrie],
date: datetime.today().display(),
abstract: [This package implements type validation, and is targeted mainly at package and template developers. The desired outcome is that it becomes easier for the programmer to quickly put a package together without spending a long time on type safety, but also to make the usage of those packages by end-users less painful by generating useful error messages.],
examples-scope: (z: z),
)
#show raw: it => {
show "{{VERSION}}": package.version
it
}
= Example usage
#add-type("schema", color: rgb("#bda8ed"))
#add-type("z-ctx", color: rgb("#afeda8"))
// #mantys.add-type("scope", color: rgb("#afeda8"))
#add-type("internal", color: rgb("#ff8c8c"))
#example(side-by-side: true)[```typst
#let template-schema = z.dictionary((
title: z.content(),
abstract: z.content(default: []),
dates: z.array(z.dictionary((
type: z.content(),
date: z.string()
))),
paper: z.schemas.papersize(default: "a4"),
authors: z.array(z.dictionary((
name: z.string(),
corresponding: z.boolean(default: false),
orcid: z.string(optional: true)
))),
header: z.dictionary((
journal: z.content(default: [Journal Name]),
article-type: z.content(default: "Article"),
article-color: z.color(default: rgb(167,195,212)),
article-meta: z.content(default: [])
)),
));
#z.parse(
(
title: [This is a required title],
paper: "a3",
authors: ( (name: "Example"),)
),
template-schema,
)
```]
= Documentation
== Terminology
As this package introduces several type-like objects, the Tidy style has had these added for clarity. At present, these are #dtype("schema") (to represent type-validating objects), #dtype("z-ctx") (to represent the current state of the parsing heuristic), and #dtype("scope") (an array of strings that represents the parent object of values being parsed). #dtype("internal") represents arguments that, while settable by the end-user, should be reserved for internal or advanced usage.
Generally, users of this package will only need to be aware of the #dtype("schema") type.
== Specific language
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in #link("http://www.ietf.org/rfc/rfc2119.txt", [RFC 2119]).
== Use cases
The interface for a template that a user expects and that the developer has implemented are rearly one and the same. Instead, the user will apply common sense and the developer will put in somewhere between a token- and a whole-hearted- attempt at making their interface intuitive. Contrary to what one might expect, this makes it more difficult for the end user to correctly guess the interface as different developers will disagree on what is and isn't intuitive, and what edge cases the developer is willing to cover.
By first providing a low-level set of tools for validating primitives upon which more complicated schemas can be defined, `Valkyrie` handles both the micro and macro of input validation.
#pagebreak()
== Parsing functions
#command(
"parse",
arg[object],
arg[schemas],
arg(ctx: auto),
arg(scope: ("argument",)),
ret: ("any", "none"),
)[
Validates an object against one or more schemas. *WILL* return the given object after validation if successful, or none and *MAY* throw a failed assertion error.
#argument("object", types: "any")[
Object to validate against provided schema. Object *SHOULD* satisfy the schema requirements. An error *MAY* be produced if not.
]
#argument("schemas", types: ("array", "schema"))[
Schema against which `object` is validated. Coerced into array. *MUST* be an array of valid valkyrie schema types.
]
#argument("ctx", default: auto, types: "z-ctx")[
ctx passed to schema validator function, containing flags that *MAY* alter behaviour.
]
#argument("scope", default: ("argument",), types: "scope")[
An array of strings used to generate the string representing the location of a failed requirement within `object`. *MUST* be an array of strings of length greater than or equal to `1`
]
]
#pagebreak()
== Schema definition functions
For the sake of brevity and owing to their consistency, the arguments that each schema generating function accepts are listed in the table below, followed by a description of each of argument.
#let rotatex(body, angle) = style(styles => {
let size = measure(body, styles)
box(
inset: (
x: -size.width / 2 + (
size.width * calc.abs(calc.cos(angle)) + size.height * calc.abs(
calc.sin(angle),
)
) / 2,
y: -size.height / 2 + (
size.height * calc.abs(calc.cos(angle)) + size.width * calc.abs(
calc.sin(angle),
)
) / 2,
),
rotate(body, angle),
)
})
#align(
center,
table(
stroke: black + 0.75pt,
columns: (1fr,) + 12 * (auto,),
inset: 9pt,
align: (horizon, horizon + center),
table.header(
[],
rotatex([*any*], -90deg),
rotatex([*array*], -90deg),
rotatex([*boolean*], -90deg),
rotatex([*color*], -90deg),
rotatex([*content*], -90deg),
rotatex([*date*], -90deg),
rotatex([*dictionary*], -90deg),
rotatex([*either*], -90deg),
rotatex([*number, integer, float*], -90deg),
rotatex([*string, ip, email*], -90deg),
rotatex([*tuple*], -90deg),
rotatex([*choice*], -90deg),
),
[body],
[ ],
[✔],
[ ],
[ ],
[ ],
[ ],
[✔],
[✔],
[ ],
[ ],
[✔],
[✔],
[name],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[optional],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[default],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[types],
[✔],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[✱],
[assertions],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✱],
[✱],
[✔],
[✱],
[✔],
[✱],
[pre-transform],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✱],
[✱],
[✔],
[✔],
[✔],
[✔],
[post-transform],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
[✔],
),
)
✔ Indicates that the argument is available to the user.
✱ Indicates that while the argument is available to the user, it may be used internally or may hold a default value.
#pagebreak()
#block(
breakable: false,
argument(
"name",
default: "unknown",
types: "string",
)[Human-friendly name of the schema for error-reporting purposes.],
)
#block(
breakable: false,
argument("optional", default: false, types: "boolean")[
Allows the value to have not been set at the time of parsing, without generating an error.
#mty.alert[If used on a dictionary, consider adding default values to child schemas instead.]
#mty.alert[If used on a array, consider relying on the default (an empty array) instead.]
],
)
#block(
breakable: false,
argument("default", default: none, types: "any")[
The default value to use if object being validated is `none`.
#mty.alert[Setting a default value allows the end-user to omit it.]
],
)
#block(
breakable: false,
argument(
"types",
default: (),
types: "array",
)[Array of allowable types. If not set, all types are accepted],
)
#block(
breakable: false,
argument("assertions", default: (), types: "array")[
Array of assertions to be tested during object validation. see (LINK TO ASSERTIONS)
#mty.alert[Assertions cannot modify values]
],
)
#block(
breakable: false,
argument("pre-transform", default: "(self,it)=>it", types: "function")[
Transformation to apply prior to validation. Can be used to coerce values.
],
)
#block(
breakable: false,
argument(
"post-transform",
default: "(self,it)=>it",
types: "function",
)[Transformation to apply after validation. Can be used to reshape values for internal use
],
)
#pagebreak()
#command("alignment", sarg[args], ret: "schema")[
Generates a schema that accepts only alignment objects as valid.
]
#command("angle", sarg[args], ret: "schema")[
Generates a schema that accepts only angles as valid.
]
#command("any", sarg[args], ret: "schema")[
Generates a schema that accepts any input as valid.
]
#command("array", arg[schema], sarg[args], ret: "schema")[
#argument(
"schema",
types: "schema",
)[Schema against which to validate child entries. Defaults to #tidyref(none, "any").]
]
#command("boolean", sarg[args], ret: "schema")[
Generates a schema that accepts only booleans as valid.
]
#command("bytes", sarg[args], ret: "schema")[
Generates a schema that accepts only bytes as valid.
]
#command("color", sarg[args], ret: "schema")[
Generates a schema that accepts only colors as valid.
]
#command("content", sarg[args], ret: "schema")[
Generates a schema that accepts only content or string as valid.
]
#command("date", sarg[args], ret: "schema")[
Generates a schema that accepts only datetime objects as valid.
]
#command(
"dictionary",
arg(aliases: (:)),
arg[schema],
sarg[args],
ret: "schema",
)[
#argument(
"aliases",
types: "dict",
default: (:),
)[Dictionary representation of source to destination aliasing. Has the effect of allowing the user to key something with `source` when its `destination` that is meant.]
#argument(
"schema",
types: "dictionary",
)[Dictionary of schema elements, used to define the validation rules for each entry.]
]
#command("direction", sarg[args], ret: "schema")[
Generates a schema that accepts only directions as valid.
]
#command("either", sarg[schema], sarg[args], ret: "schema")[
#argument(
"schema",
types: "dictionary",
is-sink: true,
)[Positional arguments of validation schemes in order or preference that an input value should satisfy.]
]
#command("function", sarg[args], ret: "schema")[
Generates a schema that accepts only functions as valid.
]
#command("fraction", sarg[args], ret: "schema")[
Generates a schema that accepts only fractions as valid.
]
#command("gradient", sarg[args], ret: "schema")[
Generates a schema that accepts only gradient objects as valid.
]
#command("label", sarg[args], ret: "schema")[
Generates a schema that accepts only labels as valid.
]
#command("length", sarg[args], ret: "schema")[
Generates a schema that accepts only lengths as valid.
]
#command("location", sarg[args], ret: "schema")[
Generates a schema that accepts only locations as valid.
]
#command("number", arg(min: none), arg(max: none), sarg[args], ret: "schema")[
Generates a schema that accepts only numbers as valid.
]
#command("plugin", sarg[args], ret: "schema")[
Generates a schema that accepts only plugins as valid.
]
#command("ratio", sarg[args], ret: "schema")[
Generates a schema that accepts only ratios as valid.
]
#command("relative", sarg[args], ret: "schema")[
Generates a schema that accepts only relative types, lengths, or ratios as valid.
]
#command("regex", sarg[args], ret: "schema")[
Generates a schema that accepts only regex expressions as valid.
]
#command("selector", sarg[args], ret: "schema")[
Generates a schema that accepts only selectors as valid.
]
#command("string", arg(min: none), arg(max: none), sarg[args], ret: "schema")[
Generates a schema that accepts only strings as valid.
]
#command("stroke", sarg[args], ret: "schema")[
Generates a schema that accepts only stroke objects as valid.
]
#command("symbol", sarg[args], ret: "schema")[
Generates a schema that accepts only symbol types as valid.
]
#command("tuple", sarg[schema], sarg[args], ret: "schema")[
#argument(
"schema",
types: "schema",
is-sink: true,
)[Positional arguments of validation schemes representing a tuple.]
]
#command("version", sarg[args], ret: "schema")[
Generates a schema that accepts only version objects as valid.
]
#command(
"sink",
arg(positional: none),
arg(named: none),
sarg[args],
ret: "schema",
)[
#argument(
"positional",
types: ("schema", none),
)[Schema that `args.pos()` must satisfy. If `none`, no positional arguments may be present]
#argument(
"named",
types: ("schema", none),
)[Schema that `args.named()` must satisfy. If `none`, no named arguments may be present]
]
#command("choice", arg[choices], sarg[args], ret: "schema")[
#argument("choices", types: "array")[Array of valid inputs]
]
#pagebreak()
#import "@preview/tidy:0.2.0"
#let module-doc = tidy.parse-module(
read("/src/coercions.typ"),
name: "z.coerce",
label-prefix: "z.coerce",
scope: (:),
)
#tidy.show-module(
module-doc,
style: (
get-type-color: mty-tidy.get-type-color,
show-outline: mty-tidy.show-outline,
show-parameter-list: mty-tidy.show-parameter-list,
show-parameter-block: mty-tidy.show-parameter-block,
show-function: mty-tidy.show-function.with(
tidy: tidy,
extract-headings: true,
),
show-variable: mty-tidy.show-variable.with(tidy: tidy),
show-example: mty-tidy.show-example,
show-reference: mty-tidy.show-reference,
),
first-heading-level: 2,
show-module-name: true,
sort-functions: false,
show-outline: true,
)
#tidy-module(read("/src/coercions.typ"), name: "coerce")
#pagebreak()
#let module-doc = tidy.parse-module(
read("/src/assertions.typ") + read("/src/assertions/comparative.typ") + read("/src/assertions/string.typ"),
name: "z.assert",
label-prefix: "z.assert",
scope: (:),
)
#tidy.show-module(
module-doc,
style: (
get-type-color: mty-tidy.get-type-color,
show-outline: mty-tidy.show-outline,
show-parameter-list: mty-tidy.show-parameter-list,
show-parameter-block: mty-tidy.show-parameter-block,
show-function: mty-tidy.show-function.with(
tidy: tidy,
extract-headings: true,
),
show-variable: mty-tidy.show-variable.with(tidy: tidy),
show-example: mty-tidy.show-example,
show-reference: mty-tidy.show-reference,
),
first-heading-level: 2,
show-module-name: true,
sort-functions: false,
show-outline: true,
)
#let module-doc = tidy.parse-module(
read("/src/assertions/length.typ"),
name: "z.assert.length",
label-prefix: "z.assert.string.",
scope: (:),
)
#tidy.show-module(
module-doc,
style: (
get-type-color: mty-tidy.get-type-color,
show-outline: mty-tidy.show-outline,
show-parameter-list: mty-tidy.show-parameter-list,
show-parameter-block: mty-tidy.show-parameter-block,
show-function: mty-tidy.show-function.with(
tidy: tidy,
extract-headings: true,
),
show-variable: mty-tidy.show-variable.with(tidy: tidy),
show-example: mty-tidy.show-example,
show-reference: mty-tidy.show-reference,
),
first-heading-level: 2,
show-module-name: true,
sort-functions: false,
show-outline: true,
)
#pagebreak()
= Advanced Documentation
== Validation heuristic
#import "@preview/fletcher:0.4.4" as fletcher: diagram, node, edge, shapes
#figure(
align(
center,
diagram(
spacing: 2em,
node-stroke: 0.75pt,
edge-stroke: 0.75pt,
node((-2, 1), [Start], corner-radius: 2pt, shape: shapes.circle),
edge("-|>"),
node((0, 1), align(center)[`value` or `self.default`]),
edge("-|>"),
node((0, 2), align(center)[pre-transform value], corner-radius: 2pt),
edge("-|>"),
node((0, 3), align(center)[Assert type of value], corner-radius: 2pt),
node(
(-1, 4),
align(center)[Allow #repr(none) if \ `self.optional` is #true],
corner-radius: 2pt,
),
node(
(0, 4),
align(center)[Allow if `self.types` \ length is 0],
corner-radius: 2pt,
),
node(
(1, 4),
align(center)[Allow `value` if type\ in `self.types`],
corner-radius: 2pt,
),
node((1, 3), align(center)[`self.fail-validation`], corner-radius: 2pt),
edge("-|>"),
node(
(2, 3),
align(center)[throw],
corner-radius: 2pt,
shape: shapes.circle,
),
edge((0, 3), (-1, 4), "-|>", bend: -20deg),
edge((-1, 4), (0, 5), "-|>", bend: -20deg),
edge((0, 3), (0, 4), "-|>"),
edge((0, 4), (0, 5), "-|>"),
edge((0, 3), (1, 4), "-|>", bend: 20deg),
edge((1, 4), (0, 5), "-|>", bend: 20deg),
edge((0, 3), (1, 3), "-|>"),
node(
(0, 5),
align(center)[Handle descendents \ transformation],
corner-radius: 2pt,
),
edge(
"ll,uuuu",
"|>--|>",
align(center)[child schema \ on descendent],
label-side: left,
label-pos: 0.3,
),
edge("-|>"),
node(
(0, 6),
align(center)[Handle assertions \ transformation],
corner-radius: 2pt,
),
edge("-|>"),
node((1, 6), align(center)[post-transform `value`], corner-radius: 2pt),
edge("-|>"),
node((2, 6), [end], corner-radius: 2pt, shape: shapes.circle),
) + v(2em),
),
caption: [Flow diagram representation of parsing heuristic when validating a value against a schema.],
)
|
https://github.com/AU-Master-Thesis/thesis | https://raw.githubusercontent.com/AU-Master-Thesis/thesis/main/lib/numbers.typ | typst | MIT License | #let written(n) = (
"0": "zero",
"1": "one",
"2": "two",
"3": "three",
"4": "four",
"5": "five",
"6": "six",
"7": "seven",
"8": "eight",
"9": "nine",
"10": "ten",
).at(str(n), default: n)
#let ordinal(n) = {
(
"zeroth",
"first",
"second",
"third",
"fourth",
"fifth",
"sixth",
"seventh",
"eighth",
"ninth",
"tenth",
).at(n)
}
|
https://github.com/lctzz540/typst-journal-template | https://raw.githubusercontent.com/lctzz540/typst-journal-template/main/main.typ | typst | #import "template.typ": *
#show: ieee.with(
title: "TIẾP CẬN CHẨN ĐOÁN \n VIÊM TÚI THỪA ĐẠI TRÀNG",
abstract: [
Bệnh túi thừa đại tràng rất phổ biến ở Mỹ và châu Âu. Ước tính với hơn một nửa dân số trên 50 tuổi có túi thừa đại tràng. Đại tràng chậu hông là vị trí thường gặp túi thừa nhất. Ở châu á, báo cáo ngày càng nhiều tại các nước Hàn Quốc, Nhật bản, Đài Loan... Bệnh chủ yếu ở đại tràng phải với tỉ lệ so với viêm ruột thừa là 2,7-17 tùy theo báo cáo (cứ 2,7-17 ca viêm ruột thừa thì có 1 ca viêm túi thừa đại tràng phải). Tại Việt Nam, bệnh viêm túi thừa đại tràng ít được nhắc đến. Do vậy tỉ lệ chẩn đoán trước mổ viêm túi thừa đại tràng rất thấp. Trong nghiên cứu của Lê Huy Lưu báo cáo 45 trường hợp được mổ cắt túi thừa nội soi điều trị viêm túi thừa đại tràng phải tại Bệnh Viện Nhân Dân Gia Định, trong đó 16 trường hợp được chẩn đoán trước mổ là viêm túi thừa đại tràng và 29 trường hợp bị chẩn đoán nhầm với các thể của viêm ruột thừa (chiếm hơn 64,4%) @RN1
],
authors: (
(
name: "<NAME>",
location: [HCMC, Vietnam],
email: "<EMAIL>"
),
),
index-terms: ("Viêm túi thừa", "Túi thừa thật", "Phân độ viêm túi thừa", "Colonic diverticulitis"),
bibliography-file: "refs.bib",
)
= Cơ chế bệnh sinh
Dựa theo cấu trúc, túi thừa đại tràng được chia thành 2 loại là túi thừa thật và túi thừa giả. Túi thừa thật có đầy đủ các lớp ống tiêu hóa trong khi túi thừa giả bị khiếm khuyết lớp cơ. Cơ chế hình thành 2 loại túi thừa này hoàn toàn khác nhau
== Túi thừa giả
Túi thừa giả không có lớp cơ nên cấu trúc của nó chỉ là lớp niêm mạc được bao phủ bên ngoài bởi thanh mạc. Túi thừa giả còn được xem là sự thoát vị của niêm mạc đại tràng ra bên ngoài xuyên qua lớp cơ. Việc hình thành túi thừa giả là sự kết hợp của nhiều yếu tố:
=== Tồn tại các điểm yếu tự nhiên của thành đại tràng
Khác với các phần khác của ống tiêu hóa, đại tràng có lớp cơ dọc bên ngoài không phủ toàn bộ chu vi mà tụ thành 3 dải, bao gồm 1 dải cơ dọc nằm ở bờ mạc treo và 2 dải cơ dọc ở bờ tự do đối diện 2 bên. Như vậy ở những chỗ thiếu lớp cơ dọc, thành đại tràng sẽ mỏng và yếu hơn.
Mạch máu từ mạc treo sẽ tỏa ra cung cấp máu cho đại tràng, khi tới thành ruột các động mạch sẽ xuyên qua lớp cơ để đi vào lớp dưới niêm. Vị trí mạch máu xuyên qua tạo ra các chỗ yếu của thành đại tràng, niêm mạc có thể chui qua đó tạo thành túi thừa. Mạch máu xuyên ở gần bờ mạc treo thì lớn và nhỏ dần khi ra xa. Như vậy, tại 2 vùng khuyết cơ dọc ở gần mạc treo là nơi thuật lợn cho sự hình thành của túi thừa. Trong khi đó, vùng khuyết dải cơ dọc còn lại ở đối diện mạc treo có các mạch máu xuyên nhỏ nên ít bị hình thành túi thừa
#figure(
image("figure/fig1.jpg"),
caption: [
Túi thừa đại tràng
],
)
=== Sự thay đổi cấu trúc của thành ruột
Collagen và elastin là các cấu trúc protein dạng sợi quan trọng của mô liên kết. Collagen đảm nhận chức năng chịu lực căng co kéo của mô trong khi elastin thì có chức năng co để thu hồi mô về hình dạng ban đầu. Khi nghiên cứu cấu trúc thành của đại tràng có túi thừa, người ta thấy có sự gia tăng các liên kết chéo (cross-linkage) của các sợ collagen và sự lắng đọng elastin tại các dải cơ dọc của đại tràng.
Sự gia tăng các liên kết chéo của các sợi collagen (vốn đứng riêng rẽ với nhau) làm cho cấu trúc căn bản của collagen bị xáo trộn, làm giảm sức đề kháng của thành ruột đối với áp lực trong lòng ruột. Các liên kết chéo này gia tăng theo tuổi và được xem là một yếu tố bệnh sinh của túi thừa
Sự gia tăng lắng đọng elastin cũng làm thay đổi cấu trúc của thành đại tràng. Cụ thể là làm dày lên lớp cơ vòng, ngắn lại dải cơ dọc và làm hẹp lòng đại tràng. Hậu quả tiếp theo là gây ra những bất thường trong vận động của đại tràng, góp phần làm gia tăng áp lực trong lòng đại tràng
Các thay đổi này gia tăng trong quá trình lão hóa tương ứng với việc gia tăng tần suất của bệnh túi thừa đại tràng theo tuổi. Điều này cũng giải thích việc xuất hiện bệnh túi thừa ở người trẻ bị các bệnh của mô liên kết như Ehlers-Danlos, hội chứng Marfan và bệnh nhận đa nang di truyền trội trên nhiễm sắc thể thường
=== Tăng áp lực trong lòng ruột
Sự hình thành túi thừa được cho là hậu quả của sự tăng áp lực trong lòng ruột. Theo định luật Laplance: _Pressure = (2 $*$ Thickness $*$ Tension)/Radius_. Như vậy, áp suất P(Pressure) tỷ lệ thuận với sức căn T (Tension) lên thành ruột và tỷ lệ nghịch với bán kính R (Radius) của ruột. Trong tình huống thông thường, đại tràng là một ống dài liên tục thông suốt nên áp lực (P) sẽ như nhau trên khắp đại tràng. Do đó, sức căng (T) lên thành ruột lớn nhất là ở manh tràng và đại tràng phải (vì có bán kính lớn hơn) chứ không phải là đại tràng chậu hông. Nhưng thực tế đại tràng chậu hông là nơi xuất hiện túi thừa nhiều nhất, cho nên phải có một lý do khác lý giải được sự gia tăng áp lực trong lòng đại tràng chậu hông.
#figure(
image("figure/fig2.jpeg", width: 70%),
caption: [
Hiện tượng co cơ phân đoạn của đại tràng
],
)
Điều này được làm sáng tỏ khi người ta thấy có sự tồn tại của hiện tượng phân đoạn của đại tràng. Hiện tượng phân đoạn được mô tả là những cơn co cơ mạnh của thành đại tràng nhằm đẩy hoặc ngăn chặn sự đi qua của các thành phần trong lòng của nó. Nếu như 2 cơn co cơ như vậy xảy ra trên 1 đoạn tương đối gần nhau thì sẽ tạo ra 1 buồng kín, áp lực trong buồng này có thể tăng vượt quá 90 mmHg. Áp lực tăng cao sẽ thúc đẩy niêm mạc thoát vị qua các chỗ yêu của thành ruột. Hiện tượng như vậy thường gặp ở đại tràng chậu hông (Figure 2).
== Túi thừa thật
Túi thừa thật ít gặp hơn, cấu trúc của nó có đầy đủ các lớp của ống tiêu hóa. Cơ chế hình thành chưa rõ ràng, có khả năng là bẩm sinh, thường xuất hiện ở người trẻ. Túi thừa thật thường được cho là của đại tràng phải, chính xác hơn là của manh tràng. Khác với túi thừa giả, cơ chế bệnh sinh của túi thừa thật chưa được chứng minh bằng thực nghiệm mà chỉ có những ghi nhận và suy luận. Có thể tóm lược một số quan điêm tương đôi nồi bật trong y văn về nguồn gốc của túi thừa thật.
Quan niệm phô biến xem túi thừa manh tràng như là 1 túi thừa thật, đơn độc và có nguon goc bam sinh bat nguon từ 100 năm trước. Các nhà nghiên cứu đầu tiên trích dẫn các nghiên cứu phôi thai học của Kelly và Hurdon, mô tả quá trình phát triển của đỉnh manh tràng trong giai đoạn tuần thứ 6 của thai kỳ. Giai đoạn này có sự tồn tại một cầu trúc túi nằm phía ngoài ruột thừa, cấu trúc này thường biến mất trước khi ruột thừa hình thành. Họ cho rằng túi thừa manh tràng có nguồn gốc từ di tích của phần phụ phôi thai bẩm sinh này. Như vậy, túi thừa ở ngoài khu vực này thì không phù hợp với giả thuyết trên. Tương tự, năm 1929, Evans cho rằng túi thừa bẩm sinh bắt nguồn từ những bất thường trong quá trình làm đầy của nội bì manh tràng. Vị trí thay đổi của túi thừa trên manh tràng và bản chất bẩm sinh của nó củng cố thêm cho giả thuyết này.
Các tác giả khác lại cho rằng, dù túi thừa manh tràng là túi thừa thật thì nó cũng có thể là mắc phải. Năm 1914, Bunts báo cáo 1 túi thừa manh tràng xảy ra tại vị trí mòm cụt của ruột thừa, hiện tượng này là do lỏng mũi khâu vòng khi khâu lộn mỏm ruột thừa vào trong manh tràng. Năm 1922, Horsely tuyên bố rằng, phương pháp khâu vùi gốc trong cắt ruột thừa là một yếu tố quan trọng hình thành túi thừa manh tràng. Năm 1917, Schlesinger báo cáo 3 trường hợp viêm túi thừa manh tràng, thứ phát do các dây dinh hình thành sau lần mô trước kéo tạo nên. Năm 1929, Greensfelder và Hiller báo cáo nghiên cứu lâm sàng và thực nghiệm xác nhận cả 2 nguyên nhân dính và khâu vùi gốc trong cắt ruột thừa là cơ chế gây ra túi thừa thật mắc phải của manh tràng.
= Diễn tiến của bệnh túi thừa đại tràng
Hiểu biết diễn tiến tự nhiên của bệnh túi thừa rất quan trọng để chọn lựa cách điều trị phù hợp cho bệnh nhân. Hầu hết các nghiên cứu về diễn tiến bệnh thường tập trung cho bệnh túi thừa đại tràng trái, theo đó có 70% bệnh nhân túi thừa đại tràng không có biểu hiện triệu chứng, 15 - 25% bệnh nhân sẽ bị viêm và 5-15% bệnh nhân có biến chứng chảy máu.
== Viêm túi thừa
=== Cơ chế viêm
Viêm túi thừa là hậu quả của thủng vi thể hay đại thể của túi thừa. Trước đây, người ta tin rằng sự tắc nghẽn của túi thừa (do sỏi phân) làm tăng áp lực trong lòng túi thừa là nguyên nhân gây thủng. Hiện nay, người ta cho rằng khả năng đó hiếm khi xảy ra mà là do thành túi thừa bị xói mòn bởi sự tăng áp lực trong lòng đại tràng hoặc do tác động của các mảnh phân cứng. Sự viêm và hoại tử khu trú xảy ra sau đó gây ra thủng túi thừa. Các yếu tố góp phần vào tình trạng viêm là: sự tắc nghẽn của túi thừa, sự ứ đọng, sự thay đổi của hệ vi khuẩn đường ruột và sự thiếu máu cục bộ. Sau khi túi thừa thủng, một lỗ thủng nhỏ có thể được mỡ quanh đại tràng, mạc treo hoặc các cơ quan kế cận bao bọc lại. Nếu tình trạng nhiễm khuẩn tiếp tục diễn tiến có thể dẫn đến áp xe, viêm phúc mạc hay rò vào các cơ quan kế cận. Tắc đại tràng có thể xảy ra khi hiện tượng viêm làm hẹp lòng đại tràng. Trong trường hợp lỗ thủng lớn hoặc sự bao bọc lỏng lẻo có thể gây thủng tự do vào ổ bụng dẫn đến viêm phúc mạc phân.
#figure(
image("figure/fig4.png"),
caption: [
Common types of blind loop. (a) Self-filling: deficiency occurs. (b) Self-emptying: no deficiency occurs. (c) Long afferent loop stasis in Pólya gastrectomy. (d) Jejunal diverticula. (e) Intestinal stricture causing stasis. (f) ‘Stenosis–anastomosis loop’ syndrome.
@RN2
],
)
=== Phân độ viêm túi thừa
Cho tới nay có rất nhiều bảng phân loại theo diễn tiến cũng như độ nặng của bệnh túi thừa đại tràng nói chung. Hầu hết các bảng phân loại được thay đổi theo thời gian bởi có những điểm mới trong chẩn đoán và điều trị. Một số phân loại có sự tương đồng về tổn thương đại thể và dấu hiệu trên chụp cắt lớp vi tính (phân loại Kaiser).
#table(
columns: (40pt, auto, auto),
inset: 7pt,
align: horizon,
[*Mức độ*], [*Phân loại Wasvary*], [*Dấu hiệu trên cắt lớp vi tính (Kaiser)*],
text("0"),
text("Viêm túi thừa biểu hiện lâm sàng nhẹ"),
text("Túi thùa viêm, +/- dày thành đại tràng"),
text("Ia"),
text("Viêm khu trú quanh thành đại tràng"),
text("Dày thành kèm thay đổi mô mỡ xung quanh"),
text("Ib"),
text("Áp xe quanh đại tràng hoặc mạc treo"),
text("Tương tự Ia kèm hình ảnh áp xe"),
text("II"),
text("Áp xe xa: vùng chậu, giữa các quai ruột hay sau phúc mạc"),
text("Tương tự Ia kèm hình ảnh áp xe ở xa chỗ nguyên phát"),
text("III"),
text("Viêm phúc mạc mủ toàn thể"),
text("Khí và dịch tự do kèm theo dày phúc mạc"),
text("IV"),
text("Viêm phúc mạc phân toàn thể"),
text("Tương tự III")
)
Gần đây, Hội Ngoại khoa Cấp cứu Thế Giới (WSES) đã đưa ra bảng phân loại mới và được sử dụng phổ biến hiện nay. Căn cứ vào hình ảnh chụp cắt lớp vi tính, viêm túi thừa đại tràng được chia thành 2 nhóm là không biến chứng và có biến chứng, trong đó nhóm có biến chứng lại được chia tiếp thành 4 mức độ tùy theo độ nặng. Dưới đây là phân loại WSES 2020:
*(1) Viêm túi thừa không biến chứng:*
Giai đoạn 0: túi thừa dày thành, tăng đậm độ mỡ xung quanh
*(2) Viêm túi thừa có biến chứng:*
Giai đoạn 1a: có các bóng khí hoặc tụ dịch lượng ít quanh đại tràng trong phạm vi 5 cm từ vị trí viêm (chưa hình thành ổ áp xe)
Giai đoạn lb: ổ áp xe ≤ 4 cm Giai đoạn 2a: ô áp xe > 4 cm
Giai đoạn 2b: có khí ở xa ngoài 5 cm tính từ vị trí túi thừa viêm
Giai đoạn 3: dịch lan tỏa khắp ổ bụng không kèm theo khí tự do
Giai đoạn 4: dịch lan tỏa khắp ổ bụng kèm khí tự do
Tuy nhiên, bảng phân loại WSES 2020 có thể gây lẫn lộn vì có giai đoạn chia thành các nhóm thứ cấp (la,b và 2a,b) có giai đoạn không chia (3 và 4). Đặc biệt là cùng 1 thế lâm sàng lại được phân vào 2 giai đoạn khác nhau như áp xe có ở 1b và 2a hoặc thậm chí ở các giai đoạn không liên tiếp nhau như khí tự do có ở la, 2b và 4.
Tất cả các phân loại này chủ yếu dành cho viêm túi thừa đại tràng trái, tuy nhiên, khá nhiều tác giả cũng sử dụng để phân loại cho viêm túi thừa đại tràng phải. Cho tới nay cũng có vài tác giả nhận biết sự khác biệt về đặc điểm bệnh cũng như diễn tiến của túi thừa đại tràng phải và túi thừa đại tràng trái nên đã đưa ra bảng phân loại riêng cho túi thừa đại tràng phải (thật ra là manh tràng) như Greaney và Snyder (1957) hoặc Thorson va Tement (1998), Khác biệt cơ bản so với phân loại Hinchey là giai đoạn II không phải là áp xe và giai đoạn III là thủng khu trú chứ không phải viêm phúc mạc toàn thể.
#table(
columns: (40pt, auto, auto),
inset: 7pt,
align: horizon,
[*Mức độ*], [*Greaney và Snyder (1957)*], [*Thorson va Tement (1998)*],
text("I"),
text("Viêm cấp"),
text("Túi thừa viêm dễ nhận biết"),
text("II"),
text("Khối viêm"),
text("Khối manh tràng viêm"),
text("III"),
text("Thủng khu trú"),
text("Rò hoặc áp xe khu trú"),
text("IV"),
text("Mủ khắp ổ bụng"),
text("Viêm phúc mạc lan tỏa do thủng hoặc vỡ áp xe")
)
#figure(
image("figure/fig3.PNG"),
caption: [
Phân loại viêm túi thừa manh tràng
],
)
=== Chảy máu túi thừa
Khi một túi thừa giả được hình thành, niêm mạc đại tràng thoát ra tại chỗ yếu của thành ruột, mạch máu xuyên tại điêm đó bị đấy lên vòm của túi thừa và chỉ được ngăn cách với lòng ruột bởi lớp niêm mạc. Theo thời gian, mạch máu này tiếp xúc với các chân thương tác động từ trong lòng túi thừa, dẫn tới dày không đồng tâm lớp nội mạc và mỏng lớp trung mạc. Các thay đối này có thể tạo ra các đoạn yếu của động mạch, dẫn tới vỡ vào trong lòng túi thừa. Chảy máu túi thừa thông thường xảy ra không kèm theo viêm túi thừa.
Mối tương quan về giải phẫu của túi thừa và mạch máu thì giống nhau giữa túi thừa đại tràng phải và đại tràng trái. Tuy nhiên chảy máu ở túi thừa đại tràng phải thường xảy ra hơn, dù thực tế túi thừa chủ yếu nằm ở đại tràng bên trái. Một lý giải khả dĩ cho hiện tượng này đó là túi thừa ở đại tràng phải có cổ và vòm rộng hơn nên khả năng các mạch máu tiếp xúc với tác nhân gây chấn thương kéo dài và mạnh hơn. Một số tác giả khác giải thích là do thành đại tràng phải mỏng hơn.
= Thể lâm sàng
== Thủng túi thừa
Biến chứng thủng túi thừa là biến chứng nặng, tùy theo mức độ lan rộng của dịch mủ hay dịch phân mà dẫn đến hậu quả nhiễm độc và viêm phúc mạc khu trú hay toàn thể. Những trường hợp này cần được phẫu thuật cắt bỏ đoạn đại tràng thủng và có thể phải đưa hậu môn nhân tạo trên dòng. Tỷ lệ tử vong còn cao từ 12-36% và phụ thuộc nhiều vào tình trạng sức khỏe của người bệnh trước phẫu thuật.
== Rò túi thừa
Thường hay xảy ra túi thừa đại tràng Sigma, túi thừa viêm dính vào các cơ quan lân cận hay thành bụng. Rò được hình thành do quá trình viêm nhiễm của bản thân túi thừa hay do hậu quả của phầu thuật. Đa số các trường hợp chỉ có 1 đường rò duy nhất từ đại tràng ra 1 tạng lân cận, nhưng có khoảng 8% là có nhiều đường rò. Các dạng đường rò có thê gặp như rò đại tràng ra da, rò đại tràng - bàng quang rò đại tràng - ruột non, rô đại tràng - âm đạo.
- Rò đại tràng ra da: về mặt giải phẫu đại tràng Sigma nằm sát thành bụng bên nên khi áp xe quanh túi thừa đại tràng sẽ có xu hướng rò ra thành bụng bên trái. Hoặc rò xuất hiện sau khi dẫn lưu áp xe túi thừa qua da dưới hướng dẫn siêu âm hay chụp cắt lớp vi tính bụng. Hoặc đôi khi rò xuất hiện sau khi có rò ở miệng nối đại tràng sau phẫu thuật cắt đoạn đại tràng do bệnh lý túi thừa.
- Rò đại tràng - bàng quang: là dạng rò hay gặp nhất trên lâm sàng, rò bàng quang gặp ở nam nhiều hơn do nữ có tử cung nằm giữa bàng quang và đại tràng. Người bệnh sẽ có biểu hiện lâm sàng của nhiễm khuẩn tiểu tái đi tái lại nhiều lần, tiểu gắt buốt, đôi lúc tiểu ra mủ hay lẫn ít phân (ít gặp). Chẩn đoán cần kết hợp dựa vào soi bàng quang có thể thấy được lỗ rò hay 1 vùng biếu mô viêm nhiễm trên thành bàng quang và chụp đại tràng đối quang kép với thuốc cản quang tan trong nước hoặc chụp cắt lớp vi tính bụng thấy đường rò từ đại tràng vào bàng quang.
- Rò đại tràng - ruột non: đoạn ruột non bị dính vào túi thừa viêm, rò được hình thành khi áp xe túi thừa thủng vào thành ruột non và thường không gây triệu chứng. Dạng rò này thường phát hiện trong lúc mổ áp xe trong ổ bụng và thấy đường rò từ đại tràng vào ruột non kế cận.
- Rò đại tràng âm đạo: người bệnh có triệu chứng nhiễm khuẩn âm đạo, có phân hay mủ chảy ra từ âm đạo và hay gặp ở những trường hợp đã mổ cắt tử cung trước đó. Chần đoán dựa vào sự kết hợp giữa khám lâm sàng và chụp cộng hưởng từ vùng chậu để xác định đường rò và loại trừ bệnh lý ác tính của trực tràng và phần phụ.
== Chảy máu túi thừa
Biến chứng chảy máu túi thừa thường ít gặp, chỉ khoảng 5%, tuy nhiên việc chẩn đoán chảy máu từ túi thừa hay do nguyên nhân khác thì rất khó. Ở người lớn tuổi, hầu hết nguyên nhân xuất huyết tiêu hóa dưới là do dị dạng mạch máu, nhưng 90% trường hợp chảy máu tiêu hóa dưới nặng là do kết hợp giữa dị dạng mạch máu và chảy máu từ túi thừa. Chụp mạch máu dưới cắt lớp vi tính (CT angiography) có thể phát hiện ra chỗ thoát mạch gây chây máu và can thiệp tắc mạch cầm máu, nhưng hạn chế angiography là chỉ phát hiện được dấu thoát mạch khi lưu lượng máu chảy ít nhất là 0,5 ml/phút. Nội soi đại tràng cũng thấy được điểm chảy máu túi thừa tuy nhiên chỉ thực hiện được khi mức độ chảy máu rỉ rả, nội soi can thiệp đóng vai trò ngày càng quan trọng điều trị bằng các phương pháp sử dụng clip hay vòng thắt cầm máu.
== Tắc ruột
Tắc đại tràng do túi thừa chiêm 10-20% ở phương Tây là hậu quả của quá trính viêm túi thừa đại tràng kéo dầi, tái đi tái lại nhiều lần dẫn đến viêm mạn tính, dầy thành đại rng gây hẹp lòng ruột. Tắc ruột non cũng có thể gặp do ruột dính vào đại tràng gây viêm dính gập góc làm hẹp lòng ruột. Hầu hết người bệnh vào viện với bệnh cánh đau bung, bi trung đại tiện và phát hiện tắc ruột trên chụp cắt lớp vi tính (CLVT) bụng. Trong lúc mổ đôi lúc rất dễ nhầm lẫn giữa nguyên nhân gây hẹp lòng đại trăng là do thoi ung thu dai trang tien trien hay viem ti thia man tinh, viee xae dinh nguyen nhan lúc này phải dựa vào kết quả giải phẫu bệnh đoạn đại tràng cắt ra sau mổ.
== Áp xe túi thừa
Áp xe túi thừa là biến chứng thường gặp của viêm túi thừa có biến chứng, khối áp xe được hình thành do hoại tử trung tâm của túi thừa bị viêm và lan rộng ra bên ngoài. Bệnh cảnh lâm sàng là đau bụng, sốt, khối ấn đau ở thành bụng, số lượng bạch cầu tăng. Áp xe túi thừa bên phải rất dễ chẩn đoán nhầm với áp xe ruột thừa do đặc điểm đau, thời gian bệnh cũng như khám lâm sàng có khối ấn đau ở hố chậu phải tương tự nhau. Chụp CLVT bụng giúp xác định chẩn đoán, vị trí ổ áp xe, kích thước ổ áp xe, hình ảnh của túi thừa viêm và xác định có khí trong ổ bụng hay không, dựa vào kêt quả đó sẽ phân độ túi thừa có biến chứng theo bảng phân loại WSES 2020 và có hướng xử trí theo hướng dẫn điều trị được trình bày ở phần tiếp theo.
== Ung thư
Chưa có bằng chứng rõ ràng khẳng định viêm túi thừa đại tràng sẽ dẫn đến ung thư đại tràng, tuy nhiên nghiên cứu tại Thuy Điến (2004) cho thấy có môi liên quan giữa viêm túi thừa đại tràng Sigma và tăng ngụy cơ ung thư đại tràng bên trái trong thời gian dài (OR = 4,2; 95% Cl).
= Chẩn đoán
Túi thừa đại tràng không biểu hiện lâm sàng khi không có các biến chứng, có thể được phát hiện tình cờ khi nội soi đại tràng, chụp đại tràng cản quang, chụp CLVT bụng... Hai biến chứng phổ biến nhất là viêm túi thừa và chảy máu túi thừa. Phần bên dưới mô tả các triệu chứng và dầu hiệu của viêm túi thừa đại tràng
== Lâm sàng
=== Viêm túi thừa đại tràng ở mọi vị trí
Biểu hiện lâm sàng của viêm túi thừa (túi thừa trở nên viêm và nhiễm khuẩn) tùy thuộc vào vị trí của túi thừa bị viêm, mức độ nặng của tình trạng viêm và sự xuất hiện các biến chứng. Đau ¼ dưới trái là biểu hiện phổ biến nhất và chiếm 70% các trường hợp, đau kiêu quặn và thường kèm theo thay đổi thói quen đi cầu. Viêm túi thừa của manh tràng hoặc đại tràng lên có thể gây đau ở ¼ dưới, dễ gây nhầm lẫn với viêm ruột thừa. Triệu chứng viêm túi thừa nhẹ có thể nhầm lẫn hoặc trùng lắp với triệu chứng của hội chứng ruột kích thích và nhiều bệnh lý khác. Một số triệu chứng khởi đầu bao gồm:
- Đau bụng (thường đau ¼/ dưới trái)
- Buồn ói, ói
- Sốt
- Đây hơi, chướng bụng
- Các triệu chứng và dấu hiệu có thể tăng khi xuất hiện các biến chứng như áp xe, viêm phúc mạc.
- Bệnh nhân suy giảm miễn dịch, dùng corticoid kéo dài, lớn tuổi có thể triệu chứng không điển hình hoặc không triệu chứng.
- Khi bệnh diễn tiến mạn tính có thể gây ra rò (bàng quang, âm đạo...), hẹp lòng đại tràng...
Bởi vì túi thừa có thể ở bất cứ vị trí nào nên khi viêm có thể nhầm lẫn với nhiều tình trạng khác:
- Viêm túi thừa đại tràng phải hoặc đại tràng chậu hông dài có thể nhầm với viêm
ruột thừa
- Viêm túi thừa đại tràng ngang có thể nhầm với viêm dạ dày, viêm tụy, viêm túi mật
- Viêm các túi thừa đại tràng nằm sau phúc mạc có thể nhầm lẫn với bệnh lý hệ niệu
- Viêm túi thừa đại tràng ở phụ nữ có thể nhầm với các bệnh lý phụ khoa
=== Viêm túi thừa đại tràng phải
Túi thừa đại tràng phải khi viêm thường biểu hiện đau tại vùng bụng phải. Có khá nhiều bệnh lý biếu hiện triệu chứng đau ở vùng này như các bệnh lý của gan mật, đại tràng phải, hồi manh tràng, thận niệu quản phải... mà phổ biến nhất là viêm ruột thừa.
Thực tế, ở nước ta hiện nay, túi thừa đại tràng vẫn được xem là bệnh quá hiếm nên ít khi được nghĩ tới. Chính vì vậy khi một bệnh nhân đến khám với biểu hiện đau hố chậu phải thì thường được nghĩ tới viêm ruột thừa chứ ít ai nghĩ tới viêm túi thừa.
Tuy nhiên, vẫn có một số chi tiết khác biệt rất hữu ích để phân biệt viêm ruột thừa và viêm túi thừa: viêm ruột thừa thường khởi bệnh ở độ tuôi trẻ hơn, đau thường bắt đầu từ thượng vị hoặc quanh rốn sau đó mới di chuyển xuống hố chậu phải, quá trình bệnh thường là ngắn (vài giờ tới 1-2 ngày), các triệu chứng buồn ói và ói gặp ở khoảng 70% trường hợp. Trong khi đó, viêm túi thừa thì thường đau khu trú ở bụng phải (tùy vị trí túi thừa) ngay từ đầu, quá trình bệnh dài hơn (do không rầm rộ nên bệnh nhân chưa đi khám), hiếm khi có triệu chứng buồn ói hoặc ói.
Điểm đau nằm ngoài hoặc cao hơn điểm McBurney khi khám lâm sàng cũng là dấu hiệu gợi ý của viêm túi thừa. Ngoài ra các biêu hiện như đau mơ hô, đau mức độ nhẹ, ít có các biểu hiện của đáp ứng viêm toàn thân như sốt cao, tăng bạch cầu.
Kết quả nghiên cứu trong luận án Tiến sĩ mới được công bố năm 2019 ở nước ta cho thấy, bệnh thường biểu hiện ở độ tuổi khá trẻ với tuổi trung bình là 35,6 ‡ 12,8 tuổi.Phái nam chiếm ưu thế (nam: nữ = 2:1). Thời gian đau đến lúc nhập viện khoảng 1,7 - 1,8 ngày; khởi phát chủ yếu ở hông hoặc hố chậu phải chứ ít khi di chuyền; mức độ đau ít hoặc vằ; ít khi sốt cao và số lượng bạch cầu tăng vừa phải.
Như vậy, các dấu hiệu lâm sàng đơn thuần không thể giúp chấn đoán xác định viêm túi thừa đại tràng phải. Tuy nhiên, với việc hỏi kỹ bệnh sữ, thăm khám kỹ căng, đánh iá tương quan giữa các dấu hiệu có thể giúp chúng ta sàng lọc được những bệnh nhân nghi ngờ viêm túi thừa đại tràng phải để chỉ định các phương tiện hình ảnh phù hợp giúp xác định chẩn đoán.
== Siêu âm
=== Viêm túi thừa đại tràng trái
Hình ảnh bất thường của một đoạn đại tràng (dày thành > 4 mm trên đoạn dài ≥ 5 cm) tại điểm đau nhất là dấu hiệu thường thấy nhất trên siêu âm, có ở gần 85% các bệnh nhân. Trên hình cắt ngang, đại tràng dày giống hình bia. Túi thừa viêm, các bóng khí, áp xe trong thành ruột, áp xe quanh túi thừa và hiện tượng viêm quanh đại tràng cũng có thể thấy. Độ nhạy của siêu âm thay đôi từ 85-98%, độ đặc hiệu 80-98%.
#figure(
image("figure/fig7.png"),
caption: [
Hình này thể hiện số đo được thực hiện bởi EP của thành ruột khoảng 1 cm. Số đo >4–5 mm là dấu hiệu của thành ruột dày lên. @RN3
],
)
=== Viêm túi thừa đại tràng phải
Về mặt giải phẫu, túi thừa có đường kính rất thay đổi, chiều dài thì ngắn hơn ruột thừa và có thể xuất phát từ bất cứ chỗ nào trên đại tràng (ruột thừa chỉ xuất phát từ manh tràng). Như vậy, nếu có cầu trúc hình tròn hay bầu dục nhô ra ngoài và có xuất phát từ đại tràng phải mà không đủ tiêu chuân của viêm ruột thừa thì có thế là túi thừa.
Hoặc nếu xác định được cấu trúc này không xuất phát từ manh tràng thì càng có nhiều khả năng là túi thừa. Chấn đoán càng trở nên chắc chắn khi ngoài cấu trúc đó chúng ta còn thấy được cấu trúc ruột thừa bình thường. Một số hình ảnh khác cũng cần được đánh giá là tình trạng thành đại tràng và mô mỡ bao xung quanh.
Dấu hiệu phổ biến nhất của túi thừa đại tràng phải viêm không biến chứng là 1 câu trúc giảm âm hoặc gần như không phản âm, hình tròn hoặc hình bầu dục nhô ra khỏi thành của đoạn đại tràng. Một số trường hợp cấu trúc này chứa chất phản âm mạnh bên trong, đó có thể là khí hoặc sỏi phân trong lòng túi thừa. Khi túi thừa chứa mủ, mô mềm xung quanh tăng âm không đồng nhất biểu hiện phản ứng viêm mô mỡ quanh đại tràng. Với những đặc điểm này, đặc biệt là hình ảnh ruột thừa bình thường cũng được thấy trên siêu âm, thì nhiều khả năng đó là túi thừa.
#figure(
image("figure/fig5.png"),
caption: [
Hình một túi thừa (mũi tên) với dải mỡ tăng âm (sáng) xung quanh. @RN3
],
)
#figure(
image("figure/fig6.png"),
caption: [
Hình một túi thừa (mũi tên) với dải mỡ tăng âm (sáng) liền kề. @RN3
],
)
Chou và cộng sự báo cáo 934 bệnh nhân với lâm sàng đau bụng bên phải chưa rõ nguyên nhân được siêu âm bụng. Kết quả là siêu âm có thể phân biệt viêm ruột thừa với viêm túi thừa đại tràng phải với độ chính xác 100%. Báo cáo cũng cho biết độ nhạy là 91,3%, độ đặc hiệu là 99,8% và độ chính xác là 99,5%. Ngoài ra, giá trị tiên đoàn dương là 95,5% và giá trị tiên đoán âm là 99,7%. Âm tính già có thể do túi thừa nhỏ bi bò sót, khảo sát bị hạn chế do bệnh nhân mập, ruột chướng hơi hoặc do đề kháng thành hụng. Ngoài ra kinh nghiệm cũng như trình độ của người bác sĩ siêu âm cũng ănh hưởng rất nhiều tới chẩn đoán bệnh.
Đề đạt được các con số ấn tượng này, sự kết hợp với bác sĩ lâm sàng rất quan trọng, lâm sàng cần cung cấp thông tin nghi ngờ viêm túi thừa hoặc lâm sàng không điền hình của viêm ruột thừa. Khi đó, bác sĩ siêu âm nếu không thấy hình ảnh chứng tỏ viêm ruột thừa thì cần phải khảo sát thêm một cách kỹ lưỡng manh tràng và đại tràng lên. Bất cứ một cấu trúc hình tròn hay bầu dục nhỏ chứa dịch nằm kế đại tràng thì phải nghi ngờ túi thừa.
Siêu âm nên là phương tiện hình ảnh đầu tiên chỉ định cho bệnh nhân nghi ngờ viêm túi thừa. Thuận lợi của siêu âm là an toàn, dễ tiếp cận, được sử dụng rộng rãi, giá cả phải chăng, thực hiện được trong nhiều tình huống, có thể lặp lại dễ dàng, cho các hình ảnh có giá trị để chẩn đoán nhất là khi kết hợp chặt chẽ với lâm sàng.
== Chụp cắt lớp vi tính
Chụp cắt lớp vi tính (CLVT) và các phương tiện hình ảnh cắt ngang (cross-sectional imaging) được xem là phương tiện tốt nhất dùng để chần đoán và theo dõi diễn tiến viêm túi thừa đại tràng Tương tự như siêu âm, chụp CL VT cho những hình ảnh cắt qua cơ quan nên có thể đánh giá tốt cả trong và bên ngoài đại tràng, là những chi tiết mà nội soi hay chụp đại tràng không thê có được. Chụp CL VT có ưu điểm hơn siêu âm là cho những hình ảnh khách quan và toàn diện hơn trong khi siêu âm phụ thuộc rất nhiều vào người siêu âm. Chính vì vậy, chụp CLVT khong những có thể chẩn đoán tốt túi thừa đại tràng mà còn đánh giá tốt các biến chứng và độ nặng của nó.
Ngày nay, chụp CLVT được xem là tiệu chuẩn vàng để chân đoán và phân giai đoạn bệnh viêm túi thừa đại tràng, đặc biệt là trong tình huống cấp cứu. Các hướng dẫn của các quốc gia Âu Mỹ có sự đồng thuận và khuyên cáo mạnh về sử dụng chụp CLVT để chẫn đoán bệnh túi thừa đại tràng trái. Tuy nhiên, với túi thừa đại tràng phải thì là một câu chuyện khác. Theo báo cáo tổng kết của Graham vào năm 1987 thì chân đoán chính xác trước mổ viêm túi thừa đại tràng phải chỉ đạt được 6%, thậm chí kể cả ở nhóm đã cắt ruột thừa rồi thì chẩn đoán chính xác trước mô cũng chỉ là 16,6%. Giai đoạn đầu, với chụp CLVT thế hệ cũ, Balthazar và cộng sự mô tả dấu hiệu của viêm túi thừa manh tràng trên chụp CLVT giống như cách mô tả của viêm túi thừa đại tràng
Sigma. Với các dấu hiệu này (dày thành đại tràng, thâm nhiễm) thì chẩn đoán chính xác vẫn khó khăn do viêm ruột thừa cũng có các dấu hiệu tương tự như. Sau này, với chụp
CLVT thế hệ mới, lát cắt mỏng thì hầu hết ruột thừa bình thường đều phát hiện được nên chẩn đoán phân biệt 2 bệnh lý này không còn là vấn đề với chụp CLVT hiện đại
#figure(
image("figure/fig8.png"),
caption: [
Hình ảnh CT cản quang theo trục cho thấy sự hiện diện của túi thừa dưới dạng một túi nhỏ chứa đầy khí của thành đại tràng (mũi tên). @RN4
],
)
#figure(
image("figure/fig9.png"),
caption: [
Ví dụ về mật độ túi thừa. Hình ảnh CT tăng cường độ tương phản theo trục cho thấy khoảng cách tối thiểu giữa hai túi thừa liền kề (mũi tên). Trường hợp này ở mức độ vừa phải (mỗi túi thừa nằm cạnh nhau dưới 1 cm). @RN4
],
)
Độ nhạy và đặc hiệu của chụp CLVT trong chấn đoán viêm túi thừa đại tràng phải được báo cáo là trên 98%. Tiêu chuẩn chẩn đoán viêm túi thừa đại tràng phải trên chụp CLVT là dày thành đại tràng; thâm nhiễm mỡ quanh đại tràng; áp xe quanh đại tràng; các bóng khí trong niêm mạc đại tràng, thành đại tràng và khí bên ngoài lòng ống. Theo Jang, với chụp CLVT xoắn ốc lát cắt mỏng có thuốc cần quang, có thể chẩn đoán được viêm túi thừa đại tràng phải trong hầu hết các trường hợp. Đặc biệt, các dấu hiệu hữu ích cho chẩn đoán là sỏi phân trong túi thừa, tăng quang của thành túi thừa và kiểu bắt thuốc cản quang đặc trưng của thành đại tràng. Kiểu bắt thuốc của đại tràng (lớp ngoài và trong mỏng có đậm độ cao trong khi lớp giữa dày có đậm độ thấp) có thể là một dấu hiệu hỗ trợ hữu ích, có ý nghĩa để phân biệt với ung thư đại tràng. Khi quen thuộc các dấu hiệu này có thể giúp chúng ta chẩn đoán chính xác viêm túi thừa đại tràng phải. Lee và cộng sự đưa ra các tiêu chuẩn trên chụp CLVT tương tự trong đó lưu ý sự hiện diện của túi thừa viêm và hình ảnh ruột thừa bình thường. Qua nghiên cứu, tác giả ghi nhận có 60% TH có 2 tiêu chuẩn này.
Sự hiện diện hình ảnh túi thừa viêm được cho là bằng chứng khách quan nhất của viêm túi thừa, nhưng cần phải phân biệt đúng là túi thừa gây ra viêm hay chỉ là sự hiện diện của 1 túi thừa trong môi trường viêm do nguyên nhân khác. Và khi đó, cần phải tìm nguyên nhân chính gây bệnh, túi thừa lúc này chỉ đơn thuần là bệnh kèm theo. Các túi thừa chứa sỏi phân hoặc chứa đầy chất phân thì dễ nhận biết trong khi các túi thừa viêm với hình ảnh bắt quang kém kiểu mô mềm sẽ rất khó để nhận ra. <NAME>n là đa số túi thừa thường bắt cản quang lớp niêm mạc mạnh, do đó chụp CLVT cần có sự hỗ trợ của thuốc cản quang đường tĩnh mạch.
Tuy nhiên, có nhiều ý kiến cho rằng việc áp dụng chụp CLVT để chẩn đoán tất cả các trường hợp đau hô chậu phải hoặc tất cả các trường hợp nghi ngờ viêm ruột thừa để phần biệt với viêm túi thừa là khó khả thi và làm tăng chi phí y tế đồng thời ít nhiều khiến bệnh nhân tiếp xúc với tia xạ, do vậy hiện nay hầu hết viêm ruột thừa vẫn được chân đoán dựa vào lâm sàng, xét nghiệm máu và siêu âm bụng, như vậy khả năng lầm với viêm túi thừa vẫn có thể xảy ra. Để hạn chế điều này, người lâm sàng phải hỏi và khám kỹ lâm sàng và chỉ định chụp CLVT khi nghi ngờ như thời gian đau dài, vị trí đau bất thường, mức độ đau không tương xứng thời gian đau, biểu hiện toàn thân không rõ...
== Chụp X quang đại tràng
Khi bơm thuốc cản quang vào đại tràng, thuốc đi vào trong túi thừa tạo ra ổ đọng thuốc. Ở đọng thuốc thường có hình cầu hay bầu dục, bờ trơn láng, lớn hay nhỏ tùy kích thước túi thừa. Chụp đại tràng cản quang cho hình ảnh với độ đặc hiệu rất cao, và cũng rất nhạy đối với những bệnh nhân bị đa túi thừa. Tuy nhiên nếu bệnh nhân chỉ có ít túi thừa thì phương pháp này có thể bỏ sót. Nguyên nhân bỏ sót túi thừa có thế là do thuốc không chảy vào trong túi thừa được trong trường hợp túi thừa bị lấp đầy bởi phân, cổ túi thừa nhỏ, áp lực bơm thuốc cản quang không đủ (nhất là đại tràng bên phải cách xa vị tri bơm). Khi túi thừa viêm, hiện tượng phù nề cũng có thê khiên cho thuốc cản quang không vào lòng túi thừa được. Thậm chí, ngay cả khi thuốc có vào trong túi thừa nhưng hướng chụp bị chồng với thuốc trong lòng đại tràng nên túi thừa bị che lấp. Như vậy, túi thừa đại tràng phải dễ bị bỏ sót với phương pháp chụp đại tràng cản quang vì số lượng túi thừa ít, xa nơi bơm thuốc cản quang. Để cải thiện khả năng phát hiện, cần chụp đại tràng nhiều hướng để có thể phát hiện các túi thừa ở các vị trí khác nhau, chụp đối quang kép...
_Dưới đây là hình ảnh túi thừa đại tràng trên phim x quang có bơm thuốc cản quang _
#figure(
image("figure/fig12.jpg"),
caption: [
Hình ảnh túi thừa đại tràng trên phim thẳng. @RN5
],
)
#figure(
image("figure/fig11.jpg"),
caption: [
Hình ảnh túi thừa đại tràng trên phim nghiêng. @RN5
],
)
Một nhược điểm rất lớn của phương pháp này đó là các rủi ro khi thực hiện trong tình trạng túi thừa đang có biến chứng. Sẽ rất nguy hiểm nếu như túi thừa đang viêm hay thủng mà ta bơm áp lực vào trong lòng đại tràng, tạo ra nguy cơ chảy vào trong khoang bụng gây nhiễm bẩn, chưa kể thuốc cản quang thường là barium sulfate rất độc khi tràn vào trong phúc mạc.
Không có nhiều nghiên cứu về phương pháp này trong chân đoán túi thừa đại tràng phải. Nghiên cứu của Gouge: chụp đại tràng cản quang được thực hiện cho 7 bệnh nhân, trước mô chỉ có 1 bệnh nhân được chẩn đoán, hồi cứu lại sau mô thì cũng chỉ có 5 bệnh nhân có hình ảnh chấn đoán được, vẫn còn 2 bệnh nhân không có dấu hiệu để chấn đoán. Vào năm 1991, Yap khảo sát tại Singapore trên 361 bệnh nhân (96% là người Châu Á) được chụp đại tràng cản quang vì nhiều lý do khác nhau. Kết quả có 102 bệnh nhân (28%) bệnh nhân có túi thừa đại tràng. Về vị trí và phân bố của túi thừa: 71% có túi thừa bên đại tràng phải (manh tràng, đại tràng lên, đại tràng góc gan), 15% có túi thừa đại tràng bên trái (đại tràng góc lách, đại tràng xuống, chậu hông), 14% có túi thừa ở khắp đại tràng. Tuổi trung bình người có túi thừa bên phải trẻ hơn bên trái và 2 bên, lần lượt là 54, 62, 67 tuổi. Đối với 72 bệnh nhân túi thừa bên phải, 25 bệnh nhân (35%) chỉ có 1 túi thừa, 21 bệnh nhân có trên 5 túi thừa. Tóm lại, chụp đại tràng cản quang hoặc tốt hơn là đối quang kép nên được áp dụng khi muốn tầm soát hoặc khảo sát sự phân bố cũng như mật độ của túi thừa trên đại tràng. Nên thực hiện ngoài giai đoạn cấp do đó không có vai trò trong tình huống cấp cứu.
== Nội soi đại tràng
Nội soi đại tràng cũng là phương pháp chẩn đoán với độ đặc hiệu cao. Tuy nhiên, cũng như chụp đại tràng, nội soi cũng rất dè dặt chỉ định trong khi túi thừa viêm vì nguy cơ xì dịch vào ổ bụng gây nhiễm bần. Hình ảnh túi thừa thể hiện qua nội soi là các hốc lõm ra ngoài thành đại tràng. Sẽ rất dễ dàng phát hiện nếu bệnh nhân có nhiều túi thừa (sót cái này thì thấy cái khác). Tuy nhiên, nếu túi thừa ít, túi thừa ở đại tràng phải, thao tác soi khó khăn, nếu miệng túi thừa ẩn nấp sau các nếp niêm mạc ruột bị nhô lên thì cũng rất dễ bị bỏ sót, đặc biệt là khi chúng ta không có ý muốn tìm.
Mặc dù không có vai trò trong tình huống cấp tính hoặc thậm chí bị chống chỉ định trong các trường hợp nghi ngờ viêm có biến chứng, nhưng phương pháp này gần như là bắt buộc phải làm sau giai đoạn cấp để xác định chẩn đoán và quan trọng hơn là để phân biệt với các bệnh lý khác của đại tràng, đặc biệt là loại trừ ung thư đại tràng.
== Một số hình ảnh cận lâm sàng khác
#figure(
image("figure/fig14.jpg"),
caption: [
Hình ảnh túi thừa trên MRI. @RN6
],
)
#figure(
image("figure/fig13.jpg"),
caption: [
Giải phẫu bệnh túi thừa. @RN6
],
) |
|
https://github.com/waterlens/resume | https://raw.githubusercontent.com/waterlens/resume/main/README.md | markdown | MIT License | # Resume Template in Typst
The template is inspired by [Matchy's template](https://github.com/matchy233/typst-chi-cv-template) and adjusted with my resume style.
## Usage
### Using Typst web app
Upload `template.typ`, `fa.typ`, `resume.typ` and `fonts/*` to [Typst](https://typst.app/), and then you can edit the resume.
### Locally
Assume that you have installed `typst` cli already and it's in your `$PATH`.
```bash
git clone https://github.com/waterlens/resume.git
cd resume
typst --font-path ./fonts compile resume.typ resume.pdf
``` |
https://github.com/TypstApp-team/typst | https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/compiler/field.typ | typst | Apache License 2.0 | // Test field access.
// Ref: false
---
// Test field on dictionary.
#let dict = (nothing: "ness", hello: "world")
#test(dict.nothing, "ness")
#{
let world = dict
.hello
test(world, "world")
}
---
// Test fields on elements.
#show list: it => {
test(it.children.len(), 3)
}
- A
- B
- C
---
// Test fields on function scopes.
#enum.item
#assert.eq
#assert.ne
---
// Error: 9-16 function `assert` does not contain field `invalid`
#assert.invalid
---
// Error: 7-14 function `enum` does not contain field `invalid`
#enum.invalid
---
// Error: 7-14 function `enum` does not contain field `invalid`
#enum.invalid()
---
// Closures cannot have fields.
#let f(x) = x
// Error: 4-11 cannot access fields on user-defined functions
#f.invalid
---
// Error: 6-13 dictionary does not contain key "invalid"
#(:).invalid
---
// Error: 8-10 cannot access fields on type boolean
#false.ok
---
// Error: 25-28 content does not contain field "fun"
#show heading: it => it.fun
= A
---
// Error: 9-13 cannot access fields on type boolean
#{false.true}
---
// Test relative length fields.
#test((100% + 2em + 2pt).ratio, 100%)
#test((100% + 2em + 2pt).length, 2em + 2pt)
#test((100% + 2pt).length, 2pt)
#test((100% + 2pt - 2pt).length, 0pt)
#test((56% + 2pt - 56%).ratio, 0%)
---
// Test length fields.
#test((1pt).em, 0.0)
#test((1pt).abs, 1pt)
#test((3em).em, 3.0)
#test((3em).abs, 0pt)
#test((2em + 2pt).em, 2.0)
#test((2em + 2pt).abs, 2pt)
---
// Test stroke fields for simple strokes.
#test((1em + blue).paint, blue)
#test((1em + blue).thickness, 1em)
#test((1em + blue).cap, auto)
#test((1em + blue).join, auto)
#test((1em + blue).dash, auto)
#test((1em + blue).miter-limit, auto)
---
// Test complex stroke fields.
#let r1 = rect(stroke: (paint: cmyk(1%, 2%, 3%, 4%), thickness: 4em + 2pt, cap: "round", join: "bevel", miter-limit: 5.0, dash: none))
#let r2 = rect(stroke: (paint: cmyk(1%, 2%, 3%, 4%), thickness: 4em + 2pt, cap: "round", join: "bevel", miter-limit: 5.0, dash: (3pt, "dot", 4em)))
#let r3 = rect(stroke: (paint: cmyk(1%, 2%, 3%, 4%), thickness: 4em + 2pt, cap: "round", join: "bevel", dash: (array: (3pt, "dot", 4em), phase: 5em)))
#let s1 = r1.stroke
#let s2 = r2.stroke
#let s3 = r3.stroke
#test(s1.paint, cmyk(1%, 2%, 3%, 4%))
#test(s1.thickness, 4em + 2pt)
#test(s1.cap, "round")
#test(s1.join, "bevel")
#test(s1.miter-limit, 5.0)
#test(s3.miter-limit, auto)
#test(s1.dash, none)
#test(s2.dash, (array: (3pt, "dot", 4em), phase: 0pt))
#test(s3.dash, (array: (3pt, "dot", 4em), phase: 5em))
---
// Test 2d alignment 'horizontal' field.
#test((start + top).x, start)
#test((end + top).x, end)
#test((left + top).x, left)
#test((right + top).x, right)
#test((center + top).x, center)
#test((start + bottom).x, start)
#test((end + bottom).x, end)
#test((left + bottom).x, left)
#test((right + bottom).x, right)
#test((center + bottom).x, center)
#test((start + horizon).x, start)
#test((end + horizon).x, end)
#test((left + horizon).x, left)
#test((right + horizon).x, right)
#test((center + horizon).x, center)
#test((top + start).x, start)
#test((bottom + end).x, end)
#test((horizon + center).x, center)
---
// Test 2d alignment 'vertical' field.
#test((start + top).y, top)
#test((end + top).y, top)
#test((left + top).y, top)
#test((right + top).y, top)
#test((center + top).y, top)
#test((start + bottom).y, bottom)
#test((end + bottom).y, bottom)
#test((left + bottom).y, bottom)
#test((right + bottom).y, bottom)
#test((center + bottom).y, bottom)
#test((start + horizon).y, horizon)
#test((end + horizon).y, horizon)
#test((left + horizon).y, horizon)
#test((right + horizon).y, horizon)
#test((center + horizon).y, horizon)
#test((top + start).y, top)
#test((bottom + end).y, bottom)
#test((horizon + center).y, horizon)
---
#{
let object = sym.eq.not
// Error: 3-9 cannot mutate fields on symbol
object.property = "value"
}
---
#{
let object = [hi]
// Error: 3-9 cannot mutate fields on content
object.property = "value"
}
---
#{
let object = calc
// Error: 3-9 cannot mutate fields on module
object.property = "value"
}
---
#{
let object = calc.sin
// Error: 3-9 cannot mutate fields on function
object.property = "value"
}
---
#{
let object = none
// Error: 3-9 none does not have accessible fields
object.property = "value"
}
---
#{
let object = 10
// Error: 3-9 integer does not have accessible fields
object.property = "value"
}
---
#{
let s = 1pt + red
// Error: 3-4 fields on stroke are not yet mutable
// Hint: 3-4 try creating a new stroke with the updated field value instead
s.thickness = 5pt
}
|
https://github.com/SillyFreak/typst-packages-old | https://raw.githubusercontent.com/SillyFreak/typst-packages-old/main/scrutinize/gallery/gk-ek-austria.typ | typst | MIT License | #import "@preview/scrutinize:0.2.0": grading, question, questions
// #import "../src/lib.typ" as scrutinize: grading, question, questions
#import question: q
// make the PDF reproducible to ease version control
#set document(date: none)
#let title = "Praktische Leistungsfeststellung"
#set document(title: title)
#set text(lang: "de")
#let categories = (
(id: "mt", body: [Anwendungsentwicklung -- Multithreading]),
(id: "sock", body: [Anwendungsentwicklung -- Sockets]),
)
#set page(
paper: "a4",
margin: (x: 1.5cm, y: 2cm, top: 4cm),
header-ascent: 20%,
// header: locate(loc => {
// if (calc.odd(loc.page())) {
// }
// }),
header: {
set text(size: 10pt)
table(
columns: (1fr,) * 3,
stroke: none,
align: (col, row) => (left, center, left).at(col) + horizon,
[],
[*#title*],
[],
[Name:],
[],
[Datum: ],
)
},
)
#set table(stroke: 0.5pt)
#show heading.where(level: 2): it => {
let q = question.current()
[Frage #question.counter.display()]
if it.body != [] {
[: #it.body]
}
if q.points != none {
[#h(1fr) #none / #q.points P.]
}
if q.at("extended", default: false) {
[ EK]
}
}
#context {
let qs = question.all()
set text(size: 10pt)
let points(category, extended) = {
grading.total-points(qs, filter: q => q.category == category and q.at("extended", default: false) == extended)
}
let category-points(category) = grading.total-points(qs, filter: q => q.category == category)
let categories = categories.map((category) => {
let gk = points(category.id, false)
let ek = points(category.id, true)
(..category, gk: gk, ek: ek)
})
let total = grading.total-points(qs)
let grades = grading.grades(
[Nicht Genügend (5)],
4/8 * total,
[Genügend (4)],
5/8 * total,
[Befriedigend (3)],
6/8 * total,
[Gut (2)],
7/8 * total,
[Sehr Gut (1)],
)
let grades = grades.map(((body, lower-limit, upper-limit)) => {
if lower-limit == none {
(body: body, range: [< #upper-limit P.])
} else if upper-limit != none {
(body: body, range: [#(lower-limit + 0.5) - #upper-limit P.])
} else {
(body: body, range: [#(lower-limit + 0.5) - #total P.])
}
})
[
= Punkte nach Kompetenzbereichen
#table(
columns: (3fr, ..(1fr,) * 3),
align: (col, row) =>
if col == 0 { left + horizon }
else { right + horizon },
[*Kompetenzbereich*], [*Punkte GK*], [*Punkte EK*], [*Punkte Gesamt*],
..for (id, body, gk, ek) in categories {
(body, [#none / #gk], [#none / #ek], [#none / #(gk + ek)])
},
[Gesamt], [], [], [#none / #total],
)
= Notenschlüssel
#table(
columns: (auto, ..(1fr,) * grades.len()),
align: (col, row) =>
if col == 0 { left + horizon }
else { center + horizon },
[Punkte:],
..grades.map(g => g.range),
[Note:],
..grades.map(g => g.body),
)
]
}
= Grundkompetenzen -- Theorieteil Multithreading
#lorem(50)
#q(category: "mt", points: 2)[
==
#lorem(40)
]
#q(category: "mt", points: 2)[
==
#lorem(40)
]
#q(category: "mt", points: 2)[
==
#lorem(40)
]
#q(category: "mt", points: 3)[
==
#lorem(40)
]
= Grundkompetenzen -- Theorieteil Sockets
#lorem(50)
#q(category: "sock", points: 6)[
==
#lorem(50)
]
#q(category: "sock", points: 2)[
==
#lorem(30)
]
= Grund- und erweiterte Kompetenzen -- Praktischer Teil Multithreading
#lorem(80)
#q(category: "mt", points: 4)[
==
#lorem(40)
]
#q(category: "mt", points: 3)[
==
#lorem(40)
]
#q(category: "mt", points: 4)[
==
#lorem(40)
]
#q(category: "mt", points: 4)[
==
#lorem(40)
]
#q(category: "mt", points: 5, extended: true)[
==
#lorem(40)
]
#q(category: "mt", points: 3, extended: true)[
==
#lorem(40)
]
= Grund- und erweiterte Kompetenzen -- Praktischer Teil Sockets
#lorem(80)
#q(category: "sock", points: 6)[
==
#lorem(40)
]
#q(category: "sock", points: 4)[
==
#lorem(40)
]
#q(category: "sock", points: 6)[
==
#lorem(40)
]
#q(category: "sock", points: 3, extended: true)[
==
#lorem(40)
]
#q(category: "sock", points: 5, extended: true)[
==
#lorem(40)
]
|
https://github.com/Error-418-SWE/Documenti | https://raw.githubusercontent.com/Error-418-SWE/Documenti/src/2%20-%20RTB/Documentazione%20interna/Verbali/23-12-04/23-12-04.typ | typst | #import "/template.typ": *
#show: project.with(
date: "04/12/23",
subTitle: "Meeting di context wwitch relativo al PoC",
docType: "verbale",
authors: (
"<NAME>",
),
missingMembers: (
"<NAME>",
"<NAME>",
"<NAME>",
"<NAME>"
),
timeStart: "15:00",
timeEnd: "16:00",
);
= Ordine del giorno
- spiegazione del lavoro svolto sul PoC;
- analisi dei dubbi emersi;
- organizzazione dei lavori da svolgere durante lo sprint attuale relativamente al PoC.
== Spiegazione del lavoro svolto sul PoC
I lavori svolti durante lo sprint precedente sono stati esposti e spiegati, nello specifico è stato mostrata l'implementazione del sistema di posizionamento degli scaffali nell'ambiente di lavoro, il funzionamento di meccaniche base di Three.js, l'implementazione della lettura dei file SVG e del database.
Sono stati analizzati i moduli e le tecnologie utilizzate (dat.gui, OrbitControls, Vite, Parcel, MySQL).
== Analisi dei dubbi emersi
Tramite l'analisi dei lavori svolti sono emersi dubbi da esporre al Proponente:
- definire se sia più opportuno precaricare il database in blocco oppure interrogarlo ad ogni interazione che necessita le sue informazioni;
- definire come dovrebbe essere gestita l'altezza degli scaffali dopo aver configurato l'ambiente di lavoro tramite file SVG.
= Azioni da intraprendere
Le azioni da intraprendere si concentrano sullo sviluppo del PoC:
- studiare l'utilizzo di Docker e la containerizzazione dell'applicativo;
- esplorare le tecnologie alternative a Three.js, nello specifico Unreal Engine (appena terminato il lavoro attualmente iniziato sulle Norme di Progetto);
- implementare i bin e il loro rapporto con gli scaffali (appena terminato il lavoro attualmente iniziato sulle action di GitHub);
- esplorare i diversi modi di implementare l'interfaccia utente (nel caso qualcuno terminasse anzitempo il lavoro assegnato).
|
|
https://github.com/thomasschuiki/thomasschuiki | https://raw.githubusercontent.com/thomasschuiki/thomasschuiki/main/cv/de.typ | typst | #import "brilliant-CV/template.typ": *
#show: layout
#let data = yaml("./vitae.de.yml")
#cvHeader(hasPhoto: false, align: left)
#cvSection("Professional Experience")
#for e in data.Employment [
#cvEntry(
title: [#e.Role],
society: [#e.Name],
date: [#e.StartDate - #e.EndDate],
location: [#e.Location],
description: list(..e.Details),
logo: "",
tags: ()
)
]
#cvSection("Education")
#for e in data.Education [
#cvEntry(
title: [#e.Credential],
society: [#e.Institution],
date: [#e.StartDate - #e.EndDate],
location: [#e.Location],
description: list([#e.Area]),
logo: "",
tags: ()
)
]
#cvSection("Skills")
#cvSkill(
type: [Languages],
info: [German #hBar() English]
)
#cvSkill(
type: [Software Development],
info: [Python #hBar() Golang #hBar() Git #hBar() Bash #hBar() Cypress #hBar() MySQL #hBar() MongoDB #hBar() Nginx]
)
#cvSkill(
type: [Infrastructure],
info: [Ansible #hBar() Terraform #hBar() Packer #hBar() Docker #hBar() Gitlab CI/CD #hBar() Debian/Ubuntu Linux]
)
#cvSkill(
type: [IT Administration],
info: [Atlassian Confluence, JIRA #hBar() Nextcloud #hBar() Gitlab #hBar() AWS #hBar() Microsoft 365]
)
#cvFooter()
|
|
https://github.com/so298/cv-theme.typ | https://raw.githubusercontent.com/so298/cv-theme.typ/main/README.md | markdown | # cv-theme.typ
> [!NOTE]
> Example PDFs are available in the [Releases](https://github.com/so298/cv-theme.typ/releases) page.
My CV template for [typst](https://typst.app/).
## Requirements
- typst v0.11+
- Fonts
- Open Sans
- <NAME>
## Typst Template
Add the following code to your typst file.
```typst
#set page("a4")
#import "./theme.typ": *
#show: cv
#set text(font: ja_sans, size: 10pt, lang: "ja")
// #set text(font: en_sans, size: 10pt, lang: "en") // For English
```
## Development
You can develop using vscode devcontainer.
Because typst-lsp does not read `TYPST_FONT_PATHS`, I recommend to use `typst watch` command instead.
```console
$ typst watch <file>
```
## Automatic build pdf workflow
This repository uses GitHub Actions to automatically build PDFs when you push a commit tagged with `releases/*`.
> [!NOTE]
>
> To enable this feature, add read and write permissions for github actions.
>
> Go to
> `Settings > Actions > General > Workflow permission` and select `Read and write permissions`.
|
|
https://github.com/Enter-tainer/typstyle | https://raw.githubusercontent.com/Enter-tainer/typstyle/master/tests/assets/unit/math/attach.typ | typst | Apache License 2.0 | $ a_b^c $
$ a^c_b $
$ a^c_b'' $
$ a^c''_b $
$ a''^c_b $
$ a''^(c+d)_b $
$ a''^((c+d))_b $
$ a''^(c+d)_(e^f) $
|
https://github.com/tfachada/thesist | https://raw.githubusercontent.com/tfachada/thesist/main/README.md | markdown | MIT License | # ThesIST
ThesIST (pronounced "desist") is an unofficial Master's thesis template for Instituto Superior Técnico written in Typst.
This template fully meets the official formatting requirements as outlined [here](https://tecnico.ulisboa.pt/files/2021/09/guia-disserta-o-mestrado.pdf), and also attempts to follow most unwritten conventions. Regardless, you can be on the lookout for things you may want to see added.
PIC2 reports are also supported. However, some conventions for these may vary with the supervisors, so please check with them if anything needs to be changed.
## Changelogs
The changelogs of new versions are available on [the Releases page](https://github.com/tfachada/thesist/releases). Make sure to check the latest one(s) whenever you update the imported `thesist` version.
## Usage
If you are in the Typst web app, simply click on "Start from template" and pick this template.
If you want to develop locally:
1. Make sure you have the **TeX Gyre Heros** font family installed.
2. Install the package with `typst init @preview/thesist`.
## Overview
**Please read the "Quick guide" chapter included in this template to get set up. You can keep it as a reference if you want.**
This template's source files, hidden from the user view, are the following:
- `layout.typ`: The main configuration file, which initializes the thesis and contains its general formatting rules.
- `figure-numbering.typ`: This file contains a function to set a chapter-relative numbering for the various types of figures. The function is called once or twice depending on whether the user decides to include appendices.
- `utils.typ`: General functions that you may want to import and use for QoL improvements.
### A sidenote about subfigures
Since subfigures are not yet native to Typst, the current implementation, present in `utils.typ`, needs the user to manually input whether each called subfigure figure (aka subfigure grid) is in an appendix or not. This is because the numbering is different in appendices, and because the functionality of `figure-numbering.typ` can't be applied to subfigure grids, since they are imported with their default numbering once in every chapter. `context` expressions also don't work across imports, so location within the document couldn't be used as a parameter (unless the user called `context` themselves, which would be unintuitive). **Regardless, the workaround that was found, which is explained in the quick guide, doesn't need much thinking from the user, so you can see this as a more technical note that shouldn't matter when you're writing the thesis.**
## Final remarks
This template is not necessarily (or hopefully) a finished product. Feel free to open issues or pull requests!
Also thanks to the Typst community members for the help in some of the functionalities, and for the extensions used here.
|
https://github.com/dead-summer/math-notes | https://raw.githubusercontent.com/dead-summer/math-notes/main/notes/Analysis/ch1-measures/measure-theory.typ | typst | #import "/book.typ": book-page
#show: book-page.with(title: "Measure Theory")
= Motivation
Motivation: Lebesgue measure ($cal(L)^n$) on $bb(R)^n$ is approximately
n-dimensional volume:
1. #emph[Countable] Additivity If $E_1 , E_2 , dots.h , subset bb(R)^n$ is disjoint, then
$ cal(L)^n (union.sq.big E_i) = sum cal(L)^n (E_i). $
2. If$E subset bb(R)^n$ is (Euclidean) congruent to $E^(') subset bb(R)^n$ (that is, if $E$ can be transformed into $E^(')$ by translations, rotations, and reflections), then
$ cal(L)^n (E) = cal(L)^n (E^(')). $
3. Normalization: $cal(L)^n ([0 , 1]^n) = 1$ .
It's impossible for 1-3 to hold simultaneously if $cal(L)^n$ is defined
on the whole
$ cal(P) (bb(R)^n) = { E : E subset bb(R)^n } .$
We define $cal(L)^n$ (or more general measure) on a subset of $cal(P) (bb(R)^n)$ . |
|
https://github.com/sevehub/minimalbc | https://raw.githubusercontent.com/sevehub/minimalbc/main/template/main.typ | typst | MIT License | #import "lib.typ":minimalbc
#show: minimalbc.with(
// possible geo_size options: eu, us, jp , cn
geo_size: "eu",
flip:true,
company_name: "Company Name",
name: "<NAME>",
role: "Role",
telephone_number: "+000 00 000000",
email_address: "<EMAIL>",
website: "example.com",
company_logo: "company_logo.png",
bg_color: "ffffff",
)
|
https://github.com/edgarcarbajal/typst-resume | https://raw.githubusercontent.com/edgarcarbajal/typst-resume/main/main.typ | typst | MIT License | #show link: text.with(rgb("#00a3cd"))
#set text(font: ("PT Serif", "Noto Emoji"), size: 10pt)
#show heading.where(level: 1): it => {
it
v(-3mm)
line(length: 100%)
}
#show heading.where(level: 2): it => {
set text(size: .9em)
it.body
}
#set document(title: "Resume", author: "<NAME>")
#set page(
paper: "us-letter",
margin: (x: 0.8in, y: 0.8in),
footer: [
#set align(center)
#set text(size: 8pt, style: "italic")
Typst source code at
#link("https://github.com/edgarcarbajal/typst-resume")[github.com/edgarcarbajal/typst-resume]
under #link("https://opensource.org/license/MIT")[MIT] license.
]
)
#grid(
align: horizon,
columns: (1fr, auto),
text(36pt)[
*<NAME>*
],
block()[
💻: #link("https://github.com/edgarcarbajal")[github.com/edgarcarbajal]\
📧: #link("mailto:<EMAIL>")[<EMAIL>]\
🌐: #link("https://edgarcarbajal.com")[edgarcarbajal.com]
]
)
= Education:
#grid(
columns: (1fr, 1fr, 1fr),
rows: 2,
row-gutter: 15pt,
column-gutter: 15pt,
align: (left, center, right),
//gutter: 25pt,
//row 1
[== B.S. in Computer Science w/ Applied Math Minor], [*Northern Illinois University*\
GPA: 3.95], [*Aug 2022 - May 2024*\
_DeKalb, IL_],
// row 2
[== Associates in Science ], [*McHenry County College*\
GPA: 4.00], [*Aug 2020 - May 2022*\
_Crystal Lake, IL_]
)
= Skills:
#grid(
columns: (1fr, 2fr),
row-gutter: 15pt,
column-gutter: 15pt,
//row 1
[== Programming Languages:], [C++ | Python | Javascript, HTML & CSS | Java | SQL | Julia | Swift | Bash],
//row 2
[== Technologies/Libraries: ], [React.js | iOS | Express.js | Git/Github | Spring | Maven | CI/CD],
//row 3
[== Other: ], [MS Word | MS Excel | Unreal Engine 4 | Forklift Operator]
)
= Experience:
#grid(
columns: (1fr, 1fr),
align: (left, right),
//row 1
[== Software Engineer IT Intern\
_<NAME>_], [*May 2023 - Aug 2023*\
_Moline, IL_],
)
- Revamped an old, static feature in a highly-used web application by <NAME> equipment dealers to be more dynamic/user customizable.
- Worked with frontend using React and Typescript for the web application UI/user behavior, and backend with Java and Spring to create new API endpoints and connect to the application database.
= Notable Projects:
#grid(
columns: (1fr, 1fr),
align: (left, right),
//row 1
[== Plant Company Quote Web Application #link("https://github.com/edgarcarbajal/cs467proj")[🔗]\
_Intro to Software Engineering (CSCI467) Semester Project_], [*Jan 2024 - May 2024*\
_DeKalb, IL_]
)
- Semester group project where we built a web application that tracks quotes for a plant company; meeting requirements given to us by the professor.
- Used React + Node.js as the frontend application server, Express.js as the backend/API server, and MariaDB as the database.
- Learned a lot about the software development cycle, and how to convert user requirements into a fully-functioning software product.
#grid(
columns: (1fr, 1fr),
align: (left, right),
//row 1
[== Karaoke Web Application #link("https://github.com/edgarcarbajal/cs466proj")[🔗]\
_Databases (CSCI466) Semester Project_], [*Jan 2023 - May 2023*\
_DeKalb, IL_]
)
- Semester group project where we built a web application given requirements by the professor; to show what we had learned about databases.
- Used PHP to interface with the backend, and dynamically printout the HTML/CSS to be rendered to the frontend.
- Showed my knowledge about how to set up database schemas in a relational database, how to make sure how to use SQL to get, and update the right data.
|
https://github.com/pedrofp4444/BD | https://raw.githubusercontent.com/pedrofp4444/BD/main/report/content/[1] Definição do sistema/recursos.typ | typst | #let recursos = {
[
== Recursos e Equipa de Trabalho
Para esta fase inicial do projeto, a equipa “<NAME>” precisou de estudar o método de atuação da “Casa do Xerife”, para perceber o modelo de aplicação e aprofundar o conhecimento na área. Neste seguimento, organizou-se um plano de execução para tornar o objetivo possível, o qual depende tanto de recursos humanos como materiais.
A nível de recursos humanos, a empresa _Lusium_ é orientada por três representantes, uma equipa especializada de espionagem pertencente ao departamento “Brigada de Espionagem e Localização Operacional" e contém mais de cem funcionários que conhecem e lidam no quotidiano com o funcionamento da mesma. Para concretizar o significado dos dados recorreu-se a diversas reuniões com os representantes e a inquéritos gerais sobre a experiência individual dos funcionários, que incidem no problema do elevado fluxo criminal.
Quanto a recursos materiais, a equipa "Quatro em Linha" adotou uma abordagem prática, utilizando papel e caneta para inquéritos e atas de reuniões, posteriormente transcritos para formato digital. Essa escolha simples, mas eficaz, permite a obtenção de dados detalhados sobre a experiência dos funcionários e a gestão do elevado fluxo criminal.
A equipa de trabalho é composta pelos membros da "Quatro em Linha", cada um trazendo uma especialidade valiosa para o desenvolvimento do sistema de gestão de base de dados da Lusium. <NAME>, especialista em análise de requisitos, lidera a identificação precisa das necessidades do cliente. <NAME>, com vasta experiência em modelagem de sistemas, encarrega-se da criação de estruturas eficientes para a base de dados. <NAME>, especializado em implementação de sistemas, traduzirá as especificações em código funcional. Por fim, <NAME>, especialista em otimização de desempenho, garantirá que o sistema opere de maneira eficaz e otimizada. Juntos, esta equipa diversificada assegura uma abordagem abrangente e bem-sucedida para o projeto em questão.
Além disso, os três representantes responsáveis pela empresa Lusium, <NAME>, <NAME> e <NAME>, desempenham um papel crucial na implementação do sistema de gestão da base de dados. Para além das suas funções habituais, atuam como porta-vozes dos funcionários, sendo fundamentais para uma comunicação eficaz. A sua participação ativa em reuniões estratégicas e sessões de discussão permite que as preocupações e sugestões dos funcionários sejam adequadamente transmitidas e consideradas no processo de implementação do sistema. Essa abordagem colaborativa reforça a coesão e a eficácia do projeto, garantindo que as necessidades e perspetivas de todos os membros da empresa sejam levadas em conta.
No âmbito desta equipa dedicada, é imprescindível destacar a significativa contribuição dos detetives do Departamento “Brigada de Espionagem e Localização Operacional". Estes profissionais desempenham um papel vital na análise e resolução dos casos relacionados com o elevado fluxo criminal. A colaboração entre os detetives e os especialistas em tecnologia da "Quatro em Linha" fortalece a abordagem integral do projeto, assegurando uma implementação eficaz do sistema de gestão da base de dados da Lusium.
Por último, é imperativo destacar que a importância de todos os funcionários na implementação do sistema de gestão da base de dados não pode ser subestimada. Cada membro da equipa da _Lusium_ desempenha um papel vital na colheita de dados e na adaptação às mudanças. Reconhecendo a valiosa participação de cada indivíduo, o projeto ganha força através da diversidade de experiências e perspetivas, reforçando a união e promovendo um ambiente de trabalho mais colaborativo e eficiente.
]
}
|
|
https://github.com/Fr4nk1inCs/typreset | https://raw.githubusercontent.com/Fr4nk1inCs/typreset/master/tests/homework-1.typ | typst | MIT License | #import "../src/lib.typ": homework
#let simple_question = homework.simple_question
#let complex_question = homework.complex_question
#show: homework.style.with(
course: "Test Course",
number: 1,
names: "<NAME>",
ids: "Test ID 1",
lang: "en"
)
#show raw.where(block: true): block.with(
width: 100%,
stroke: 1pt,
radius: 5pt,
breakable: true,
inset: 5pt
)
#simple_question()[
A Simple Question Frame
]
_A_: This is a simple question frame.
Minimal Typst code to show the frame above:
```typ
#import "../src/lib.typ": homework
#let simple_question = homework.simple_question
#simple_question()[
A Simple Question Frame
]
_A_: This is a simple question frame.
```
#simple_question()[
Yet Another Simple Question Frame
]
_A_: The number of question is auto incremented.
Minimal Typst code to show the frame above:
#simple_question(number: "Custom Question Number.")[
A Question Frame with Custom Number
]
_A_: You can custom the question number using the `number` field. Note that the number is not incremented if `number` is not `auto`.
Minimal Typst code to show the frame above (with previous import and definition):
```typ
#simple_question(number: "Custom Question Number.")[
A Question Frame with Custom Number
]
_A_: You can custom the question number using the `number` field. Note that the number is not incremented if `number` is not `auto`.
```
#complex_question()[
Here is a complex question frame. You can write any description here. For example, here is a enum list:
+ First item
+ Second item
+ ...
]
_A_: A complex question frame is often used to describe a question with detailed description which you can easily write (or copy paste) using Typst syntax.
Minimal Typst code to show the frame above:
```typ
#import "../src/lib.typ": homework
#let complex_question = homework.complex_question
#complex_question()[
Here is a complex question frame. You can write any description here. For example, here is a enum list:
+ First item
+ Second item
+ ...
]
_A_: A complex question frame is often used to describe a question with detailed description which you can easily write (or copy paste) using Typst syntax.
``` |
https://github.com/binhtran432k/ungrammar-docs | https://raw.githubusercontent.com/binhtran432k/ungrammar-docs/main/glossaries.typ | typst | #let abbreviations = (
"api": ("API", "Application Programming Interface"),
"apis": ("APIs", "Application Programming Interfaces"),
"ast": ("AST", "Abstract Syntax Tree"),
"bdd": ("BDD", "Behavior-Driven Development"),
"cd": ("CD", "Continuous Delivery"),
"ci": ("CI", "Continuous Integration"),
"css": ("CSS", "Cascading Style Sheets"),
"cst": ("CST", "Concrete Syntax Tree"),
"dom": ("DOM", "Document Object Model"),
"dsl": ("DSL", "Domain-Specific Language"),
"http": ("HTTP", "HyperText Transfer Protocol"),
"html": ("HTML", "HyperText Markup Language"),
"id": ("ID", "Identifier"),
"ides": ("IDEs", "Integrated Development Environments"),
"jsx": ("JSX", "JavaScript XML"),
"lr": ("LR", "Left-to-right, Rightmost derivation"),
"lsp": ("LSP", "Language Server Protocol"),
"nast": ("NAST", "Non-Abstract Syntax Tree"),
"json": ("JSON", "JavaScript Object Notation"),
"rpc": ("RPC", "Remote Procedure Call"),
"seo": ("SEO", "Search Engine Optimization"),
"ssg": ("SSG", "Static Site Generation"),
"ssr": ("SSR", "Server-Side Rendering"),
"tdd": ("TDD", "Test-Driven Development"),
"uri": ("URI", "Uniform Resource Identifier"),
"uat": ("UAT", "User Acceptance Testing"),
"ui": ("UI", "User Interface"),
"vscode": ("VS Code", "Visual Studio Code"),
"xml": ("XML", "Extensible Markup Language"),
)
#let symbols = (:)
#let glossaries = (
"electron": (
"Electron",
"A framework that enables developers to create native desktop applications using web technologies like HTML, CSS, and JavaScript",
),
"git": ("Git", "A distributed version control system used for tracking changes in computer files."),
"json-rpc": ("JSON-RPC", "A remote procedure call (RPC) protocol encoded in JSON"),
"meta-lang": ("meta-language", "Language used to describe another language"),
"meta-pgm": (
"meta-programming",
"Programming technique where a program can manipulate or generate other programs as its data",
),
"utf8": ("UTF-8", "A variable-length character encoding standard used for electronic communication"),
)
#let GLOSSARIES = (
abbreviation: abbreviations,
symbol: symbols,
glossary: glossaries,
)
|
|
https://github.com/LeptusHe/LeptusHe.github.io | https://raw.githubusercontent.com/LeptusHe/LeptusHe.github.io/main/source/_posts/fourier-transform/fourier-transform-02-fourier-series.typ | typst | #import "../typst-inc/blog-inc.typc": *
#show: blog_setting.with(
title: "傅里叶变换02 - 傅里叶变换",
author: ("<NAME>"),
paper: "jis-b0",
preview: false
)
#metadata("傅里叶变换") <tags>
#metadata("数学") <categories>
#metadata("2024-09-21") <date>
#show: shorthands.with(
($<|$, math.angle.l),
($|>$, math.angle.r)
)
#set math.equation(numbering: "(1)")
= 傅里叶变换
周期为$T$的函数$f(x)$可以用傅里叶级数来表示,但是无法表示#im[非周期函数]。非周期函数可以看做周期$T -> infinity$的周期函数。
当$T -> infinity$时,则
$
omega = (2 pi) / T -> 0
$
代入傅里叶级数中,得到:
$
f(x) &= sum_(n = -infinity) ^(infinity) d_n dot.c e^(i n omega x) \
&= sum_(n = -infinity)^infinity (1 / T dot.c Integral(-T/2, T/2, f(x) dot.c e^(-i n omega x))) dot.c e^(i n omega x) \
&= sum_(n = -infinity)^infinity (1 / (2 pi) dot.c omega dot.c Integral(-T/2, T/2, f(x) dot.c e^(-i n omega x))) dot.c e^(i n omega x) \
$ <eq-riemann-sum-omega>
基于定积分的概念,@eq-riemann-sum-omega 可以看做对连续变量$omega'$的黎曼和形式。对于连续变量$omega'$,将定义区间分为$m$份小区间,每个区间的长度为$Delta omega$,为微小增量。对于第$n$个区间,选取的变量为$epsilon = n Delta omega$,则@eq-riemann-sum-omega 可以变换为:
$
f(x) &= sum_(n = -infinity) ^(infinity) d_n dot.c e^(i n omega x) \
&= sum_(n = -infinity)^infinity (1 / (2 pi) dot.c Delta omega dot.c Integral(-T/2, T/2, f(x) dot.c e^(-i epsilon x))) dot.c e^(i epsilon x) \
&= sum_(n = -infinity)^infinity ( (1 / (2 pi) dot.c Integral(-T/2, T/2, f(x) dot.c e^(-i epsilon x))) dot.c e^(i epsilon x)) dot.c Delta omega \
&= Integral(-infinity, infinity, 1 / (2 pi) Integral(-infinity, infinity, f(x) dot.c e^(-i omega x)) dot.c e^(i omega x) , dif: omega) \
&= 1 / (2 pi) dot.c Integral(-infinity, infinity, Integral(-infinity, infinity, f(x) dot.c e^(-i omega x)) dot.c e^(i omega x) , dif: omega)
$
令$F(omega)$为:
$
F(omega) = Integral(-infinity, infinity, f(x) dot.c e^(-i omega x))
$
则傅里叶变换公式可以表示为:
$
f(x) = Integral(-infinity, infinity, F(omega) dot.c e^(i omega x), dif: omega)
$
其中$F(omega)$为频率为$omega$时的线性组合系数。
= 离散傅里叶变换
傅里叶变换与傅里叶级数都是对连续信号进行分析处理的工具,而无法对离散的时间信号或者有限长信号进行分析。为了解决傅里叶变换的局限性,
#im[离散傅里叶变换]被提出来对离散时间信号进行频谱分析,例如二维图像、离散采样的信号等。
== 周期离散信号的表示
对于离散信号$x[n]$,如果满足:
$
x[n] = x[n + N]
$
则该信号为一个周期为$N$的信号。其最小正周期为$N$,频率$omega_o = 2 pi \/ N$。
复指数函数$phi.alt[n] = e^(i omega_o n)$也是周期函数,其中$n$为函数自变量。该函数的周期为$N$。并且,@complex-exp-function-set 中的复指数函数都是周期函数,
$
phi.alt_k [n] = e^(i k omega_o n) = e^(i k (2 pi) / N dot.c n), quad k = plus.minus 0, plus.minus 1, plus.minus 2, dots.c
$ <complex-exp-function-set>
fuzhishu
其频率都是$omega_o$的倍数。
事实上,@complex-exp-function-set 中只有$N$个函数是不同。因为函数$phi.alt[n]$为周期函数,其周期为$N$,因此:
$
phi.alt_(k + m N) [n] = phi.alt_k [n]
$
#proof[
$
phi.alt_(k + m N) [n] &= e^(i (k + m N) dot.c (2 pi) / N dot.c n) \
&= e^(i (k (2 pi) / N + m dot.c 2 pi) dot.c n) \
&= e^(i k (2 pi) / N dot.c n) dot.c e^(i m 2 pi dot.c n) \
&= e^(i k (2 pi) / N dot.c n) dot.c (cos(m 2 pi n) + i sin (m 2 pi n)) \
&= e^(i k (2 pi) / N dot.c n) dot.c 1 \
&= phi.alt_k [n]
$
]
另外,设函数集合$Phi$定义如下:
$
Phi = { e^(i k omega_o n) | k = 0, 1, 2, dots.c, N - 1 }
$
定义在函数集$Phi$上的内积为:
$
<| f[n], g[n] |> = sum_(k=0)^(N-1) f[n] dot.c overline(g[n])
$
则可以证明:函数集$Phi$是正交函数集。
#proof[
$
<| phi.alt_k [n], phi.alt_m [n] |> &= sum_(i=0)^(N-1) e^(i k (2 pi) / N n) dot.c e^(-i m (2 pi) / N n) \
&=sum_(i = 0)^(N - 1) e^(i (k - m) (2 pi) / N n)
$
当$k = m$时,有:
$
<| phi.alt_k [n], phi.alt_m [n] |> &=sum_(i = 0)^(N - 1) e^(i (k - m) (2 pi) / N n) \
&= sum_(i=0)^(N-1) e^(i 2 pi 0) \
&= sum_(i=0)^(N-1) 1 \
&= N
$
当$k != m$时,设$alpha = e^(i (k - m) (2 pi) / N)$,则有:
$
alpha != 1
$
根据几何级数公式,有:
$
sum_(i=0)^N alpha^n = (1 - a^N) / (1 - a)
$
由于
$
a^N = (e^(i 2 pi (k - m) / N))^N = e^(i 2 pi (k - m)) = cos((k - m) 2 pi) - i sin((k - m) 2 pi) = 1
$
因此可得:
$
sum_(i = 0)^N alpha^n = (1 - alpha^N) / (1 - alpha) = 0
$
综上所述:
$
<| phi.alt_k [n], phi.alt_m [n] |> = cases(
N &\, quad "if " k = m,
0 &\, quad "if " k != m
)
$
因此,函数集$Phi$是正交函数集。
]
因此,任意的周期为$N$的离散信号$x[n]$都可以使用正交函数集$Phi$的线性组合来表示,即:
$
x[n] = sum_(k=0)^(N-1) a_k dot.c phi.alt_k [n]
$
其中,系数$a_n$可以用正交函数的性质表示为:
$
a_k &= 1 / N dot.c <|x[n], phi.alt_k [n] |> \
&= 1 / N dot.c sum_(n = 0)^(N-1) (x[n] dot.c e^(i k omega_o n))
$
= 快速傅里叶变换
离散傅里叶变换需要求$N$个线性组合系数$a_k$,而每个系数$a_k$都需要$N$次复数乘法。因此,计算所有$N$个组合系数的算法复杂度为$O(n^2)$。
为了解决计算离散傅里叶系数的算法复杂度过高的问题,快速傅里叶变换被提出了。快速傅里叶变换利用分治的思想,将大规模的DFT(discret fourier transform)问题转换为若干个小规模的DFT问题进行递归求解,其算法复杂度为$O(n log n)$。
== $N$次单位根及其性质
对于复平面上的单位圆,将其$N$等分,得到$N$个等分点的集合,该集合称为#im[$N$次单位根]。其中每个点的相位角相差$(2 pi) / N$弧度。该集合中的根可以表示为:
$
W_N^k = e^(i (2 pi) / N dot.c k), quad k = 0, 1, dots.c, N- 1
$
#definition([$N$次单位根的性质])[
对于$N$次单位根,其满足以下性质:
- 周期性:
$
W_N^(k) = W_N^(k + m dot.c N)
$
- 对称性:
$
W_N^(k + N / 2) = - W_N^(k)
$
- 若$m$是$N$的约数,则:
$
W_N^(m k) = W_(N/m)^k
$
]
== 快速傅里叶算法
对于周期为$N$的函数$x[n]$,其线性组合系数为$a_0, a_1, dots.c, a_(N-1)$。
离散傅里叶变换的线性组合系数$a_k$的计算公式如下:
$ a_k &= 1 / N dot.c sum_(n = 0)^(N-1) (x[n] dot.c e^(i k omega_o n)) $
其中:
$
omega_o = (2 pi) / N
$
对该公式中的形式进行简化,令
$
alpha = e^(i k omega_o) = W_N^k,
$
且令函数$f(alpha)$为:
$
f(alpha) &= sum_(n = 0)^(N-1) (x[n] dot.c e^(i k omega_o n)) \
&= sum_(n = 0)^(N-1) (x[n] dot.c alpha^n)
$
=== 分治法
将函数$f(a)$分解为:
$
f(alpha) &= x[0] dot.c alpha^0 + x[1] dot.c alpha^1 + dots.c + x[N-1] dot.c alpha^(N-1) \
&= (x[0] dot.c alpha^0 + x[2] dot.c alpha^2 + dots.c + x[N-2] dot.c alpha^(N-2)) \
& quad + (x[1] dot.c alpha^1 + x[3] dot.c alpha^3 + dots.c + x[N-1] dot.c alpha^(N-1)) \
&= (x[0] dot.c alpha^0 + x[2] dot.c alpha^2 + dots.c + x[N-2] dot.c alpha^(N-2)) \
& quad + alpha dot.c (x[1] dot.c alpha^0 + x[3] dot.c alpha^2 + dots.c + x[N-1] dot.c alpha^(N-2))
$
令
$
f_1(alpha) &= (x[0] dot.c alpha^0 + x[2] dot.c alpha^1 + dots.c + x[N-2] dot.c alpha^(N/2-1)) \
f_2(alpha) &= (x[1] dot.c alpha^1 + x[3] dot.c alpha^1 + dots.c + x[N-1] dot.c alpha^(N/2-1))
$
则
$
f(alpha) = f_1(alpha^2) + alpha dot.c f_2(alpha^2)
$
根据$N$次方根的性质3,即:
$
W_N^(m k) &= W_(N/m)^k
$
可以得到:
$
f(alpha) &= f(W_N^k) = f_1(W_N^(2 k)) + alpha dot.c f_2(W_N^(2 k)) \
&= f_1(W_(N/2)^(k)) + alpha dot.c f_2(W_(N/2)^(k)) \
$
函数$f_1(W_(N/2)^k)$展开为:
$
f_1(W_(N/2)^k) = x[0] dot.c W_(N/2)^(k dot.c 0) + x[2] dot.c W_(N/2)^(k dot.c 1) + x[4] dot.c W_(N/2)^(k dot.c 2) + dots.c + x[2 floor(N / 2)] dot.c W_(N/2)^(k dot.c n)
$
对于周期为$N$的信号$x[n]$,将其下标$n$为偶数与奇数的信号元素进行分组,可以得到两个子信号,分别为$x[2 n]$以及x[2 n + 1],其中$n$满足:
$
n in Z, " 且 " n <= floor(N /2)
$
因此,$f_1(W_(N/2)^k)$可以看做是对周期为$N/2$的信号$x[2 n]$求取系数$a_k$过程。同理,$f_2(W_(N/2)^k)$可以看为对周期为$N/2$的信号$x[2 n + 1]$求取系数$a_k$的过程。
从上面可以看出,对于周期为$T$的信号$x[n]$,求取其离散傅里叶变换系数${a_k| k = 0, 1, dots.c, N-1}$的过程,可以划分为两个子问题:
- 求子信号$x[2 n]$的离散傅里叶变换系数
- 求子信号$x[2 n + 1]$的离散傅里叶变换系数
该流程一直会递归,则到子信号的周期为$1$,此时可以直接求解。
=== 周期性
当对周期为$T$的信号$x[n]$求离散傅里叶变换的系数时,根据$N$次单位根的对称性,可以发现以下结论:
令$m = k + N/2$,其中$0 <= k < N / 2$。根据$N$次单位根的周期性有:
$
f(W_N^(k + N / 2)) &= f_1(W_N^(2k + N)) + W_N^(k+N/2) dot.c f_2(W_N^(2k+N)) \
&= f_1(W_N^(2k) dot.c W_N^N) + W_N^(k+N/2) dot.c f_2(W_N^(2k) dot.c W_N^N) \
&= f_1(W_N^(2k) dot.c 1) + W_N^(k+N/2) dot.c f_2(W_N^(2k) dot.c 1) \
&= f_1(W_N^(2k)) - W_N^(k) dot.c f_2(W_N^(2k)) \
&= f_1(W_(N/2)^(k)) - W_N^(k) dot.c f_2(W_(N/2)^(k)) \
&= f_1(W_(N/2)^(k)) - alpha dot.c f_2(W_(N/2)^(k)) \
$
因此,当$m > N / 2$时,根据对称性,可以通过子信号$x[2n]$与$x[2 n + 1]$的离散傅里叶变换系数,可以简单的得到离散傅里叶变换中$a_m$的系数值。 |
|
https://github.com/Slyde-R/not-jku-thesis-template | https://raw.githubusercontent.com/Slyde-R/not-jku-thesis-template/main/disclaimer.typ | typst | MIT No Attribution | #let disclaimer(
date: "",
place-of-submission: "Place",
thesis-type: "",
author: "",
submissionDate: none,
) = {
// --- Disclaimer ---
text("SWORN DECLARATION", weight: 600, size: 1.4em)
v(1.5em)
[
I hereby declare under oath that the submitted #thesis-type's Thesis has been written solely by me without any third-party assistance, information other than provided sources or aids have not been used and those used have been fully documented. Sources for literal, paraphrased and cited quotes have been accurately credited.
The submitted document here present is identical to the electronically submitted text document.
#v(25mm)
// Option 1
#grid(
columns: 2,
gutter: 1fr,
overline[#sym.wj #sym.space #sym.space #sym.space #sym.space (Place, Date) #sym.space #sym.space #sym.space #sym.space #sym.wj],
overline[#sym.wj #sym.space #sym.space #sym.space #sym.space #sym.space (#author) #sym.space #sym.space #sym.space #sym.space #sym.space #sym.wj]
)
// Option 2
// #place-of-submission, #date.display()
// #align(center)[
// #overline[#sym.wj #sym.space #sym.space #sym.space #sym.space #sym.space (#author) #sym.space #sym.space #sym.space #sym.space #sym.space #sym.wj]
// ]
// Option 3
// #align(center)[
// #overline[#sym.wj #sym.space #sym.space #sym.space #sym.space #sym.space #place-of-submission, #date.display()\; (#author) #sym.space #sym.space #sym.space #sym.space #sym.space #sym.wj]
// ]
#v(15%)
]
pagebreak()
}
|
https://github.com/m4cey/mace-typst | https://raw.githubusercontent.com/m4cey/mace-typst/main/aliases.typ | typst | #let space_around(vertical: false, outer: 3fr, inner: 1fr, sep:"", ..args) = {
let space(vertical, size) = if vertical {v(size)} else {h(size)}
[
#space(vertical, outer)
#for (i, arg) in args.pos().enumerate() {
if i > 0 and i < args.pos().len() { space(vertical, inner) }
arg + sep
}
#space(vertical, outer)
]
}
// TESTS
#[
#show heading.where(level: 1): it => [
#let str = it.body.fields().children.fold("#", (a, i) => a + i.text )
#raw(lang: "typ", str + ":" )]
= space_around(outer:3fr,inner:1fr,sep:\",\",args)
#space_around(
outer: 2fr,
inner: 1fr,
sep: ",",
$not(P and Q)$,
$not P and not Q$,
$not P or not Q$,
)
]
|
|
https://github.com/tomowang/typst-twentysecondcv | https://raw.githubusercontent.com/tomowang/typst-twentysecondcv/main/example.typ | typst | MIT License | #import "twentysecondcv.typ": *
#set text(font: "PT Sans")
#main(
[
#profile(
name: "<NAME>",
jobtitle: lorem(3),
)
#show_contacts(
(
(
icon: "linkedin",
text: "https://www.linkedin.com/in/someone",
),
(
icon: "github",
text: "https://github.com/tomowang",
),
(
icon: "globe",
solid: true,
text: "https://tomo.dev",
),
(
icon: "phone",
solid: true,
text: link("tel:+86 123 456 78999")[+86 123 456 78999],
),
(
icon: "envelope",
solid: true,
text: "<EMAIL>",
),
)
)
#profile_section("Skills")
#align(center, image("images/skills.png", width: 80%))
#profile_section("Interests")
#show_interests((
(
interest: lorem(2),
score: 1,
),
(
interest: lorem(2),
score: 0.8,
),
(
interest: lorem(2),
score: 0.75,
),
(
interest: lorem(2),
score: 0.5,
),
))
#profile_section("Languages")
#image("images/languages.png")
],
[
#body_section("Education")
#twentyitem(
period: [
Sep. 2007 - \
Jun. 2011
],
title: lorem(4),
note: link("http://www.nju.edu.cn/")[Nanjing University],
addtional_note: lorem(3),
body: lorem(30)
)
#body_section("Experience")
#twentyitem(
period: [
Oct. 2017 - \
Now
],
title: lorem(4),
note: lorem(1),
body: list(
lorem(20),
lorem(20),
lorem(20),
)
)
#twentyitem(
period: [
Mar. 2016 - \
Oct. 2017
],
title: lorem(4),
note: lorem(1),
body: list(
lorem(20),
lorem(20),
lorem(20),
)
)
#twentyitem(
period: [
Jul. 2011 - \
Mar. 2016
],
title: lorem(4),
note: lorem(1),
body: list(
lorem(20),
lorem(20),
)
)
#body_section("Certificate")
#twentyitem(
period: [2017-02-22],
title: "Machine Learning",
note: link("https://www.coursera.org/")[Coursera],
body: ""
)
#twentyitem(
period: [2018-07-10],
title: "Professional Data Engineer",
note: link("https://www.credential.net/")[Google Cloud],
body: ""
)
#twentyitem(
period: [2019-12-31],
title: "AWS Certified Big Data - Specialty",
note: link("https://aws.amazon.com/verification")[AWS],
body: ""
)
]
)
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/cetz/0.3.0/src/draw/projection.typ | typst | Apache License 2.0 | #import "grouping.typ": group, get-ctx, set-ctx, scope
#import "transformations.typ": set-transform
#import "/src/process.typ"
#import "/src/matrix.typ"
#import "/src/drawable.typ"
#import "/src/util.typ"
#import "/src/polygon.typ"
// Get an orthographic view matrix for 3 angles
#let ortho-matrix(x, y, z) = matrix.mul-mat(
matrix.ident(),
matrix.transform-rotate-x(x),
matrix.transform-rotate-y(y),
matrix.transform-rotate-z(z),
)
#let ortho-projection-matrix = (
(1, 0, 0, 0),
(0, 1, 0, 0),
(0, 0, 0, 0),
(0, 0, 0, 1),
)
#let _sort-by-distance(drawables) = {
return drawables.sorted(key: d => {
let z = none
for ((kind, ..pts)) in d.segments {
pts = pts.map(p => p.at(2))
z = if z == none {
calc.max(..pts)
} else {
calc.max(z, ..pts)
}
}
return z
})
}
// Filter out all clock-wise polygons, or if `invert` is true,
// all counter clock-wise ones.
#let _filter-cw-faces(drawables, mode: "cw") = {
return drawables.filter(d => {
let poly = polygon.from-segments(d.segments)
poly.first() != poly.last() or polygon.winding-order(poly) == mode
})
}
// Sets up a view matrix to transform all `body` elements. The current context
// transform is not modified.
//
// - body (element): Elements
// - view-matrix (matrix): View matrix
// - projection-matrix (matrix): Projection matrix
// - reset-transform (bool): Ignore the current transformation matrix
// - sorted (bool): Sort drawables by maximum distance (front to back)
// - cull-face (none,str): Enable back-face culling if set to `"cw"` for clockwise
// or `"ccw"` for counter-clockwise. Polygons of the specified order will not get drawn.
#let _projection(body, view-matrix, projection-matrix, reset-transform: true, sorted: true, cull-face: "cw") = {
(ctx => {
let transform = ctx.transform
ctx.transform = view-matrix
let (ctx, drawables, bounds) = process.many(ctx, util.resolve-body(ctx, body))
if cull-face != none {
assert(cull-face in ("cw", "ccw"),
message: "cull-face must be none, cw or ccw.")
drawables = _filter-cw-faces(drawables, mode: cull-face)
}
if sorted {
drawables = _sort-by-distance(drawables)
}
if projection-matrix != none {
drawables = drawable.apply-transform(projection-matrix, drawables)
}
ctx.transform = transform
if not reset-transform {
drawables = drawable.apply-transform(ctx.transform, drawables)
}
return (
ctx: ctx,
bounds: bounds,
drawables: drawables,
)
},)
}
// Apply function `fn` to all vertices of all
// elements in `body`.
//
// - body (element): Elements
// - ..mat (matrix): Transformation matrices
#let scoped-transform(body, ..mat) = {
scope({
set-ctx(ctx => {
ctx.transform = matrix.mul-mat(ctx.transform, ..mat.pos().filter(m => m != none))
return ctx
})
body
})
}
/// Set-up an orthographic projection environment.
///
/// This is a transformation matrix that rotates elements around the x, the y and the z axis by the parameters given.
///
/// By default an isometric projection (x ≈ 35.264°, y = 45°) is set.
///
/// ```typc example
/// ortho({
/// on-xz({
/// rect((-1,-1), (1,1))
/// })
/// })
/// ```
///
/// - x (angle): X-axis rotation angle
/// - y (angle): Y-axis rotation angle
/// - z (angle): Z-axis rotation angle
/// - sorted (bool): Sort drawables by maximum distance (front to back)
/// - cull-face (none,str): Enable back-face culling if set to `"cw"` for clockwise
/// or `"ccw"` for counter-clockwise. Polygons of the specified order will not get drawn.
/// - reset-transform (bool): Ignore the current transformation matrix
/// - body (element): Elements to draw
#let ortho(x: 35.264deg, y: 45deg, z: 0deg, sorted: true, cull-face: none, reset-transform: false, body, name: none) = group(name: name, ctx => {
_projection(body, ortho-matrix(x, y, z), ortho-projection-matrix,
sorted: sorted,
cull-face: cull-face,
reset-transform: reset-transform)
})
/// Draw elements on the xy-plane with optional z offset.
///
/// All vertices of all elements will be changed in the following way: $\begin{pmatrix} x \\ y \\ z_\text{argument}\end{pmatrix}$, where $z_\text{argument}$ is the z-value given as argument.
///
/// ```typc example
/// on-xy({
/// rect((-1, -1), (1, 1))
/// })
/// ```
///
/// - z (number): Z offset for all coordinates
/// - body (element): Elements to draw
#let on-xy(z: 0, body) = get-ctx(ctx => {
let z = util.resolve-number(ctx, z)
scoped-transform(body, if z != 0 {
matrix.transform-translate(0, 0, z)
}, matrix.ident())
})
/// Draw elements on the xz-plane with optional y offset.
///
/// All vertices of all elements will be changed in the following way: $\begin{pmatrix} x \\ y_\text{argument} \\ y \end{pmatrix}$, where $y_\text{argument}$ is the y-value given as argument.
///
/// ```typc example
/// on-xz({
/// rect((-1, -1), (1, 1))
/// })
/// ```
///
/// - y (number): Y offset for all coordinates
/// - body (element): Elements to draw
#let on-xz(y: 0, body) = get-ctx(ctx => {
let y = util.resolve-number(ctx, y)
scoped-transform(body, if y != 0 {
matrix.transform-translate(0, y, 0)
}, matrix.transform-rotate-x(90deg))
})
/// Draw elements on the yz-plane with optional x offset.
///
/// All vertices of all elements will be changed in the following way: $\begin{pmatrix} x_\text{argument} \\ x \\ y \end{pmatrix}$, where $x_\text{argument}$ is the x-value given as argument.
///
/// ```typc example
/// on-yz({
/// rect((-1, -1), (1, 1))
/// })
/// ```
///
/// - x (number): X offset for all coordinates
/// - body (element): Elements to draw
#let on-yz(x: 0, body) = get-ctx(ctx => {
let x = util.resolve-number(ctx, x)
scoped-transform(body, if x != 0 {
matrix.transform-translate(x, 0, 0)
}, matrix.transform-rotate-y(90deg))
})
|
https://github.com/MrToWy/Bachelorarbeit | https://raw.githubusercontent.com/MrToWy/Bachelorarbeit/master/abbreviations.typ | typst | #import "@preview/gloss-awe:0.0.5": *
#let his = "HIS Hochschul-Informations-System eG"
#let hone = "HISinOne"
#let hsh = "<NAME>"
#let heine = "Prof. Dr. <NAME>"
#let studybase = "StudyBase"
#let studyPlan = "StudyPlan"
#let controller = "Controller"
#let service = "Service"
#let nest = "NestJS"
#let sophisten = "SOPHISTen" |
|
https://github.com/justmejulian/typst-documentation-template | https://raw.githubusercontent.com/justmejulian/typst-documentation-template/main/sections/relatedwork.typ | typst | = Related Work
#rect(
width: 100%,
radius: 10%,
stroke: 0.5pt,
fill: yellow,
)[
Note: Describe related work regarding your topic and emphasize your (scientific) contribution in contrast to existing approaches / concepts / workflows. Related work is usually current research by others and you defend yourself against the statement: “Why is your thesis relevant? The problem was al- ready solved by XYZ.” If you have multiple related works, use subsections to separate them.
]
|
|
https://github.com/skyzh/chicv | https://raw.githubusercontent.com/skyzh/chicv/master/template/cv.typ | typst | Creative Commons Zero v1.0 Universal | #show heading: set text(font: "Linux Biolinum")
#show link: underline
// Uncomment the following lines to adjust the size of text
// The recommend resume text size is from `10pt` to `12pt`
// #set text(
// size: 12pt,
// )
// Feel free to change the margin below to best fit your own CV
#set page(
margin: (x: 0.9cm, y: 1.3cm),
)
// For more customizable options, please refer to official reference: https://typst.app/docs/reference/
#set par(justify: true)
#let chiline() = {v(-3pt); line(length: 100%); v(-5pt)}
= <NAME>
<EMAIL> |
#link("https://github.com/skyzh")[github.com/skyzh] | #link("https://skyzh.dev")[skyzh.dev]
== Education
#chiline()
#link("https://typst.app/")[*#lorem(2)*] #h(1fr) 2333/23 -- 2333/23 \
#lorem(5) #h(1fr) #lorem(2) \
- #lorem(10)
*#lorem(2)* #h(1fr) 2333/23 -- 2333/23 \
#lorem(5) #h(1fr) #lorem(2) \
- #lorem(10)
== Work Experience
#chiline()
*#lorem(2)* #h(1fr) 2333/23 -- 2333/23 \
#lorem(5) #h(1fr) #lorem(2) \
- #lorem(20)
- #lorem(30)
- #lorem(40)
*#lorem(2)* #h(1fr) 2333/23 -- 2333/23 \
#lorem(5) #h(1fr) #lorem(2) \
- #lorem(20)
- #lorem(30)
- #lorem(40)
== Projects
#chiline()
*#lorem(2)* #h(1fr) 2333/23 -- 2333/23 \
#lorem(5) #h(1fr) #lorem(2) \
- #lorem(20)
- #lorem(30)
- #lorem(40)
*#lorem(2)* #h(1fr) 2333/23 -- 2333/23 \
#lorem(5) #h(1fr) #lorem(2) \
- #lorem(20)
- #lorem(30)
- #lorem(40)
|
https://github.com/QuadnucYard/cpp-coursework-template | https://raw.githubusercontent.com/QuadnucYard/cpp-coursework-template/main/font.typ | typst | #let __font-serif = "Linux Libertine"
#let fonts = (
primary: (__font-serif, "SimSun"),
strong: (__font-serif, "SimHei"),
emph: (__font-serif, "STKaiti"),
mono: ("DejaVu Sans Mono", "SimHei"),
)
|
|
https://github.com/7sDream/fonts-and-layout-zhCN | https://raw.githubusercontent.com/7sDream/fonts-and-layout-zhCN/master/chapters/11-web/web.typ | typst | Other | #import "/template/template.typ": web-page-template
#import "/template/heading.typ": chapter
#import "/lib/glossary.typ": tr
#show: web-page-template
#chapter[
// Fonts on the Web
网页上的字体
]
|
https://github.com/N3M0-dev/typst-note-template | https://raw.githubusercontent.com/N3M0-dev/typst-note-template/main/note.typ | typst | MIT License | #let basic-styling(body) = {
set page(numbering: "1", number-align: center)
set heading(numbering: "1.1")
set par(justify: true)
set text(12pt, font: ("Times New Roman", "Noto Serif CJK SC"))
set outline(indent: true)
body
}
#let 字号 = (
初号: 42pt,
小初: 36pt,
一号: 26pt,
小一: 24pt,
二号: 22pt,
小二: 18pt,
三号: 16pt,
小三: 15pt,
四号: 14pt,
中四: 13pt,
小四: 12pt,
五号: 10.5pt,
小五: 9pt,
六号: 7.5pt,
小六: 6.5pt,
七号: 5.5pt,
小七: 5pt,
)
#let template_into=[
= Brief Introduction
This tempalate is designed to be used in daily notes for courses, meetings, lectures and etc, which now provides the following conveniences:
+ Basic Title, authors, date row
+ Definition, theorem term_box and note component for note taking
+ Fixed numbering for definition, theorem, term_box in the article and outline
= Syntax
== Definition
The definition function ```typc #def(body)``` accept 2 types of parameter:
+ A *Content* _body_
+ An *Array* _body_
For *Content*: The body must be formed like [concept:content]\
For *Array*: The body must be formed like ([concept_1:content_1], [concept_2:content_2])
== Theorem
Same as the ```typc #def()``` function, the```typc #theorem(body)``` function also accepts the same 2 types of parameter:
+ A *Content* _body_
+ An *Array* _body_
For *Content*: The body must be formed like [theorem:content]\
For *Array*: The body must be formed like ([theorem_1:content_1], [theorem_2:content_2])
== Term_box
The term_box is designed to be a complement for the definition and theorem component. The function ```typc #term_box(term, body)``` accepts 2 parameters:
+ Term: The name for the term, a string, _e.g. "Lemma"_.
+ Body: The main content of the term, which also can be in two types content and array the format is the same [term:content] or ([term_1:content_1],[term_2:content_2])
== Note
The note block is a simple but kind of fancy block in this minimalism template. The function ```typc #note(name: [], body)```, accepts 2 parameters: name and body. The name parameter in default an empety content, and the body is the content of the note, which can be whatever you want.
]
#let frontmatter(authors: ("Authors Here As Array",),
title: "Title Here As String",
subtitle: "Subtitle Here As String",
date: "Date Here As String") = {
//Title and date
align(center, {
block(text(weight: 700, 1.75em, title))
v(1em, weak: true)
subtitle
linebreak()
date}
)
//Authors information
align(center, { box(width: 85%, {
context {
let max_width = 0pt
for author in authors {
if measure(author).width > max_width {
max_width = measure(author).width
}
}
for author in authors {
box(width: max_width+1em, {author})
}
}
})})
}
#let split_body(con)={
if con.has("children"){
if con.children.len()==0 { return (con,) }
let search_colon(item)={
if item.has("text"){
if item.text==":" or item.text==":" {
return true
}
else{
return false
}}
else{
return false
}
}
let pos=con.children.position(item=>search_colon(item))
let name=[];let content=[]
if pos!=none {
name=[#con.children.slice(0,pos).join()];content=[#con.children.slice(pos+1).join()]}
return (name,content)
}
else { return (con,) }
}
#let note(name: [],body) = {
align(center)[
#block(fill: luma(230),inset: 8pt,radius: 4pt, width: 95%)[
#align(start)[
*Note*: #name
#body
]]]
}
#let term_box(term,
term_counter: "",
body) = {
if body == [] {
body = [
#text(fill: gray, style: "italic")[Term here ...]:
#text(fill: gray, style: "italic")[Term content here ...]
]
}
if term_counter == "" {
term_counter = term
}
if type(body) == "array" {
locate( loc => {
let levelin=counter(heading).at(loc).len()
let num=(query(selector(label(term_counter)).before(loc),loc).len()+1)
let i=0
align(center)[ #rect(width: 95%)[ #align(start+horizon)[ #pad(top: 5pt,bottom: 5pt)[
#for def in body {
[
#heading(level: levelin+1, numbering: none)[
#text(style: "italic")[#term]
#num+i:
#split_body(def).at(0)]
#label(term_counter)
]
split_body(def).at(1)
i=i+1
}
]]]]
})
}
if type(body) == "content" {
locate( loc => {
let levelin = counter(heading).at(loc).len()
align(center)[ #rect(width: 95%)[ #align(start+horizon)[ #pad(top: 5pt,bottom: 5pt)[
#heading(level: levelin+1, numbering: none)[
#text(style: "italic")[#term]
#(query(selector(label(term_counter)).before(loc),loc).len()+1):
#split_body(body).at(0)
]
#label(term_counter)
#split_body(body).at(1)
]]]]
})
}
}
#let def(body) = {
term_box("Definition", term_counter: "def", body)
}
#let theorem(body) = {
term_box("Theorem", term_counter: "th", body)
} |
https://github.com/DrGo/typst-tips | https://raw.githubusercontent.com/DrGo/typst-tips/main/refs/samples/typst-uwthesis-master/uw-ethesis.typ | typst | #import "format.typ": project, appendix, gls
#import "glossaries.typ": GLOSSARIES
#show: project.with(
title: "University of Waterloo E-Thesis Template for typst",
doc_type: "theis",
author: "<NAME>",
affiliation: "the University of Waterloo",
major: "Philosophy of Zoology",
address: "Waterloo, Ontario, Canada",
year: "2023",
committee_members: (
(
position: "External Examiner",
persons: (
(
name: "<NAME>",
title: "Professor",
department: "Dept. of Philosophy of Zoology",
affiliation: "University of Wallamaloo"
),
)
),
(
position: "Supervisor(s)",
persons: (
(
name: "<NAME>",
title: "Professor",
department: "Dept. of Zoology",
affiliation: "University of Waterloo"
),
(
name: "<NAME>",
title: "Professor Emeritus",
department: "Dept. of Zoology",
affiliation: "University of Waterloo"
),
)
),
(
position: "Intertnal Member",
persons: (
(
name: "<NAME>",
title: "Professor",
department: "Dept. of Zoology",
affiliation: "University of Wallamaloo"
),
)
),
(
position: "Intertnal-External Member",
persons: (
(
name: "Meta Meta",
title: "Professor",
department: "Dept. of Philosophy",
affiliation: "University of Wallamaloo"
),
)
),
(
position: "Other member(s)",
persons: (
(
name: "<NAME>",
title: "Professor",
department: "Dept. of Fine Art",
affiliation: "University of Wallamaloo"
),
)
),
),
abstract: lorem(59),
declaration: "",
acknowledgements: "Hopefully, I will be able to thank everyone who made this possible.",
dedication: "This is dedicated to the one I love. You may remove this section by setting this to empty",
glossaries: GLOSSARIES
)
// #committee
//
= Introduction
#label("introduction")
In the beginning, there was $pi$:
$ e^(pi i) plus 1 eq 0 $ <eqn_pi> A #gls("computer") could compute $pi$ all day long. In
fact, subsets of digits of $pi$’s decimal approximation would make a
good source for psuedo-random vectors, #gls("rvec")#cite("goossens.book").
== State of the Art
#label("state-of-the-art")
See equation @eqn_pi in @state-of-the-art.#footnote[A famous equation.]
== Some Meaningless Stuff
#label("some-meaningless-stuff")
The credo of the #gls("aaaaz") was, for several years, several paragraphs of
gibberish, until the dingledorf responsible for the #gls("aaaaz") Web site
realized his mistake:
\"Velit dolor illum facilisis zzril ipsum, augue odio, accumsan ea augue
molestie lobortis zzril laoreet ex ad, adipiscing nulla. Veniam dolore,
vel te in dolor te, feugait dolore ex vel erat duis nostrud diam commodo
ad eu in consequat esse in ut wisi. Consectetuer dolore feugiat wisi eum
dignissim tincidunt vel, nostrud, at vulputate eum euismod, diam minim
eros consequat lorem aliquam et ad. Feugait illum sit suscipit ut,
tation in dolore euismod et iusto nulla amet wisi odio quis nisl feugiat
adipiscing luptatum minim nisl, quis, erat, dolore. Elit quis sit dolor
veniam blandit ullamcorper ex, vero nonummy, duis exerci delenit
ullamcorper at feugiat ullamcorper, ullamcorper elit vulputate iusto
esse luptatum duis autem. Nulla nulla qui, te praesent et at nisl ut in
consequat blandit vel augue ut.
Illum suscipit delenit commodo augue exerci magna veniam hendrerit
dignissim duis ut feugait amet dolor dolor suscipit iriure veniam. Vel
quis enim vulputate nulla facilisis volutpat vel in, suscipit facilisis
dolore ut veniam, duis facilisi wisi nulla aliquip vero praesent nibh
molestie consectetuer nulla. Wisi nibh exerci hendrerit consequat,
nostrud lobortis ut praesent dignissim tincidunt enim eum accumsan.
Lorem, nonummy duis iriure autem feugait praesent, duis, accumsan tation
enim facilisi qui te dolore magna velit, iusto esse eu, zzril. Feugiat
enim zzril, te vel illum, lobortis ut tation, elit luptatum ipsum,
aliquam dolor sed. Ex consectetuer aliquip in, tation delenit dignissim
accumsan consequat, vero, et ad eu velit ut duis ea ea odio.
Vero qui, te praesent et at nisl ut in consequat blandit vel augue ut
dolor illum facilisis zzril ipsum. Exerci odio, accumsan ea augue
molestie lobortis zzril laoreet ex ad, adipiscing nulla, et dolore, vel
te in dolor te, feugait dolore ex vel erat duis. Ut diam commodo ad eu
in consequat esse in ut wisi aliquip dolore feugiat wisi eum dignissim
tincidunt vel, nostrud. Ut vulputate eum euismod, diam minim eros
consequat lorem aliquam et ad luptatum illum sit suscipit ut, tation in
dolore euismod et iusto nulla. Iusto wisi odio quis nisl feugiat
adipiscing luptatum minim. Illum, quis, erat, dolore qui quis sit dolor
veniam blandit ullamcorper ex, vero nonummy, duis exerci delenit
ullamcorper at feugiat. Et, ullamcorper elit vulputate iusto esse
luptatum duis autem esse nulla qui.
Praesent dolore et, delenit, laoreet dolore sed eros hendrerit consequat
lobortis. Dolor nulla suscipit delenit commodo augue exerci magna veniam
hendrerit dignissim duis ut feugait amet. Ad dolor suscipit iriure
veniam blandit quis enim vulputate nulla facilisis volutpat vel in. Erat
facilisis dolore ut veniam, duis facilisi wisi nulla aliquip vero
praesent nibh molestie consectetuer nulla, iriure nibh exerci hendrerit.
Vel, nostrud lobortis ut praesent dignissim tincidunt enim eum accumsan
ea, nonummy duis. Ad autem feugait praesent, duis, accumsan tation enim
facilisi qui te dolore magna velit, iusto esse eu, zzril vel enim zzril,
te. Nisl illum, lobortis ut tation, elit luptatum ipsum, aliquam dolor
sed minim consectetuer aliquip.
Tation exerci delenit ullamcorper at feugiat ullamcorper, ullamcorper
elit vulputate iusto esse luptatum duis autem esse nulla qui. Volutpat
praesent et at nisl ut in consequat blandit vel augue ut dolor illum
facilisis zzril ipsum, augue odio, accumsan ea augue molestie lobortis
zzril laoreet. Ex duis, te velit illum odio, nisl qui consequat aliquip
qui blandit hendrerit. Ea dolor nonummy ullamcorper nulla lorem tation
laoreet in ea, ullamcorper vel consequat zzril delenit quis dignissim,
vulputate tincidunt ut.\"
#pagebreak(weak: true)
= Observations
#label("observations")
This would be a good place for some figures and tables.
Some notes on figures and photographs…
- A well-prepared PDF should be
+ Of reasonable size, #emph[i.e.] photos cropped and compressed.
+ Scalable, to allow enlargment of text and drawings.
- Photos must be bit maps, and so are not scaleable by definition. TIFF
and BMP are uncompressed formats, while JPEG is compressed. Most
photos can be compressed without losing their illustrative value.
- Drawings that you make should be scalable vector graphics, #emph[not]
bit maps. Some scalable vector file formats are: EPS, SVG, PNG, WMF.
These can all be converted into PNG or PDF, that pdflatex recognizes.
Your drawing package can probably export to one of these formats
directly. Otherwise, a common procedure is to print-to-file through a
Postscript printer driver to create a PS file, then convert that to
EPS (encapsulated PS, which has a bounding box to describe its exact
size rather than a whole page). Programs such as GSView (a Ghostscript
GUI) can create both EPS and PDF from PS files.
Appendix #link("#AppendixA")[3] shows how to generate properly sized
Matlab plots and save them as PDF.
- It’s important to crop your photos and draw your figures to the size
that you want to appear in your thesis. Scaling photos with the
includegraphics command will cause loss of resolution. And scaling
down drawings may cause any text annotations to become too small.
For more information on LaTeX see these
#link("https://uwaterloo.ca/information-systems-technology/services/electronic-thesis-preparation-and-submission-support/ethesis-guide/creating-pdf-version-your-thesis/creating-pdf-files-using-latex/latex-ethesis-and-large-documentscourse")
notes. #super[2]
The classic book by <NAME> #cite("lamport.book"), author of
LaTeX, is worth a look too, and the many available add-on packages are
described by Goossens #emph[et al] #cite("goossens.book").
#pagebreak(weak: true)
#bibliography("uw-ethesis.bib", title: [References])
// #set heading(numbering: "A.1.1.1")
// #counter(heading).update(0)
#show: appendix
#pagebreak(weak: true)
#heading("APPENDICES", numbering: none)
#label("appendices")
#pagebreak(weak: true)
= Matlab Code for Making a PDF Plot
#label("AppendixA")
== Using the Graphical User Interface
#label("using-the-graphical-user-interface")
Properties of Matab plots can be adjusted from the plot window via a
graphical interface. Under the Desktop menu in the Figure window, select
the Property Editor. You may also want to check the Plot Browser and
Figure Palette for more tools. To adjust properties of the axes, look
under the Edit menu and select Axes Properties #cite("goossens.book").
To set the figure size and to save as PDF or other file formats, click
the Export Setup button in the figure Property Editor.
== From the Command Line
#label("from-the-command-line")
All figure properties can also be manipulated from the command line.
Here’s an example:
```
x=[0:0.1:pi];
hold on % Plot multiple traces on one figure
plot(x,sin(x))
plot(x,cos(x),'--r')
plot(x,tan(x),'.-g')
title('Some Trig Functions Over 0 to \pi') % Note LaTeX markup!
legend('{\it sin}(x)','{\it cos}(x)','{\it tan}(x)')
hold off
set(gca,'Ylim',[-3 3]) % Adjust Y limits of "current axes"
set(gcf,'Units','inches') % Set figure size units of "current figure"
set(gcf,'Position',[0,0,6,4]) % Set figure width (6 in.) and height (4 in.)
cd n:\thesis\plots % Select where to save
print -dpdf plot.pdf % Save as PDF
```
|
|
https://github.com/longlin10086/HITSZ-PhTyp | https://raw.githubusercontent.com/longlin10086/HITSZ-PhTyp/main/layout/page.typ | typst | #import "../themes/theme.typ" : *
#import "../utils/two_line.typ" : two_lines
#import "../utils/head_element.typ" : head_elements_line
#import "../utils/head_element.typ" : underline_element
#import "../utils/question_list.typ" : question_list
#import "../utils/tables.typ" : signature_table
#import "../utils/tables.typ" : simple_table
#let page_style(body) = {
set page(
paper: "a4",
margin: (top: 100pt, bottom: auto, right: 3.18cm, left: 3.18cm),
header: [
#set text(font: 字体.楷体, size: 字号.四号)
#grid(
row-gutter: 3pt,
rows: (auto, auto),
[
大学物理实验报告
#h(1fr)
哈尔滨工业大学(深圳)
],
line(length: 100%, stroke: 0.05em)
)
],
footer: [
#set align(right)
#set text(8pt)
#counter(page).display(
"1",
)
]
)
show heading.where(level: 1) : it => {
set align(center)
set text(font: 字体.黑体, size: 字号.小四)
grid(
columns: (auto, auto),
column-gutter: 10pt,
strong("实验名称"),
strong(it),
)
}
show heading.where(level: 2) : it => {
set align(left)
set text(font: 字体.宋体, size: 字号.五号)
let num = counter(heading.where(level: 2)).get().at(0)
grid(
columns: (0em, auto, auto),
column-gutter: 3pt,
align: bottom + left,
hide[一], numbering("一、", num),
it
)
v(0.5em)
}
body
}
|
|
https://github.com/katamyra/Notes | https://raw.githubusercontent.com/katamyra/Notes/main/Compiled%20School%20Notes/CS1332/CompiledNotes.typ | typst | #import "../../template.typ": *
#show: template.with(
title: [CS 1332 Lecture Notes],
authors: (
(
name: "<NAME>"
),
),
)
#set text(
fill: rgb("#04055c")
)
#include "Modules/ArraysAndArrayLists.typ"
#include "Modules/LinkedLists.typ"
#include "Modules/Stacks.typ"
#include "Modules/Queues.typ"
#include "Modules/Trees.typ"
#include "Modules/Heaps.typ"
#include "Modules/Hashmaps.typ"
#include "Modules/AVL.typ"
#include "Modules/IterativeSorts.typ"
#include "Modules/DAndCSorts.typ"
#include "Modules/PatternMatching.typ" |
|
https://github.com/VZkxr/Typst | https://raw.githubusercontent.com/VZkxr/Typst/master/Seminario/Problema%20Proba%20-%20Bitacora/problema_proba.typ | typst | #set page(header: [
Problemario 2 (parte 2)
#h(1fr)
<NAME>])
1. Se tiene un examen de 20 preguntas de verdadero y falso. Se requiere que una o un estudiante conteste al menos 17 preguntas de forma correcta. ¿Qué probabilidad hay de que esto ocurra?.
_Solución._ \
Primero, es importante identificar la "naturaleza" del problema, es decir, si se trata de una permutación, una variación o una combinación. Para esto, con conocimientos básicos de conteo se puede establecer un diagrama como el siguiente:
#figure(
image("diagram.png", width: 80%),
caption: [
Diagrama de conteo hecho en Excalidraw.
],
)
De este modo, podemos conjeturar que se requiere del uso de combinaciones, en efecto, si queremos los subconjuntos con 17 preguntas buenas que se pueden formar a partir de un conjunto de 20 preguntas, sin importar el orden y sin repetir, necesitamos las combinaciones de $20$ en $17$, es decir, $mat(20;17)$, sin embargo, tenemos como dato que se requiere que una o un estudiante conteste #text(weight: "bold", "al menos") $17$ preguntas de forma correcta, es decir, hay que considerar la posibilidad de obtener más aciertos, por lo que también nos piden las combinaciones de $20$ en $18$, de $20$ en $19$ y de $20$ en $20$. \ \
Por otro lado, cada pregunta tiene $1/2$ de probabilidad de ser correcta y $1/2$ de ser incorrecta, por lo que el uso de estas probabilidades son imprescindibles para cada combinación, teniendo en cuenta la cantidad de preguntas que se pueden tener correctas y también las incorrectas. \
En este punto, notemos que los contenidos matemáticos que se deben considerar para la resolución de este ejercicio son:
/ -: Principio básico de conteo
/ -: Aritmética factorial
/ -: Combinaciones en probabilidad
Dada la argumentación anterior, tenemos que la probabilidad de contestar exactamente 17 preguntas de forma correcta está determinada por la expresión
$ mat(20; 17) (1/2)^17 (1/2)^3 &= frac(20!, 17!(20-17)!) (1/131072) (1/8) \
&= frac(20 dot 19 dot 18, 6) (1/131072) (1/8) \
&= 1140/131072 (1/8) \
&= 285/262144 \
&= 0.00108 & "...(i)" $
Análogamente, para 18 preguntas tenemos:
$ mat(20; 18) (1/2)^18 (1/2)^2 &= frac(20!, 18!(20-18)!) (1/262144) (1/4) \
&= 190/262144 (1/4) \
&= 0.000181198 & "...(ii)" $
Para 19 preguntas:
$ mat(20; 19) (1/2)^19 (1/2)^1 &= frac(20!, 19!(20-19)!) (1/524288) (1/2) \
&= 0.0000190735 & "...(iii)" $
Y para 20 preguntas:
$ mat(20; 20) (1/2)^20 (1/2)^0 &= frac(20!, 20!(20-20)!) (1/1048576) \
&= 0.000000953674 & "...(iv)" $
Finalmente, la probabilidad de que un estudiante conteste al menos 17 preguntas correctas es equivalente a pedir la probabilidad de que conteste exactamente 17 preguntas correctas, más la probabilidad de que conteste exactamente 18 preguntas correctas, más la probabilidad de que conteste exactamente 19 preguntas correctas, más la probabilidad de que conteste exactamente 20 preguntas correctas. Por lo tanto, la solución está determinada por la suma de (i), (ii), (iii) y (iv), es decir que
$ PP(X gt.eq 17) &= 0.00108 + 0.000181198 + 0.0000190735 + 0.000000953674 \
&= 0.00128839 $
$ therefore PP(X gt.eq 17) = 0.12% $
_Extensión._ \
Una pregunta que puede surgir para este problema, es si se puede modelar mediante una función de distribución, y si es así ¿qué distribución de sigue?.
#pagebreak()
2. Demostrar que todo entero es par o impar, pero no ambos. \
_Demostración._ \
Haremos uso de un teorema de Álgebra superior 2: \
\
#highlight(fill: rgb("#FFCE16"), radius: 8pt, stroke: black, extent: 3pt)[Teorema 3.1.] #h(2pt) Si $a$ y $b$ son enteros, con $b eq.not 0$, entonces existen únicos enteros $q$ y $r$, con $0 lt.eq r < |b|$, tales que $a = b q + r$. \
\
Tomando $a=n$ y $b=2$, por el #text(fill: rgb("#FFCE16"))[Teorema 3.1] tenemos que
$ n = 2q+r $
con $0 lt.eq r < 2$ para algunos enteros únicos $q$ y $r$. Así,
$ n = 2q+0 #h(7pt) #text(style: "normal", "o") #h(7pt) n = 2q + 1 $
es decir, sólo ocurre una de estas posibilidades, ser par, de la forma $n = 2q$ o ser impar de la forma $n = 2q+1$. Por lo tanto, todo entero $n$ es par o impar, pero no ambos. \
#h(1fr) $qed$ |
|
https://github.com/SillyFreak/typst-prequery | https://raw.githubusercontent.com/SillyFreak/typst-prequery/main/tests/image-with-assets/test.typ | typst | MIT License | #import "/src/lib.typ" as prequery
#prequery.image(
"https://upload.wikimedia.org/wikipedia/commons/a/af/Cc-public_domain_mark.svg",
"assets/public_domain.svg")
|
https://github.com/Gekkio/gb-ctr | https://raw.githubusercontent.com/Gekkio/gb-ctr/main/chapter/cpu/simple.typ | typst | Creative Commons Attribution Share Alike 4.0 International | #import "../../common.typ": *
== Simple model
#figure(
image(width: 70%, "../../images/SM83-simple.svg"),
caption: "Simple model of the SM83 CPU core"
) <sm83-simple>
@sm83-simple shows a simplified model of the SM83 CPU core. The core interacts with the rest of the SoC using interrupt signals, an 8-bit bidirectional data bus, and a 16-bit address bus controlled by the CPU core.
The main subsystems of the CPU core are as follows:
#grid(columns: 2, gutter: 12pt,
[*Control unit*], [
The control unit decodes the executed instructions and generates control signals for the rest of the CPU core. It is also responsible for checking and dispatching interrupts.
],
[*Register file*], [
The register file holds most of the state of the CPU inside registers. It contains the 16-bit Program Counter (PC), the 16-bit Stack Pointer (SP), the 8-bit Accumulator (A), the Flags register (F), general-purpose register pairs consisting of two 8-bit halves such as BC, DE, HL, and the special-purpose 8-bit registers Instruction Register (IR) and Interrupt Enable (IE).
],
[*ALU*], [
An 8-bit Arithmetic Logic Unit (ALU) has two 8-bit input ports and is capable of performing various calculations. The ALU outputs its result either to the register file or the CPU data bus.
],
[*IDU*], [
A dedicated 16-bit Increment/Decrement Unit (IDU) is capable of performing only simple increment/decrement operations on the 16-bit address bus value, but they can be performed independently of the ALU, improving maximum performance of the CPU core. The IDU always outputs its result back to the register file, where it can be written to a register pair or a 16-bit register.
]
)
|
https://github.com/Myriad-Dreamin/tinymist | https://raw.githubusercontent.com/Myriad-Dreamin/tinymist/main/syntaxes/textmate/tests/unit/basic/control-flow-for-destruct.typ | typst | Apache License 2.0 | #for i in () { }
#for (i) in () { }
#for (i,) in () { }
#for (i, ..) in () { }
#for (.., i) in () { }
#for (i: 1, ..) in () { }
#for (.., i: 1) in () { }
#for (i: 1, a, ..) in () { }
#for (.., i: 1, b) in () { } |
https://github.com/dismint/docmint | https://raw.githubusercontent.com/dismint/docmint/main/religion/rw2.typ | typst | #import "template.typ": *
#show: template.with(
title: "24.05 Second Revision",
subtitle: "<NAME> (924310245)",
pset: true,
)
<NAME> articulates his belief in “The Cosmological Fine-Tuning Argument” that the fine-tuning of the universe provides significant evidence for theism. Fine-tuning here refers to the setting of *fundamental* universal constants, such as the speed of light or the strength of atomic attractions. Even a slight alteration in these values could lead to a vastly different universe that interacts in a completely different way.
Here I will summarize White’s argument:
/ P1: If a fact E that we observe stands in need of explanation, and hypothesis H provides a satisfactory explanation of E that is better than any alternative explanation available,
then E provides significant evidential support for H.
/ P2: That our universe is life-permitting to life stands in need of explanation.
/ P3: That God adjusted the constants in order to allow for life to develop provides a satisfactory explanation for why our universe is life-permitting.
/ P4: There is no comparably satisfying explanation of this fact available.
/ P5: Therefore, that our universe is life-permitting provides significant evidential support for theism.
We can observe here that a central premise of White’s argument on Cosmological Fine Tuning (FTA) regards motivation - that the universe being hospitable for life is in need of explanation (P2). I will propose an argument against this premise, as well as the overall argument as follows:
/ P1: There exists an insignificant number of life in the universe
/ P2: If there exists an insignificant number of life in the universe, then the universe is not hospitable for life.
/ P3: If the universe is not hospitable for life, then the universe being hospitable is not in need of explanation.
/ P4: If the universe being hospitable is not in need of explanation, White’s second premise is false.
/ P5: If White’s second premise is false, then White’s argument is unsound.
/ C: White’s argument is unsound.
Since I have learned of the fine tuning argument from White’s paper, I will use “White’s argument” and Cosmological Fine Tuning (FTA) interchangeably.
Regarding P1, I believe that all cumulative observations of humans up until the present would lead us to believe this premise. Not only have we been unable to locate any extraterrestrial life forms, it seems the universe is quite hostile, from poisonous atmospheres to bone-crushing gravity. I believe therefore, that we ought to think there is an insignificant amount of life in this universe.
It is important to note here what I mean by “insignificant”. A believer of the FTA might say, for example, that even one instance of life should be considered significant, and to equate few forms of life as insignificant would be an injustice. However, I use insignificance in the context of the FTA - specifically that there is not enough life to justify that the universe is hospitable.
A supporter of White could easily contest this point that the given evidence is insignificant. As mentioned above, one or few instances of life might be enough reason to believe in fine-tuning, with uninhabitable locations in the universe being insignificant themselves in proving why existing life is not enough. They could argue that a given locale’s inhospitality does not diminish the hospitality of the universe, or the instances of life that do exist. However, I do not believe this is the case. Suppose we throw a hundred ruthless criminals into a mansion. The mansion is equipped with lavish furnishing, food, and entertainment. Yet still, the criminals try to kill each other. In no way can one say an environment such as this was hospitable, despite being “fine-tuned”. Perhaps for some well-doing citizens, it could be an acceptable environment, however there is nothing innately hospitable about the mansion. We could have instead used an abandoned warehouse, and things would have turned out the same. A truly hospitable environment would be one where the environment can supersede the specific situation - say if the mansion were equipped with therapists. Thus the idea that there exist so few instances of life should compel one to believe the universe is not generally hospitable for life, except in those few scenarios. I do not think we could be persuaded to say a universe with no life is hospitable for life, so thus a universe with little life is also inhospitable.
However, it is also possible to make a point against this - even if it is the case that the universe might not be the ideal circumstances for life in the vast majority of cases, it can still be immeasurably better than some alternatives. Suppose that the prisoners have an alternate housing option in the form of a deadly volcano that will erupt. The mansion, albeit not the ideal scenario, now looks incomparably better, and could be argued that it is now hospitable for these inmates. I do not think that this line of reasoning contributes any meaningful attack towards my saying that the mansion (the is inhospitable. This is because hospitality as I am defining it is not a relative term. When we say the universe is hospitable for life, I do not think we are trying to say that the universe is *more* hospitable than other potential environments. If it is, there is no contention that this point is true since some life exists, but our universe also becomes less interesting since we can imagine infinite universes with worse conditions.
Instead, hospitality should be taken to mean a state in which the host provides everything needed for the guest to flourish. Of course, circling back around to the aforementioned analogy, it is possible that even in the most perfect environment, a terrorist comes and makes the overall situation negative. I do not think that this takes away from hospitality. I define hospitality as a host that should provide a more likely chance (greater than half) to have a positive impact (whatever positive might mean in a specific context) for a random guest, on average. Hospitality should be viewed on a sliding scale instead of a binary metric. It is of course hard to tell where one draws the line between calling something “inhospitable” and “hospitable”, but I believe it is reasonable to say this occurs at the midway point.
Concretely, I do not believe the presence of life itself is that significant in itself, and the little life in the universe is insignificant to the idea that it is hospitable for life. A supporter of White might say that life in itself is rare and precious, to which I would respond that, yes, it might be, but without a large presence in the universe, our environment cannot be considered hospitable. Surely just as the universe could be less accommodating, it could also be *more* accommodating for life such that we see much more of it. As mentioned in the previous paragraph, I don’t expect to see the perfect conditions - just enough to persuade us that the universe is hospitable. The amount of life we have been able to observe is far from the significance needed to say the universe is hospitable for life.
A believer in the FTA might argue that we have no way of knowing if there is an abundance of life farther outward in the universe. To this, I agree, but the FTA is fundamentally limited by human understanding. Perhaps further scientific discoveries in the future will reveal the fine-tuning of the universe is not random at all. Thus we must work off of current human understanding to converse about the FTA.
It is not remarkable then, that the universe is somehow fine-tuned to be a hospitable environment for life. With how I have defined insignificant, it follows naturally from a state of insignificance that the universe is not hospitable.
Thus, P2 of White’s argument cannot be used. If the universe’s hospitality is not in need of an explanation, then an attempt to find a “best” explanation, and all other subsequent parts of his argument, cannot stand. With P2 being false, the contention is no longer sound, and the overall argument becomes unsound as well.
|
|
https://github.com/tony-rsa/thonifho.muhali.cv | https://raw.githubusercontent.com/tony-rsa/thonifho.muhali.cv/main/src/sections/ru/education.typ | typst | MIT License | #import "../../template.typ": *
#cvSection("Образование")
#cvEntry(
title: [Магистр факультета Информатики],
host: [#link("https://shorturl.at/cjxPZ")[#ln #hSpc() Технический Университет Мюнхена] #hDot() Очная форма],
date: [Октябрь 2022 — Март 2023 (6 месяцев)],
mode: [Мюнхен, Германия #hDot() Физический режим],
logo: "assets/logos/tum.png",
desc: [Дисциплины: #hSpc() Паттерны программного проектирования #hBar() Распределенные системы #hBar() Методы виртуализации],
)
#cvEntry(
title: [Магистр факультета Компьютерных наук и Прикладной математики],
host: [#link("https://shorturl.at/qTV46")[#ln #hSpc() Московский Авиационный Институт] #hDot() Вечерняя форма],
date: [Сентябрь 2021 — Август 2023 (2 года)],
mode: [Москва, Россия #hDot() Комбинированный режим],
logo: "assets/logos/mai.png",
desc: [Дисциплины: #hSpc() Архитектура высоконагруженных сервисов#hBar() Серверная разработка #hBar() Параллельные вычисления],
)
#cvEntry(
title: [Бакалавр факультета Бизнеса и Экономики],
host: [#link("https://shorturl.at/fQRX4")[#ln #hSpc() Высшая Школа Экономики] #hDot() Очная форма],
date: [Сентябрь 2016 — Август 2020 (4 года)],
mode: [Санкт-Петербург, Россия #hDot() Физический режим],
logo: "assets/logos/hse.png",
desc: [Дисциплины: #hSpc() Наука данных #hBar() Статистический анализ #hBar() Экономическая теория #hBar() Эконометрика],
)
|
https://github.com/Ourouk/typst_hepl_template | https://raw.githubusercontent.com/Ourouk/typst_hepl_template/main/template.typ | typst | // In file top level sit the global variables that need to be exported
// (they need to be used outside the template settings),
// as well as the main template setting function, named `project`.
// Save font families.
#let main-font = "STIX Two Text"
#let sans-font = "Source Sans Pro"
#let mono-font = "Inconsolata"
//Based on color scheme of the official https://hepl.be/themes/custom/hepl/css/module.css?s8sgmk
#let HEPLColors = (
beige-super-pale: rgb("#e8e8e3"),
rouge-prv: rgb("#CC0033"),
jaune-prv: rgb("#F6A800"),
jaune-fonce-hepl: rgb("#be7f00"),
bleu-hepl: rgb("#0080a0"),
bleu-clair-hepl: rgb("#8abcc8"),
bleu-clair-darker-hepl: rgb("#294e57"),
bleu-fonce-hepl: rgb("#002b4f"),
)
// Uliège colors (from official graphic chart).
#let Uliege = (
TealDark: rgb(000, 112, 127),
TealLight: rgb(095, 164, 176),
// Beige gray scale.
BeigeLight: rgb(232, 226, 222),
BeigePale: rgb(230, 230, 225),
BeigeDark: rgb(198, 192, 180),
// Faculty colors.
Yellow: rgb(255, 208, 000),
OrangeLight: rgb(248, 170, 000),
OrangeDark: rgb(240, 127, 060),
Red: rgb(230, 045, 049),
GreenPale: rgb(185, 205, 118),
GreenLight: rgb(125, 185, 040),
Green: rgb(040, 155, 056),
GreenDark: rgb(000, 132, 059),
BlueLight: rgb(031, 186, 219),
BlueDark: rgb(000, 092, 169),
LavenderDark: rgb(091, 087, 162),
LavenderLight: rgb(141, 166, 214),
PurpleLight: rgb(168, 088, 158),
PurpleDark: rgb(091, 037, 125),
GrayDark: rgb(140, 139, 130),
GrayLight: rgb(181, 180, 169),
)
// The project function defines how your document looks.
// It takes your content and some metadata and formats rest.
#let project(
title: "Title of the document",
course-title: none,
abstract: none,
authors: (),
date: datetime.today(),
paper-size: "a4",
twocols: false, // TODO: implement this.
bibliography-file: none,
body,
) = {
// Document's basic properties.
set document(author: authors.map(author => author.first-name + author.last-name), title: title)
// Paper and margins
let headsize = 0.95em // TODO: get true head height.
set page(
paper: paper-size,
margin:
if twocols == true {
(x: 1.5cm, top: 2cm+headsize, bottom: 1.5cm)
} else {
(x: 3cm, top: 2cm+headsize, bottom: 2cm)
},
header-ascent: 35%,
)
// Font families.
let font-size = 11pt
if twocols == true {font-size = 10pt}
set text(
font: main-font,
size: font-size,
lang: "en",
number-type: "old-style",
number-width: "proportional")
show raw: set text(font: mono-font, size: font-size)
set raw(tab-size: 4)
// Math settings.
show math.equation: set text(font: "STIX Two Math")
set math.equation(numbering: "(1.1)")
// Header.
set page(
header: locate(loc => {
set text(font: sans-font, size: headsize, fill: Uliege.GrayDark)
// Right header: page numbering
let thisPage = counter(page).display()
let totalPages = [#counter(page).final(loc).at(0)]
let pageNumbering = thisPage + " \u{2022} " + totalPages
// Left header: section number and title
let elems = query(
selector(heading.where(level: 1)).before(loc),
loc,
)
let sectionNum = none
let sectionTitle = none
let sectionHeader = none
if elems != () {
sectionTitle = elems.last().body
if elems.last().numbering == none {
sectionHeader = sectionTitle
} else {
sectionNum = counter(heading.where(level: 1)).display()
sectionHeader = sectionNum + " \u{2022} " + sectionTitle
}
}
// Build the complete header.
sectionHeader + h(1fr) + pageNumbering
}),
)
// Paragraphs.
set par(
leading: 0.8em,
first-line-indent: 1.8em,
justify: true,
linebreaks: "optimized",
)
show par: set block(spacing: 0.8em)
// Headings.
set heading(numbering: "1.1")
show heading: set text(font: sans-font, fill: Uliege.TealDark)
show heading: rest => {
if rest.level == 1 {
text(size:1.10em, weight: "semibold")[#rest]
} else if rest.level == 2 {
text(size:1.05em, weight: "semibold")[#rest]
} else if rest.level == 3 {
text(size:1.03em, weight: "regular")[#rest]
} else if rest.level > 3 { // Set run-in subheadings, starting at level 4.
parbreak()
text(font: sans-font, fill: Uliege.TealDark, weight: "semibold")[#rest.body ---]
} else {
rest
}
}
{
let size = 2.2em
let number_of_authors = 0
if authors.len() > 3 {
number_of_authors = authors.len() -3
}
place(top + center, dy: -2.35cm ,
rect(
fill: HEPLColors.beige-super-pale,
width: 140%,
height: 6.5cm + number_of_authors * size,
)
)
}
// Teal top right triangle.
place(top + right, dx: 6cm, dy: -5.5cm,
rotate(30deg,
polygon.regular(
fill:HEPLColors.rouge-prv,
size: 9cm,
vertices: 5,
)
)
)
// Faculty logo.
place(top + left, dy: -1cm)[
#image("figures/g2.svg", height: 1.25cm)
]
v(1.5cm)
// Title and course. + academic year
box(width: 100%,columns(2, gutter: 11pt)[
#align(left)[
// Determine the academic year.
#v(0.25cm, weak: true)
#let this_year = date.year()
#if date.month() < 9 [Année Académique #{this_year - 1} -- #this_year] else [Année Académique #this_year -- #(this_year+ 1)]
\
// Report course
#text(size: 1.4em, fill: HEPLColors.bleu-fonce-hepl, weight: "semibold")[
#course-title :
] \
#text(size: 1.8em, fill: HEPLColors.bleu-clair-darker-hepl, weight: "semibold")[
#title
]
]
#colbreak()
#set par(justify: false)
#set par(justify: true, leading: 0.15em)
#grid(
..authors.map(author => align(
center,
[
#author.first-name #smallcaps(author.last-name) \
#author.cursus
\
\
]
),
)
)
]
)
// Abstract.
if abstract != none {
block(
width: 100%,
fill: Uliege.TealDark.lighten(90%),
inset: 2em,
below: 2em,
par(first-line-indent: 0em)[
#text(font: sans-font, fill: Uliege.TealDark, weight: "semibold")[Abstract]
#linebreak()
#abstract
]
)
}
// Rest of document in two columns, if desired.
show: rest => {
if twocols == true {
show: columns.with(2, gutter: 2em)
rest
} else {
rest
}
}
v(1cm)
outline(indent: auto,title: "Table des matières")
pagebreak()
// Document main body.
body
// Print the bibliography.
if bibliography-file != none {
pagebreak()
show bibliography: set text(0.9em)
bibliography(bibliography-file, full: false, style: "ieee",title: "Bibliographie")
}
}
|
|
https://github.com/sdsc-ordes/modos-poster | https://raw.githubusercontent.com/sdsc-ordes/modos-poster/main/README.md | markdown | Creative Commons Attribution 4.0 International | # modos-poster
[](https://zenodo.org/doi/10.5281/zenodo.13312849)
Poster presentation of modos (multi-omics digital object system).
> [!TIP]
> The compiled PDF is available from the [release page](https://github.com/sdsc-ordes/modos-poster/releases).
## Setup
>[!NOTE]
> You will need `just` to run the instructions below ([installation](https://github.com/casey/just?tab=readme-ov-file#packages)), and and [nix](https://nixos.org/) or [docker](https://www.docker.com/) to use the provided development shell.
A nix shell with all dependencies is provided for reproducibility. It can be used in two ways:
With nix:
```shell
just develop-nix
```
Or with docker:
```shell
just develop-docker
```
## Usage
The presentation uses [typst](https://typst.app) with the [postercise](https://typst.app/universe/package/postercise/) package.
To compile the poster PDF, run `just build-poster`.
You may also `just watch-poster` to continuously rebuild the poster on source changes.
## Acknowledgement
The template is derived from [postercise](https://github.com/dangh3014/postercise).
|
https://github.com/julyfun/ncs-tp2 | https://raw.githubusercontent.com/julyfun/ncs-tp2/main/main.typ | typst | #set page(paper: "us-letter")
#set heading(numbering: "1.1.")
#set figure(numbering: "1")
#import "@preview/codelst:2.0.0": sourcecode
#show raw.where(block: true): it => {
set text(size: 10pt)
sourcecode(it)
}
// 这是注释
#figure(image("sjtu.png", width: 50%), numbering: none) \ \ \
#align(center, text(17pt)[
NCS TP2 \ \
#table(
columns: 2,
stroke: none,
rows: (2.5em),
// align: (x, y) =>
// if x == 0 { right } else { left },
align: (right, left),
[Name:], [<NAME> (Florian)],
[Student ID:], [521260910018],
[Date:], [#datetime.today().display()],
)
])
#pagebreak()
#set page(header: align(right)[
DB Lab1 Report - <NAME>
], numbering: "1")
#show outline.entry.where(
level: 1
): it => {
v(12pt, weak: true)
strong(it)
}
#outline(indent: 1.5em)
#set text(12pt)
#show heading.where(level: 1): it => {
it.body
}
= Q1
We consider the router as a "machine" in the network, so in subnet A, there is 7 devices, each of which needs an IP address. We need 2 additional addresses for the broadcast address and the reserved address. So 9 addresses are needed in total. The smallest subnet that can provide 9 addresses is a /28 subnet, which has 16 addresses in total.
Likewise, in subnet B, we need $3 + 2 = 5$ addresses and the smallest subnet that can provide 5 addresses is a /29 subnet, which has 8 addresses in total. In subnet C, we need $6 + 2 = 8$ addresses and the smallest subnet that can provide 8 addresses is a /29 subnet.
Therefore, the minimum size of the global address range should contain at least $16 + 8 + 8 = 32$ addresses, and the smallest subnet that can provide 32 addresses is a /27 subnet.
= Q2
Let's address 10.0.0.0/28 (from 10.0.0.0 to 10.0.0.15) to subnet A, 10.0.0.16/28 (from 10.0.0.16 to 10.0.0.31) to subnet B and 10.0.0.32/28 (from 10.0.0.32 to 10.0.0.47) to subnet C. The IP address assignment is shown in @t1. Command lines for these configurations are shown in @cli1.
#import "@preview/tablem:0.1.0": tablem
#let three-line-table = tablem.with(
render: (columns: auto, ..args) => {
table(
columns: columns,
stroke: none,
align: center + horizon,
table.hline(y: 0),
table.hline(y: 1, stroke: .5pt),
table.hline(y: 4, stroke: .5pt),
table.hline(y: 7, stroke: .5pt),
..args,
table.hline(),
)
}
)
#figure(
three-line-table[
| *Machine* | *Interface* | *IP/mask* |
| ---- | ---- | ---- |
| A1 | eth0 | 10.0.0.1/28 |
| A2 | eth0 | 10.0.0.2/28 |
| R1 | eth0 | 10.0.0.14/28 |
| C1 | eth0 | 10.0.0.17/28 |
| R1 | eth1 | 10.0.0.30/28 |
| R2 | eth0 | 10.0.0.29/28 |
| B1 | eth0 | 10.0.0.33/28 |
| R2 | eth1 | 10.0.0.46/28 |
| R3 | eth0 | 10.0.0.45/28 |
], caption: "IP Address Assignment"
) <t1>
The ping results from A1 to A2 and B2 are shown in @ping1. We can see from the results that A1 and A2 can communicate with each other through `ping` but A1 cannot communicate with B1.
= Q3
Let's add R1's `eth0` address for A1 and A2 as their default gateways, and add R2's `eth0` address for C1 as its default gateway. The command lines for these configurations are shown in @cli2.
`ping` from A1 to C1 failed, as shown in @ping2.
*We can observe* from the `tcpdump` results that in each attempt, there is one request packet forwarded to R1 and C1, and one reply packet from C1.
*Interpretation*:
- A1 trys to reach C1 which is not in the same subnet and not in the routing table, it forwards the packet to its default gateway R1.
- R1 forwards the packet to C1 through its `eth0` interface as C1 and R1 are in the same subnet.
- C1 forwards its reply packet to its default gateway R2.
- R2 has no idea where to forward the packet, it has no default gateway, so the communication failed.
= Q4
Like in @c4, let's add R1's default gateway to R2 and update the routing table of R2 to subnet A with gateway R1 using device `eth0`.
`ping` from A1 to C1 succeeds. Using `tcpdump` and `traceroute`, we can observe the path is:
$
"A1" -->^("request") "R1" -->^"request" "C1" -->^"reply" "R2" -->^"reply" "R1" -->^"reply" "A"
$
The paths of requests and replies are not the same.
= Q5
Finally we need to add R2 and B1's default gateways to R3, and update the routing table of R3 to subnet A and B with gateway R2 using device `eth1`.
With configurations in @c5, `ping` from A1 to B1 succeeds. The path is:
```
root@a1:/# traceroute 10.0.0.33
traceroute to 10.0.0.33 (10.0.0.33), 30 hops max, 60 byte packets
1 10.0.0.14 (10.0.0.14) 0.727 ms 0.899 ms 1.200 ms
2 10.0.0.29 (10.0.0.29) 1.874 ms 2.194 ms 2.524 ms
3 10.0.0.33 (10.0.0.33) 6.272 ms 6.716 ms 7.071 ms
```
= Appendix
== Configurations for Q2 <cli1>
```
# a1
ifconfig eth0 10.0.0.1/28
# a2
ifconfig eth0 10.0.0.2/28
# r1
ifconfig eth0 10.0.0.14/28
ifconfig eth1 10.0.0.30/28
# c1
ifconfig eth0 10.0.0.17/28
# r2
ifconfig eth0 10.0.0.29/28
ifconfig eth1 10.0.0.46/28
# b1
ifconfig eth0 10.0.0.33/28
# r3
ifconfig eth0 10.0.0.45/28
```
== Ping results in Q2 <ping1>
```
# a1 try to ping a2
root@a1:/# ping -c 5 10.0.0.2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.342 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.500 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.313 ms
64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=0.466 ms
64 bytes from 10.0.0.2: icmp_seq=5 ttl=64 time=0.375 ms
--- 10.0.0.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4084ms
rtt min/avg/max/mdev = 0.313/0.399/0.500/0.071 ms
# a1 try to ping b1
root@a1:/# ping -c 5 10.0.0.33
ping: connect: Network is unreachable
```
== Configurations for Q3 <cli2>
```
# a1
route add default gw 10.0.0.14
# a2
route add default gw 10.0.0.14
# c1
route add default gw 10.0.0.29
```
== Ping and tcpdump results in Q3 <ping2>
```
# a1
root@a1:/# ping 10.0.0.17 -c 4
PING 10.0.0.17 (10.0.0.17) 56(84) bytes of data.
--- 10.0.0.17 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3055ms
# r1 tcpdump
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:06:31.483814 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 26, seq 1, length 64
07:06:32.486765 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 26, seq 2, length 64
07:06:33.510743 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 26, seq 3, length 64
07:06:34.538570 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 26, seq 4, length 64
# c1 tcpdump
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:06:31.483949 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 26, seq 1, length 64
07:06:31.483973 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 26, seq 1, length 64
07:06:31.484241 IP 10.0.0.29 > 10.0.0.17: ICMP net 10.0.0.1 unreachable, length 92
07:06:32.487085 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 26, seq 2, length 64
07:06:32.487116 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 26, seq 2, length 64
07:06:32.487520 IP 10.0.0.29 > 10.0.0.17: ICMP net 10.0.0.1 unreachable, length 92
07:06:33.511041 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 26, seq 3, length 64
07:06:33.511070 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 26, seq 3, length 64
07:06:33.511396 IP 10.0.0.29 > 10.0.0.17: ICMP net 10.0.0.1 unreachable, length 92
```
== Configurations for Q4 <c4>
```
# r1
route add default gw 10.0.0.29
# r2
route add -net 10.0.0.0/28 gw 10.0.0.30 dev eth0
```
== Ping and tcpdump and traceroute results in Q4
```
# a1
root@a1:/# ping 10.0.0.17 -c 4
PING 10.0.0.17 (10.0.0.17) 56(84) bytes of data.
64 bytes from 10.0.0.17: icmp_seq=1 ttl=62 time=1.79 ms
64 bytes from 10.0.0.17: icmp_seq=2 ttl=62 time=1.22 ms
64 bytes from 10.0.0.17: icmp_seq=3 ttl=62 time=0.884 ms
64 bytes from 10.0.0.17: icmp_seq=4 ttl=62 time=1.03 ms
--- 10.0.0.17 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3011ms
rtt min/avg/max/mdev = 0.884/1.229/1.786/0.342 ms
# r1
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:25:22.691142 ARP, Request who-has 10.0.0.14 tell 10.0.0.1, length 46
07:25:22.691166 ARP, Reply 10.0.0.14 is-at 3e:99:66:06:4f:34 (oui Unknown), length 28
07:25:22.691466 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 29, seq 1, length 64
07:25:22.692660 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 29, seq 1, length 64
07:25:23.693239 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 29, seq 2, length 64
07:25:23.693877 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 29, seq 2, length 64
07:25:24.694492 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 29, seq 3, length 64
07:25:24.695022 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 29, seq 3, length 64
07:25:25.702752 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 29, seq 4, length 64
07:25:25.703242 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 29, seq 4, length 64
# c1
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:25:22.691142 ARP, Request who-has 10.0.0.14 tell 10.0.0.1, length 46
07:25:22.691166 ARP, Reply 10.0.0.14 is-at 3e:99:66:06:4f:34 (oui Unknown), length 28
07:25:22.691466 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 29, seq 1, length 64
07:25:22.692660 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 29, seq 1, length 64
07:25:23.693239 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 29, seq 2, length 64
07:25:23.693877 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 29, seq 2, length 64
07:25:24.694492 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 29, seq 3, length 64
07:25:24.695022 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 29, seq 3, length 64
07:25:25.702752 IP 10.0.0.1 > 10.0.0.17: ICMP echo request, id 29, seq 4, length 64
07:25:25.703242 IP 10.0.0.17 > 10.0.0.1: ICMP echo reply, id 29, seq 4, length 64
# a1
root@a1:/# traceroute 10.0.0.17
traceroute to 10.0.0.17 (10.0.0.17), 30 hops max, 60 byte packets
1 10.0.0.14 (10.0.0.14) 0.436 ms 0.659 ms 0.910 ms
2 10.0.0.17 (10.0.0.17) 1.477 ms 2.155 ms 2.532 ms
# c1
root@c1:/# traceroute 10.0.0.1
traceroute to 10.0.0.1 (10.0.0.1), 30 hops max, 60 byte packets
1 10.0.0.29 (10.0.0.29) 0.607 ms 0.815 ms 1.311 ms
2 10.0.0.30 (10.0.0.30) 5.104 ms 5.234 ms 5.741 ms
3 10.0.0.1 (10.0.0.1) 5.873 ms 5.943 ms 6.003 ms
```
== Configurations for Q5 <c5>
```
# r2
route add default gw 10.0.0.45
# b1
route add default gw 10.0.0.45
# r3
route add -net 10.0.0.16/28 gw 10.0.0.46 eth0
route add -net 10.0.0.0/28 gw 10.0.0.46 eth0
```
|
|
https://github.com/teamdailypractice/pdf-tools | https://raw.githubusercontent.com/teamdailypractice/pdf-tools/main/typst-pdf/examples/example-16.typ | typst | #set page("a4")
#set text(
font: "TSCu_SaiIndira",
size: 12pt
)
#outline()
#set page("a4")
#set text(
font: "TSCu_SaiIndira",
size: 13pt
)
#set align(center)
= 1 First
\
#set align(left)
#table(
stroke: none,
columns: (2cm, auto),
[], [],
[1000], [0 \ Line \ \ ],
[1000], [1 \ Line \ \ ],
[1000], [2 \ Line \ \ ],
[1000], [3 \ Line \ \ ],
[1000], [4 \ Line \ \ ],
[1000], [5 \ Line \ \ ],
[1000], [6 \ Line \ \ ],
[1000], [7 \ Line \ \ ],
[1000], [8 \ Line \ \ ],
[1000], [9 \ Line \ \ ],
)
#set page("a4")
#set text(
font: "TSCu_SaiIndira",
size: 13pt
)
#set align(center)
= 2 Second
\
#set align(left)
#table(
stroke: none,
columns: (2cm, auto),
[], [],
[1000], [0 \ Line \ \ ],
[1000], [1 \ Line \ \ ],
[1000], [2 \ Line \ \ ],
[1000], [3 \ Line \ \ ],
[1000], [4 \ Line \ \ ],
[1000], [5 \ Line \ \ ],
[1000], [6 \ Line \ \ ],
[1000], [7 \ Line \ \ ],
[1000], [8 \ Line \ \ ],
[1000], [9 \ Line \ \ ],
)
#set page("a4")
#set text(
font: "TSCu_SaiIndira",
size: 13pt
)
#set align(center)
= 3 Third
\
#set align(left)
#table(
stroke: none,
columns: (2cm, auto),
[], [],
[1000], [0 \ Line \ \ ],
[1000], [1 \ Line \ \ ],
[1000], [2 \ Line \ \ ],
[1000], [3 \ Line \ \ ],
[1000], [4 \ Line \ \ ],
[1000], [5 \ Line \ \ ],
[1000], [6 \ Line \ \ ],
[1000], [7 \ Line \ \ ],
[1000], [8 \ Line \ \ ],
[1000], [9 \ Line \ \ ],
)
|
|
https://github.com/Dherse/typst-brrr | https://raw.githubusercontent.com/Dherse/typst-brrr/master/samples/short-paper_01/table.typ | typst | #import "tablex.typ": tablex, colspanx, rowspanx, cellx, hlinex, vlinex
#let one = $cal(c)$
#let two = $cal(p)$
#let three = $cal(i)$
#let four = $cal(S)$
#let unknown = none
#let vertical(content) = layout(size => style(styles => {
let size = measure(content, styles)
place(horizon + center, rotate(90deg, box(width: size.width, height: size.height, content)))
box(width: size.height, height: size.width)
}))
#let generate-table(all-attributes, foos) = {
let columns = (auto,)
let items = ()
items.push(cellx(rowspan: 2, align: left)[*accountant*])
for (foo, bar) in foos {
items.push(cellx(colspan: bar.len(), strong(foo)))
}
items.push(())
let x = 1
for (foo, bar) in foos {
//jacks.pips(spells(jus: 9, S: r))
x += bar.len()
for (foo-setting, _) in bar {
columns.push(1fr)
items.push(vertical(foo-setting))
}
}
items.push(hlinex())
for attribute in all-attributes {
items.push(cellx(align: left, attribute))
for (foo, bar) in foos {
for (setting, attributes) in bar {
items.push(attributes.at(attribute))
}
}
}
tablex(
columns: columns,
align: center + horizon,
repeat-header: true,
//miss-serene: kedge,
..items
)
}
#let mytable = generate-table(
(
"beknighted misspend",
"quaich contextualizes",
"magnetohydrodynamics",
"nazifying",
"rewax",
"cerate",
"mosey",
"plug",
"tussocky",
"pas",
"biscuit soffits",
"emfs/2",
"snidenesses",
"argals",
),
(
"kirning": (
"drumhead": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"barely": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"distinguishabilities": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
),
"ago apogeal": (
"nicotine": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"bales": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"demies": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
),
"undercoat": (
"retrain": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"micros korai": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"refute halterbroken": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
),
"dozily": (
"fishtail sufferings": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"unpacked saddleless": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
),
"scut": (
"feria": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"maccoboy": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"libers": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
),
"maces": (
"sanga subcontracting cortexes": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"scaly premillenarian joinings": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
"spray psychoanalyses brisks": (
"beknighted misspend": four,
"quaich contextualizes": three,
"magnetohydrodynamics": three,
"nazifying": three,
"rewax": three,
"cerate": three,
"mosey": three,
"plug": three,
"tussocky": three,
"pas": three,
"biscuit soffits": four,
"emfs/2": four,
"snidenesses": three,
"argals": three,
),
),
)
)
|
|
https://github.com/Ourouk/typst_hepl_template | https://raw.githubusercontent.com/Ourouk/typst_hepl_template/main/main.typ | typst | #import "template.typ": *
#show: project.with(
course-title: "IOT",
title: "Vélos connectés",
authors: (
(
first-name: "Andrea",
last-name: "Spelgatti",
cursus: "M. Ing. Ind. - Informatique",
),
(
first-name: "Martin",
last-name: "<NAME>",
cursus: "M. Ing. Civ. - Informatique",
),
),
bibliography-file: "ref.bib"
)
= Introduction
== Problématique
Lors de nos diverses balades en ville, nous pouvons, désormais, constater l'apparition de plus en plus fréquente de vélos en libre-service.
C'est ainsi que l'idée de gérer une flotte de vélos Universitaire, disponible pour les étudiants et le personnel sur un campus nous est venue en tête #cite(<ruggieroSecurityFlawGoogle2018>).
Des problématiques apparaissent directement avec cette idée. Comme l'exemple du campus de Google de Montain Valley où une succession de vols des vélos mis à disposition sur le site a eu lieu. Avec près de 250 disparitions par semaines.
On ne sait aussi aucunement qui utilise les vélos, si les règles d'utilisation sont réspectées ou si les vélos sont en bon état.
Il semble donc nécessaire de mettre en place un système de gestion de ces vélos pour éviter ce genre de désagrément. Cet ajout est aussi l'occasion de rajouter une série de fonctionnalités qui pourraient être utiles pour les utilisateurs.
== Objectif
L'objectif de ce projet est de réaliser un systême de gestion permettant de suivre l'activité de vélo en libre-service à l'intérieur d'un campus.
Ce système devra permettre de gérer les vélos, les stations, les utilisateurs et les trajets.
Nous ajouterons aussi quelques fonctionnalités intelligentes pour améliorer le confort de l'utilisateur.
== Proposition
Le projet consiste à réaliser trois objets connectés avec des capteurs différents. Ces objets sont les suivants :
- Un vélo connecté avec un esp32 compatible LORA
- Une station de sécurité/Charge connectée avec un esp32 compatible WIFI
- Une Antenne connectée avec un edge processing basé sur une RPI qui se connecte aux deux autres objets.
Le serveur de gestion sera réalisé en python avec une base de MongoDB.
Un serveur sera présent coté client de notre produit et un second sera géré de notre coté pour gérer la distribution de mise à jour le troubleshooting et la télémétrie.
Les deux serveurs seraient basés sur Rocky Linux en utilisant une architecture containérisée avec Docker.
== Diagramme de |
|
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/003%20-%20Gatecrash/005_The%20Burying%2C%20Part%201.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"The Burying, Part 1",
set_name: "Gatecrash",
story_date: datetime(day: 30, month: 01, year: 2013),
author: "<NAME>",
doc
)
#figure(image("005_The Burying, Part 1/01.jpg", width: 100%), caption: [Godless Shrine | Art by Cliff Childs], supplement: none, numbering: none)
They stood and gazed at the intact window, the Orzhov guild symbol catching the morning sun, filling the ruined cathedral with a golden glow. To see such a marvel in the Rubblebelt was a rare thing.
Domri Rade sized up the unblemished glass of the solar disk while he rolled the smooth, heavy stone in his hand. His best friends, Whip and Lakkie, stood alongside him, tense with anticipation.
This was going to be great.
Domri looked at his friends. "You ready?"
Whip flashed his teeth and nodded.
"Oh yeah. Rip it, Dom." Lakkie grinned through the warpaint Whip had put on him. #emph[Not a bad job] , Domri thought.
Domri turned, cocked his arm back, and let the stone fly. All the experience of Domri's young life—hitting lizards, birds, Golgari, merchants, and wagons—guided the stone toward its target like a missile of destiny. Domri had played out the effect in his mind before releasing the stone but nothing could have prepared him for the satisfying sound of the glass exploding upon impact. A resonant crash echoed across the collapsed hall. Glass splintered everywhere. Two huge yellow panes fell to the stone floor before shattering with another dazzling sound.
It was sublime.
"Krokt!" Whip said. Then they all broke into howls of jubilation and laughter and danced like goblins after a raid.
The three friends sat around, picking through the colorful shards of glass, finding the best pieces and binding the glass to wooden hilts. They looked like magical, golden blades.
#figure(image("005_The Burying, Part 1/02.jpg", width: 100%), caption: [<NAME> | Art by <NAME>ren], supplement: none, numbering: none)
"We could call our tribe the Shard Blades," Domri said, admiring his wicked-looking knife.
"Yeah, and only the chiefs get these." Lakkie held up his finished dagger. His father knew how to make useful things out of reeds and grass, and Lakkie proved himself good at binding the glass.
"That looks wrecked," Whip said with admiration. He held out his glass blade and handle to Lakkie. "Do mine."
Domri had made a decent twin-bladed dagger with the glass at opposing ends. He finished it and demonstrated its effectiveness against some imaginary opponents, first slashing, then hacking, in fairly skilled movements.
Lakkie finished up Whip's dagger. Domri looked at his friends and grinned.
"Let's wreck some stuff."
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
It was getting dark on the walk back to camp and early rising bats had begun to flit about, eager to feast on the twilight insects that buzzed about. Dark was a dangerous time to be out in the Rubblebelt, where beasts roamed that could swallow a warrior whole or crush a wagon underfoot. The boys instinctually hastened their stride. Whip swatted at burnbugs with a willow branch and Domri kept an eye on the shadows under the ruined buildings. Lakkie was off in another world, as usual. Domri once saved Lakkie from being a makka's lunch, and another time he kept Lakkie from being crushed by a dromad. Domri wondered if Lakkie would ever be cut out for real Gruul life. He was kind of Selesnyan.
#figure(image("005_The Burying, Part 1/03.jpg", width: 100%), caption: [<NAME> | Art by <NAME>tte], supplement: none, numbering: none)
As if on cue, Lakkie said, "I wonder what it's going to be like? You know, the Burying."
"Lakkie! You gob-head." Whip swatted him with his willow branch, leaving a welt.
"Krokt, that hurt! Just wondering, that's all." Lakkie rubbed his arm and glared at Whip.
"It's no big rip," Domri said. "I'm ready for it." He hoped his voice didn't betray the weakness that fluttered within him at the mere mention of it.
He knew Whip was just as interested as Lakkie. Both of them would be weighing whether to undergo the Burying in a year's time. Tales of the Gruul rite of passage were shrouded in secrecy and dread.
The Burying came to all who sought to join the Gruul. It was said by the elder shamans to strip away all attachment to a life within the city of Ravnica, a city that was a slave to rules and represented the destruction of nature. It was said that anyone who endured the Burying came back to the tribe reborn, clear of purpose and ready to live the life of a Gruul. All were sworn to secrecy, never to talk of the details to those who had not yet gone through it. This sealed the Burying within a sarcophagus of unknown dread within the minds of all young Gruul as they neared the appointed day and hour.
It buzzed within Domri's gut like a nest of hornets. His Burying would begin at sunrise.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
The morning had been spent covering Domri in burial garb and paint made of ash and clay. Shamans mumbled burial chants while, outside the tent, the tribe wailed as if he had died in the night. There was something so real about the sound of their grief that it unsettled him.
"Why are they doing that? I'm okay." Domri felt an irritation borne of fear.
The shaman who tended him, Sabast, looked at him through a mask of ochre and ash. "They are weeping for the loss of the boy they knew. In one way or another, that boy dies today."
For a moment, Domri felt a sense of panic. Maybe this was too much for him. Maybe it was too dangerous. But Domri knew others had gone before him. If they could do it, so could he.
In the afternoon, Domri and Sabast walked deep into the Utvara, a massive area of Ravnica that had seen destruction over the centuries and was home to many Gruul, in spite of attempts by Orzhov developers to claim otherwise.
"Look how nature responds," Sabast said, as they wandered through the ancient ruins. "In time it will all return back to the soil. There's wisdom in what the Golgari say. They understand nature's urge to tear down structures and reduce them to earth, but their hearts have been deadened. They have no passion for life."
Domri looked at the imperceptibly slow power of nature. Stone had yielded to trees. Vines had broken through bricks, their roots clinging to every nook and crack. Life was pulling apart the dead stone and brick of the city.
#figure(image("005_The Burying, Part 1/04.jpg", width: 100%), caption: [Stomping Ground | Art by <NAME>], supplement: none, numbering: none)
"Closeness to death brings many things to the Gruul: clarity of purpose; freedom from clinging; seeing the futility of rules; and, most of all, a renewed sense of life. Vigor and aliveness are never more powerful than when a warrior faces mortality. That is where the Golgari and the Gruul part ways. They have dived into death, allowing it to rob them of aliveness, while we have used nature's cycle to fuel us to feel more passion for life. Today, you will experience this firsthand."
"What's going to happen?"
"Your head will never be able to prepare you for what your heart understands fully. My words are for your mind. Life is for your heart. Do not listen too closely to my words or you'll become an Azorius. You must feel your way."
As dusk approached, the overgrown ruins began to cast eerie shadows. Domri had never in his youthful wanderings ventured this far out into the Utvara. Nothing seemed familiar. They approached a wall of vines and snarled roots that seemed impenetrable, but Sabast walked through the thick swath of them into the mouth of a hidden cave. Sabast pulled a torch from the wall, muttered a spell to ignite it, and walked down a craggy path decorated with Gruul symbols and pictograms.
After a long slippery trek down tunnels, across underground streams, and around stalagmites, they eventually reached a hole in the dark earth surrounded by Gruul grave items.
Sabast drove the torch into the ground with a shower of sparks and stood before the grave. He looked like a spirit from the afterworld as his eyes looked at Domri in the torchlight.
"<NAME>. It is time for the false you to die. It is time for the real you to be born."
|
|
https://github.com/Walker-00/cs-eik | https://raw.githubusercontent.com/Walker-00/cs-eik/rust/pages/main.typ | typst | Do What The F*ck You Want To Public License | // A Template File To Include all pages in one file |
https://github.com/wcshds/manual-of-chinese-phonology | https://raw.githubusercontent.com/wcshds/manual-of-chinese-phonology/main/tools/xsampa.typ | typst | #let table-custom = json("./custom.json");
#let table = table-custom + json("./xsampa.json");
#let look-up = {
let res = (:)
for (idx, info) in table.enumerate() {
res.insert(info.X-SAMPA, idx)
}
res
};
#let xsampa-reg = regex("(" + table.map(each => {
let escape_reg = regex("[-\/\\\^\$\*\+\?\.\(\)\|\[\]\{\}]")
each.X-SAMPA.replace(escape_reg, val => "\\" + val.text)
}).join("|") + ")");
/// Converts X-SAMPA to IPA.
#let xsampa(s) = {
let s = if type(s) == str {
s
} else if type(s) == content {
s.text
} else {
panic("Unexpected input type.")
}
s.trim().replace(
xsampa-reg,
val => {
let idx = look-up.at(val.text)
table.at(idx).IPA
},
)
} |
|
https://github.com/csimide/SEU-Typst-Template | https://raw.githubusercontent.com/csimide/SEU-Typst-Template/master/seu-thesis/parts/abstract-degree-fn.typ | typst | MIT License | #import "../utils/fonts.typ": 字体, 字号
#import "../utils/packages.typ": fakebold
#let abstract-conf(
cn-abstract: none,
cn-keywords: none,
en-abstract: none,
en-keywords: none,
page-break: none,
) = {
// 摘要使用罗马字符的页码
set page(numbering: "I", number-align: center)
counter(page).update(1)
set text(font: 字体.宋体, size: 字号.小四)
set par(first-line-indent: 2em, leading: 9.6pt, justify: true)
show par: set block(spacing: 9.6pt)
if not cn-abstract in (none, [], "") or not cn-keywords in (none, ()) {
{
heading(numbering: none, level: 1, outlined: true, bookmarked: true)[摘要]
cn-abstract
v(1em)
parbreak()
if not cn-keywords in (none, ()) {
assert(type(cn-keywords) == array)
fakebold[关键词:] + cn-keywords.join(",")
}
}
}
if not en-abstract in (none, [], "") or not en-keywords in (none, ()) {
{
if type(page-break) == function {
page-break()
} else {
pagebreak(weak: true)
}
heading(
numbering: none,
level: 1,
outlined: true,
bookmarked: true,
)[ABSTRACT]
en-abstract
v(1em)
parbreak()
if not en-keywords in (none, ()) {
assert(type(en-keywords) == array)
text(weight: "bold")[Keywords: ] + en-keywords.join(",")
}
}
}
}
#abstract-conf(
cn-abstract: [示例摘要],
cn-keywords: ("关键词1", "关键词2"),
en-abstract: none,
en-keywords: ("Keywords1", "Keywords2"),
)
|
https://github.com/chamik/gympl-skripta | https://raw.githubusercontent.com/chamik/gympl-skripta/main/cj-dila/5-starec-a-more.typ | typst | Creative Commons Attribution Share Alike 4.0 International | #import "/helper.typ": dilo
#dilo("Stařec a moře", "starec", "<NAME>", "<NAME>", "modernismus, ztracená generace, meziválečná lit.", "USA", "1952", "epika", "novela")
#columns(2, gutter: 1em)[
*Téma*\
#underline["Člověka je možno zničit, ale ne porazit"];
stařec vyrazí na lov velké ryby
*Motivy*\
rybolov, oceán, síla vůle, přátelství, stará $times$ nová škola (motorové čluny atp.), potrestání překročení hranice (vyjel daleko na moře)
*Časoprostor*\
kubánská vesnice poblíž Havany, oceán; nejspíš 20. století
*Postavy* \
_Santiago_ -- vytrvalý stařec\
_Manolin_ -- chlapec, přítel _Santiaga_
*Kompozice*\
chronologická bez členění
*Vypravěč* -- er-forma
*Jazykové prostředky*\
symbolika (krvavé ruce = Kristovo utrpení, nese si stěžeň jako Kristus kříž), jednoduché věty, rybářský slang, #underline[metoda ledovce]#footnote[Většina obsahu je "pod povrchem" a čtenář se musí trochu zamyslet.]
*Obsah*\
_Santiago_ je chudý rybář, který měl poslední dobou na moři smůlu. Na lodi mu dříve pomáhal _Manolin_, ovšem jeho rodiče mu nařídili, aby se plavil s konkurencí. Stařec se tedy na moře vydá sám.
#colbreak()
Vyjede daleko a brzy zabere ryba opravdu obrovská. Prvních několik hodin ji vůbec nevidí, ovšem dokáže to odhadnout podle různých věcí. Dokáže určovat směr podle větru, slunce a hvězd a obecně je na moři velmi znalý. Nechá se rybou táhnout celý den přes noc, aby se unavila. Během celé plavby si sám se sebou povídá. Jeho myšlenky si často protiřečí. Po dlouhém boji, při kterém málem nezvládne zůstat při vědomí rybu zabije. Skoro se jí až omlouvá a referuje k ní jako k bratrovi.
Přiváže ji na bok své loďky (je tak velká, že se dovnitř nevejde) a vydá se na cestu domů. Cestou na Kubánský břeh ho ovšem přepadne několik žraloků. Prvních pár je schopný zabít harpunou a nožem připevněným k pádlu, ale žraloků je mnoho a cestou celou rybu sežerou.
V noci v přístavu jako vždy složí stěžeň i plachtu a odnese je k sobě domů (musí si několikrát cestou odpočinout). Ráno obyvatelé objeví obrovskou kostru ryby na boku lodi a stařec si tak získá zpět jejich uznání. Zdá se mu o lvech.
*Literárně historický kontext*\
#underline[Ztracená generace]. Obsahuje autobiografické prvky (lov lvů, život na Kubě). Jedná se o autorovu poslední knihu, za kterou dostal v roce 1953 Pulitzerovu cenu a v roce 1954 Nobelovu cenu.
]
#pagebreak()
*Ukázka*
Přivázal rybu k přídi a k zádi a k veslařské lavičce uprostřed. Byla tak veliká, že mu to připadalo, jako by si k boku připoutával mnohem větší člun. [...] Měl v láhvi ještě dva doušky vody a jeden z poloviny vypil, jakmile snědl garnáty. Na tak velké zatížení plul člun docela dobře a stařec jej řídil s rukojetí kormidla v podpaží. Viděl na rybu a stačilo mu podívat se na ruce a přitlačit hřbet k zádi, aby se přesvědčil, že se to všechno skutečně stalo a že to nebyl sen. Jednu chvíli před koncem, když mu bylo tak špatně, ho napadlo, že se mu to možná zdá. A když potom viděl, jak se ryba vyhoupla z vody a utkvěla nehnutě na obloze, nežli dopadla zpátky, byl si jist, že se děje něco krajně podivného, a nemohl tomu uvěřit. A pak nějaký čas pořádně neviděl, třebaže teď viděl zase tak dobře jako jindy. [...] Díval se v jednom kuse na rybu, aby se ujistil, že je to všechno pravda. To bylo hodinu předtím, než ho napadl první žralok.
Ten žralok se neobjevil náhodou. Vyplaval už dříve z vodních hlubin, jakmile se temné mračno krve sesedlo a rozptýlilo v míli hlubokém moři. Vyřítil se nahoru tak rychle a tak naprosto bezhlavě, že prorazil hladinu modré vody a octl se ve slunci. Pak padl zpátky do moře, zachytil pach a vyrazil ve sledu člunu a ryby. [...]
Teď měl stařec hlavu jasnou a v pořádku a překypoval rozhodností, ale měl málo naděje. Bylo to příliš krásné na to, aby to vytrvalo, pomyslel si. Pohlédl letmo na velkou rybu a pozoroval dál blížícího se žraloka. Vyjde to na stejno, jako by se mi všechno jen zdálo, uvědomil si v duchu. Nemůžu mu zabránit, aby se na mě nevrhl, ale snad bych ho mohl dostat. Dentuso, proklel ho v duchu. Čert aby vzal tvou mámu!
Žralok je rychle dohnal odzadu, a když se vrhl na rybu, viděl stařec jeho otevřenou tlamu a podivné oči a slyšel cvaknutí jeho zubů, když se zahryzl do rybího masa těsně nad ocasem. Žraloci hlava vyčnívala z vody a jeho hřbet se vynořoval a stařec slyšel, jak se na jeho velké rybě trhá kůže a maso. Vtom okamžiku vrazil stařec harpunu žralokovi do hlavy v těch místech, kde spojnice mezi očima prolínala čáru, táhnoucí se mu od nosu přímo vzad. Ty čáry nebylo ve skutečnosti vidět. Bylo vidět jen těžkou špičatou modrou hlavu a veliké oči a cvakající, dravě chňapající hltavé čelisti. Ale v těch místech má žralok mozek a stařec ho tam zasáhl. Zasáhl ho svýma krví pomazanýma rukama a vbodl mu tam dobře mířenou harpunu ze všech sil.
Vrazil mu ji tam bez naděje, ale odhodlaně a s naprostou škodolibou nenávistí.
Žralok se převalil a stařec viděl, že mu v oku vyhasl život. A pak se převalil ještě jednou a zamotal se do dvou kliček provazu. Stařec věděl, že je mrtev, ale žralok to nechtěl uznat. Převrácený na záda mrskal ocasem a cvakal čelistmi a rozrýval hladinu jako rychlý motorový Člun. [...]
„Urval aspoň dvacet kilo," řekl si stařec nahlas. A připravil mě o harpunu, pomyslel si, a o celé lanko, a moje ryba zase krvácí a to přiláká další...
#pagebreak() |
https://github.com/Error-418-SWE/Documenti | https://raw.githubusercontent.com/Error-418-SWE/Documenti/src/2%20-%20RTB/Lettera%20di%20presentazione/Lettera%20di%20presentazione%20RTB.typ | typst | #import "/common.typ": *
#set text(
font: "New Computer Modern",
lang: "it",
)
#set par(
leading: 0.85em,
)
#set list(
marker: ([•], [--]),
)
#set table(
fill: (_, row) => if row == 0 { luma(220) },
stroke: 0.5pt + luma(140)
)
#show link: set text(fill: blue)
#show link: it => [
#it
#v(0.75em)
]
#show "WIP": it => [
#text(it, fill: red)
]
#v(-1em)
#align(
end,
block(
width: 50%,
grid(
columns: (3fr, 2fr),
column-gutter: 1em,
[
#align(
end + horizon,
[
#text(
size: 1.2em,
weight: "bold",
err418
)
#v(-0.5em)
#link("mailto:<EMAIL>")
]
)
],
[
#align(
horizon,
[
#v(-1em)
#image("/logo.png", width: 100%)
]
)
]
)
)
)
#v(2em)
Egregio Prof. <NAME>,\
Egregio Prof. <NAME>,
#v(1em)
Con la presente, il gruppo #err418 intende comunicarVi la volontà di candidarsi alla revisione per la _Requirements and Tecnology Baseline_. Sarà esposto lo stato di avanzamento del progetto:
#align(center)[*"WMS3: Warehouse Management 3D"*]
proposto dall'azienda _Sanmarco Informatica S.p.A._, altresì denominato Capitolato 5.
I documenti prodotti dal gruppo per la RTB sono consultabili all'indirizzo:
#align(center)[#link("https://github.com/Error-418-SWE/Documenti/tree/main/2 - RTB")]
Per agevolare la consultazione dei documenti, il gruppo si è munito di un sito web:
#align(center)[#link("https://error418swe.netlify.app/")]
È fornito inoltre il _Proof of Concept_, disponibile all'indirizzo:
#align(center)[#link("https://github.com/Error-418-SWE/PoC/tree/main/")]
I membri del gruppo sono riportati nella tabella seguente:
#figure(
table(
columns: 2,
[*Nome*], [*Matricola*],
[<NAME>], [2042381],
[<NAME>], [2042346],
[<NAME>], [2010003],
[<NAME>], [1222011],
[<NAME>], [1226325],
[<NAME>], [1193375],
[<NAME>], [2043680],
),
)
Il gruppo aggiorna la stima dei costi, riducendola a *€ 13.055,00*. La data di consegna prevista rimane invariata ed è fissata al *20/03/2024*.
#v(1em)
Cordiali saluti,\
#err418 (gruppo 7) |
|
https://github.com/yhtq/Notes | https://raw.githubusercontent.com/yhtq/Notes/main/数学模型/作业/hw2.typ | typst | #import "../../template.typ": proof, note, corollary, lemma, theorem, definition, example, remark, proposition,der, partialDer, Spec
#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: "作业2",
author: "YHTQ",
date: none,
logo: none,
withOutlined : false,
withTitle :false,
)
(应交事件为3月18日)
= 3月4日
==
不妨设 $x_i$ 从小到大排列。容易发现所求函数是分段线性的,分段点分别为:
$
x_1, x_2, ..., x_n
$
从左到右,每段的斜率为:
$
- sum_(i in V) d_i, 2 d_1 - sum_(i in V) d_i, 2d_1 + 2d_2 - sum_(i in V) d_i, ... , sum_(i in V) d_i
$
显然函数取最小值当且仅当斜率在其左侧非正,右侧非负,因此最小值点恰在 $"median"(d)$ 对应的 $x$ 区间取得(题上写错了?)
==
考虑两点以及之间的边构成的图,容易计算得 $h = 1/1 = 1$,而:
$
lambda_2 = min (y^T L y)/(y^T D y) =min_(y^T y= 1) y^T mat(1, -1;-1, 1) y = 2
$
恰有 $lambda_2 = 2 h$
对于另一侧,经过尝试和查阅相关资料并没有找到实际取等的例子,但是可以证明在 $4 n$ 阶圈图上量级是紧的。事实上,设向量:
$
x_i = cases(
i - n/4\, quad i <= n/2,
(3n)/4 - i\, quad i > n/2
)
$
容易验证它与 $overline(1)$ 垂直,计算其 Rayleigh 商为:
$
lambda_2 <= (x^T L x)/(2 x^T x) = (O(n))/(O(n^3)) = O(1/n^2)
$
而 $h(G)$ 是 $O(1/n)$ 的,表明不等式的量级是紧的
==
用 Mathematica 计算得,答案在附件之中。可以看出取绝对值后,采用 $93 - 337$ 之间的值作为取整阈值均可
= 3月11日
==
===
#lemma[][
设 $h$ 是凸函数,$f$ 是线性函数,则 $h compose f$ 是凸函数
]<convexity>
#proof[
设定义域为凸集 $X$, 任取 $x, y in X, t in [0, 1]$,计算:
$
h(f(t x + (1 - t) y)) = h(t f(x) + (1-t) f(y)) <= t h(f(x)) + (1-t) h(f(y))
$
由定义知 $h compose f$ 是凸函数
]
注意到绝对值函数是凸函数,由引理知 $abs((epsilon_i - epsilon_j)^T X) = abs(x_i - x_j)$ 是凸函数,注意到凸函数的和还是凸函数,继而 $I(x)$ 也是凸函数
类似的:
$
N'(x, c) := sum_(i in V) d_i abs(x_i - c)
$
是凸函数
#lemma[][
设 $f(x, y): RR^m times RR^n -> RR$ 是凸函数,且 $min_(y in RR^n) f(x, y)$ 总存在,则:
$
g(x) = min_(y in RR^n) f(x, y)
$
也是凸函数
]
#proof[
// $
// g(t x_1 + (1-t) x_2) &= min_(y in RR^n) f(t x_1 + (1-t) x_2, y) \
// &<= min_(y in RR^n) (t f(x_1, y) + (1-t) f(x_2, y))
// $
// $
// t g(x_1) + (1-t) g(x_2) = min_(y in RR^n) t f(x_1, y) + min_(y in RR^n) (1-t) f(x_2, y)
// $
$
f(t x_1 + (1-t) x_2, t y_1 + (1-t) y_2) <= t f(x_1, y_1) + (1-t) f(x_2, y_2)
$
两边令 $y_1$ 遍历 $RR^n$ 取最小值:
$
min_(y_1 in RR^n) f(t x_1 + (1-t) x_2, t y_1 + (1-t) y_2) <= t g(x_1) + (1-t) f(x_2, y_2)
$
然而注意到:
$
min_(y_1 in RR^n) f(t x_1 + (1-t) x_2, t y_1 + (1-t) y_2) \
= min_(t y_1 + (1-t) y_2 in RR^n) f(t x_1 + (1-t) x_2, t y_1 + (1-t) y_2) = g(t x_1 + (1-t) x_2)
$
从而有:
$
g(t x_1 + (1-t) x_2) <= t g(x_1) + (1-t) f(x_2, y_2), forall y_2 in RR^n
$
再对 $y_2$ 取最小值,立得:
$
g(t x_1 + (1-t) x_2) <= t g(x_1) + (1-t) g(x_2)
$
表明 $g$ 是凸函数
]
由引理,结论是显然的
===
任意取定 $x in RR^n$,不妨设 $x_i in [-1, 1]^n$ \
对于某个阈值 $t in RR$,令:
$
S_t = {i in V | abs(x_i) > t} subset U_plus.minus (x)
$
显然 $S_0 = U_plus.minus (x), S_1 = emptyset$\
只需证明:
$
exists t in [0, 1], N(x) "cut" S_t <= I(x) "vol"(x)
$
为此,我们证明:
$
E (N(x) "cut" S_t - I(x) "vol"(x)) <= 0
$<target>
足以说明原式
- 先计算 $E ("cut" S_t)$,有:
$
E ("cut" S_t) &= E (sum_({i, j} in E) abs(1^t_i - 1^t_j)) "(其中" 1^t "是" S_t "的指示向量)" \
&= sum_({i, j} in E) E (abs(1^t_i - 1^t_j)) \
&= sum_({i, j} in E) E (1^t_i - 1^t_j | 1^t_i > 1^t_j) P(1^t_i > 1^t_j) + E (1^t_j - 1^t_i | 1^t_i < 1^t_j) P(1^t_i < 1^t_j) \
&= sum_({i, j} in E) E (1^t_i - 1^t_j | 1^t_i > 1^t_j) P(1^t_i > 1^t_j) + E (1^t_j - 1^t_i | 1^t_i < 1^t_j) P(1^t_i < 1^t_j) \
$
注意到 $P(1^t_i > 1^t_j), P(1^t_i < 1^t_j)$ 由 $abs(x_i), abs(x_j)$ 的大小关系决定,且两者至多一个不是零
- 当 $abs(x_i) = abs(x_j)$ 时,两者同时为零
- 当 $abs(x_i) < abs(x_j)$ 时,有:
$
&E (1^t_i - 1^t_j | 1^t_i > 1^t_j) P(1^t_i > 1^t_j) + E (1^t_j - 1^t_i | 1^t_i < 1^t_j) P(1^t_i < 1^t_j) \
=& E (1^t_j - 1^t_i | 1^t_i < 1^t_j) P(1^t_i < 1^t_j)\
=& 1 dot (abs(x_j) - abs(x_i))\
=& abs(x_j) - abs(x_i)
$
- 类似的,若 $abs(x_i) > abs(x_j)$,则原式等于 $abs(x_i) - abs(x_j)$
综上,有:
$
&sum_({i, j} in E) E (1^t_i - 1^t_j | 1^t_i > 1^t_j) P(1^t_i > 1^t_j) + E (1^t_j - 1^t_i | 1^t_i < 1^t_j) P(1^t_i < 1^t_j)\
&= sum_({i, j} in E) abs(abs(x_i) - abs(x_j))
$
- 再计算 $E ("vol"(x))$,有:
$
E ("vol"(x)) = E(sum_(i in V) d_i 1^t_i) = sum_(i in V) d_i E (1^t_i) = sum_(i in V) d_i P(abs(x_i) > t) = sum_(i in V) d_i abs(x_i)
$
综上,有:
$
E (N(x) "cut" S_t) = (min_(c in RR) sum_(i in V) d_i abs(x_i - c)) (sum_({i, j} in E) abs(abs(x_i) - abs(x_j)))\
E (I(x) "vol"(x)) = (sum_(i in V) d_i abs(x_i)) (sum_({i, j} in E) abs(x_i - x_j))
$
显然有:
$
0 <= min_(c in RR) sum_(i in V) d_i abs(x_i - c) <= sum_(i in V) d_i abs(x_i)\
0 <= sum_({i, j} in E) abs(abs(x_i) - abs(x_j)) <= sum_({i, j} in E) abs(x_i - x_j)
$
因此@target 成立!
===
#let h1 = $accent(h, tilde)$
设 $x_0$ 可使 $h1$ 取最小的的 $x$,不妨设 $x in [-1, 1]^n$。\
注意到:
$
I(x)/N(x) = (sum_({i, j} in E) abs(x_i - x_j)) / (min_(c in RR) sum_(i in V) d_i abs(x_i - c) )
$
上下齐次且分子分母都在平移下保持不变,因此可设 $x in [0,1]^n$\
取 $c in "median"_d (x)$,将有:
$
"vol"({i in V | x_i < c}) <= 1/2 "vol"(V)\
"vol"({i in V | x_i >= c}) <= 1/2 "vol"(V)
$
并设:
$
y = x - c
$
我们的目标是:
$
h1(x) = h1(y) = I(y)/N(y) = (I(y^+) + I(y^-))/(N(y^+) + N(y^-)) >= min(I(y^+)/N(y^+), I(y^-)/N(y^-)) >= h(G)
$
其中仅有第三个等号:
$
I(y)/N(y) = (I(y^+) + I(y^-))/(N(y^+) + N(y^-))
$
并不平凡,我们需要证明:
- $I(y) = I(y^+) + I(y^-)$
我们只需要逐项验证:
- $x_i x_j >= 0$ 时,$abs(x_i - x_j)$ 恰为 $abs(x_i^+ - x_j^+), abs(x_i^- - x_j^-)$ 其中之一(另一个是零)
- $x_i x_j < 0$,不妨设 $x_i > 0, x_j < 0$,则:
$
abs(x_i - x_j) = abs(x_i) + abs(x_j) = abs(x_i^+ - x_j^+) + abs(x_i^- - x_j^-)
$
表明 $abs(x_i - x_j) = abs(x_i^+ - x_j^+) + abs(x_i^- - x_j^-)$ 总是成立
- $N(y) = N(y^+) + N(y^-)$
注意到 $0 in "median"_d (y)$ 表明:
$
N(y) = sum_(i in V) d_i abs(y_i) = sum_({i in V | y_i >= 0}) d_i abs(y_i) + sum_({i in V | y_i < 0}) d_i abs(y_i) = N(y^+) + N(y^-)
$
得证
==
利用@convexity,这当然是凸函数。为了计算 $diff f(x_0)$,设:
$
forall x in RR^n, f(x) - f(x_0) >= g^T (x - x_0)
$
上式化简为:
$
h(A x + b) - h(A x_0 + b) >= g^T (x - x_0)
$<eq1>
任取 $t in diff h(A x_0 + b)$,有:
$
h(y) - h(A x_0 + b) >= t^T (y - A x_0 - b)
$<eq2>
- 设 $t in diff h(A x_0 + b)$,在@eq2 中取 $y = A x + b, g = A^T t$ 即得@eq1 恒成立,进而 $A^T t in diff f(x_0)$,故 $A^T diff h(A x_0 + b) subset diff f(x_0)$
- 反之,若 $x -> A x + b: RR^m -> RR^n$ 是满射,任取 $g = A^T t in diff f(x_0)$,有:
$
forall y = A x + b in RR^m, h(y) - h(A x_0 + b) >= (t^T) (y - A x_0 - b)
$
换言之 $t in A^T diff h(A x_0 + b) => diff f(x_0) subset A^T diff h(A x_0 + b)$
综上,当上述映射是满射(也即 $A$ 列满秩)时,有 $diff f(x_0) = A^T diff h(A x_0 + b)$
==
#let Sgn = $"Sgn"$
在三角形图中,有:
$
B = mat(0, 1, 1;-1, 0, 1;-1, -1, 0)\
B x = vec(x_2 + x_3, x_3 - x_1, -x_1 -x_2)\
B^T = mat(0, -1, -1;1, 0, -1;1, 1, 0)\
B^T Sgn(B x) = vec(Sgn(x_3 - x_1)+Sgn(x_1 + x_2), Sgn(x_3 + x_2)+Sgn(x_1 +x_2), Sgn(x_2 +x_3) + Sgn(x_3-x_1))\
mu D Sgn(x) = 2 mu vec(Sgn(x_1), Sgn(x_2), Sgn(x_3))
$
容易想到 Cheeger 问题的一个最优解为 $h = 1, x = vec(1, 0, 0)$,代入得:
$
B^T Sgn(B x) = vec(2, [0, 2], [0, 2])\
mu D Sgn(x) = 2 mu vec(1, [-1, 1], [-1,1])
$
显然可取 $mu = 2$ ,对应的一个特征向量为 $vec(1, 0, 0)$
= 3月13日
==
不太懂这里应该有什么“几何”的意义,比如某种意义上 $Delta_1 = 0$ 和 $Delta_2 = 0$ 都可以理解为某种“梯度”的“散度”稳定,或者说在每一点附近函数的变化率都在一定程度上稳定
==
===
#lemma[][
凸函数在有界闭凸集内的最大值可以在边界处取得
]
#proof[
如若不然,设 $x_0 in X$ 是凸函数 $f$ 在有界闭凸集 $X$ 内的最大值点,而 $x_0$ 不在 $X$ 的边界上,并且:
$
f(diff X) subset (-infinity, f(x_0))
$
此时 $x_0$ 是内点,不妨任取一个方向向量 $v$ 可设:
$
h(t) = x_0 + t v\
T = {t in [-infinity, +infinity] |h(t) subset X} = Inv(h)(X)
$
显然 $T$ 是闭集(由 $h$ 连续性)且有界(否则 $X$ 无界),因此可取:
$
t_0 = cases(
sup T quad abs(sup T) < abs(inf T),
inf T quad abs(sup T) >= abs(inf T)
)
$
这是为了保证 $x_0 plus.minus t v in X$,由凸性有:
$
1/2 (f(x_0 + t_0 v) + f(x_0 - t_0 v)) >= f(x_0)
$
注意到 $x_0$ 已经是最大值点,因此一定有:
$
f(x_0 + t_0 v) = f(x_0 - t_0 v) = f(x_0)
$
但 $x_0 plus.minus t v$ 至少有一个在边界上,矛盾!
]
回到目标,注意到:
$
f(x) = (I_p (x))/(2^(p-1) norm(x) "vol" V)
$
是齐次函数,因此:
$
max_(x in RR - {0} ) f(x)&= max_(abs(x) = 1) (I_p (x))/(2^(p-1) norm(x) "vol" V) \
&= max_(abs(x) = 1) (I_p (x))/(2^(p-1) "vol" V)\
&= 1/(2^(p-1) "vol" V) max_(abs(x) = 1) I_p (x)\
&= 1/(2^(p-1) "vol" V) max {max_(x in [-1, 1]^n quo [-1, 1]) I_p (x)|_(x_i = 1) | i in 1, 2, 3, ...,n}\
$
这里 $max_(x in [-1, 1]^n quo [-1, 1]) I_p (x)|_(x_i = 1)$ 就是如下的最大值问题:
$
max_(x' in [-1, 1]^(n-1)) I'(x')
$
由引理,它的最大值应该在边界处取得,也即至少一个 $x_i = 1$,进而:
$
max_(x' in [-1, 1]^(n-1)) I'(x') = max {max_(x' in [-1, 1]^(n-1) quo [-1, 1]) I' (x')|_(x_i = 1) | i in 1, 2, 3, ..., n-1}
$
归纳进行即得最大值 $I_p (x)$ 的最大值点 $x_0 in {-1, 1}^n$,因此:
$
max_(x in RR - {0} ) f(x)= max_(x in {-1, 1}^n)f(x)
$<eq11>
另一方面,容易计算得到:
$
h_(max) (G) = max_(x in {0, 1}^n) (I_p (x))/("vol" V)
$
定义一一映射:
$
phi: {0, 1} &<-> {-1,1}\
0 &<-> -1\
1 &<-> 1
$
将其广播得到的一一映射映射 ${0, 1}^n <-> {-1,1}^n$ 也记作 $phi$,容易验证:
$
I_p (x) = 1/2^(p-1) I_p (phi(x))
$
进而有:
$
max_(x in {0, 1}^n) (I_p (x))/("vol" V) = max_(phi(x) in {-1, 1}^n) (I_p (x))/("vol" V) = max_(phi(x) in {-1, 1}^n) (I_p (phi(x)))/(2^(p-1) "vol" V)
$
将 $phi(x)$ 换成 $x$ 结合@eq11 即得结论成立
===
熟知 $norm(x) = max abs(x_i)^p$ 作为若干凸函数的最大值仍是凸函数,因此仿照之前的理论我们希望:
$
diff I_p (x) sect mu diff norm(x) != emptyset
$
- 先计算 $diff I_p (x)$:
$
diff sum_({i, j} in E) abs(x_i - x_j)^p = p sum_({i, j} in E) abs(x_i - x_j)^(p-1) "Sgn"(x_i - x_j)
$
==
我们需要在 $pi = {x | norm(x) = 1}$ 上最大化 $f(x)$,也即希望:
$
diff I_p (x) sect mu norm(x) != emptyset
$
分别计算:
-
$
diff I_p (x) = p sum_({i, j} in E) abs(x_i - x_j)^(p-1) "Sgn"(x_i - x_j) (epsilon_i - epsilon_j)
$
-
#lemma[][
$
diff max(f, g) = 1/2 diff (abs(f + g) + abs(f - g)) = 1/2 "Sgn"(f + g)(diff f + diff g) + 1/2 "Sgn"(f - g) (diff f - diff g)
$
]
由引理,将有:(假设链式法则成立)
$
diff norm(x) = diff max{abs(x_i)^p} = p/2^n sum_(k in {1, -1}^n) "Sgn"(sum_(i in V) k_i abs(x_i)^p) (sum_(i in V) k_i abs(x_i)^(p-1) Sgn(x_i)epsilon_i) \
= sum_(i in V) (sum_(k in {1, -1}^n) "Sgn"(sum_(i in V) k_i abs(x_i)^p) (sum_(i in V) k_i abs(x_i)^(p-1) Sgn(x_i)))epsilon_i
$
|
|
https://github.com/herbhuang/utdallas-thesis-template-typst | https://raw.githubusercontent.com/herbhuang/utdallas-thesis-template-typst/main/content/abstract_en.typ | typst | MIT License | Note:
1. *paragraph:* What is the motivation of your thesis? Why is it interesting from a scientific point of view? Which main problem do you like to solve?
2. *paragraph:* What is the purpose of the document? What is the main content, the main contribution?
3. *paragraph:* What is your methodology? How do you proceed? |
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-0C00.typ | typst | Apache License 2.0 | #let data = (
("TELUGU SIGN COMBINING CANDRABINDU ABOVE", "Mn", 0),
("TELUGU SIGN CANDRABINDU", "Mc", 0),
("TELUGU SIGN ANUSVARA", "Mc", 0),
("TELUGU SIGN VISARGA", "Mc", 0),
("TELUGU SIGN COMBINING ANUSVARA ABOVE", "Mn", 0),
("TELUGU LETTER A", "Lo", 0),
("TELUGU LETTER AA", "Lo", 0),
("TELUGU LETTER I", "Lo", 0),
("TELUGU LETTER II", "Lo", 0),
("TELUGU LETTER U", "Lo", 0),
("TELUGU LETTER UU", "Lo", 0),
("TELUGU LETTER VOCALIC R", "Lo", 0),
("TELUGU LETTER VOCALIC L", "Lo", 0),
(),
("TELUGU LETTER E", "Lo", 0),
("TELUGU LETTER EE", "Lo", 0),
("TELUGU LETTER AI", "Lo", 0),
(),
("TELUGU LETTER O", "Lo", 0),
("TELUGU LETTER OO", "Lo", 0),
("TELUGU LETTER AU", "Lo", 0),
("TELUGU LETTER KA", "Lo", 0),
("TELUGU LETTER KHA", "Lo", 0),
("TELUGU LETTER GA", "Lo", 0),
("TELUGU LETTER GHA", "Lo", 0),
("TELUGU LETTER NGA", "Lo", 0),
("TELUGU LETTER CA", "Lo", 0),
("TELUGU LETTER CHA", "Lo", 0),
("TELUGU LETTER JA", "Lo", 0),
("TELUGU LETTER JHA", "Lo", 0),
("TELUGU LETTER NYA", "Lo", 0),
("TELUGU LETTER TTA", "Lo", 0),
("TELUGU LETTER TTHA", "Lo", 0),
("TELUGU LETTER DDA", "Lo", 0),
("TELUGU LETTER DDHA", "Lo", 0),
("TELUGU LETTER NNA", "Lo", 0),
("TELUGU LETTER TA", "Lo", 0),
("TELUGU LETTER THA", "Lo", 0),
("TELUGU LETTER DA", "Lo", 0),
("TELUGU LETTER DHA", "Lo", 0),
("TELUGU LETTER NA", "Lo", 0),
(),
("TELUGU LETTER PA", "Lo", 0),
("TELUGU LETTER PHA", "Lo", 0),
("TELUGU LETTER BA", "Lo", 0),
("TELUGU LETTER BHA", "Lo", 0),
("TELUGU LETTER MA", "Lo", 0),
("TELUGU LETTER YA", "Lo", 0),
("TELUGU LETTER RA", "Lo", 0),
("TELUGU LETTER RRA", "Lo", 0),
("TELUGU LETTER LA", "Lo", 0),
("TELUGU LETTER LLA", "Lo", 0),
("TELUGU LETTER LLLA", "Lo", 0),
("TELUGU LETTER VA", "Lo", 0),
("TELUGU LETTER SHA", "Lo", 0),
("TELUGU LETTER SSA", "Lo", 0),
("TELUGU LETTER SA", "Lo", 0),
("TELUGU LETTER HA", "Lo", 0),
(),
(),
("TELUGU SIGN NUKTA", "Mn", 7),
("TELUGU SIGN AVAGRAHA", "Lo", 0),
("TELUGU VOWEL SIGN AA", "Mn", 0),
("TELUGU VOWEL SIGN I", "Mn", 0),
("TELUGU VOWEL SIGN II", "Mn", 0),
("TELUGU VOWEL SIGN U", "Mc", 0),
("TELUGU VOWEL SIGN UU", "Mc", 0),
("TELUGU VOWEL SIGN VOCALIC R", "Mc", 0),
("TELUGU VOWEL SIGN VOCALIC RR", "Mc", 0),
(),
("TELUGU VOWEL SIGN E", "Mn", 0),
("TELUGU VOWEL SIGN EE", "Mn", 0),
("TELUGU VOWEL SIGN AI", "Mn", 0),
(),
("TELUGU VOWEL SIGN O", "Mn", 0),
("TELUGU VOWEL SIGN OO", "Mn", 0),
("TELUGU VOWEL SIGN AU", "Mn", 0),
("TELUGU SIGN VIRAMA", "Mn", 9),
(),
(),
(),
(),
(),
(),
(),
("TELUGU LENGTH MARK", "Mn", 84),
("TELUGU AI LENGTH MARK", "Mn", 91),
(),
("TELUGU LETTER TSA", "Lo", 0),
("TELUGU LETTER DZA", "Lo", 0),
("TELUGU LETTER RRRA", "Lo", 0),
(),
(),
("TELUGU LETTER NAKAARA POLLU", "Lo", 0),
(),
(),
("TELUGU LETTER VOCALIC RR", "Lo", 0),
("TELUGU LETTER VOCALIC LL", "Lo", 0),
("TELUGU VOWEL SIGN VOCALIC L", "Mn", 0),
("TELUGU VOWEL SIGN VOCALIC LL", "Mn", 0),
(),
(),
("TELUGU DIGIT ZERO", "Nd", 0),
("TELUGU DIGIT ONE", "Nd", 0),
("TELUGU DIGIT TWO", "Nd", 0),
("TELUGU DIGIT THREE", "Nd", 0),
("TELUGU DIGIT FOUR", "Nd", 0),
("TELUGU DIGIT FIVE", "Nd", 0),
("TELUGU DIGIT SIX", "Nd", 0),
("TELUGU DIGIT SEVEN", "Nd", 0),
("TELUGU DIGIT EIGHT", "Nd", 0),
("TELUGU DIGIT NINE", "Nd", 0),
(),
(),
(),
(),
(),
(),
(),
("TELUGU SIGN SIDDHAM", "Po", 0),
("TELUGU FRACTION DIGIT ZERO FOR ODD POWERS OF FOUR", "No", 0),
("TELUGU FRACTION DIGIT ONE FOR ODD POWERS OF FOUR", "No", 0),
("TELUGU FRACTION DIGIT TWO FOR ODD POWERS OF FOUR", "No", 0),
("TELUGU FRACTION DIGIT THREE FOR ODD POWERS OF FOUR", "No", 0),
("TELUGU FRACTION DIGIT ONE FOR EVEN POWERS OF FOUR", "No", 0),
("TELUGU FRACTION DIGIT TWO FOR EVEN POWERS OF FOUR", "No", 0),
("TELUGU FRACTION DIGIT THREE FOR EVEN POWERS OF FOUR", "No", 0),
("TELUGU SIGN TUUMU", "So", 0),
)
|
https://github.com/taooceros/CV | https://raw.githubusercontent.com/taooceros/CV/main/modules_en/projects.typ | typst | #import "@preview/brilliant-cv:2.0.2": cvSection, cvEntry, hBar
#let metadata = toml("../metadata.toml")
#let cvSection = cvSection.with(metadata: metadata)
#let cvEntry = cvEntry.with(metadata: metadata)
#cvSection("Miscellany")
#cvEntry(
title: [Advisor: <NAME>, <NAME>, <NAME>],
society: [Theory of Reinforcement Learning Seminar],
date: [Jun 2022 - Sep 2022],
location: [University of Wisconsin-Madison],
description: [
- Directed reading of _Reinforcement Learning: Theory and Algorithm_.
- Led chapter about theory behind Imitation Learning: algorithms to learn the behavior of expert.
],
)
#cvEntry(
title: [],
society: [VMAWalk],
date: [Sep 2020 - Jan 2021],
description: [
...
]
)
#cvEntry(
title: [],
society: [Quantum Random Walks],
date: [Sep 2023 - Present],
location: [University of Wisconsin-Madison],
description: [
- Explored the quantum random walks on the line and the cycle, and their connections to quantum algorithms.
],
tags: ([Quantum Information Theory], [Probability]),
)
#cvEntry(
title: [],
society: [Quantum Random Walks],
date: [Sep 2023 - Present],
location: [University of Wisconsin-Madison],
description: [
- Explored the quantum random walks on the line and the cycle, and their connections to quantum algorithms.
],
tags: ([Quantum Information Theory], [Probability]),
)
#cvEntry(
title: [],
society: [Distributed File System],
date: [Sep 2023 - Present],
location: [University of Wisconsin-Madison],
description: [
- Assumed a role within the Housing Advisor team, offering academic support to (mostly first year) residents' mathematical needs.
],
tags: ([C], [Operating Systems]),
)
|
|
https://github.com/rdboyes/resume | https://raw.githubusercontent.com/rdboyes/resume/main/modules_en/publications.typ | typst | // Imports
#import "@preview/brilliant-cv:2.0.2": cvSection, cvPublication
#let metadata = toml("../metadata.toml")
#let cvSection = cvSection.with(metadata: metadata)
#cvSection("Recent Publications")
#cvPublication(
bib: bibliography("../src/publications.bib"),
keyList: (
"wilde2024assessing",
"boyes2023physical",
"batsos2023development",
"harrison2022development"
),
refStyle: "apa",
)
|
|
https://github.com/19pdh/suplement-sprawnosci | https://raw.githubusercontent.com/19pdh/suplement-sprawnosci/master/README.md | markdown | # Suplement sprawności
Ładny suplement sprawności
## PDF:
```
TYPST_FONT_PATHS=fonts typst compile suplement.typ
# or just
./build.sh
```
|
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/math/linebreak_00.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Basic breaking after binop, rel
#let hrule(x) = box(line(length: x))
#hrule(45pt)$e^(pi i)+1 = 0$\
#hrule(55pt)$e^(pi i)+1 = 0$\
#hrule(70pt)$e^(pi i)+1 = 0$
|
https://github.com/Kasci/LiturgicalBooks | https://raw.githubusercontent.com/Kasci/LiturgicalBooks/master/CU/oktoich/1_generated/0_all/Hlas2.typ | typst | #import "../../../all.typ": *
#show: book
= #translation.at("HLAS") 2
#include "../Hlas2/0_Nedela.typ"
#pagebreak()
#include "../Hlas2/1_Pondelok.typ"
#pagebreak()
#include "../Hlas2/2_Utorok.typ"
#pagebreak()
#include "../Hlas2/3_Streda.typ"
#pagebreak()
#include "../Hlas2/4_Stvrtok.typ"
#pagebreak()
#include "../Hlas2/5_Piatok.typ"
#pagebreak()
#include "../Hlas2/6_Sobota.typ"
#pagebreak()
|
|
https://github.com/enseignantePC/2023-24 | https://raw.githubusercontent.com/enseignantePC/2023-24/master/detect.typ | typst | #let question_counter = counter("detect")
#let detect(
body: (counter, loc) => body,
add: (counter, loc) => [],
this_counter: none,
) = {
let question_counter = if this_counter != none { this_counter } else { question_counter }
question_counter.step()
locate(
loc => {
let body = body(question_counter, loc)
let str_counter = question_counter.at(loc).first()
let before_lab = label("before" + str(str_counter))
let after_lab = label("after" + str(str_counter))
let before_query = query(before_lab, loc)
let after_query = query(after_lab, loc)
if before_query.len() == 0 or after_query.len() == 0 {
[#[] #before_lab]
body
[#[] #after_lab]
} else if before_query.pop().location().page() < after_query.pop().location().page() {
add(question_counter, loc)
[#[] #before_lab]
body
[#[] #after_lab]
} else {
[#[] #before_lab]
body
[#[] #after_lab]
}
},
)
} |
|
https://github.com/soul667/typst | https://raw.githubusercontent.com/soul667/typst/main/PPT/MATLAB/touying/docs/docs/dynamic/handout.md | markdown | ---
sidebar_position: 5
---
# Handout Mode
While watching slides and attending lectures, the audience often wishes to have handouts for reviewing challenging concepts. Therefore, it's beneficial for the author to provide handouts for the audience, preferably before the lecture for better preparation.
The handout mode differs from the regular mode as it doesn't require intricate animation effects. It retains only the last subslide of each slide.
Enabling handout mode is simple:
```typst
#let s = (s.methods.enable-handout-mode)(self: s)
```
|
|
https://github.com/linhduongtuan/BKHN-Thesis_template_typst | https://raw.githubusercontent.com/linhduongtuan/BKHN-Thesis_template_typst/main/contents/acknowledgement.typ | typst | Apache License 2.0 | Khi tôi hoàn thành bài báo này, tôi muốn bày tỏ lòng biết ơn của tôi đến nhiều người.
Trước tiên, tôi xin cảm ơn cố vấn giảng dạy của tôi về những lời khuyên và hướng dẫn quý báu của anh ấy / cô ấy cho bài viết này. Tất cả sự hỗ trợ và hướng dẫn này đều rất vị tha và đã mang lại lợi ích to lớn cho tôi.
Thứ hai, tôi cũng xin gửi lời cảm ơn đến gia đình và bạn bè, những người đã luôn ủng hộ và động viên tôi trong suốt thời gian qua. Họ không ngừng cổ vũ, động viên tôi tiếp tục tiến lên, cảm ơn vì đã luôn ở bên, cho tôi hạnh phúc và sức mạnh.
Ngoài ra, em cũng xin gửi lời cảm ơn đến các bạn cùng lớp, những người đã cùng nhau trải qua một thời gian dài học tập, hỗ trợ, động viên nhau, cùng nhau tiến bộ. Vì sự hỗ trợ của bạn, tôi có thể tiếp tục phát triển và cải thiện.
Cuối cùng, tôi xin cảm ơn tất cả các tác giả, sự đón đọc và đánh giá của các bạn rất quan trọng đối với tôi, điều này cũng giúp tôi nhận ra những thiếu sót trong bài viết của mình, đồng thời hiểu rõ hơn về hướng nghiên cứu của mình. cảm ơn tất cả!
Một lần nữa tôi xin gửi lời cảm ơn và lòng biết ơn đến tất cả những người đã ủng hộ và động viên tôi.
Xác nhận này được tạo từ ChatGPT. |
https://github.com/alberto-lazari/computer-science | https://raw.githubusercontent.com/alberto-lazari/computer-science/main/advanced-topics-cs/quantum-algorithms/chapters/linear-systems.typ | typst | #import "/common.typ": *
= Linear systems solving
Linear systems can be solved by a quantum algorithm.
Given a linear system $A x = b, quad A in CC^(2^n times 2^n), b in CC^(2^n)$ \
The solution $x$ of the system is encoded in a quantum state $ket(psi)$ such that
$ mat(delim: "||", ket(psi) - ket("amp"(x))) lt.eq.slant epsilon $
For some precision parameter $epsilon > 0$.
$ket("amp"(x))$ is the amplitude encoding of the solution as a quantum state, equivalent to
$ ket("amp"(x))
:=
display(sum_(jstr in {0, 1}^n)) x_j / (||x||) ket(jstr)
=
mat(
x_1 \/||x||;
x_2 \/||x||;
dots.v;
x_(2^n - 1) \/||x||;
)
$
By encoding the result in a quantum state it cannot be immediately measured.
The algorithm is supposed to be used as a stepping stone for other operations, as there is no performance improvement over classical methods if the aim is to measure the solution.
|
|
https://github.com/frectonz/the-pg-book | https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/081.%20philosophy.html.typ | typst | philosophy.html
How to Do Philosophy
September 2007In high school I decided I was going to study philosophy in college.
I had several motives, some more honorable than others. One of the
less honorable was to shock people. College was regarded as job
training where I grew up, so studying philosophy seemed an impressively
impractical thing to do. Sort of like slashing holes in your clothes
or putting a safety pin through your ear, which were other forms
of impressive impracticality then just coming into fashion.But I had some more honest motives as well. I thought studying
philosophy would be a shortcut straight to wisdom. All the people
majoring in other things would just end up with a bunch of domain
knowledge. I would be learning what was really what.I'd tried to read a few philosophy books. Not recent ones; you
wouldn't find those in our high school library. But I tried to
read Plato and Aristotle. I doubt I believed I understood them,
but they sounded like they were talking about something important.
I assumed I'd learn what in college.The summer before senior year I took some college classes. I learned
a lot in the calculus class, but I didn't learn much in Philosophy
101. And yet my plan to study philosophy remained intact. It was
my fault I hadn't learned anything. I hadn't read the books we
were assigned carefully enough. I'd give Berkeley's Principles
of Human Knowledge another shot in college. Anything so admired
and so difficult to read must have something in it, if one could
only figure out what.Twenty-six years later, I still don't understand Berkeley. I have
a nice edition of his collected works. Will I ever read it? Seems
unlikely.The difference between then and now is that now I understand why
Berkeley is probably not worth trying to understand. I think I see
now what went wrong with philosophy, and how we might fix it.WordsI did end up being a philosophy major for most of college. It
didn't work out as I'd hoped. I didn't learn any magical truths
compared to which everything else was mere domain knowledge. But
I do at least know now why I didn't. Philosophy doesn't really
have a subject matter in the way math or history or most other
university subjects do. There is no core of knowledge one must
master. The closest you come to that is a knowledge of what various
individual philosophers have said about different topics over the
years. Few were sufficiently correct that people have forgotten
who discovered what they discovered.Formal logic has some subject matter. I took several classes in
logic. I don't know if I learned anything from them.
[1]
It does seem to me very important to be able to flip ideas around in
one's head: to see when two ideas don't fully cover the space of
possibilities, or when one idea is the same as another but with a
couple things changed. But did studying logic teach me the importance
of thinking this way, or make me any better at it? I don't know.There are things I know I learned from studying philosophy. The
most dramatic I learned immediately, in the first semester of
freshman year, in a class taught by Sydney Shoemaker. I learned
that I don't exist. I am (and you are) a collection of cells that
lurches around driven by various forces, and calls itself I. But
there's no central, indivisible thing that your identity goes with.
You could conceivably lose half your brain and live. Which means
your brain could conceivably be split into two halves and each
transplanted into different bodies. Imagine waking up after such
an operation. You have to imagine being two people.The real lesson here is that the concepts we use in everyday life
are fuzzy, and break down if pushed too hard. Even a concept as
dear to us as I. It took me a while to grasp this, but when I
did it was fairly sudden, like someone in the nineteenth century
grasping evolution and realizing the story of creation they'd been
told as a child was all wrong.
[2]
Outside of math there's a limit
to how far you can push words; in fact, it would not be a bad
definition of math to call it the study of terms that have precise
meanings. Everyday words are inherently imprecise. They work well
enough in everyday life that you don't notice. Words seem to work,
just as Newtonian physics seems to. But you can always make them
break if you push them far enough.I would say that this has been, unfortunately for philosophy, the
central fact of philosophy. Most philosophical debates are not
merely afflicted by but driven by confusions over words. Do we
have free will? Depends what you mean by "free." Do abstract ideas
exist? Depends what you mean by "exist."Wittgenstein is popularly credited with the idea that most philosophical
controversies are due to confusions over language. I'm not sure
how much credit to give him. I suspect a lot of people realized
this, but reacted simply by not studying philosophy, rather than
becoming philosophy professors.How did things get this way? Can something people have spent
thousands of years studying really be a waste of time? Those are
interesting questions. In fact, some of the most interesting
questions you can ask about philosophy. The most valuable way to
approach the current philosophical tradition may be neither to get
lost in pointless speculations like Berkeley, nor to shut them down
like Wittgenstein, but to study it as an example of reason gone
wrong.HistoryWestern philosophy really begins with Socrates, Plato, and Aristotle.
What we know of their predecessors comes from fragments and references
in later works; their doctrines could be described as speculative
cosmology that occasionally strays into analysis. Presumably they
were driven by whatever makes people in every other society invent
cosmologies.
[3]With Socrates, Plato, and particularly Aristotle, this tradition
turned a corner. There started to be a lot more analysis. I suspect
Plato and Aristotle were encouraged in this by progress in math.
Mathematicians had by then shown that you could figure things out
in a much more conclusive way than by making up fine sounding stories
about them.
[4]People talk so much about abstractions now that we don't realize
what a leap it must have been when they first started to. It was
presumably many thousands of years between when people first started
describing things as hot or cold and when someone asked "what is
heat?" No doubt it was a very gradual process. We don't know if
Plato or Aristotle were the first to ask any of the questions they
did. But their works are the oldest we have that do this on a large
scale, and there is a freshness (not to say naivete) about them
that suggests some of the questions they asked were new to them,
at least.Aristotle in particular reminds me of the phenomenon that happens
when people discover something new, and are so excited by it that
they race through a huge percentage of the newly discovered territory
in one lifetime. If so, that's evidence of how new this kind of
thinking was.
[5]This is all to explain how Plato and Aristotle can be very impressive
and yet naive and mistaken. It was impressive even to ask the
questions they did. That doesn't mean they always came up with
good answers. It's not considered insulting to say that ancient
Greek mathematicians were naive in some respects, or at least lacked
some concepts that would have made their lives easier. So I hope
people will not be too offended if I propose that ancient philosophers
were similarly naive. In particular, they don't seem to have fully
grasped what I earlier called the central fact of philosophy: that
words break if you push them too far."Much to the surprise of the builders of the first digital computers,"
<NAME> wrote, "programs written for them usually did not work."
[6]
Something similar happened when people first started trying
to talk about abstractions. Much to their surprise, they didn't
arrive at answers they agreed upon. In fact, they rarely seemed
to arrive at answers at all.They were in effect arguing about artifacts induced by sampling at
too low a resolution.The proof of how useless some of their answers turned out to be is
how little effect they have. No one after reading Aristotle's
Metaphysics does anything differently as a result.
[7]Surely I'm not claiming that ideas have to have practical applications
to be interesting? No, they may not have to. Hardy's boast that
number theory had no use whatsoever wouldn't disqualify it. But
he turned out to be mistaken. In fact, it's suspiciously hard to
find a field of math that truly has no practical use. And Aristotle's
explanation of the ultimate goal of philosophy in Book A of the
Metaphysics implies that philosophy should be useful too.Theoretical KnowledgeAristotle's goal was to find the most general of general principles.
The examples he gives are convincing: an ordinary worker builds
things a certain way out of habit; a master craftsman can do more
because he grasps the underlying principles. The trend is clear:
the more general the knowledge, the more admirable it is. But then
he makes a mistake—possibly the most important mistake in the
history of philosophy. He has noticed that theoretical knowledge
is often acquired for its own sake, out of curiosity, rather than
for any practical need. So he proposes there are two kinds of
theoretical knowledge: some that's useful in practical matters and
some that isn't. Since people interested in the latter are interested
in it for its own sake, it must be more noble. So he sets as his
goal in the Metaphysics the exploration of knowledge that has no
practical use. Which means no alarms go off when he takes on grand
but vaguely understood questions and ends up getting lost in a sea
of words.His mistake was to confuse motive and result. Certainly, people
who want a deep understanding of something are often driven by
curiosity rather than any practical need. But that doesn't mean
what they end up learning is useless. It's very valuable in practice
to have a deep understanding of what you're doing; even if you're
never called on to solve advanced problems, you can see shortcuts
in the solution of simple ones, and your knowledge won't break down
in edge cases, as it would if you were relying on formulas you
didn't understand. Knowledge is power. That's what makes theoretical
knowledge prestigious. It's also what causes smart people to be
curious about certain things and not others; our DNA is not so
disinterested as we might think.So while ideas don't have to have immediate practical applications
to be interesting, the kinds of things we find interesting will
surprisingly often turn out to have practical applications.The reason Aristotle didn't get anywhere in the Metaphysics was
partly that he set off with contradictory aims: to explore the most
abstract ideas, guided by the assumption that they were useless.
He was like an explorer looking for a territory to the north of
him, starting with the assumption that it was located to the south.And since his work became the map used by generations of future
explorers, he sent them off in the wrong direction as well.
[8]
Perhaps worst of all, he protected them from both the criticism of
outsiders and the promptings of their own inner compass by establishing
the principle that the most noble sort of theoretical knowledge had
to be useless.The Metaphysics is mostly a failed experiment. A few ideas from
it turned out to be worth keeping; the bulk of it has had no effect
at all. The Metaphysics is among the least read of all famous
books. It's not hard to understand the way Newton's Principia
is, but the way a garbled message is.Arguably it's an interesting failed experiment. But unfortunately
that was not the conclusion Aristotle's successors derived from
works like the Metaphysics.
[9]
Soon after, the western world
fell on intellectual hard times. Instead of version 1s to be
superseded, the works of Plato and Aristotle became revered texts
to be mastered and discussed. And so things remained for a shockingly
long time. It was not till around 1600 (in Europe, where the center
of gravity had shifted by then) that one found people confident
enough to treat Aristotle's work as a catalog of mistakes. And
even then they rarely said so outright.If it seems surprising that the gap was so long, consider how little
progress there was in math between Hellenistic times and the
Renaissance.In the intervening years an unfortunate idea took hold: that it
was not only acceptable to produce works like the Metaphysics,
but that it was a particularly prestigious line of work, done by a
class of people called philosophers. No one thought to go back and
debug Aristotle's motivating argument. And so instead of correcting
the problem Aristotle discovered by falling into it—that you can
easily get lost if you talk too loosely about very abstract ideas—they
continued to fall into it.The SingularityCuriously, however, the works they produced continued to attract
new readers. Traditional philosophy occupies a kind of singularity
in this respect. If you write in an unclear way about big ideas,
you produce something that seems tantalizingly attractive to
inexperienced but intellectually ambitious students. Till one knows
better, it's hard to distinguish something that's hard to understand
because the writer was unclear in his own mind from something like
a mathematical proof that's hard to understand because the ideas
it represents are hard to understand. To someone who hasn't learned
the difference, traditional philosophy seems extremely attractive:
as hard (and therefore impressive) as math, yet broader in scope.
That was what lured me in as a high school student.This singularity is even more singular in having its own defense
built in. When things are hard to understand, people who suspect
they're nonsense generally keep quiet. There's no way to prove a
text is meaningless. The closest you can get is to show that the
official judges of some class of texts can't distinguish them from
placebos.
[10]And so instead of denouncing philosophy, most people who suspected
it was a waste of time just studied other things. That alone is
fairly damning evidence, considering philosophy's claims. It's
supposed to be about the ultimate truths. Surely all smart people
would be interested in it, if it delivered on that promise.Because philosophy's flaws turned away the sort of people who might
have corrected them, they tended to be self-perpetuating. <NAME> wrote in a letter in 1912:
Hitherto the people attracted to philosophy have been mostly those
who loved the big generalizations, which were all wrong, so that
few people with exact minds have taken up the subject.
[11]
His response was to launch Wittgenstein at it, with dramatic results.I think Wittgenstein deserves to be famous not for the discovery
that most previous philosophy was a waste of time, which judging
from the circumstantial evidence must have been made by every smart
person who studied a little philosophy and declined to pursue it
further, but for how he acted in response.
[12]
Instead of quietly
switching to another field, he made a fuss, from inside. He was
Gorbachev.The field of philosophy is still shaken from the fright Wittgenstein
gave it.
[13]
Later in life he spent a lot of time talking about
how words worked. Since that seems to be allowed, that's what a
lot of philosophers do now. Meanwhile, sensing a vacuum in the
metaphysical speculation department, the people who used to do
literary criticism have been edging Kantward, under new names like
"literary theory," "critical theory," and when they're feeling
ambitious, plain "theory." The writing is the familiar word salad:
Gender is not like some of the other grammatical modes which
express precisely a mode of conception without any reality that
corresponds to the conceptual mode, and consequently do not express
precisely something in reality by which the intellect could be
moved to conceive a thing the way it does, even where that motive
is not something in the thing as such.
[14]
The singularity I've described is not going away. There's a market
for writing that sounds impressive and can't be disproven. There
will always be both supply and demand. So if one group abandons
this territory, there will always be others ready to occupy it.A ProposalWe may be able to do better. Here's an intriguing possibility.
Perhaps we should do what Aristotle meant to do, instead of what
he did. The goal he announces in the Metaphysics seems one worth
pursuing: to discover the most general truths. That sounds good.
But instead of trying to discover them because they're useless,
let's try to discover them because they're useful.I propose we try again, but that we use that heretofore despised
criterion, applicability, as a guide to keep us from wondering
off into a swamp of abstractions. Instead of trying to answer the
question:
What are the most general truths?
let's try to answer the question
Of all the useful things we can say, which are the most general?
The test of utility I propose is whether we cause people who read
what we've written to do anything differently afterward. Knowing
we have to give definite (if implicit) advice will keep us from
straying beyond the resolution of the words we're using.The goal is the same as Aristotle's; we just approach it from a
different direction.As an example of a useful, general idea, consider that of the
controlled experiment. There's an idea that has turned out to be
widely applicable. Some might say it's part of science, but it's
not part of any specific science; it's literally meta-physics (in
our sense of "meta"). The idea of evolution is another. It turns
out to have quite broad applications—for example, in genetic
algorithms and even product design. Frankfurt's distinction between
lying and bullshitting seems a promising recent example.
[15]These seem to me what philosophy should look like: quite general
observations that would cause someone who understood them to do
something differently.Such observations will necessarily be about things that are imprecisely
defined. Once you start using words with precise meanings, you're
doing math. So starting from utility won't entirely solve the
problem I described above—it won't flush out the metaphysical
singularity. But it should help. It gives people with good
intentions a new roadmap into abstraction. And they may thereby
produce things that make the writing of the people with bad intentions
look bad by comparison.One drawback of this approach is that it won't produce the sort of
writing that gets you tenure. And not just because it's not currently
the fashion. In order to get tenure in any field you must not
arrive at conclusions that members of tenure committees can disagree
with. In practice there are two kinds of solutions to this problem.
In math and the sciences, you can prove what you're saying, or at
any rate adjust your conclusions so you're not claiming anything
false ("6 of 8 subjects had lower blood pressure after the treatment").
In the humanities you can either avoid drawing any definite conclusions
(e.g. conclude that an issue is a complex one), or draw conclusions
so narrow that no one cares enough to disagree with you.The kind of philosophy I'm advocating won't be able to take either
of these routes. At best you'll be able to achieve the essayist's
standard of proof, not the mathematician's or the experimentalist's.
And yet you won't be able to meet the usefulness test without
implying definite and fairly broadly applicable conclusions. Worse
still, the usefulness test will tend to produce results that annoy
people: there's no use in telling people things they already believe,
and people are often upset to be told things they don't.Here's the exciting thing, though. Anyone can do this. Getting
to general plus useful by starting with useful and cranking up the
generality may be unsuitable for junior professors trying to get
tenure, but it's better for everyone else, including professors who
already have it. This side of the mountain is a nice gradual slope.
You can start by writing things that are useful but very specific,
and then gradually make them more general. Joe's has good burritos.
What makes a good burrito? What makes good food? What makes
anything good? You can take as long as you want. You don't have
to get all the way to the top of the mountain. You don't have to
tell anyone you're doing philosophy.If it seems like a daunting task to do philosophy, here's an
encouraging thought. The field is a lot younger than it seems.
Though the first philosophers in the western tradition lived about
2500 years ago, it would be misleading to say the field is 2500
years old, because for most of that time the leading practitioners
weren't doing much more than writing commentaries on Plato or
Aristotle while watching over their shoulders for the next invading
army. In the times when they weren't, philosophy was hopelessly
intermingled with religion. It didn't shake itself free till a
couple hundred years ago, and even then was afflicted by the
structural problems I've described above. If I say this, some will
say it's a ridiculously overbroad and uncharitable generalization,
and others will say it's old news, but here goes: judging from their
works, most philosophers up to the present have been wasting their
time. So in a sense the field is still at the first step.
[16]That sounds a preposterous claim to make. It won't seem so
preposterous in 10,000 years. Civilization always seems old, because
it's always the oldest it's ever been. The only way to say whether
something is really old or not is by looking at structural evidence,
and structurally philosophy is young; it's still reeling from the
unexpected breakdown of words.Philosophy is as young now as math was in 1500. There is a lot
more to discover.Notes
[1]
In practice formal logic is not much use, because despite
some progress in the last 150 years we're still only able to formalize
a small percentage of statements. We may never do that much better,
for the same reason 1980s-style "knowledge representation" could
never have worked; many statements may have no representation more
concise than a huge, analog brain state.[2]
It was harder for Darwin's contemporaries to grasp this than
we can easily imagine. The story of creation in the Bible is not
just a Judeo-Christian concept; it's roughly what everyone must
have believed since before people were people. The hard part of
grasping evolution was to realize that species weren't, as they
seem to be, unchanging, but had instead evolved from different,
simpler organisms over unimaginably long periods of time.Now we don't have to make that leap. No one in an industrialized
country encounters the idea of evolution for the first time as an
adult. Everyone's taught about it as a child, either as truth or
heresy.[3]
Greek philosophers before Plato wrote in verse. This must
have affected what they said. If you try to write about the nature
of the world in verse, it inevitably turns into incantation. Prose
lets you be more precise, and more tentative.[4]
Philosophy is like math's
ne'er-do-well brother. It was born when Plato and Aristotle looked
at the works of their predecessors and said in effect "why can't
you be more like your brother?" Russell was still saying the same
thing 2300 years later.Math is the precise half of the most abstract ideas, and philosophy
the imprecise half. It's probably inevitable that philosophy will
suffer by comparison, because there's no lower bound to its precision.
Bad math is merely boring, whereas bad philosophy is nonsense. And
yet there are some good ideas in the imprecise half.[5]
Aristotle's best work was in logic and zoology, both of which
he can be said to have invented. But the most dramatic departure
from his predecessors was a new, much more analytical style of
thinking. He was arguably the first scientist.[6]
<NAME>, Programming in Common Lisp, Wiley, 1985, p.
94.[7]
Some would say we depend on Aristotle more than we realize,
because his ideas were one of the ingredients in our common culture.
Certainly a lot of the words we use have a connection with Aristotle,
but it seems a bit much to suggest that we wouldn't have the concept
of the essence of something or the distinction between matter and
form if Aristotle hadn't written about them.One way to see how much we really depend on Aristotle would be to
diff European culture with Chinese: what ideas did European culture
have in 1800 that Chinese culture didn't, in virtue of Aristotle's
contribution?[8]
The meaning of the word "philosophy" has changed over time.
In ancient times it covered a broad range of topics, comparable in
scope to our "scholarship" (though without the methodological
implications). Even as late as Newton's time it included what we
now call "science." But core of the subject today is still what
seemed to Aristotle the core: the attempt to discover the most
general truths.Aristotle didn't call this "metaphysics." That name got assigned
to it because the books we now call the Metaphysics came after
(meta = after) the Physics in the standard edition of Aristotle's
works compiled by Andronicus of Rhodes three centuries later. What
we call "metaphysics" Aristotle called "first philosophy."[9]
Some of Aristotle's immediate successors may have realized
this, but it's hard to say because most of their works are lost.[10]
Sokal, Alan, "Transgressing the Boundaries: Toward a Transformative
Hermeneutics of Quantum Gravity," Social Text 46/47, pp. 217-252.Abstract-sounding nonsense seems to be most attractive when it's
aligned with some axe the audience already has to grind. If this
is so we should find it's most popular with groups that are (or
feel) weak. The powerful don't need its reassurance.[11]
Letter to <NAME>, December 1912. Quoted in:<NAME>, Ludwig Wittgenstein: The Duty of Genius, Penguin, 1991,
p. 75.[12]
A preliminary result, that all metaphysics between Aristotle
and 1783 had been a waste of time, is due to I. Kant.[13]
Wittgenstein asserted a sort of mastery to which the inhabitants
of early 20th century Cambridge seem to have been peculiarly
vulnerable—perhaps partly because so many had been raised religious
and then stopped believing, so had a vacant space in their heads
for someone to tell them what to do (others chose Marx or Cardinal
Newman), and partly because a quiet, earnest place like Cambridge
in that era had no natural immunity to messianic figures, just as
European politics then had no natural immunity to dictators.[14]
This is actually from the Ordinatio of Duns Scotus (ca.
1300), with "number" replaced by "gender." Plus ca change.<NAME> (trans), Duns Scotus: Philosophical Writings, Nelson,
1963, p. 92.[15]
Frankfurt, Harry, On Bullshit, Princeton University Press,
2005.[16]
Some introductions to philosophy now take the line that
philosophy is worth studying as a process rather than for any
particular truths you'll learn. The philosophers whose works they
cover would be rolling in their graves at that. They hoped they
were doing more than serving as examples of how to argue: they hoped
they were getting results. Most were wrong, but it doesn't seem
an impossible hope.This argument seems to me like someone in 1500 looking at the lack
of results achieved by alchemy and saying its value was as a process.
No, they were going about it wrong. It turns out it is possible
to transmute lead into gold (though not economically at current
energy prices), but the route to that knowledge was to
backtrack and try another approach.Thanks to <NAME>, <NAME>, <NAME>,
<NAME>, <NAME>, and <NAME> for reading drafts of this.French Translation
|
|
https://github.com/LegNeato/mdbook-typst | https://raw.githubusercontent.com/LegNeato/mdbook-typst/main/README.md | markdown | # `mdbook-typst`
`mdbook-typst` is a
[backend](https://rust-lang.github.io/mdBook/for_developers/backends.html) for
[mdBook]. The backend converts the book to
[Typst] markup and can output any format Typst can (currently
`pdf`, `png`, `svg`, and raw Typst markup).
## Usage
First, install the Typst cli:
```sh
cargo install --git https://github.com/typst/typst
```
Next, install `mdbook-typst` (this project):
```sh
cargo install mdbook-typst
```
Then, add an entry to your
[book.toml]:
```toml
[output.typst]
```
Finally, build your book via mdBook:
```sh
mdbook build
```
By default `mdbook-typst` will output raw Typst markup to `book/typst/book.typst`.
## Pdf and other formats
Pdf and other formats can be output instead of raw Typst markup. In your [book.toml] set the `format` value of the `output` config section:
```toml
[output.typst.output]
format = "pdf"
```
By default `mdbook-typst` will output to `book/typst/book.[format]`.
## Other configuration
`mdbook-typst` is fairly configurable. Check out [the configuration
code](./src/config.rs) for a complete list of options.
If you want more control, consider creating your own formatter and/or preprocessing the
book using the [pullup](https://github.com/LegNeato/pullup) project.
[mdBook]: https://github.com/rust-lang/mdBook
[book.toml]: https://rust-lang.github.io/mdBook/guide/creating.html#booktoml
[Typst]: https://typst.app/docs/
|
|
https://github.com/tony-rsa/thonifho.muhali.cv | https://raw.githubusercontent.com/tony-rsa/thonifho.muhali.cv/main/src/sections/en/skills.typ | typst | MIT License | #import "../../template.typ": *
#cvSection("Skills")
#cvSkill(
type: [Technologies],
info: [#techSkills],
)
#cvSkill(
type: [Languages],
info: [English (fluent) #hBar() Russian (native)],
)
|
https://github.com/TJ-CSCCG/tongji-undergrad-thesis-typst | https://raw.githubusercontent.com/TJ-CSCCG/tongji-undergrad-thesis-typst/main/fonts/README.md | markdown | MIT License | # fonts
请到本仓库的 [`fonts`](https://github.com/TJ-CSCCG/tongji-undergrad-thesis-typst/tree/fonts) 分支下载字体文件。
本仓库的字体文件仅供学习目的使用。 请遵守相关法律法规,不要将字体文件用于商业用途或非法用途。作者不对因使用本字体文件而产生的任何问题负责。
Please download the font files from the [`fonts`](https://github.com/TJ-CSCCG/tongji-undergrad-thesis-typst/tree/fonts) branch of this repository.
The font files in this repository are for learning purposes only. Please comply with relevant laws and regulations and do not use the font files for commercial or illegal purposes. The author is not responsible for any issues arising from the use of these font files.
|
https://github.com/Toniolo-Marco/git-for-dummies | https://raw.githubusercontent.com/Toniolo-Marco/git-for-dummies/main/slides/practice/branch.typ | typst | #import "@preview/touying:0.5.2": *
#import themes.university: *
#import "@preview/numbly:0.1.0": numbly
#import "@preview/fletcher:0.5.1" as fletcher: node, edge
#let fletcher-diagram = touying-reducer.with(reduce: fletcher.diagram, cover: fletcher.hide)
#import "../components/gh-button.typ": gh_button
#import "../components/git-graph.typ": branch_indicator, commit_node, connect_nodes, branch
#import "../components/utils.typ": rainbow
#import "../components/thmbox.typ": custom-box, alert-box
=== Creating a New Branch
To create a new branch, we can use the command: `git switch -c <new-branch> [<start-point>]`.
#footnote([By `[start-point]` we mean the commit hash to start from; square brackets indicate that it is optional.])
This command creates a new branch and moves us to it.
Alternatively we can use the commands: `git checkout -b <new_branch> [<start_point>]` or `git branch <new_branch> [<start_point>]`.
#footnote([The last option will not automatically move us to the new branch.])
=== Deleting a Branch in Local
To delete a branch, we can use the command: `git branch -d <branch-name>`.
#footnote([To force the deletion of a branch, use the `-D` option instead of `-d`. This option will delete the branch regardless of state.])
---
=== Renaming a Branch
Picking up right away on the suggestion received from GitHub in the @init[Slide] the command:
`git branch -M main` is optional, it simply *renames* the default branch as _main_ instead of _master_; *it is up to you to choose* whether to run this command by renaming it. The same command can be used to rename any branch.
Github has switched their default branch name to _main_, to make sure the world knew they were a #rainbow[slave free organization.]
---
=== Moving between Branches
To move to a different branch, simply use the command: `git switch <branch-name>` or `git checkout <branch-name>`.
#align(center)[
#scale(100%)[
#set text(11pt)
#fletcher-diagram(
node-stroke: .1em,
node-fill: none,
spacing: 4em,
mark-scale: 50%,
branch(
name:"main",
color:blue,
start:(0,0),
length:5,
head:4
),
// edge((5,0),(6,0),"--",stroke:2pt+blue),
// //... other commits
// develop branch
connect_nodes((1,0),(2,1),orange),
branch(
name:"develop",
indicator-xy:(7,1),
color:orange,
start:(1,1),
length:5,
)
)
]
]
#pause
#align(center)[
#scale(100%)[
#set text(11pt)
#fletcher-diagram(
node-stroke: .1em,
node-fill: none,
spacing: 4em,
mark-scale: 50%,
branch(
name:"main",
color:blue,
start:(0,0),
length:5
),
// develop branch
connect_nodes((1,0),(2,1),orange),
branch(
name:"develop",
indicator-xy:(7,1),
color:orange,
start:(1,1),
length:5,
head:4
),
edge((5,0),(6,1),label:[HEAD],"-->",mark-scale:500%,bend:40deg)
)
]
]
---
=== HEAD
Before continuing with the explanation, it is important to better understand concept of HEAD.#footnote([In the previous graph, the HEAD is represented by the commit with the circle completely filled.])
#custom-box(title:"HEAD")[
The _HEAD_ is a *pointer* that *points to the current commit* and consecutively the contents of the working directory.
]
So, what we get is that the HEAD will move to the commit related to the selected branch. For example we are on the _main_ branch and we wanted to move to the _develop_ branch, the command would be: `git switch develop` or `git checkout develop`.
---
=== Move between commits
We can *move to a specific commit* too, with the command: `git switch <commit-hash>` or `git checkout <commit-hash>`. This command will cause a state called _detached HEAD_.
#footnote([Every repository has its own HEAD, including remotes. The commit that the HEAD points to in the remotes is the last commit of the main branch (usually _main_); and it is also what you see on the repository web page.])
#grid(columns:2, rows:2, column-gutter: 10%,
custom-box(title:"Detached Head")[
The detached HEAD is a state in which the HEAD does not point to any branch, but directly to a commit.
],
grid.cell(rowspan: 2,
image("/slides/img/meme/detached-head.png", width: 70%)),
alert-box(title:"Warning")[
This means that if we create a new commit in this state, it will not be added to any branch and may be lost.
]
)
#include "../animations/detached-head.typ"
=== Move Branch to a Commit
So far we have always imagined a branch as a like an entire commit line, *in reality* a *branch is* nothing more than *a label associated with a specific commit*.
This is why we can move a branch to another commit with the command `git branch --force <branch-name> [<new-tip-commit>]`.
This is why some graphs or some plugins represent, not only each branch with different color, but also the label of the branch next to the commit itself:
#align(center)[
#scale(95%)[
#set text(10pt)
#fletcher-diagram(
node-stroke: .1em,
node-fill: none,
spacing: 4em,
mark-scale: 50%,
branch( // main branch
name:"main",
indicator-xy:(5.5,1),
color:blue,
start:(0,1),
length:5,
),
connect_nodes((3,1),(4,2),orange),
branch( // develop branch
name:"develop",
indicator-xy:(7.75,1.5),
color:orange,
start:(3,2),
length:5,
),
connect_nodes((3,0),(2,1),red),
branch(// detached HEAD commits
color: red,
start:(2,0),
length:3,
head:2,
)
)
]
]
|
|
https://github.com/TechnoElf/mqt-qcec-diff-thesis | https://raw.githubusercontent.com/TechnoElf/mqt-qcec-diff-thesis/main/content/benchmarks.typ | typst | #import "@preview/cetz:0.2.2": canvas, plot, chart, styles, draw, palette
#import "@preview/tablex:0.0.8": tablex
#import "@preview/unify:0.6.0": qty
#let unclip(res) = {
res.filter(r => not r.clipped).enumerate().map(((i, r)) => {
r.i = i
r
})
}
#let sort-by-circuit-size(res) = {
res.sorted(key: r => r.total-circuit-size).enumerate().map(((i, r)) => {
r.i = i
r
})
}
#let filter(res) = {
res.filter(r => r.equivalence-rate > 0.35).enumerate().map(((i, r)) => {
r.i = i
r
})
}
#let filter-rev(res) = {
res.filter(r => r.equivalence-rate-rev > 0.35).enumerate().map(((i, r)) => {
r.i = i
r
})
}
#let results-r1-b5q16-cprop = csv("../resources/results-r1-b5q16-cprop-smc.csv", row-type: dictionary)
#let results-r1-b5q16-cmyersrev-pmismc = csv("../resources/results-r1-b5q16-cmyersrev-pmismc-smc.csv", row-type: dictionary)
#let results-r1-b5q16-cmyersrev-p = csv("../resources/results-r1-b5q16-cmyersrev-p-smc.csv", row-type: dictionary)
#let results-r1-b5q16-cmyers-p = csv("../resources/results-r1-b5q16-cmyers-p-smc.csv", row-type: dictionary)
#let results-r1-b5q16-cpatience-p = csv("../resources/results-r1-b5q16-cpatience-p-smc.csv", row-type: dictionary)
#let results-r1-b5q16-cmyers-pmismc = csv("../resources/results-r1-b5q16-cmyers-pmismc-smc.csv", row-type: dictionary)
#let results-r1-b5q16 = results-r1-b5q16-cprop.enumerate().map(((i, r)) => {
let cmyersrev-pmismc = results-r1-b5q16-cmyersrev-pmismc.find(r2 => r2.name == r.name)
let cmyersrev-p = results-r1-b5q16-cmyersrev-p.find(r2 => r2.name == r.name)
let cmyers-p = results-r1-b5q16-cmyers-p.find(r2 => r2.name == r.name)
let cmyers-pmismc = results-r1-b5q16-cmyers-pmismc.find(r2 => r2.name == r.name)
let cpatience-p = results-r1-b5q16-cpatience-p.find(r2 => r2.name == r.name)
let num-gates-1 = float(r.numGates1)
let num-gates-2 = float(r.numGates2)
let total-circuit-size = num-gates-1 + num-gates-2
(
name: r.name,
i: i,
clipped: not ((r.finished == "true") and (cmyersrev-pmismc.finished == "true") and (cmyersrev-p.finished == "true") and (cmyers-pmismc.finished == "true") and (cmyers-p.finished == "true")),
total-circuit-size: total-circuit-size,
circuit-size-difference: calc.abs(num-gates-1 - num-gates-2),
equivalence-rate: float(cmyers-pmismc.diffEquivalenceCount) / total-circuit-size,
equivalence-rate-rev: float(cmyersrev-pmismc.diffEquivalenceCount) / total-circuit-size,
cprop: (
mu: float(r.runTimeMean)
),
cmyersrev-pmismc: (
mu: float(cmyersrev-pmismc.runTimeMean)
),
cmyersrev-p: (
mu: float(cmyersrev-p.runTimeMean)
),
cmyers-p: (
mu: float(cmyers-p.runTimeMean)
),
cmyers-pmismc: (
mu: float(cmyers-pmismc.runTimeMean)
),
cpatience-p: (
mu: float(cpatience-p.runTimeMean)
),
)
})
#let results-r1-b5q16-hist = {
let min = calc.log(0.001)
let max = calc.log(20)
let bins = 15
let bins-mu = range(bins + 1).map(x => calc.pow(10, min + x * (max - min) / bins))
let cprop-mu = bins-mu.slice(1).map(_ => 0)
let cmyersrev-pmismc-mu = bins-mu.slice(1).map(_ => 0)
let cmyersrev-p-mu = bins-mu.slice(1).map(_ => 0)
let cmyers-p-mu = bins-mu.slice(1).map(_ => 0)
let cmyers-pmismc-mu = bins-mu.slice(1).map(_ => 0)
let cpatience-p-mu = bins-mu.slice(1).map(_ => 0)
for r in unclip(results-r1-b5q16) {
for b in range(bins) {
if bins-mu.at(b) <= r.cprop.mu and r.cprop.mu < bins-mu.at(b + 1) {
cprop-mu.at(b) += 1
}
if bins-mu.at(b) <= r.cmyersrev-pmismc.mu and r.cmyersrev-pmismc.mu < bins-mu.at(b + 1) {
cmyersrev-pmismc-mu.at(b) += 1
}
if bins-mu.at(b) <= r.cmyersrev-p.mu and r.cmyersrev-p.mu < bins-mu.at(b + 1) {
cmyersrev-p-mu.at(b) += 1
}
if bins-mu.at(b) <= r.cmyers-p.mu and r.cmyers-p.mu < bins-mu.at(b + 1) {
cmyers-p-mu.at(b) += 1
}
if bins-mu.at(b) <= r.cmyers-pmismc.mu and r.cmyers-pmismc.mu < bins-mu.at(b + 1) {
cmyers-pmismc-mu.at(b) += 1
}
if bins-mu.at(b) <= r.cpatience-p.mu and r.cpatience-p.mu < bins-mu.at(b + 1) {
cpatience-p-mu.at(b) += 1
}
}
}
let scientific(val) = {
let exp = calc.floor(calc.log(val))
[$#(calc.round(val / calc.pow(10, exp), digits: 2)) dot 10 ^ #exp$]
}
(
bins-mu: bins-mu.slice(0, -1).zip(bins-mu.slice(1)).map(((s, e)) => [$<$ #scientific(e)]),
cprop: (
mu: cprop-mu
),
cmyersrev-pmismc: (
mu: cmyersrev-pmismc-mu
),
cmyersrev-p: (
mu: cmyersrev-p-mu
),
cmyers-p: (
mu: cmyers-p-mu
),
cmyers-pmismc: (
mu: cmyers-pmismc-mu
),
cpatience-p: (
mu: cpatience-p-mu
)
)
}
= Benchmarks
This section presents the results of applying the implemented @qcec application scheme on practical problems.
The focus herein lies on the performance in terms of run time of the methodology compared to previous approaches, as the accuracy is already guaranteed by the @dd\-based equivalence checking method.
First, the test cases used will be listed and justified.
Next, the environment which was used to perform the benchmarks will be elaborated.
Finally, the quantitative results will be presented and interpreted.
== Test Cases
To generate test cases for the application schemes discussed in the implementation section, @mqt Bench was used @quetschlich2023mqtbench.
A subset of the available circuits was generated using the python package of @mqt Bench at version 1.1.3.
Implementations of the Deutsch-Jozsa @deutsch1992quantum, Portfolio Optimization with QAOA @hodson2019qaoa, Portfolio Optimization with VQE @peruzzo2014vqe, Quantum Fourier Transformation @coppersmith2002qft, and Quantum Neural Network @purushothaman1997qnn benchmarks were generated using 4, 8, and 16 qubits.
Each implementation was compiled using Qiskit for the IBM Eagle target (named IBM Washington in @mqt Bench) @chow2021eagle with optimisation levels 0 and 3.
There are therefore 5 different versions of each circuit:
- Target independent representation
- Native gates representation with no optimisation
- Native gates representation with full optimisation
- Mapped representation with no optimisation
- Mapped representation with full optimisation
As any two optimisation stages can be compared, this results in $binom(5, 2) = 5!/(2!(5-2)!) = 10$ benchmark instances per circuit.
This means that there are $10 dot 3 = 30$ benchmarks per circuit type and $30 dot 5 = 150$ benchmarks in total for each application scheme.
== Environment
The following data was collected using @mqt @qcec Bench, the benchmarking tool developed in the course of this work.
It was compiled using `clang` 17.0.6, `cmake` 3.29.2 and `ninja` 1.11.1.
`cmake` was configured to build the application in release mode and without tests or python bindings.
The application was then run on a virtual machine for each benchmarking and @qcec configuration sequentially.
The virtual machine was configured with 32 AMD EPYC 7H12 cores and 64GiB of RAM.
It ran NixOS 23.11 as the operating system on top of an ESXi hypervisor.
Initially, the application was locked to a single core using the `taskset` utility in an attempt to prevent the Linux scheduler from interfering with the benchmark.
This significantly reduced the performance of the benchmarking application, however, which lowered the turnaround time for the benchmark results.
It was determined that the variance due to context switches was low enough, so this restriction was removed.
@qcec itself was configured as follows:
- The numerical tolerance is set to the built-in epsilon (1024 times the smallest possible value of a double-precision floating-point value according to IEEE 754)
- Parallel execution is disabled.
- The alternating checker is enabled. All other checkers are disabled.
- All optimisations are disabled.
- The application scheme is set to either proportional or diff-based.
- The trace threshold is set to $10^(-8)$
- Partial equivalence checking is disabled.
Additionally, the following configuration was used for @qcec Bench:
- The timeout is set to 30 seconds.
- The minimum run count for each benchmark is 3.
== Results
@results_overview_histogram presents an overview of the performed benchmarking runs.
The results are sorted into bins and portrayed as a histogram.
A larger count in a bin that is further to the left therefore points towards a better algorithm.
This graph suggests that there is no significant difference in the run time of the tested algorithms and configurations in most cases.
The proportional application scheme does, however, appear to have a slight advantage in benchmarks that have a higher run time.
#figure(
canvas({
draw.set-style(
axes: (bottom: (tick: (
label: (angle: 45deg, anchor: "east"),
)))
)
chart.columnchart(
mode: "clustered",
label-key: 0,
value-key: range(1, 7),
size: (14, 5),
x-label: [Run Time (s)],
x-tick: 45,
y-label: [Count],
y-max: 22,
y-min: 0,
legend: "legend.inner-north-east",
bar-style: i => { if i >= 1 { palette.red(i) } else { palette.cyan(i) } },
labels: ([Proportional], [Myers' Diff (Reversed, Processed)], [Myers' Diff (Processed)], [Myers' Diff (Reversed)], [Myers' Diff], [Patience Diff]),
results-r1-b5q16-hist.bins-mu.zip(
results-r1-b5q16-hist.cprop.mu,
results-r1-b5q16-hist.cmyersrev-pmismc.mu,
results-r1-b5q16-hist.cmyers-pmismc.mu,
results-r1-b5q16-hist.cmyersrev-p.mu,
results-r1-b5q16-hist.cmyers-p.mu,
results-r1-b5q16-hist.cpatience-p.mu
)
)
}),
caption: [
Benchmark instances sorted into bins based on their run time.
The size of the bins increases exponentially to better reflect the distribution of the results.
The benchmark runs that did not finish within the time limit are excluded from these results.
]
) <results_overview_histogram>
The difference between the run times of the application schemes can be further highlighted by graphing the relative improvement according to the following formula:
$ p_"improvement" = (t_"proportional" - t_"diff") / t_"proportional" * 100% $
@results_improvement visualises the improvement for each benchmark instance of the processed Myers' diff application scheme compared to the proportional application scheme.
#figure(
canvas({
chart.columnchart(
size: (14, 6),
x-ticks: (),
y-label: [Run Time Improvement (%)],
y-max: 100,
y-min: -100,
sort-by-circuit-size(unclip(results-r1-b5q16)).map(r =>
([#r.name], calc.max(-(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100), -100))
)
)
}),
caption: [
The run time improvement of the application scheme based on the processed Myers' algorithm relative to the proportional application scheme for each benchmark instance.
The bars are arranged according to the total size of the circuits compared in the benchmark instance, with the smallest circuits being on the left.
]
) <results_improvement>
Taking the average of this improvement for each variant of the diff-based application scheme produces a good measure of their relative performance.
@results_average_improvement presents the results obtained by this method.
#figure(
tablex(
columns: (1fr, 1fr),
[*Algorithm*], [*Average Run Time Improvement (%)*],
[Myers' Diff], align(right, [#calc.round(unclip(results-r1-b5q16).map(r => -(r.cmyers-p.mu / r.cprop.mu * 100 - 100)).sum() / unclip(results-r1-b5q16).len(), digits: 3)]),
[Myers' Diff (Processed)], align(right, [#calc.round(unclip(results-r1-b5q16).map(r => -(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100)).sum() / unclip(results-r1-b5q16).len(), digits: 3)]),
[Myers' Diff (Reversed)], align(right, [#calc.round(unclip(results-r1-b5q16).map(r => -(r.cmyersrev-p.mu / r.cprop.mu * 100 - 100)).sum() / unclip(results-r1-b5q16).len(), digits: 3)]),
[Myers' Diff (Reversed, Processed)], align(right, [#calc.round(unclip(results-r1-b5q16).map(r => -(r.cmyersrev-pmismc.mu / r.cprop.mu * 100 - 100)).sum() / unclip(results-r1-b5q16).len(), digits: 3)]),
[Patience Diff], align(right, [#calc.round(unclip(results-r1-b5q16).map(r => -(r.cpatience-p.mu / r.cprop.mu * 100 - 100)).sum() / unclip(results-r1-b5q16).len(), digits: 3)]),
),
caption: [
The average of the run time improvement of all benchmark instances over the proportional application scheme for each variant of the diff application scheme.
This value is used as an indicator to determine the relative performance of the application schemes.
]
) <results_average_improvement>
These results show that, on average, every variant of the diff-base application scheme results in a significantly worse run time compared to the state-of-the-art proportional application scheme.
Of these, the reversed Myers' algorithms performed the worst by a significant margin.
On the other hand, the processed variants performed better than their plain counterparts.
This shows that the approach of reversing the second circuit before running the diff algorithm is clearly wrong, but processing the edit script to make it more suitable for use in the equivalence checker tends to work in most cases.
By comparing the run time improvement to various independent variables, a scheme was developed to determine whether or not applying the diff application scheme would result in a positive improvement.
Properties such as the circuit length in terms of gate count, the number of qubits in either circuit, and the @dd node count were considered.
However, the key variable for this scheme turned out to be the equivalence rate of the two circuits.
It was determined by counting the number of keep operations in the edit script and dividing it by the total size of the circuits.
In @results_equivalence_rate, the results of each variant are plotted dependent on their respective equivalence rates.
#figure(
canvas({
plot.plot(
size: (14, 6),
x-label: [Equivalence Rate],
y-label: [Run Time Improvement (%)],
y-max: 100,
y-min: -100,
legend: "legend.inner-north-east",
{
plot.add-hline(style: (stroke: black), 0)
plot.add(
mark: "triangle",
mark-style: (fill: none),
style: (stroke: none),
label: [Myers' Diff],
unclip(results-r1-b5q16).map(r =>
(r.equivalence-rate, calc.max(-(r.cmyers-p.mu / r.cprop.mu * 100 - 100), -100))
)
)
plot.add(
mark: "square",
mark-style: (fill: none),
style: (stroke: none),
label: [Myers' Diff (Processed)],
unclip(results-r1-b5q16).map(r =>
(r.equivalence-rate, calc.max(-(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100), -100))
)
)
plot.add(
mark: "o",
mark-style: (fill: none),
style: (stroke: none),
label: [Myers' Diff (Reversed)],
unclip(results-r1-b5q16).map(r =>
(r.equivalence-rate, calc.max(-(r.cmyersrev-p.mu / r.cprop.mu * 100 - 100), -100))
)
)
plot.add(
mark: "x",
mark-style: (fill: none),
style: (stroke: none),
label: [Myers' Diff (Reversed, Processed)],
unclip(results-r1-b5q16).map(r =>
(r.equivalence-rate, calc.max(-(r.cmyersrev-pmismc.mu / r.cprop.mu * 100 - 100), -100))
)
)
plot.add(
mark: "+",
mark-style: (fill: none),
style: (stroke: none),
label: [Patience],
unclip(results-r1-b5q16).map(r =>
(r.equivalence-rate, calc.max(-(r.cpatience-p.mu / r.cprop.mu * 100 - 100), -100))
)
)
}
)
}),
caption: [The run time improvement dependent on the circuit equivalence rate for each diff algorithm.]
) <results_equivalence_rate>
The plot suggests that diff-based application schemes tend to do better when the equivalence rate is higher.
This makes sense as there is no structure that could be exploited using an edit script to apply gates when there are few common subsequences in the two circuits.
Even so, the right side of the graph is obviously very noisy for most diff variants.
The results of the application scheme based on the processed Myers' algorithm look especially interesting in this regard, as they tend to rank higher than those of the other algorithms.
@results_equivalence_rate_processed shows this application scheme on its own to highlight the relationship between the variables.
#figure(
canvas({
plot.plot(
size: (14, 6),
x-label: [Equivalence Rate],
y-label: [Run Time Improvement (%)],
y-max: 100,
y-min: -100,
{
plot.add-hline(style: (stroke: black), 0)
plot.add(
mark: "square",
mark-style: (stroke: green, fill: none),
style: (stroke: none),
unclip(results-r1-b5q16).map(r =>
(r.equivalence-rate, calc.max(-(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100), -100))
)
)
plot.add-vline(style: (stroke: red), 0.35)
}
)
}),
caption: [
The run time improvement dependent on the circuit equivalence rate for the application scheme based on the processed Myers' diff algorithm.
Using the vertical line at 0.35, the benchmark instances can be filtered into cases where the diff application scheme is superior to the proportional application scheme.
]
) <results_equivalence_rate_processed>
Using an equivalence rate of $0.35$ as a limit, it is possible to separate most good benchmark instances where it is beneficial to use a diff-based application scheme from those where the run time increases.
As this value was determined empirically, it may need further adjustment based on more thorough tests.
For the benchmark instances used in this thesis, it was sufficiently precise, however.
@results_filtered_improvement visualises the run time improvement of the benchmark instances filtered using the described approach.
#figure(
canvas({
chart.columnchart(
size: (14, 6),
x-ticks: (),
y-label: [Run Time Improvement (%)],
y-max: 100,
y-min: -100,
filter(sort-by-circuit-size(unclip(results-r1-b5q16))).map(r =>
([#r.name], calc.max(-(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100), -100))
)
)
}),
caption: [
The run time improvement of the application scheme based on the processed Myers' algorithm relative to the proportional application scheme for each benchmark instance.
The benchmark instances are filtered so the application scheme is only used for those where the circuits are more than 40% equivalent.
]
) <results_filtered_improvement>
#let mu = calc.round(filter(unclip(results-r1-b5q16)).map(r => -(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100)).sum() / filter(unclip(results-r1-b5q16)).len(), digits: 3)
#let sigma = calc.round(calc.sqrt(filter(unclip(results-r1-b5q16)).map(r => calc.pow(-(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100) - mu, 2)).sum() / filter(unclip(results-r1-b5q16)).len()), digits: 3)
#let max = calc.round(filter(unclip(results-r1-b5q16)).map(r => -(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100)).fold(0, calc.max), digits: 3)
#let min = -calc.round(filter(unclip(results-r1-b5q16)).map(r => -(r.cmyers-pmismc.mu / r.cprop.mu * 100 - 100)).fold(0, calc.min), digits: 3)
These results are significantly better than those obtained through the naive approach of applying the scheme to all equivalence checking instances.
The average of the run time improvement of the filtered test cases is $#mu%$, with a standard deviation of $#sigma%$.
Furthermore, the application scheme results in a maximum improvement of $#max%$ and a maximum regression of $#min%$.
|
|
https://github.com/TypstApp-team/typst | https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/math/alignment.typ | typst | Apache License 2.0 | // Test implicit alignment math.
---
// Test alignment step functions.
#set page(width: 225pt)
$
"a" &= c \
&= c + 1 & "By definition" \
&= d + 100 + 1000 \
&= x && "Even longer" \
$
---
// Test post-fix alignment.
$
& "right" \
"a very long line" \
"left" \
$
---
// Test no alignment.
$
"right" \
"a very long line" \
"left" \
$
---
// Test #460 equations.
$
a &=b & quad c&=d \
e &=f & g&=h
$
|
https://github.com/1216892614/learn-category | https://raw.githubusercontent.com/1216892614/learn-category/main/main.typ | typst | #import "lib.typ": *
#show: project.with(
title: "Learn Category",
authors: (
(name: "HuNerd", email: "<EMAIL>"),
),
date: [#datetime.today().display("[year]-[month]-[day]")],
)
= 什么是猫猫
*对象*(Object)的*身份*(Identity)总是不平凡的(Extraordinary), 在经过*抽象*(Abstraction)后抹除细节会变的相对平凡(Ordinary). 在*组合*(Composition)中细节往往是无关紧要的, 经过抽象后的平凡对象往往意味着可以在组合中被任意替换. 猫猫论(Category Theory)的核心是关于身份和组合. 这是一种认识论(Epistemology)而非本体论(Ontology), 前者是我们认识世界的思维方式, 后者是世界本身的真理.
#align(center)[
#commutative-diagram(
node((0, 0), $"Obj" a$, "x"),
node((0, 1), $"Obj" b$, "y"),
arr("x", "y", $"Mor" f_1$, curve: 20deg),
arr("x", "y", $"Mor" f_2$, label-pos: right, curve: -20deg),
)
$ "Cat" X $
]
- *范畴, 猫猫*(Category, Cat)
- *对象*(Object, Obj): 组成猫猫的元素之一, 用点$dot a$表示, 不存在更多细节._(\*在实际交换图中我们会省略点$dot$的存在)_
- *态射*(Morphisms, Mor): 组成猫猫的元素之一, 连接对象与对象, 有向, 用箭头$a arrow b$表示. 对同样的对象序列可以存在*任意多*的态射, 它们不相等, 态射是不平凡的.
== 组合与身份(Composition and Identity)
#pad(top: 5pt)[#align(center)[#commutative-diagram(
node((0, 0), $a$, "a"),
node((0, 1), $b$, "b"),
node((0, 2), $c$, "c"),
arr("a", "b", $f$, label-pos: right),
arr("b", "c", $g$, label-pos: right),
arr("a", "c", $g circle.tiny f$, curve: 20deg),
)]]
#align(center)[
$forall "Mor" f: a->b, g: b->c, exists "Mor" g circle.tiny f: a -> c$
]
- *组合*(Composition): 当我们有 $f: a -> b, g: b -> c$ 的时候我们总有 $g circle.tiny f: a -> c$, 其中 $g circle.tiny f$ 读作 _g after f_.
#pad(top: 5pt)[#align(center)[#commutative-diagram(
node((0, 0), $a$, "a"),
arr("a", "a", pad(bottom: 15pt)[$"id"_a$], curve: 70deg),
)]]
#align(center)[
$forall "Obj" a, exists "id"_a: a -> a$
]
- *身份*(Identity): 对于猫猫中的每一对象, 都有一个指向自身的态射, 称为*身份*.
#pad(top: 5pt)[#align(center)[#commutative-diagram(
node((0, 0), $a$, "a"),
node((0, 1), $b$, "b"),
arr("a", "b", $f$, label-pos: right),
arr("b", "b", pad(bottom: 15pt)[$"id"_b$], curve: 70deg),
)]]
#align(center)[
$forall "Mor" f: a -> b, exists "id"_b circle.tiny f = f$
]
*定理: *因此我们总是可以从一个态射$f$出发可以获得与其终点对象身份组合的态射$"id"_b circle.tiny f $, 也就是$f$本身. _(\*注意, 这两个态射同时存在的时候并不恒等$eq.triple$, 它们仅仅是相同的组合形式, 态射是不平凡的, 下文的定理也是相同的)_
#pad(top: 5pt)[#align(center)[#commutative-diagram(
node((0, 0), $a$, "a"),
node((0, 1), $b$, "b"),
arr("a", "b", $g$, label-pos: right),
arr("a", "a", pad(bottom: 15pt)[$"id"_a$], curve: 70deg),
)]]
#align(center)[
$forall "Mor" g: a -> b, exists g circle.tiny "id"_a = g$
]
*定理: *我们也总可以从一个对象$a$出发获得与其相连态射组合$ g circle.tiny "id"_a$, 也就是$g$本身.
== 组合性和同一性(Composability and Identity)
#pad(y: 40pt)[#align(center)[#commutative-diagram(
node((0, 0), $a$, "a"),
node((0, 1), $b$, "b"),
node((0, 2), $c$, "c"),
node((0, 3), $d$, "d"),
arr("a", "b", $f$),
arr("b", "c", $g$),
arr("c", "d", $h$),
arr("a", "c", $g circle.tiny f$, curve: 25deg),
arr("a", "d", $h circle.tiny (g circle.tiny f)$, curve: 40deg),
arr("b", "d", $h circle.tiny g$, label-pos: right, curve: -25deg),
arr("a", "d", $(h circle.tiny g) circle.tiny f$, label-pos: right, curve: -40deg),
)]]
#align(center)[
$forall "Mor" f: a -> b, g: b -> c, h: c -> d, exists h circle.tiny (g circle.tiny f) = (h circle.tiny g) circle.tiny f$
]
*定理: *对任意态射$f, g, h$, 态射满足结合律. 即运算顺序为$h circle.tiny (g circle.tiny f)$和运算顺序为$(h circle.tiny g) circle.tiny f$结果是一样的. _(\*依旧注意, 这两个态射同时存在的时候并不恒等$eq.triple$, 它们仅仅是相同的组合形式.)_
我们可以尝试在编程中探索这些概念, 下面是一些一一对应关系的概念作为参考:
- $"对象" <==> "类型"$: 你可以将类型看作一组值的集合
- $"态射" <==> "函数"$: 那么在PL类型模型中, 函数(纯函数)在数学中仍旧是函数(数学函数), 只不过是对值集合的函数, 接受一个集合, 返回一个集合
```hs
f1::X->Y
f1 x = y
f2::Y->Z
f1 y = z
f2_after_f1::X->Z
f2_after_f1 x = (f2 . f1) x
-- 这里 assert_eq 中 lambda 的 in 在理想情况下代表任意合法值
-- 当且仅当这两个 lambda 返回值相同时断言成立
assert_eq (\in -> f2 (f1 in)) (\in -> f2_after_f1 in)
```
从上文的(伪)Haskell代码中我们可以看到交换律的组合关系.
#align(center)[#box(width: 30%)[#render(```
.---f2_after_f1---.
_|__ _____ __|_
/ \ / \ / V \
| . -|--|->. -|--|->. |
| . -|--|->. -|--|->. |
| . -|--|->. -|--|->. |
\__/ \___/ \__/
f1 f2
X ---> Y ---> Z
```)]]
如你所见, 态射和对象组成的交换图隐藏了数据的实质内容, 但是通过数据之间的联系我们可以看到足够多的东西来推断. 在这种意义上, 猫猫是抽象数据结构的终点, 猫猫是展示数据联系的终点.
#pagebreak()
= 函数, 泛态(Functions, epimorphisms)
普遍来说, 计算机语言是由语义构成的, 其中一种是告诉你程序的操作流程, 被称为*操作语义*(Operational Semantics); 另一种是将程序映射到另一领域的模型, 这被称为*指称语义*(Denominational Semantics).
尽管我们在编程中也有函数, 但是它们和数学中的函数概念并不同一. 因此我们有了*纯函数*(Pure Function)和*总函数*(Total Function)的概念.
#align(center)[#box(width: 65%)[#render(```
^^
\\ //
\\/ \ |
+---+ \| -+
--|---|--> ---*--|-->
--|---|--> | \-|-->
--|---|--> | ++-->
--|---|--> --|---|-->
+---+ +---+
Pure Function Not Pure Function
纯粹的输入输出 相同的输入也不一定代表相同
不受外界影响 的输出, 输出受外界副作用影响
+---+ +---+
--|---|--> --|---|-->
--|---|--> --|-| |
--|---|--> --|---|-->
--|---|--> --|-| |
+---+ +---+
Total Function Total Function
对每种合法输入 在部分输入会
都有结果 有未定义的值
```)]]
- *纯函数*(Pure Function): 一个纯函数是指它的输出只依赖于其输入参数, 并且在执行过程中不产生或受到外部世界的任何副作用. 这意味着给定相同的输入, 纯函数总是返回相同的输出, 并且单独的它不会修改任何外部状态 (如全局变量) 或执行其他有副作用的操作 (如写入文件、更改数据库等). _(\*尽管我们现在这样说, 但是在后面我们会想办法用纯函数实现这一切的.)_
- *总函数*(Total Function): 在计算理论中, 总函数是指对于其定义域内的每一个输入值, 函数都能给出一个输出值的函数. 这与*部分函数*(Partial Function)相对, 部分函数可能对某些输入没有定义输出.
#align(center)[#box(width: 35%)[#render(```
____ _____
/ \ / \
| . -|------------------|->. |
| . -|----------+-------|->. |
| . -|---------/ | |
| . -|--------+ | |
| . -|------------------|->. |
| . -|----+-------------|->. |
| . -|----+ | |
\__/ \___/
Domain -- Function -> Codomain
```)]]
在一个函数映射中, 你可以将多个输入映射到一个输出, 但是反之将多个输出映射到一个输入是绝对不行的, 这就是函数的*方向性*(Directionality)来源, 也是为何*总纯函数*(Total Pure Function)的表示是一个箭头. 在总纯函数中我们会定义:
- *领域*(Domain): 也就是包含所有函数有效输入的集合.
- *共域*(Codomain): 也就是包含所有函数可能的输出的集合.
- *图像*(Image): 这个函数映射向的结果集合_(\*共域往往是这个结果的子集)_.
函数的方向性是一个很重要的猫猫论直觉, 在之后我们还会看到其他东西之间的映射关系, 比如: 猫猫之前的映射关系, 我们称之为*函子*(Functor); 还有函子之间的映射关系, 我们称之为*自然变换*(Natural Transformation)...而这些映射都具有类似的方向性.
#align(center)[#grid(
columns: (auto, auto),
rows: (auto, auto),
rect(width: 100%, height: 130pt, stroke: (right: 1pt, left: 1pt, top: 1pt, bottom: 0pt))[
#render(```
____ _____
/ \ / \
| . -|------------------|->. |
| . -|------------------|->. |
| | | |
| +--+---- g -----------+--+ |
| | | | | |
| v | | | |
|x. -|---- f -----------|->.y |
\__/ \___/
Domain ------ f ------> Codomain
```)
],
rect(width: 100%, height: 130pt, stroke: (right: 1pt, left: 1pt, top: 1pt, bottom: 0pt))[
#pad(top: 35pt)[#commutative-diagram(
node((0, 0), $a$, "a"),
node((0, 1), $b$, "b"),
arr("a", "b", $f$, curve: 20deg),
arr("b", "a", $g$, curve: 20deg),
arr("b", "b", pad(bottom: 15pt)[$"id"_b$], curve: 70deg),
arr("a", "a", pad(top: 15pt)[$"id"_b$], label-pos: right, curve: -70deg),
)]
],
rect(width: 100%, height: 40pt, stroke: (right: 1pt, left: 1pt, top: 0pt, bottom: 1pt))[
```hs
f::a->b
g::b->a
```
],
rect(width: 100%, height: 40pt, stroke: (right: 1pt, left: 1pt, top: 0pt, bottom: 1pt))[
$g circle.tiny f = id_a$
$f circle.tiny g = id_b$
]
)]
既然有方向性, 那么我们就会考虑可逆问题. 既然我们可以从一个函数的领域映射到其共域, 那么我们能否从其共域以相反的关系映射到其领域来得到*逆函数*(Inverse of the Function)?
- *可逆函数*(Inverse of the Function): 从其对应函数的领域中任何一个元素在共域的映射出发映射回原本领域中原来元素也可以组成函数.
- *函数同构*(Isomorphism Between Functions): 一个函数和其逆函数之间的关系.
同样我们可以将这层关系延申到猫猫上:
- *逆态射*(Inverse of the Morphism): 从其对应态射的目标指向起始的态射.
- *同构*(Isomorphism): 一个态射和其逆态射之间的关卡.
我们来讨论一下有哪些函数不能成为可逆函数:
#align(center)[#grid(
columns: (130pt, 130pt),
rect(width: 130pt, height: 80pt, stroke: (right: 1pt, left: 1pt, top: 1pt, bottom: 0pt))[
#render(```
____ _____
/ \ f / \
| . -|--+-|->. |
| . -|--+ | |
\__/ \___/
```)
],
rect(width: 130pt, height: 80pt, stroke: (right: 1pt, left: 1pt, top: 1pt, bottom: 0pt))[
#render(```
________
____ | .____ .|
/ \ f | / \ |
| . -|---++->. |.|
| . -|---++->. | |
\__/ |.\___/. |
|________|
```)
],
rect(width: 130pt, height: 20pt, stroke: (right: 1pt, left: 1pt, top: 0pt, bottom: 1pt))[函数会折叠元素],
rect(width: 130pt, height: 20pt, stroke: (right: 1pt, left: 1pt, top: 0pt, bottom: 1pt))[图像是共域的真子集],
)]
- 函数会折叠元素, 这意味着函数的领域中的多个元素映射向共域中的同一个元素.
- 图像是共域的真子集, 函数的输出无法覆盖它所有可能的输出集合.
针对这两种情况我们有了以下概念:
#align(center)[#box(width: 35%)[#render(```
____ _____
/ \ / \
|x1.-|------------------|->.y1|
|x2.-|------------------|->.y2|
|x3.-|------------------|->.y3|
\__/ \___/
-- Injective Function -->
```)]]
- *单射*(Injective), *注入*(Injection): 指一个不折叠元素, 领域和共域一一映射的函数.
#align(center)[#box(width: 35%)[#render(```
________
____ |xx____xx|
/ \ |x/ \x|
| . -|-------------------++->. |x|
| . -|-------------------++->. |x|
\__/ |x\___/xx|
|________|
-- Surjective Function -->
```)]]
#align(center)[
$forall y, exists x, y = f(x)$
]
- *满射*(Surjective): 指共域完全覆盖它的图像, 函数的输出完全覆盖它所有可能的输出集合.
只有当一个函数同时满足*单射*和*满射*的时候它才是一个可逆函数. 既然我们可以在函数中得到这样的函数特征, 那么我们当然可以抽象这种特征到范畴论中, 下面我们先谈论满射的对应*泛态*:
#pad(top: 5pt)[#align(center)[#commutative-diagram(
node((0, 0), $a$, "a"),
node((0, 1), $b$, "b"),
node((0, 2), $c$, "c"),
arr("a", "b", $f$),
arr("b", "c", $g_1$, curve: 20deg),
arr("b", "c", $g_2$, label-pos: right, curve: -20deg),
)]]
#align(center)[
$forall c, forall g_1, g_2 :: b -> c, g_1 circle.tiny f = g_2 circle.tiny f => g_1 = g_2$
]
- *泛态*, *外态*(Epic, Epimorphism): 对对象$b$和所有从$b$指出的态射指向对象$c$的所有态射$g$, 其中的每一$g_1$, $g_2$都与从$a$指向$b$的态射$f$满足$g_1 circle.tiny f = g_2 circle.tiny f$, 也即$g_1 = g_2$, 则态射$f$满足泛态. 这对应函数中的满射概念.
#align(center)[
$forall a, b, c, a circle.tiny c = b circle.tiny c => a = b$
]
这也揭示了猫猫运算的另一项准则: 你可以化简等式两侧相同的组合运算.
== 单态, 简单类型(Monomorphisms, simple types)
和向$a -> b$后组合一个$c$不同, 在这里我们需要向前组合一个$c$来定义单态, 而且我们要先讨论否定的情况.
#align(center)[#box(width: 30%)[#render(```
____ _____ ____
/ \ / \ / \
| |g1| x1 | | y |
|z. -++-|->. -++-|->. |
| |+-|->. -++ | |
\__/ g2 \_x2/ \__/
g f
c ---> a ---> b
```)]]
从上图我们可以看到一个典型的非单射情况, 来自$a$外部的集合$c$中的点指向$a$中的态射和态射$f:a->b$组合就可能会产生相同的态射, 即$f circle.tiny g_1 != f circle.tiny g_2$, 也即$g_1 != g_2$. 将这个情况反向推广我们就可以得到单射的定义:
#pad(top: 5pt)[#align(center)[#commutative-diagram(
node((0, 0), $a$, "a"),
node((0, 1), $b$, "b"),
node((0, -1), $c$, "c"),
arr("a", "b", $f$),
arr("c", "a", $g_1$, curve: 20deg),
arr("c", "a", $g_2$, label-pos: right, curve: -20deg),
)]]
#align(center)[
$forall c, forall g_1, g_2 :: c -> a, f circle.tiny g_1 = f circle.tiny g_2 => g_1 = g_2$
]
- *单态*(Monic, Monomorphism): 对对象$a$和所有指向$a$态射发出的对象$c$的所有态射$g$, 其中的每一$g_1$, $g_2$都与从$a$指向$b$的态射$f$满足$f circle.tiny g_1 = f circle.tiny g_2$, 也即$g_1 = g_2$, 则态射$f$满足单态. 这对应函数中的单射概念.
_\*需要注意, 即便你的某个态射*既是单态又是泛态*, 它依旧有可能*不是同构的*, 这会在后面提到!!!_
|
|
https://github.com/TGM-HIT/typst-diploma-thesis | https://raw.githubusercontent.com/TGM-HIT/typst-diploma-thesis/main/src/assets/mod.typ | typst | MIT License | /// The TGM logo. This is a partially applied function and thus can accept most of the parameters
/// that ```typc image()``` can.
#let tgm-logo = image.with("logo-left.png")
/// The HTL logo. This is a partially applied function and thus can accept most of the parameters
/// that ```typc image()``` can.
#let htl-logo = image.with("logo-right.png")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.