Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
json
Languages:
English
Size:
10K - 100K
Tags:
code
License:
repo
stringlengths 26
115
| file
stringlengths 54
212
| language
stringclasses 2
values | license
stringclasses 16
values | content
stringlengths 19
1.07M
|
---|---|---|---|---|
https://github.com/fenjalien/metro | https://raw.githubusercontent.com/fenjalien/metro/main/tests/unit/sticky-per/test.typ | typst | Apache License 2.0 | #import "/src/lib.typ": unit, metro-setup
#set page(width: auto, height: auto)
#metro-setup(per-mode: "power")
#unit("pascal per gray henry")
#unit("pascal per gray henry", sticky-per: true)
|
https://github.com/Servostar/dhbw-abb-typst-template | https://raw.githubusercontent.com/Servostar/dhbw-abb-typst-template/main/src/lib.typ | typst | MIT License |
// .--------------------------------------------------------------------------.
// | Template of DHBW thesis |
// '--------------------------------------------------------------------------'
// Author: <NAME>
// Edited: 27.06.2024
// License: MIT
#import "conf.typ": validate-config, default-config
#import "branding.typ": *
#import "style.typ": global_styled_doc, content_styled, end_styled
#import "glossary.typ": glossary
#import "pages/titlepage.typ": new_title_page
#import "pages/declaration-of-authorship.typ": new_declaration_of_authorship
#import "pages/confidentiality-statement.typ": new_confidentiality_statement_page
#import "pages/prerelease-note.typ": new_prerelease_note
#import "pages/outline.typ": new_outline
#import "pages/abstract.typ": new_abstract
#import "pages/preface.typ": new-preface
#import "pages/appendix.typ": show-appendix
#let group-break() = {
[#pagebreak()]
}
#let inline-color(color, content) = {
box(
stroke: 1pt + ABB-GRAY-05,
radius: 2pt,
inset: (left: 2pt, right: 2pt),
outset: (top: 4pt, bottom: 4pt),
fill: ABB-GRAY-06,
[#box(
fill: rgb(color),
radius: 2pt,
inset: 0pt,
width: 0.75em,
height: 0.75em,
) #text(
font: default-config.style.code.font,
size: default-config.style.code.size,
content,
)],
)
}
#let url(label, content) = {
link(label)[#underline(
offset: 2pt,
stroke: 0.5pt + blue,
text(fill: blue)[
#content
#let domain = label.find(regex("\w+\.\w+(?:\.\w+)*"))
#if domain.len() > 0 [
(#domain)
]
],
)]
}
// start of template pages and styles
#let dhbw-template(config, body) = [
#let config = validate-config(config)
#let doc = body
// apply global style to every element in the argument content
#global_styled_doc(config)[
// set document properties
#set document(
author: config.author.name,
keywords: config.thesis.keywords,
title: config.thesis.title,
)
// configure text locale
#set text(
lang: config.lang,
region: config.region,
)
// preppend title page
#new_title_page(config)
// prelude includes: title, declaration of authorship, confidentiality statement, outline and abstract
// these will have roman page numbers
#new_declaration_of_authorship(config)
#new_confidentiality_statement_page(config)
#if config.draft {
new_prerelease_note(config)
}
#new_abstract(config)
#new-preface(config)
#new_outline()
// glossary is built inline here because the links must be
// exposed to the entire document
#import "glossarium.typ": *
#show: make-glossary
#pagebreak(weak: true)
#if "glossary" in config.thesis and config.thesis.glossary != none {
print-glossary(
show-all: false,
disable-back-references: true,
enable-group-pagebreak: true,
glossary(config.thesis.glossary, config),
)
pagebreak(weak: true)
}
#counter(page).update(1)
// mark end of prelude
#metadata("prelude terminate") <end-of-prelude>
#content_styled(config, doc)
#metadata("content terminate") <end-of-content>
#end_styled(config)[
// add bibliography if set
#if "bibliography" in config.thesis and config.thesis.bibliography != none {
pagebreak(weak: true)
counter(page).update(1)
set bibliography(style: "ieee")
config.thesis.bibliography
}
// appendix
#show-appendix(config: config)
]
]
]
|
https://github.com/AntoniosBarotsis/typst-assignment-template | https://raw.githubusercontent.com/AntoniosBarotsis/typst-assignment-template/master/template.typ | typst | // This should be private but don't think Typst supports that (?)
#let box(contents) = {
rect(
fill: rgb(242,242,242),
stroke: 0.5pt,
width: 100%,
align(center)[#contents]
)
}
// A simple, single question and answer
#let answer(question, term) = {
[== #question]
box(term)
}
// A question with multiple sub-questions and corresponding answers.
//
// The numbering can be configured by specifying the `numbering_fmt` parameter.
#let answer(question, numbering_fmt: "a", ..answers) = {
[== #question]
let length = answers.pos().len()
for i in range(0, length) {
let answer = answers.pos().at(i)
let question_number = numbering(numbering_fmt, i+1) // Numbering must be non-negative
[=== #question_number)]
box(answer)
}
}
// Sets the document title, author and optionally, a student number.
#let init(title, author, student_number: none) = {
set document(title: title, author: author)
align(top + left)[Student name: #author]
if student_number != none {
align(top + left)[Student number: #student_number]
}
align(center)[= #title]
}
|
|
https://github.com/Shedward/dnd-charbook | https://raw.githubusercontent.com/Shedward/dnd-charbook/main/dnd/game/abilities.typ | typst | #import "../core/core.typ": *
#let ability(title, source: none, body) = (
title: title,
source: source,
body: body
)
#let abilityCharges(count) = figure(box(framed(checkboxes(count))))
#let abilityRequirement(body) = [
#set text(top-edge: 0.5em)
#set par(first-line-indent: 0em)
#emph(body)
]
#let abilitySlot(lines) = figure(
box(
framed(
fitting: expand-h,
insets: (
x: paddings(2),
y: if lines == 1 { paddings(1) } else { 0pt }
)
)[
#inputGrid(lines)
]
)
)
|
|
https://github.com/LDemetrios/Typst4k | https://raw.githubusercontent.com/LDemetrios/Typst4k/master/src/test/resources/suite/layout/stack.typ | typst | // Test stack layouts.
--- stack-basic ---
// Test stacks with different directions.
#let widths = (
30pt, 20pt, 40pt, 15pt,
30pt, 50%, 20pt, 100%,
)
#let shaded(i, w) = {
let v = (i + 1) * 10%
rect(width: w, height: 10pt, fill: rgb(v, v, v))
}
#let items = for (i, w) in widths.enumerate() {
(align(right, shaded(i, w)),)
}
#set page(width: 50pt, margin: 0pt)
#stack(dir: btt, ..items)
--- stack-spacing ---
// Test spacing.
#set page(width: 50pt, margin: 0pt)
#let x = square(size: 10pt, fill: eastern)
#stack(
spacing: 5pt,
stack(dir: rtl, spacing: 5pt, x, x, x),
stack(dir: ltr, x, 20%, x, 20%, x),
stack(dir: ltr, spacing: 5pt, x, x, 7pt, 3pt, x),
)
--- stack-overflow ---
// Test overflow.
#set page(width: 50pt, height: 30pt, margin: 0pt)
#box(stack(
rect(width: 40pt, height: 20pt, fill: conifer),
rect(width: 30pt, height: 13pt, fill: forest),
))
--- stack-fr ---
#set page(height: 3.5cm)
#stack(
dir: ltr,
spacing: 1fr,
..for c in "ABCDEFGHI" {([#c],)}
)
Hello
#v(2fr)
from #h(1fr) the #h(1fr) wonderful
#v(1fr)
World! 🌍
--- stack-rtl-align-and-fr ---
// Test aligning things in RTL stack with align function & fr units.
#set page(width: 50pt, margin: 5pt)
#set block(spacing: 5pt)
#set text(8pt)
#stack(dir: rtl, 1fr, [A], 1fr, [B], [C])
#stack(dir: rtl,
align(center, [A]),
align(left, [B]),
[C],
)
--- issue-1240-stack-h-fr ---
// This issue is sort of horrible: When you write `h(1fr)` in a `stack` instead
// of directly `1fr`, things go awry. To fix this, we now transparently detect
// h/v children.
#stack(dir: ltr, [a], 1fr, [b], 1fr, [c])
#stack(dir: ltr, [a], h(1fr), [b], h(1fr), [c])
--- issue-1240-stack-v-fr ---
#set page(height: 60pt)
#stack(
dir: ltr,
spacing: 1fr,
stack([a], 1fr, [b]),
stack([a], v(1fr), [b]),
)
--- issue-1918-stack-with-infinite-spacing ---
// https://github.com/typst/typst/issues/1918
#set page(width: auto)
#context layout(available => {
let infinite-length = available.width
// Error: 3-40 stack spacing is infinite
stack(spacing: infinite-length)[A][B]
})
|
|
https://github.com/UnnamedOrange/Typst-Templates | https://raw.githubusercontent.com/UnnamedOrange/Typst-Templates/main/article.typ | typst | The Unlicense | #let 字号 = (
初号: 42pt,
小初: 36pt,
一号: 26pt,
小一: 24pt,
二号: 22pt,
小二: 18pt,
三号: 16pt,
小三: 15pt,
四号: 14pt,
中四: 13pt,
小四: 12pt,
五号: 10.5pt,
小五: 9pt,
六号: 7.5pt,
小六: 6.5pt,
七号: 5.5pt,
小七: 5pt,
)
#let 字体 = (
仿宋: ("Times New Roman", "FangSong"),
宋体: ("Times New Roman", "SimSun"),
黑体: ("Times New Roman", "SimHei"),
楷体: ("Times New Roman", "KaiTi"),
代码: ("New Computer Modern Mono", "Times New Roman", "SimSun"),
)
// Typst hard-to-fix bug: https://github.com/typst/typst/issues/311
#let indent() = {
h(2em)
}
#let article(
title: "",
authors: (),
date: datetime.today(),
doc
) = {
// Set the document's metadata.
set document(title: title, author: authors)
// Set the document's basic default styles.
set page(paper: "a4", numbering: "1", number-align: center)
set text(字号.小四, font: 字体.宋体, lang: "zh")
set heading(numbering: "1.1 ")
set par(justify: true, first-line-indent: 2em)
show heading: it => {
it
v(0.5em)
}
// Set behavior of Chinese.
show strong: it => text(font: 字体.黑体, weight: "semibold", it.body)
show emph: it => text(font: 字体.楷体, style: "italic", it.body)
show raw: set text(font: 字体.代码)
// Make title.
{
pad(bottom: 1em, {
set text(字号.小一)
align(center)[
#block[*#title*]
]
set text(字号.小二)
grid(
columns: (1fr,) * calc.min(3, authors.len()),
gutter: 1em,
..authors.map(author => align(center, author)),
)
align(center)[
#block[
#date.display("[year] 年 [month] 月 [day] 日")
]
]
})
}
doc
}
|
https://github.com/teamdailypractice/pdf-tools | https://raw.githubusercontent.com/teamdailypractice/pdf-tools/main/typst-pdf/thirukkural-oneline/001-tol.typ | typst | #set page("a4")
#set text(
font: "TSCu_SaiIndira",
size: 16pt
)
#set align(center)
திருக்குறள் - உற்சாகம் ஊட்டும் வரிகள் - தினமும்
\
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 14pt
)
உள்ளத்து அனையது, உயர்வு. \
அசாவாமை வேண்டும்;
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 12pt
)
என் உயர்வு, என்னிடம் உள்ளது. நல்ல எண்ணத்தோடு, நல்ல செயலை, நல்ல முயற்சியோடு நான் செய்தால், என் உயர்வு நிச்சயம். \
மன உறுதியோடு முயற்சி செய்வேன்.
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 14pt
)
முயற்சி, திருவினை ஆக்கும். \
முயற்சி, தன்-மெய்-வருத்தக் கூலி-தரும். \
பெருமை, முயற்சி தரும்.
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 12pt
)
என் நல்ல முயற்சி, நல்ல செயலை செய்து முடிக்க உதவும்.
செயலை செய்து முடிப்பது எனக்கு மகிழ்ச்சியைத் தரும்.
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 14pt
)
மனம்-தூய்மை, செய்-வினை தூய்மை; \
அகம்-தூய்மை, வாய்மையால் காணப்படும். \
மனத்துக்கண் மாசு-இலன் ஆதல்;
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 12pt
)
நல்லதை நினைப்பேன். \
நல்லதை பேசுவேன். உண்மையைப் பேசுவேன்.\
நல்லதை செய்வேன்.
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 14pt
)
அற்றார் அழி-பசி தீர்த்தல்! \
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 12pt
)
பசியால் வாடுபவர்க்கு/இல்லை என்று கேட்பவர்க்கு, என்னால் முடிந்ததை கொடுப்பேன்.
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 14pt
)
அழுக்காறு, அவா, வெகுளி, இன்னாச்-சொல்; \
நெடு-நீர், மறவி, மடி, துயில்; \
#set text(
font: "TSCu_SaiIndira",
size: 12pt
)
பொறாமை, பேராசை, கோபம், கடும் சொல் - இவைகளை முயற்சி செய்து தவிர்ப்பேன். \
காலம் தாழ்த்தி செய்தல், மறதி, சோம்பல், அளவுக்கு மீறிய தூக்கம் - இவைகளை முயற்சி செய்து தவிர்ப்பேன். \
#set align(left)
#set text(
font: "TSCu_SaiIndira",
size: 14pt
)
அற்றால், அளவு-அறிந்து உண்க! \
#set text(
font: "TSCu_SaiIndira",
size: 12pt
)
பசித்து சாப்பிடுவேன். அளவாக சாப்பிடுவேன். உடலுக்கு நலம் தருவதை சாப்பிடுவேன். \
உடலுக்கு நலம் தராத உணவை, தவிர்ப்பேன்.
|
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/layout/container_02.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test box sizing with layoutable child.
#box(
width: 50pt,
height: 50pt,
fill: yellow,
path(
fill: purple,
(0pt, 0pt),
(30pt, 30pt),
(0pt, 30pt),
(30pt, 0pt),
),
)
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/dict-04.typ | typst | Other | // Missing lvalue is not automatically none-initialized.
#{
let dict = (:)
// Error: 3-9 dictionary does not contain key "b" and no default value was specified
dict.b += 1
}
|
https://github.com/miliog/typst-penreport | https://raw.githubusercontent.com/miliog/typst-penreport/master/typst-penreport/helper/tlp.typ | typst | MIT No Attribution | #let TLP = (
RED: (
text: "TLP:RED",
color: "#FF2B2B"
),
AMBER: (
text: "TLP:AMBER",
color: "#FFC000"
),
AMBER_STRICT: (
text: "TLP:AMBER+STRICT",
color: "#FFC000"
),
GREEN: (
text: "TLP:GREEN",
color: "#33FF00"
),
CLEAR: (
text: "TLP:CLEAR",
color: "#FFFFFF"
),
)
#let ShowTLP(sharing) = [
#box(height: 1.5em, fill: black, inset: .2em,
[
#set align(horizon)
#text(rgb(sharing.color), size: 12pt, weight: 700)[#sharing.text]
]
)
] |
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compute/data-10.typ | typst | Other | // Test reading YAML data
#let data = yaml("test/assets/files/yaml-types.yaml")
#test(data.len(), 7)
#test(data.null_key, (none, none))
#test(data.string, "text")
#test(data.integer, 5)
#test(data.float, 1.12)
#test(data.mapping, ("1": "one", "2": "two"))
#test(data.seq, (1,2,3,4))
#test(data.bool, false)
#test(data.keys().contains("true"), false)
|
https://github.com/MilanR312/ugent_typst_template | https://raw.githubusercontent.com/MilanR312/ugent_typst_template/main/template/methods/title_page.typ | typst | MIT License | #import "globals.typ" : ublue
#let title_page(
title: none,
authors: (),
other_people: ()
) = {
// display the papers layout
align(
image("../images/faculteit.png", width: 60%),
left + top
)
align(
[
#set text(stroke: ublue, fill: ublue)
#title
],
left + horizon
)
align(
for author in authors [
#set text(16pt)
#if author.keys().contains("email") {
link("mailto:" + author.email, author.name)
} else {
author.name
}
#if author.keys().contains("student_number") {
set text(12pt)
[student number: #author.student_number]
}
],
left + bottom
)
v(3em)
align(
[
#set text(14pt)
#if other_people != none and other_people.promotors != none [
Promotors: #other_people.promotors.join(", ")
]
#if other_people != none and other_people.begeleiders != none [
Supervisors: #other_people.begeleiders.join(", ")
]
],
left + bottom
)
v(3em)
image("../images/ugent.png", width: 30%)
pagebreak()
} |
https://github.com/ufodauge/master_thesis | https://raw.githubusercontent.com/ufodauge/master_thesis/main/src/template/components/intro-section/index.typ | typst | MIT License | #import "toc-figure.typ": TocFigurePage
#import "toc.typ" : TocPage
#import "../common/page.typ" : Page
#import "../common/heading.typ": H1
#import "../../constants/page.typ": PAGE_NUMBERING_INTRO
#let IntroSection(
abstract : [],
acknowledgement: [],
) = [
#set page(numbering: PAGE_NUMBERING_INTRO)
#counter(page).update(1)
#show heading: it => [
#panic("Headings in the Abstract and Acknowledgements section are not defined.")
]
#show heading.where(level: 1): it => H1(it.body)
#Page[
= 概要
#abstract
]
#Page[
= 謝辞
#acknowledgement
]
#TocPage()
#TocFigurePage(
title : "図目次",
target: image,
)
#TocFigurePage(
title : "表目次",
target: table,
)
] |
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/cetz/0.1.2/src/styles.typ | typst | Apache License 2.0 | #import "util.typ"
#let default = (
root: (
fill: none,
stroke: black + 1pt,
radius: 1,
),
line: (
mark: (
size: .15,
angle: 45deg,
start: none,
end: none,
stroke: auto,
fill: none,
),
),
bezier: (
mark: (
size: .15,
angle: 45deg,
start: none,
end: none,
stroke: auto,
fill: none,
),
),
mark: (
size: .15,
angle: 45deg,
start: none,
end: none,
stroke: auto,
fill: none,
),
arc: (
mode: "OPEN",
),
content: (
padding: 0em,
frame: none,
fill: auto,
stroke: auto,
),
shadow: (
color: gray,
offset-x: .1,
offset-y: -.1,
),
)
/// Resolve the current style root
///
/// - current (style): Current context style (`ctx.style`).
/// - new (style): Style values overwriting the current style (or an empty dict).
/// I.e. inline styles passed with an element: `line(.., stroke: red)`.
/// - root (none, str): Style root element name.
/// - base (none, style): Base style. For use with custom elements, see `lib/angle.typ` as an example.
#let resolve(current, new, root: none, base: none) = {
if base != none {
if root != none {
let default = default
default.insert(root, base)
base = default
} else {
base = util.merge-dictionary(default, base)
}
} else {
base = default
}
let resolve-auto(hier, dict) = {
if type(dict) != dictionary { return dict }
for (k, v) in dict {
if v == auto {
for i in range(0, hier.len()) {
let parent = hier.at(i)
if k in parent {
v = parent.at(k)
if v != auto {
dict.insert(k, v)
break
}
}
}
}
if type(v) == dictionary {
dict.insert(k, resolve-auto((dict,) + hier, v))
}
}
return dict
}
let s = base.root
if root != none and root in base {
s = util.merge-dictionary(s, base.at(root))
} else {
s = util.merge-dictionary(s, base)
}
if root != none and root in current {
s = util.merge-dictionary(s, current.at(root))
} else {
s = util.merge-dictionary(s, current)
}
s = util.merge-dictionary(s, new)
s = resolve-auto((current, s, base.root), s)
return s
}
|
https://github.com/RaphGL/ElectronicsFromBasics | https://raw.githubusercontent.com/RaphGL/ElectronicsFromBasics/main/DC/chap3/6_emergency_response.typ | typst | Other | #import "../../core/core.typ"
=== Emergency response
Despite lock-out/tag-out procedures and multiple repetitions of
electrical safety rules in industry, accidents still do occur. The vast
majority of the time, these accidents are the result of not following
proper safety procedures. But however they may occur, they still do
happen, and anyone working around electrical systems should be aware of
what needs to be done for a victim of electrical shock.
If you see someone lying unconscious or \"froze on the circuit,\" the
very first thing to do is shut off the power by opening the appropriate
disconnect switch or circuit breaker. If someone touches another person
being shocked, there may be enough voltage dropped across the body of
the victim to shock the would-be rescuer, thereby \"freezing\" two
people instead of one. Don\'t be a hero. Electrons don\'t respect
heroism. Make sure the situation is safe for you to step into, or else
you #emph[will] be the next victim, and nobody will benefit from your
efforts.
One problem with this rule is that the source of power may not be known,
or easily found in time to save the victim of shock. If a shock
victim\'s breathing and heartbeat are paralyzed by electric current,
their survival time is very limited. If the shock current is of
sufficient magnitude, their flesh and internal organs may be quickly
roasted by the power the current dissipates as it runs through their
body.
If the power disconnect switch cannot be located quickly enough, it may
be possible to dislodge the victim from the circuit they\'re frozen on
to by prying them or hitting them away with a dry wooden board or piece
of nonmetallic conduit, common items to be found in industrial
construction scenes. Another item that could be used to safely drag a
\"frozen\" victim away from contact with power is an extension cord. By
looping a cord around their torso and using it as a rope to pull them
away from the circuit, their grip on the conductor(s) may be broken.
Bear in mind that the victim will be holding on to the conductor with
all their strength, so pulling them away probably won\'t be easy!
Once the victim has been safely disconnected from the source of electric
power, the immediate medical concerns for the victim should be
respiration and circulation (breathing and pulse). If the rescuer is
trained in CPR, they should follow the appropriate steps of checking for
breathing and pulse, then applying CPR as necessary to keep the
victim\'s body from deoxygenating. The cardinal rule of CPR is to
#emph[keep going] until you have been relieved by qualified personnel.
If the victim is conscious, it is best to have them lie still until
qualified emergency response personnel arrive on the scene. There is the
possibility of the victim going into a state of physiological shock -- a
condition of insufficient blood circulation different from electrical
shock -- and so they should be kept as warm and comfortable as possible.
An electrical shock insufficient to cause immediate interruption of the
heartbeat may be strong enough to cause heart irregularities or a heart
attack up to several hours later, so the victim should pay close
attention to their own condition after the incident, ideally under
supervision.
#core.review[
- A person being shocked needs to be disconnected from the source of
electrical power. Locate the disconnecting switch/breaker and turn it
off. Alternatively, if the disconnecting device cannot be located, the
victim can be pried or pulled from the circuit by an insulated object
such as a dry wood board, piece of nonmetallic conduit, or rubber
electrical cord.
- Victims need immediate medical response: check for breathing and
pulse, then apply CPR as necessary to maintain oxygenation.
- If a victim is still conscious after having been shocked, they need to
be closely monitored and cared for until trained emergency response
personnel arrive. There is danger of physiological shock, so keep the
victim warm and comfortable.
- Shock victims may suffer heart trouble up to several hours after being
shocked. The danger of electric shock does not end after the immediate
medical attention.
]
|
https://github.com/tiankaima/typst-notes | https://raw.githubusercontent.com/tiankaima/typst-notes/master/ea2724-ai_hw/hw7.typ | typst | == HW7
Due 2024.05.12
#import "@preview/diagraph:0.2.1": *
#let ans(it) = [
#pad(1em)[
#text(fill: blue)[
#it
]
]
]
#show math.equation: it => [
#math.display(it)
]
#show image: it => align(center, it)
=== Question 13.15
在一年一度的体检之后,医生告诉你一些坏消息和一些好消息。坏消息是你在一种严重疾病的测试中结果呈阳性,而这个测试的准确度为 $99 percent$ (即当你确实患这种病时,测试结果为阳性的概率为 $0.99$;而当你未患这种疾病时测试结果为阴性的概率也是 $0.99$)。好消息是,这是一种罕见的病,在你这个年龄段大约 $10000$ 人中才有 $1$ 例。为什么“这种病很罕见”对于你而言是一个好消息?你确实患有这种病的概率是多少?
#ans[
按照题目描述, 我们可以将所有可能的检测成果总结如下:
#table(
columns: (auto, auto, auto),
fill: (x, y) => {
if (x == 0 or y == 0) and not (x == 0 and y == 0) {
blue.lighten(80%)
}
if (x == 0 and y == 0) {
blue.lighten(60%)
}
},
stroke: blue,
align: center,
[], [阳性], [阴性],
[患病: $1\/10000$], [$1\/10000 times 99\/100$], [$1\/10000 times 1\/100$],
[未患病: $9999\/10000$], [$9999\/10000 times 1\/100$], [$9999\/10000 times 99\/100$],
)
在已知我检测结果为阳性的情况下, 我确实患病的概率为:
$
(1\/10000 times 99\/100) / (1\/10000 times 99\/100 + 9999\/10000 times 1\/100) approx 0.0098 < 1%
$
如果这并不是罕见病, 例如每$100$人就有$1$人患病, 那么在阳性检测结果下我确实患病的概率将会是:
$
(1\/100 times 99\/100) / (1\/100 times 99\/100 + 99\/100 times 1\/100) = 0.5
$
从这个角度说, 这种病很罕见对于我而言是一个好消息.
]
=== Question 13.18
假设给你一只袋子,装有个无偏差的硬币,并且告诉你其中$n$个硬币是正常的,一面是正面而另一面是反面。不过剩余$1$枚硬币是伪造的,它的两面都是正面。
+ 假设你把手伸进口袋均匀随机地取出一枚硬币,把它抛出去,硬币落地后正面朝上。那么你取出伪币的(条件)概率是多少?
#ans[
$
&P("fake") = 1 / n &quad& P("normal") = 1 - 1 / n&\
&P("head"|"fake") = 1 &quad& P("head"|"normal") = 1 / 2&\
&P("tail"|"fake") = 0 &quad& P("tail"|"normal") = 1 / 2&\
$
$
=> P("fake"|"head") = (P("head"|"fake")P("fake")) / P("head") = (1\/n) / (1\/n + (1-1\/n)\/2) = 2 / (n+1)
$
]
+ 假设你不停地抛这枚硬币,一共抛了$k$次,而且看到$k$次正面向上。那么你取出伪币的条件概率是多少?
#ans[
$
P("fake"|"head"^k) = (P("head"^k|"fake")P("fake")) / P("head"^k) = (1^k dot 1\/n) / (1^k dot 1\/n + (1-1\/n) dot (
1\/2
)^k) = (2^k) / (2^k+n-1)
$
]
+ 假设你希望通过把取出的硬币抛$k$次的方法来确定它是不是伪造的。如果抛次后都是正面朝上,那么决策过程返回 fake(伪造),否则返回 normal(正常)。这个过程发生错误的(无条件)概率是多少?
#ans[
$
P("WA") = P("normal" and "head"^k) = (1-1 / n) dot (1 / 2)^k
$
]
=== Question 13.21
(改编自Pearl (1988)的著述.) 假设你是雅典一次夜间出租车肇事逃逸的交通事的目击者。雅典所有的出租车都是蓝色或者绿色的。而你发誓所看见的肇事出租车是蓝色的。大量测试表明,在昏暗的灯光条件下,区分蓝色和绿色的可靠度为 $75 percent$。
+ 有可能据此计算出肇事出租车最可能是什么颜色吗?(提示:请仔细区分命题“肇事车是蓝色的”和命题“肇事车看起来是蓝色的”。)
#ans[
不能. 我们知道肇事车看起来的颜色, 但是不知道真实颜色的概率分布. 例如, 如果绿色出租车的数量远远多于蓝色出租车, 那么即使看起来是蓝色的车辆的概率也可能很高.(与上面罕见病的例子类似)
]
+ 如果你知道雅典的出租车 $10$ 辆中有 $9$ 辆是绿色的呢?
#ans[
也与上面罕见病类似, 我们整理出所有可能的情况如下:
#table(
columns: (auto, auto, auto),
fill: (x, y) => {
if (x == 0 or y == 0) and not (x == 0 and y == 0) {
blue.lighten(80%)
}
if (x == 0 and y == 0) {
blue.lighten(60%)
}
},
stroke: blue,
align: center,
[], [看起来蓝色], [看起来绿色],
[真实蓝色], [$1\/10 times 3\/4$], [$1\/10 times 1\/4$],
[真实绿色], [$9\/10 times 1\/4$], [$9\/10 times 3\/4$],
)
因此在 「看起来是蓝色」的前提下, 真实是蓝色的概率为: $1\/4$, 真实是绿色的概率为 $3\/4$. 肇事车最可能是绿色的.
]
=== Question 13.22
文本分类是基于文本内容将给定的一个文档分类成固定的几个类中的一类。朴素贝叶斯模型经常用于这个问题。在朴素贝叶斯模型中,查询(query)变量是这个文档的类别,而结果(effect)变量是语言中每个单词的存在与否;假设文档中单词的出现是独立的,单词的出现频率由文档类别决定。
+ 给定一组已经被分类的文档,准确解释如何构造这样的模型。
#ans[
考虑一组已经分类的文档, $C = {C_i}$, 对于每个单词 $w_j$, 我们可以计算出在每个类别下的概率 $P(w_j|C_i)$.
我们再计算每个类别的概率 $P(C_i)$, 以及每个单词的概率 $P(w_j)$.
]
+ 准确解释如何分类一个新文档。
#ans[
考虑一篇新文档含有单词 $w_1 ,dots.c, w_k$, 分别计算在各个分类下, 这些单词出现的概率:
$
P(C_i|w_1,dots,w_k) &= (P(w_1, dots.c, w_k) dot P(C_i)) / (P(w_1, dots.c, w_k))\
&= (limits(product)_i P(w_j|C_i) dot P(C_i)) / (P(w_1, dots.c, w_k))
$
无需计算分母, 只需比较各个分类下的概率即可.
]
+ 题目中的条件独立性假设合理吗?请讨论。
#ans[
这个假设并不合理. 例如, 在一篇关于机器学习的文章中, 出现了 "机器" 这个词, 那么 "学习" 这个词出现的概率就会变得很大. 这两个词并不是独立的.
]
=== Question 14.12
两个来自世界上不同地方的宇航员同时用他们自己的望远镜观测了太空中某个小区域内恒星的数目 $N$。他们的测量结果分别为 $M_1$ 和 $M_2$。通常,测量中会有不超过 $1$ 颗恒星的误差,发生错误的概率 $e$ 很小。每台望远镜可能出现(出现的概率$f$ 更小一些)对焦不准确的情况(分别记作 $F_1$ 和 $F_2$),在这种情况下科学家会少数三颗甚至更多的恒星(或者说,当 $N$ 小于 $3$ 时,连一颗恒星都观测不到)。考虑图14.22所示的三种贝叶斯网络结构。
#align(center)[
#table(
columns: (auto, auto, auto),
stroke: none,
column-gutter: 1em,
[
#raw-render(```dot
digraph {
rankdir=TD;
node [shape=circle];
F_1, F_2, M_1, M_2, N;
F_1 -> M_1; F_2 -> M_2;
M_1 -> N; M_2 -> N;
}
```)
],
[
#raw-render(```dot
digraph {
rankdir=TD;
node [shape=circle];
F_1, F_2, M_1, M_2, N;
F_1 -> M_1; F_2 -> M_2;
N -> M_1; N -> M_2;
}
```)
],
[
#raw-render(```dot
digraph {
layout=neato;
rankdir=TD;
node [shape=circle];
F_1 [pos="0,0!"];
F_2 [pos="1.5,0!"];
M_1 [pos="0,2!"];
M_2 [pos="1.5,2!"];
N [pos="0.5,1"];
M_1 -> F_1; M_1 -> M_2; M_1 -> N;
N -> F_1; N -> F_2; M_2 -> N; M_2 -> F_2;
}
```)
],
[
(i)
],
[
(ii)
],
[
(iii)
],
)
]
+ 这三种网络结构哪些是对上述信息的正确(但不一定高效)表示?
#ans[
(ii), (iii) 正确;
考虑到 $ P(N mid(|)M_1)!=P(N|M_1,F_1) $ 所以 $F_1$ 与 $M$ 应该同时连接到 $N$, (i) 不正确.
]
+ 哪一种网络结构是最好的?请解释。
#ans[
(ii), 关系少, 更紧致.
]
+ 当 $N in {1,2,3}, quad M_1 in {0,1,2,3,4}$时,请写出 $P(M_1 mid(|) N)$ 的条件概率表。概率分布表里的每个条目都应该表达为参数$e$和/或$f$的一个函数。
#ans[
$
P(M_1 mid(|) N) &= P(M_1 mid(|) N, F_1) P(F_1 mid(|) N) + P(M_1 mid(N), not F_1) P(not F_1 mid(|) N)\
&= P(M_1 mid(|) N, F_1) P(F_1) + P(M_1 mid(N), not F_1) P(not F_1)\
$
#table(
columns: (auto, auto, auto, auto, auto, auto),
align: center,
fill: (x, y) => {
if (x == 0 or y == 0) and not (x == 0 and y == 0) {
blue.lighten(80%)
}
if (x == 0 and y == 0) {
blue.lighten(90%)
}
},
stroke: blue,
[
$P(M_1 mid(|) N)$
],
[
$M_1 = 0$
],
[
$M_1 = 1$
],
[
$M_1 = 2$
],
[
$M_1 = 3$
],
[
$M_1 = 4$
],
[
$N = 1$
],
[
$f+e(1-f)$
],
[
$(1-2e)(1-f)$
],
[
$e(1-f)$
],
[
#set text(fill: red)
$0$
],
[
$0$
],
[
$N = 2$
],
[
$f$
],
[
#set text(fill: green)
$e(1-f)$
],
[
$(1-2e)(1-f)$
],
[
#set text(fill: green)
$e(1-f)$
],
[
$0$
],
[
$N = 3$
],
[
$f$
],
[
#set text(fill: red)
$0$
],
[
$e(1-f)$
],
[
$(1-2e)(1-f)$
],
[
$e(1-f)$
],
)
]
+ 假设 $M_1 = 1, quad M_2 = 3$。如果我们假设 $N$ 取值上没有先验概率约束,可能的恒星数目是多少?
#ans[
#table(
columns: (auto, auto, auto, auto, auto, auto, auto),
align: center,
fill: (x, y) => {
if (x == 0 or y == 0) and not (x == 0 and y == 0) {
blue.lighten(80%)
}
if (x == 0 and y == 0) {
blue.lighten(90%)
}
},
stroke: blue,
[
$P(M_1 mid(|) N)$
],
[
$M_1 = 0$
],
[
$M_1 = 1$
],
[
$M_1 = 2$
],
[
$M_1 = 3$
],
[
$M_1 = 4$
],
[
$dots.c$
],
[
$N = 4$
],
[
$f$
],
[
#set text(fill: green)
$f$
],
[
$0$
],
[
#set text(fill: green)
$e(1-f)$
],
[
$(1-2e)(1-f)$
],
[
$dots.c$
],
[
$N=5$
],
[
$f$
],
[
$f$
],
[
$f$
],
[
#set text(fill: red)
$0$
],
[
$e(1-f)$
],
[
$dots.c$
],
)
#let color_r(x) = text(fill: red, $#x$)
$
P(M = 3 mid(|) N = 0) = 0 &quad& => &quad& N!=0\
P(M = 3 mid(|) N = 1) = 0 &quad& => &quad& N!=1\
P(M = 1 mid(|) N = 3) = 0 &quad& => &quad& N!=3\
P(M = 1 mid(|) N = 5) = 0 &quad& => &quad& N!=5\
$
$P(M = i mid(|) N = n) > 0 quad forall i = 1,3; n = 2,4$ 已经在表中标记出来了. (考虑到 $f approx 0$ 时=, 我们近似地认为每行加起来为 $1$. )
考虑 $n >= 6$ 时, $P(M = 1 mid(|) N = n) = P(M = 3 mid(|) N = n) = f > 0$.
因此可能的 $n$ 的取值为 $2,4$ 或 $n>=6$
]
+ 在这些观测结果下,最可能的恒星数目是多少?解释如何计算这个数目,或者,如果不可能计算,请解释还需要什么附加信息以及它将如何影响结果。
#ans[
缺少 $N$ 的先验概率分布, 无法计算最可能的恒星数目.
考虑我们提供一个分布: $P(N=n) = p_n quad forall n = 2,4,6,7, dots$
$
&P(N=2, M_1 = 1, M_2 = 3) &=& p_2 e^2(1-f)^2\
&P(N=4, M_1 = 1, M_2 = 3) &=& p_4 e f(1-f)^2\
(n>=6) quad &P(N=n, M_1 = 1, M_2 = 3) &=& p_n f^2\
$
计算出并比较大小即可, 取 $n="argmax"_n P(N=n, M_1 = 1, M_2 = 3)$.
]
=== Question 14.13
考虑 图14.22(ii) 的网络,假设两个望远镜完全相同。$N in {1,2,3}$,$M_1, M_2 in {0,1,2,3,4}$,CPT表和习题14.12所描述的一样。使用枚举算法(图14.9)计算概率分布 $P(N mid(|) M_1=1,M_2 = 2)$。
#ans[
$
cal(P)(N mid(|) M_1=2, M_2=2) &= alpha sum_(f_1,f_2) cal(P)(f_1, f_2, N, M_1=2,M_2=2)\
&=alpha sum_(f_1,f_2) P(f_1) P(f_2) cal(P)(N) P(M_1=2,M_2=2)
$
考虑到 $M_1=M_2=2$, 只有 $F_1=F_2="false"$ 时才能满足, 因此:
$
cal(P)(N mid(|) M_1=2, M_2=2) &= alpha (1-f)^2 angle.l p_1, p_2, p_3 angle.r angle.l e, (
1-2e
), e angle.r angle.l e, (1-2e), e angle.r\
&= alpha^' angle.l p_1 e^2, p_2(1-2e)^2, p_3 e^2 angle.r
$
] |
|
https://github.com/domoritz/tvcg-journal-typst | https://raw.githubusercontent.com/domoritz/tvcg-journal-typst/main/lib.typ | typst | MIT No Attribution | // Workaround for the lack of an `std` scope.
#let std-bibliography = bibliography
#let serif-font = "Liberation Serif"
#let sans-serif-font = "Liberation Sans"
// This function gets your whole document as its `body` and formats
// it as an article in the style of the TVCG.
#let tvcg(
// The paper's title.
title: [Paper Title],
// An array of authors. For each author you can specify a name,
// department, organization, location, and email.
// Everything but the name is optional.
authors: (),
// The paper's abstract.
abstract: none,
// Teaser image path and caption
teaser: (),
// A list of index terms to display after the abstract.
index-terms: (),
// The article's paper size. Also affects the margins.
paper-size: "us-letter",
// The result of a call to the `bibliography` function or `none`.
bibliography: none,
// The paper's content.
body
) = {
// Set document metadata.
set document(title: title, author: authors.map(author => author.name))
// Set the body font.
set text(font: serif-font, size: 9pt)
// Configure the page.
set page(
paper: paper-size,
margin: (
top: 54pt, // 0.75in
bottom: 45pt, // 0.625in
inside: 54pt, // 0.75in
outside: 45pt // 0.625in
)
)
// Configure equation numbering and spacing.
set math.equation(numbering: "(1)")
show math.equation: set block(spacing: 0.65em)
// Configure appearance of equation references
show ref: it => {
if it.element != none and it.element.func() == math.equation {
// Override equation references.
link(it.element.location(), numbering(
it.element.numbering,
..counter(math.equation).at(it.element.location())
))
} else {
// Other references as usual.
it
}
}
// Configure lists.
set enum(indent: 10pt, body-indent: 9pt)
set list(indent: 10pt, body-indent: 9pt)
// Configure headings.
set heading(numbering: "1.1.1.")
show heading: it => locate(loc => {
// Find out the final number of the heading counter.
let levels = counter(heading).at(loc)
let deepest = if levels != () {
levels.last()
} else {
1
}
set text(font: sans-serif-font, size: 9pt)
if it.level == 1 [
// First-level headings are centered smallcaps.
// We don't want to number the acknowledgments section.
#let is-ack = it.body in ([Acknowledgments], [Acknowledgements])
#show: smallcaps
#v(20pt, weak: true)
#if it.numbering != none and not is-ack {
numbering("1.", deepest)
h(7pt, weak: true)
}
#if it.body.has("text"){
for letter in it.body.text{
if letter == upper(letter) {
set text(size: 9pt)
letter
} else {
set text(size: 7pt)
upper(letter)
}
}
}
// *#it.body*
#v(13.75pt, weak: true)
] else if it.level == 2 [
// Second-level headings are run-ins.
#set par(first-line-indent: 0pt)
#set text(style: "italic")
#v(10pt, weak: true)
#if it.numbering != none {
numbering("1.", deepest)
h(7pt, weak: true)
}
*#it.body*
#v(10pt, weak: true)
] else [
// Third level headings are run-ins too, but different.
#if it.level == 3 {
numbering("1)", deepest)
[ ]
}
_#(it.body):_
]
})
// Display the paper's title.
v(3pt, weak: true)
align(center, text(18pt, title, font: sans-serif-font))
v(23pt, weak: true)
// Display the authors list.
let and-comma = if authors.len() == 2 {" and "} else {", and "}
align(center,
text(10pt, font: sans-serif-font, authors.map(author => {
author.name
if "orcid" in author and author.orcid != "" {
link("https://orcid.org/" + author.orcid)[#box(height: 1.1em, baseline: 13.5%)[#image("assets/orcid.svg")]]
}
} ).join(", ", last: and-comma)
)
)
v(50pt, weak: true)
block(inset: (left: 24pt, right: 24pt), [
// Insert teaser image
#figure(
teaser.image,
caption: teaser.caption,
) <teaser>
#v(20pt, weak: true)
// Display abstract and index terms.
#(if abstract != none [
#set par(justify: true)
*Abstract*---#abstract
#if index-terms != () [
*Index terms*---#index-terms.join(", ")
]
]
)
]
)
v(10pt, weak: true)
align(center, box(width: 40%)[#image("assets/diamondrule.svg")])
v(15pt, weak: true)
// Start two column mode and configure paragraph properties.
show: columns.with(2, gutter: 12.24pt) // 0.17in
set par(justify: true, first-line-indent: 1em)
show par: set block(spacing: 0.65em)
// Display the email address and manuscript info.
place(left+bottom, float: true, block(
width: 100%,[
#align(center, line(length: 50%))
#set text(style: "italic", size: 7.5pt, font: serif-font)
#set list(indent: 0pt, body-indent: 5pt)
#for author in authors [
- #author.name is with #author.organization. #box(if "email" in author [E-mail: #author.email.])
]
Manuscript received DD MMM. YYYY; accepted DD MMM. YYYY.
Date of Publication DD MMM. YYYY; date of current version DD MMM. YYYY.
For information on obtaining reprints of this article, please send e-mail to: <EMAIL>`@`<EMAIL>.
Digital Object Identifier: xx.xxxx/TVCG.YYYY.xxxxxxx
]
)
)
// Set the body font.
set text(font: serif-font, size: 9pt)
// Display the paper's contents.
body
// Display bibliography.
if bibliography != none {
show std-bibliography: set text(8pt)
set std-bibliography(title: text(10pt)[References], style: "ieee")
bibliography
}
}
|
https://github.com/vitto4/ttuile | https://raw.githubusercontent.com/vitto4/ttuile/main/DOC.FR.md | markdown | MIT License | # 📚 Documentation
### `ttuile`
C'est la fonction principale, le point d'entrée du template. Elle doit être appelée en début de document, comme décrit dans [README.FR.md > Utilisation](https://github.com/vitto4/ttuile/blob/main/README.FR.md#-utilisation).
Si le compte rendu n'est pas réalisé pour l'INSA Lyon, le logo peut être remplacé ou supprimé avec l'argument `logo`.
### `annexe`
Fonction utilisée pour définir un objet `annexe`. Cet objet - étant un `dictionary` - sera ensuite utilisé par la fonction `afficher-annexes`.
| Argument | Valeur par défaut | Type | Description |
|:--------:|:-----------------:|:----:|:------------|
| `titre` | `none` | `content?` | Titre de l'annexe. |
| `reference` | `none` | `label` | Label/référence à utiliser dans le corps du rapport pour se référer à l'annexe. |
Un seul argument positionnel est accepté, étant le corps de l'annexe.
**Exemple :**
```typ
#let Annexe-1 = annexe(
titre: [Titre de l'annexe],
reference: <référence-à-utiliser>,
)[
Corps de l'annexe, du texte, des images, des titres, ...
]
```
La `reference` peut ensuite s'utiliser normalement dans le reste du rapport : `@référence-à-utiliser`.
**Remarque :**
- Comme les titres des annexes sont en réalité des titres de niveau `1` stylisés pour l'occasion, il n'est actuellement possible d'utiliser que des titres de niveau `2` ou plus dans le corps des annexes.
### `afficher-annexes`
Cette fonction prend en argument une liste d'objets `annexe` définis à l'aide de la fonction `annexe`, et les affiche avec une mise en page appropriée.
| Argument | Valeur par défaut | Type | Description |
|:--------:|:-----------------:|:----:|:------------|
| `annexes` | `none` | `list<dictionary>` | Liste de dictionnaires générés avec la fonction `annexe`. |
| `table` | `true` | `bool` | Permet d'afficher ou de masquer la table des annexes. |
| `saut-page-apres-table` | `false` | `bool` | Force un saut de page immédiatement après l'éventuelle table des annexes. |
**Exemple :**
```typ
#afficher-annexes(
annexes: (Annexe-1, Annexe-2,),
table: true,
saut-page-apres-table: false,
)
```
### `equation-anonyme`
Simple raccourci pour afficher une équation sans la numéroter.
**Exemple :**
```typ
#equation-anonyme(
$
"Une équation"
$
)
```
### `figure-emboitee`
Fait en sorte que la légende de la figure n'en dépasse pas la largeur.
```typ
figure-emboitee(
figure(
image("img.png"),
caption: [Une figure.]
)
reference: <référence-à-utiliser>,
)
``` |
https://github.com/Stautaffly/typ | https://raw.githubusercontent.com/Stautaffly/typ/main/小技巧.typ | typst |
#set text(size: 15pt)
= 等比\*等差数列求和办法
令 $T_n=("An"+B)q^n$ 其部分和$ S_n=(A+B)q+(2A+B)q^2+dots+("An"+B)q^n $
法一:错位相减\
$ S_n=&(A+B)q+(2A+B)q^2+dots+("An"+B)q^n \
q S_n=& (A+B)q^2+dots+(A n+B-A)q^(n)+ ("An"+B)q^(n+1)
$
两式相减得$ S_n=((A+B)q+A q^2(1-q^(n-1))/(1-q)-(A n+B)q^(n+1))/(1-q) $
|
|
https://github.com/LDemetrios/Typst4k | https://raw.githubusercontent.com/LDemetrios/Typst4k/master/src/test/resources/suite/foundations/content.typ | typst | --- content-at-default ---
// Test .at() default values for content.
#test(auto, [a].at("doesn't exist", default: auto))
--- content-field-syntax ---
// Test fields on elements.
#show list: it => {
test(it.children.len(), 3)
}
- A
- B
- C
--- content-field-missing ---
// Error: 25-28 heading does not have field "fun"
#show heading: it => it.fun
= A
--- content-fields ---
// Test content fields method.
#test([a].fields(), (text: "a"))
#test([a *b*].fields(), (children: ([a], [ ], strong[b])))
--- content-fields-mutable-invalid ---
#{
let object = [hi]
// Error: 3-9 cannot mutate fields on content
object.property = "value"
}
--- content-field-materialized-table ---
// Ensure that fields from set rules are materialized into the element before
// a show rule runs.
#set table(columns: (10pt, auto))
#show table: it => it.columns
#table[A][B][C][D]
--- content-field-materialized-heading ---
// Test it again with a different element.
#set heading(numbering: "(I)")
#show heading: set text(size: 11pt, weight: "regular")
#show heading: it => it.numbering
= Heading
--- content-field-materialized-query ---
// Test it with query.
#set raw(lang: "rust")
#context query(<myraw>).first().lang
`raw` <myraw>
--- content-fields-complex ---
// Integrated test for content fields.
#let compute(equation, ..vars) = {
let vars = vars.named()
let f(elem) = {
let func = elem.func()
if func == text {
let text = elem.text
if regex("^\d+$") in text {
int(text)
} else if text in vars {
int(vars.at(text))
} else {
panic("unknown math variable: " + text)
}
} else if func == math.attach {
let value = f(elem.base)
if elem.has("t") {
value = calc.pow(value, f(elem.t))
}
value
} else if elem.has("children") {
elem
.children
.filter(v => v != [ ])
.split[+]
.map(xs => xs.fold(1, (prod, v) => prod * f(v)))
.fold(0, (sum, v) => sum + v)
}
}
let result = f(equation.body)
[With ]
vars
.pairs()
.map(p => $#p.first() = #p.last()$)
.join(", ", last: " and ")
[ we have:]
$ equation = result $
}
#compute($x y + y^2$, x: 2, y: 3)
--- content-label-has-method ---
// Test whether the label is accessible through the `has` method.
#show heading: it => {
assert(it.has("label"))
it
}
= Hello, world! <my-label>
--- content-label-field-access ---
// Test whether the label is accessible through field syntax.
#show heading: it => {
assert(str(it.label) == "my-label")
it
}
= Hello, world! <my-label>
--- content-label-fields-method ---
// Test whether the label is accessible through the fields method.
#show heading: it => {
assert("label" in it.fields())
assert(str(it.fields().label) == "my-label")
it
}
= Hello, world! <my-label>
--- content-fields-unset ---
// Error: 10-15 field "block" in raw is not known at this point
#raw("").block
--- content-fields-unset-no-default ---
// Error: 2-21 field "block" in raw is not known at this point and no default was specified
#raw("").at("block")
--- content-try-to-access-internal-field ---
// Error: 9-15 hide does not have field "hidden"
#hide[].hidden
|
|
https://github.com/HEIGVD-Experience/docs | https://raw.githubusercontent.com/HEIGVD-Experience/docs/main/S5/SYE/docs/5-EtatsTransition%26Threads/etats-transition-threads.typ | typst | #import "/_settings/typst/template-note.typ": conf
#show: doc => conf(
title: [
Etats transistions et Threads
],
lesson: "SYE",
chapter: "5 - Etats transition et Threads",
definition: "Definition",
col: 1,
doc,
)
= Etats et transitions
#image("/_src/img/docs/image copy 141.png")
Voici une explication de chacun des états d'un processus mentionnés dans le texte :
== État New
- Description : Un processus est dans l'état *new* lorsqu'il est en phase d'initialisation. Cela signifie qu'il a été créé, mais pas encore totalement configuré pour être exécuté.
- Caractéristiques : Dans cet état, le PCB (Process Control Block) du processus existe, mais toutes les structures de données nécessaires ne sont pas encore initialisées. Le processus n'est pas prêt à être ordonnancé (c'est-à-dire, il ne peut pas encore être exécuté par le processeur).
== État Ready
- Description : Le processus est dans l'état *ready* lorsqu'il est prêt à être exécuté mais qu'il ne peut pas le faire en raison de la disponibilité limitée du processeur.
- Caractéristiques : À ce stade, toutes les structures de données nécessaires sont initialisées, et le processus est en attente de l'ordonnanceur, qui décidera quand lui accorder du temps CPU. Un processus peut passer de l'état *new* à *ready* après son initialisation.
== État Running
- Description : Dans cet état, le processus est effectivement en cours d'exécution sur le processeur.
- Caractéristiques : Le processus a été sélectionné par l'ordonnanceur et utilise le CPU pour exécuter ses instructions. Il peut passer à un autre état en fonction d'événements (comme une interruption ou une demande de ressource).
== État Waiting
- Description : Un processus entre dans l'état *waiting* lorsqu'il attend une ressource nécessaire pour continuer son exécution, comme l'accès à un fichier, à une entrée/sortie, ou à une autre ressource logique ou physique.
- Caractéristiques : Dans cet état, le processus ne peut pas être exécuté. Lorsqu'il obtient la ressource qu'il attendait, il doit d'abord passer par l'état *ready* avant de pouvoir redevenir *running*.
== État Zombie
- Description : Cet état se produit lorsqu'un processus a terminé son exécution, mais son PCB est encore présent dans le système.
- Caractéristiques : Un processus zombie ne peut plus être ordonnancé et reste dans cet état pour permettre au processus parent de récupérer son code de sortie. Le processus parent peut alors lire les informations sur l'état du processus terminé (générées par l'appel système `exit()`) avant de libérer le PCB et de supprimer définitivement le processus du système.
Ces états permettent au système d'exploitation de gérer efficacement les processus, en assurant une utilisation optimale des ressources et en maintenant un contrôle sur l'exécution des programmes.
#image("/_src/img/docs/image copy 143.png")
En principe, il existe dans le noyau une file de processus par état (à l'exception de l'état running auquel peut être associé plusieurs processus que si la machine est multi-cœur). Les processus dans l'état ready sont des processus prêts à être ordonnancés. Les mouvements de cette file dépendra en particulier de l'ordonnanceur.
= Définition d'un thread
#image("/_src/img/docs/image copy 142.png")
== Accès aux Ressources
- Contexte d'Exécution : Un thread représente un contexte d'exécution au sein d'un processus et doit avoir accès à toutes les ressources allouées à ce processus, comme la mémoire et d'autres ressources logiques.
- Espace d'Adressage : Tous les threads d'un même processus partagent le même espace d'adressage. Cela signifie qu'ils ont accès aux différentes sections du processus, comme le code, les données dans les sections data et bss, et le tas (heap).
- Pile : Chaque thread a sa propre pile, qui fait partie de son contexte d'exécution. Cela permet à chaque thread de gérer ses propres variables locales et ses appels de fonction.
== Exemple de Threads
Un exemple illustratif est le traitement de texte. Lorsqu'un utilisateur saisit du texte, le traitement de texte peut lancer un correcteur orthographique en arrière-plan pour souligner les fautes. Les deux tâches — la saisie et le correcteur — sont indépendantes, mais elles doivent accéder au même contenu.
== Gestion des Accès Concurrents
Les deux threads associés à ces tâches doivent gérer les accès concurrents au contenu partagé. Pour ce faire, ils peuvent utiliser des objets de synchronisation, tels que des mutex ou des sémaphores, afin de s'assurer que les données sont correctement gérées sans conflit.
#colbreak()
== Thread Control Break (TCB)
#image("/_src/img/docs/image copy 144.png")
Le TCB est une structure de données contenant les informations propres au thread, comme son état, sa priorité, le pointeur de pile, etc. Il est *fortement* sollicité lors d'un changement de contexte.
Par ailleurs, on remarque que le TCB est beaucoup plus petit que le PCB ; il ne contient
aucune information particulière concernant les ressources qui pourraient être utilisées
par le thread, comme des fichiers ouverts ou d'autres objets de synchronisation ou de
communication.
= Librairie de threads POSIX
- Portable Operating System Interface (X pour uniX/linuX/macosX)
- API standardisée (IEEE 1003.1c) largement répandue pour les threads
- Création/terminaison
- Synchronisation
- Accès concurrents
- Supporté par Windows (sous-système POSIX)
== Creation d'un thread
```c
#include <pthread.h>
int pthread_create(pthread_t *thread, const pthread_attr_t *, void *(*start_routine) (void *), void *arg);
voicd start_routine(void *);
```
== Sychronisation d'un thread
```c
int pthread_join(pthread_t thread, void **retval)
```
== Terminaison d'un thread
Retour de fonction (pas de valeur particulière à transmettre)
```c
void pthread_exit(void *retval);
```
= Exécution de threads
|
|
https://github.com/yingziyu-llt/blog | https://raw.githubusercontent.com/yingziyu-llt/blog/main/archived/Linear-Algebra-C3.typ | typst | #set document(title:"线性映射",date: auto )
#set page(margin: (
top: 0cm,
bottom: 0cm,
x: 0cm,
))
#set text(size: 16pt)
== 线性映射的定义
*Definition:*
一个映射 $T : V -> W$ 一定是线性的当且仅当它满足以下两个性质:
+ 可加性(additivity): $T(x + y) = T(x) + T(y)$
+ 齐次性(homogeneity): $T(c v) = c T(v)$
我们记作$T v$为一个线性映射(Linear Mapping),称$L(V, W)$为从$V$到$W$的线性映射. 显然其保持0元$T(0) = 0$
*Example*
零映射(zero) $0 in L(V,W),0v=0$
恒等(identity) $I in L(V,W),I v=v$
微分(differential) $D in L(V,W),D v = v'$
积分(integral) $I in L(V,W),I v(x)= integral_0^1 v(x) dif x$
*Theorem*
$V$的基为$v_1,v_2,dots,v_n$;$W$的基为$u_1,u_2,dots,u_n$,存在唯一的线性映射$T$,使得$T v_i = u_i$
证明思路:围绕着$forall u in W,exists c_1,c_2,dots,c_n$,只用构造$T(c_1 v_1 + c_2 v_2 + dots + c_n v_n) = c_1 u_1 + c_2 u_2 + dots + c_n u_n$即可.
== 线性映射的线性性
为了寻找其线性性,我们要先定义$L(V,W)$上的加法和数乘
*Definition*
定义$S,T in L(V,W)$
定义$(S+T)(v) = S(v) + T(v)$,$(lambda S)(v) = lambda S(v)$
于是容易看出,$L(V,W)$是一个线性空间.
*Definition*
定义线性映射的乘法$S in L(U,V),T in L(V,W)$,那么$(S T)(v) = S(T(v))$
*Theorem*
乘法的性质
+ 结合律$T_1T_2T_3 = T_1(T_2T_3)$
+ 幺元$I T = T I = T$,$I$是$L(V,V)$上的恒等映射
+ 分配率$(S_1 + S_2)(T) = S_1 T + S_2 T$,$S(T_1 + T_2) = S T_1 + S T_2$
需要注意的是,线性映射的乘法不具有交换律.
== 零空间和值域
*Definition*
零空间(null space) $T in L(V,W)$,$T$的零空间就是$V$的一个子集,使得${v in V : T v = 0}$,记作$"null" T$,也叫做$T$的核空间(kernel space),记作$ker T$
单射(injective) $T in L(V,W),T v = T w => v = w$ 这样的$T$称为一个单射.
*Theorem*
+ $ker T$是$V$的一个子空间
+ $T$是单射$<=>$$ker T = {0}$
*Proof*
对于命题1:取$v_1,v_2 in ker T$,$T(v_1 + v_2) = T v_1 + T v_2 = 0 + 0 = 0$;$T(lambda v) = lambda T v = 0$
对于命题2:$\"=>\"$由于$T$为单射,所以$T(v) = T(0) = 0 => v = 0$,于是$ker T = {0}$
$\"<==\"$ $T(v_1) = T(v_2) => T(v_1) - T(v_2) = 0 =>T(v_1 - v_2) = 0$,又$ker T = {0}$,$=> v_1 - v_2 = 0 => v_1 = v_2$
*Definition*
值域(range):对于一个函数$T : V -> W$,$T$的值域就是$W$的一个子集${T v}$,记作$"range" T$,也叫函数的像空间(image),记作$im T$.
*Theorem*
$im T$是$V$的一个子空间
*Proof*
设$w_1,w_2 in im T$,那么$w = T(v_1 + v_2) = T v_1 + T v_2 = w_1 + w_2 in im T$,$T(lambda v) = lambda T v = lambda w in im T$
*Definition*
满射(surjective):如果某个映射$T:V->W$的像空间等于$W$,那么称$T$是一个满射.
*Theorem*
*线性代数基本定理*:$T in L(V,W)$,$dim V$ = $dim ker T + dim im T$
于是容易得出:如果$T:V->W$,$dim W < dim V$,那么$T$一定不是单射. 如果$dim V < dim W$,那么$T$一定不是满射
显然,一个欠定的齐次线性方程组有非零解,非齐次线性方程组可能无解. (齐次线性方程组$T(v) = 0$,非齐次线性方程组$T(v) = v_0$)
== 矩阵
为了更加方便的表示线性映射,我们定义矩阵
*Definition*
设$m,n$都是正整数. 一个$m times n$矩阵$A$是一个在$FF$上的$m times n$矩形数组,写作:
#let matrix_m_n(x) = $mat(#x _"1,1",dots,#x _"1,n";dots. v,,dots. v;#x _"m,1",dots,#x _"m,m")$
$ A = #matrix_m_n("A") $
一些特殊矩阵:$I$是单位矩阵,除了对角线元素为$1$,其他均为$0$.
下面来定义一个线性映射的矩阵表示
*Definition*
若$v_1,v_2,dots,v_n$是$V$的一组基,$w_1,w_2,dots,w_m$是$W$的一组基,且$T v_i = sum_j=1^m A_"i,j"w_j$,那么其矩阵表示$M(T)$就是$A$. 如果未指明$v_i$和$w_i$,可以记作$M(T,(v_1,v_2,dots,v_n),(w_1,w_2,dots,w_m))$
容易看出,$M(T)$的第$i$列和$v_i$的选取有关,而第$i$行和$w_i$的选取有关. 例如变换$T(x,y)=(8x+9y,2x+3y,x+y)$,在标准正交基($(1,0),(0,1)$,$(1,0,0),(0,1,0),(0,0,1)$)下的矩阵表示为$M(T) = mat(8,9;2,3;1,1)$
为了进一步扩展矩阵的意义,定义矩阵的加法、数乘
*Definition*
定义两个$m times n$矩阵$A,B$的和$ A + B = #matrix_m_n("A") + #matrix_m_n("B") = mat(A_"1,1" + B_"1,1",dots,A_"1,n" + B _ "1,n";dots. v,,dots. v;A _"m,1" + B_"m,1",dots,A _"m,m" + B_"m,n") $
数乘$ lambda * A = #matrix_m_n($lambda * A$) $
容易看出,矩阵的加法就相当于线性映射的加法,矩阵数乘就相当于线性映射的数乘.
考虑到线性映射还有叠加这一组合方法,我们下面定义矩阵的乘法.
试探:$S,T$是两个线性映射,$S T$:$ S T(u_k) \
= S(sum_"r=1"^n C_"r,k" v_r) \
= sum_"r=1"^n C_"r,k" sum_"j=1"^m A_"j,r" w_j $
为了表示这种变换规律,定义矩阵乘法
*Definition*
矩阵乘法:设$A$是$n times k$矩阵,$B$是$k times m$矩阵,定义运算$(A B)_"i,j" = sum_"k=1"^k A_"i,k" B_"k,j"$,更加直观的,就是选取$A$的第$i$行和$B$的第$j$列,按元素依次乘在一起再求和,表示新矩阵第$i$行$j$列的元素.
具体计算可以自己去试试.
*Notation*
一种简明记法
$A_(j,dot)$指$A$的第j行形成的一个$m times 1$矩阵,$A_(dot,j)$指$A$的第j列形成的一个$1 times n$矩阵
于是对于矩阵的乘法有以下表示法
$ (A B)_(i,j) = A_(i,dot) B_(dot,j) $ $ (A B)_(dot,k) = A C_(dot,k) $
对矩阵乘法的另一种理解:线性组合 设$c = vec(c_1,c_2,dots,c_n)$,A为$m times n$矩阵,那么$A c$ = $c_1 A_(dot,1) + c_2 A_(dot,2) + dots + c_n A_(dot,n)$,换言之,$A c$就是对$A$列的线性组合,用$c$的每一个元来数乘.
== 逆和同构
*Definition*
$A,B$是两个映射($n times n$矩阵),且有$A B = B A = I$,那么称$B$是$A$的逆(inverse),记作$B = A^(-1)$,$A$是可逆的(invertible)
*Theorem*
如果某矩阵(映射)可逆,那么其逆是唯一的. proof:若$A B = A C = I$,那么$C = C I = C (A B) = (C A) B = B$
映射$V$可逆$<=>$映射$V$是单射满射(一一对应)
对于存在可逆隐射的两个空间,他们也有一些潜在的关系,下面加以定义.
*Definition*
一个可逆映射可以称为同构(isomorphism)
两个空间中存在一个可逆映射,则这两个空间称为是同构的(isomorphic)
*Theorem*
两个向量空间同构$<=>$两个向量空间维度相同
设$dim V = n$,$dim W = m$,那么$L(V,W)$和$FF^(n m)$同构,于是$dim L(V,W) = dim V dim W$
为了统一表示线性映射,我们试着用矩阵相乘的方法来表示映射. 为了更好处理向量,我们定义向量的矩阵表示(matrix of a vector)
*Definition*
设$V$的一组基是$v_1,v_2,dots,v_n$,$v in V$,$v = a_1 v_1 + a_2 v_2 + dots + a_n v_n$,那么$M(v) = vec(a_1,a_2,dots,a_n)$叫做$v$的矩阵表示.
这样之后,我们容易得到$M(T v) = M(T) M(v)$
== 算子
对于以上种种线性映射来说,有一类很特殊的是从$V$到$V$的映射. 我们对其进行一些定义.
*Definition*
一个从$V$到$V$的线性映射定义为*算子*(operator),记$V$上所有算子构成的线性空间为$L(V)$
对于算子,也有一些很好的性质.
*Theorem*
如果有限维向量空间中的算子$T in L(V)$,下面三个命题等价
- $T$可逆
- $T$是单射
- $T$是满射
== 积空间和商空间
*Definition*
线性空间的积:设$V_1,V_2,dots,V_n$是$FF$上的线性空间,定义$V_1 times V_2 times dots times V_n = {(v_1,v_2,dots,v_n),v_1 in V_1,v_2 in V_2,dots in V_n}$叫做这些空间的积.
在积空间中的加法被定义为$(v_1,v_2,dots,v_n) + (u_1,u_2,dots,u_n) = (v_1 + u_1,v_2 + u_2,dots + u_n,v_n + u_n)$,数乘也类似$lambda (v_1,v_2,dots,v_n) = (lambda v_1,lambda v_2,lambda dots,lambda v_n)$
实际上就可以将$v_i$当成一个数,其运算规则就变成了一般向量的运算规则了.
*Theorem*
积空间是一个线性空间
证明从略.
对于积空间本身,我们也要有一些观察. $((1,2),(3,4,5))$和$(1,2,3,4,5)$似乎并没有什么本质上的差异. 那我们就可以去猜测$FF^n times FF^m$和$FF^(m+n)$有同构关系了. 事实也正是如此.
*Theorem*
设$V_1,V_2,dots,V_n$都是有限维线性空间,$dim (V_1 times V_2 times dots times V_n) = dim V_1 + dim V_2 + dots + dim V_n$
*Proof*
选取每个$U$的一个基.对千每个$U$的每个基向量,考虑 $V_1 times V_2 times dots times V_n$ 的如下元素 : 第$j$个位置为此基向量,其余位置为$$0. 所有这些向量构成的组是线性无关的,且张成$V_1 times V_2 times dots times V_n$, 因此是积空间的基 . 这个基的长度是$dim V_1 + · · ·+ dim V_n$
我们下面来定义子空间和向量的和.
*Definition*
设$v in V$,$U$是$V$的子空间. 那么定义子空间和向量的和为:
$v + U = {v + u:u in U}$
我们称$v + U$是$V$的仿射子集(affine subset),$v+U$和$U$形成平行(parallel)关系.
从几何的角度来看,$v + U$是将过原点的$U$平面向$v$方向平移的结果,所以有一定的几何直观. 很显然,一个仿射子集不是一个子空间($v != 0$)
为了描述相同性质的仿射子集,我们来定义商空间.
*Definition*
设$U$是$V$的子空间,那么商空间就是所有平行于$U$的仿射子集的并. 定义为:$V\/U={v + U: v in V}$
*Theorem*
平行于$U$的两个仿射子集要么相等,要么不相交.
即:$U$是$V$的子空间,$v,w in V$下列陈述等价
- $v - w in U$
- $v + U = w + U$
- $(v + U) sect (w + U) != nothing$
下面来定义商空间上的线性运算.
*Definition*
定义加法和数乘分别是:
$(v + U) + (w + U) = (v + w) + U$,$lambda (v + U) = lambda v + U$
需要注意的是,对于同一个集合$v + U$,会有多种表示方法. 举例$y = x + 1$这个集合至少可以有$(-1,0) + (y = x)$和$(0,1) + (y = x)$两种表示方法. 为了说明加法和数乘是有意义的,需要有如下的证明.
*Proof*
命题:若$v_1 + U = v_2 + U$,$w_1 + U = w_2 + U$,那么$(v_1 + w_1) + U = (v_2 + w_2) + U$
由上面的定理知,$v_1 - v_2 in U$,$w_1 - w_2 in U$,于是$(v_1 - v_2) + (w_1 - w_2) in U$,于是$(v_1 + w_1) - (v_2 + w_2) in U$,从而$(v_1 + w_1) + U = (v_2 + w_2) + U$
*Definition*
商映射:定义一个映射$pi: V -> V / U$,对任意$v in V$,$ pi (v) = v + U $
可以证明这个映射是一个线性映射.
*Theorem*
商空间的维数:如果$V$是有限维空间,那么$dim V = dim U + dim V / U$
== 对偶(Duality)
像(值域)是一个标量空间的线性函数也有一些有趣的性质,我们将这类函数单独拿出来讨论一下。
*Definition*
线性泛函(linear functional)是$L(V,FF)$的一个线性函数
*Example*
- 定义$phi: RR^3 -> RR$,$phi(x,y,z) = 3x+4y+5z$,$phi$是线性泛函
- 定义$phi:P(RR) -> RR$,$phi(p) = integral_0^1 p dif x$是线性泛函
线性泛函构成的空间也有研究的价值,下面给予定义
*Definition*
对偶空间(dual space)是线性泛函构成的空间,即$L(V,FF)$,记作$V'$,容易知道$dim V' = dim V$
对偶基(dual basis)是$V'$的一组基,也就是说,取$v_1,v_2,dots,v_n$,那么其对偶基也是一组线性泛函即
$ phi_j (v_k) = cases(1 "if" k = j,
0 "if" k != j) $
对偶映射(dual mapping):对于$T in L(V,W)$,定义对偶映射$T' in L(W',V')$,满足$phi in W'$,有$T'(phi) = phi circle.small T$
*Theorem*
对偶函数的代数性质:$(lambda T)' = lambda (T')$,$(S + T)' = S' + T'$,$(S T)' = T' S'$
*Definition*
零化子(annihilator):对于$U subset V$,$U$的零化子$U^0$定义为$U^0 = {phi in V': forall v in U,phi(u) = 0$.
*Theorem*
- 零化子是一个$V'$的子空间.
- 设$V$是有限维的,那么$dim U + dim U^0 = dim V$
- $V,W$有限维,$T in L(V,W)$
- $dim ker T' = dim ker T + dim W - dim V$
- $ker T = (im T)^0$
- $T$是满的当且仅当$T'$是单的.
我们知道,线性映射总是有对应的矩阵表示,我们理应好奇对偶映射在矩阵上的反应。下面定义这一点。
*Definition*
矩阵的转置(transpose),$A^T$:定义$n times m$矩阵$A$的转置$A$为$m times n$矩阵,$(A^T)_(i,j) = (A)_(j,i)$
*Theorem*
转置的代数性质:
- $(A+B)^T = A^T + B^T$
- $(lambda A)^T = lambda A^T)$
- $(A B)^T = B^T A^T$
$M(T') = M(T)^T$
== 矩阵的秩(rank)
*Definition*
行秩和列秩:设$A$是$FF$上的$m times n$矩阵
- $A$的行秩是$A$诸行张成空间的维数。
- $A$的列秩是$A$诸列张成空间的维数。
*Theorem*
$im T$的维数等于$M(T)$的列秩
行秩等于列秩,统称为秩(rank),记作$"rank" A$
个人看来,线性泛函在后面用到的比较少,主要用到的可能还是转置和秩。所以最后的结论可能比前面的推到更加重要,具体为什么这里要用线性泛函引出这些内容,我也很懵
|
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/math/matrix-alignment_06.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test #454 equations.
$ mat(-1, 1, 1; 1, -1, 1; 1, 1, -1) $
$ mat(-1&, 1&, 1&; 1&, -1&, 1&; 1&, 1&, -1&) $
$ mat(-1&, 1&, 1&; 1, -1, 1; 1, 1, -1) $
$ mat(&-1, &1, &1; 1, -1, 1; 1, 1, -1) $
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/gentle-clues/0.6.0/docs.typ | typst | Apache License 2.0 | #import "@local/gentle-clues:0.6.0": *
#import "@local/svg-emoji:0.1.0": *
#set page(margin: 2cm);
#show: setup-emoji
#show: gentle-clues.with(
lang: "de",
headless: false,
breakable: false,
// header-inset: 0.4em,
// content-inset: 1.3em,
// border-radius: 12pt,
// border-width: 1pt,
// stroke-width: 5pt,
)
#set text(font: "Roboto")
= Gentle clues for typst
Add some beautiful, predefined admonitions or define your own.
#clue(title: "Getting Started")[
A minimal starting example
```typ
#import "@preview/gentle-clues:0.6.0": *
#show: gentle-clues.with(
lang: "de", // set header title language (default: "en")
)
#tip[Check out this cool package]
```
#tip[Check out this cool package]
]
#clue(title: "Usage")[
+ Import the package like this:
```typ
#import "@preview/gentle-clues:0.6.0": *
```
+ Change the default settings for a clue.
```typ
#show: gentle-clues.with(
lang: "de", // set header title language (default: "en")
// Accepts "en", "de", "fr" or "es" for the moment.
headless: false, // never show any headers
breakable: false, // default breaking behavior
header-inset: 0.5em, // default header-inset
content-inset: 1em, // default content-inset
stroke-width: 2pt, // default left stroke-width
border-radius: 2pt, // default border-radius
border-width: 0.5pt, // default boarder-width
)
```
+
#grid(columns: 2, gutter: 1em)[
Use a predefined clue without any options
```typ
#info[You will find a list with all predefined clues at the last page.]
```
#align(end)[_Turns into this_ #sym.arrow]
][
#set align(bottom)
#info[You will find a list with all predefined clues at the last page.]
]
+ #grid(columns: 2, gutter: 1em)[
Or add some options like a custom title
```typ
#example(title: "Custom title")[ Content ...]
```
#align(end)[_Turns into this_ #sym.arrow]
][
#set align(bottom)
#example(title: "Custom title")[ Content ...]
]
#memo(title: "New in v0.6.0",_color: gradient.linear(..color.map.crest))[
Using global show rule for default configuration.
]
]
#clue(title: "All Options for a clue")[
All default settings can also be applied to a single clue through passing it as an named argument. Here is a list of accepted arguments:
```typ
title: auto, // [string] or [none] (none will print headless)
icon: emoji.magnify.l, // [file] or [symbol]
_color: navy, // base color [color]
width: auto, // total width [length]
radius: auto, // radius of the right border [length]
border-width: auto, // width of the right and down border [length]
content-inset: auto, // [length]
header-inset: auto, // [length]
breakable: auto, // if clue can break onto next page [bool]
```
]
#box(
height: 4.5cm,
stroke: gray.lighten(40%),
radius: 2pt,
inset: 2mm,
columns(2)[
#example(title: "Breaking news", breakable: true)[
Clues can now break onto the next page with option: `breakable: true`
#lorem(30)
]
This is a two columns layout.
])
#clue(title: "Define your own clue")[
```typst
#import "@preview/gentle-clues:0.6.0": *
// Define a clue called ghost
#let ghost(title: "Buuuuuuh", icon: emoji.ghost , ..args) = clue(
_color: purple, // Define a base color
title: title, // Define the default title
icon: icon, // Define the default icon
..args // Pass along all other arguments
)
// Use it
#ghost[Huuuuuuh.]
```
The result looks like this.
#let ghost(title: "Buuuuuuh.", icon: emoji.ghost , ..args) = clue(_color: gray, title: title, icon: icon, ..args)
#ghost[Huuuuuuh.]
#tip[Use the `svg-emoji` package until emoji support is fully supported in typst ]
]
#pagebreak()
== List of all predefined clues <predefined>
#columns(2)[
`#abstract`
#abstract[Make it short. This is all you need.]
`#question`
#question[How do amonishments work?]
`#info`
#info[It's as easy as
```typst
#info[Whatever you want to say]
```
]
`#example`,
#example[Testing ...]
`#task`
#task[
#box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, radius: 2pt) Check out this wonderfull typst package!
]
`#error`
#error[Something did not work here.]
`#warning`
#warning[Still a work in progress.]
`#success`
#success[All tests passed. It's worth a try.]
`#tip`
#tip[Try it yourself]
`#conclusion`
#conclusion[This package makes it easy to add some beatufillness to your documents]
`#memo`
#memo[Leave a #emoji.star on github.]
`#quote`
#quote[Keep it simple. Admonish your life.]
=== Headless Variant
just add `title: none` to any example
#info(title:none)[Just a short information.]
] // columns end
|
https://github.com/Jozott00/typst-LLNCS-template | https://raw.githubusercontent.com/Jozott00/typst-LLNCS-template/main/template/theorem_proof_cnf.typ | typst | #import "@preview/lemmify:0.1.4": *
///// private stuff
#let __llncs_thm_style(
thm-type,
name,
number,
body
) = block(width: 100%, breakable: true)[#{
strong(thm-type) + " "
if number != none {
strong(number) + ". "
}
if name != none {
emph[(#name)] + " "
}
emph(body)
}]
#let __llncs_thm_proof_style(
thm-type,
name,
number,
body
) = block(width: 100%, breakable: true)[#{
emph(thm-type) + ". "
body
v(5pt)
}]
#let __llncs-thm-styling = (
thm-numbering: (fig) => {
if fig.numbering != none {
numbering(fig.numbering, ..fig.counter.at(fig.location()))
}
},
thm-styling: __llncs_thm_style,
proof-styling: __llncs_thm_proof_style,
)
#let __llncs_thm_cnf() = {
let thm = default-theorems(
"llcns-thm-group", lang: "en", ..__llncs-thm-styling)
let def = default-theorems(
"llcns-def-group", lang: "en", ..__llncs-thm-styling)
let prop = default-theorems(
"llcns-prop-group", lang: "en", ..__llncs-thm-styling)
let lem = default-theorems(
"llcns-lemma-group", lang: "en", ..__llncs-thm-styling)
let proof = default-theorems(
"llcns-proof-group", lang: "en", ..__llncs-thm-styling)
let coral = default-theorems(
"llcns-coral-group", lang: "en", ..__llncs-thm-styling)
return (
theorem: thm.theorem,
__thm-rules: thm.rules,
definition: def.definition,
__def-rules: def.rules,
proposition: prop.proposition,
__prop-rules: prop.rules,
lemma: lem.lemma,
__lem-rules: lem.rules,
proof: proof.proof,
__proof-rules: proof.rules,
corollary: coral.corollary,
__corol-rules: coral.rules,
)
} |
|
https://github.com/drbartling/obsidian-to-typst | https://raw.githubusercontent.com/drbartling/obsidian-to-typst/master/README.md | markdown | # Obsidian to Typst
This utility attempts to make it easy to convert markdown documents written using obsidian into PDFs.
## Requirements
- typst
- mermaid
- mutool
## Getting Started
This project uses python [poetry](https://python-poetry.org/). Follow the [intallation instructions](https://python-poetry.org/docs/#installation) for poetry.
Install typst using a package manager or `cargo install`
Run `poetry install` and `poetry shell` to install and and activate the python virtual environment.
Than, run `obsidian_to_typst .\examples\feature_guide\Widget.md` to convert the example document to a PDF. The PDF will be placed in `.\examples\feature_guide\output\Widget.pdf`.
```powershell
watchexec --clear --restart --debounce 500 --exts py "isort . && black . && pytest && obsidian-to-typst ./examples/feature_guide/Widget.md"
```
|
|
https://github.com/PorterLu/Typst | https://raw.githubusercontent.com/PorterLu/Typst/main/make_a_template/make_a_template.typ | typst | #let document_title = "Make a Template"
#set par(justify: true)
#set page(
paper: "us-letter",
header: align(right)[
#document_title
],
numbering: "1"
)
#align(center, text(17pt)[* #document_title *])
= Introduction
#h(2em) 在之间的章节中已经介绍了Typst的撰写一篇文章所需要的内容。但是如果你要重复书写同一个会议的论文,这就需要多次编写重复的内容,于是就有了模版的需求。在这一章节中将介绍如何去创建一个模版和使用模版。开始吧!
= A toy Example
#h(2em) 在 Typst 中模版就是将整个文档都包裹的函数。为了学习模版的概念,我们首先回顾一下我们自己的函数
```
#let amazed(term) = box[🤡 #term 🤡]
You are #amazed[beautiful]!
```
#let amazed(term) = box[ 🤡 #term 🤡 ]
#h(2em) You are #amazed[beautiful]!,我们可以看到结果输出正确。这个函数接受一个参数,输出两个表情符号将输入包裹。进一步我们可以改进这个函数。
```
#let amazed(term, color: blue) = {
text(color, box[🤡 #term 🤡])
}
You are #amazed[beautiful]!
```
#let amazed(term, color: blue) = {
text(color, box[🤡 #term 🤡])
}
#h(2em)I am #amazed(color: purple)[amazed]!,这样就可以改变字体的颜色。接下来我们对所有的文本内容都做函数操作。
#show: amazed("I choose to focus on the good
in my life and let go of any
negative thoughts or beliefs,
In fact, I am amazing!", color: blue)
|
|
https://github.com/chamik/gympl-skripta | https://raw.githubusercontent.com/chamik/gympl-skripta/main/cj-dila/7-farma-zvirat.typ | typst | Creative Commons Attribution Share Alike 4.0 International | #import "/helper.typ": dilo, hrule
#dilo("<NAME>", "farma", "<NAME> (<NAME>)", "<NAME>", "1. p. 20. st; Světová lit. 20. st; sci-fi, antiutopie", "Británie", "1945", "epika", "alegorický román (bajka)")
#columns(2, gutter: 1em)[
*Téma*\
kritika komunistického režimu, zejména v tehdejším SSSR
*Motivy*\
pokrytectví, totalitní režimy, politika
*Časoprostor*\
na Anglické farmě v době autora (v době existence SSSR)
*Postavy* \
_Major_ - prase, které přišlo s myšlenkou revoluce na farmě; Marx/Lenin \
_Napoleon_ - kruté prase, které vydobíjí respekt silou; Stalin \
_Kuliš_ - učil ostatní prasata číst a psát, nakonec vyhnán; Trockij \
_Pištík_ - pravá ruka Napoleona; propagandista \
_Boxer_ - pracovitý kůň, který je na konci zrazen \
_<NAME>_ - bývalý majitel farmy vyhnán (a nahrazen) zvířaty; kulak/buržoust
*Kompozice* -- chronologická, kapitoly
*Vypravěč* -- 3. os, vševědoucí
*Jazykové prostředky*\
hodně přímé řeči (dialogy mezi zvířaty), metonymie (ovce tupé stádo, psi věrní, atp.) a metafory, celé je to alegorie, velká písmena pro *R*#[]evoluci
#colbreak()
*Obsah*\
<NAME> je alkoholik vlastnící farmu, kde se nespokojená zvířata rozhodnou udělat převrat. V jeho vedení jsou prasata a nastolí systém až podezřele připomínající komunistický režim. V knize lze nalézt motivy překrucování informací, slibů, nesmyslných dlouhodobých projektů, a ještě méně kvalitního života, než býval dříve. Věrný pracovní kůň Boxer, který je režimem vyzdvihován, je na konci svého života zrazen a dán na salám. Prasata jen využívají tvárnosti obyvatelstva podobně, jako se to doopravdy dělo v SSSR.
*Literárně historický kontext*\
Tato kniha vznikla během druhé světové války a ocenění se jí dostalo až o pár let později.
]
#pagebreak()
*Ukázka*
"[...] Copak není úplně jasné, soudruzi, že toto zlo našeho života pochází z tyranie lidských bytostí? Produkty naší práce nám budou patřit pouze tehdy, zbavíme-li se člověka! Mohli bychom získat svobodu a bohatství téměř ze dne na den! Co tedy musíme udělat? Ve dne v noci, tělem i duší pracovat na svržení lidské rasy. A to je moje poselství, soudruzi: REVOLUCE! Nevím, kdy přijde. Možná za týden, možná za sto let, ale vím tak jistě, jako vidím pod nohama tuhle slámu, že dříve či později zvítězí spravedlnost. A na to se soustřeďte, soudruzi. Zbývá vám už málo času! A především předejte toto mé poselství těm, kteří přijdou po vás, aby budoucí generace dovedly bitvu až do jejího vítězného konce.
Nezapomeňte, soudruzi, že ve své odhodlanosti nesmíte ochabnout. Nic vás nesmí zarazit. Neposlouchejte nikdy ty, kteří vám budou tvrdit, že člověk a zvíře mají společné zájmy, že prospěch jednoho je prospěchem druhého. To vše jsou lži! člověk neuznává zájmy jiného tvora než sebe. A mezi námi zvířaty musí být dokonalá jednota a bojové soudružství. Všichni lidé jsou nepřátelé, všechna zvířata jsou si soudruhy! [...] Žádné zvíře nesmí nikdy bydlet v domě, spát v posteli, nosit šaty, pít alkohol, kouřit, používat peníze či obchodovat. Všechny lidské zvyky jsou špatné. A především: žádné zvíře nesmí nikdy tyranizovat jiné, slabé či silné, chytré či prosté. Všichni jsme si bratry. Žádné zvíře nesmí nikdy zabít jiné zvíře! Všechna zvířata jsou si rovna. [...]"
#hrule()
Někdy v té době se prasata najednou přestěhovala do Jonesova
domu a udělala si z něj dům svůj. A zvířata si vzpomněla, že kdysi
snad byla přijata rezoluce, která právě tyto praktiky zakazovala,
a zase musel nastoupit Kvičoun a přesvědčovat je, že se pletou, že to
je úplně jinak. Je absolutně nutné, řekl, aby prasata, která jsou jak
známo mozky celé farmy, měla k dispozici klidné místo na práci.
Je také v souladu s důstojností Vůdce (poslední dobou nazýval Napoleona vždy „Vůdcem“), aby žil a tvořil v domě, a ne v nějakém
chlívě. Přesto však byla některá zvířata dost zaskočena, když se dozvěděla, že prasata nejenže jedí v kuchyni a udělala si z obýváku salon,
ale k tomu všemu ještě spí v posteli. Boxer to jako vždycky vyřešil
svým obligátním „Napoleon má vždycky pravdu!“, ale Jetelinka, která
si dobře pamatovala na pravidlo výslovně zakazující spaní v posteli,
šla za stodolu a pokoušela se tam rozluštit Sedmero přikázání napsané na vratech. I při sebevětší snaze se jí však nedařilo pospojovat
jednotlivá písmena ve slova, a obrátila se proto na Lízu.
„Lízo,“ řekla, „přečti mi Čtvrté přikázání. Není tam náhodou něco
o zákazu spaní v postelích?“. Líza s občasným zakoktnutím nakonec nápis přečetla. „Říká se tu: „Žádné zvíře nebude nikdy spát v posteli s prostěradly.“. To je vážně zvláštní, Jetelinka si ne a ne vzpomenout, že by se ve
Čtvrtém přikázání říkalo něco o prostěradlech.
#pagebreak()
|
https://github.com/dainbow/MatGos | https://raw.githubusercontent.com/dainbow/MatGos/master/themes/29.typ | typst | #import "../conf.typ": *
= Системы линейных однородных дифференциальных уравнений с постоянными коэффициентами, методы их решения
#definition[
Пусть $bold(x)(t) = vec(x_1 (t), ..., x_n (t)); A in M_n (CC)$
Тогда *Нормальная линейная однородная система уравнений* выглядит так:
#eq[
$dot(bold(x)) = A bold(x)$
]
Где под $dot$ подразумевается дифференцирование по $t$.
]
#theorem[
Если $bold(h_1), ..., bold(h_n)$ -- базис из собственных векторов матрицы $A$,
то $bold(x_i) = e^(lambda_i t)bold(h_i)$ -- ФСР для исходной однородной системы.
]
#proof[
Заметим, что
#eq[
$A(e^(lambda t)bold(h)) = e^(lambda t)(A bold(h)) = e^(lambda t) lambda bold(h) = (e^(lambda t) bold(h))'$
]
Значит собственный вектор является решением.
Их линейная независимость следует из того, что их вронскиан в точке $t = 0$ равен
определителю из координатных столбцов этого базиса, а значит не равен нулю.
]
#definition[
Пусть $t$ -- действительная переменная, $A in M_n (CC)$.
Тогда *матричной экспонентой* называется ряд
#eq[
$e^(t A) := E_n + sum_(k = 1)^oo t^k / k! A^k$
]
]
#lemma[
Свойства матричной экспоненты:
+ Если $S$ невырожденная и $A = S B S^(-1)$, то $forall t in RR : e^(t A) = S e^(t B) S^(-1)$
+ $(e^(t A))'_t = A e^(t A) = e^(t A) A$
]
#theorem(
"Матричная экспонента для ФСР",
)[
Матрица $e^(t A)$ является фундаментальной матрицей для системы линейный
уравнений $dot(bold(x)) = A bold(x)$.
]
#proof[
По свойствам экспоненты
#eq[
$(e^(t A))'_t = A e^(t A)$
]
Значит каждый столбец матрицы $e^(t A)$ является решением исходной систему.
Поскольку $forall t in RR : det e^(t A) != 0$, то $e^(t A)$ фундаментальна.
]
|
|
https://github.com/Shambuwu/stage-docs | https://raw.githubusercontent.com/Shambuwu/stage-docs/main/documenten/ontwerprapport.typ | typst | #align(
center,
text(
size: 1.2em,
[
*Competentie: Ontwerpen* \
Ontwerprapport en onderbouwing \
],
)
)
#align(
center,
figure(
image("../bijlagen/ontwerprapport/OIG.jpg",
width: 400pt
)
)
)
#let date = datetime(
year: 2023,
month: 6,
day: 30
)
#place(
bottom + left,
text[
*Student:* <NAME> \
*Studentnummer:* 405538 \
*Datum:* #date.display() \
*Onderwerp:* Competentie: Analyseren \
*Opleiding:* HBO-ICT \
*Studiejaar:* 3 \
]
)
#place(
bottom + right,
image("../bijlagen/logo.png", width: 175pt)
)
#pagebreak()
#set heading(numbering: "1.1")
#show heading: it => {
set block(below: 10pt)
set text(weight: "bold")
align(left, it)
}
#outline(
title: [
*Inhoudsopgave*
],
)
#set page(
numbering: "1 / 1",
number-align: right,
)
#pagebreak()
= Samenvatting
Dit ontwerprapport beschrijft de ontwikkeling van een datavisualisatietool voor de voedingsindustrie. Het doel van dit project was om een tool te ontwerpen die gebruikers in staat stelt om recepten en ingrediënten op een visuele en interactieve manier te verkennen en analyseren.
Het rapport begint met een probleemdefinitie, waarin de behoefte aan geavanceerde datavisualisatietools in de voedingsindustrie wordt beschreven. Vervolgens worden de ontwerpeisen opgesteld, waarbij concrete, meetbare criteria worden geformuleerd op basis van klantbehoeften. Daarna volgt een technische beoordeling, waarin de belangrijkste aspecten van het ontwerpgebied worden behandeld en de keuzes voor de gebruikte technologieën worden toegelicht.
Het ontwerp van de datavisualisatietool bestaat uit verschillende componenten, waaronder een React frontend, een Symfony backend en een Neo4j database. De frontend biedt een intuïtieve gebruikersinterface, terwijl de backend de logica en functionaliteiten beheert en communiceert met de database via de Neo4j Object Graph Mapper (OGM). Deze architectuur zorgt voor schaalbaarheid, modulariteit en efficiënte verwerking van complexe relaties tussen recepten, ingrediënten en andere gegevens.
Het ontwerp is uitgebreid getest en geëvalueerd aan de hand van functionele tests en gebruikersfeedback. De tests hebben aangetoond dat de tool voldoet aan de gestelde ontwerpeisen en functionaliteiten zoals zoeken, filteren en visualisatie correct functioneren. De gebruikerservaring is positief beoordeeld, waarbij de gebruikersinterface als overzichtelijk en gebruiksvriendelijk wordt ervaren.
De ontwerpbeoordeling concludeert dat het ontwerp over het algemeen effectief en efficiënt is, met enkele verbeterpunten om de gebruikerservaring verder te optimaliseren. Aanbevelingen voor toekomstig werk omvatten het implementeren van ontbrekende functionaliteiten en het verfijnen van de gebruikersinterface op basis van gebruikersfeedback.
Dit ontwerprapport biedt een gedetailleerd inzicht in het ontwerp en de ontwikkeling van de datavisualisatietool, waarbij voldaan wordt aan de gestelde ontwerpeisen en rekening gehouden wordt met de behoeften van de gebruikers in de voedingsindustrie. Het ontwerp legt een solide basis voor verdere ontwikkeling en implementatie van de tool, met het potentieel om waardevolle inzichten te bieden en innovatie te stimuleren in de voedingssector.
#pagebreak()
= Probleem definitie
== Probleemscope
De probleemscope van dit ontwerprapport richt zich op het ontwerp van een datavisualisatietool voor de voedingsindustrie. Het probleem dat moet worden aangepakt, is het gebrek aan een gebruiksvriendelijke tool waarmee gebruikers recepten en ingrediënten kunnen zoeken, filteren, visualiseren en alternatieve ingrediënten kunnen identificeren.
De scope van dit ontwerprapport omvat het ontwerpproces van de datavisualisatietool, waarbij de nadruk ligt op het creëren van een intuïtieve gebruikersinterface, het ontwerpen van relevantie zoek- en filtermogelijkheden, en het visualiseren van de gegevens op een overzichtelijke manier.
== Technische beoordeling
Deze technische beoordeling biedt een overzicht van de belangrijkste aspecten die relevant zijn voor het ontwerp van de datavisualisatietool. Het doel van deze beoordeling is om inzicht te krijgen in recente ontwikkelingen op het gebied van datavisualisatie, de huidige staat van de voedingsindustrie, en de technische mogelijkheden van de datavisualisatietool.
=== Achtergrondinformatie
In de voedingsindustrie is er een toenemende behoefte aan geavanceerde tools die het zoeken, filteren en visualiseren van recepten en ingrediënten mogelijk maken. Deze tools kunnen bijdragen aan het identificeren van alternatieve ingrediënten, het optimaliseren van voedingswaarden en het bevorderen van innovatie. Het ontwikkelen van een datavisualisatietool kan hierin een cruciale rol spelen.
=== Huidige stand van zaken
Binnen het vakgebied van datavisualisatie zijn er verschillende technologieën en benaderingen die relevant zijn voor dit project. Grafische bibliotheken zoals D3.js, Plotly en Highcharts bieden geavanceerde mogelijkheden voor het creëren van interactieve en visueel aantrekkelijke visualisaties. Daarnaast zijn er frameworks zoals React en Angular die kunnen worden gebruikt voor de ontwikkeling van de gebruikersinterface.
Er zijn reeds verschillende tools beschikbaar die het zoeken, filteren en visualiseren van recepten en ingrediënten mogelijk maken. Enkele voorbeelden hiervan zijn Foodpairing, Yummly en FoodData Central. Het is essentieel om deze tools te onderzoeken om inzicht te krijgen in de sterke punten en verbeterpunten ervan, om zo een effectieve datavisualisatietool te kunnen ontwerpen.
=== Best practices en richtlijnen
Het ontwerpen van een effectieve datavisualisatietool vereist het volgen van best practices en richtlijnen op het gebied van gebruikerservaring, interactieontwerp en visualisatietechnieken. Enkele belangrijke aspecten om rekening mee te houden zijn:
- Zorg voor een intuïtieve gebruikersinterface die eenvoudig te navigeren is.
- Bied interactieve filters en zoekmogelijkheden om de gebruiker te helpen bij het vinden van relevante informatie.
- Gebruik geschikte grafische representaties, zoals staafdiagrammen, taartdiagrammen en netwerkdiagrammen, om de gegevens effectief te communiceren.
- Maak gebruik van kleur, vorm en grootte om belangrijke informatie te benadrukken en visueel te onderscheid te maken.
- Zorg voor responsieve en schaalbare ontwerpen, zodat de tool op verschillende apparaten kan worden gebruikt.
Het begrijpen van deze technische aspecten en het volgen van best practices zal bijdragen aan het succesvol ontwerpen van de datavisualisatietool. Door gebruik te maken van de juiste technologieën en ontwerpprincipes kan een effectieve tool worden ontwikkeld die voldoet aan de eisen van de gebruikers.
== Ontwerpeisen
De ontwerpeisen vormen de kern van het ontwerp en zijn gebaseerd op de behoeften van de opdrachtgever en gebruikers. De volgende meetbare ontwerpeisen zijn vastgesteld om te voldoen aan de verwachtingen van het systeem:
+ *Toegankelijkheid via webapplicatie:*
- De webapplicatie moet toegankelijk zijn via gangbare webbrowsers, zoals Chrome, Firefox en Safari.
- De laadtijd van de webpagina's mag niet langer zijn dan 3 seconden.
+ *Zoekfunctionaliteit:*
- Het systeem moet in staat zijn om recepten en ingrediënten te doorzoeken op basis van opgegeven zoektermen.
- De zoekresultaten moeten binnen 2 seconden worden weergegeven.
- Het systeem moet een nauwkeurigheidspercentage van 90% hebben bij het identificeren van relevante zoekresultaten.
+ *Filterfunctionaliteit:*
- Het systeem moet de mogelijkheid bieden om recepten en ingrediënten te filteren op basis van specifieke criteria, zoals voedingswaarde en allergenen.
- De toegepaste filters moeten de resultaten nauwkeurig en consistent beperken.
+ *Visualisatie van recepten en ingrediënten:*
- Het systeem moet visuele weergaven en presentaties genereren van het recepten- en ingrediëntennetwerk.
- De visualisaties moeten duidelijk, overzichtelijk en begrijpelijk zijn voor de gebruikers.
- Het systeem moet de mogelijkheid bieden om in te zoomen, uit te zoomen en te navigeren binnen de visualisaties.
+ *Identificatie van alternatieve ingrediënten:*
- Het systeem moet alternatieve ingrediënten kunnen identificeren op basis van specifieke criteria, zoals voedingswaarde, smaak en vergelijkbare recepten.
- Het systeem moet minimaal 80% nauwkeurigheid hebben bij het aanbevelen van alternatieve ingrediënten.
Deze ontwerpeisen vormen de basis voor het ontwerp van de datavisualisatietool en zullen ervoor zorgen dat de tool voldoet aan de behoeften van de opdrachtgever en gebruikers.
#pagebreak()
= Ontwerpbeschrijving
De ontwerpbeschrijving biedt een gedetailleerde uitleg van het ontwerp van de datavisualisatietool voor de voedingsindustrie. Dit hoofdstuk is opgedeeld in drie secties: Overzicht, Gedetailleerde beschrijving en Gebruik.
== Overzicht
Het ontwerp van de tool is gebaseerd op een client-server database model. Het bestaat uit een React frontend, een Symfony backend en een Neo4j-database. Alle componenten draaien in Docker containers, waardoor het gemakkelijk te implementeren en schaalbaar is. Het ontwerp streeft ernaar om een gebruiksvriendelijke webapplicatie te bieden waarmee gebruikers recepten en ingrediënten kunnen zoeken, filteren, visualiseren en alternatieve ingrediënten kunnen identificeren.
== Gedetailleerde beschrijving
Het ontwerp van de datavisualisatietool is gebaseerd op zorgvuldige ontwerpkeuzes die zijn gemaakt om de gewenste functionaliteiten te realiseren en een optimale gebruikerservaring te bieden.
=== Client-server database model
Het gebruik van een client-server database model biedt verschillende voordelen. Het maakt een schaalbare architectuur mogelijk, waarbij de frontend en backend onafhankelijk van elkaar kunnen worden opgeschaald om aan de groeiende vraag te voldoen. Daarnaast zorgt de scheiding tussen de frontend en backend ervoor dat de applicatie flexibel is en gemakkelijk kan worden aangepast of uitgebreid. Het gebruik van Docker helpt bij het vereenvoudigen van de implementatie en het beheer van de applicatie door de containerisatie van de componenten.
=== Frontend (React)
React is gekozen als het frontend-library vanwege zijn efficiënte, herbruikbare componenten en zijn vermogen om snelle en responsieve gebruikersinterfaces te creëren. Met React kunnen interactieve elementen en dynamische updates gemakkelijk worden geïmplementeerd, waardoor een vloeiende gebruikerservaring ontstaat. Daarnaast biedt React de mogelijkheid om componenten opnieuw te gebruiken, waardoor de ontwikkeltijd wordt verkort en de codebase overzichtelijk blijft.
#figure(
image("../bijlagen/ontwerprapport/design_2.png",
width: 300pt
),
caption: "Een eerste werkende demo van het frontendontwerp",
supplement: "Figuur",
kind: "figure"
)
React biedt de volgende voordelen die bijdragen aan het realiseren van de ontwerpeisen:
- *Modulaire componenten:* Met React kunnen componenten worden opgesplitst in herbruikbare modules, wat zorgt voor een modulaire en goed gestructureerde codebase. Dit maakt het gemakkelijk om de code te onderhouden en uit te breiden.
- *Interactieve gebruikersinterface:* React maakt het mogelijk om interactieve elementen en dynamische updates te implementeren, waardoor een vloeiende gebruikerservaring ontstaat.
- *Herbruikbaarheid:* React biedt de mogelijkheid om componenten opnieuw te gebruiken, waardoor de ontwikkeltijd wordt verkort en de codebase overzichtelijk blijft.
=== Backend (Symfony)
Symfony is gekozen als het backend-framework vanwege zijn krachtige mogelijkheden op het gebied van webontwikkeling. Het is een betrouwbaar, robuust en flexibel framework dat een solide basis biedt voor het ontwikkelen van complexe webapplicaties. Symfony volgt de principes van het Model-View-Controller (MVC) ontwerppatroon, wat helpt bij het scheiden van de logica, het datamodel en de presentatie van de applicatie. Dit zorgt voor een modulaire en goed gestructureerde codebase, waardoor onderhoud en uitbreiding van de applicatie gemakkelijker worden.
Symfony biedt verschillende voordelen die bijdragen aan het voldoen aan de ontwerpeisen:
- *Betrouwbaarheid en flexibiliteit:* Symfony is een betrouwbaar en robuust framework. Het biedt flexibiliteit in termen van architectuur en functionaliteiten, waardoor het mogelijk is om de backend af te stemmen op de specifieke behoeften van de datavisualisatietool.
- *Model-View-Controller (MVC) Patroon:* Het toepassen van het Model-View-Controller (MVC) patroon in Symfony heeft als voordeel dat het de applicatie in modulaire componenten opdeelt, waardoor de codebase goed gestructureerd is. Deze modulaire structuur maakt het eenvoudiger om onderhoudstaken uit te voeren en de applicatie uit te breiden met nieuwe functionaliteiten. Door de scheiding van verantwoordelijkheden tussen het model, de view en de controller is het gemakkelijker om wijzigingen aan te brengen in specifieke onderdelen zonder de rest van de applicatie te beïnvloeden. Dit bevordert de flexibiliteit en maakt het mogelijk om de codebase beter te beheren en te onderhouden over de tijd.
- *Communicatie met de database:* Symfony communiceert met de Neo4j-database via de Neo4j Object Graph Mapper (OGM). De OGM biedt een abstractielaag voor de communicatie met de database en maakt het gemakkelijk om objectgeoriënteerde modellen te mappen naar de grafenstructuur van Neo4j. Dit zorgt voor een efficiënte interactie met de database en het ophalen en manipuleren van de benodigde gegevens.
=== Database (Neo4j)
De keuze voor Neo4j als de databaseoplossing is gebaseerd op de unieke mogelijkheden van een grafendatabase voor het opslaan en bevragen van complexe relaties tussen entiteiten. De grafenstructuur van Neo4j maakt het gemakkelijk om de onderlinge verbanden tussen recepten, ingrediënten en andere gegevens vast te leggen. Dit is vooral waardevol in de voedingsindustrie, waar de relaties tussen ingrediënten en recepten vaak complex zijn.
- *Grafenstructuur:* Een van de voordelen van Neo4j is de grafenstructuur, die het mogelijk maakt om complexe relaties tussen recepten, ingrediënten en andere gegevens efficiënt vast te leggen. Door gebruik te maken van deze grafenstructuur kan de applicatie waardevolle inzichten genereren door de onderlinge verbanden tussen de entiteiten te verkennen.
- *Efficiënte bevraging van gegevens:* Daarnaast biedt Neo4j geavanceerde querymogelijkheden die specifiek zijn ontworpen voor grafen. Deze querymogelijkheden stellen de applicatie in staat om complexe zoek- en filteroperaties efficiënt uit te voeren, wat resulteert in een verbeterde responstijd van de applicatie. Door deze efficiënte bevraging van gegevens kan de datavisualisatietool snel en nauwkeurig reageren op gebruikersverzoeken.
- *Schaalbaarheid:* Een ander belangrijk aspect is de schaalbaarheid van Neo4j. Het kan gemakkelijk worden opgeschaald om te voldoen aan de groeiende vraag naar dataverwerking. Dit betekent dat de applicatie eenvoudig kan worden uitgebreid en kan voldoen aan de behoeften van een groeiend aantal gebruikers en een grotere dataset.
#figure(
image("../bijlagen/ontwerprapport/design_1.png",
width: 400pt
),
caption: "Architectuur van het ontwerp",
supplement: "Figuur",
kind: "figure"
)
Hierboven is een schematische weergave te zien van de architectuur van het ontwerp. De frontend communiceert met de backend via API-calls. De backend communiceert met de neo4j database via de OGM. De neo4j database bevat de verzameling van recepten, ingrediënten en gerelateerde gegevens.
Deze architectuur biedt verschillende voordelen, zoals schaalbaarheid, modulariteit en efficiënte interactie met de database. Het stelt de datavisualisatietool in staat om gebruikersvriendelijke functionaliteiten te bieden, zoals zoeken, filteren, visualiseren en identificeren van alternatieve ingrediënten. Door de scheiding van verantwoordelijkheden tussen de frontend, backend en database is de applicatie flexibel, onderhoudbaar en gemakkelijk uitbreidbaar.
== Gebruik
Het ontwerp van de datavisualisatietool is bedoeld om gebruikers in staat te stellen recepten en ingrediënten te verkennen, filteren, visualiseren en alternatieven te identificeren. De tool is ontworpen als een webapplicatie, waardoor gebruikers eenvoudig toegang hebben tot de functionaliteiten via een webbrowser.
Wanneer een gebruiker de webapplicatie opent, wordt deze verwelkomd met een intuïtieve gebruikersinterface. Hier kan de gebruiker navigeren door de verschillende functionaliteiten en acties uitvoeren.
De zoekfunctionaliteit stelt gebruikers in staat om specifieke recepten en ingrediënten te vinden door zoektermen in te voeren. Het ontwerp zorgt ervoor dat de zoekresultaten binnen enkele seconden worden weergegeven. Gebruikers kunnen ook filters toepassen om de resultaten verder te verfijnen op basis van criteria zoals voedingswaarde, allergenen en andere eigenschappen.
Het ontwerp omvat ook de mogelijkheid om recepten en ingrediënten visueel weer te geven. Gebruikers kunnen interactieve visualisaties verkennen, inzoomen op details en uitzoomen voor een breder overzicht. De visualisaties zijn ontworpen om de relaties tussen recepten, ingrediënten en andere gegevens duidelijk en begrijpelijk te tonen.
Daarnaast biedt het ontwerp de functionaliteit om alternatieve ingrediënten te identificeren op basis van specifieke criteria, zoals voedingswaarde, smaak en vergelijkbare recepten. Dit stelt gebruikers in staat om verschillende opties te verkennen en alternatieven te vinden die passen bij hun specifieke behoeften of dieetvereisten.
Het ontwerp van de datavisualisatietool is gericht op het bieden van een intuïtieve en gebruiksvriendelijke ervaring voor gebruikers. Door middel van de ontworpen functionaliteiten kunnen gebruikers op een effectieve en efficiënte manier recepten en ingrediënten verkennen, filteren, visualiseren en alternatieven identificeren.
#pagebreak()
= Evaluatie
In dit gedeelte wordt het ontwerp van de datavisualisatietool geëvalueerd aan de hand van een aantal criteria. Deze criteria zijn gebaseerd op de ontwerpeisen en de verwachtingen van de opdrachtgever en gebruikers.
Om het ontwerp te evalueren, wordt er gebruik gemaakt van een aantal evaluatiemethoden, waaronder functionele tests en prestatietests. Deze evaluatiemethoden zullen helpen bij het beoordelen van de effectiviteit en efficiëntie van het ontwerp.
== Testen en resultaten
=== Functionele tests
Er zijn uitgebreide tests uitgevoerd om ervoor te zorgen dat de datavisualisatietool naar behoren functioneert en voldoet aan de gestelde ontwerpeisen. Deze tests zijn uitgevoerd op zowel de frontend als de backend om de functionaliteiten van de tool te controleren en te valideren. Aan de frontend zijn verschillende functionele tests uitgevoerd om de gebruikersinterface te controleren en te valideren. Aan de backend zijn verschillende functionele tests uitgevoerd om de API-calls te controleren en te valideren. De resultaten van deze tests zijn weergegeven in de onderstaande tabellen.
#figure(
[
#table(
columns: (auto, auto, auto),
[Testcase], [Verwacht resultaat], [Werkt zoals verwacht?],
[Zoeken op naam], [Recepten met overeenkomende naam worden weergegeven], [Ja],
[Zoeken op ingrediënt], [Recepten met het opgegeven ingrediënt worden weergegeven], [Ja],
[Zoeken op voedingswaarde], [Recepten met de opgegeven voedingswaarde worden weergegeven], [N/A],
[Filteren op allergenen], [Recepten zonder de opgegeven allergenen worden weergegeven], [N/A],
[Filteren op categorie], [Recepten binnen de opgegeven categorie worden weergegeven], [N/A]
)
],
caption: "Functionele tests frontend",
supplement: "Tabel",
)
Bepaalde tests zijn niet uitgevoerd omdat de functionaliteit nog niet is geïmplementeerd. Deze tests zullen worden uitgevoerd zodra de functionaliteit is geïmplementeerd.
=== Gebruikersfeedback
Naast tests is er ook feedback verzameld van de opdrachtgever om inzicht te krijgen in de gebruikerservaring en de verwachtingen. De feedback is waardevol gebruikt om het ontwerp te verbeteren en de functionaliteiten aan te passen aan de behoeften van de gebruikers.
== Ontwerpbeoordeling
Het ontwerp van de datavisualisatietool is grondig geëvalueerd op basis van functionele tests en gebruikersfeedback. Hieronder volgt een beoordeling van het ontwerp:
- Functionaliteit: De uitgevoerde functionele tests hebben aangetoond dat de datavisualisatietool voldoet aan de gestelde ontwerpeisen. De zoekfunctionaliteit, filtermogelijkheden en visualisaties werken zoals verwacht en bieden gebruikers de mogelijkheid om op een intuïtieve manier recepten en ingrediënten te vinden en te analyseren.
- Gebruikerservaring: De feedback van de opdrachtgever is positief en geeft aan dat de gebruikersinterface overzichtelijk en gebruiksvriendelijk is. De visuele presentaties van recepten- en ingrediëntennetwerken zijn duidelijk en begrijpelijk, waardoor gebruikers waardevolle inzichten kunnen verkrijgen. De prestatietests hebben aangetoond dat de tool snel reageert en voldoet aan de verwachtingen qua laadtijd.
- Verbeterpunten: Tijdens de evaluatie zijn enkele verbeterpunten naar voren gekomen. Zo zijn bepaalde functionaliteiten nog niet geïmplementeerd en zullen deze in een latere fase worden getest. Daarnaast zijn er enkele suggesties gegeven om de gebruikerservaring verder te optimaliseren, zoals het verbeteren van de navigatie en het toevoegen van aanvullende functionaliteiten.
Op basis van de evaluatie kan geconcludeerd worden dat het ontwerp van de datavisualisatietool over het algemeen goed voldoet aan de gestelde ontwerpeisen en de verwachtingen van de gebruikers. Er zijn nog enkele verbeterpunten die kunnen worden doorgevoerd om de gebruikerservaring verder te versterken. Aanbevelingen voor toekomstig werk omvatten het implementeren van de ontbrekende functionaliteiten en het verder finetunen van de gebruikersinterface op basis van gebruikersfeedback.
#pagebreak()
= Bronnen
#align(left,
table(
columns: (auto, auto, auto),
rows: (auto, auto, auto),
align: left,
inset: 10pt,
stroke: none,
[*Bijlagen*], [], [],
[Hanzehogeschool Groningen logo], [Hanzehogeschool Groningen], [https://freebiesupply.com/logos/hanzehogeschool-groningen-logo/],
[Titelpagina figuur], [DALL-E-2, OpenAI], [bijlagen -> analyserapport -> OIG.jpg],
[Sequentiediagram 1], [<NAME>], [bijlagen -> analyserapport -> use_case_1.png],
[Sequentiediagram 2], [<NAME>], [bijlagen -> analyserapport -> use_case_2.png],
[Sequentiediagram 3], [<NAME>], [bijlagen -> analyserapport -> use_case_3.png],
)
) |
|
https://github.com/drupol/cv | https://raw.githubusercontent.com/drupol/cv/master/src/cv/common/lib.typ | typst | #import "metadata.typ": *
#import "@preview/fontawesome:0.4.0": *
#let languageItem(
lang: "",
level: "",
comment: ""
) = {
block(
grid(
columns: (1fr, 1fr),
align: (left, right),
)[
#text(weight: "bold", lang)
#box(width: 1fr, repeat[.])
][
#box(width: 1fr, repeat[.])
#text(fill: black.lighten(70%))[#level]
#text(fill: black.lighten(70%))[#comment]
],
)
}
#let educationEntry(
title: "",
school: "",
date: "",
type: "",
grade: "",
body,
) = {
set text(size: font-defaults.footnotesize)
block(
grid(
columns: (1fr, 4fr),
align: (left, left),
)[
#date\
#text(fill: black.lighten(70%))[#grade]
][
#grid(
columns: (1fr, 1fr),
align: (left, right),
text(weight: "bold", title), school,
)
#body
],
)
}
#let jobEntry(
title: "",
company: "",
location: "",
date: "",
type: "",
tags: (),
body,
) = {
block(
grid(
columns: (1fr, 5fr),
align: (left, left),
)[
#date\
#text(fill: black.lighten(70%))[#type]\
#text(fill: black.lighten(70%))[#location]
][
#if title != "" and company != "" {
grid(
columns: (1fr, 1fr),
align: (left, right),
text(weight: "bold", title), company,
)
}
#body
#{
set text(font: "New Computer Modern Mono", fill: black.lighten(60%))
grid(columns: (1fr), tags.join(" / "))
}
],
)
}
#let linkItem(body, icon: "") = {
block(
grid(
columns: (auto, auto),
column-gutter: .3em,
align: horizon,
box(width: 2em, height: 2em, fill: black)[
#{
set align(center + horizon)
fa-icon(icon, fill: white)
}
],
body,
),
)
}
#let customBox(
body,
title: "",
) = {
block(
grid(rows: 2)[
#{
block(fill: black, inset: .3em)[
#text(fill: white, size: font.large)[#upper(title)]
]
}
][
#v(.5em)
#body
],
)
}
#let featureBar(
title: "Skills",
value: 100%,
) = {
{
block()[
#grid(
columns: (1fr, 1fr),
column-gutter: 1em,
align: horizon,
align(right)[#title], line(stroke: .75em + black, length: value),
)
]
}
}
|
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/array-29.typ | typst | Other | // Test the `join` method.
#test(().join(), none)
#test((1,).join(), 1)
#test(("a", "b", "c").join(), "abc")
#test("(" + ("a", "b", "c").join(", ") + ")", "(a, b, c)")
|
https://github.com/PorterLu/Typst | https://raw.githubusercontent.com/PorterLu/Typst/main/formatting/typst_demo.typ | typst | #set par(justify: true, leading: 0.52em)
#set text(font: "New Computer Modern", size: 12pt)
#set page(paper: "a4", margin: (x: 1.8cm, y: 1.5cm))
Typst是一个新的文本编辑器,可以从某种程度上替代Latex,从文将记录笔者学习Typst的过程。在 www.typst.app 上,我们可以在左侧编辑文件,等待一段时间后右侧就会自动渲染完成。
= 1介绍
== 1.1 段落
在行首添加 = 可以使得文件变为标题,两个 = 可以开启二级标题,同时使用 ‘\_’ 可以开启强调 _强调_, _Emphasize_,现在发现中文的强调不是很明显。
添加一个段落需要加入一个空行即可,如果要列出小点,只需要使用在每一行使用'\+'即可,同时在可以使用'\-'列出子弹列表,例如列出宝可梦三原色,同时举例两只火系宝可梦:
+ 红
- 小火龙
- 帝君
+ 绿
+ 蓝
== 1.2 图片
#figure(
image("pikachu.png", width : 50%),
caption: [
A pikachu
],
) <pikachu>
我们使用 `#image` 函数可以添加一张图片。如果为图片添加一个标题,那么可以使用 `#figure` 函数,在`image`属性中添加图片,caption属性中添加标题,这时图片会默认居中。如果在 `figure` 最后使用 `<label_name>`, label_name就会成为这个图片的引用名,可以使用`@label_name`进行引用,如@pikachu。
== 1.3 引用
我们使用`#bibliography`函数添加一个`bib`文件,使用`#cite`函数进行具体引用,如 #cite("lee2019keystone")。
#bibliography("typst.bib")
== 1.4 数学公式
和其他工具一致,typst中使用`$$`可以开启行内公式,如$Q = rho A v + C$。为了使用行间公式,我们可以独立一行输入` $$ `,记得公式开头和末尾都加上空格。
$ 7.32 beta + sum_(i = 0)^nabla Q_i / 2 $
更多的数学公式写法可以参考typst的数学公式页面。
= 2 格式
== 2.1 规则(rule)
`#par(justify: true)[...]` 可以将其中的文字设置为每行都对齐,如果不想每次都使用一个括号将段落包裹,可以考虑使用规则的语法,使用`#set par(justify: true)`, 本文档已经使用了该对齐语法,可以看见每一行的长度都是相同的。
== 2.2 配置页面属性
有了规则语法后,下面是一些常用选项:
+ text:设置文本字体、大小、颜色等;
+ page:设置页面大小、边框、标头、列和注脚等;
+ par:设置行对齐和行间距等;
+ heading:设置标题和页号使能;
+ document:设置PDF输出的元数据,例如文章题目和作者。
本文的设置如下:
```
#set par(justify: true, leading: 0.52em)
#set text(font: "New Computer Modern", size: 12pt)
#set page(paper: "a4", margin: (x: 1.8cm, y: 1.5cm))
```
== 2.3 对齐
#align(center + bottom)[
#image("pikachu.png", width: 50%)
*A pikachu.*
]
通过使用`#align`可以设置图片的对齐模式,如上图中使用`#align(center + bottom)`。
== 2.4 加入一点复杂性
#set heading(numbering: "1.a")
= Big Title
== Normal Title
=== Small Title
通过`#set heading(number: "1.a")`, 可以设置标题前面标号的格式。
#set heading(numbering: none)
== 2.5 函数
#show "withPikachu": name => box[
#box(image(
"pikachu.png",
height: 2em,
))
#name
]
withPikachu 测试函数,这里我们通过`#show` 定义了一个函数可以每次输出固定字符串都自带一个图片。
|
|
https://github.com/Axot017/CV | https://raw.githubusercontent.com/Axot017/CV/master/modules_en/skills.typ | typst | #import "@preview/brilliant-cv:2.0.2": cvSection, cvSkill, hBar
#let metadata = toml("../metadata.toml")
#let cvSection = cvSection.with(metadata: metadata)
#cvSection("Skills")
#cvSkill(
type: [Languages],
info: [Polish - native #hBar() English - B2 ]
)
#cvSkill(
type: [Tachnologies],
info: [
Java #hBar() Spring #hBar() Spock #hBar() MongoDB #hBar() Keycloak #hBar() Kafka #hBar()
Go #hBar() SQL (MySQL, PostgreSQL) #hBar() AWS #hBar() Terraform #hBar() Flutter #hBar() Git #hBar()
Rust #hBar() DynamoDB #hBar() Docker #hBar() Dart #hBar()
Firebase #hBar() Neovim #hBar() GitHub Actions #hBar() Postman
]
)
#v(6pt)
|
|
https://github.com/7sDream/fonts-and-layout-zhCN | https://raw.githubusercontent.com/7sDream/fonts-and-layout-zhCN/master/chapters/04-opentype/deltas-2.typ | typst | Other | #import "/lib/draw.typ": *
#import "deltas-1.typ": start, end, graph as delta-1, p2, p3, p5, arrow-line-size, arrow-head-scale, main-txt-size
#let arrow-color = yellow
#let ps = (p2, p3, p5)
#let graph = with-unit((ux, uy) => {
delta-1
let arrow-relative = (
(-300, -20),
(-300, 150),
(-300, -30),
)
for (s, r) in ps.zip(arrow-relative) {
arrow(s, r, relative: true, stroke: arrow-line-size * ux + arrow-color, head-scale: 1.5)
}
let p = p5.zip(arrow-relative.last()).map(((a, b)) => a + b)
txt([字宽压缩#linebreak()沿此移动], p, anchor: "cb", dy: 30)
})
#canvas(
end, start: start,
width: 40%,
graph,
)
|
https://github.com/Shuenhoy/modern-zju-thesis | https://raw.githubusercontent.com/Shuenhoy/modern-zju-thesis/master/dependency/i-figured.typ | typst | MIT License | #import "@preview/i-figured:0.2.4": * |
https://github.com/han0126/MCM-test | https://raw.githubusercontent.com/han0126/MCM-test/main/2024校赛typst/chapter/chapter1.typ | typst | = 问题重述
== 问题背景
在大学时代,参加各种学科竞赛是一种积极而富有意义的行为。这不仅是一种展示个人才华和专业知识的机会,更是一次锻炼和成长的过程。参加竞赛可以让学生在激烈的竞争中学会团队合作、解决问题的能力,并且通过与来自不同院校、不同背景的同学交流,拓展自己的视野,结交志同道合的朋友,建立起深厚的人际关系网络。因此,大学生积极参与学科竞赛,不仅是对自身能力的锻炼和提升,更是一种全面发展和自我实现的重要途径。通过竞赛,学生能够在学业上取得优异成绩,在人格上得到更深的塑造,为未来的发展奠定坚实的基础。由此,慎重地对大学生各种赛事的选择尤为重要,对大学生面临的各种竞赛赛事的评估和分析也成为值得深思的实际问题。
== 问题提出
本题给出了中国高等教育学会高校竞赛评估与管理体系研究专家工作组发布《2023全国普通高校大学生竞赛分析报告》中包含的13个普通本科院校大学生竞赛榜单、11个高职院校大学生竞赛榜单、3个省份大学生竞赛榜单。需根据各赛事的运营情况,确立评价标准和规则,建立分级条件并对数据进行处理分析,量化处理并建立模型,对各项赛事进行分级评价和排序。具体问题如下:
1. 对竞赛目录中的84项赛事进行筛选,选择合适的评价指标并对数据进行量化处理,最后对选取的赛事进行综合评价并分类。
2. 对进入观察目录的34项赛事进行评价指标的选取,并选择评价方法进行综合评价分析,预测出最有可能进入竞赛目录的赛事。
3. 根据设置的不同问卷数据,要求建立参赛的人数与每周理论和实践培训以及投入之间的数学模型。并针对建立的模型,推算讨论得到使得参加学生比例呈现最高水平的最佳的培训时间和投入。最后根据建模以及讨论的结果从综合应用价值和改进方式等方面给学校相关部门提出对应的建议和意见。 |
|
https://github.com/zenor0/FZU-report-typst-template | https://raw.githubusercontent.com/zenor0/FZU-report-typst-template/main/fzu-report/utils/outline-tools.typ | typst | MIT License | #import "states.typ": *
#import "../utils/fonts.typ": 字体, 字号
/*
这里有一个巨大的自造轮子用于显示目录。
由于 heading 跨页问题,如果使用 Typst 内置的目录,将导致页码显示错误、链接跳转锚点不正确。故仍使用自造轮子。
请查阅 `utils/show-heading.typ` 以查看 heading 跨页的其他影响 。如有更好的解决方案,欢迎给出建议或提交 PR。
*/
#let cn-outline(
outline-depth: 3,
base-indent: 1em,
first-level-spacing: none,
first-level-font-weight: "regular",
show-self-in-outline: true,
item-spacing: 14pt,
use-raw-heading: false,
) = [
#set text(font: 字体.宋体, size: 字号.小四)
#set par(leading: item-spacing, first-line-indent: 0pt)
#locate(loc => {
let elems = query(heading.where(outlined: true), loc)
for el in elems {
let el_real_loc = query(selector(<__heading__>).after(el.location()), el.location()).first().location()
let outlineline = {
if (el.level == 1) {
v(if first-level-spacing != none {first-level-spacing} else {item-spacing} - 1em)
// 一级标题前更长的空间
}
h((el.level - 1) * 2em + base-indent)
if el.level == 1 {
set text(weight: first-level-font-weight)
if chapter-numbering-show-state.at(el_real_loc) != none {
chapter-numbering-show-state.at(el_real_loc)
h(0.5em)
}
if use-raw-heading {
chapter-name-str-state.at(el_real_loc)
} else {
chapter-name-show-state.at(el_real_loc)
}
} else if el.level <= outline-depth and chapter-numbering-show-state.at(el_real_loc) != none {
chapter-numbering-show-state.at(el_real_loc)
h(0.3em)
chapter-name-show-state.at(el_real_loc)
} else {continue}
box(width: 1fr, h(10pt) + box(width: 1fr, repeat[.]) + h(10pt))
chapter-page-number-show-state.at(el_real_loc)
linebreak()
}
link(el_real_loc)[#outlineline]
}
})
] |
https://github.com/optimizerfeb/MathScience | https://raw.githubusercontent.com/optimizerfeb/MathScience/main/personal/fast_exp/문서.typ | typst | #set text(font: "KoPubDotum_Pro")
#set page(paper: "a4", margin: 5%)
$x, y$ 는 $e^x = y$ 를 만족하는 Float32 타입의 수, $i, j$ 는 각각 $x, y$ 의 각 비트를 보존한 채 Int32 로 인식시킨 수라고 하자. $b in [0, 1]$ 일 때 $log_2 (1 + b)$ 를 $b + 0.0573$ 으로 근사시킬 수 있으므로
$
x &= ln y\
&= (log_2 y) / (log_2 e)\
&tilde.eq 1 / (log_2 e) [2^(-23)j - 127 + 0.0573]\
$
이다. 우변을 정리하여
$
2^(23) (x log_2 e + 127 - 0.0573) = j
$
을 얻을 수 있다. 따라서,
$
y tilde.eq "* ( Float32 * ) " (2^(23) (x log_2 e + 127 - 0.0573) "as Int32")
$
이다. 이제 $x, y$ 가 Float64 타입이라 하면
$
x tilde.eq 1 / (log_2 e) [2^(-52)j - 1023 + 0.0573]\
$
이므로
$
y tilde.eq "* ( Float64 * ) " (2^(52) (x log_2 e + 1023 - 0.0573) "as Int64")
$
이다. 이러한 방법으로 지수를 계산하는 함수를 다음 페이지에서 작성해 보았다.
#pagebreak()
#align(center,
block(fill: rgb("f0f0f0"), outset: 2%, radius: 5%, width: 80%,
```rust
const mult32:f32 = 12102203.161561485;
const adder32: f32 = 1064872507.1615615;
const mult64:f64 = 6497320848556798.0;
const adder64: f64 = 4606924340207518000.0;
fn fast_exp32(x: f32) -> f32 {
union U {
f: f32,
i: i32,
}
unsafe {
let mut u = U { f: x };
u.i = (u.f * mult32 + adder32) as i32;
u.f
}
}
fn fast_exp64(x: f64) -> f64 {
union U {
f: f64,
i: i64,
}
unsafe {
let mut u = U { f: x };
u.i = (u.f * mult64 + adder64) as i64;
u.f
}
}
```
)
)
#pagebreak()
$x$ 를 $1$ 에서 $701$ 까지 $0.1$ 씩 증가시켜서 ``` fast_exp64``` 를 계산하여 얻은 오차는 아래와 같다.
```
e^1 : trad = 3.00416602e0, fast = 3.05932909e0, error = 9.81968901e-1
e^101 : trad = 8.07555019e43, fast = 8.02456026e43, error = 1.00635423e0
e^201 : trad = 2.17080249e87, fast = 2.12590311e87, error = 1.02112014e0
e^301 : trad = 5.83537138e130, fast = 5.93651567e130, error = 9.82962348e-1
e^401 : trad = 1.56861618e174, fast = 1.59051345e174, error = 9.86232580e-1
e^501 : trad = 4.21662405e217, fast = 4.14155986e217, error = 1.01812462e0
e^601 : trad = 1.13347794e261, fast = 1.12837100e261, error = 1.00452594e0
e^701 : trad = 3.04692148e304, fast = 3.10776457e304, error = 9.80422233e-1
Deviation : 0.01791137, Min_error : -0.01974522 at 521, Max_error : 0.04048682 at 520
```
$x = 88$ 에 대해 32 비트 지수 계산을 100000회, $x = 400$ 에 대해 64 비트 지수 계산을 100000회 반복하는데 소요된 시간은 다음과 같다.
```
test fast_exp32 ... bench: 465,635 ns/iter (+/- 75,791)
test fast_exp64 ... bench: 467,780 ns/iter (+/- 30,638)
test trad_exp32 ... bench: 624,230 ns/iter (+/- 53,545)
test trad_exp64 ... bench: 672,160 ns/iter (+/- 188,869)
```
사용된 시스템 : AMD Ryzen 5 5800X, 32GB DDR4-3200, Windows 11, Rust 1.73.0 |
|
https://github.com/Enter-tainer/typstyle | https://raw.githubusercontent.com/Enter-tainer/typstyle/master/tests/assets/typstfmt/84-ws-text-code.typ | typst | Apache License 2.0 | #let f() = []
a#sym.RR
a#f()
|
https://github.com/SWATEngineering/Docs | https://raw.githubusercontent.com/SWATEngineering/Docs/main/src/2_RTB/PianoDiProgetto/sections/PreventivoSprint/OttavoSprint.typ | typst | MIT License | #import "../../const.typ": Re_cost, Am_cost, An_cost, Ve_cost, Pr_cost, Pt_cost
#import "../../functions.typ": prospettoOrario, prospettoEconomico, glossary
== Ottavo #glossary[sprint]
*Inizio*: Venerdì 12/01/2024
*Fine*: Giovedì 18/01/2024
#prospettoOrario(sprintNumber: "8")
#prospettoEconomico(sprintNumber: "8") |
https://github.com/frectonz/the-pg-book | https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/118.%20nthings.html.typ | typst | nthings.html
The List of N Things
September 2009I bet you the current issue of Cosmopolitan has an article
whose title begins with a number. "7 Things He Won't Tell You about
Sex," or something like that. Some popular magazines
feature articles of this type on the cover of every
issue. That can't be happening by accident. Editors must know
they attract readers.Why do readers like the list of n things so much? Mainly because
it's easier to read than a regular article.
[1]
Structurally, the list of n things is a degenerate case of essay.
An essay can go anywhere the writer wants. In a list of n things
the writer agrees to constrain himself to a collection of points
of roughly equal importance, and he tells the reader explicitly
what they are.Some of the work of reading an article is understanding its
structure—figuring out what in high school we'd have called
its "outline." Not explicitly, of course, but someone who really
understands an article probably has something in his brain afterward
that corresponds to such an outline. In a list of n things, this
work is done for you. Its structure is an exoskeleton.As well as being explicit, the structure is guaranteed to be of the
simplest possible type: a few main points with few to no subordinate
ones, and no particular connection between them.Because the main points are unconnected, the list of n things is
random access. There's no thread of reasoning you have to follow. You could
read the list in any order. And because the points are independent
of one another, they work like watertight compartments in an
unsinkable ship. If you get bored with, or can't understand, or
don't agree with one point, you don't have to give up on the article.
You can just abandon that one and skip to the next. A list of n
things is parallel and therefore fault tolerant.There are times when this format is what a writer wants. One, obviously,
is when what you have to say actually is a list of n
things. I once wrote an essay about the mistakes that kill startups, and a few people made fun of me
for writing something whose title began with a number. But in that
case I really was trying to make a complete catalog of a number of
independent things. In fact, one of the questions I was trying to
answer was how many there were.There are other less legitimate reasons for using this format. For
example, I use it when I get close to a deadline. If I have to
give a talk and I haven't started it a few days beforehand, I'll
sometimes play it safe and make the talk a list of n things.The list of n things is easier for writers as well as readers. When
you're writing a real essay, there's always a chance you'll hit a
dead end. A real essay is a train of thought, and some trains of
thought just peter out. That's an alarming possibility when you
have to give a talk in a few days. What if you run out of ideas?
The compartmentalized structure of the list of n things protects
the writer from his own stupidity in much the same way it protects
the reader. If you run out of ideas on one point, no problem: it
won't kill the essay. You can take out the whole point if you need
to, and the essay will still survive.Writing a list of n things is so relaxing. You think of n/2 of
them in the first 5 minutes. So bang, there's the structure, and
you just have to fill it in. As you think of more points, you just
add them to the end. Maybe you take out or rearrange or combine a
few, but at every stage you have a valid (though initially low-res)
list of n things. It's like the sort of programming where you write
a version 1 very quickly and then gradually modify it, but at every
point have working code—or the style of painting where you begin
with a complete but very blurry sketch done in an hour, then spend
a week cranking up the resolution.Because the list of n things is easier for writers too, it's not
always a damning sign when readers prefer it. It's not necessarily
evidence readers are lazy; it could also mean they don't have
much confidence in the writer. The list of n things is in that
respect the cheeseburger of essay forms. If you're eating at a
restaurant you suspect is bad, your best bet is to order the
cheeseburger. Even a bad cook can make a decent cheeseburger. And
there are pretty strict conventions about what a cheeseburger should
look like. You can assume the cook isn't going to try something
weird and artistic. The list of n things similarly limits the
damage that can be done by a bad writer. You know it's going to
be about whatever the title says, and the format prevents the writer
from indulging in any flights of fancy.Because the list of n things is the easiest essay form, it should
be a good one for beginning writers. And in fact it is what most
beginning writers are taught. The classic 5 paragraph essay is
really a list of n things for n = 3. But the students writing them
don't realize they're using the same structure as the articles they
read in Cosmopolitan. They're not allowed to include the numbers,
and they're expected to spackle over the gaps with gratuitous
transitions ("Furthermore...") and cap the thing at either end with
introductory and concluding paragraphs so it will look superficially
like a real essay.
[2]It seems a fine plan to start students off with the list of n things.
It's the easiest form. But if we're going to do that, why not do
it openly? Let them write lists of n things like the pros, with
numbers and no transitions or "conclusion."There is one case where the list of n things is a dishonest format:
when you use it to attract attention by falsely claiming the list
is an exhaustive one. I.e. if you write an article that purports
to be about the 7 secrets of success. That kind of title is the
same sort of reflexive challenge as a whodunit. You have to at least
look at the article to check whether they're the same 7 you'd list.
Are you overlooking one of the secrets of success? Better check.It's fine to put "The" before the number if you really believe
you've made an exhaustive list. But evidence suggests most things
with titles like this are linkbait.The greatest weakness of the list of n things is that there's so
little room for new thought. The main point of essay writing, when
done right, is the new ideas you have while doing it. A real essay,
as the name implies, is
dynamic: you don't know what you're going
to write when you start. It will be about whatever you discover
in the course of writing it.This can only happen in a very limited way in a list of n things.
You make the title first, and that's what it's going to be about.
You can't have more new ideas in the writing than will fit in the
watertight compartments you set up initially. And your brain seems
to know this: because you don't have room for new ideas, you don't
have them.Another advantage of admitting to beginning writers that the 5
paragraph essay is really a list of n things is that we can warn
them about this. It only lets you experience the defining
characteristic of essay writing on a small scale: in thoughts of a
sentence or two. And it's particularly dangerous that the 5 paragraph
essay buries the list of n things within something that looks like
a more sophisticated type of essay. If you don't know you're using
this form, you don't know you need to escape it.Notes[1]
Articles of this type are also startlingly popular on Delicious,
but I think that's because
delicious/popular
is driven by bookmarking,
not because Delicious users are stupid. Delicious users are
collectors, and a list of n things seems particularly collectible
because it's a collection itself.[2]
Most "word problems" in school math textbooks are similarly
misleading. They look superficially like the application of math
to real problems, but they're not. So if anything they reinforce
the impression that math is merely a complicated but pointless
collection of stuff to be memorized.Russian Translation
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-FB00.typ | typst | Apache License 2.0 | #let data = (
("LATIN SMALL LIGATURE FF", "Ll", 0),
("LATIN SMALL LIGATURE FI", "Ll", 0),
("LATIN SMALL LIGATURE FL", "Ll", 0),
("LATIN SMALL LIGATURE FFI", "Ll", 0),
("LATIN SMALL LIGATURE FFL", "Ll", 0),
("LATIN SMALL LIGATURE LONG S T", "Ll", 0),
("LATIN SMALL LIGATURE ST", "Ll", 0),
(),
(),
(),
(),
(),
(),
(),
(),
(),
(),
(),
(),
("ARMENIAN SMALL LIGATURE MEN NOW", "Ll", 0),
("ARMENIAN SMALL LIGATURE MEN ECH", "Ll", 0),
("ARMENIAN SMALL LIGATURE MEN INI", "Ll", 0),
("ARMENIAN SMALL LIGATURE VEW NOW", "Ll", 0),
("ARMENIAN SMALL LIGATURE MEN XEH", "Ll", 0),
(),
(),
(),
(),
(),
("HEBREW LETTER YOD WITH HIRIQ", "Lo", 0),
("HEBREW POINT JUDEO-SPANISH VARIKA", "Mn", 26),
("HEBREW LIGATURE YIDDISH YOD YOD PATAH", "Lo", 0),
("HEBREW LETTER ALTERNATIVE AYIN", "Lo", 0),
("HEBREW LETTER WIDE ALEF", "Lo", 0),
("HEBREW LETTER WIDE DALET", "Lo", 0),
("HEBREW LETTER WIDE HE", "Lo", 0),
("HEBREW LETTER WIDE KAF", "Lo", 0),
("HEBREW LETTER WIDE LAMED", "Lo", 0),
("HEBREW LETTER WIDE FINAL MEM", "Lo", 0),
("HEBREW LETTER WIDE RESH", "Lo", 0),
("HEBREW LETTER WIDE TAV", "Lo", 0),
("HEBREW LETTER ALTERNATIVE PLUS SIGN", "Sm", 0),
("HEBREW LETTER SHIN WITH SHIN DOT", "Lo", 0),
("HEBREW LETTER SHIN WITH SIN DOT", "Lo", 0),
("HEBREW LETTER SHIN WITH DAGESH AND SHIN DOT", "Lo", 0),
("HEBREW LETTER SHIN WITH DAGESH AND SIN DOT", "Lo", 0),
("HEBREW LETTER ALEF WITH PATAH", "Lo", 0),
("HEBREW LETTER ALEF WITH QAMATS", "Lo", 0),
("HEBREW LETTER ALEF WITH MAPIQ", "Lo", 0),
("HEBREW LETTER BET WITH DAGESH", "Lo", 0),
("HEBREW LETTER GIMEL WITH DAGESH", "Lo", 0),
("HEBREW LETTER DALET WITH DAGESH", "Lo", 0),
("HEBREW LETTER HE WITH MAPIQ", "Lo", 0),
("HEBREW LETTER VAV WITH DAGESH", "Lo", 0),
("HEBREW LETTER ZAYIN WITH DAGESH", "Lo", 0),
(),
("HEBREW LETTER TET WITH DAGESH", "Lo", 0),
("HEBREW LETTER YOD WITH DAGESH", "Lo", 0),
("HEBREW LETTER FINAL KAF WITH DAGESH", "Lo", 0),
("HEBREW LETTER KAF WITH DAGESH", "Lo", 0),
("HEBREW LETTER LAMED WITH DAGESH", "Lo", 0),
(),
("HEBREW LETTER MEM WITH DAGESH", "Lo", 0),
(),
("HEBREW LETTER NUN WITH DAGESH", "Lo", 0),
("HEBREW LETTER SAMEKH WITH DAGESH", "Lo", 0),
(),
("HEBREW LETTER FINAL PE WITH DAGESH", "Lo", 0),
("HEBREW LETTER PE WITH DAGESH", "Lo", 0),
(),
("HEBREW LETTER TSADI WITH DAGESH", "Lo", 0),
("HEBREW LETTER QOF WITH DAGESH", "Lo", 0),
("HEBREW LETTER RESH WITH DAGESH", "Lo", 0),
("HEBREW LETTER SHIN WITH DAGESH", "Lo", 0),
("HEBREW LETTER TAV WITH DAGESH", "Lo", 0),
("HEBREW LETTER VAV WITH HOLAM", "Lo", 0),
("HEBREW LETTER BET WITH RAFE", "Lo", 0),
("HEBREW LETTER KAF WITH RAFE", "Lo", 0),
("HEBREW LETTER PE WITH RAFE", "Lo", 0),
("HEBREW LIGATURE ALEF LAMED", "Lo", 0),
)
|
https://github.com/ren-ben/typst-notes | https://raw.githubusercontent.com/ren-ben/typst-notes/master/physics/art/master.typ | typst | #align(center, text(24pt)[
*Spezielle & Generelle Relativitätstheorie*
])
#align(center)[
<NAME> \
Technologisches Gewerbemuseum \
#link("mailto:<EMAIL>")
]
#show: rest => columns(2, rest)
#import "@preview/physica:0.9.2": *
#set heading(numbering: "1.")
#show par: set block(spacing: 0.65em)
#set par(
first-line-indent: 1em,
justify: true,
)
= Einführung
== Der Streit
Der Streit zwischen der klassichen Mechanik und dem Elektromagnetismus bezieht sich darauf, dass aus den Maxwell-Gleichungen die Wellengleichung erstellt werden kann:
#set align(center)
$ div E = 0 \
curl B = epsilon_0 mu_0 pdv(E,t) \
curl E = -pdv(B,t) \ \ \
curl (curl E) = curl (- pdv(B,t)) \
grad(div E ) - laplacian E = - pdv(,t) (curl B) \
grad(div E ) - laplacian E = - epsilon_0 mu_0 pdv(E,t,2) \
0 - laplacian E = - 1/c^2 pdv(E,t,2) \
1/c^2 pdv(E,t,2) - laplacian E = 0
$
#set align(start)
Das Problem erscheint, weil hier die Lichtgeschwindigkeit $c$ als eine Konstante betrachtet wird ($c=1/(sqrt(mu_0 epsilon_0))$) was die Physiker damals verwirrt hat, weil die Theorie von Galileo, die klassische Mechanik davon überzeugt war, dass beispielsweise die Geschwindigkeit eines Balles relativ zu einem Bezugsystem $x'$ und $y'$ bei $v-v'$ liegt, was aber bei einer Konstante nicht möglich ist. Außerdem ist sich die klassische Mechanik ziemlich sicher, dass eine absolute Geschwindigkeit nicht existiert, also muss es ein Weg geben, $v-v'$ im Bezug auf die Lichtgeschwindigkeit auszudrücken. Die Physiker des 20ten Jahrhunderts haben nach verschiedenen Lösungen wie Ether gesucht. Schlussendlich kamen sie auf die Relativitätstheorie, mit der sich dieser Paper beschäftigt.
== Galileo's Transformationen
Einstein war der erste Physiker, der nicht den Elektromagnetismus in Frage stellte, sondern die klassische Mechanik. Galileo fand raus, dass Zeit absolut ist ($t=t'$). Die $x'$ Koordinate ist $x'=x-v' t$. Wenn wir jetzt die Ableitung nehmen: $dv(x',t)=dot(x')=dot(x) - v'$ wobei $dot(x')$ ist die Geschwindigkeit des Balles die aus dem Bezugsystem $x'$ und $y'$ gemessen wird. Wie später im Detail besprochen wird, hat Einstein valide Argumente geformt, die auf ein Fehler in diesen Transformationen angedeutet haben.
#figure(
image("images/galilean_transform.jpeg", width: 80%),
caption: [
Bezugsystem in Galileo's Transformationen
],
)
= Lorentz Transformationen
== Ableitung
#figure(
image("images/lorentz_derivation.svg", width: 50%),
caption: [
Plot der Lichtgeschwindigkeit $times$ Zeit
],
)
Bevor es mit Lorentz Transformationen weitergehen kann, muss zuerst das Prinzip der Gleichzeitigkeit erwähnt werden.
=== Gleichzeitigkeit
Gleichzeitigkeit bezeichnet die Eigenschaft von zwei Ereignissen, dass sie zur gleichen Zeit auftreten. Im Kontext der Physik, insbesondere in der speziellen Relativitätstheorie, wird Gleichzeitigkeit relativ interpretiert, was bedeutet, dass sie von der Perspektive des Beobachters abhängt, der die Ereignisse beobachtet.
#figure(
image("images/simultaneous.svg", width: 70%),
caption: [
Person $A$ und Person $B$ senden jeweils ein Lichtstrahl zum Mittelpunkt
]
) <gleich>
Grundsätzlich wenn es keine Bewegung bei der @gleich gibt kommen die Lichtstrahle gleichzeitig an. Wenn das Senden jedoch während einer Bewegung durchgeführt wird, kommen sie nicht gleichzeitig an.
#figure(
image("images/refframesim2.svg", width: 50%),
caption: [
$B$ & $A$ senden Lichtstrahle und bewegen sich mit $v$
]
)
Person B sendet den Lichtstrahl in die entgegengesetzte Richtung, was die Geschwindigkeit von $-c$ beträgt. Der Schnittpunkt mit der $B$-Funktion passiert später als der Schnittpunkt mit der $A$-Funktion was bedeutet, dass Person $B$ den Lichtstrahl später senden sollte, damit sie sich gleichzeitig treffen. Dieses Ergebnis ist ist intuitiv, wenn man die Geschwindigkeit $v$ in Acht nimmt, mit der sich die beiden Personen bewegen. Aus einem anderen Bezugsystem würde sich rausstellen, dass die Beiden Lichtstrahle tatsächlich gleichzeitig ankommen.
Die Gleichung für die Linie mit der Steigung von $-c$ lautet
#set align(center)
#figure(
$x=-c(t-t_A) + x_A$
)
#set align(start)
Jetzt müssen die Koordinate des Punktes $A$ gefunden werden (Schnittpunkt des Mittelpunktes und der Lichtstrahle).
#set align(center)
#figure(
$cases(x=v t+a, x=c t)$
)
#set align(start)
($a$ ist die Distanz zwischen $x=0$ und dem Mittelpunkt)
#set align(center)
#figure(
$x=-c(t-a/(c-v)) + (a c)/x-v \
cases(x=-c(t-a/(c-v)) + (a c)/x-v, x=v t + 2a) \
t_B = (2 a v)/(c^2-v^2) \
x_B = (2 a c)/(c^2-v^2) \
x_B/t_B = c^2/v |-> x/t = c^2/v |-> x=c^2/v t$
)
#set align(start)
=== Beziehung zwischen $x$ und $x'$
Wie wir wissen, hat $x$ eine Beziehung zu $x'$ und die kann durch eine Differenz zwischen $x$ und $v t $ multipliziert mit einer Konstante $gamma$ dargestellt werden.
#set align(center)
#figure(
$x' = 0, x = v t -> x' = gamma times (x - v t)$
)
#set align(start)
Für $t'$ ist die Situation sehr ähnlich
#set align(center)
#figure(
$t' = 0, t = v/c^2x -> t' = gamma' times (t - v/c^2x)$
)
#set align(start)
Daraus können folgende Beziehung aufgezeichnet werden
#set align(center)
#figure(
$x=gamma times (x' + v t) \ t = gamma' times (t' + v/c^2x)$
)
#set align(start)
Durch das Substitutionsverfahren kann alles auf $x'$ und $t'$ umgewandlet werden.
#set align(center)
#figure(
$x'=gamma [gamma (x'+v t') - gamma' v (t'+v/c^2x')] \ = gamma^2 x' + gamma^2v t'-gamma gamma' v t' - gamma gamma' v^2/c^2x' \ =(gamma^2 - gamma gamma' v^2/c^2)x' + (gamma^2 v-gamma gamma' v) t'$
)
#set align(start)
Weil alles gleich $x'$ ist, muss der erste Term $(gamma^2-gamma gamma' v^2/c^2)$ gleich eins sein und der zweite Term gleich null sein.
#figure(
$gamma^2 - gamma^2 v/c^2 = 1 -> gamma^2 = 1 / (1-v^2/c^2) -> gamma = plus.minus 1/sqrt(1-v^2/c^2) \ $
)
#set align(start)
Dementsprechend kann $gamma$ (auch Lorentzfaktor oder $beta$ genannt) ebenfalls substituiert werden und damit bekommen wir die Lorentz Transformationen
#set align(center)
#figure(
$cases(x'= (x-v t)/sqrt(1-v^2/c^2), t'= (t-v/c^2 x)/sqrt(1-v^2/c^2))$
)
#set align(start)
Durch weitere Berechnungen, kann auf die Lorentz-Invarianz draufgekommen werden. Diese wird nicht durch die Lorentz-Transformation beeinflusst. Es ist eine Einheit die sich nicht verändert.
#set align(center)
#figure(
$x'^2-c^2t'^2 = x^2-c^2 t^2$
)
#set align(start)
Man kann außerdem die Lorentz-Transformationen aus der Lorentz Invarianz Ableiten.
=== Geschwindigkeitskompositionen
Ein statischer Beobachter ($x$, $t$) sieht ein fahrendes Auto ($x'$, $t'$) wo drinnen ein Ball nach vorne geschmissen wird ($x''$, $t''$). Gallileo würde sagen, dass $t=t'=t''$ und dass die Geschwindigkeit des Balles gleich der Geschwindigkeit des Balles im Auto ($w$) minus der Geschwindigkeit des Autos ($v$) (wenn der Beobachter das Inertialsystem ist). Wenn wir jetzt aber mit Lorentz-Transformationen von $x$ auf $x'$ umsteigen wollen, gilt wie bereits erwähnt $x'=(x-v t)/sqrt(1-v^2/c^2)$ oder einfach $x'=x-v t beta(v)$ wenn wir annehmen, dass $beta(v)=1/(sqrt(1-v^2/c^2))$. Außerdem ist $t'=(t-v/c^2 x)beta(v)$. Wichtig ist auch das Inverse davon:
#figure(
$ cases(x = (x'+v t')beta(v), t = (t' + v/c^2 x') beta(v)) $,
caption: [
Gleichung 1
]
) <Gleichung1>
Wie kommt man aber auf $x''$ von $x$?
Ganz einfach, wie bereits erwähnt bewegt sich der Ball mit einer Geschwindigkeit von $w$ und das Auto mit einer Geschwindigkeit von $v$. Also müssen wir einfach folgendes tun:
#figure(
$ cases(x''=(x-w t)beta(w), t''=(t-w/c^2 x)beta(w)) $,
caption: [
Gleichung 2
]
) <Gleichung2>
Was wir jetzt finden wollen ist die folgende Beziehung: $(x',t') <-> (x'', t'')$. Wir wissen aus @Gleichung1 was $x$ gleich ist mittels $x'$ und $t'$ und somit müssen wir nur @Gleichung1 in @Gleichung2 substituieren. Das bedeutet wir ersetzen $x$ in der @Gleichung2 mit $(x'+v t')beta(v)$ usw. Nach ein wenig Algebra kommen wir auf
#figure(
$ cases(x'' = beta(v)beta(w)[x'(1-(w v)/c^2) - t' (w-v)], t'' = beta(v)beta(w)[t'(1-(w v)/c^2)-x'/c^2(w-v)]) $,
caption: [
Gleichung3
]
) <Gleichung3>
Wir könnten es aber in eine andere Art und Weise aufschreiben. Wenn wir die relative Geschwindigkeit zwischen dem Fahrer und dem Ball $u$ bennenen, können wir die folgenden Gleichungen aufstellen:
#figure(
$ cases(x''=(x'-u t') beta(u), t'' = (t'-u/c^2 x') beta(u)) $,
caption: [
Gleichung 4
]
) <Gleichung4>
Daraufhin können wir @Gleichung3 und @Gleichung4 gleich setzen weil sie beide Gleich $x''$ bzw. Gleich $t''$ sind. Somit können wir folgendes aufstellen:
#figure(
$ cases(beta(u) = beta(v)beta(w)((1-w v)/c^2), u beta(u) = beta(v)beta(w) (w-v)) $
)
Was wir jetzt noch machen müssen ist die obere Gleichung mit der Unteren zu dividieren. Wir kommen auf ein interessantes Ergebnis:
#figure(
$ u = (w - v)/(1- (w v)/c^2) $
)
Dies ist eine generalisierung der Galileo-Transformationen ($u=w-v$). Das bedeutet, wir können Lorentz-Transformationen aus Galileo-Transformationen herausfinden.
#figure(
image("images/lorentz_vel.svg", width: 50%),
caption: [
Beispiel des Zebrechens der Galileo-Transformationen
]
)
Wenn wir jetzt ein Lichtstrahl haben der nach links vom Inertialsystem kehrt und ein Lichtstrahl der nach rechts kehrt werden und die Galileo-Transformationen folgendes sagen:
#figure(
$ u = c - (-c) = 2c $
)
Was nicht möglich ist weil nichts schneller als $c$ sein kann. Probieren wir Lorentz-Transformationen aus:
#figure(
$ u = (2 c)/(1-(-c^2)/c^2) = (2 c)/(1 + c^2/c^2) = (2 c)/(2) = c $
)
Bingo! Genau das was uns Relativität zeigt. Nichts kann schneller als Licht sein.
== Längenkontraktion und Zeitdilatation
Dies sind zwei wichtige Bestandteile der speziellen Relativitätstheorie. Wir nehmen an, es gibt ein Objekt mit der Länge $l -> (x,t)$ und wir wollen die Länge im Bezugsystem $(x',t') -> l'$ messen. Die Koordinaten von $l$ sind $x_1$ und $x_2$ auf dem Plot:
#figure(
image("images/lcontraction.svg", width: 50%),
caption: [
Längenkontraktion Beispiel
]
)
Die Länge kann durch $x_2-x_1$ berechnet werden. Mit Lorentz-Transformationen kommen wir auf Zwei Gleichungen wenn wir auf $(x',t')$ wächseln:
#figure(
$ x'_2 = (x_2-v t_0)/(sqrt(1-v^2/c^2)) space , space x'_1 = (x_1-v t_0)/sqrt(1-v^2/c^2) $
)
Jetzt können wir die Beiden subtrahieren und bekommen:
#figure(
$ x'_2-x'_1 = (x_2-x_1)/(sqrt(1-v^2/c^2)) -> l'=l/sqrt(1-v^2/c^2) $
)
Weil der Lorentzfaktor $<1$ ist, ist $l' > l$.
Bei der Zeitdilatation nehmen wir eine stehende Person im Bezugsystem $(x,t) --> (x_1, t_1)$ und weil die Person steht werden ihre Koordinaten nach einiger Zeit $(x_1, t_1 + Delta t)$ betragen. Wir können also die folgende Gleichung benutzen:
#figure(
$ t'_1 = (t_1-v/c^2 x_1)/sqrt(1-v^2/c^2) \ t'_1
Delta t' = (t_1 + Delta t - v/c^2 x_1) / sqrt(1-v^2/c^2) \ Delta t' = (Delta t)/sqrt(1-v^2/c^2) -> Delta t' > Delta t$
)
=== Nicht-inertiale Systeme
Einfach erklärt ist die Geschwindigkeit zwischen den beiden Bezugsystemen nicht mehr konstant. Für deren Berechnung brauchen wir die Lorentz-Invarianz:
#figure(
$ x'^2-c^2 t'^2 = x^2-c^2 t^2 $
)
Für eine bessere Übersicht, müssen wir folgende Variable definieren:
#figure(
$ c^2t^2-x^2=s^2 $
)
Weil wir derzeit sehr kleine Raum- und Zeit-Abstände betrachten (wir schauen uns auch nur den ersten Zeitpunkt an), kann man $x$ und $t$ mit $d x$ und $d t$ ersetzen
#figure(
$ d s^2 = c^2 d t^2 - d x^2 $
)
Wenn man aber diese Aussage Integriert bekommt man sehr interessante Ergebnisse sowohl für Inertialsysteme als auch für Nicht-inertialsysteme.
Wir werden uns damit später beschäftigen, aber dazu braucht man noch ein Paar andere Definitionen:
#figure(
$ d tau = (d s)/c \ d s = c d tau \ d tau = sqrt(1 - v^2/c^2) d t$
)
= Lagrange-Formalismus
Wir haben einen Partikel der im Zeitraum sich bewegt (die Zeitdimension geht durch den Bildschirm)
#figure(
image("images/lagrangian_1.png", width: 50%)
)
Wenn wir den Abstand zwischen $tau_1$ und $tau_2$ berechnen wollen, gibt es die Newton'sche Art und Weise:
#figure(
$ tau_2 - tau_1 = integral^(tau_1)_tau_2 sqrt(1-v^2/c^2) space d t$
)
aber auch die Lagrang'sche Art und Weise:
#figure(
$ S = A = integral^(t_2)_t_1 L(arrow(x), dot(arrow(x)), t) space d t $
)
Hamilton sagt uns, dass wir die Aktion ($A$ oder $S$) minimieren müssen damit wir die Flugbahn bekommen können. Wir machen das indem wir die Flugbahn ändern, aber nicht die Endpunkte.
#figure(
$ delta S = integral^(t_2)_t_1 delta L (arrow(x), dot(arrow(x)), t) space d t = 0 $
)
Durch diese Formulation kann man die Euler-Lagrange-Gleichung ableiten:
#figure(
$ pdv(f,y,1) - d/(d x) pdv(f,y',1) = 0 $
)
Grundlegend ist $T$ die kinetische Energie, $V$ die potenzielle Energie und $U$ das Potenzial wobei $U=-V$.
== Lagrange - Spezielle Relativität
Zuerst sollten wir uns an die Invariaz erinnern:
#figure(
$ d s^2 = c^2 d t^2 - d x^2 $
)
Zur erinnerung, diese Invarianz beschreibt das Intervall zwischen zwei Ereignissen im Zeit-Raum. Wenn $d s^2 < 0$ haben wir ein Raumhaftes Intervall. Heißt, dass sie sich nicht beeinflüssen können und sind nicht Zeitlich verbunden. Wenn $d s^2 > 0$ dann ist das Intervall Zeithaft und kann sich zwischen den Ereignissen bewegen.Wenn $d s^2 = 0$ dann kann nur eine Lichtgeschwindigkeit die zwei Ereignisse verbinden.
Dazu definieren wir $d tau = (d s)/c$ noch einmal. (Invarianz dividiert durch die Lichtgeschwindigkeit). Dadurch, dass $|d arrow(x)|=V d t$ kann man durch einfache Algebra zu der folgenden Formel kommen:
#figure(
$ d tau = d t times sqrt(1- v^2/c^2) $
)
Jetzt wollen wir den Lagrangian erstellen.
#figure(
$ A = integral^(t_0)_(t_1) L d t $
)
Die eine Regel ist, dass alle Werte invariant sein müssen. Wir können zuerst $d t$ mit $d tau$ ersetzen. Den Lagrangian selbst zu ersetzen ist schwer. Man kann die Ruhemasse $m_0$ und $c$ nehmen. Weil $L = T - V$ und $T = 1/2 m_0 dot(x)^2$ können wir den folgenden Integral erstellen:
#figure(
$ A = integral - m_0 c^2 d tau $
)
Wir werden später sehen, wieso da ein minus ist und außerdem können wir $1/2$ weglassen weil es im grunde genommen nichts ausmacht. Fahren wir fort:
#figure(
$ delta A = delta integral - m_0 c^2 sqrt(1-v^2/c^2) d t = delta integral L d t $
)
Endlich haben wir unseren Lagrangian:
#figure(
$ L = -m_0 c^2 sqrt(1-v^2/c^2) $
)
=== Schwung in der SRT
Um zu klären, womit wir arbeiten: Wir haben einen einzigen Partikel mit der Ruhemasse $m_0$.
Der Schwung des Partikels ist $P_J = pdv(L,dot(x_J))$ welchen wir 3 Mal in jede Richtung ableiten können. Dazu sollte auch klar sein, dass $v^2 = dot(x^2 _1) + dot(x^2 _2) + dot(x^2 _3)$. Damit können wir lösen, was $P_J$ ist:
#figure(
$ P_J = -m_0 c^2 1/(2 sqrt(1-v^2/c^2)) (-2 v)/c^2 pdv(V,dot(x_J)) $
)
Zur Erinnerung: $pdv(V,dot(x_J)) = pdv(,dot(x_J)) sqrt(dot(x^2 _1) + dot(x^2 _2) + dot(x^2 _3))$ was gleich $1/(2 V) 2 dot(x)_J$ ist. Einfache Zusammensetzung (c^2 fällt weg, 2V fällt weg und 2 fällt weg) führt uns zum folgenden Ergebnis:
#figure(
$ P_J = (m_0 dot(x)_J)/sqrt(1-v^2/c^2) $
)
Manche Wissenschaftler definieren eine relative Masse ($m(v) = m_0/sqrt(1-v^2/c^2)$) und somit kann der Schwung in der SRT als eine klassische Definitio aufgeschrieben werden:
#figure(
$ P_J = m dot(x)_J $
)
=== E=mc2
$P_J$ ist sehr stark mit dem Hamiltonian verbunden. Weil $H= sum_J pdv(L, dot(x)_J) dot(x)_J - L$. Nach einer Substitution kommen wir zu der folgenden Formel:
#figure(
$ H = (m_0 sum_J dot(x)^2_J)/sqrt(1 - v^2/c^2) + m_0 c^2 sqrt(1-v^2/c^2) $
)
Nach ein wenig Algebra kommen wir zum folgenden Ergebnis:
#figure(
$ H = (m_0 c^2)/sqrt(1-v^2/c^2) $
)
Dadurch kann der klassische Hamiltonian herausgezogen werden (mittels der Taylor-Expansion):
#figure(
$ H approx m_0 c^2 + 1/2 m_0 V^2 -> H_(V=0) = m_0 c^2 $
)
Dies bedeutet, das der Hamiltonian (Energie) während der Partikel sich nicht bewegt ist die Ruhemasse mal $c^2$. Dies ist die berühmte Formel von Einstein:
#figure(
$ E=m c^2 $
)
= Generelle Relativitätstheorie
== Tensoren
=== Invarianz als ein Tensor
Schauen wir uns die Invarianz noch einman an:
#figure(
$ d s^2 = c^2 d t^2 - d x^2 - d y^2 - d z^2 $
)
Wenn man sich ein Koordinatensystem $(x^0, x^1, x^2, x^3)$ vorstellt, wo $x^0 = c t$, kann man die Invarianz flgendermaßen aufschreiben:
#figure(
$ d s^2 = d x^0 - (d x^1)^2 - (d x^2)^2 - (d x^3)^2 $
)
Wenn wir jetzt ein $4 x 4$ Matrix und ein Vektor mit den Koordinaten definieren
#figure(
$ eta_(mu nu) = mat(
1, 0, 0, 0;
0, -1, 0, 0;
0, 0, -1, 0;
0, 0, 0, -1;
)
d x^(mu) = vec(d x^0, d x^1, d x^2, d x^3)
$
)
können wir die Invarianz auf die folgende Art und Weise definieren:
#figure(
$ d s^2 = sum_mu sum_nu d x^mu d x^nu eta_(mu nu) $
)
Einstein hat aber gesagt, dass wenn wir wiederholende Indizes haben, können wir einfach sie summieren ohne den Summensymbolen:
#figure(
$ d s^2 = d x^mu d x^nu eta_(mu nu) $
)
=== Tensor-Transformationen
Wenn man die Invarianz von $g_(mu nu)$ zu $g_(alpha beta)$ verwandeln möchte, muss man folgend vorgehen:
#figure(
$ d s^2 = g_(mu nu) d x^(mu) d x^nu = g_(mu nu) pdv(x^mu, y^alpha) d y^alpha pdv(x^nu, y^beta) d y^beta \ = g_(alpha beta) d y^alpha d y^beta $
)
Das bedeutet, dass:
#figure(
$ g_(alpha beta) = g_(mu nu) pdv(x^mu, y^alpha) pdv(x^nu, y^beta) $
)
Sehr wichtig ist außerdem, dass kontravariante Tensor-Komponente sich mit dem Inversen des Jacobians transformieren lassen und kovariante Tensor-Komponente lassen sich mit dem Jacobian transformieren.
Ein kontravariantes Komponent $v^mu$ wird folgendermaßen verwandelt:
#figure(
$ x^(mu) = pdv(y^(mu), x^nu) x^nu $
)
Und ein kovariantes Komponent $w_mu$ wird so verwandelt:
#figure(
$ x_mu = pdv(x^nu, y^mu) x_nu$
)
Das würd folgendes im Fall von $F_(alpha beta)^(gamma delta)$ bedeuten:
#figure(
$ F_(alpha beta)^(gamma delta) (y^0, y^1, y^2, y^3) \ = F_(alpha' beta')^(gamma' delta' ) (x^0, x^1, x^2, x^3) pdv(x^alpha', y^alpha) pdv(x^beta', y^beta) pdv(y^delta, x^delta') pdv(y^gamma, x^gamma') $
)
Kontravariante Tensor-Komponente beschreiben den Absolutwert (Größe) und die Richtung im Raum. Beispielsweise Geschwindigkeit.
Kovariante Tensor-Komponente beschreiben die geometrie im Raum, beispielsweise Gradiente oder Ableitungen.
=== Lower-Rank Tensor zu Higher-Rank Tensor
Wenn man zwei Lower-Rank Tensoren miteinander multipliziert bekommt man einen Higher-Rank Tensor:
Sagen wir, dass wir den Tensor $V_mu^(1)$ und $V_nu^(1)$ wobei 1 der Index ist.
#figure(
$ V_mu^(1) V_nu^(1) = mat(1;0;0;0) mat(1,0,0,0) = mat(1, 0, 0, 0 ; 0, 0, 0, 0 ; 0, 0, 0, 0) = V_(mu nu) $
)
|
|
https://github.com/goshakowska/Typstdiff | https://raw.githubusercontent.com/goshakowska/Typstdiff/main/tests/test_working_types/ordered_list/ordered_list_updated.typ | typst | + The updated
+ The second |
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/metro/0.2.0/src/metro.typ | typst | Apache License 2.0 | #import "defs/units.typ"
#import "defs/prefixes.typ"
#import "impl/impl.typ"
#import "utils.typ": combine-dict
#let _state-default = (
units: units._dict,
prefixes: prefixes._dict,
prefix-power-tens: prefixes._power-tens,
powers: (
square: impl.raiseto([2]),
cubic: impl.raiseto([3]),
squared: impl.tothe([2]),
cubed: impl.tothe([3])
),
qualifiers: (:),
// quantites
times: sym.dot,
// Unit
// Num
allow-breaks: false,
delimiter: " ",
)
#let _state = state("metro-setup", _state-default)
#let metro-reset() = _state.update(_ => return _state-default)
#let metro-setup(..options) = _state.update(s => {
return combine-dict(options.named(), s)
})
#let declare-unit(unt, symbol) = _state.update(s => {
s.units.insert(unt, symbol)
return s
})
#let create-prefix = math.class.with("unary")
#let declare-prefix(prefix, symbol, power-tens) = _state.update(s => {
s.prefixes.insert(prefix, symbol)
s.prefix-power-tens.insert(prefix, power-tens)
return s
})
#let declare-power(before, after, power) = _state.update(s => {
s.powers.insert(before, impl.raiseto([#power]))
s.powers.insert(after, impl.tothe([#power]))
return s
})
#let declare-qualifier(quali, symbol) = _state.update(s => {
s.qualifiers.insert(quali, impl.qualifier(symbol))
return s
})
#let unit(input, ..options) = _state.display(s => {
return impl.unit(input, ..combine-dict(options.named(), s))
})
#let num(number, e: none, pm: none, pw: none, ..options) = _state.display(s => {
return (impl.num(number, exponent: e, uncertainty: pm, power: pw, ..combine-dict(options.named(), s)))
})
#let qty(
number,
units,
e: none,
pm: none,
pw: none,
..options
) = _state.display(s => {
return impl.qty(
number,
units,
e: e,
pm: pm,
pw: pw,
..combine-dict(options.named(), s)
)
}) |
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/math/attach-04.typ | typst | Other | // Test associativity and scaling.
$ 1/(V^2^3^4^5),
1/attach(V, tl: attach(2, tl: attach(3, tl: attach(4, tl: 5)))),
attach(Omega,
tl: attach(2, tl: attach(3, tl: attach(4, tl: 5))),
tr: attach(2, tr: attach(3, tr: attach(4, tr: 5))),
bl: attach(2, bl: attach(3, bl: attach(4, bl: 5))),
br: attach(2, br: attach(3, br: attach(4, br: 5))),
)
$
|
https://github.com/kdog3682/2024-typst | https://raw.githubusercontent.com/kdog3682/2024-typst/main/src/visual-more-than-rect.typ | typst | #import "base-utils.typ": *
#let get(x) = {
let ref = (
"*": sym.times,
"times": sym.times,
"+": sym.plus,
"plus": sym.plus,
)
return ref.at(x, default: x)
}
#let attrs = (
width: 100pt,
)
#let table-attrs = (
columns: 5,
gutter: 5pt,
stroke: none,
inset: 0pt,
)
#let visual-more-than-rect() = {
// this has to happen in the context of cetz.
let hb = k * h1
let ha = h1 - hb
let a = rect(p.origin, (size, h1), ..d1)
let a-stroked = rect((0, ha), (size, h1), ..d2)
let b = rect((gap, 0), (gap + size, h2), ..d3)
let b-stroked = rect((gap, h2), (gap + size, h2 + hb), ..d4)
arrow
c-arrow
a
b
a-stroked
b-stroked
}
// inoreab ls (it) => {
// $c
// }
#let booga(a, n, delimiter, ending: none, equals: none) = {
// takes a numeric term and repeats it n times
// joining it with the delimiter provided
let delimiter = get(delimiter)
let val = str(a)
let s = ""
for i in range(n) {
s += val
if i == n - 1 {
let value = if delimiter == sym.plus { a * n } else { calc.pow(a, n) }
return if exists(ending) {
s + templater(ending, value)
} else if exists(equals) {
s + " = " + str(value)
} else {
s
}
} else {
s += " " + delimiter + " "
}
}
}
#let interweave(a, n, delimiter, equals: none) = {
// takes a numeric term and repeats it n times
// joining it with the delimiter provided
let delimiter = get(delimiter)
let base = (($#a$,) * n).join($space #delimiter space$)
if equals != none {
let value = if delimiter == sym.plus { a * n } else { calc.pow(a, n) }
let ending = if is-string(equals) {
markup(templater(" " + equals.trim(), value))
} else {
equals(value)
}
return base + ending
}
return base
}
#let to-number(x) = {
return int(x)
}
#let content-templater(template, ..sink) = {
let ref = sink.named()
let items = split(template, "\s+")
let runner(part) = {
if test(part, "^\$") {
let value = ref.at(part.slice(1))
return if is-function(value) {
value()
} else {
value
}
} else {
return text(part)
}
}
let parsed = items.map(runner)
return parsed.join(" ")
}
#let ExponentGenerator(..a) = {
let args = a.pos()
let numbers = if args.len() == 2 {
args
} else {
split(args.first(), "\^")
}
let (base, power) = numbers.map(to-number)
let expand() = {
return interweave(base, power, "times")
}
let value() = {
return text(str(calc.pow(base, power)))
}
let expr() = {
return [$#base^#power$]
}
let state = (
expand: expand,
equals: $space = space$,
value: value,
expr: expr,
)
let templater = content-templater.with(..state)
state.insert("templater", templater)
let definition() = {
return templater("$expr means $expand")
}
state.insert("definition", definition)
return templater
return state
}
#{
// let templater = ExponentGenerator(3, 4)
// let boxy = (..items) => box(..attrs, table(..table-attrs, ..items))
// let small-box = (content) => box(
// width: 80pt,
// text(size: 6pt, content)
// )
}
#let boxed-interweave(a, b, c, equals: none) = {
let small-box = (content) => box(
width: b * 3pt,
baseline: 100%,
par(justify: true, text(size: 7pt, content))
)
return small-box(interweave(a, b, c, equals: equals))
}
// #boxed-interweave(2, 70, "+", equals: "\= *$1*?")
// #block(width: 200pt, fill: yellow)[
// how did you do that so fast? did you do #booga(2, 140, "+", equals: true)?
//
// no. i did $2 times 70$.
//
// wow kaylee.
//
// i know. im smart
// ]
#let first = {
for i in step(4) {
let base = ExponentGenerator(10, i)
let a = base("$expr $equals $expand")
a
linebreak()
}
}
#let second = include("decimal-shift.typ")
#let second = eval(read("decimal-shift.typ"), mode: "markup")
#table(first, second)
the space and stuff will be handled explicitly
what does and doesnt define a content block is so interesting
one of the most interesting languages i have ever used
|
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/methods-05.typ | typst | Other | // Error: 2:3-2:19 cannot mutate a temporary value
#let numbers = (1, 2, 3)
#(numbers.sorted() = 1)
|
https://github.com/kunalchandan/resume | https://raw.githubusercontent.com/kunalchandan/resume/main/resume.typ | typst | #set page(
// fill: rgb("222222"),
margin: (
x : 2.5em,
y : 2em,
)
)
// #set text(fill: rgb("fdfdfd"))
#import "conf.typ": page_heading, experience, accent_1, accent_10, heading_font_size, main_font_size
#set text(font: ("Jost"), weight: "light", size: main_font_size,)
#set list(marker: ([--], [-]))
#show heading: it => {
if it.level == 1 {
text(
weight: "medium",
size : heading_font_size,
fill : accent_1,
it
)
}
else if it.level == 2 {
// Since smallcaps aren't implemented yet for fonts without scmp, use upper
// smallcaps(it)
text(
weight: "regular",
size: heading_font_size,
spacing: 100%,
upper(it)
)
}
else if it.level == 3 {
text(weight: "medium", it)
} else {
it
}
}
#show strong: set text(weight: "extralight", fill: accent_10)
#page_heading(
name : (
first : "Kunal",
last : "Chandan",
email : "<EMAIL>",
phone : "814-807-7652",
github : "kunalchandan",
linkedin : "kunal-chandan",
caption : "B.A.Sc Honours Electrical Engineering '23",
// caption : "University of Waterloo",
subcaption : "",
// subcaption : "B.A.Sc Honours Electrical & Computer Engineering",
website : "chandan.one"
)
)
#let languages = {
[Python, C++, SQL, Verilog, VHDL, MATLAB, Go, RISC-V]
}
#let libraries = {
[Numpy, Pandas, PyTorch, Boost, FastAPI, Flask, CUDA]
}
// #let languages = exp_list(
// title : "Languages",
// items : (
// [Python],
// (
// // [Numpy],
// // [Pandas],
// [Scipy],
// // [Flask],
// [Sympy],
// // [TensorFlow],
// [Pytorch],
// ),
// [C++],
// (
// [Boost],
// [Catch],
// ),
// [SQL],
// // [Rust],
// // (
// // [nalgebra],
// // [Rayon],
// // ),
// [MATLAB],
// [Go],
// [Verilog],
// [RISC-V],
// // [Shell],
// // [LaTeX],
// )
// )
#let software = {
[KiCAD, LTSpice, Cadence Virtuoso, LayoutEditor, Quartus Prime]
}
// #let software = experience(
// description : (
// [KiCAD],
// [LTSpice/PySpice],
// [Cadence Virtuoso],
// [LayoutEditor],
// [Quartus Prime],
// [Linux],
// )
// )
#let awards = experience(
description : (
[Baylis Medical Capstone Design Award],
[2022 - #link("https://qnfcf.uwaterloo.ca/", "QNFCF Cleanroom Certification")],
[2022 - #link("https://uwaterloo.ca/giga-to-nanoelectronics-centre/lab-equipment", "G2N Cleanroom Certification")],
)
)
#let interests = experience(
description : (
[Cycling],
[Rock Climbing],
[Juggling],
)
)
// #let lab_tools = experience(
// description: (
// [PCB Design],
// [Oscilliscope],
// [Network Analyzer],
// [Probe Station],
// [Wirebonder],
// [Diebonder],
// [Plasma Cleaner & Asher],
// [Dicing saw],
// [HMDS Oven],
// [Spincoater],
// [SEM],
// [X-Ray Spectroscopy],
// )
// )
#let Summary_Quals = experience(
description : (
[Multidisciplinary generalist electrical engineering skills specialist in software development at scale in data engineering with *Python* and performance critical development in *C++*],
[Experienced electrical engineering skills with clean-room and hands-on electrical lab-work],
[Strong electrical engineering foundation through coursework in semiconductor device physics, RF devices, control systems, and IC design]
)
)
#let nvidiac = experience(
title : "Post-Silicon Validation Engineer",
website : "https://nvidia.com/",
company : "NVIDIA - Contractor (6 months)",
dates : (
start : "March 2024",
end : "Present",
),
location : "Santa Clara, CA, USA",
description : (
[Working on *PCIe* testing for upcoming SoCs and GPUs according to PCIe 5.0 spec],
)
)
#let enphase = experience(
title : "Electrical Engineer - Compliance",
website : "https://enphase.com/",
company : "Enphase Energy",
dates : (
start : "Aug 2023",
end : "Mar 2024",
),
location : "Fremont/Petaluma, CA, USA",
description : (
// [Creating tests for compliance of microinverters and other products to *UL-1741* and *IEEE-1547*],
// [Automation of tests in *Python* targetting lab safety and interoperability with lab instruments like powermeters, environment chambers, oscilliscopes etc.],
[Designed and implemented automated compliance testing for PV inverters to IEEE and UL standards],
//[],
[Created business analytics and equipment management application, improving test equipment utilization by *20%* (*Ignition Perspective*,* Python*)],
// [Developed *MySQL*, *Flask* asset management database and interlock system ensuring regulatory compliance and saving \$50K yearly],
// [Improved ease of testing for technicians by adding interoperability with *Ignition*],
)
)
#let uw_wong = experience(
title : "Electrical Engineering Research Assistant - Display Semiconductors",
website : "https://chandan.one/posts/Report/",
company : "University of Waterloo",
dates : (
start : "Sept 2022",
end : "Apr 2023",
),
location : "Waterloo, ON, CA",
description : (
[Designed custom PCBs in *KiCAD* for driving small $mu$LED active/passive matrix displays using *STM32* microcontroller and accompanying circuitry],
[Developed research plan for packaging $mu$LEDs onto TFT backplane using indium electroplating],
// [Characterized results using *SEM* and *X-Ray Spectroscopy*],
[Designed characterization setups for $mu$LEDs in *Fusion360* and *Arduino* interfaced with *Python*],
[Validated flip-chip diebonding results with thermal and electrical simulations in *MATLAB*],
[Designed and validated new $mu$LED layouts to improve mechanical and electrical performance],
),
)
#let uw_yash = experience(
title : "Data Science Research Assistant - Autonomous Vehicles",
website : "https://github.com/kunalchandan/CL2-AutoDetective",
company : "University of Waterloo",
dates : (
start : "Jan 2023",
end : "Apr 2023",
),
location : "Waterloo, ON, CA",
description : (
[Fault analysis of autonomous vehicles (AVs), causality and failure modes of AVs explored, literature reviews conducted],
[Causal inference and counterfactual reasoning applied to identify root cause failures],
[Created a dashboard using *Flask/Dash* to allow for data exploration and identification of novel failure modes],
)
)
#let groq_inc = experience(
title : "Software Engineer - Firmware",
website : "https://groq.com/",
company : "Groq Inc.",
dates : (
start : "Jan 2022",
end : "Apr 2022",
),
location : "Mountain View, CA, USA",
description : (
[Defined algorithm for resource allocation over memory and processing units of tensors on Groq’s TPU],
[Developed *Python* and *C++* firmware API to improve streaming of instructions and data],
[Used *PyBind11* for interoperability between C++ and Python firmware during codebase migration],
// [Used timing analysis to prevent stream conflicts & allowed for interleaving of streams],
)
)
#let huawei = experience(
title : "Software Engineer - Digital Compression",
company : "Huawei Technologies",
dates : (
start : "May 2020",
end : "Aug 2020",
),
location : "Waterloo, ON, CA",
description : (
// [Designed collision free non-cryptographic hash function (NCHF) in Galois Field 2 (GF-2)],
[Designed and analyzed non-cryptographic hash (NCHF) with linear algebra, SAT and self-designed $G F(2)$ matrix solver to verify properties],
[Benchmarked the optimized SIMD hashing function against existing NCHFs (*Rust*, *C++*)],
[Implemented novel border detection algorithm in *Go* using *probabilistic data structures* to maximize performance with Go-routines],
)
)
#let mappedin = experience(
title : "Software Engineer - Machine Learning",
website : "https://www.mappedin.com/",
company : "MappedIn",
dates : (
start : "Sept 2019",
end : "Dec 2019",
),
location : "Waterloo, ON, CA",
description : (
[Designed pipelines for data cleaning and analysis; integrated new *SQL* data warehouse],
[Increased prediction accuracy from *40%* to *80%* on existing *LSTM* models with feature engineering, hyperparameter optimization, and automated data cleaning (*Python*, *SQL*)],
[Created *Embeddings* + *SVM* + *Random Forest* ensemble models to replace existing LSTM models, reducing inference costs *2x* while maintaining prediction accuracy],
)
)
// #let robarts = experience(
// title : "Software Engineer - Bioinformatics",
// company : "Robarts Research Institute",
// dates : (
// start : "Jan 2021",
// end : "Apr 2021",
// ),
// location : "London, ON",
// description : (
// // [Developed software for migration of genetic analysis database from GRCh37 to GRCh38],
// // [Developed software in *Python* & *SQL* for existing genetics analysis pipeline],
// // [Resolved bugs in existing lab software (*Perl*, *Python*, *C\#*)],
// )
// )
#let oicr = experience(
title : "Software Engineer - Bioinformatics",
website : "https://github.com/oicr-gsi/dashi",
company : "Ontario Institute for Cancer Research",
dates : (
start : "Jan 2019 - Apr 2019",
end : "Jan 2021 - Apr 2021",
),
location : "Toronto, ON, CA",
description : (
// [Project lead of new statistical analysis tool for all future studies at OICR-GSI],
[Developed software in *Python* and *SQL* for existing genetics analysis pipeline],
[Resolved bugs in existing lab software (*Perl*, *Python*, *C\#*)],
[Designed genomics pipelines for visualization, cleaning, and analysis; interfacing with existing *R*, *Perl*, and *Shell* pipelines],
[Wrote future-proof and extensible code to process big datasets (*Pandas*, *Shell*)],
// [Open-sourced project and version controlled with *Git*; created extensive documentation],
)
)
#let risc_v_core = experience(
title : "Pipelined Risc-V Core",
description : (
[Designed 5-stage pipelined *RISC-V* 32-bit core in *Verilog* using only synthesizable constructs],
[Core synthesized on *FPGA* and successfully ran branching and recursive algorithms. Testbenches used to ensure cycle accuracy],
)
)
#let compiler = experience(
title : "C++ Compiler for C++ like Language",
website : "https://github.com/kunalchandan/RajLang/",
description : (
[Wrote lexer and compiler to generate *RISC-V* assembly for custom programming language, used Spike-sim to verify correctness of assembly],
[Used *CMake* (build management tool), *Catch* (unit-testing framework), *Boost* (graph library/dotviz generator)],
)
)
#let msa_dna = experience(
title : "Multiple Sequence Aligner",
website : "https://github.com/kunalchandan/goSeq/",
description : (
[Wrote sequence aligner for novo assembly of short sequences using Progressive Alignment Construction using the Needleman-Wunsch algorithm],
[Written in *Go* to take advantage of light weight green threads, used greedy heuristics to reduce $O(n!)$ problem to $O(n^2)$],
)
)
#let hearing_aid = experience(
title : "Beamforming Hearing Aid System",
website : "https://chandan.one/posts/mic-array/",
description : (
[Designed 4-channel microphone array PCB with active analog bandpass filtering, diff. amp., and multichannel *ADC* over *SPI* to R-Pi (*KiCAD*)],
[Created *Flask* server on R-Pi to compress and transfer audio data to *Pytorch* neural network for further digital filtering and beamforming],
[Adapted and trained Pytorch quantized voice isolation model to minimize latency while maintaining desired audio quality],
[Used *multiprocessing*, *asyncio*, and *websockets* to maximize system throughput, providing continuous audio output],
)
)
#let ray_tracing = experience(
title : "3D Ray Tracing Engine",
website : "https://github.com/kunalchandan/ToyTracer/",
description : (
[Implemented 3D recursive path-tracing for arbitrary materials on basic geometric shapes],
[Used *nalgebra* for arbitrary rotations and positions of camera and objects],
[Parallel processing of ray-tracing using *rayon* yielding *\~10X* performance speed-up on CPU],
)
)
#let education = experience(
title : "University of Waterloo -- B.A.Sc Electrical Engineering '23",
description : (
[Key Courses: Electronic devices, semiconductor physics, analog/digital integrated circuits, analog/digital/multivariable control systems],
[Select Awards and Certifications: Baylis Medical Capstone Design Award, #link("https://qnfcf.uwaterloo.ca/", "QNFCF") and #link("https://uwaterloo.ca/giga-to-nanoelectronics-centre/lab-equipment", "G2N") Cleanroom Certifications],
)
)
#box(height: 1.7cm,
columns(1, gutter: 5pt)[
#text(weight: "medium", size : heading_font_size, fill : accent_1, [Libraries:])
#libraries
#text(weight: "medium", size : heading_font_size, fill : accent_1, [Languages:])
#languages
#text(weight: "medium", size : heading_font_size, fill : accent_1, [Software:])
#software
// #text(weight: "medium", size : heading_font_size, fill : accent_1, [Lab Tools:])
// #lab_tools
// #colbreak()
// = Interests
// #interests
// = Award
// #awards
]
)
// = Summary of Qualifications
// #Summary_Quals
#box(height: 23.6cm,
columns(1, gutter: 10pt)[
= Experience
#nvidiac
#uw_yash
#groq_inc
#huawei
// #enphase
// #mappedin
#uw_wong
// #oicr
= Projects
#compiler
#msa_dna
#ray_tracing
#risc_v_core
#hearing_aid
= Education
#education
]
)
|
|
https://github.com/f14-bertolotti/bedlam | https://raw.githubusercontent.com/f14-bertolotti/bedlam/main/src/colors.typ | typst | // COLORS
#let orchid = color.rgb(200,150,250)
#let darkgray2 = color.rgb(84,84,84)
#let darkgray = color.rgb(64,64,64)
#let superdarkgray = color.rgb(16,16,16)
#let lightblue = color.rgb(82, 220, 255)
#let lightgreen = color.rgb(100, 255, 87)
#let ochre = color.rgb(204, 119, 34)
#let neonorange = color.rgb(255, 95, 31)
#let celadon = color.rgb(175, 225, 175)
#let emerald = color.rgb(80, 200, 120)
#let turquoise = color.rgb(64, 224, 208)
#let gold = color.rgb(196, 180, 84)
// Text colors associations
#let heading_color = white
#let line_color = 2pt + gradient.linear(superdarkgray, white)
#let page_color = superdarkgray
#let text_color = white
#let bold_color = orchid
#let link_color = turquoise
#let comment_color = emerald
// Theorem colors association
#let lemma_color = orange
#let definition_color = yellow
#let theorem_color = turquoise
#let example_color = lightgreen
#let proof_color = orchid
#let proposition_color = orange
// better page color, but it slow down the render in okular quite a bit
//#let page_color = gradient.linear(darkgray, superdarkgray, angle:45deg)
|
|
https://github.com/GuTaoZi/SUSTech-thesis-typst | https://raw.githubusercontent.com/GuTaoZi/SUSTech-thesis-typst/main/template/cover_en.typ | typst | MIT License | #import "../utils/datetime_display.typ" : *
#import "../utils/style.typ" : *
#import "@preview/tablex:0.0.6" : *
#let cover_en(
anonymous: false,
fonts: (:),
info: (:),
) = {
let display_info_top(
term,
value,
) = {
block(
width: 100%,
gridx(
columns: (auto,-15pt,auto),
rect(
stroke: none,
text(font: FONTS.宋体,size: FSIZE.小四,term)
),
"",
rect(
width: 3cm,
stroke: (bottom: 1pt + black),
align(center)[
#text(font : FONTS.宋体, size : FSIZE.小四, value)
]
)
)
)
}
let display_info(
term,
value,
) = {
block(
width: 100%,
gridx(
columns: (14em,auto),
rect(
width: 14em,
stroke: none,
align(right)[
#text(font: FONTS.宋体,size: FSIZE.三号,weight: "bold",term)
]
),
rect(
width: 9.5cm,
stroke: (bottom: 1pt + black),
align(center)[
#text(font : FONTS.宋体, size : FSIZE.三号, weight : "bold", value)
]
)
)
)
v(-10pt)
}
// render cover
gridx(
columns: (50%,50%),
align(left)[
#display_info_top(
"CLC",
info.clc,
)
],
align(right)[
#display_info_top(
"Number",
info.thesis_id,
)
],
)
v(-1cm)
gridx(
columns: (50%,50%),
align(left)[
#display_info_top(
"UDC",
info.udc,
)
],
align(right+horizon)[
#text(font: FONTS.宋体,size: FSIZE.小四,"Available for reference ◻Yes ◻No")
],
)
set align(center)
if(anonymous){
text("under consturction")
}
else{
}
image("../assets/logo_en.svg",width: 13cm)
v(-10pt)
text("Undergraduate Thesis",size: FSIZE.小初,font: FONTS.宋体)
v(40pt)
// render info
let title_rows = info.title.len()
let it = 0
while it < title_rows {
if it == 0 {
display_info(
"Thesis Title:",
info.title.at(0),
)
}
else{
display_info(
"",
info.title.at(it),
)
}
it = it + 1
}
if info.subtitle != "" {
display_info(
" ",
info.subtitle,
)
}
display_info(
"Student Name:",
info.author,
)
display_info(
"Student ID:",
info.student_id,
)
display_info(
"Department:",
info.department,
)
display_info(
"Program:",
info.major,
)
display_info(
"Thesis Advisor:",
info.supervisor,
)
// render submit date
align(center+bottom)[
#text(font: FONTS.宋体,size: FSIZE.三号,datetime_display_en(
info.submit_date,
))]
}
|
End of preview. Expand
in Dataset Viewer.
- Downloads last month
- 49