repo
stringlengths
26
115
file
stringlengths
54
212
language
stringclasses
2 values
license
stringclasses
16 values
content
stringlengths
19
1.07M
https://github.com/typst-community/valkyrie
https://raw.githubusercontent.com/typst-community/valkyrie/main/tests/types/array/test.typ
typst
Other
#import "/src/lib.typ" as z #import "/tests/utility.typ": * #show: show-rule.with(); #let schema = z.array() = types/array == Input types #{ let input-types = ( "array (empty)": (), "array (single)": (0,), ) for (name, value) in input-types { utility-expect-eq( test: value, schema: schema, truth: value, )([It should validate #name]) } } == Test \#1 #let test-array = ("<EMAIL>", "<EMAIL>") #test-array #utility-expect-eq( test: test-array, schema: z.array(), truth: test-array, )([Test satisfies array\<any\>]) #utility-expect-eq( test: test-array, schema: z.array(z.email()), truth: test-array, )([Test satisfies array\<email\>]) === Assertions - Minimum length #utility-expect-eq( test: test-array, schema: z.array(z.email(), min: 1), truth: test-array, )([Test satisfies array\<email\> min length 1]) #utility-expect-eq( test: test-array, schema: z.array(z.email(), min: 2), truth: test-array, )([Test satisfies array\<email\> min length 2]) #utility-expect-eq( test: test-array, schema: z.array(z.email(), min: 3), truth: (), )([Test fails array\<email\> min length 3]) === Assertions - Maximum length #utility-expect-eq( test: test-array, schema: z.array(z.email(), max: 1), truth: (), )([Test fails array\<email\> max length 1]) #utility-expect-eq( test: test-array, schema: z.array(z.email(), max: 2), truth: test-array, )([Test satisfies array\<email\> max length 2]) #utility-expect-eq( test: test-array, schema: z.array(z.email(), max: 3), truth: test-array, )([Test satisfies array\<email\> max length 3]) === Assertions - Exact length #utility-expect-eq( test: test-array, schema: z.array(z.email(), assertions: (z.assert.length.equals(2),)), truth: test-array, )([Test satisfies array\<email\> equal length 2]) #utility-expect-eq( test: test-array, schema: z.array(z.email(), assertions: (z.assert.length.equals(3),)), truth: (), )([Test fails array\<email\> equal length 3])
https://github.com/IdoWinter/UnitedDumplingsLegislatureArchive
https://raw.githubusercontent.com/IdoWinter/UnitedDumplingsLegislatureArchive/main/elections/ballot.typ
typst
MIT License
#let ballot(initials, name) = { set align(center) rect([ #set text(lang: "he", font: "FrankRuehl") #set text(size: 72pt) #v(0.5cm) #initials #v(-60pt) #set text(size: 16pt) #name ], height: 5.96cm, width: 4.2cm) } #let pm_ballot(first_name, last_name) = { set align(center) rect([ #set text(lang: "he", font: "FrankRuehl") #set text(size: 40pt) #v(1.2cm) #first_name #v(-1cm) #last_name ], height: 5.96cm, width: 4.2cm) } #let repeat_ballot(ballot, lines: 3) = { for j in range(lines) { let l = () for i in range(5) { l.push(ballot) } stack(dir: ltr, ..l) v(-14pt) } }
https://github.com/chendaohan/bevy_tutorials_typ
https://raw.githubusercontent.com/chendaohan/bevy_tutorials_typ/main/18_change_the_background_color/change_the_background_color.typ
typst
#set page(fill: rgb(35, 35, 38, 255), height: auto, paper: "a3") #set text(fill: color.hsv(0deg, 0%, 90%, 100%), size: 22pt, font: "Microsoft YaHei") #set raw(theme: "themes/Material-Theme.tmTheme") = 1. 更改背景颜色 使用 ClearColor 资源来选择默认的背景颜色。此颜色将作为所有相机的默认颜色,除非被覆盖。 请注意,如果没有相机存在,窗口将是黑色的。你必须至少生成一个相机。 ```Rust .insert_resource(ClearColor(Color::Srgba(tailwind::GREEN_300))) ``` 要覆盖默认颜色并为特定相机使用不同的颜色,可以使用 Camera 组件进行设置。 ```Rust commands.spawn(Camera3dBundle { camera: Camera { viewport: Some(Viewport { physical_position: UVec2::new(1280 / 2, 0), physical_size: UVec2::new(1280 / 2, 720 / 2), ..default() }), order: 1, clear_color: ClearColorConfig::None, ..default() }, transform: Transform::from_xyz(0., 140., 106.).looking_at(Vec3::ZERO, Vec3::Y), ..default() }) ``` 所有这些位置(特定相机上的组件,全局默认资源)都可以在运行时进行更改,Bevy 将使用你的新颜色。使用资源更改默认颜色将把新颜色应用于所有未指定自定义颜色的现有相机,而不仅仅是新生成的相机。
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/t4t/0.2.0/def.typ
typst
Apache License 2.0
// Defaults #let if-true( test, default, do:none, value ) = if test { return default } else if do == none { return value } else { return do(value) } #let if-false( test, default, do:none, value ) = if not test { return default } else if do == none { return value } else { return do(value) } #let if-none( default, do:none, value ) = if value == none { return default } else if do == none { return value } else { return do(value) } #let if-auto( default, do:none, value ) = if value == auto { return default } else if do == none { return value } else { return do(value) } #let if-any( ..compare, default, do:none, value ) = if value in compare.pos() { return default } else if do == none { return value } else { return do(value) } #let if-not-any( ..compare, default, do:none, value ) = if value not in compare.pos() { return default } else if do == none { return value } else { return do(value) } #let if-empty( default, do:none, value ) = if is-empty(value) { return default } else if do == none { return value } else { return do(value) } #let if-arg( default, do:none, args, key ) = if key not in args.named() { return default } else if do == none { args.named().at(key) } else { do(args.named().at(key)) } #let as-arr( ..values ) = (..values.pos(),).flatten()
https://github.com/sa-concept-refactoring/doc
https://raw.githubusercontent.com/sa-concept-refactoring/doc/main/chapters/developmentProcess.typ
typst
= Development Process <development_process> Within this section, it is explained how the working environment was setup and what tools were used for development. @workflow documents what the work process looked like. In @setup, it is described how the project was setup for Windows and Linux. == Workflow <workflow> As the LLVM project, to which the new refactoring features should be contributed, is on GitHub, it was decided to also work using GitHub. The LLVM project already had workflows set up on GitHub, so the decision was made to re-use them. The LLVM project was then forked into a public repository @llvm_fork_github, where for each refactoring feature, a separate branch was created. After the implementation of a refactoring feature was finished, a pull request to the LLVM project was submitted. Two different systems were used for development (Windows and Linux), but the IDEs used were the same on both systems. To be able to use the local build of the clangd language server, a simple settings.json file can be added to VS Code. More details about this setup can be found in @setup. For testing the local build, a test project was created containing different versions of function templates and concepts. These code snippets were then used to test the refactoring implementations using VS Code. @project_organisation_diagram illustrates how the different tools and setups work together. #figure( image("../drawio/project-organisation.drawio.svg", width: 100%), caption: [Diagram showing structure and workflow of the project \ (Logos from @logo_clangd, @logo_clion, @logo_git, @logo_github, @logo_llvm, @logo_vscode)], ) <project_organisation_diagram> == Setup <setup> To build clangd, CLion was used as an IDE since it has great support for CMake as well as very good autocomplete, search, and debugging capabilities. VS Code with the clangd extension @clangd_extension and the CMake extension @cmake_extension was then configured to use the locally built language server using the `clangd.path` setting as shown in @settings_json. #figure( ```cpp { // Windows "clangd.path": "..\\llvm-project\\llvm\\cmake-build-release\\bin\\clangd.exe" // Linux "clangd.path": "../llvm-project/llvm/cmake-build-release/bin/clangd" } ```, caption: [Configuration in settings.json file for to VS Code], ) <settings_json> For building clangd using CLion the following steps were executed. + Clone project from GitHub https://github.com/llvm/llvm-project - `git clone <EMAIL>:llvm/llvm-project.git` + Open llvm project in CLion + Open folder `llvm/CMake.txt` in CLion and execute cmake + File -> Settings -> Build, Execution, Deployment -> CMake -> CMake options - add `-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra'` + Choose "clangd" in target selector and start building #footnote[ When using Windows, clangd.exe should not be in use to build clangd successfully. In this example this applies to VS Code when the language server has started. ] After the clangd build is completed the language server within VS Code needs to be restarted to use the current build. This can be done by pressing `Ctrl + p` : `>Restart language server`. === Linux The project was built using ninja and gcc12. Tests with the language server were performed using VSCodium @VSCodium, a fork of VS Code without telemetry. Neovim @neovim was also used for testing, which contains a built-in LSP client. Configuration for Neovim can be found in @configuration_neovim. The hardware used was an AMD Ryzen™ PRO 4750U (8 core mobile) and an AMD Ryzen™ 9 5900X (12 core desktop) CPU with 48 gigabytes of system memory. #figure( ```lua :lua vim.lsp.start({ name = 'clangd', cmd = {'PATH_TO_CLANGD_BINARY'}, root_dir = vim.fs.dirname( vim.fs.find({'CMakeLists.txt'}, { upward = true })[1] ) }) ```, caption: "Configuring clangd in Neovim" ) <configuration_neovim> === Windows On Windows the project was built using ninja and Visual Studio. The hardware used was a Intel® Core™ i7-10510U CPU with 16 gigabytes of system memory. Visual Studio was installed with the following components. - C++ ATL for latest v143 build tools - Security Issue Analysis - C++ Build Insights - Just-In-Time debugger - C++ profiling tools - C++ CMake tools for Windows - Test Adapter for Boost.Test - Test Adapter for Google Test - Live Share - IntelliCode - C++ AddressSanitizer - Windows 11 SDK - vcpkg package manager #figure( image("../images/screenshot_build_options_windows.png", width: 100%), caption: [Screenshot showing build settings in CLion on Windows], )
https://github.com/L364CY-FM/typst-thesis
https://raw.githubusercontent.com/L364CY-FM/typst-thesis/main/projektarbeit/metadata.typ
typst
MIT License
// Enter your thesis data here: #let title = "Titel der Arbeit" #let degree = "Projekt 3" #let supervisor = "Prof. Dr. <NAME>" #let advisors = ("<NAME>, M.Sc.",) #let author = "(Author)" #let location = "(Location)" #let startDate = "(Start Date)" #let submissionDate = "(Handover Date)"
https://github.com/VisualFP/docs
https://raw.githubusercontent.com/VisualFP/docs/main/SA/project_documentation/content/used_tools.typ
typst
= Used Tools We used these tools to realize this project. / Jira: is a software management tool to manage agile teams. We are using it to plan the project and keep track of the progress. #footnote("https://visual-fp-ost.atlassian.net/jira/") / GitHub: is a web-based hosting service for version control using Git. We are using it to control and build the source code. #footnote("https://github.com/VisualFP") / Typst: is a typesetting system that allows the document to be written in code, similar to LaTeX. We use it to write the project documentation and the design concept. #footnote("https://typst.app/") / GHC: short for Glasgow Haskell Compiler, is a compiler for the Haskell programming language. We are employing GHC to write the backend and use it as a compiler platform in the product. #footnote("https://www.haskell.org/ghc/") / Grammarly: is an advanced writing tool that rephrases English texts to correct errors and improve their quality.
https://github.com/chendaohan/bevy_tutorials_typ
https://raw.githubusercontent.com/chendaohan/bevy_tutorials_typ/main/13_cameras/cameras.typ
typst
#set page(fill: rgb(35, 35, 38, 255), height: auto, paper: "a3") #set text(fill: color.hsv(0deg, 0%, 90%, 100%), size: 22pt, font: "Microsoft YaHei") #set raw(theme: "themes/Material-Theme.tmTheme") = 1. 摄像机 Camera 在 Bevy 中驱动所有渲染。它们负责配置绘制内容、绘制方式和绘制位置。 你必须至少拥有一个摄像机实体,才能显示任何内容!如果忘记生成摄像机,会看到一个空的黑屏。 在最简单的情况下,可以使用默认设置创建摄像机。只需使用 Camera2dBundle 或 Camera3dBundle 生成一个实体。它会绘制所有可见的可渲染实体。 实用建议:始终为你的摄像机实体创建标记组件,这样可以方便地查询摄像机。 ```Rust #[derive(Component)] struct MyGameCamera; fn setup(mut commands: Commands) { commands.spawn(( Camera2dBundle::default(), MyGameCamera, )); } ``` = 2. 摄像机 Transform 摄像机拥有 Transform,可以用于定位或旋转摄像机。这就是移动摄像机的方法。 = 3. 缩放摄像机 不要使用 Transform 来缩放摄像机!这只是拉伸图像,并不是真正的缩放。这可能还会导致其他问题和不兼容性,应该使用 Projection 来缩放。 对于正交投影,改变缩放比例。对于透视投影,改变视场(FOV)。视场模拟镜头缩放效果。 ```Rust fn scale_camera(mut projection: Query<&mut Projection, With<MyCamera>>) { let Ok(projection) = projection.get_single_mut() else { return; }; match projection.into_inner() { Projection::Orthographic(projection) => { if (projection.scale - 0.15).abs() <= f32::EPSILON { projection.scale = 0.05; } else { projection.scale = 0.15; } } Projection::Perspective(projection) => { if (projection.fov - 0.785).abs() <= f32::EPSILON { projection.fov = 1.2; } else { projection.fov = 0.785; } } } } ``` = 4. Projection(投影) 摄像机投影负责将坐标系映射到视口(通常是屏幕/窗口)。它配置坐标空间以及图像的任何缩放/拉伸。 Bevy 提供两种投影:正交投影和透视投影。它们是可配置的,以服务于各种不同的使用场景。 正交投影意味着无论物体距离摄像机多远,大小始终相同。 透视投影意味着物体距离摄像机越远,看起来越小。这是为 3D 图形提供深度和距离感的效果。 2D 摄像机始终是正交的。 3D 摄像机可以使用任一种投影。透视是最常见(也是默认)的选择。正交投影适用于如 CAD 和工程等应用,在这些应用中,你希望准确表示物体的尺寸,而不是创造逼真的 3D 空间感。一些游戏(尤其是模拟游戏)出于艺术选择使用正交投影。 可以实现自定义摄像机投影。这可以让你完全控制坐标系统。不过,请注意,如果违反 Bevy 的坐标系统约定,可能会导致行为异常! ```Rust fn toggle_perspective_orthographic(mut projection: Query<&mut Projection, With<MyCamera>>) { let Ok(mut projection) = projection.get_single_mut() else { return; }; if let Projection::Perspective(_) = projection.as_ref() { *projection = Projection::Orthographic(OrthographicProjection { scale: 0.15, ..default() }); } else { *projection = Projection::Perspective(PerspectiveProjection::default()); } } ``` = 5. 渲染层 RenderLayers 是一种过滤哪些实体应该由哪些相机绘制的方法。将此组件插入到您的实体上,以将它们放置在特定的“层”中。 将此组件插入到相机实体上可以选择该相机应该渲染哪些层。将此组件插入到可渲染实体上可以选择哪些相机应该渲染这些实体。如果相机的层和实体的层之间有任何重叠(它们至少有一个共同的层),则该实体将被渲染。 如果实体没有 RenderLayers 组件,则假定它属于第 0 层(仅此一层)。 您还可以在实体生成后修改其渲染层 ```Rust fn toggle_render_layers(mut render_layers: Query<&mut RenderLayers>) { for mut render_layer in &mut render_layers { if render_layer.iter().next().unwrap() == 0 { *render_layer = RenderLayers::layer(1); } else { *render_layer = RenderLayers::layer(0); } } } ``` = 6. 禁用摄像机 您可以在不销毁相机的情况下停用它。这在您想保留相机实体及其携带的所有配置,以便以后可以轻松重新启用时非常有用。 ```Rust fn toggle_camera_active(mut camera: Query<&mut Camera, With<MyCamera>>) { let Ok(mut camera) = camera.get_single_mut() else { return; }; if camera.is_active { camera.is_active = false; } else { camera.is_active = true; } } ```
https://github.com/herbhuang/utdallas-thesis-template-typst
https://raw.githubusercontent.com/herbhuang/utdallas-thesis-template-typst/main/thesis.typ
typst
MIT License
#import "/layout/thesis_template.typ": * #import "/metadata.typ": * #set document(title: titleEnglish, author: author) #show: thesis.with( title: titleEnglish, titleGerman: titleGerman, degree: degree, program: program, supervisor: supervisor, advisors: advisors, author: author, startDate: startDate, submissionDate: submissionDate, abstract_en: include "/content/abstract_en.typ", abstract_de: include "/content/abstract_de.typ", acknowledgement: include "/content/acknowledgement.typ", transparency_ai_tools: include "/content/transparency_ai_tools.typ", ) #include "/content/introduction.typ" #include "/content/background.typ" #include "/content/related_work.typ" #include "/content/requirements_analysis.typ" #include "/content/system_design.typ" #include "/content/evaluation.typ" #include "/content/summary.typ"
https://github.com/goshakowska/Typstdiff
https://raw.githubusercontent.com/goshakowska/Typstdiff/main/tests/test_complex/text_formats/text_formats_inserted_result.typ
typst
= Heading1 Paragraph with quotes “This is in quotes.”#underline[ ];#underline[“New];#underline[ ];#underline[quote”] #strong[Date:] 26.12.2022 \ Date used in paragraph #strong[Date:] 26.12.2022#strike[ \ ];#strike[#strong[Topic:];];#strike[ ];#strike[Infrastructure] #strike[Test];#strike[ \ ];#strong[#strike[Severity:];#underline[Date:];] #strike[High];#underline[30.12.2024];#strike[ \ ] #underline[#strong[Topic:];];#underline[ ];#underline[Infrastructure];#underline[ ];#underline[Test];#underline[ \ ];#underline[#strong[Severity:];];#underline[ ];#underline[High];#underline[ \ ] = Heading3 #emph[emphasis] Some#underline[ ];#underline[normal];#underline[ ];#underline[text];#underline[ ];#underline[Another] normal text Italic #strong[MY TEXT] \ ALREADY HIGH #link("https://typst.app/") = Heading4 abc#underline[ ];#underline[def] Link#underline[ ];#underline[in];#underline[ ];#underline[paragraph:];#underline[ ];#underline[#link("https://typst.app/");];#underline[ ];#underline[Another];#underline[ ];#underline[link] in paragraph: #link("https://typst.app/") = Heading5
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/array-32.typ
typst
Other
// Test joining content. // Ref: true #([One], [Two], [Three]).join([, ], last: [ and ]).
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/046%20-%20Streets%20of%20New%20Capenna/008_The%20Family%20Man.typ
typst
#import "@local/mtgstory:0.2.0": conf #show: doc => conf( "The Family Man", set_name: "Streets of New Capenna", story_date: datetime(day: 04, month: 04, year: 2022), author: "<NAME>", doc ) "Do we#emph[ have] to stop here tonight, Dad? This place~it's plain old gauche, ain't it?" Anhelo winced. She wasn't wrong. Park Heights was a carefully crafted work of art, a thing anyone would die to behold. All its parts sang together like a choir of~well, angels. And for a man like Anhelo—a conductor, a connoisseur, a true bon vivant—picking the right environment for his work was like picking the right key for a symphony. But he couldn't imagine what anyone could compose here. If you asked him, the place was a dump, plain and simple. Stank like rotten food, grime on all the walls. No limestone here, no sir; no marble, no gold. Trash lined the streets, waiting for pick up. The people here were just as shifty—not a drop of fashion anywhere to be seen. The angels must not be watching this place. Of course, Errant hated it. She was right to. Having her here was like bringing a sunbeam down into a cave. But there was no helping it. The boss wanted intel, and Errant needed some last-minute supplies for the big day tomorrow. Anhelo wasn't sure how many more chances he was going to get to be the one to come through for her. He had to take them when he got them. But the boss, well~ "I'm sorry, sweetheart," he said. He kissed her forehead. "Just five minutes, I promise." "What are you even buying here?" she asked him, pouting. She had her mother's warm brown skin, but the thick wavy hair was all him. She gestured out the window, her expensive manicure cheapened by the flicker of badly maintained lights. "No way this place has any artists." "Art's everywhere, if you know where to look," Anhelo answered. Wishful thinking on his part, but it wasn't a total lie. He got out of the car. A glare conveyed to the driver what'll happen to him if Errant comes to any harm while he's away. Word on the streets was this place did business quick, but if they didn't~"If I'm not back in fifteen, then I'll see you in the morning." Errant crossed her arms. She looked so much like her mother when she did that, rest the woman's soul. "You said five minutes. Now it's fifteen. Is this going to be like when you missed my party because of that Severo guy?" No knife he'd ever wielded could match the hurt of that disappointment. He deserved that one. Errant didn't know why he was here, nor would she. "You got me there," he admitted. "Five it is." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) Five minutes to make his case. Five minutes to get his information. Five minutes back to the car. He couldn't disappoint her, not again. The thought of that alone was impetus enough to get to the point. "Toluz. You heard the news?" #figure(image("008_The Family Man/01.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) Her grin was wide and white in the dark of her office, pale as a razor held against the night's own throat. Her voice was richer than everything in this neighborhood put together. "I hear all the news, Anhelo. Is that any way to greet your family?" Anhelo flicked the tip of his own brown nose. "I don't have a lot of time, and we aren't family yet." Fingernails drummed unseen on the desk. Despite that, he'd seen Toluz enough to know the look on her face. Always had the look of a mother who'd just caught you sneaking out at night. Those thick black brows of hers were the most expressive thing in this part of town. "Business, then? I'd expect nothing else from a Maestro. You have no sense of propriety." "Business," Anhelo nodded. He'd let the rest pass without comment, just for today. "There's a woman in white traipsing around the boss's territory. Know anything about 'er?" "Plenty," came the answer. Of course. Toluz had a reputation for playing with her food, and Anhelo was under no illusions. Outside of this place, he was an unstoppable assassin, an artist of the knife without compare. But here? There was a reason Toluz kept her office so dark. And Errant marrying Toluz's daughter wasn't going to matter much if he upset her. They didn't call her Light's-Out Luz for nothing. Won a slick gadget from the higher-ups once, fair and square she alleged. A shadow generator. If Light's-Out Luz wanted you gone, you'd never see her coming. But Anhelo didn't have time to waste, and he didn't like the idea of someone who worked in the dark. Better to have your work out in the open. Part of why he hated this neighborhood, really. Lot of inventive folk here—but no sense of drama. "What's a guy gotta do to get that information?" "If you were family," she began, "it'd be free." Here she was, dragging things out. Anhelo grit his teeth. "Just tell me." "Don't look so grim, Anhelo," she said. "All I'm asking for is a favor. Helps you as much as it helps me." "Find that hard to believe with your reputation," he said. The extra power Toluz offered her clients meant she charged far more than even the Brokers for her services. Hadn't seemed to slow her down much, having her leg messed up in the Shadow Generator job. Only difference was she did a bit less of her own field work—and when she did, she brought a cane. "You don't know me very well," came the answer. Heels clicked along the ground. "<NAME>. You know the name?" Anhelo chuckled. "Yeah, I know the guy. One of ours. Got no taste in fashion but keeps heading to the buffet, anyway. What's the job?" "The buffoonery's a cover. My daughter's been having trouble with him for years. Last night he made a move. You saw her." He had. Parnesse showed up to the rehearsal dinner with a gash across her cheek the size of a stick of gum. Errant couldn't stop fussing over her all night. Anhelo hadn't missed the scent of blood on her, either, or the way she winced when Errant embraced her. Broken ribs. Parnesse refused to talk about it, of course—knuckleheaded pride—but Anhelo had a hunch it was bad. Thought maybe it was the woman in white he'd heard so much about, causing trouble left and right. But Fiero? #emph[Fiero] ? It just didn't make any sense. Guy'd never done a real job, so far as Anhelo heard. He #emph[really was ] just an art dealer, and a bad one, at that. Still, he knew Toluz was no liar. Especially when it came to Parnesse. "If you want information for your Family, you have to do a little work for ours. Bump him off, and we'll talk," she said. He pinched the bridge of his nose. Offing someone within the family was going to be tough to explain, but he could make it work. Wasn't like he liked Fiero all that much, either. No one did. Man wore enough cologne to smother you to death from a mile away. "When do you need it done?" "Tomorrow." "But that's—" "The wedding, I know," she said. A tap against the cool stone floor—her cane, most likely. "He has twenty goons under his heel looking to cause trouble otherwise. Tired of being the joke, I'd wager, and looking to make a name for himself. What better way to prove his merciless nature than ruining such a high-profile affair?" He clenched his right hand into a fist. That little~ The timing was going to be tight. He needed to be at the Grand Capenna Hall by half-past three to make the wedding. Errant wanted him to walk her down the aisle. To make Fiero into the monument to cowards and traitors Anhelo wanted him to be, it'd take hours. "Why can't you do it?" "Because you're going to," Toluz says. "Let's not make bones about that." She could have done it herself. That Fiero would try to put out a hit on Parnesse when her mother once beat a rhox's skull in barehanded spoke to his audacity, his hubris. That he'd try to follow that up with an attack on an inter-family wedding~ He hated to admit that she's right. The guy had to go. "It's been three and a half minutes, Anhelo. If you leave now, you have time to make it back to the car." "Real considerate of you," he said. He turned toward the door. "I'll get it done." "I know you will," she said. "Congratulations on the wedding." He let out a strained laugh. "Yeah. You, too, Toluz. You, too." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) You can compose the best symphony in the plane only to hand it to a bunch of kids playing out-of-tune violins. Good art—whether it be music, painting, or murder—was all about the sum of its parts. Composer, performer, instrument. Painter, canvas, paint. Anhelo had one terrible part to work with. Fiero was nobody's friend, and what he called fashion was just going to get in the way of Anhelo's artistic expression. Too gaudy, by far. If he was going to make this work, he needed to ensure the body was found somewhere clean and simple for contrast's sake. That was a big ask for a man who ran a museum. It was a bigger ask with less than twelve hours to get the job done. But Anhelo hated to disappoint—the boss, Errant, his adoring public. He'd get it done. Step one was to send the invitation. That he could do the night he got the orders, and it'd give him time to work with. #emph[To Mister <NAME>, in recognition of your contribution to New Capenna's ever-changing fashions, we'd like to invite you to a private tour of the museum] #emph[] #emph[. . .] The next step was to find a collaborator. Great art like this required two artists, after all. First thing in the morning, he swung by Evelyn's place, kissed the ring, talked up her latest acquisitions—but she caught him out in five minutes. #figure(image("008_The Family Man/02.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) "You aren't here to look at portraits, are you?" Evelyn's cunning was as sharp as the knives Anhelo kept up his sleeves. She'd had centuries to hone it. "Got me sniffed out," he said. "Need something for tomorrow." "For the wedding?" Evelyn said. Her brows rose. "I'd heard Parnesse got into a tussle, but I didn't think it was with you." "It wasn't," Anhelo said. "Then~you're doing family business on the day of your daughter's wedding?" The corner of Anhelo's lip twitched. He hated how that sounded, but~"Yeah. I am. I need something I can rig in the museum." A moment of silence passed between them, Evelyn sizing him up. "My, what a #emph[predicament] . Of course, I'll help~" A sinking feeling in his stomach. "For a price?" "Clever boy," she said, flashing her fangs. "We'll work out the details some other time, but for now, let's just call it a favor for a favor." Evelyn's "favors" were about the worst thing you could have hanging around your neck in the Maestros. The boss being upset with you was the only thing that could inspire more desperation from one of the family. The last time he'd owed her a favor, she'd asked him to kill a Nightmare. Said she wanted to be the only one in town. He'd done it—but the scars from that one still coated his ribs. Unsightly flesh he'd have to live with for eternity. Toluz could make that sort of thing a point of pride, but not him. He could turn her down. He could figure out some way to do this on his own, one that involved less flash. If he gave up on making this a work of art, then he could just pull Fiero into an alcove and kill him there, easy as could be. Show up at the wedding early enough to help set up the silverware. But what sort of message would that leave? What kind of impression? No. An artist never compromises. He had time for both. He #emph[was] both. He could no more slit Fiero's throat in an alley than he could abandon his daughter. It was going to work out, it had to. "All right," he said. "Name your price." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) "Anhelo, Anhelo, Anhelo!" Fiero wrapped an arm around him like they were old friends. Halo smoke curled around them, earning glares from security. Never mind the signs posted all over—Fiero wanted to make an impression. "My old friend! What an honor. I had no idea you'd be giving the tour. Isn't it your daughter's wedding day?" Anhelo's smile was strained. "Sure is." "Taking time out of your day to help a jamoke like me," he said. With two more claps on the shoulder, he let Anhelo go, anointed now with the reek of cheap cologne. "I tell ya, nobody in the family like you, buddy. Nobody looking out for the little guy anymore." At least they agreed that he was a jamoke. "That's your job, ain't it?" Anhelo said. He started walking, hoping Fiero would take the hint. "Looking after all our new fellas, showing them the ropes, keeping an eye out for new art. Where'd we be without you?" Hook, line, and sinker, he reeled Fiero in. Man was walking straight into his own tomb. Despite how banal a person he was, the solemnity of the occasion lent things a certain poetry Anhelo couldn't resist. "Well, you know, I do what I can. Say, how is Errant, anyway? Nervous about the big day?" Anhelo walked them past a portrait of an angel embracing a demon, the latter's throat slit. #emph[Redeemer and Redeemed. ] Knucklehead doesn't even bother looking. Some art dealer he was. Private tour, and he was busy preening about a wedding he wanted to ruin. If Anhelo killed him right here, it wouldn't be out of line. "Don't know. I haven't seen her," he admitted. The twinge of guilt in his voice wasn't part of the act. "But she was as happy as could be before I left in the morning. Parnesse is her whole world." Fiero took a drag from his Halo stick. He blew the smoke directly toward the oil painting. Anhelo's teeth hurt. "And she's your whole world. I'm surprised you aren't over there right now," he said. "Oh, believe me, I'd like to be there. But you know how it is. Boss's orders I look after this place," Anhelo said, the venom boiling below the surface of his charming smile. "Right this way, Fiero. Got a whole new exhibit I wanted to show you. Figured I could use your expert eye." "Whaddya got for ol' Fiero?" he asked. He walked straight through the door Anhelo held open for him. The air in this room was noticeably drier and cooler than it'd been in the main antechamber. "My specialty's in, you know, the contemporary stuff. Modernism they're calling it. You dipping your toes into the bloodbath there?" "Could say that," Anhelo said. Why did he want to make so much small talk? At least they were on the way. He gestured to the walls around them, festooned as they were with wooden panels salvaged from Old Capennan churches. Up above there were genuine eaves torn from the same, worked from oak and cherry. "Welcome to the Old Capenna exhibit." "Old Capenna? Anhelo, a guy like you, rea—What is #emph[that] ?" Even a rube like Fiero knew something special when he saw it. And it #emph[was ] something special. Standing twice as tall as Anhelo and twice as wide as Fiero, the Old Capennan Warrior's blade arm was fearsome even in death. A storm of sharp edges, a symphony of metal, Anhelo had never seen anything like it. He had no idea where Evelyn found it, either. But he knew that if he could get Fiero to stand in a particular spot, the axe it held would sever his head just as the light came through the stained glass to illuminate him. And that was a delight to work toward. "Impressive, isn't it?" Anhelo said. He now set his own hand on Fiero's shoulder and walked him to the marvel. The head of its axe alone was the size of a person curled into a ball. "Fresh shipment. I wanted your thoughts on how to pose it." Fiero, for the first time, put away his stick of Halo. "The size of that thing. I wonder what I could do with an axe like that~" "Like to get your hands on it?" Anhelo said. Closer, closer~"We can get it down. You could give it a test swing, if you wanted." Fiero looked at him like a child told he can have whatever he liked in the candy shop. "You mean that? You'd do that for me?" "For my old friend, Fiero? Anything." Anhelo grinned. His blood started to pump again, close as he was to the occasion. "Just stand right here and I'll climb up there to get it down." Fiero planted his feet right in the perfect spot. The light was at his ankles already; it was time. Anhelo whistled as he rounded the plinth. Even grunted as if he was about to start climbing. In fact, all he had to do was cut a tiny, nearly invisible wire. He didn't even need the knife to do it—snapped it with his fingernail. Turns out whoever this warrior was, the axe soldered onto their arm was still sharp. Fiero's head came clean off. Blood sprayed in a perfect arc around the statue, then landed in the grooves Anhelo had spent all morning carving. Bloody letters at the feet of the warrior spelled out his warning: #emph[death to traitors.] He allowed himself a moment to admire his work—the way the multicolored light played upon the scarlet of Fiero's blood, the contrast of his body against the smooth white marble floor. It was almost perfect. After a second to adjust the body's posture to that of a nearby icon, the image was complete. And not a moment too soon. Anhelo's watch read three. He had half an hour to make it across town. #figure(image("008_The Family Man/03.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) Driving yourself was gauche. Much like he couldn't kill Fiero the easy way last night, his brain wouldn't let him get into any old car and drive off to the wedding. If the day ever came when Anhelo had to choose between death and showing up to a party in last month's fashions, the #emph[only ] thing that might sway his mind was the thought of Errant in mourning. Even when time was of the essence, he couldn't force himself to steal a car and drive, no matter how fast it was. And, of course, he'd been so focused on Fiero dying beautifully that he hadn't thought to call for a ride. He didn't have time to wait for a Maestro-approved car—which meant, horror of horrors~ #emph[Taking a cab.] But it was fine. It was for Errant, and he still wasn't driving himself. It'd be fine. Cabbies knew their way around New Capenna better than anyone, didn't they? He stormed past his stooges at the gates and down the steps. Outside, a fleet of cars stood ready and waiting for whichever out-of-town mook wanted to pay their prices. Anhelo's eyes landed on the finest of them—driver outside wearing a double-breasted jacket, tailored to kill. His ride was slick, too—all black with polished gold accents. With this guy, it wouldn't even feel like a cab ride at all. "Grand Capenna Hall, double time," Anhelo said as he slid into the back seat. "Make it in fifteen, and I'll buy you whatever you want." "You got it, Boss, you got it," said the driver. He grinned—but there was something wrong in his eyes, something like a fire sparking to life. But the second Anhelo had that thought the locks clamped down on the doors. The hair on the back of his neck stood on end. Maybe it was the stress of the situation, but wasn't there something off here? The scent of cherries stuck to his tongue; he knew well enough the toughest industrial cleaners used cherry to hide the smell of solvent. And while the interior of the car was plush and new, it was #emph[too ] new. A cab wasn't outfitted like this. #figure(image("008_The Family Man/04.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) "Grand Capenna Hall. Big day for you, isn't it?" The driver's voice was smooth and light, yet the burn was still there in his eyes when he adjusted the rearview. "<NAME>." "Real big," Anhelo said. He didn't look away from the guy. "Look, my offer still stands. I don't care who you are. Today, of all days, if you get me where I need to go—I'll get you whatever you like." The driver pulled them out onto the street. Whatever his real goal was, he wasn't shy about having a lead foot. The city lights around them became streaks of light within minutes. Other cars swerved out of the way and honked when they couldn't. Every corner sent them listing from one side of the car to the other. Something rattled in the trunk—something that sounded glass, something that sounded expensive. "You can't get me what I want," the driver said, still smooth, still professional. Anhelo looked around for the guy's medallion. There, on the divider, he caught sight of it—a small, sketched portrait and basic information. <NAME>. What a name for a driver. Not one he'd heard before, either. He'd have remembered it. But, come to think of it, wasn't that face a little familiar, too? The nose, especially—broken once and healed off center, like a crack in concrete. "Oh, it's starting to fall into place for you, isn't it?" Antonio said. "This face of mine. You've seen it before." Anhelo closed his hand around his knife. It never rains, but it pours. "Might have. Do we have business, Antonio? Because it can wait. Today's the day of my daughter's—" "Wedding. I know," the driver said. "I know everything about you. That's how I tricked you so easily. This car, this suit. I wasn't sure it would work, but you vampires, you're all so easy to read. Your addiction to luxury is pathetic." Stolen car and stolen suit. Maybe it wasn't just a bad likeness. "Your name isn't Antonio." "No, it isn't. It's Severo. And three years ago, you killed my father on my birthday," he said, grinning the whole while. He twisted the wheel all the way to the right. Bright lights filled the cabin as they swerved into the wrong lane of traffic. "Congratulations on the big day. Hope your daughter hurts like I did." Anhelo lunged for him across the divider, but even plunging the knife into Severo's chest wasn't enough to avert what was coming. A huge Riveteer transport crashed into them like an angry rhox. Anhelo's vision went red, then white; his head knocked against the divider. The last thing he heard before his ears started to ring was Severo's maniacal laugh. But even as he danced on the edge of unconsciousness, he didn't let himself give in. Couldn't. Not today. Not with so little time to spare. And Severo had been right about one thing: Anhelo #emph[couldn't] give him what he wanted. He was going to get to that wedding. No matter if he looked like warm roadkill, no matter if the whole while his head spun like a roulette wheel, he was going to make it. By the time the car stopped moving, it was his only thought. Glass dug into his skin; a shard the size of his dagger had gone straight through his forearm. Anhelo snapped it, then tore his hand free from its pinion to Severo's shoulder. He lurched out of the car. Had he been a mortal, his stomach would've emptied—but there were perks to unlife, and freedom from vomiting was one. But it wasn't all good news. Anhelo set a hand on the wreckage of the car to steady himself, only to hear shouting coming from behind him. "That a Maestro with our merchandise?!" Anhelo let out a breath. Merchandise. The stuff in the trunk, the glass~He shambled toward the back of the car only for his fears to be confirmed. Whoever this Antonio guy had been, he'd been running Halo for the Riveteers. Riveteers who had just run him off the road, and who wanted their merchandise back. Riveteers who were closing in around him, crowbars and wrenches in hand. He could hear them even if he couldn't see them. He had fifteen minutes, #emph[maybe] , to make it to the wedding before Errant missed him. He could hardly see, his suit was ruined, he'd killed two people in one day, and every bone in his body ached, freshly broken. But as the toughs closed in around him, all he could think about was Errant's big day. He'd done the wrong thing taking this job, hadn't he? Well, he wasn't going to let his mistake ruin the wedding. Anhelo, bloodied and beaten, pulled a spare knife from his boot. "You want to dance?" he slurred. "Then let's dance!" The mooks knew an invitation when they heard one. Footsteps shuffled around him as they closed the distance. A rhox swung a piece of rebar over Anhelo's head. Preternatural reflexes were the only thing that kept him standing—he didn't see the blow coming so much as he felt the wind overhead. But dodging came with a hefty price: Anhelo couldn't recover his balance in time. He fell face first against the road. Glass dug into his cheeks; ash coated his tongue. When he rolled over, he saw the gathered Riveteers but could not make out their faces with the world spinning around him. In the blur, he saw Errant, and in the howl of the horns and engines around him, he heard her voice. #emph[You promise, right?] How many times had she asked him that? If he sat down and counted, probably more times than there were lights in this city. "I'm~I'm coming," he mumbled. He set his glass-embedded knuckles against the asphalt and forced himself up. He didn't see the knife coming for his back. But he didn't have to—because Toluz did. The knife clattered to the ground an instant before its wielder. If the crack of dozens of bones and the frantic whispers of "light's-out" did not tell him who'd come to his aid, the sudden darkness was clue enough. A cloud of black swallowed up everything in sight. Within, he heard death rattles and sternums crushed, dreams snuffed and hopes dashed. When it was all over, she was the only one left standing—with not a drop of blood on her suit. She gave him a hand. He stared at it a moment, at the blood across her palm, and considered his options. He could try and stand on his own, but~what would the Family think if they heard of this? Getting his teeth kicked in by a bunch of goons, needing Toluz to save him. The boss wouldn't take too kindly to it. "Don't let your pride get in the way of things," she said. "You're family, Anhelo." It caught him a little off guard. The waves of the world kept spinning—but her hand was a tether. "Did you follow me?" "I protect my investments," she answered. She slung his arm around her shoulder. That cane was supporting the two of them, now. Together, they headed toward the side of the road, where she had a car ready and waiting for them. "And I~had some regrets about the job." He laughed, which only made him cough up blood. "Oh? #emph[You've] got some regrets? Tell me about it." To his surprise she laughed, too. "Must sound rich coming from me, huh?" Her henchmen opened the door and helped him into the back seat of her limo. Waiting for him inside were a healer and a fella holding a new suit. Designer, even. "Hang in there, Anhelo. Anything happens to you, and Parnesse'll never let me hear the end of it." #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) The road goes fast when your head ain't on right. He couldn't keep track of any of it—his flesh knitting back together, the assistant changing him out of his messed-up clothes into his fresh new duds. As the lights swam around him, all he could do was keep checking the time. Ten minutes. Eight minutes. Five. #emph[Promise?] When they got to the Grand Capenna Hall, he'd only begun to get his bearings. But he knew, even then, that if his heart yet beat, the metronome it would follow: his daughter. The thought of Errant huddled up in the bride's chambers wondering where he was~ He threw himself out of the car without waiting for it to come to a stop. To his surprise, he saw Toluz doing the same—although she looked more collected than he did. Obscura might not have much in the way of style, but they knew how to keep it together. And, okay, maybe that cane of hers was slick. The party started the moment they cleared the entrance. All around them were gold and mother-of-pearl, feathers and silk. Obscura in staid gray wore grins and ruddy cheeks, champagne gladdening their spirits; Maestro assassins made small talk over Halo. Swing tunes put a pep in even Anhelo's tired step. Next to him, Toluz lets out a relieved sigh. "Thought your crew would've started a fight by now." "And ruin a beautiful night? Forget about it," Anhelo said. "If anyone was going to start a fight, it'd be your people." She smirked and shook her head. "Not tonight, not tonight," she said. Like him, she was scanning the crowd for her daughter. Two Obscura at the other end of the hall were already flagging her down. Toluz pulled an envelope from her jacket and offered it to him. The paper was crisp and black, sealed with black wax. "I had my doubts about this whole thing. People like us don't tend to come together easy. Too much blood on our hands. But seeing all this, and how you put yourself out there~I might have been too harsh on you. It was wrong of me to make you jump through all those hoops. Next time you need some information, it's on me." He looked down at the envelope as he'd looked on her hand. Once more, the answer sprung to him. He waved her off. "Listen, I get it. Guy like me spends too much time thinking about the job, you needed to know I cared. We can leave business for some other day." Toluz gave a considered nod. She hid the envelope away, then picked up a glass from a passing server. This she lifted toward him as she made her exit. "Congratulations, Anhelo." "You, too, Toluz," he said. He saw the stairs up to the bridal suite and wasted no time. The dames on either side offered him a little liquid courage for his troubles, but he didn't need anything like that. What he needed was to get up there in the next three minutes. Which was why one of his lackeys grabbing him by the arm wore away at the last little bit of patience he had. Even when he realized the guy was paler than the flowers flowing from the urn of a nearby caryatid. "You'd better have a good reason for this," he snapped. "Boss, we lost some guys over at the Caldaia—" Anhelo pinched his nose. "What did I just say?" "That I'd better have a good reason," the guy said. "Yeah. That wasn't one. Go find someone else to report to. Tell the Big Man you couldn't reach me if it comes down to it," Anhelo said. "Unless we got goons busting down the doors, for the next eight hours, the only family I care about is in that room. Now scram." At least he didn't have to repeat himself. The lackey left, taking the last of work's aura with him. Only the bridal suite remained. Within, he could hear Errant and her friends chattering away, the happy bubble of laughter. In that moment, it didn't matter how much he suffered to get here on time. Anhelo opened the door. There she was, his little girl, wearing her mother's wedding dress. They looked so much alike that it stopped him in his tracks, robbed him of his breath. Has he ever seen her happier than this? Surrounded by friends, radiant with joy, the air itself around her seeming to sparkle? The flowers held in her lap couldn't hope to match her. She bounded to her feet at the sight of him, leaving the flowers to her maid of honor. "Daddy! Daddy, you're here!" #figure(image("008_The Family Man/05.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) "Always, honey." He embraced her. There was a lump in his throat. The lump only got bigger when he realized her mother wouldn't ever get to see her like this. Anhelo had been there instead, when he could, but~ It didn't matter. He'd be there. For Serena, and Errant, forever was a promise. Today and all the days to come, they were the center of his world. No work of art could ever compare.
https://github.com/jneug/typst-typopts
https://raw.githubusercontent.com/jneug/typst-typopts/main/typopts.typ
typst
MIT License
#import "options.typ" #import "states.typ"
https://github.com/alberto-lazari/computer-science
https://raw.githubusercontent.com/alberto-lazari/computer-science/main/lcd/project-presentation/sections/components.typ
typst
#import "/common.typ": * #new-section-slide[Compiler components] #slide(title: [Architecture])[ - vCCS parser - CCS interface - vCCS to CCS encoder - vCCS encoding utilities ] #slide(title: [vCCS parser])[ Classic components to parse a language - Abstract syntax tree (AST) - Parser - Lexer ] #slide(title: [CCS interface])[ Basic CCS support for the encoder results - AST - Pretty printer ] #slide(title: [vCCS to CCS encoder])[ Implementation of $encode()$ Defined by structural induction on vCCS processes #pause Considerations: - Programs are the root nodes of my syntax #pause - More syntax cases than just $pi$ and $P$ to consider in practice ] #slide(title: [vCCS encoding utilities])[ Functions that solve CCS encoding sub-tasks #pause - Booleans/expressions evaluation \ $tick"out"((1 + 3) "/" 2)$ #to $tick"out"(2)$ #pause - Variable substitution \ $k(x)$ #to $k(1)$ #pause - Variable expansion \ $"in"(x). k(x)$ #to $"in"_1(x). k(1) + "in"_2(x). k(2) + ...$ ]
https://github.com/jbro/supernote-templates
https://raw.githubusercontent.com/jbro/supernote-templates/main/work-one-on-one.typ
typst
The Unlicense
#import "include/a5x-template.typ": template #show: doc => template(doc) #import "include/elements.typ": titled-box, note-lines, week-box #grid(columns: (1fr, 170pt, 136pt), column-gutter: 5pt, [ #set text(size: 20pt) #h(5pt) 1 on 1 ], [ #titled-box(title: "Name", v(16.8pt)) ], week-box() ) #titled-box(title: "Goals", note-lines(5)) #titled-box(title: "Obstacles", note-lines(5)) #titled-box(title: "Oputunities", note-lines(5)) #titled-box(title: "Decisions", note-lines(4))
https://github.com/janlauber/bachelor-thesis
https://raw.githubusercontent.com/janlauber/bachelor-thesis/main/chapters/conclusion.typ
typst
Creative Commons Zero v1.0 Universal
= Conlusion and Future Work == Summary of Contributions The development and implementation of the One-Click Deployment system has significantly advanced the efficiency and accessibility of deploying applications, particularly within Kubernetes environments. This system stands out for its integration of a straightforward user interface with the complex mechanisms of container orchestration, making advanced deployment techniques accessible to developers regardless of their Kubernetes expertise. Its ability to seamlessly manage scalability ensures that both small-scale applications and large, dynamic workloads can operate with high reliability. This project has contributed to the field by providing a deployment tool that not only simplifies the process but also enhances the deployment experience through customizable settings that cater to diverse operational needs. These settings enable strict compliance with data governance standards, which is critical for applications requiring stringent security measures and adherence to local data protection laws. == Conclusions Drawn Evaluations across various real-world applications have demonstrated that the One-Click Deployment system effectively minimizes the time and effort required for deployments. The system's robustness in managing scalable solutions underlines its potential to support a range of applications from individual academic projects to large-scale enterprise solutions. The feedback from users like <NAME>. and <NAME>. has been overwhelmingly positive, highlighting the system's ability to meet and exceed the operational requirements of diverse deployment scenarios. The system's architecture is designed to evolve, anticipating future needs and technologies. Its current integration with Kubernetes provides a strong foundation for supporting emerging technologies and deployment strategies. #pagebreak() == Recommendations for Future Work To ensure the One-Click Deployment system continues to lead and innovate in deployment solutions, future work should focus on several strategic areas: - *User Education and Engagement*: Developing comprehensive training programs and interactive tutorials that can help new users quickly understand and utilize the system effectively. - *Community Development*: Establishing a robust community around the system can facilitate the sharing of best practices, custom configurations, and support, which are invaluable for the evolution of the platform. - *Security Enhancements*: As cybersecurity threats evolve, so too should the security features of the deployment system. Investing in advanced security protocols and regular updates will be crucial to maintaining the integrity and trustworthiness of the system. == Potential Enhancements To maintain its competitive edge and adaptability, the One-Click Deployment system can explore several enhancements: - *Integration of AI and Machine Learning*: Implementing AI to analyze deployment patterns and predict potential issues before they affect the deployment could dramatically improve efficiency and uptime. - *Support for Hybrid Cloud Environments*: As businesses increasingly adopt hybrid cloud strategies, the system could expand its capabilities to manage deployments across multiple cloud environments and on-premise infrastructure seamlessly. - *Enhanced Customization for Enterprise Applications*: Developing more granular control features would allow larger organizations to fine-tune the system to their complex environments and workflows, thus broadening the system's applicability. By focusing on these recommendations and potential enhancements, the One-Click Deployment system can continue to evolve and meet the changing needs of developers and organizations in the dynamic landscape of application deployment. The system's commitment to simplicity, scalability, and reliability positions it as a key player in the future of deployment solutions.
https://github.com/GYPpro/ACM_res
https://raw.githubusercontent.com/GYPpro/ACM_res/main/2_Notes/lambdaFunc_inDFS.typ
typst
#import "@preview/tablex:0.0.6": tablex, hlinex, vlinex, colspanx, rowspanx // Display inline code in a small box // that retains the correct baseline. #set text(font:("Times New Roman","Source Han Serif SC")) #show raw.where(block: false): box.with( fill: luma(230), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, ) // #set raw(align: center) #show raw: set text( font: ("consolas", "Source Han Serif SC") ) #set page( // flipped: true, paper: "a4", // background: [#image("background.png")] ) #set text( font:("Times New Roman","Source Han Serif SC"), style:"normal", weight: "regular", size: 13pt, ) #let nxtIdx(name) = box[ #counter(name).step()#counter(name).display()] // Display block code in a larger block // with more padding. #show raw.where(block: true): block.with( fill: luma(230), inset: 7pt, radius: 4pt, ) // #set par( // first-line-indent: 1cm // ) #set math.equation(numbering: "(1)") #let titlePage(titleName,translatedTitle,Discrib) = [ #set page(footer: []) #[ #text( font:("Times New Roman","Source Han Serif SC"), style:"normal", weight:"regular", size: 22pt, )[ #align( left+horizon )[ #heading(level: 1,[#strong(titleName)]) #smallcaps(translatedTitle) #line(start: (0pt,11pt),end:(300pt,11pt)) #[ #text(Discrib,size:19pt) ] ] ] ] ] #set heading( numbering: "1.1.1." ) = Lambda表达式在DFS上的应用 Lambda表达式:形如```cpp [capture](parameters)->return_type{ ... } ``` 其中`capture`为闭包行为指定标识符: ```cpp [] // 沒有定义任何变量。使用未定义变量会引发错误。 [x, &y] // x以传值方式传入(默认),y以引用方式传入。 [&] // 任何被使用到的外部变量都隐式地以引用方式加以引用。 [=] // 任何被使用到的外部变量都隐式地以传值方式加以引用。 [&, x] // x显式地以传值方式加以引用。其余变量以引用方式加以引用。 [=, &z] // z显式地以引用方式加以引用。其余变量以传值方式加以引用。 ``` 具体的,使用: ```cpp auto dfs = [&](auto self,int x,int p) -> void { ... self(self,x,p); } ``` 两个`auto`均解释为`class lambda [](auto self, int x, int y)->void` 调用时`dfs(dfs,x,p);`
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/templates/compiler-node/examples/main.typ
typst
Apache License 2.0
= Example Document Hello World. 你好世界。 こんにちは世界。
https://github.com/liuguangxi/fractusist
https://raw.githubusercontent.com/liuguangxi/fractusist/main/tests/test-koch-curve.typ
typst
MIT License
#set document(date: none) #import "/src/lib.typ": * #set page(margin: 1cm) = n = 1 #align(center)[ #koch-curve(1, step-size: 40) ] = n = 2 #align(center)[ #koch-curve(2, step-size: 20, stroke-style: red + 2pt) ] = n = 3 #align(center)[ #koch-curve(3, step-size: 10, stroke-style: stroke(paint: gradient.linear(..color.map.crest, angle: 45deg), thickness: 4pt)) ] = n = 4 #align(center)[ #koch-curve(4, step-size: 5, stroke-style: stroke(paint: gradient.linear(..color.map.rainbow, angle: 45deg), thickness: 2pt)) ] = n = 5 #align(center)[ #koch-curve(5, step-size: 2, stroke-style: blue) ] #pagebreak(weak: true)
https://github.com/AU-Master-Thesis/thesis
https://raw.githubusercontent.com/AU-Master-Thesis/thesis/main/lib/table.typ
typst
MIT License
#import "blocks.typ": * #import "@preview/funarray:0.4.0": * #import "marker.typ" #let term-table(colors: (catppuccin.latte.lavender, ), ..rows) = { // insert a marker.arrow.single as a third column between the terms and their definitions let colors = cycle(colors, rows.pos().len()) let rows = chunks(rows.pos(), 2).enumerate().map(el => { let index = el.at(0) let term-and-def = el.at(1) let term = term-and-def.at(0) let definition = term-and-def.at(1) (term, { set line(stroke: (paint: colors.at(index))) marker.arrow.single }, definition) }).flatten() // repr(rows) v(-0.5em) table( columns: (auto, auto, 1fr), stroke: none, row-gutter: 0.25em, ..rows ) v(-0.5em) } #let tablec( title: none, columns: none, header: auto, alignment: auto, stroke: none, header-color: ( fill: catppuccin.latte.lavender, text: white ), even-color: catppuccin.latte.mantle, odd-color: catppuccin.latte.base, fill: auto, ..content ) = { let column-amount = if type(columns) == int { columns } else if type(columns) == array { columns.len() } else { 1 } let header-rows = (-1, ) if header != auto { let cells-in-header = header.children.map(it => { let internal-len = 0 if not (it.has("colspan") or it.has("rowspan")) { internal-len = 1 } else{ if it.has("rowspan") { internal-len += it.rowspan } if it.has("colspan") { internal-len += it.colspan } } internal-len }).fold(0, (acc, it) => acc + it) header-rows = range(int(cells-in-header / column-amount)) } show table.cell : it => { if it.y in header-rows { set text(header-color.text) strong(it) } else if calc.even(it.y) { set text(catppuccin.latte.text) it } else { set text(catppuccin.latte.text) it } } set align(center) set par(justify: false) set table.vline(stroke: white + 2pt) set table.hline(stroke: white + 2pt) let f = if fill == auto { (x, y) => if y in header-rows { header-color.fill } else if calc.even(y - header-rows.len()) { even-color } else { odd-color } } else { fill } let c = (header, ..content.pos()).slice(if header == auto {1} else {0}, content.pos().len() + 1) cut-block( table( columns: columns, align: alignment, stroke: stroke, fill: f, gutter: -1pt, ..c // header, // ..content ) ) }
https://github.com/rytst/convex_analysis
https://raw.githubusercontent.com/rytst/convex_analysis/main/03_convex_functions/proposition_3.6/unequivocal-ams/proposition_3.6.typ
typst
#import "@preview/unequivocal-ams:0.1.0": ams-article, theorem, proof #show: ams-article.with( title: [Convex Analysis Workshop], authors: ( ( name: "<NAME>", email: "<EMAIL>", ), ), bibliography: bibliography("refs.bib"), ) #import "@preview/ctheorems:1.1.2": * #show: thmrules.with(qed-symbol: $square$) #set heading(numbering: "1.1.") #let theorem = thmbox("theorem", "Theorem", fill: rgb("#eeffee")) #let corollary = thmplain( "corollary", "Corollary", base: "theorem", titlefmt: strong ) #let definition = thmbox("definition", "Definition", inset: (x: 1.2em, top: 1em)) #let lemma = thmbox("lemma", "Lemma", inset: (x: 1.2em, top: 1em)) #let proposition = thmbox("proposition", "Proposition", inset: (x: 1.2em, top: 1em)) #let example = thmplain("example", "Example").with(numbering: none) #let proof = thmproof("proof", "Proof") #set math.equation(numbering: "(1)") #show ref: it => { let eq = math.equation let el = it.element if el != none and el.func() == eq { // Override equation references. numbering( el.numbering, ..counter(eq).at(el.location()) ) } else { // Other references as usual. it } } = Convex functions I made this material referring to @Boyd. == Definitions #definition("Convex function")[ A function $f colon RR^n -> RR union {oo}$ is convex if $bold(op("dom")) f$ is a convex set and $ forall bold(x), bold(y) in bold(op("dom")) f, forall t in [0, 1], f(t bold(x) + (1-t) bold(y) lt.eq t f(bold(x)) + (1-t) f(bold(y))) $ where $bold(op("dom")) f$ is the effective domain of $f$: $ bold(op("dom")) f := {bold(x) | f(bold(x)) < oo}. $ ] #definition("Gradient")[ Let $f : RR^n -> RR$ be a differentiable function. The gradient of $f$ at $bold(x) in RR^n$, denoted $nabla f(bold(x))$, is an n-dimensional vector whose entries are given by $ (nabla f(bold(x)))_i := (partial f(bold(x))) / (partial x_i). $ The gradient of $f$ is the vector containing all the partial derivatives. Element i of the gradient is the partial derivative of $f$ with respect to $x_i$. ] == Lemma #lemma[ A differentiable function $f : RR -> RR union {oo}$ is convex if and only if $ f(y) gt.eq f(x) + f'(x) (y - x) $ for all $x$ and $y$ in $bold(op("dom")) f$. ] <single> #lemma[ Let $f : RR^n -> RR union {oo}, g : RR -> RR union {oo}, bold(x), bold(y) in RR^n, t in [0, 1]$ and $ g(t) = f(t bold(y) + (1-t) bold(x)). $ Then, $g$ is convex if and only if $f$ is convex. ] <fg> #proof[ $(==>)$ Let $theta in [0, 1]$. For any $t_1, t_2 in bold(op("dom")) g$, $ & space space space g(theta t_1 + (1-theta) t_2) \ &= f((theta t_1 + (1 - theta) t_2) bold(y) + (1 - (theta t_1 + (1 - theta) t_2)) bold(x)) \ &= f(theta t_1 bold(y) + (1 - theta) t_2 bold(y) + bold(x) - theta t_1 bold(x) - (1 - theta) t_2 bold(x)) \ &= f(theta t_1 bold(y) + theta bold(x) - theta t_1 bold(x) + (1 - theta) t_2 bold(y) + (1 - theta) bold(x) - (1 - theta) t_2 bold(x)) \ &= f(theta (t_1 bold(y) + (1 - t_1) bold(x)) + (1 - theta) (t_2 bold(y) + (1 - t_2) bold(x))) \ &lt.eq theta f(t_1 bold(y) + (1 - t_1) bold(x)) + (1 - theta) f(t_2 bold(y) + (1 - t_2) bold(x)) \ &= theta g(t_1) + (1 - theta) g(t_2) $ Thus, $g$ is convex. \ \ $(<==)$ Let $bold(x), bold(y) in bold(op("dom")) f$ and $t in RR$. For any $theta in [0, 1]$, $ f(theta bold(y) + (1 - theta) bold(x)) &= g(theta) \ &= g(theta dot 1 + (1- theta) dot 0) \ &lt.eq theta g(1) + (1- theta) g(0) \ &= theta f(bold(y)) + (1 - theta) f(bold(x)) $ Thus, $f$ is convex. ] == Exercise #proposition("First-order convexity condition")[ Suppose $f$ is differentiable. Then $f$ is convex if and only if $bold(op("dom")) f$ is convex and $ forall bold(x), bold(y) in bold(op("dom")) f, f(bold(y)) gt.eq f(bold(x)) + nabla f(bold(x))^(upright(T)) (bold(y) - bold(x)). $ <ineq> ] #proof[ Let $bold(x), bold(y) in RR^n, bold(z) = t bold(y) + (1-t) bold(x)$ for $t in [0, 1]$, and $ g(t) = f(t bold(y) + (1-t) bold(x)). $ Then, using chain rule, $ g'(t) &= d / (d t) f(t bold(y) + (1-t) bold(x)) \ &= d / (d t) f(bold(z)) \ &= sum_(i=1)^n d / (d t) z_i partial / (partial z_i) f(bold(z)) \ &= (partial / (partial z_1) f(bold(z)) , dots.h , partial / (partial z_n) f(bold(z))) mat( delim: "[", d / (d t) z_1; dots.v; d / (d t) z_n; ) \ &= mat( delim: "[", partial / (partial z_1) f(bold(z)); dots.v; partial / (partial z_n) f(bold(z)); )^upright(T) mat( delim: "[", d / (d t) (t y_1 + (1-t) x_1); dots.v; d / (d t) (t y_n + (1-t) x_n); ) \ &= nabla f(bold(z))^upright(T) mat( delim: "[", y_1 - x_1; dots.v; y_n - x_n; ) \ &= nabla f(t bold(y) + (1-t) bold(x))^upright(T) (bold(y) - bold(x)). $ $(==>)$ Assume $f$ is convex. From @fg, $g$ is convex. From @single, we have $ g(1) gt.eq g(0) + g'(0), $ which means that $ f(bold(y)) gt.eq f(bold(x)) + nabla f(bold(x))^upright(T) (bold(y) - bold(x)). $ $(<==)$ Assume that @ineq holds for any $bold(x), bold(y) in bold(op("dom")) f$. Let $t_1, t_2 in [0, 1]$. Since $bold(x), bold(y) in bold(op("dom")) f$, $t_1 bold(y) + (1 - t_1) bold(x) in bold(op("dom")) f$ and $t_2 bold(y) + (1 - t_2) bold(x) in bold(op("dom")) f$. From @ineq, $ & space space space f(t_1 bold(y) + (1 - t_1) bold(x)) \ &gt.eq f(t_2 bold(y) + (1 - t_2) bold(x)) \ & space space + nabla f(t_2 bold(y) + (1 - t_2) bold(x))^upright(T) (t_1 bold(y) + (1 - t_1) bold(x) - (t_2 bold(y) + (1 - t_2) bold(x))) \ &= f(t_2 bold(y) + (1 - t_2) bold(x)) \ & space space + nabla f(t_2 bold(y) + (1 - t_2) bold(x))^upright(T) ((t_1 - t_2) bold(y) + (1 - t_1 - (1 - t_2)) bold(x)) \ &= f(t_2 bold(y) + (1 - t_2) bold(x)) \ & space space + nabla f(t_2 bold(y) + (1 - t_2) bold(x))^upright(T) ((t_1 - t_2) bold(y) - (t_1 - t_2) bold(x)) \ &= f(t_2 bold(y) + (1 - t_2) bold(x)) \ & space space + nabla f(t_2 bold(y) + (1 - t_2) bold(x))^upright(T) (t_1 - t_2) (bold(y) - bold(x)). $ That is $ g(t_1) gt.eq g(t_2) + g'(t_2) (t_1 - t_2). $ From @fg, since $g$ is convex, then $f$ is convex. ]
https://github.com/RedGl0w/TypHex
https://raw.githubusercontent.com/RedGl0w/TypHex/main/sgf.typ
typst
// Basic implementation of a Smart Game Format (SGF) parser // For specification, see https://www.red-bean.com/sgf/sgf4.html // We should get rid off whitespaces : // White space (space, tab, carriage return, line feed, vertical tab and so on) may appear anywhere between PropValues, Properties, Nodes, Sequences and GameTrees. #let getPropIdent(input, position) = { let out = ""; while position < input.len() { let c = input.at(position); if c == "[" { break; } position += 1; out += c; } assert(input.at(position) == "[", message: "Unexpected end of string while getPropIdent"); return (position, out); } #let getPropValue(input, position) = { let out = ""; let escaped = false; while position < input.len() { let c = input.at(position); position += 1; if (c == "]") and (not escaped) { break; } if (c == "\\") and (not escaped) { escaped = true; continue; } escaped = false; out += c; } assert(input.at(position -1) == "]", message: "Unexpected end of string while getPropValue") return (position, out); } #let getPropValues(input, position) = { let propValues = (); while position < input.len() { let c = input.at(position); if c == "[" { let (p, r) = getPropValue(input, position+1); propValues.push(r); position = p; } else { break; } } if propValues.len() == 1 { return (position, propValues.at(0)); } return (position, propValues); } #let getProp(input, position) = { let (p, ident) = getPropIdent(input, position); position = p; let (p, values) = getPropValues(input, position); return (p, ident, values); } #let tokenize(input) = { let tokens = (); let position = 0; while position < input.len() { let c = input.at(position); if c == "(" { tokens.push((type: "startTree")); position += 1; continue; } if c == ")" { tokens.push((type: "endTree")); position += 1; continue; } if c == ";" { tokens.push((type: "newNode")); position += 1; continue; } let (p, ident, values) = getProp(input, position); position = p; tokens.push((type: "Property", ident: ident, values: values)); continue; } return tokens; } // Return (new position, node) #let parseNode(tokens, position) = { let n = (children : ()); while tokens.at(position).type == "Property" { let p = tokens.at(position); n.insert(p.ident, p.values); position += 1; } return (position, n); } #let parseTree(tokens, position) = { let tree = (); let followedNodes = (); // when tokens are ;a;b;c without another complete tree (with parentheses) between assert(tokens.at(position) == (type: "startTree"), message: "Expected tree to be parsed in parseTree"); position += 1; while tokens.at(position) == (type: "newNode") { let (p, c) = parseNode(tokens, position + 1); position = p; followedNodes.push(c); } assert(followedNodes != 1, message: "Expected a root in parseTree"); while tokens.at(position) == (type: "startTree") { let (p, c) = parseTree(tokens, position); position = p+1; followedNodes.last().children.push(c); } for c in followedNodes.rev() { c.children.push(tree); tree = c; } assert(tokens.at(position) == (type: "endTree")) return (position, tree) } #let parse(input) = { let tokens = tokenize(input); let position = 0; let (p, tree) = parseTree(tokens, 0); return tree; }
https://github.com/exdevutem/taller-git
https://raw.githubusercontent.com/exdevutem/taller-git/main/src/branches.typ
typst
= Trabajar en paralelo Durante el desarrollo de tu proyecto, es muy común que no puedas mantener una serie lineal de cambios por diversas razones. Quizás estás trabajando con mucha gente, quizás estás trabajando en un cambio muy grande, y otro cambio menor, pero más urgente, requiere que pauses este trabajo brevemente. Sea cual sea el motivo, esto puede traer diversos problemas al momento de commitear cambios a tu proyecto. El caso más común de esto se da cuando dos desarrolladores contribuyen código a la misma rama. Uno comete y empuja sus cambios antes que el otro, y cuando el último intenta hacer lo mismo recibe un error bastante feo por parte de Git diciéndole que "pullee" los cambios más recientes antes de esto (ver @alvarito) #figure( image("../assets/branches/alvarito.png"), caption: [Jovencito primer merge conflict], ) <alvarito> == Branches / Ramas La solución que Git (y múltiples otros gestores de version) han ideado es el concepto de ramas, en donde el flujo de cambios deja de ser lineal, sino que diverge en diversos puntos, y se reunifica en otros. Viendo este concepto explicado, lo más común es que encuentren diagramas como el que se ve en la @diagrama. En este diagrama, cada círculo contempla un commit, y cada color contempla una rama. En este caso, la rama principal va avanzando, y diverge primero en una pequeña rama `Little Feature`, y luego en otra rama más grande `Big Feature`. #figure( image("../assets/branches/branch.svg"), caption: [Diagrama clásico sobre las ramas de un repositorio. #link("https://www.atlassian.com/git/tutorials/using-branches")[Fuente: Atlassian.]], ) <diagrama> La ventaja de esto es que aisla el trabajo de cada desarrollador, librando de problemas como el visto en @alvarito, además de mantener una rama principal consistente y libre de código cuestionable. Puedes pensar en una rama como una forma de solicitarle al repositorio tu propia área de trabajo personal, donde no te webee nadie. Para trabajar con estas ramas, los comandos más típicos que veras son: ```bash # Listar todas las ramas $ git branch $ git branch --list # Crea una rama "test", pero no hace "checkout" $ git branch test # Borra la rama "test" $ git branch -d test # forma segura $ git branch -D test # forma forzada # Cambia el nombre de la rama actual $ git branch -m popipo # Lista las ramas del repositorio remoto $ git branch -a ``` == Checkout Estas ramas por si solas no hacen mucho si no cambias y trabajas en ellas. El acto de cambiar el commit actual sobre el que se está trabajando se llama "checkout", y el comando correspondiente puede actuar sobre tres entidades distintas; archivos, commits y ramas, y consta de cambiar la versión sobre la cual se está actuando en tal entidad. El uso más común, sin embargo, es para navegar a través de las ramas del proyecto, y normalmente cuando uno habla de "hacer checkout", se refiere a cambiar de una rama a otra, y esto le dice a git que, primero cambie todos los archivos del directorio de trabajo para que estén al cambio más actual de la rama, y que guarde todos los commits futuros hacia esta rama, lo que hace que sea muy sencillo experimentar, al igual que trabajar en dos cosas al mismo tiempo. El uso más común es: ```bash # Considerando el siguiente espacio de trabajo: $ git branch * main # La rama de trabajo actual (denotada por el *) ft/nuevo_boton # Una rama de feature (denotada por ft) fix/cookies # Una rama hotfix (denotada por fix) # Me cambio a trabajar en la rama "ft/nuevo_boton" $ git checkout ft/nuevo_boton # Creo una nueva rama, y le hago checkout $ git checkout -b ft/validaciones # A partir de HEAD (main) $ git checkout -b ft/validaciones fix/cookies # A partir de fix/cookies ```
https://github.com/PraneethJain/Science-1
https://raw.githubusercontent.com/PraneethJain/Science-1/main/Assignment-2/2022101093_Assignment_2.typ
typst
#align(center, text(17pt)[*Science-1*]) #align(center, text(16pt)[Assignment-2]) #align(center, text(13pt)[<NAME>, 2022010193]) = Question 1 == (a) For a perfect gas $ p V_m^o = R T "(ideal gas equation)" - (1) $ $ Z = V_m / V_m^o "(by definition)" $ $ Z = V_m / ((R T) / p) "(on substituing (1))" $ $ p V_m = R T Z $ Hence, proven. == (b) Case 1: $Z > 1$ at high pressure At very high pressures, the number of collisions between the gas molecules increases drastically. This causes the gas molecules to come closer to each other, due to which the repulsive forces between them drastically increase and in turn, their molar volume increases ($V_m > V_m^0$). Therefore, $Z = V_m / V_m^0 > 1$. Case 2: $Z < 1$ at intermediate pressure At intermediate pressures, the gases are far enough apart for the attractive forces to dominate over the repulsive forces. Due to this, the molar volume decreases ($V_m < V_m^0$). Therefore, $Z = V_m / V_m^0 < 1$. Case 3: $Z approx 1$ at very low pressures At very low pressures, the gas molecules so far apart that the interactions between them are negligible and there is almost no change in molar volume ($V_m = V_m^0$). In this condition, the gas acts like an ideal gas. Therefore, $Z = V_m / V_m^0 approx 1$. == (c) $ p V_m = R T (1 + B^' p + C^' p^2 + ...) $ $ Z = V_m / V_m^o $ $ Z = ((R T)/p (1 + B^' p + C^' p^2 + ...)) / ((R T) / p) $ $ Z = 1 + B^' p + C^' p^2 + ... $ $ (d Z)/(d p) = B' + 2 C^'p + ... $ $ "As" p arrow.r 0, (d Z) / (d p) arrow.r B^' "and" Z arrow.r 1 $ == (d) $20K: $ Below Boyle's temperature, at low pressure, $Z$ decreases with increase in pressure, but at high pressure, $Z$ increases with pressure. $22.64K:$ At Boyle's temperate, $Z approx 1$ for a considerable range of pressure, after which $Z$ increases with pressure. $25K: $ Above Boyle's temperature, $Z$ increases as pressure increases. However, the gas can never be liquified at this temperature. == (e) Boyle temperature is the temperature for which the second virial coefficient is zero. $ B(T) = a + b e^(-c/T^2) $ $a = -0.1993 / 10^5 "Pa"^(-1), b = 0.2002 / 10^5 "Pa"^(-1), c = 1131 K^2$ $ 0 = -0.1993 + 0.2002 e^(-1131/T^2) $ $ e^(1131/T^2) = 2002/1993 $ $ 1131/T^2 = ln(2002/1993) $ $ T = sqrt(1131 / ln(2002/1993)) $ #let T = calc.round(calc.sqrt(1131 / calc.ln(2002/1993)), digits: 4) $ T approx #T K $ The Boyle's temperature of methane is approximately #T K. == (f) Vanderwaal's equation for a mole of gas is given by $ (p + a / V^2) (V - b) = R T $ Case 1: At low pressure Since the pressure is low, the volume occupied by the gas is high, so the volume correction term $b$ is negligible. $ (p + a / V^2)V = R T $ $ p V + a / V = R T $ $ (p V) / (R T) + a / (V R T) = 1 $ $ Z + a / (V R T) = 1 $ $ Z = 1 - a / (V R T) $ Therefore, at low pressure, the compressibility factor $Z$ is less than one. Case 2: At high pressure Since the pressure is high, the pressure correction term $a$ is negligible. $ p(V - b) = R T $ $ p V - p b = R T $ $ (p V) / (R T) - (p b) / (R T) = 1 $ $ Z = 1 + (p b) / (R T) $ Therefore, at high pressure, the compressibility factor $Z$ is greater than one. = Question 2 Vanderwaal's equation for a mole of gas is given by $ (p + a / V^2) (V - b) = R T $ $ p = (R T) / (V - b) - a / V^2 $ At critical point, $(diff p) / (diff V) = 0$ $ (diff p) / (diff V) = (- R T)/(V - b)^2 + (2 a)/V^3 $ $ 0 = (- R T_c) / (V_c - b)^2 + (2 a)/V_c^3 $ $ (R T_c) / (V_c - b)^2 = (2 a)/V_c^3 $ $ T_c = (2 a (V_c - b)^2) / (R V_c^3) $ At critical point, $(diff^2 p) / (diff V^2) = 0$ $ (diff^2 p) / (diff V^2) = (2 R T) / (V - b)^3 - (6 a) / V^4 $ $ 0 = (2 R T_c) / (V_c - b)^3 - (6 a) / V_c^4 $ $ (R T_c) / (V_c - b)^3 = (3 a) / V_c^4 $ $ T_c = (3 a (V_c - b)^3) / (R V_c^4) $ $ therefore (2 a (V_c - b)^2) / (R V_c^3) = (3 a (V_c - b)^3) / (R V_c^4) $ $ 2 V_c = 3 V_c - 3 b $ $ V_c = 3 b $ $ T_c = (3 a (3b - b)^3) / (R (3b)^4) $ $ T_c = (8 a) / (27 R b) $ $ (p_c + a/V_c^2) (V_c - b) = R T_c $ $ (p_c + a/(9 b^2)) 2 b = (8 a)/(27 b) $ $ p_c = a/(27b^2) $ The critical constants are $p_c = a/(27b^2), T_c = (8 a)/(27 R b), V_c = 3b$ = Question 3 Vanderwaal's equation for a mole of gas is given by Let $X/X_c "be" X_r$ $ (p + a / V^2) (V - b) = R T $ $ (p / p_c a/(27b^2) + a/((3b)^2(V / V_c)^2))(V/V_c 3b - b) = R T/T_c (8a)/(27 R b) $ $ (p_r a/(27b^2) + a/((9b^2)V_r^2))3b(V_r - 1/3) = R T_r (8a)/(27 R b) $ $ a/b (p_r/9 + 1/(3V_r^2)) (V_r - 1/3) = R T_r (8a)/(27 R b) $ $ (p_r + 3/V_r^2) (V_r - 1/3) = 8/3 T_r $ This is the reduced form of Vanderwaal's equation.
https://github.com/jakoblistabarth/tud-corporate-design-slides-typst
https://raw.githubusercontent.com/jakoblistabarth/tud-corporate-design-slides-typst/main/lib.typ
typst
MIT No Attribution
#import "tud-slides/template.typ": *
https://github.com/liuguangxi/suiji
https://raw.githubusercontent.com/liuguangxi/suiji/main/examples/matrix-rain.typ
typst
MIT License
#set document(date: none) #import "/src/lib.typ": * #import "@preview/cetz:0.2.2" #set page(width: auto, height: auto, margin: 0pt) #cetz.canvas(length: 1pt, { import cetz.draw: * let font-size = 10 let num-col = 80 let num-row = 32 let text-len = 16 let seq = "abcdefghijklmnopqrstuvwxyz!@#$%^&*".split("").slice(1, 35).map(it => raw(it)) let rng = gen-rng(42) let num-cnt = 0 let val = 0 let chars = () rect((-10, -10), (font-size * (num-col - 1) * 0.6 + 10, font-size * (num-row - 1) + 10), fill: black) for c in range(num-col) { (rng, num-cnt) = integers(rng, low: 1, high: 3) for cnt in range(num-cnt) { (rng, val) = integers(rng, low: -10, high: num-row - 2) (rng, chars) = choice(rng, seq, size: text-len) for i in range(text-len) { let y = i + val if y >= 0 and y < num-row { let col = green.transparentize((i / text-len) * 100%) content( (c * font-size * 0.6, y * font-size), text(size: font-size * 1pt, fill:col, stroke: (text-len - i) * 0.04pt + col, chars.at(i)) ) } } } } })
https://github.com/barddust/Kuafu
https://raw.githubusercontent.com/barddust/Kuafu/main/src/Meta/build.typ
typst
#{ import "/config.typ": project project( bio: false, "夸父:元认知", "0.1", "Meta", ( "intro.typ", "resources.typ", "reading.typ", "sleep.typ", "yoga.typ", "study.typ", "exercise.typ", "feynman.typ", ) ) }
https://github.com/BeiyanYunyi/Architectural-Technology-and-Art-Paper
https://raw.githubusercontent.com/BeiyanYunyi/Architectural-Technology-and-Art-Paper/main/nju-thesis/utils/custom-tablex.typ
typst
MIT License
#import "@preview/t4t:0.3.2": is #import "@preview/tablex:0.0.6": * // 让 figure 的 kind 默认为 table,以支持 tablex 识别 #let fig(body, kind: auto, ..args) = figure( kind: if (kind != auto) { kind } else if (is.elem(image, body) or is.elem(raw, body)) { auto } else { // 让其默认为 table table }, body, ..args, ) // 三线表,包含居中,使用 tablex 实现 #let tlt(..args) = tablex( auto-lines: false, align: center + horizon, hlinex(y: 0), hlinex(y: 1), ..args, hlinex(), )
https://github.com/jomaway/typst-linguify
https://raw.githubusercontent.com/jomaway/typst-linguify/main/lib/lib.typ
typst
MIT License
#import "linguify.typ": set-database, reset-database, linguify #import "fluent.typ": load_ftl_data #import "utils.typ": if-auto-then
https://github.com/Shambuwu/stage-docs
https://raw.githubusercontent.com/Shambuwu/stage-docs/main/documenten/adviesrapport.typ
typst
#align( center, text( size: 1.2em, [ *Competentie: Adviseren* \ Adviesrapport en aanbevelingen \ ], ) ) #align( center, figure( image("../bijlagen/adviesrapport/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 rapport onderzoekt de mogelijkheden voor het ontwikkelen van een datavisualisatietool in de voedingsindustrie, waarbij Neo4j als onderliggende database wordt gebruikt. De kern van het onderzoek richt zich op het vergelijken van de prestaties tussen het gebruik van een Object Graph Mapper (OGM) en de standaard Neo4j-driver bij het uitvoeren van specifieke query's om alle nodes te verkrijgen. Uit de initiële resultaten blijkt dat er prestatieverschillen zijn tussen de twee benaderingen, maar de dataset was te beperkt om definitieve conclusies te trekken. Daarom wordt aanbevolen om verder onderzoek te doen, met name met een grotere dataset om de resultaten te valideren. Het rapport biedt drie alternatieven voor het verbeteren van de huidige situatie: - Het optimaliseren van de huidige Neo4j-setup voor betere prestaties. - Het overwegen van het gebruik van een andere database die beter past bij de vereisten. - Een herontwerp van de huidige node-architectuur om efficiënter gebruik te maken van databasebronnen. De aanbeveling is om te beginnen met het optimaliseren van de huidige Neo4j-setup, aangezien dit zowel kostenefficiënt als tijdbesparend lijkt te zijn. Echter, verder onderzoek met een uitgebreidere dataset is cruciaal voor het nemen van een weloverwogen besluit. #pagebreak() = Inleiding == Context De huidige digitale transformatie heeft geleid tot een explosieve groei van data binnen verschillende industrieën, waaronder de voedingsindustrie. Databases zijn een onmisbaar component geworden in dit landschap, met Neo4j als één van de meest populaire grafendatabases. De opkomst van grafendatabases heeft geleid tot een groeiende vraag naar datavisualisatietools die de data in deze databases kunnen visualiseren. In deze context is het project ontstaan om een datavisualisatietool te ontwikkelen voor de voedingsindustrie, gebaseerd op de Neo4j database. De tool moet in staat zijn om de data in de database te visualiseren, en de gebruiker in staat stellen om de data te manipuleren en te analyseren. De optimalisatie van databasetoegang is van groot belang, vooral als het gaat om applicaties die veel data moeten ophalen en verwerken, zoals een datavisualisatietool. Daarom is het van belang om de verschillende technologieën te onderzoeken die gebruikt kunnen worden om de tool te ontwikkelen, en de architectuur van de tool te optimaliseren om de gewenste functionaliteit te realiseren. == Onderzoek Bij dit adviesrapport hoort een onderzoeksrapport, waarin de resultaten van het onderzoek worden beschreven. Dit onderzoeksrapport is te vinden in de folder `documenten/onderzoeksrapport.pdf`. Het primaire focus van dit onderzoek is het vergelijken van de prestaties tussen een Object Graph Mapper (OGM) en de standaard Neo4j-driver bij het ophalen van alle nodes uit een Neo4j-database. Door de impact van beide methoden op de verwerkingstijden en de variabiliteit van de metingen te analyseren, biedt het onderzoek waardevolle inzichten in het optimaliseren van database-interacties voor de datavisualisatietool. De onderzoeksvraag die centraal staat in dit onderzoek is: *“Wat is het verschil in prestaties tussen het gebruik van de Object Graph Mapper (OGM) en de standaard Neo4j-driver bij het ophalen van alle nodes uit een Neo4j-database?”*. Om deze vraag te beantwoorden, is een experiment uitgevoerd waarbij de prestaties van een OGM en de standaard Neo4j-driver zijn vergeleken bij het ophalen van alle nodes uit een Neo4j-database. De resultaten van het experiment zijn geanalyseerd om de impact van beide methoden op de verwerkingstijden en de variabiliteit van de metingen te bepalen. == Randvoorwaarden Randvoorwaarden voor dit project zijn: - *Webinterface*: De tool moet een webinterface hebben, zodat het toegankelijk is voor gebruikers via een webbrowser. Er dient geen native applicatie ontwikkeld te worden. - *LCP (Largest Contentful Paint, laadtijd van de grafiek)*: Deze moet onder de 2.5 seconden blijven, om een goede gebruikerservaring te garanderen. - *INP (Input Delay, reactietijd van de pagina)*: Deze moet onder de 200ms blijven, om een goede gebruikerservaring te garanderen. == Overzicht van de structuur #box(height: 225pt, columns(2)[ #set par(justify: true) + *Samenvatting:* Dit deel biedt een beknopt overzicht van de belangrijkste punten van het rapport. + *Inleiding:* Hier wordt de context en het doel van het rapport uiteengezet, inclusief achtergrondonderzoek en randvoorwaarden. + *Onderzoek:* Dit deel beschrijft de onderzoeksopzet, resultaten en conclusies van het onderzoek. + *Conclusie:* Hier wordt een advies gegeven over de technologieën die gebruikt kunnen worden voor de ontwikkeling van de tool, en de architectuur van de tool. + *Bronnen:* Hier worden alle referenties en bronnen vermeld die zijn gebruikt tijdens het schrijven van het rapport. ] ) #pagebreak() = Onderzoek == Onderzoeksopzet Om de gestelde onderzoeksvraag te beantwoorden, is een onderzoeksopzet opgesteld. Het primaire doel was om de prestatieverschillen te meten tussen het gebruik van een Object Graph Mapper (OGM) en de standaard Neo4j-driver bij het ophalen van alle nodes uit een Neo4j-database. De metingen focusten zich op de tijd in milliseconden die nodig was om deze taak te voltooien. Er werd gebruik gemaakt van een Neo4j-database met 2349 nodes, 7678 relaties, 19998 eigenschappen en 2321 labels. De metingen werden uitgevoerd op een Debian server met een AMD Ryzen 5 3600, 16GB RAM en een 1TB SSD. == Resultaten Twee Python-scripts werden gebruikt voor de analyse. Het eerste script maakt grafieken die de tijd weergeven die nodig is om nodes op te halen, met behulp van de bibliotheek Matplotlib. Het tweede script berekent statistische parameters zoals de standaarddeviate en variantie van de metingen, met behulp van de bibliotheek Numpy. Uit de eerste bevindingen blijkt dat er een merkbaar verschil is in de tijdsduur tussen het gebruik van een OGM en de standaard Neo4j-driver. De exacte implicatie van dit verschil zal verder moeten worden geanalyseerd. == Conclusies Ondanks de waargenomen prestatieverschillen is het essentieel op te merken dat dit onderzoek een beperking kent: de omvang van de dataset. Met slechts 2349 nodes is de dataset relatief klein, en is het mogelijk dat de prestatieverschillen tussen een OGM en de standaard Neo4j-driver groter worden bij een grotere dataset. Ook is het mogelijk dat de prestatieverschillen tussen een OGM en de standaard Neo4j-driver afhankelijk zijn van de complexiteit van de queries, en standaard caching configuraties. Daarom valt er op basis van dit onderzoek geen definitie conclusie te trekken over de prestatieverschillen tussen een OGM en de standaard Neo4j-driver. Het is aan te raden om dit onderzoek te herhalen met een grotere dataset, om een definitieve conclusie te kunnen trekken. #pagebreak() = Alternatieven == Alternatief 1: Optimalisatie van de huidige setup Het eerste alternatief is om de huidige setup te optimaliseren, en uitgebreider onderzoek te doen naar de prestatieverschillen tussen een OGM en de standaard Neo4j-driver. Dit kan gedaan worden door het onderzoek te herhalen met een grotere dataset, en door de complexiteit van de queries te variëren. Er kan gekeken worden naar het wijzigen van standaardconfiguraties van de database, zoals de caching configuratie. Ook kan er gekeken worden naar het optimaliseren van queries door het gebruik van indexen, dit kan de prestaties van de database mogelijk aanzienlijk verbeteren. == Alternatief 2: Gebruik van een andere database Een ander alternatief dat overwogen kan worden, is het gebruik van een andere database dan Neo4j. Neo4j is in dit geval gekozen, omdat het een van de meest populaire grafendatabases is. Hierdoor is er veel documentatie en ondersteuning beschikbaar, wat de ontwikkeling van de tool kan versnellen. Ook is Neo4j een open-source database, wat betekent dat er geen licentiekosten aan verbonden zijn. Tenslotte is Neo4j een ACID-compliant database, wat betekent dat het voldoet aan de vier eigenschappen van een transactie: atomiciteit, consistentie, isolatie en duurzaamheid. Het prestatieverschil met andere databases is niet meegenomen in de beslissing om Neo4j te gebruiken voor dit project. Voor een vollediger beeld zou vervolgonderzoek moeten vergelijken hoe Neo4j presteert ten opzichte van andere database-opties. Tenslotte kunnen andere databases ook andere voordelen bieden, zoals specifieke functionaliteit die niet beschikbaar is in Neo4j. == Alternatief 3: Wijziging van node architectuur Een ander alternatief dat overwogen kan worden, is het wijzigen van de architectuur van de nodes. In de huidige setup zijn de nodes allemaal van hetzelfde type, en bevatten ze allemaal dezelfde eigenschappen. Het is mogelijk dat het wijzigen van de architectuur van de nodes de prestaties van de database kan verbeteren. == Benodigdheden Voor het implementeren van deze alternatieven zijn de volgende benodigdheden nodig: - *Tijd:* Het uitvoeren van het onderzoek en het implementeren van de alternatieven kost tijd. Het is belangrijk om deze tijd in te plannen, en te zorgen dat er voldoende tijd beschikbaar is om de alternatieven te implementeren. - *Kennis:* Het implementeren van de alternatieven vereist kennis van de verschillende technologieën die gebruikt worden. Het is belangrijk om te zorgen dat er voldoende kennis beschikbaar is om de alternatieven te implementeren. - *Geld:* Het implementeren van de alternatieven kan kosten met zich meebrengen, bijvoorbeeld voor het aanschaffen van licenties voor andere databases. Het is belangrijk om deze kosten in kaart te brengen, en te zorgen dat er voldoende budget beschikbaar is om de alternatieven te implementeren. == Voor- en nadelen De voor- en nadelen van de alternatieven zijn als volgt: - *Alternatief 1:* Het voordeel van dit alternatief is dat het optimaliseren van de huidige setup minder tijd en geld kost dan het implementeren van een ander alternatief. Het nadeel is dat het optimaliseren van de huidige setup mogelijk niet voldoende is om de gewenste prestaties te behalen. - *Alternatief 2:* Het voordeel van dit alternatief is dat het gebruik van een andere database mogelijk betere prestaties kan bieden dan Neo4j. Het nadeel is dat het implementeren van een andere database meer tijd en geld kost dan het optimaliseren van de huidige setup. - *Alternatief 3:* Het voordeel van dit alternatief is dat het wijzigen van de architectuur van de nodes mogelijk betere prestaties kan bieden dan de huidige architectuur. Het nadeel is dat het wijzigen van de architectuur van de nodes meer tijd kost dan het optimaliseren van de huidige setup. #pagebreak() = Conclusie == Advies Mijn eerste advies is om te beginnen met het optimaliseren van de huidige Neo4j-setup, zoals aangegeven in Alternatief 1. Dit lijkt de meest efficiënte en kostenbesparende optie op korte termijn. Daarnaast is het zinvol om verder onderzoek te doen naar de prestatieverschillen tussen een OGM en de standaard Neo4j-driver. Voor een langetermijnstrategie zou ik echter aanraden om Alternatief 2 niet volledig van tafel te vegen. Als de optimalisaties in Alternatief 1 onvoldoende blijken, zou het zinvol kunnen zijn om de prestaties van Neo4j te vergelijken met andere databases. == Onderbouwing Het kiezen voor een optimalisatie van de huidige setup is gebaseerd op de resultaten van het voorlopige onderzoek, die duidelijk een verschil in prestatie tonen tussen de gebruikte methodes. Echter, het onderzoek is niet uitputtend en de dataset is relatief klein, dus het is een voorzichtige eerste stap. Daarnaast biedt Neo4j verschillende voordelen zoals ACID-compliance en een rijke set aan documentatie, wat de leercurve en implementatietijd kan verkorten. Het overstappen naar een andere database zou deze voordelen kunnen wegnemen, en mogelijk nieuwe problemen introduceren. == Actieplan Een eerste actiepunt is het optimaliseren van de huidige Neo4j-configuratie. Dit omvat het fine-tunen van queries en eventueel aanpassen van database-instellingen. Deze aanpassingen zijn relatief snel door te voeren en vereisen geen drastische wijzigingen in de huidige setup. Vervolgens, plan voor het uitvoeren van een vervolgonderzoek met een grotere dataset. Hierbij kan ook de complexiteit van de queries worden gevarieerd om een meer genuanceerd beeld te krijgen van de prestatieverschillen. Op basis van deze resultaten kan dan een gefundeerde beslissing gemaakt worden over het al dan niet switchen van database. Tenslotte is het ook van belang om andere alternatieve te overwegen, als deze zich voordoen. Het is mogelijk dat er andere alternatieven zijn die niet zijn meegenomen in dit adviesrapport, maar die wel een betere oplossing bieden voor het probleem. #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-3, OpenAI], [bijlagen -> realisatierapport -> OIG.jpg], [Symfony Server Source Code], [<NAME>], [https://github.com/Shambuwu/neo4j-symfony-app] ) )
https://github.com/maxgraw/bachelor
https://raw.githubusercontent.com/maxgraw/bachelor/main/apps/document/src/4-concept/architecture.typ
typst
Im folgenden Kapitel wird die Struktur der Anwendung definiert, welche auf Grundlage der Zielgruppen- und Anforderungsanalyse entwickelt wurde. Hierbei wird zunächst eine theoretische Grundstruktur der Anwendung definiert, welche auf Grundlage der zuvor gesammelten Informationen definiert wird. === Hardware Zunächst kann die Anwendung in ihre Hardware-Komponenten aufgeteilt werden. Wie in der Zielgruppenanalyse beschrieben, handelt es sich bei der Primärgruppe um Endnutzer, welche die Software zur Planung und Visualisierung von Möbeln einsetzen möchten. Aus dieser Analyse ergeben sich direkte Anforderungen an die Hardware. Die Verwendung von spezialisierter Hardware kann zwar Vorteile in Bezug auf die Performance und Interaktion bieten, jedoch ist die Nutzerbasis deutlich geringer als bei Smartphones und Tablets. Hierbei kann die Nutzerbasis als ausschlaggebender Faktor für die Auswahl der Hardware betrachtet werden. Smartphones und Tablets bieten eine breite Nutzerbasis und sind bereits im Besitz der Zielgruppe. === Software Im nächsten Schritt wird die Software-Komponente der Anwendung definiert. Wie in der Zielgruppen- und Anforderungsanalyse beschrieben, soll die Anwendung in bereits bestehende Systeme integriert werden. Die Anwendung sollte daher nicht als eigenständige Software entwickelt werden, sondern als Modul, das in bestehende Systeme integriert werden kann. In @web-components-chapter wurde die Verwendung von Web Components vorgestellt. Hierbei handelt es sich um eine Reihe an Web-API, die es ermöglichen, abgekapselte und wiederverwendbare Komponenten in Webdokumenten und Webanwendungen zu erstellen. Diese Technologie erfüllt somit die gestellten Anforderungen an die Anwendung. Es handelt sich um einen etablierten Webstandard, der ohne externe Abhängigkeiten genutzt werden kann. Dieser Punkt ist von Bedeutung, da die Verwendung von externen Frameworks, z. B. für User Interfaces, zwar Vorteile in Bezug auf die Entwicklungsgeschwindigkeit bietet, jedoch auch Nachteile darstellt. Dazu gehört die Abhängigkeit von externen Bibliotheken und die Notwendigkeit, auf die Weiterentwicklung des Frameworks zu vertrauen. Zudem müssen zur Erweiterung und Wartung der Anwendung Entwickler mit spezifischen Kenntnissen aller Frameworks ausgestattet sein oder diese Kenntnisse erwerben. === Import/Export Das Import- und Exportmodul ist ein zentrales Element der Anwendung, da es die Schnittstelle zu bestehenden Systemen bildet. Zunächst muss festgelegt werden, welche Daten importiert und exportiert werden sollen. Importiert werden Möbelstücke mit Metadaten, wie interne IDs und Namen aus dem Shopsystem. Exportiert werden die vom Nutzer erstellten Daten, insbesondere Auswahl und Anzahl der Möbelstücke. 3D-Modelle der Möbelstücke können in verschiedenen Formaten vorliegen. In dieser Arbeit wird der Open Source glTF-Standard verwendet, der mehrere für die Anwendung relevante Vorteile bietet. Das Format glTF wird von vielen 3D-Modellierungsprogrammen unterstützt, was die Integration in bestehende Systeme erleichtert. Zudem ist der Standard auf die Echtzeitdarstellung optimiert, was insbesondere für die Nutzung auf Smartphones und Tablets von Bedeutung ist. Dies ermöglicht eine hohe Performance bei der Darstellung der 3D-Modelle. Darüber hinaus können Materialien und Texturen direkt in glTF-Dateien gespeichert werden, was den Importprozess vereinfacht @gltf-format. Die zuvor erwähnten Metadaten der Möbelstücke könnten theoretisch direkt im glTF-Format gespeichert werden. Dies würde jedoch den direkten Zugriff auf das 3D-Modell zum Erstellen, Bearbeiten und Auslesen der Metadaten erfordern. Dadurch würde die Wartbarkeit und Erweiterbarkeit der Anwendung erschwert. Daher sollten die Metadaten in einem separaten Format importiert werden. Web Components bieten verschiedene Ansätze für den Datenimport. Eine Möglichkeit besteht darin, Daten über externe APIs zu laden. Alternativ können die Daten als Attribute an die Web Component übergeben werden. Diese Methode ermöglicht es, die Daten direkt im HTML-Code zu definieren, wodurch die Notwendigkeit entfällt, neue API-Endpunkte für die Datenbereitstellung zu erstellen, was die Integration in bestehende Systeme erleichtert. #let code = ```html <component data="[box.gltf, apple.gltf]"></component> ``` #figure( code, caption: [Beispiel für den Import von Daten über Attribute] ) Das Importieren von Daten über Attribute kann durch die Verwendung von verschachtelten Web Components weiter verbessert werden. Wie zuvor festgestellt, sollten Metadaten getrennt von den 3D-Modellen importiert werden. Durch die Verschachtelung können Metadaten separat, aber in Bezug auf das jeweilige 3D-Modell definiert werden. Diese Methode ermöglicht eine klarere Strukturierung und verbessert die Wartbarkeit des Codes, da sie sich an den gängigen Strukturen von HTML-Elementen orientiert. #let code = ```html <component> <component-option data="box.gltf" shopId="1"></component-option> <component-option data="apple.gltf" shopId="2"></component-option> </component> ``` #figure( code, caption: [Beispiel für den Import von Daten über verschachtelte Web Components] ) Web Components bieten die Möglichkeit, Daten durch die Nutzung von Events zu exportieren. Diese Events ermöglichen die Kommunikation mit anderen Systemen oder Komponenten und können durch Benutzerinteraktionen ausgelöst werden. Es kann grundlegend zwischen externen und internen Events unterschieden werden. Bei externen Events überwacht das externe System die Anwendung und führt die Logik des Datenexports aus. Im Gegensatz dazu wird bei internen Events die Exportlogik innerhalb der Anwendung ausgeführt. Da die Anforderungen an die Schnittstelle je nach externem System variieren können, ist es notwendig, dass die Anwendung flexible und beide Methoden des Datenexports bereitstellt. === Darstellung Für die Darstellung der Augmented Reality-Anwendung wird WebXR verwendet. Im @webxr-frameworks-chapter wurden verschiedene Frameworks untersucht, die die Arbeit mit WebXR erleichtern. Für diese Arbeit wurde Three.js ausgewählt. Three.js ist ein etabliertes Framework, das hinsichtlich Downloadzahlen und Community die höchste Relevanz besitzt @frameworks-stars @frameworks-download. Im Vergleich zu Babylon.js bietet Three.js eine schlankere API, die eine bessere Anpassung an die spezifischen Anforderungen der Anwendung ermöglicht. Babylon.js verfügt über viele vorgefertigte Funktionen, die jedoch für diese Anwendung keine relevanz besitzen. Ein weiteres Framework, A-Frame, ermöglicht die deklarative Erstellung von AR-Szenen über HTML-Tags und baut dabei auf Three.js auf. Diese Abstraktionsebene ist jedoch für die vorliegende Anwendung nicht notwendig und kann direkt in Three.js erreicht werden. Wie bereits im @webxr-frameworks-chapter über WebXR-Frameworks beschrieben, bietet Three.js eine umfangreiche Unterstützung für die Entwicklung von 3D- und WebXR-Anwendungen. Das Framework ermöglicht die Erstellung und Verwaltung von komplexen 3D-Szenen und -Logiken und bietet die Möglichkeit, mit WebXR-APIs zu interagieren. === Interface Das Interface der Anwendung basiert auf den zuvor definierten Kapiteln der Darstellung und bildet die Grundlage für die Interaktion. Augmented Reality stellt grundsätzlich besondere Herausforderungen an die Entwicklung von Interfaces. Durch die frei bewegliche Ansicht können Informationen, die im Raum platziert sind, übersehen oder nicht aufgenommen werden. Diese Problematik wird durch die begrenzte Ansicht eines Smartphones noch verstärkt. Aus diesem Grund sollte beim Design des Interfaces darauf geachtet werden, dass wichtige Informationen unabhängig von der Kameraposition und -drehung sichtbar sind. Hierbei bietet es sich an, die Informationen in Bezug auf Position und Drehung mit der Kameraposition zu verbinden, um eine durchgehend sichtbare Darstellung zu gewährleisten. === Interaktion Die Interaktion mit der Anwendung beschreibt die Schnittstelle zwischen Endbenutzer und Anwendung. Augmented Reality bietet grundsätzlich eine Vielzahl von Interaktionsmöglichkeiten. Durch die Fokussierung auf Smartphones und Tablets als Hardware sowie die Verwendung von WebXR als Technologie wird die Anzahl der Interaktionsmöglichkeiten jedoch eingeschränkt. Diese Einschränkung muss nicht als Nachteil angesehen werden, da die Verwendung von Smartphones die Interaktion über den Touchscreen ermöglicht. Hierbei kann durch Tippen auf den Bildschirm die jeweilige Interaktion ausgelöst werden. Dadurch kann auf bereits bekannte Interaktionsmuster zurückgegriffen werden, was die Benutzererfahrung der Anwendung verbessert. Zusätzlich kann auch die Kamera des Smartphones als Interaktionsmöglichkeit genutzt werden. Durch die Verwendung der Kamera sowie die Erfassung von Position und Drehung des Geräts kann die Position der Möbelstücke bestimmt werden. Die Interaktion bzw. die Struktur dieser wird im Folgenden Abschnitt genauer erläutert. Hierbei wird ein User-Flow erstellt, um die Interaktion und Abläufe der Anwendung zu visualisieren.
https://github.com/wjakethompson/wjt-quarto-ext
https://raw.githubusercontent.com/wjakethompson/wjt-quarto-ext/main/ku-letter/_extensions/ku-letter/typst-template.typ
typst
Creative Commons Zero v1.0 Universal
// This function gets your whole document as its `body` // and formats it as a simple letter. #let letter( // The subject line. subject: none, // The letter's recipient, which is displayed close to the top. recipient: none, // The letter's sender, which is display at the top of the page. sender: none, // The logo for the header header-logo: none, // The logo for the footer footer-logo: none, // The date, displayed to the right. date: none, // The letter's content. body ) = { // Configure page and text properties. show link: underline show link: set text(blue) set text(font: "Calibri", 12pt) set page( paper: "us-letter", margin: (top: 1in, right: 1in, bottom: 1.5in, left: 1in), header-ascent: 10%, footer-descent: 30% ) set page(header: locate(loc => { if counter(page).at(loc).first() <= 1 [ #style(styles => { if header-logo == none { return } let img = image(header-logo, width: 4in) let img-size = measure(img, styles) grid( columns: (img-size.width, 1fr), rows: 1, pad(left: -0.5in, img), none ) }) ] })) set page(footer: locate(loc => { if counter(page).at(loc).first() <= 1 [ #style(styles => { if footer-logo == none { return } let img = image(footer-logo, width: 1.1in) let img-size = measure(img, styles) let linkedin-logo = image("linkedin.svg", width: 0.4cm) let x-logo = image("x.svg", width: 0.4cm) let linkedin-size = measure(linkedin-logo, styles) let x-size = measure(x-logo, styles) pad(top: -0.22in, left: -0.5in, line( start: (0in, 0in), length: 7.5in, stroke: (paint: rgb("#002060")) )) grid( columns: (1fr, img-size.width), rows: 1, pad(left: -0.5in, [ 431 <NAME>, Lawrence, KS 66045-7575 \ #link("https://atlas.ku.edu")[atlas.ku.edu] | (785) 864-7093 | #link("mailto:<EMAIL>") \ #pad(top: -6pt, grid( columns: (linkedin-size.width, x-size.width, 1fr), column-gutter: 10pt, rows: 1, linkedin-logo, x-logo, [\@atlas4learning] )) ]), none ) }) ] else [ #style(styles => { if footer-logo == none { return } let img = image(footer-logo, width: 1.1in) let img-size = measure(img, styles) let linkedin-logo = image("linkedin.svg", width: 0.4cm) let x-logo = image("x.svg", width: 0.4cm) let linkedin-size = measure(linkedin-logo, styles) let x-size = measure(x-logo, styles) pad(top: -0.22in, left: -0.5in, line( start: (0in, 0in), length: 7.5in, stroke: (paint: rgb("#002060")) )) grid( columns: (1fr, img-size.width), rows: 1, pad(left: -0.5in, [ 431 <NAME>, Lawrence, KS 66045-7575 \ #link("https://atlas.ku.edu")[atlas.ku.edu] | (785) 864-7093 | #link("mailto:<EMAIL>") \ #pad(top: -6pt, grid( columns: (linkedin-size.width, x-size.width, 1fr), column-gutter: 10pt, rows: 1, linkedin-logo, x-logo, [\@atlas4learning] )) ]), pad(top: -0.1in, left: 0.5in, img) ) }) ] })) // Display date. If there's no date add some hidden // text to keep the same spacing. align(left, if date != none { date } else { hide("a") }) v(0.5em) // Display recipient. recipient v(0.5em) // Add the subject line, if any. text( [ #if subject == none {none} else [Re: ] #if subject == none {none} else {subject} ] ) v(0.5em) // Add body and name. body v(1.25cm) sender }
https://github.com/ilsubyeega/circuits-dalaby
https://raw.githubusercontent.com/ilsubyeega/circuits-dalaby/master/Type%201/2/13.typ
typst
#set enum(numbering: "(a)") #import "@preview/cetz:0.2.2": * #import "../common.typ": answer 2.13 $I_0 = 0$으로 주어졌을 때, 다음 회로에서 전류 $I$를 구하라. #answer[ $I_0 = 0$이기에, $I_0$이 연결된 가운데 엣지는 실제로 작동하지 않는다. 따라서 각 두 엣지(2개의 1옴 직렬로 이루어진 = 2옴)의 병렬 연결임으로, $R = 3 + (2*2 / 4) = 4 ohm$. $therefore I = V/R = 24 / 4 = 6 A$ ]
https://github.com/Gekkio/gb-ctr
https://raw.githubusercontent.com/Gekkio/gb-ctr/main/chapter/cartridges/mbc2.typ
typst
Creative Commons Attribution Share Alike 4.0 International
#import "../../common.typ": * == MBC2 mapper chip MBC2 supports ROM sizes up to 2 Mbit (16 banks of #hex("4000") bytes) and includes an internal 512x4 bit RAM array, which is its unique feature. The information in this section is based on my MBC2 research, Tauwasser's research notes @tauwasser_mbc2, and Pan Docs @pandocs. #speculation[ MBC1 is strictly more powerful than MBC2 because it supports more ROM and RAM. This raises a very important question: why does MBC2 exist? It's possible that Nintendo tried to integrate a small amount of RAM on the MBC chip for cost reasons, but it seems that this didn't work out very well since all later MBCs revert this design decision and use separate RAM chips. ] === MBC2 registers #caveat[ These registers don't have any standard names and are usually referred to using one of their addresses or purposes instead. This document uses names to clarify which register is meant when referring to one. ] The MBC2 chip includes two registers that affect the behaviour of the chip. The registers are mapped a bit differently compared to other MBCs. Both registers are accessible within #hex-range("0000", "3FFF"), and within that range, the register is chosen based on the A8 address signal. In practice, this means that the registers are mapped to memory in an alternating pattern. For example, #hex("0000"), #hex("2000") and #hex("3000") are RAMG, and #hex("0100"), #hex("2100") and #hex("3100") are ROMB. Both registers are smaller than 8 bits, and unused bits are simply ignored during writes. The registers are not directly readable. #reg-figure( caption: [#hex-range("0000", "3FFF") when A8=#bin("0") - RAMG - MBC2 RAM gate register] )[ #reg-table( [U], [U], [U], [U], [W-0], [W-0], [W-0], [W-0], unimpl-bit(), unimpl-bit(), unimpl-bit(), unimpl-bit(), table.cell(colspan: 4)[RAMG\<3:0\>], [bit 7], [6], [5], [4], [3], [2], [1], [bit 0] ) #set align(left) #grid( columns: (auto, 1fr), gutter: 1em, [*bit 7-4*], [*Unimplemented*: Ignored during writes], [*bit 3-0*], [ *RAMG\<3:0\>*: RAM gate register\ #bin("1010") = enable access to chip RAM\ All other values disable access to chip RAM ] ) ] The 4-bit MBC2 RAMG register works in a similar manner as MBC1 RAMG, so the upper bits don't matter and only the bit pattern #bin("1010") enables access to RAM. When RAM access is disabled, all writes to the external RAM area #hex-range("A000", "BFFF") are ignored, and reads return undefined values. Pan Docs recommends disabling RAM when it's not being accessed to protect the contents @pandocs. #speculation[ We don't know the physical implementation of RAMG, but it's certainly possible that the #bin("1010") bit pattern check is done at write time and the register actually consists of just a single bit. ] #reg-figure( caption: [#hex-range("0000", "3FFF") when A8=#bin("1") - ROMB - MBC2 ROM bank register] )[ #reg-table( [U], [U], [U], [U], [W-0], [W-0], [W-0], [W-1], unimpl-bit(), unimpl-bit(), unimpl-bit(), unimpl-bit(), table.cell(colspan: 4)[ROMB\<3:0\>], [bit 7], [6], [5], [4], [3], [2], [1], [bit 0] ) #set align(left) #grid( columns: (auto, 1fr), gutter: 1em, [*bit 3-0*], [ *ROMB\<3:0\>*: ROM bank register\ Never contains the value #bin("0000").\ If #bin("0000") is written, the resulting value will be #bin("0001") instead. ] ) ] The 4-bit ROMB register is used as the ROM bank number when the CPU accesses the #hex-range("4000", "7FFF") memory area. Like MBC1 BANK1, the MBC2 ROMB register doesn't allow zero (bit pattern #bin("0000")) in the register, so any attempt to write #bin("0000") writes #bin("0001") instead. === ROM in the #hex-range("0000", "7FFF") area In MBC2 cartridges, the A0-A13 cartridge bus signals are connected directly to the corresponding ROM pins, and the remaining ROM pins (A14-A17) are controlled by the MBC2. These remaining pins form the ROM bank number. When the #hex-range("0000", "3FFF") address range is accessed, the effective bank number is always 0. When the #hex-range("4000", "7FFF") address range is accessed, the effective bank number is the current ROMB register value. #figure( table( columns: 3, stroke: (y: none), align: center, table.hline(), [], table.cell(colspan: 2)[ROM address bits], [Accessed address], [Bank number], [Address within bank], table.hline(), [], [17-14], [13-0], table.hline(), hex-range("0000", "3FFF"), bin("0000"), [A\<13:0\>], table.hline(), hex-range("4000", "7FFF"), [ROMB], [A\<13:0\>], table.hline(), ), kind: table, caption: "Mapping of physical ROM address bits in MBC2 carts" ) === RAM in the #hex-range("A000", "BFFF") area All MBC2 carts include SRAM, because it is located directly inside the MBC2 chip. These cartridges never use a separate RAM chip, but battery backup circuitry and a battery are optional. If RAM is not enabled with the RAMG register, all reads return undefined values and writes have no effect. MBC2 RAM is only 4-bit RAM, so the upper 4 bits of data do not physically exist in the chip. When writing to it, the upper 4 bits are ignored. When reading from it, the upper 4 data signals are not driven by the chip, so their content is undefined and should not be relied on. MBC2 RAM consists of 512 addresses, so only A0-A8 matter when accessing the RAM region. There is no banking, and the #hex-range("A000", "BFFF") area is larger than the RAM, so the addresses wrap around. For example, accessing #hex("A000") is the same as accessing #hex("A200"), so it is possible to write to the former address and later read the written data using the latter address. #figure( table( columns: 2, stroke: (y: none), align: center + bottom, table.hline(), [], [RAM address bits], [Accessed address], [], table.hline(), [], [8-0], table.hline(), hex-range("A000", "BFFF"), [A\<8:0\>], table.hline(), ), kind: table, caption: "Mapping of physical RAM address bits in MBC2 carts" ) === Dumping MBC2 carts MBC2 cartridges are very simple to dump. The total number of banks is read from the header, and each bank is read one byte at a time. ROMB zero adjustment must be considered in the ROM dumping code, but this only means that bank 0 should be read from #hex-range("0000", "3FFF") and not from #hex-range("4000", "7FFF") like other banks. #figure( raw(read("../../code-snippets/mbc2_rom_dump.py"), lang: "python", block: true), caption: "Python pseudo-code for MBC2 ROM dumping" )
https://github.com/binhtran432k/ungrammar-docs
https://raw.githubusercontent.com/binhtran432k/ungrammar-docs/main/contents/system-implementation/lezer.typ
typst
#import "/components/glossary.typ": gls === Ungrammar Lezer <subsec-impl-lezer> The Ungrammar Lezer Parser serves as the fundamental component responsible for analyzing and understanding Ungrammar code. Leveraging the powerful Lezer (@sec-lezer) parser generator and runtime, this essential tool transforms raw Ungrammar text into a well-structured #gls("cst", mode:"full"). ==== Why Lezer? When developing an LSP ecosystem that requires frequent code analysis during editing, a high-performance parser is essential. Lezer, with its reputation for efficiency and robustness, was the ideal choice for our project. Key Reasons for Choosing Lezer: - *Performance*: Lezer's efficient parsing capabilities are crucial for handling the frequent analysis required in an LSP environment. - *Error Tolerance*: Lezer's built-in error tolerance allows us to estimate the number of errors in the code without halting the analysis process, enabling focused error correction. - *Incremental Parsing*: Lezer's incremental parsing capabilities minimize the overhead of re-parsing large portions of code when changes are made, improving responsiveness. - *CodeMirror Integration*: Lezer's integration with CodeMirror, a widely used code editor, simplifies the development process and ensures compatibility with a popular editor choice. By selecting Lezer as our parser, we have laid a strong foundation for the Ungrammar LSP ecosystem, ensuring efficient performance, robust error handling, and seamless integration with code editors. ==== Creating the Ungrammar Lezer Parser To establish a robust foundation for our #gls("lsp") ecosystem, we developed a powerful Lezer-based parser specifically tailored for the Ungrammar language. This parser, generated using the Lezer parser generator, plays a critical role in analyzing Ungrammar code and constructing its syntax tree. #[ #show figure: set block(breakable: true) #set raw(block: true) #figure( raw(read("/assets/ungrammar.grammar")), caption: [Lezer code to generate the Ungrammar Parser], ) <fig-grammar> ] #[ #show figure: set block(breakable: true, clip: true) #set raw(block: true) #figure( raw(read("/assets/parser.js"), lang: "js"), caption: [Generated Parser from @fig-grammar], ) ] ==== Deployment to NPM Upon completion of development, we successfully deployed the Ungrammar Lezer parser to the NPM registry. This strategic move allows other developers to easily discover, integrate, and extend our project for their own language-related endeavors. By making the parser readily available on NPM, we've expanded the accessibility and potential impact of our work within the developer community. Here is our deployed Ungrammar Lezer parser, which has been downloaded by 198 users since its public release and is currently hosted at #link("https://www.npmjs.com/package/ungrammar-lezer"). #figure( image("/assets/lezer.jpg", width: 90%), caption: [Deployed Ungrammar Lezer on NPM], )
https://github.com/maucejo/cnam_templates
https://raw.githubusercontent.com/maucejo/cnam_templates/main/template/main_reunion.typ
typst
MIT License
#import "../src/cnam-templates.typ": * // #show: cnam-reunion.with( // // composante: "lmssc", // type: "pv", // titre: [Conseil de perfectionnement de la LP CAPPI], // date: [01 janvier 2025], // lieu: "Salle des conseils", // redacteur: "<NAME>", // toc: true // ) // = Point 1 // #lorem(50) // = Point 2 // #lorem(50) #show: cnam-reunion.with( // composante: "lmssc", type: "odj", titre: [Conseil de perfectionnement de la LP CAPPI], date: [01 janvier 2025], ) + #lorem(10) + #lorem(10)
https://github.com/crd2333/template-report
https://raw.githubusercontent.com/crd2333/template-report/master/covers.typ
typst
MIT License
#import "fonts.typ": 字体, 字号 #import "utils.typ": date_format #let _info_key(body) = { rect(width: 100%, inset: 2pt, stroke: none, text( font: 字体.宋体, size: 字号.三号, body ) ) } #let _info_value(body) = { rect( width: 120%, inset: 3pt, stroke: ( bottom: 1pt + black ), text( font: 字体.宋体, size: 字号.三号, bottom-edge: "descender" )[#body] ) } #let cover_normal( title: "Title", author: "author", date: (2023, 5, 14), lang: "en", show_name: true, ..args ) = { let author = if show_name {author} else {none}; align(center)[ #image("assets/校名.jpg", width: 60%) #v(4em) #image("assets/校徽.jpg", width: 70%) #set par(leading: 1.5em) #v(3.5em) #text(title, font: 字体.宋体, size: 字号.小一, weight: "bold") #v(1em) #text(author, font: 字体.宋体, size: 字号.三号) #v(0.5em) #date_format(date: date, lang: lang) ] } #let cover_report( title: "", title_2: "", author: "", class: "", grade: "", department: "", date: (2023, 04, 17), id: "", lang: "en", mailbox: "", major: "", mentor: "", type: 1, ..args ) = { date = date_format(date: date, lang: lang, size: 字号.三号) align(center + horizon)[ #image("assets/校名.jpg", width: 40%) #image("assets/校徽.jpg", width: 60%) #text(title, font: 字体.宋体, size: 字号.小一, weight: "bold") #v(0.5em) #if (lang == "en") { let title = (_info_key("Project Name"), _info_value(title_2)) let author = (_info_key("<NAME>"), _info_value(author)) let id = (_info_key("Student ID"), _info_value(id)) let class = (_info_key("Class"), _info_value(class)) let major = (_info_key("Major"), _info_value(major)) let department = (_info_key("Department"), _info_value(department)) let date = (_info_key("Date"), _info_value(date)) let mailbox = (_info_key("Mailbox"), _info_value(mailbox)) let mentor = (_info_key("Mentor"), _info_value(mentor)) let info_show = if type == "1" { (title + author + id + class + department + date) } else if type == "2" { (title + author + department + major + mailbox + date) } else if type == "3" { (title + author + id + mailbox + mentor + date) } grid( columns: (160pt, 180pt), rows: (40pt, 40pt), gutter: 3pt, ..info_show ) } else { let title = (_info_key("实验题目"), _info_value(title_2)) let author = (_info_key("学生姓名"), _info_value(author)) let id = (_info_key("学  号"), _info_value(id)) let class = (_info_key("班  级"), _info_value(class)) let major = (_info_key("专  业"), _info_value(major)) let department = (_info_key("所在学院"), _info_value(department)) let date = (_info_key("提交日期"), _info_value(date)) let mailbox = (_info_key("邮  箱"), _info_value(mailbox)) let mentor = (_info_key("指导教师"), _info_value(mentor)) let info_show = if type == "1" { (title + author + id + class + department + date) } else if type == "2" { (title + author + department + major + mailbox + date) } else if type == "3" { (title + author + id + mailbox + mentor + date) } grid( columns: (120pt, 180pt), rows: (40pt, 40pt), gutter: 3pt, ..info_show ) } ] pagebreak() } #let cover_anonymous_report( title: "", title_2: "", title_3: "", author: "", date: (2023, 5, 14), lang: "en", ..args ) = { align(center + horizon)[ #image("assets/校名.jpg", width: 60%) #v(5em) #image("assets/校徽.jpg", width: 70%) #v(3em) #text(title, font: 字体.宋体, size: 字号.小一, weight: "bold") #v(1em) #text(title_2, font: 字体.宋体, size: 字号.小二 + 2pt) #v(0.5em) #text(title_3, font: 字体.宋体, size: 字号.小二,) #v(0.1em) #date_format(date: date, lang: lang) ] pagebreak() } #let show_cover(infos: (:)) = { // 如果 report_type 中含有数字,则提取并细化设置 report 类型,默认为 1 if (infos.cover_style == false or infos.cover_style == "" or infos.cover_style == none) {return;} // no cover let report_type = if infos.cover_style.match(regex("\d+")) != none {infos.cover_style.match(regex("\d+")).text} else {"1"} let cover_style = infos.cover_style.trim(report_type) if cover_style == "report" and infos.show_name { cover_report(type: report_type, ..infos) } // 实验报告 else if cover_style == "report" { cover_anonymous_report(..infos) } // 匿名实验报告 else { cover_normal(..infos) } }
https://github.com/indicatelovelace/typstTemplates
https://raw.githubusercontent.com/indicatelovelace/typstTemplates/main/themes/modern/modern.typ
typst
MIT License
//#import "../logic.typ" //#import "../utils/utils.typ" #import "@preview/polylux:0.3.1": * #let fgdark = rgb("#234563") #let bgwhite = rgb("FFFFFF") #let sections = state("sections", ()) #let license = sym.copyright #let author = [<NAME>] #let currentSection(update: none) = { let newSec = [] if update != none { newSec = sections.update(l => { l.push(update) l }) } newSec context { let sec = sections.get() if sec.len() < 1 { return [] } else { return sections.get().last() } }) } #let currentSectionNumber() = context { sections.get().len() + 1 }) #let _loremBullet( count: 5 ) = list(..range(count).map(item => lorem(calc.rem((item + 1) * 149, 17) + 1))) #let _sectionSymbols( size: 10pt, unselected: circle(radius: 5pt, fill: white, stroke: black), selected: circle(radius: 5pt, fill: black, stroke: black) ) = { context { let allSecs = sections.final(here()) let currentSecs = sections.get() if currentSecs.len() > 0 { stack(spacing: 3pt, dir: ltr, ..allSecs.map(item => if item == sections.get()).last() { selected } else { unselected } )) } }) } #let slideHeader(section: none) = { set text(font: "IBM Plex Mono SmBld", size: 12pt) set align(left) stack(dir: ltr, line( start: (2%, 30%), end: (2%, 70%), stroke: (paint: black, thickness: 2pt) ), h(4pt), currentSection(update: section), ) set align(right) _sectionSymbols() } #let slideFooter = { set text(font: "IBM Plex Mono SmBld", size: 10pt) stack(dir: ltr, [#set align(left); #license], [#set align(center); #author], // TODO: authors functions, that checks the space, if their is not enough space try to shorten the names by display only initials or combination, e.g <NAME>, <NAME> [#set align(right); #logic.logical-slide.display()] ) } #let mancy( aspect-ratio: "16-9", author: none, body ) = { set page( paper: "presentation-" + aspect-ratio, fill: none, margin: 1.6em, ) set text( font: "IBM Plex Sans", weight: "light", size: 20pt) body } #let _corners( margin: 2%, length: 4%, style: (paint: black, thickness: 3pt, cap: "round") ) = { let offset = (100% - margin) // TODO: organisation place(top + left, path( stroke: style, (margin + length, margin), (margin, margin), (margin, margin + length), ) ) place(top + left, path( stroke: style, (margin + length, offset), (margin, offset), (margin, offset - length), ) ) place(top + left, path( stroke: style, (offset, margin + length), (offset, margin), (offset - length, margin), ) ) place(top + left, path( stroke: style, (offset - length, offset), (offset, offset), (offset, offset - length), ) ) } #let title-slide( title: [], subtitle: none, author: none, organisation: none, background: none, date: datetime.today(), ) = { set page(margin: 5%, background: background + _corners(margin: 8pt, length: 30pt, style: (thickness: 2pt)) + _sectionSymbols()) let content = { set text(fill: fgdark) set align(horizon + center) block(width: 100%, inset: 2em, { text(size: 30pt, strong(title)) if subtitle != none { linebreak() text(size: 24pt, subtitle) } line(length: 100%, stroke: .05em + black) set text(size: 20pt) if author != none { block(spacing: 1em, author) } set text(size: 16pt) set align(bottom) if date != none { // TODO: smaller and strong block(spacing: 1em, date.display()) } // TODO: organisation }) } logic.polylux-slide(content) } #let single-slide( title: [], body: none, section: none, ) = { set page( footer: slideFooter, header: slideHeader(section: section) ) let content = { set text(fill: fgdark) set align(top + left) if title != none { box(width: 100%, height: 16%, inset: 5pt, title) } set align(left) if body != none { body } set align(bottom + right) } logic.polylux-slide(pad(rest: 16pt, content)) } #show: mancy.with(aspect-ratio: "16-9") #title-slide(title: "<NAME>", subtitle: "Aber haben sie schonmal ein Dokument in Typst geschrieben", author: "<NAME>", background: ellipse(width: 87%, height: 85%, fill: yellow, stroke: 6pt)) #single-slide(title: "Introduction", body: "Hier könnte ihre Doku stehen", section: "Introduction") #single-slide(title: "Introduction", body: "Hier könnte ihre Doku stehen", section: "2")
https://github.com/wumin199/wumin199.github.io
https://raw.githubusercontent.com/wumin199/wumin199.github.io/main/source/_posts/2023/power-of-matrix.md
markdown
--- title: 《矩阵力量》课程笔记 date: 2023-07-16 22:05:15 tags: 笔记 toc: true comment: true widgets: - type: toc position: right index: true collapsed: false depth: 3 --- 有数据的地方,必有矩阵!有矩阵的地方,更有向量! 有向量的地方,就有几何!有几何的地方,皆有空间! 有数据的地方,定有统计! <!-- more --> --- ## 概要 - [《矩阵力量》--姜伟生,清华大学出版社,2023年6月第一版](https://book.douban.com/subject/36424128/)(本课程基于此书) - [github: power-of-matrix](https://github.com/Visualize-ML/Book4_Power-of-Matrix)(含勘误表) - [配套B站视频](https://space.bilibili.com/513194466) - [notion:矩阵力量](https://wumin199.notion.site/b4913149815448a4bcbc5b41c690fec6) - [github:wm-power-of-matrix](https://github.com/wumin199/wm-power-of-matrix) - [Typst: power-of-matrix](https://typst.app/project/pIVVvBW-Q4xUWGthZc6PjN) - [github: wm-test-case](https://github.com/wumin199/wm-test-case)(python测试案例) 重点:第5章 再出一章:极简版,一句话概述 --- ## 速记 1. 投影分向量投影和标量投影。方向向量只提供方向,其大小不管是多少都会被归一化。标量投影和投影向量的方向有关和大小无关,向量投影 = 标量投影*单位投影向量。 2. 向量投影:有些是xv,有些是vx写法,只要结果是个标量就行了! ## 课程笔记 ### 前言 - `VI页` 介绍了如何用python包 [streamlit](https://streamlit.io/)制作数学动画,并配套了 - [Streamlit做数学动画、机器学习App](https://www.bilibili.com/video/BV1oV4y1E7GZ/?spm_id_from=333.999.0.0&vd_source=991bc0898d44d84ddbbb0469ce816e70) - [运动的椭圆---Streamlit做数学动画、机器学习APP](https://www.bilibili.com/video/BV1CT411J7Ey/?spm_id_from=333.999.0.0&vd_source=991bc0898d44d84ddbbb0469ce816e70) - [圆周率 0~9 出现频率---Streamlit做数学动画、机器学习APP](https://www.bilibili.com/video/BV1nd4y1D7f7/?spm_id_from=333.999.0.0&vd_source=991bc0898d44d84ddbbb0469ce816e70) - 纸质书有一些错误,可以参考开源的pdf - 参考 - [python 画图 matplotlib, sympy, mpmath与 Matlab, R 比较](https://blog.csdn.net/robert_chen1988/article/details/80465255) - [一个 Python 库( mpmath 库)的 plot 函数](https://blog.csdn.net/yong1585855343/article/details/115547039) --- ### 不止向量 - `P8` 基本概念:花萼长度(sepal length)、花萼宽度(sepal width)、花瓣长度(petal length)、花瓣宽度(petal width),以及最重要的本书的鸢尾花数据矩阵X,并给出了数据矩阵列向量和行向量的符号表示 ![鸢尾花数据矩阵X](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch01/IrisDataSet.png) ![行向量,用上标;列向量,用下标](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch01/X_notation.png) - `P12` 正交是线性代数的概念,是垂直的推广 - `P15` 成对特征散点图的纵坐标画错了,纵坐标从低到高应该是P、P、S、S。这幅图的详细介绍可以看《数学要素》P420。成对特征散点图可以用来可视化4个特征的数据集(花萼长度、花萼宽度、花瓣长度、花瓣宽度)。对角线的4幅图叫概率密度估计曲线。作者将在《统计至简》中讲述概率密度估计。 - `P16` 将数据云的质心平移到原点,这个过程叫去均值化过程 - `P17` 代数视角:矩阵乘法代表线性映射,具体参考[Typst: power-of-matrix](https://typst.app/project/pIVVvBW-Q4xUWGthZc6PjN) - `P17` 几何视角:矩阵完成的是线性变换,平面是由矩阵各列的base(基底)张成的 ![可以利用这个变化,将单位圆转换为椭圆](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch01/Ch01-linear-transformation.png) - `P18` 利用矩阵A,可以将单位圆转化为旋转椭圆,要了解椭圆的信息,需要用到特征值分解。需要注意的是,鸢尾花数据矩阵不能完成特征值分解,但是格拉姆矩阵(对称矩阵)可以完成特征值分解 - `P18` 不同于特征值分解,不管形状如何,任何实数矩阵都可以完成奇异值分解(SVD) - `P20` 多个特征之间的关系,如花萼长度、花萼宽度、花瓣长度、花瓣宽度,可以使用格拉姆矩阵(方阵)、协方差矩阵、相关性系数矩阵等矩阵来描述。而某个特征内部,可以用均值、均方差、概率密度估计进行表征。 - `P21` 总结了鸢尾花数据矩阵X(nx4)衍生出的各种矩阵,并在后续章节中介绍 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch01/Ch01-derived-matrix.png) --- ### 向量运算 - `P24` 向量运算汇总 ![向量运算汇总](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-vector-calculations.jpg) - `P26` 使用`pylot.quiver()`绘制矢量箭头图 `plt.quiver(X, Y, U, V, angles='xy', scale_units='xy')` 中, X 和 Y:箭头的起始位置坐标,可以是数组、列表或网格。 U 和 V:箭头的水平和垂直分量,可以是数组或列表。它们的长度应与 X 和 Y 相同。 - `P27` 自然界的风、水流、电磁场,在各自空间的每一个点上对应的物理量既有强度、也有方向。将这些既有大小又有方向的场抽象出来便得到**向量场(vector field)** 本书中,我们会使用向量场来描述函数在一系列排列整齐点的梯度向量。 梯度下降方向 -- 下山方向 梯度向量(gradient vector) -- 上山方向 ![梯度定义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch01/Ch01-gradient-vector.png) ![梯度向量--上山方向](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch01/Ch01-gradient-vector-2.png) - `P28` 观察数据矩阵的两个视角 ![行列向量](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-matrix-view.png) - `P28` 用numpy构造行向量,`numpy的array默认是行向量`,测试可以看[github: wm-test-case](https://github.com/wumin199/wm-test-case),下同 - `P29` 数据分析偏爱用行向量表达样本点,`本书默认的向量指列向量` - `P30` 用numpy构造列向量 - `P30` 可以用numpy.zeros()或者numpy.ones()生成全零/全1向量 - `P31` 向量长度又叫向量模(norm),欧几里得距离(Euclidean distance)、欧几里得范数(Euclidean norm)或L^2范数(L2-norm) - `P32` 函数np.linalg.norm默认计算L^2范数 - `P33` python中绘制等高线 - `P35` 理解向量a-b ![向量减法](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-vector-subtraction.png) - `P37` 向量内积(dot product/inner product):结果为标量 - 向量内积 (inner product),又叫标量积 (scalar product)、点积 (dot product)、点乘 - 定义、公式(符号)、常见公式 ![内积公式](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-inner-product.png) ![常见内积案例](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-inner-product-cases.png) - `P38` python的内积 - np.inner(a,b) - np.dot(m1,m2) -> 矩阵乘积 - np.dot(a,b) -> 向量内积 - m1 @ m2 -> 矩阵乘积,向量也是特殊的矩阵 - 行向量a @ 列向量b -> 向量内积 - np.vdot(a,b) 或这 np.vdot(m1,m2) -> 都是向量内积,会把矩阵转换为向量。 - `P39` 几何意义 - 从几何角度看,向量内积相当于两个向量的模 (L^2 范数) 与它们之间夹角余弦值三者之积 ![内积几何定义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-inner-product-geometric-perspective-2.png) ![内积几何意义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-inner-product-geometric-perspective.png) - `P39` 柯西-施瓦茨不等式的推导,核心推导公式是(2.42) ![内积取值范围](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-cauchy-derivation.png) - `P42` 两点之间的欧式距离 - `P42` 向量内积无处不在,比如:样本方差公式、样本协方差公式 ![样本X的方差、协方差。这里的n是样本点个数](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/inner_product_in_stats_1.png) ![样本X的方差、协方差。这里的n是样本点个数](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/inner_product_in_stats_2.png) ![样本X的方差、协方差。这里的n是样本点个数](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/inner_product_in_stats_2.png) ![广播原则](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/numpy_broadcast.png) - 向量夹角:反余弦 - `P44` 2个单位向量的内积就是夹角的余弦值 - `P44` 2个向量内积为0,则互相正交 - 余弦相似度和余弦距离 - `P45` 机器学习中,余弦相似度用向量夹角的余弦值度量样本数据的相似度 - `P46` 余弦距离基于余弦相似度,等于1-余弦相似度,取值范围是[0,2]。和L^2范数一样也是一种常见的距离度量 - `P47` 脚本案例中使用 scipy.spatial 可以直接计算余弦距离。可以学习下from sklearn中的datasets类,iris = datasets.load_iris()返回的是Bunch()类,可以直接用iris.data。Bunch类是基于Dict来实现getter/setter的 - 向量积(vector product):结果为向量 - `P47` 向量积(vector product)也叫叉乘(cross product),向量积结果为向量。也就是说,向量积一种“向量→向量”的运算规则 - a x b的结果c,方向垂直于a和b, 大小为a和b构成的平行四边形面积 - `P49` 叉乘的常见性质、正交向量之间的叉乘、任意两个向量之间的叉乘 - `P49` python的叉乘 - np.cross() - 有些教材把向量积叫做外积(outer product),有些教材也把张量积叫做外积,注意区分。 - 逐项积(piecewise product)或者阿达玛乘积(Hadamard product) - `P50` 记住符号,圆圈中一个点 ⊙ - `P51` python中的逐项积 - np.multiply(a,b) - python中a*b - 张量积:张起网格面 - `P51` 张量积(tensor product) 又叫克罗内克积(Kronecker product),符号:⊗ - `P51` 向量张量积是一种“向量→矩阵”的运算规则,同时列出了一些性质 - `P51` 向量的矩阵表达法 - `P53` 几何视角:2个向量张起空间,新的空间中的行列和2个向量之间有相似性 - a ⊗ b 的秩为1; a ⊗ a 为对称阵 ![张量积的几何视角](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-tensor-product.png) ![张量积](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch02/Ch02-tensor-product-2.png) - `P53` python实现 - np.outer - `P54` 2个离散随机变量的联合概率,可以看成是张量积 - streamlit中使用KATEX打印数学公式 - `P54` 中的Streamlit_Bk4_Ch2_13.py,使用了KATEX来打印数学按公式;同时展示了streamlit会绘制plotly图 --- ### 向量范数 - overview ``P58`` ![向量范数](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch03/Ch03-overview.png) - L^p范数 - ``P58``,p>=1时才是范数,L^p范数非负,代表距离,是一种“向量”->"标量"的运算 - ``P60``,对同一个向量,Lp范数随p增大而减小,Lp范数丈量一个向量的“大小”。p取值不同时,丈量的方式略有差别。在数据科学、机器学习算法中,Lp范数扮演重要角色,比如距离度量、正则化(regularization) - L^p范数和超椭圆的联系 - 等高线的含义是:z = f(x,y),是个三维图,然后投影到取不同的z值,投影到x,y平面中 ``P62`` ![Lp等高线](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch03/Ch03-contour.png) - ``P63`` p>=1时, Lp范数具有次可加性 - ``P63`` 代码中给出了用plotly绘制2维/3维可缩放图的方法,并且在streamlit中用到了可折叠的方法(expander) - 常见距离汇总 - ``P72`` python实现各类距离,使用plotly,在一张图中绘制等高线和散点图 ![常见距离](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch03/Ch03-distance.png) - 高斯核函数:从距离到亲进度 - ``P73`` 在很多应用场合,我们需要把“距离”转化为“亲近度”,就好比上一章余弦距离和余弦相似度之间的关系。为了把距离||p−x||_q转化成亲近度,我们需要借助复合函数这个工具。本系列丛书《数学要素》一册介绍过高斯函数(Gaussian function) ![高斯核函数](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch03/Ch03-Gausian.png) ![e^(-x)](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch03/Ch03-e-x.png) --- ### 矩阵 - python中的矩阵构造方法 ``P81``, np.matrxi()和np.array()都可以 - 矩阵形状 - ``P83`` 对角矩阵也可以是长方形矩阵, 这在SVD分解中有用到 - ``P84`` 如果矩阵A为可逆矩阵(invertible matrix, non-singularmatrix),A可以通过LU分解变成一个下三角矩阵L与一个上三角矩阵U的乘积 - ``P84`` 计算时,长方形矩阵的形状并不“友好”。比如,很多矩阵分解都是针对方阵。可以将长方形矩阵转换为方阵(格拉姆矩阵) ![格拉姆矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch03/Ch03-gram-matrix.png) - ``P84`` 处理长方形矩阵有一个利器,这就是奇异值分解(SVD) - 矩阵乘法 - ``P88`` 矩阵两大主要功能:1)表格;2) 线性映射。线性映射就体现在矩阵乘法中。比如Ax= b完成→xb的线性映射;反之,如果A可逆,A−1完成→bx的线性映射。 - ``P89`` 矩阵乘法是一种“矩阵→矩阵”的运算规则 - ``P89`` python中矩阵乘法: - np.matmul(A, B) - A @ B - 如果是 np.array: * -> 逐元素相乘; 如果是np.matrix: * -> 矩阵乘法 - 对np.array: **2 -> 逐元素平方; np.matrix: **2 -> 矩阵的幂 - ``P90`` 列出常见矩阵乘法性质,其中:不满足交换律 - 两个视角解析矩阵乘法 - ``P90~P91`` 常规视角(第一视角):标量积展开;第二视角:外积(张量积)展开,也可以参考第6章的矩阵乘法第一视角和第二视角(`P150`) - 转置矩阵 - ``P93`` 列向量和自身的张量积,是对称矩阵 - ``P93`` 列出了矩阵转置的一些性质,和内积的一些关系 - <span id="ch04_transpose">向量内积的矩阵表示法,以及矩阵平方和</span> ![转置](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch03/Ch03-transpose.png) - 逆矩阵:相当于除法运算 - ``P94`` 矩阵可逆(invertible) 也称非奇异(non-singular);否则就称矩阵不可逆(non-invertible),或称奇异(singular) - ``P94`` 矩阵求逆“相当于”除法运算,但是两者有本质上的区别。矩阵的逆本质上还是矩阵乘法。 - ``P94`` 逆矩阵常见运算 - ``P94`` 正交矩阵:A^T=A^-1 - 迹:主对角元素之和 - ``P96`` “迹”这个运算是针对“方阵”定义的 - ``P96`` 迹的一些性质 - 逐项积,或者阿达玛乘积 - ``P97`` A ⊙ B - ``P97`` numpy: - np.multiply(A, B) - A * B - 行列式:将矩阵映射到标量值 - ``P98`` 每个“方阵”都有自己的行列式(determinant),如果方阵的行列式值非零,方阵则称可逆或非奇异 - ``P98`` 矩阵的行列式值可正可负,也可以为0。列出了行列式的一些性质 - ``P99`` 向量积可以通过行列式得到 - ``P101`` 列出了特殊的2x2方阵的行列式以及图形,可以看到几何意义 - ``P100`` 以a1和a2为两条边构造得到一个平行四边形。这个平行四边形的面积就是A的行列式值。 - ``P102`` 代码,在streamlit中用Katex显示出矩阵,并绘制坐标网格,以及变化后的平行且等距的网格线,以及网格线变换和行列式几何意义,用np.stack拼接矩阵 - ``P102`` 3×3方阵的行列式值的几何意义 - 对于任意3×3方阵A,它的行列式值的几何含义就是由其三个列向量a1、a2、a3构造的平行六面体的体积。注意,这个体积值也有正负。 - 单位矩阵I的行列式为1 - 如果a3在a1、a2构造的平面中,平行六面体体积为0,即方阵A行列式值为0,这种情况下,a1、a2、a3线性相关,A的秩为2 - 在线性变换中,变换矩阵的行列式值代表面积或体积缩放比例 - ``P103`` 对角方阵的行列式为对角元素的乘积 - ``P103`` 平行四边形到矩形:可对角化矩阵和特征值分解 - 我们遇到的方阵大部分不是对角方阵,计算其面积或体积显然不容易。有没有一种办法能够将这些方阵转化成对角方阵?也就是说,把平行四边形转化成矩形,把平行六面体转化为立方体? - 并不是所有的方阵都可以转化为对角方阵,能够完成对角化的矩阵叫可对角化矩阵 - 如果可以对角化,则对角化方法为:**特征值分解**,而且前后方阵的trace一样 - [线性代数为什么要研究行列式?](https://www.zhihu.com/question/615552517/answer/3151269382) 矩阵的行列式与矩阵的关系类似向量的模长与向量的关系。模长是向量的某种几何尺度,是向量非零端与零点之间的距离,而矩阵的行列式也是由矩阵的列向量们围成的几何体的“体积” ![线性代数为什么要研究行列式?](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch04/ch04-determinant.png) --- ### 矩阵乘法 - overview - ``106`` ![矩阵乘法](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/overview.png) - <span id="ch05_vector_vector">向量和向量</span> - ``P107`` 向量·向量的几何含义是向量内积,`向量内积的运算中间有点,矩阵相乘中间没有点`, 同[矩阵转置](#ch04_transpose) ![向量内积的矩阵乘法表示](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/vector_in_matrix.png) - ``P108`` 全1列向量具有复制功能:全1列向量1乘行向量a,相当于对行向量a进行复制、向下叠放。列向量b乘全1列向量1转置,相当于对列向量b复制、左右排列 - ``P109`` 全1对列向量x元素求和;向量x·向量x,可以求元素平方和。这在统计学的方差、协方差中有用到 ![向量元素和](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/vector_mean.png) ![向量元素平方和](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/vector_variance.png) - ``P110`` 向量相乘(·) -- 内积(<>) -- 矩阵相乘(没有点或者是@) -- 范数 -- 标量 提醒大家注意,但凡遇到矩阵乘积结果为标量的情况,请考虑是否能从“距离”角度理解这个矩阵乘积 ![向量相乘](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/vector_inner_matrix.png) - ``P111`` 向量的张量积也可以写成矩阵形式 ![向量的张量积](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/vector_tensor.png) - 全1列向量在求和方面的用途 - ``P112`` 全1矩阵具有复制的功能:可以用于求数据矩阵的行元素的和、列元素的和、所有元素的和 ![每列元素求和](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/sum_in_column.png) ![每行元素求和](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/sum_in_row.png) ![所有元素求和](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/sum_in_matrix_all.png) ![应用:去均值](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/one_vector_mean.png) ![应用:成绩分布、成绩变化趋势](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/application_in_sum.png) - ``P114`` 张量积1⊗1是个n×n方阵,矩阵的元素都是1 - 矩阵乘向量:线性方程组 - ``P117`` 解的个数:若线性方程组有唯一一组解,矩阵A可逆;如果A^TA可逆,则可以用广义逆或伪逆来求解;如果A^TA非满秩,则A^TA不可逆,这种情况需要用摩尔-彭若斯广义逆(Moore–Penrose inverse)。函数numpy.linalg.pinv() 计算摩尔-彭若斯广义逆。这个函数用的实际上是奇异值分解获得的摩尔-彭若斯广义逆。 ![广义逆、伪逆](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/pseudoinverse.png) - ``P117`` 从向量、几何、空间、数据等视角理解Ax= b。 - ``P118`` A的列向量的线性组合系数x构成线性组合 - ``P118`` 其中如果x和b在同一个空间,没有降维,则成为线性映射 - ``P119`` 几何变换:x经过各类线性变换(缩放/平移/旋转/...)后变成b ![旋转矩阵1和矩阵乘向量理解1](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/geo_view.png) ![旋转矩阵1和矩阵乘向量理解2](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/geo_view2.png) - ``P119`` 向量模:x^TA^TAx这种矩阵乘法的结果为非负标量,其中A^TA叫做A的格拉姆矩阵。x^TA^TAx就是下一节要介绍的二次型 - 向量乘矩阵乘向量:二次型 x^TQx = q,其中Q为对称矩阵 ![二次型,Q是对称矩阵, 单项式变量的最高次数是2,这就是x^TQx被成为二次型的原因](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/quadratic_form.png) - y=f(x) -> 一元函数 - z=f(x,y) 或 y=f(x1,x2) -> 二元函数 ![二次型和二元函数](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/quadratic_form_curve.png) - 三个方阵连乘 - ``P122`` V^TΣV, V和Σ都是D×D方阵,上式结果也是D×D方阵。特别地,实际应用中V多为正交矩阵。矩阵(i,j)元素v_i^TΣv_j便是一个二次型,viTΣvj对应的运算示意图如图21所示。这说明,上式包含了D×D个二次型。 - 方阵乘方阵:矩阵分解 - 对角阵:批量缩放 - ``P124`` 左乘、右乘、行乘、列乘、左右都乘 ![Λ的对角线元素相当于缩放系数,分别对矩阵X的每一列数值进行不同比例缩放。如果缩放系数都是1,且对角阵的每列顺序有交换则就起到置换矩阵交换每列的作用](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/dia_matrix.png) ![Λ的对角线元素分别对矩阵X 的每一行数值进行批量缩放。如果缩放系数为1,且对角镇的每行顺序发生交换,则起到置换矩阵交换每行的作用](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/dia_matrix_2.png) 以上对Permutation矩阵也是一样的道理。口诀:单行矩阵@单列矩阵=数,多行矩阵@单列矩阵=单列矩阵,多行矩阵@多列矩阵=多行多列矩阵 - ``P126`` 特殊的二次型,只有x_1^2项目,没有x1*x2项 - 置换矩阵:调换元素顺序 - `P127` 行向量a乘副对角矩阵,如果副对角线上元素都为1,得到左右翻转的行向量。完成左右翻转的方阵是置换矩阵(permutation matrix) 的一种特殊形式。 - `P127` 置换矩阵是由0和1组成的方阵。置换矩阵的每一行、每一列都恰好只有一个1,其余元素均为0。置换矩阵的作用是调换元素顺序。 - 可以用来调整列向量顺序、调整行向量顺序,这一点和上面的对角线的左右乘效果类似的。置换矩阵可以用来简化一些矩阵运算。 - 矩阵乘向量:映射到一维 这里的矩阵在左边,是样本点数据矩阵 视角:矩阵各列的线性组合 -> 一维 ![矩阵乘向量的理解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/matrix_vector.png) - `P129` 以鸢尾花数据为例理解矩阵乘向量 - 矩阵乘矩阵:映射到多维 这个案例中,样本点矩阵在左边,右边的矩阵是方向矩阵(或者叫新的坐标系的各个坐标轴。方向矩阵还是以列为基础表示坐标,和数据矩阵是用行还是列表示无关) ![样本点矩阵乘矩阵:2个方向映射的理解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/matrix_matrix.png) ![样本点矩阵乘新矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/matrix_matrix_many.png) 理解:每一行是一个样本,变换后的每一行是一个样本在新的坐标系下的坐标值。原来是一行代表一个点,现在也是一行代表一个点。但是方向矩阵/旋转矩阵依然是以列来衡量的 ![一个样本点,可以写成列形式或行形式](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/matrix_matrix_vector.png) - `P132` 约定俗成,各种线性代数工具定义偏好列向量;但是,在实际应用中,更常用行向量代表数据点。两者之间的桥梁就是——转置。 **如果样本点的矩阵是:一个行向量代表一个样本点,则一般是XM=Z,这里X和Z都是行向量代表一个点。但是线性代数中的工具样本点一般每一列代表一个样本点,则MX=Z,X和Z都一个列向量代表一个样本点!!** - 长方阵:奇异值分解、格拉姆矩阵、张量积 - `P133` 格拉姆矩阵G=X^TX,其对角线元素含有L^2范数信息;每个元素也可以从向量内积角度考虑 - `P133` 格拉姆矩阵之所以重要,一方面是因为它集成了向量长度(L2范数)和相对夹角(夹角余弦值)两部分重要信息。另一方面,格拉姆矩阵G为对称矩阵。一般情况,数据矩阵X都是“细高”长方形矩阵,矩阵运算时这种形状不够友好。比如,细高的X显然不存在转置。而把X转化为方阵G(=XTX)之后,很多运算都变得更加容易 - `P136` 矩阵元素平方和,理解连续2个求和符号:相当于程序中的连续2个for循环 ![求和符号](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/sum_in_matrix.png) - `P136` 一个矩阵的所有元素平方和、再开方叫做矩阵F-范数 - 爱因斯坦求和约定 - `P136` Python中Xarray专门用来存储和运算高阶矩阵 - 矩阵乘法的几个雷区 - `P139` A(B-C)=O,不能直接得出B= C,这是因为矩阵A不一定可逆 - `P139` 求逆和转置的顺序 ![求逆和转置的顺序](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/sequence_in_inv_trans.png) - `P139` 逆矩阵和转置矩阵中带乘法和标量的情况;如果分子、分母上都出现同一个矩阵,绝不能消去 --- ### 分块矩阵 - `P144` 分块矩阵overview - 分块矩阵:横平竖直切豆腐 - `P147` 分块矩阵的转置有2层 - 矩阵乘法的2个视角 - `P149~P150` 标量积展开 和 外积(张量积)展开 ![第一视角:标量积展开](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch06/view1.png) ![第一视角:标量积展开](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch06/view2.png) ![第二视角:外积(张量积)展开](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch06/view3.png) - 展开的意思是:一个值是由很多个值叠加起来的 - 它这里的外积,是指有多个:列矩阵和行矩阵乘法运算后得到的矩阵的叠加 - 外积展开的思路:将A看成一系列的列向量,B看成一系列的行向量,之后就是这些列和行各自的外积/张量积的展开 - 在这个基础上,将列矩阵和行矩阵看成是向量,然后张量积是2个列向量的运算,所以对第二个行向量要转置成列向量 - `P153` 还给出了矩阵运算的可视化图来帮助理解 - 这个思路对于特征值分解(Eigen Decomposition)、奇异值分解(Singular Value Decomposition, SVD)、主成分分析(Principal Component Analysis, PCA) 非常重要。 - 学好特征值分解、奇异值分解的关键就是“多视角”——数据视角、向量视角、几何视角、空间视角、统计视角等等。 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch06/matrix_in_tensor.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch06/matrxi_in_tensor_2.png) - 矩阵乘法更多视角:分块多样化 `P154` C=AB,分块完,都可以化为以上2个视角来理解! - B切成列向量:相当于每个列向量是个样本,A的各列相当于坐标系 - A切成一组行向量:相当于A的每行是个样本点(鸢尾花数据矩阵),B的每行相当于坐标系向量 - 分块矩阵的逆 `P160` 分块矩阵的逆将会用在协方差矩阵上,特别是在求解条件概率、多元线性回归时。 - 克罗内克积:矩阵张量积 `P160` 克罗内克积(Kronecker product),也叫矩阵张量积,是两个任意大小矩阵之间的运算,运算符为⊗ - `P161` numpy.kron()可以用来计算矩阵张量积。克罗内克积讲究顺序,一般情况A⊗B≠B⊗A。同时列出了一些性质。 - 克罗内克积相当于向量张量积的推广;反过来,向量张量积也可以看做克罗内克积的特例。但两者稍有不同,为了方便计算,两个2×1列向量的张量积定义为a⊗b=ab^T --- ### 向量空间 - 向量空间:从直角坐标系说起 - `P167` 向量空间定义:给定域F,F上的向量空间V是一个集合。集合V非空,且对于加法和标量乘法运算封闭。如果V连同上述加法运算和标量乘法运算满足如下公理(结合律/交换律/过原点等),则称V为向量空间 - `P168` v1、v2...vD所有线性组合的集合称作v1、v2...vD的张成(span),记做span(v1,v2...vD) -> 展成一个空间 相关:你的条件有多余的,有些是做了重复的工作,有冗余量 无关:每个都是独立的,有贡献的,不能完全被其他表示出来的 ![线性相关和线性无关](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch07/linearly-independant.png) - `P169` 一个矩阵X的列秩(columnrank) 是X的线性无关的列向量数量最大值。类似地,行秩(row rank) 是X的线性无关的行向量数量最大值. - `P169` 极大线性无关组的元素数量r为V={x1, x2, ...,xD}的秩,也称为V的维数或维度。 r <=D ![rank(X)的秩和span(X)的空间](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch07/span_rank.png) - `P169` 矩阵的列秩和行秩总是相等的,因此就叫它们为矩阵X的秩(rank),记做rank(X)。rank(X)小于等于min(D, n) - `P169` 当rank(X)的秩取不同值时,span(X) 所代表的空间: 1维/2维/3维/... - 特别地,若矩阵X的列数为D,当rank(X) = D时,矩阵X列满秩,列向量x1, x2, ...,xD线性无关。 - `P170` 秩的性质:乘法中/转置矩阵中的秩 - `P170` 一个向量空间V的基底向量(basis vector)指V中线性无关的v1、v2 ... vD,它们张成(span) 向量空间V,即V= span(v1,v2,...,vD) - `P170` 向量空间的维数(dimension) 是基底中基底向量的个数,本书采用的维数记号为dim() ![维度为2的向量空间](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch07/dim_2.png) - `P172` “过原点”这一点对于向量空间极为重要。向量空间平移后得到的空间叫做仿射空间(affinespace),几何变换中点仿射变换涉及这一点 - `P173` 基底中基底向量若两两正交,该基底叫正交基(orthogonal basis)。如果正交基中每个基底向量的模都为1,则称该基底为规范正交基(orthonormal basis)。更特殊的是,[e1, e2]叫做平面2的标准正交基(standard orthonormal basis),或称标准基(standardbasis)。“标准”这个字眼给了[e1, e2],是因为用这个基底表示平面2最为自然。[e1, e2]也是平面直角坐标系最普遍的参考系。 - `P174` 基底转换(change of basis)完成不同基底之间变换,而标准正交基是常用的桥梁 ![坐标系和坐标值](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch07/coordinate-values.png) ![坐标系和坐标值](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch07/matrix-basis.png) - 给向量空间涂颜色:RGB色卡 - `P178` 强调一下,红、绿、蓝不是调色盘的涂料。RGB中,红、绿、蓝均匀调色得到白色;而在调色盘中,红、绿、蓝三色颜料均匀调色得到黑色 - `P178` 在三原色模型这个空间中,任意一个颜色可以视作基底 [e1, e2, e3] 中三个基底向量构成线性组合。RGB三原色可以用10进制/8进制/16进制表示,每个颜色的10进制分量为0 ~ 255 之间整数 - 张成空间:线性组合红、绿、蓝三原色 - `P182` 一种特殊情况,e1、e2 和e3 这三个基底向量以均匀方式混合,得到的便是灰度:α(e1+e2+e3),这些灰度颜色在原点(0, 0, 0)和(1, 1, 1) 两点构成的线段上:(0, 0, 0):黑色,(1, 1, 1):白色。 - `P183` streamlit中借助pandas的DataFrame和plotly的Scatter3d绘制带颜色的空间散点图 - 非正交基底:青色、品红、黄色 - `P184` e1([1, 0, 0]T red)、e2([0, 1, 0]T green) 和e3([0, 0, 1]T blue) 这三个基底向量任意两个组合构造三个向量v1([0, 1, 1]T cyan)、v2([1, 0, 1]T magenta) 和v3([1, 1, 0]T yellow) - `P184` v1、v2 和v3 线性无关,因此 [v1, v2, v3] 也可以是构造三维彩色空间的基底 - `P184` 印刷四分色模式 (CMYK color model) 就是基于基底 [v1, v2, v3]。CMYK 四个字母分别指的是青色 (cyan)、品红 (magenta)、黄色 (yellow) 和黑色 (black) - `P185` v1、v2 和v3 并非两两正交。经过计算可以发现v1、v2 和v3 两两夹角均为60°,[v1, v2, v3] 为非正交基底 - 基底转换:从红、绿、蓝,到青色、品红、黄色 - `P187` 通过矩阵A,基底向量 [e1, e2, e3] 转化为基底向量 [v1, v2, v3]。 [v1, v2, v3] = A[e1, e2, e3] --- ### <span id="ch08_geometric_ransformation">几何变换</span> - `P189` 线性变换的特征是原点不变、平行且等距的网格 - 线性变换:线性空间到自身的线性映射 - `P191` 线性映射是指从一个空间到另外一个空间的映射,且保持加法和数量乘法运算。如三维物体投影到一个平面上,得到这个杯子在平面上的映像 - `P191` 线性变换是线性空间到自身的线性映射,是一种特殊的线性映射。白话说,线性变换是在同一个坐标系中完成的图形变换。从几何角度来看,线性变换产生“平行且等距”的网格,并且原点保持固定。原点保持固定,这一性质很重要,因为大家马上就会看到“平移”不属于线性变换 - `P192` 非线性变换。如产生平行但不等距网格、产生“扭曲”网格 - `P193` <span id="ch08_transform">常见几何变换</span>。包含了以列向量形式表达坐标点,和以行向量形式表达坐标点。平移并不是线性变换,平移是一种仿射变换(affine transformation),对应的运算为y = Ax + b。几何角度来看,仿射变换是一个向量空间的线性映射 (Ax) 叠加平移 (b),变换结果在另外一个仿射空间。b ≠ 0,平移导致原点位置发生变化。因此,线性变换可以看做是特殊的仿射变换。 - 平移:仿射变换,原点变动 - `P196` 使用matplotlib绘制带有颜色填充的多边形,conner做标记 - 缩放:对角阵 - `P198` 只有行列式值不为 0 的方阵才存在逆矩阵 - 旋转:行列式值为1 - `P201` 旋转矩阵 R 的行列式值为1,也就是说旋转前后面积不变 - `P203` 旋转 → 缩放”过程是主成分分析 (principal component analysis, PCA) 的思路。反向来看,“缩放 → 旋转”将单位圆变成旋转椭圆的过程,代表利用满足IID N(0, I2 × 2) 二元随机数产生具有指定相关性系数、指定均方差的随机数。IID 指的是独立同分布 (Independent and Identically Distributed)。 - 矩阵乘法不满足交换律 - `P205` 但是两个2 × 2 缩放矩阵连乘满足交换律,两个2 × 2 旋转矩阵连乘满足交换律 - 镜像:行列式值为负 - `P206` 几种镜像:第一种镜像用切向量来完成、第二种镜像通过角度定义、关于横纵轴镜像 - 投影:降维操作 - `P207` 本书默认是正交投影:包含沿切向量投影、沿横轴坐标投影 - 再谈行列式值:几何视角 - `P210` 从二维矩阵角度:行列式值决定了变换前后面积缩放比例。可正可负可零。如果矩阵 A 行列式值为负,几何上来看,图形翻转。几何变换前后,逆时针来看,蓝色箭头和红色箭头“先后次序”发生调转 - `P213` Streamlit 应用中,我们看到如何产生不同“平行且等距网格”。在此基础上,本章Streamlit 应用增加了矩阵A 对单位圆的线性变换 --- ### 正交投影 投影的直觉理解:太阳往地面照射,物体的影子。太阳有早上、中午、晚上之分 正交投影:正午的太阳往地面照射,物体的影子。 投影是个矢量,有大小(标量投影)和方向(向量投影)。大小就是影子的长度,方向就是规定的方向(用向量表示,方向都会用单位向量来衡量)。注意影子大小和规定方向的大小无关。但是整体来说就是大小*单位投影方向。 ![正交投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/projection_intuition.png) 可以往单一方向正交投影,这个单一方向可以构造出投影矩阵出来,这个投影矩阵可以作用到某个向量上完成这个方向的投影计算。 也可以同时往很多方向投影(往一个有续基构成的平面/超平面投影),这个有续基可以是正交也可以不是正交的。本章主要研究这个有序基,而且是规范正交基础的情况。同时也在“投影视角看回归”这一节给出了往一个有序基(不管是不是正交)投影的公式,可以是一个点或一系列点往这个有序基投影(线性回归)。且给出了如果是规范正交基,那么往这个规范正交基投影的公式会更简洁和清晰,也间接说明了需要施密特正交化的重要性。 往标准正交基的各个方向的标量投影就是坐标值,坐标值和正交投影的关系就是这么来的。 一个规范正交基可以当成一个坐标系,也可以当成的一个运动(变换),其还有一些自己的特点,如:(V是正交矩阵) - V的格拉姆矩阵是 G = V^TV -> 含有一系列向量模和两两夹角的信息(向量指的是正交矩阵的各个基向量) - VV^T=I --> v1⊗V1 + v2⊗V2 + v3⊗V3 + .. 规范正交矩阵的每个基(方向)构造出来的投影矩阵的和,构成单位矩阵(或者说单位矩阵可以分解为)。 一个或者多个样本点(每个样本点有多个特征),可以往一个或者多个方向(特征方向)进行正交投影。这可以完成降维或者重新设置特征的效果。 正交投影还可以用于求镜像向量,以及用于施密特正交化(套用往单一方向正交投影的公式)。 为了理解往一个有序基投影(不再是单一方向,而是多个方向),作者从回归的角度给出了解释。就一个点来说,y(向量)和x(向量)可以看成是一元线性回归: y=bx。y和x1,x2可以看成是二元线性回归:y=b1x1+b2x2;同理多元线性回归是y = b1x1+b2x2+b3x3+...。从正交投影角度理解多元线性回归就是y往超平面span(x0,x1,x2,...,xd)方向投影得到的hat(y)和 x0,x1,x2,...,xd 之间的系数关系, y - hat(y)是和span(x0,x1,x2,...,xd)垂直的部分,也就是残差部分。 对于只有1个自变量x和1个因变量y点的情况,可以用对 y=bx 对于2个自变量x1,x2,一个因变量y的情况,可以用y = b1x1+b2x2 对于n个x,一个y的情况,可以套用 y = b1x1+b2x2+b3x3+... 以上求系数b矩阵的方法,类似单个方向的投影矩阵,在这里叫帽子矩阵(hat matrix),这个矩阵是由设计矩阵 X = [x1, x2, ..., xd]构造出来的。最后结论是 hat(y) = 帽子矩阵* y 作者也补充提到了多项式回归,只要能写出设计矩阵,就可以把他看成线性变换,同时利用类似的公式求出b。 思考:n个方程n个未知数,如果上面的线性回归中,点数过多,可能就要想怎么最小化残差部分了。 往多个方向投影,标量和方向向量都可以从1个方向上投影推广。帽子矩阵(多个方向的投影矩阵)也是从投影矩阵(一个方向)推广过来的。同时注意如果投影向量是单位正交向量,那么帽子矩阵具有简洁形式(投影矩阵也有简洁形式)。 ![summary_1:将x扩大到数据集X,如果v是单位向量,则Xv表示往v方向的投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_1.png) ![summary_2:这里x是列向量。但在数据矩阵中x一般用行向量表示,所有后续拓展x到数据集X的时候是Xv](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_2.png) ![summary_3。注意这里的Z=Xv中的X是行表示的数据集,v是单位向量,这样Xv才是X向v方向正交投影的投影公式。否则投影公式复杂一点,见后面。n个样本点(每个样本点一行)往单位v方向正交](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_3.png) ![summary_4](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_4.png) ![summary_5:b是投影矩阵的理解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_5.png) ![summary_6:往多个方向的正交投影 == 往各个方向的正交投影的线性组合](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_6.png) ![summary_7](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_7.png) ![summary_8](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_8.png) ![summary_9:对个采样点y构成一个向量,这个向量有n个维度。这就将多个点转换为一个具有多个特征值的点](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_9.png) ![summary_10:简化的前提是要求X的列向量两两正交且列向量都是单位向量,但不要求X是标准正交基,即X可以不是方阵,即X^TX=I,但XX^T不一定是I。如果X是方阵的话,那么可以进一步简化:hat(y) = XX^Ty=(x1⊗x1+x2⊗x2+...)y=Iy=y](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_10.png) ![summary_11:往多个方向的正交投影 == 往各个方向的正交投影的线性组合](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/summary_11.png) ![summary_12:理解Z=XV](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/general_projection.png) - 标量投影:结果为标量 - `P218` 标量投影公式,注意正交投影和向量内积不一样!!!,标量投影和方向向量的大小无关!! ![标量投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/projection.png) ![标量投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/projection_2.png) - 标量:坐标系的含义。往i轴的标量投影,就是i的坐标;往j轴的标量投影,就是j轴的坐标 - 向量投影:结果为向量 - `P218` 向量投影公式,包含推导点投影到切向量的公式 ![标量投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/vector_projection.png) - `P218/P219` 向量投影公式。向量x在v方向的投影公式,包括如果v是单位向量的公式和v不是单位向量的公式 向量投影 = 标量投影 * 单位向量方向(注意是单位向量方向,方向都会被归一化) 如果v是单位向量:proj_v(x) = < x ,v>v = (x·v)v=(v·x)v=(x^Tv)v=(v^Tx)v = (v⊗v)x -> (v⊗v)叫投影矩阵,此时的v是单位向量 - `P221` python中,用matplotlib.pyplot的plot绘制点,线;以及用plt.quiver绘制箭头 - plot([x1, x2], [y1, y2]) -> 绘制直线(x1,y1) -> (x2, y2) - 如果plot只有一个点,则绘制的是marker - `P221` 如果v为单位向量,我们称v⊗v为投影矩阵 (projection matrix),会在proj_v(x),即列向量x向列向量v投影中会用到。任意向量x向v投影的公式也可以得到 - 列向量只能向列向量投影,一般意义上行向量不能向列向量投影。书里面的行向量(X)向列向量投影,是因为把行向量看成了列向量(或者说把X处理成左乘还是右乘来解决),然后套用的还是列向量投影公式 - 投影矩阵可以将 列向量x向**单位列向量v**的向量投影(内积x·v)v,变成矩阵运算 -> (v⊗v)x - `P222` 向量x 向v 方向(v方向表示特征方向,如花瓣长度方向,或者组合方向)投影,这可以视作x 向v 张起的向量空间span(v) 投影。v如果是个向量,span(v)就是沿着这条向量的向量空间 ![投影矩阵;注意v一直是列向量或者列矩阵或者多列矩阵。(22/23)和(25)区别是x是行还是列代表样本。标量投影Z=Xv,可以从行*列=值来理解 -> 向量投影Z=(Xv)v^T=X(v⊗v);行向量X的投影可以从转置的角度理解;如果X是列向量代表一个样本点,则标量Z=v^TX,向量Z=(v^TX)v= v(v^TX)=(v⊗v)X](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/projection_matrix.png) ![理解XVV^T](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/xvvt.png) - 正交矩阵:一个规范正交基 - 正交矩阵的各列向量都是单位向量 - `P222` 向量x 向一个列 v 方向投影,这可以视作x 向v 张起的向量空间span(v) 投影。同理,向量x 也可以向一个有序基构造的平面/超平面投影。这个有序基可以是正交基,可以是非正交基。数据科学和机器学习实践中,最常用的基底是**规范正交基**。正交矩阵的本身就是规范正交基。正交矩阵的每列向量都互相正交且都是单位向量,所以正交矩阵可以看成一些规范列正交基构成的矩阵,也就是张成的向量空间。 向一个列向量v投影 -> 扩展到向多个方向投影:[v1, v2, v3, v4]。如果v1,v2,v3,v4满足一定条件(两两正交且都是单位向量),则成[v1, v2, v3, v4]是正交矩阵 - `P222` 正交矩阵V: VV^T = V^TV=I,V是方阵。性质有V^T=V^-1, V^TV=VV^T=I -> V^T也是正交矩阵 - `P223` 旋转矩阵,镜像矩阵,置换矩阵都是正交矩阵 - `P224` G=V^TV 相当于正交矩阵V 的格拉姆矩阵,格拉姆矩阵包含原矩阵(的各个列向量)的所有向量模、向量两两夹角这两类信息 - `P223` 正交矩阵乘法理解的第一视角:V^TV ![正交矩阵乘法第一视角](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/orthogonal_view1.png) - `P225` 正交矩阵乘法理解的第二视角: VV^T VV^T = V^TV=I 理解XVV^T,先从(xv)v^T开始, 这里x是1xn的行向量,代表一个样本点,有n个特征值。v是nx1的方向向量(列向量)。 在这里xv就相当于是标量的作用 1个样本点,1个方向向量: 1x4 * 4x1 = 1x1,(1个样本点,4个特征) * 4x1的方向向量 = 1x1 2个样本点,1个方向向量: 2x4 * 4x1 = 2x1, (2个样本点,4个特征) * 4x1的方向向量 = 2x1 (2个样本点各自在方向向量下的标量) 1个样本点,2个方向向量: 1x4 * 4x2 = 1x2, (1个样本点,4个特征) * 2个方向向量(第1列的方向向量,第2列的方向向量) 2个样本点,2个方向向量: 2x4 * 4x2 = 2x2, (1个样本点,4个特征) * 2个方向向量(第1列的方向向量,第2列的方向向量) XV -> X是nx4, V是4xb,结果是nxb -> n个样本点在b个方向向量的各自的投影标量,就是nxb 投影向量还需要加一个方向: (XV)V^T, V^T是bxn,所以是nxb x (bxn) = nxn. 之所以方向是V^T,是因为X是每行代表一个数据点。 ![理解XVV^T](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/xvvt.png) ![正交矩阵乘法第二视角](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/orthogonal_view2.png) ![正交矩阵乘法第二视角](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/orthogonal_view3.png) ![正交矩阵乘法第二视角](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/orthogonal_view4.png) ![正交矩阵乘法第二视角](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/orthogonal_view5.png) - 规范正交矩阵的性质 ![线性变换](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/understand_transform.png) `P227` 向量x经过正交矩阵V线性变换后,具有:1. 向量长度不变 2. 向量夹角不变 `P227` 向量模的计算,学习下2个向量的运算: ![向量模长](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/vector_dot_in_module.png) `P228` 正交矩阵的行列式为1或者-1,可以学到行列式运算的一些应用。(直接用到了行列式的一些性质) - 从投影角度看镜像:x关于对称轴(τ)的镜像得到z `P229` 可以学到,利用张量积(投影矩阵),向量x在单位切向量τ方向的投影向量,进而得到镜像向量 `P230` z(镜像向量) = H(豪斯霍尔德矩阵)x(原向量) -> H利用到了和对称轴τ正交的向量v,v的方向是反射面所在方向。 矩阵H完成豪斯霍尔德反射,也叫初等反射 - 格雷格-施密特正交化 `P231` 正交化过程,注意里面的proj_v(x)中:x往v方向的投影向量,这个向量和和v的大小无关 - 投影视角看回归 > 什么是回归和线性回归 > 回归(Regression)是一种用于预测和建模的统计分析方法,通过观察变量之间的关系来推断一个或多个自变量与因变量之间的关系。回归分析可用于探索变量之间的相关性、预测未来趋势以及评估自变量对因变量的影响程度。 > 线性回归(Linear Regression)是回归分析中最简单且常用的一种方法,它假设自变量与因变量之间存在线性关系。线性回归的目标是拟合出一条直线(在一维空间中)或一个超平面(在高维空间中),使得这条直线或超平面能够最好地拟合数据点,即最小化预测值与实际观测值之间的误差。线性回归可以用于解决连续型因变量的预测问题,例如预测房价、销售量等。 > 非线性回归包括多项式回归等。 `P236` 的帽子公式给出了从线性回归角度理解的往有序基础(多个方向)投影的投影矩阵,只不过这里叫帽子矩阵 `P237` 讲了多项式回归,通过列好设计矩阵X,也可以转换到帽子矩阵方法求系数矩阵b `P238` 如果有续基是正交基,那么帽子矩阵具有非常优雅的写法,也简洁说明了需要正交化的重要性 ![理解多元线性回归](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/regression.png) ![理解多元线性回归](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/linear_reg_in_formula.png) ![帽子矩阵类似投影矩阵,也可以通过帽子矩阵求得系数矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/linear_reg_in_formula_2.png) ![多项式回归的理解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/linear_reg_in_formula_3.png) ![多项式回归](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/linear_reg_in_formula_4.png) ![正交矩阵的投影具有简洁的公式,和往一个单位方向投影的投影矩阵一样简洁](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/linear_reg_in_formula_5.png) --- ### 数据投影 本章主要讲解Z=XVV^T的意义,这里V各列必须是单位向量且互相正交,则其意义是XV表示X在V方向的标量投影,XVV^T表示向量投影(在X原来的空间下的表示) 如果V恰好又是个方阵(标准正交基的情况),则VV^T=I -> XVV^T=X - 从一个矩阵乘法运算Z=XV说起 `P242` 如果X为行向量代表数据点,V各列互相正交且是单位向量,则Z=XV表示X向V的各列有续基的标量投影,Z表示X在新的单位正交基下的坐标。需要记住这个结论,具体逻辑看上一章 ![Z的每一行的每个值,表示X在v1~vd下的投影坐标](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/Z%3DXV.png) ![从上一章延伸而来:从一般性投影到Z=XV](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/general_projection.png) - 二特征数据投影:标准正交基[e1, e2] 如果X恰好又是方阵,则Z=XVV^T=XI=X XV表示标量投影和XVV^T表示向量投影,且恰好VV^T=I ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_in_h_1.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_in_h_2.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_in_h_3.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_in_h_4.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_in_v_1.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_in_v_2.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_combination_1.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_combination_2.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/projection_combination_3.png) - 二特征数据投影:规范正交基和[e1, e2]类似,但旋转一定角度 XV:表示往V方向的标量投影,XVV^T表示向量投影(在X原来的空间下的表示) ![点A往v1,v2投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/proj_in_v1.png) ![点A在v1方向的标量投影是5.33](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/proj_in_v1_2.png) ![点A在v1方向的向量投影,在原来A的坐标系下的表示](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/proj_in_v1_3.png) ![点A在v2方向的标量投影和向量投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/proj_in_v2.png) ![点A在v1/v2方向的向量投影,在A原来的坐标系下的表示, 还是等于点A](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch10/proj_in_all.png) - 数据正交化 `P270` 原始数据X,其格拉姆矩阵G= X^TX,它不是一个对角阵。而经过V以后(V要求两两正交且是单位向量,但不一定要求V是方阵),即Z=XV后,Z的格拉姆矩阵Z^TZ=Λ就是个对角阵!不过这2个格拉姆矩阵的迹都是一样的。同时也要知道Z=XV以后,Z的列向量两两正交了!! `P271` 利用以上特点,可以将原始数据X的格拉姆矩阵,分解为3个特殊矩阵的乘积 G=VΛV^T,即V正交矩阵, Λ对角阵。 --- ### 矩阵分解 ![矩阵分解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/matrix_decomposition.png) - 矩阵分解:类似因式分解 `P278` 矩阵分解 (matrix decomposition) 将矩阵解构得到其组成部分,类似代数中的因式分解。 从矩阵乘法角度,矩阵分解将矩阵拆解为若干矩阵的乘积。 从几何角度,矩阵分解结果可能对应缩放、旋转、投影、剪切等等各种几何变换。而原矩阵的映射作用就是这些几何变换按特定次序的叠加 - LU分解:上下三角 `P279` LU分解可以视为高斯消元法的矩阵乘法形式。 A = LU `P280` scipy.linalg.lu()函数可以进行LU分解,默认进行的是PLU分解,即A=PLU,其中P是置换矩阵,作用是交换矩阵的行、列。注意所有的方阵都可以进行PLU 分解。 ![PLU分解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/PLU.png) - Cholesky分解:适用于正定矩阵 `P280` Cholesky分解 (Cholesky decomposition) 是LU 分解的特例。丛书在讲解协方差矩阵(covariance matrix)、数据转换、蒙特卡洛模拟等内容都会使用Cholesky 分解。 Cholesky 分解把矩阵分解为一个下三角矩阵以及它的转置矩阵的乘积 A = LL^T .Numpy 中进行Cholesky 分解的函数为numpy.linalg.cholesky() `P281` Cholesky 分解可以进一步扩展为LDL分解 A = LDL^T。其中,L 为下三角矩阵,但是对角线元素均为1;D 为对角矩阵,起到缩放作用;几何角度来看,L 的作用就是“剪切”。也就是说,矩阵A 被分解成“剪切 → 缩放 → 剪切”。 LDL 分解的函数为scipy.linalg.ldl() - QR分解:正交化 `P282` QR分解 (QR decomposition, QR factorization) 和本书第9 章介绍的格拉姆-斯密特正交化联系紧密。QR 分解有两种常见形式:完全型 (complete),Q 为方阵;缩略型 (reduced),Q 和原矩阵形状相同。 完全型QR分解: X_(nxd) = Q_(nxn)R_(nxd),其中 Q是方阵且是正交矩阵(正交矩阵的含义是方阵,且列向量两两正交且列向量都是单位向量)。QR分解结果不唯一,但是,如果X 列满秩,且R 的对角元素为正实数的情况下QR 分解唯一。 ![完全型QR分解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/complete_QR.png) ![缩略型QR分解。此时Q不是方阵,但各列两两正交](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/reduced_QR.png) ![P285 QR分解的几何意义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/understanding_QR.png) - 特征值分解:刻画矩阵映射的特征 `P286` 特征值和特征向量的定义。不是所有方阵都可以进行特征值分解,只有可对角化矩阵才能进行特征值分解 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/eigen_decompsition.png) ![Ax=0,如果x不是零向量的话,则A的行列式比==0, 否则A就是各列线性无关,这种情况x必须是0](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/Ax_0.png) 对称矩阵 V^T = V^-1, 前提是逆矩阵存在 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/eigen_decomposition_2.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/characteristic_equation.png) ![普分解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/spectral_decomposition.png) ![对称矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/explain_symmetric_matrix.png) ![特征值分解的几何视角](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/understanding_eigen_decomposition.png) - 奇异值分解:适用于任何实数矩阵 如果特征值分解是“大菜”,奇异值分解绝对就是矩阵分解中的“头牌” ![svd定义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/svd_definition.png) ![svd和特征值的关系](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch11/characteristic_equation.png) `P291` 给出了手算svd的一个容易理解的案例 --- ### Cholesky分解 - Cholesky分解 `P296` 定义(A=LL^T或者A=R^TR),以及LDL分解(A=LDL^T,D是方阵,L的对角线元素都是1),并对LDL分解进一步写法,可以导出A的平方根项 - 正定矩阵才可以进行Choleskey分解 `P297` 正定矩阵的定义,同时指出只有正定矩阵才能进行Cholesky分解。正定矩阵都是对称方阵,且特征值都>0,且必满秩(正定矩阵满秩,都是线性无关的各列) ![正定矩阵定义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch12/positive_define_matrix.png) `P298` 给出了常见的正定型对应的几何图形 - 几何角度:开合 `P299` 本节针对一个特殊的矩阵P进行Cholesky分解 P = R^TR,分解完的R几何变换作用是“开合”,或者说R的作用可以把一个圆变成椭圆。 `P305` 这种类型的P矩阵,是本书之后要讲到的相关性系数矩阵,其中的余弦值相当于相对性系数 - 几何变换:缩放 -> 开合 `P302/P305` 以Σ矩阵(协方差矩阵)为例来讲Cholesky分解,分解后的 R_Σ的几何作用是:先(对原坐标系进行)缩放 -> 再(对缩放后的新的坐标系进行)开合 - 推广到三维空间 `P305` 将P矩阵从上面的2维扩展到3维来理解Cholesky分解,也是继续探讨分解后的R的几何作用 - 从格拉姆矩阵到相似度矩阵 `P309~P312`鸢尾花数据集X=[x1, x2, x3, x4],总共有4个特征,150个样本点(150行)。可以用X的格拉姆矩阵G=X^TX=4x4矩阵来表示x1,x2,x3,x4之间的关系。这里格拉姆矩阵是个4x4矩阵,包含4个向量两两长度和夹角余弦信息。对G矩阵再次进行Cholesky分解,可以得到更好更简洁的R矩阵(4x4),包含信息等价于上面的格拉姆矩阵。 ![格拉姆矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch12/grammar_matrix.png) `P311` 由于格拉姆矩阵含有向量长度信息,余弦相似度矩阵C只包含列向量的两两夹角cos信息。 相似度矩阵S和格拉姆矩阵的转换公式是: C= S^-1GS^-1 ![余弦相似度矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch12/cosine_similarity_matrix.png) --- ### 特征值分解 `P315` 本书第8章讲解线性变换时提到,几何视角下,方阵对应缩放、旋转、投影、剪切等几何变换中一种甚至多种的组合,而矩阵分解可以帮我们找到这些几何变换的具体成分。本章要讲的特征值分解能帮我们找到某些特定方阵中“缩放”和“旋转”这两个成分。 可对角化方阵才可以进行特征值分解。 `P286` 一般的特征值分解是: A = VΛV^-1,且特征向量矩阵的各列(特征向量)一般是单位向量 `P289` 如果A本身是对称矩阵,则 A=VΛV^T,即VV^T=I一个典型的对称矩阵是格拉姆矩阵XX^T和X^TX,各自得到的特征向量矩阵都是正交矩阵 `P324~326` A为对称矩阵的这种特征值分解也叫谱分解,因为特征值分解将矩阵拆解成一系列特征值和(特征向量张量积)之和。同时在这个基础上,将X往v(来源于格拉姆矩阵的v)投影,可以得到yj=Xv的投影结果,其结果和特征值λ有关! - 几何角度看特征值分解 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/transform_exam_1.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/transform_exam_2.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/transform_exam_3.png) - 旋转 -> 缩放 -> 旋转 `P318-P320` 特殊的矩阵:对称方阵的特征值分解,即谱分解来理解其几何意义 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/roate_scale_rotate.png) ![Aw=VΛV^-1w:对w先旋转V^-1在缩放Λ,再旋转V。图中的v1,v2是特征向量,所以结果这个过程后,方向一致,只是大小变量,其他单位圆上的向量方向都不一致。](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/roate_scale_rotate_2.png) ![特征值分解各个分量的含义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/understandint_ev_meaning.png) `P288` 特征向量一般是单位向量,除非特殊说明 - 再谈行列式值和线性变换 `P321` 如果A 可以进行特征值分解,矩阵A 的行列式值等于A 的所有特征值之积。特征值可以是正数/负数/0/复数 - 对角化、谱分析 `P323` 方阵可对角化概念,以及只有可对角化的矩阵才能特征值分解。 如果A可以对角化,则可以利用特征值分解,方便计算矩阵A的n次幂 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/diagonalizable.png) `P324` 如果矩阵A不仅可对角化,而且是对称矩阵,则可以将特征值分解 A=VDV^-1写成 A=VDV^T -> 这就是谱分解 其中D是特征值矩阵。格拉姆矩阵就符合可对角化且是对称矩阵,所以会被用于谱分解 - 谱分解可以得到特征值矩阵Λ=V^TAV,这个正好是二次型(含有距离平方的含义) - 用格拉姆矩阵G=X^TX带Λ=V^TAV中的A且令y_i=Xv_i,可以得到 (y_i)^Ty_i = λ_i - 可以用于解释||y_i||_2 = ||Xv_i||_x = λ_i。 - 这个可以用于最优化 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/spectral_decomposition.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/spectral_decomposition_2.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/spectral_decomposition_3.png) `P325` 同时以格拉姆矩阵为例来说明谱分析(以格拉姆矩阵为对称矩阵进行的案例) `P326` 从几何视角来理解格拉姆矩阵(以格拉姆矩阵为对称矩阵的案例)的谱分析,来说明特征值大小对特征值分解的重要性 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/glammer_spec_decomposition.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/glammer_spec_decomposition_2.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/spec_decomposition_exam1.png) ![案例:这里的X是数据矩阵, vj是X的格拉姆矩阵的特征值分解的V的各个特征向量。yj=Xvj,V各个列向量是相互垂直的。同时Xvj,把X分解开就是各个样本点, y1 = x1vj; y2 = x2vj ; ...](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/spectral_decomposition_4.png) - 聊聊特征值 `P328` 从几何角度来看,对角化实际上就是,平行四边形转化为矩形,或者,平行六面体转化为立方体的过程,这恰好和行列式联系起来。 作者这里用的是举例计算并推广的方法,从而得出 det(A)=det(Λ)。 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/dia_in_geo.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch13/dia_in_geo2.png) `P329` 列出了矩阵A的特征值的一些重要性质,如λA, A^n, A^-1的特征值和行列式的关系 - 特征值分解中的复数现象 `P330` 本书前文讲述的向量矩阵等概念都是建立在R^n 上,我们可以把同样的数学工具推广到复数空间C^n 上 `P331` 给出了特殊矩阵的例子并给出几何视角 --- ### 深入特征值分解 `P334` 汇总了特征值分解的应用场景 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch14/ev_application.png) - 方阵开方 `P335` A^p =VΛ^pV^-1, p可以是1/2, 3 - 矩阵指数 `P335~337` 可以从标量指数e^a的泰勒展开开始,类比得到 e^A - 斐波那契数列:求通项式 `P337~339` 介绍如何使用特征值分解推导得到斐波那契数列通项式,主要是要写出用矩阵表达的通项公式,就可以得到解析解 - 马尔科夫过程的平稳状态 `P339` 介绍了什么是马尔科夫过程:每晚有30%的小鸡变成小兔,其他小鸡不变;同时,每晚有20%小兔变成小鸡,其余小兔不变。这个转化的过程叫做马尔科夫过程。 `P340` 马尔科夫过程可以用转移矩阵表示,只要写出转移矩阵: Tπ(k) = π(k+1), T是转移矩阵。平稳态就是Tπ=π,这个正好就是特征向量的定义,就可以用特征值分解的方法求取。 - 瑞利商 `P342` 瑞利商的定义 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch14/rayleigh_quotient.png) `P343` 后面用分母为1,即x_1^2 + x_2^2 = 1来举例,求瑞利商的最大值和最小值。 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch14/rayleigh_quotient_2.png) - 再谈椭圆:特征值分解 `P346~P351` 一个圆,经过变换后会变成椭圆。这个变换过程是个缩放->旋转的过程,正好对应特征值分解的过程,椭圆形的长短轴信息和缩放有关,也即和特征值有关(等于特征值的开根号)。 也可以把这个过程理解为先缩放-> 剪切的过程,这个正好对应LDL分解。最后的结论用图标表示如下: ![这里的Λ以及V不是来自对称矩阵A的特征值分解,而是来自Q=(AA^T)^-1的特征值分解。书中也讲解了最后A对z的作用,即x=Az,相当于x=VΛ^(-1/2)z。这里没提到平移,平移是最后的。](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch14/tuoyuan_1.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch14/tuoyuan_2.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch14/tuoyuan_3.png) --- ### 奇异值分解 奇异值分解的U和V和特征值分解中的特征向量有关,奇异值和特征值有关,详见下文介绍。 - 几何视角:旋转(V^T) -> 缩放(S) -> 旋转(U) X = USV^T ![奇异值定义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch15/svd_definition.png) `P356` 任何实数矩阵都可以进行奇异值分解 - 不同类似的SVD分解 SVD 分解分为完全型 (full)、经济型 (economy-size, thin)、紧凑型 (compact) 和截断型(truncated) 四大类。本节将简要介绍完全型和经济型两种奇异值分解之间的关系。下一章将深入讲解这四种SVD分解。 `P359~P360` 介绍了完全型 、经济型 - 左奇异向量矩阵U `P360` U^TU=I `P361` 对方阵XX^T 进行特征值分解,可以发现U 的列向量是特征向量,而SS^T 是XX^T 的特征值矩阵 `P362` XX^T 进行特征值分解得到正交矩阵U = [u1, u2, ..., un] 是个规范正交基,张起的空间为R^n。对完全型SVD分解,U和V都是正交矩阵,详见上面的定义。 ![奇异值定义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch15/svc_qr.png) - 右奇异向量矩阵V `P363` 值得强调的是,凡是满足V^TV = VV^T = I 的方阵V 都是正交矩阵 (orthogonal matrix),对应规范正交基。前文提过,并不是所有正交矩阵都是旋转矩阵 (rotation matrix)。只有det(V) = 1 的正交矩阵才叫旋转矩阵,这种矩阵也叫特殊正交矩阵 (special orthogonal matrix)。也就是旋转前后面积不变。而一般正交矩阵的行列式值为±1,即det(V) = ±1。当det(V) = −1 时,V 对应的几何操作为“旋转 + 镜像”。这也告诉我们,SVD 分解中V 和U 并不唯一,V 和U 的列向量都可以取负。当det(V) = det(U) = −1 时,V 和U 都是“旋转 + 镜像”。但是为了方便,完全型SVD 结果中的V 和U,我们还是管它们的几何操作叫“旋转” `P364` 对X^TX 进行特征值分解,S^TS 为特征值矩阵。X^TX 进行特征值分解得到正交矩阵V = [v1, v2, ..., vD],它也是个规范正交基,张起的空间为R^D `P364` 奇异值分解不但可以分解各种形状实数矩阵,并且一次性获得U = [u1, u2, ..., un] 和 V = [v1, v2, ..., vD] 两个规范正交基 - 两个视角:投影和数据投影 `P365` XV=US -> Xv_j= s_j * u_j -> X 向vj 投影,结果为s_j * u_j ![PCA主成分分析](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch15/pca.png) `P366` X可以看成是通过叠加还原原始数据矩阵,或者张量积的和 --- ### 深入奇异值分解 本章深入介绍这四种奇异值分解:完全型、经济型、紧凑型、截断型 `P372` 经济型可以由完全型转变而来:完全型的S去掉零矩阵变成方阵 `P323~324` 当X非满秩时,奇异值有0的存在,进而可以由经济型转换为紧凑型。只有X 为非满秩情况下,才存在紧缩型SVD 分解。紧缩型SVD 分解中,U 和V 都不是方阵 `P374` 截断型svd:近似 ![截断型svd](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch16/trunctated_svd.png) ![截断型svd](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch16/trunctated_svd_2.png) `P375~P378` 经济型SVD 分解可以看成是一种张量积的和 ![svd的分解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch16/thin_1.png) ![svd中X的组成部分](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch16/thin_2.png) ![svd的张量积](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch16/thin_3.png) ![svd的正交投影理解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch16/thin_4.png) `P379~P381` 估计与误差:截断型SVD。把数据矩阵X 对应的热图看做一幅图像,本节介绍如何采用较少数据尽可能还原原始图像,并准确知道误差是多少,这也是主成分分析。同时有鸢尾花照片的PCA分析例子。 `P382` 用SVD找到一个V,来理解Z=XV,即X->Z的过程是正交化的过程:Z各列两两正交 ![从SVD角度理解XV](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch16/orth_1.png) ![从SVD角度理解XV](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch16/orth_2.png) --- ### 多元函数微分 一阶偏导数 -> 梯度向量 -> 上山方向 二阶偏导 -> 黑塞矩阵 - 偏导:特定方向的变化率 `P388` 一个多变量的函数的偏导数是函数关于其中一个变量的导数,而保持其他变量恒定。通俗地说,偏导数关注曲面某个特定方向上的变化率。换个角度,一元函数导数这个工具改造成偏导数后,可以用在多元函数上 ![P389~390 二元函数一阶偏导数的向量形式,也叫梯度向量(gradient vector),在2个方向上的偏导数](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/partial_derivative_vec_form.png) `P389~P391` 分别介绍一次多元函数(x1,x2项最高是一次方),二次多元函数(最高项是二次方),以及二次型的(x^TQx)的矩阵形式的一阶偏导数有个总结,方便和Maxtrix Cookbook对照 `P391~P392` 黑塞矩阵 (Hessian matrix) 是一个多元函数的二阶偏导数构成的方阵,黑塞矩阵描述了函数的局部曲率。本书后续会在优化问题中用到黑塞矩阵判断极值点 ![黑塞矩阵定义以及二阶偏导数顺序,以及二次型的黑塞矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/hessian_matrix.png) - 梯度向量:上山方向 ![梯度向量:Nabla算子](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/gradient_vector_definition.png) `P393` 几何视角来看梯度向量,如图 2 所示,在坡面P 点处放置一个小球,轻轻松开手一瞬间,小球沿着坡面最陡峭方向 (绿色箭头) 滚下。瞬间滚动方向在平面上的投影方向便是梯度下降方向(direction of gradient descent),也称“下山”方向。 数学中,下山方向的反方向即梯度向量方向,也称作“上山”方向。 `P393` 梯度向量场的理解 ![梯度下降方向](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/gradient_descent.png) ![梯度向量场](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/gradient_vector_field.png) `P393~P395` 分别以一次函数、二次函数和复合函数的例子来解释梯度向量,来理解“局部”最大值和最小值。(局部最大值点附近,梯度向量均指向局部最大值点。局部最小值点附近,梯度向量均背离局部最小值点) `P394` 如果我们现在处于曲面上某一点,沿着下山方向一步步行走,最终我们会到达最小值点处。这个思路就是基于梯度的优化方法。当然,我们需要制定一个下山的策略。比如,下山的步伐怎么确定?路径怎么规划?怎么判定是否到达极值点?不同的基于梯度的优化方法在具体下山策略上有差别。这些内容,我们会在本系列丛书后续分册中讨论。 - 法向量:垂直于切平面 `P396` 给出了求法向量的公式,非常重要!重要视角:法向量向[x1, x2, x3...] 平面投影便得到f(x) 的梯度向量 ![法向量公式,之所以是-1,是因为▽F(x,y)是F对x求偏导,和对y求偏导](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/n_vector.png) ![梯度向量都是在自变量平面内](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/n_vector_2.png) `P397` 还举例了不同的函数的法向量场以及在水平面上的投影,来说明最大最小值的梯度向量的特点 - 方向性微分:函数任意方向的变化率 `P398` 光滑曲面 f(x1, x2) 某点的切线有无数条,而偏导数仅仅分析了其中两条切线的变化率,它们分别沿着x1 和x2 轴方向。方向性微分 (directional derivative),它可以分析光滑曲面某点处不同方向切线的变化率 ![方向性微分](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/directional_derivative.png) `P398~402` 以曲面上的P点到Q点为例,如果根据P点近似得到Q点呢:可以用多元函数泰勒一阶展开来近似:在P点做一个切平面,然后沿着这个切平面移动△x1,△x2,就近似得到Q点 ![二元函数泰勒一阶展开](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/directional_derivative_2.png) ![沿着x1,x2这个方向](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/directional_derivative_3.png) ![方向还是用单位向量来表示](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/directional_derivative_4.png) ![方向性微分和偏导数之间的关系:注意▽底下有个v](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/directional_derivative_5.png) - 泰勒展开:一元到多元 泰勒展开可以用于一元/多元函数的逼近,包括一次逼近(线性逼近)和二次逼近。 `P402` 回顾一元函数泰勒展开 ![一元函数泰勒展开](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/single_value_taylor_expansion.png) `P403` 多元函数的线性逼近,即一阶泰勒展开,并和一元函数的对比 ![多元函数的线性逼近(一次逼近)](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/mv_linear.png) ![线性逼近](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/mv_linear_2.png) `P404` 给出了多元函数的二次逼近,即二阶泰勒展开,里面涉及到黑塞矩阵, 也部分涉及到正定性。注意二阶泰勒展开中的二次型是: 1/2(△x)^T* H* △x,这和黑塞矩阵的正定性有关联 ![多元函数的线性逼近(二次逼近)](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/second_order.png) `P404~405` 利用法向量推导了二次曲线在某一点处的切平面公式并举例说明 ![二次曲面切平面](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/quad_curve_1.png) ![二次曲面切平面](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch17/quad_curve_2.png) ### 拉格朗日乘子法 拉格朗日乘子法就是一种能够把有约束优化问题转化成无约束优化问题的方法 - 回归优化问题 `P409` 一般情况下,标准优化问题都是最小化优化问题。最大化优化问题的目标函数取个负号便转化为最小化优化问题 ![含约束最小化优化问题](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/optimal_question.png) - 等式约束条件 不管是线性等式还是非线性等式约束,都可以通过构造拉格朗日函数: L(x,λ) = f(x) + λh(x)来将其转换为无约束优化问题 `P410~P413` 给出了这种情况下获取最优解必须满足的条件:拉格朗日函数L(x,λ)的一阶偏导数为零,即 ▽f(x) + λ▽h(x) = 0,即f(x) 和h(x) 在驻点x 处梯度同向或者反向。 根据该式求得的驻点(偏导数为零的点)x, 进一步判断驻点是极大值、极小值还是鞍点 ![理解拉格朗日乘子法:梯度一定是基于等高线的!](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/understanding_Lagrange_Multiplier.png) ![理解拉格朗日乘子法](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/understanding_Lagrange_Multiplier_2.png) - 线性等式约束 `P414` 用一个线性等式约束例子来讲解拉格朗日乘子法。其中也有对(等高)直线的梯度垂直于直线的理解。 `P415` 给出了拉格朗日函数的另一种计法:L(x,λ) = f(x) - λh(x) - 非线性等式约束 `P415` 用一个非线性等式的例子来讲解拉格朗日乘子法 - 不等式约束 本节介绍如何用KKT (Karush-Kuhn-Tucker) 条件将本章前文介绍的拉格朗日乘子法推广到不等式约束问题 `P417~419` 总结了只有不等式约束 + 既有不等式又有等式约束的最小值问题的KKT条件 - 再谈特征值分解:优化角度 `P420` 这一节介绍一些线性代数中会遇到的含约束优化问题。利用拉格朗日乘子法,它们最终都可以用特征值分解求解。包含二次型、瑞利商等的最优解。这回用到后面的矩阵范数中。 ![这个优化问题,会用到后面的矩阵范数中](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/SVD_in_opt.png) ![矩阵范数是max,这里是min。不过没关系,后面的svd中会讲到max/min对应最大特征值](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/SVD_in_opt_2.png) 特征值分解和奇异值分解有关系,特征值和奇异值是平方关系,特征值分解的分解矩阵也有关系,具体看SVD分解。 - 再谈SVD:优化视角 数据矩阵X 中任意行向量x(i) 在单位v向量 上投影,得到标量投影结果为y(i)。y(i) 就是x(i)在v 上坐标,h(i) 为x(i) 到v 的距离。整个数据矩阵X 在v 上投影得到向量y:Xv= y ![一个样本点在某个方向的投影:这个方向必须是单位向量才是xv=y。(身高、体重、年龄)在(1/2身高、1体重、1年龄)方向上的投影:是个标量](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/SVD_in_opt.png) ![数据矩阵X在v上的投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/SVD_in_opt_2.png) `P424` 在Xv=y中, 从优化问题角度,SVD 分解等价于最大化y(i) 平方和。其中X为数据矩阵,v为优化变量(只有一个方向)。 `P424-425` 对一个数据矩阵X,SVD分解得到的V的含义是,X(所有样本点)往v1(V中的第一列,对应最大特征值λ1)投影等价于最大化投影结果y(||y1||==||Xv1||)的摸,且其值为开根号(λ1)。有了v1以后,再构造优化问题,求取X往v2投影的最大值: ||Xv2||=||y2||,满足条件是v1⊥v2且是单位向量。 ![特征值分解和SVD分解是有联系的,详细查看SVD分解那一章](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/understandint_ev_meaning.png) `P425` 数据矩阵X,其中心化数据矩阵表示为Xc。对中心化数据矩阵Xc进行SVD分解,会和协方差矩阵联系到一起。 - 矩阵范数:矩阵 -> 标量,矩阵“大小” `P426` 矩阵范数借鉴了向量范数。向量范数代表某种距离,矩阵A的范数,也需要向量x的参与计算 ![矩阵范数定义,这用到了上面提到的优化问题,只不过那边是min,这里是max,正好是对应最小/最大特征值](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/matrix_norm.png) `P428` 介绍了矩阵F范数。一些知识点:矩阵A 的所有元素平方和就是A 的格拉姆矩阵的迹。矩阵的迹等于其特征值之和。 - 再谈数据正交投影:优化视角 `P428` 数据矩阵X(假设是150x2,150个样本点,2个特征),可以往一个规范正交基V=[v1, v2]上投影,往v1方向标量投影得到y1=Xv1, 往v2方向标量投影得到y2=Xv2。y1是个150x1的列向量,y2也是如此。 ![数据正交投影](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/X_proj_in_x1_x2.png) `P430` y1,y2向量有内积,夹角,余弦值可以用来衡量y1,y2之间的关系。y1和y2两个列向量随theta(v1和x轴夹角)而变换,即上述几个量值(内积、夹角、余弦值)会随着theta变换。有了变化,就会有最大值、最小值,这就进入了优化视角。 `P430` Y=[y1,y2]=XV,Y也有格拉姆矩阵G_Y, G_Y和G_X和v1,v2有关 -> G_y = V^TG_xV `P430` 统计视角,y1,y2本身有均值(E(y1), E(y2)),方差(var(y1),var(y2)),标准差(std(y1), std(y2));而y1, y2之间也有协方差cov(y1,y2),相关性系数corr(y1,y2)。上述所有这些统计量同样随着theta变换。 ![y1,y2的统计特征](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/y1_y2_character_vector.png) ![y1,y2的统计特征](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/cov_y1_y2.png) `P432` 列出了y1,y2各个量化指标随正交投影的投影方向theta的变化图。其中一些曲线特点,用到了矩阵trace特性,也讲到如果V是来自特征值分解的一些曲线特征。 ![y1,y2的统计特征](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/understanding_y1_y2.png) - (补充<数学要素>)标准差:离散程度 `P424` 标准差描述一组数值以均值 µ 为基准的分散程度 ![方差,最后取均值](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/standard_d.png) - (补充<数学要素>)协方差:联合变化程度 `P425-P427` 协方差 (covariance) 描述的是随机变量联合变化程度。白话讲,以花瓣长度和宽度数据关系为例,我们发现如果样本数据的花瓣长度越长,其花瓣宽度很大可能也越宽。这就是联合变化。而协方差以量化的方式来定量分析这种联合变化程度。备注:花瓣长度用的是一个列向量表示(一组随机变量)、花瓣宽度同理。协方差描述的就是这2组样本特征向量的联合变化关系。 ![协方差定义:是个平均值的概念。统计的时候是每朵花的2个特征和这2个特征的均值差做面积,然后再取平均值](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/covariance_definition.png) ![协方差](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/understanding_covariance.png) ![协方差矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/covariance_matrix_1.png) ![协方差](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/covariance_matrix_2.png) - (补充<数学要素>)线性相关系数:线性关系强弱 `P429` 可以根据两个随机变量(随机变量特征1的样本向量,随机变量特征2的样本向量)的协方差,定义线性相关系数。线性相关系数也叫皮尔逊相关系数,它刻画随机变量线性关系的强度。线性相关系数相当于协方差归一化,归一化的线性相关系数比协方差更适合横向比较。 ![线性相关系数](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/linear_corr_coef_1.png) ![线性相关系数:几何含义](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/linear_corr_coef_2.png) `P430` 相关性系数构成的矩阵叫做相关性系数矩阵 ![相关性系数矩阵](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/correlation_matrix_1.png) ![相关性系数矩阵2](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch18/correlation_matrix_2.png) --- ### 直线到超平面 - 切向量:可以用来定义直线 `P439~P440` 切向量用τ表示,单位切向量用hat(τ)。切向量可以用来描述平面直线和三维空间直线等 ![切向量定义直线](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch19/line_in_plane.png) ![切向量定义直线](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch19/line_in_3d_plane.png) - 法向量:定义直线、平面、超平面 `P442` 给定平面(2维平面or超平面)上一点和平面法向量n,可以确定一个平面。n维平面只有一个方程。 - 超平面:一维直线和二维平面的推广 `P443` 超平面定义: w^Tx+b=0,其中w是列向量,也是超平面的法向量!用内积形式表示是:w·x + b = 0 `P445` 超平面是个多元一次函数 理解:w^T[x+(w^T)^-1*b]=0,即法向量垂直于平面内的直线 - 平面与梯度向量 `P446` 超平面函数,即多元一次函数 f(x)=w^Tx+b的梯度向量正好是w,即超平面的法向量 ![平面与梯度向量](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch19/plane_grandient.png) - 中垂线:用向量求解析式 `P451` 利用向量求解中垂线的解析式 ![中垂线:向量减法的直观理解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch19/perpendicular_bisector.png) - 用向量计算距离 `P453~P456` 列出了点面距离、正交投点坐标、向量在过原点平面内投影、平行面距离的公式 --- ### 再谈圆锥曲线 - 无处不在的圆锥曲线 `P459` 圆锥曲线是二次曲线,同时给出了其矩阵表达: (1/2)x^TQx + w^Tx + F = 0, Q的行列式决定了圆锥曲线的性质(椭圆、抛物线、双曲线),其中Q是对称矩阵,具体值(来自于解析式) `P460` 对双曲线矩阵求一阶导数(矩阵求导),利用到了 Matrxi Cook中的相关公式。圆锥曲线中心点的坐标推导用到了矩阵一阶导数 - 正圆:从单位圆到任意正圆 `P460` 单位圆的解析式: x^Tx -1 = 0 `P461` 半径为r的正圆解析式 x^Tx -r^2 = 0 -> x^T [S^-1] [S^-1]x - 1 = 0 -> 从这里可以分析S起到的缩放作用 `P461` 圆形位于 [c1, c2]^T的任意正圆表达式的矩阵形式和熟悉的解析式/代数形式 -> 上面的缩放 + 圆形位置的平移 `P462~P463` 给出了:单位圆通过“缩放+平移”,得到圆心位于c且半径为r的圆的图解。 ![z和x的变换关系,带动了原来的正圆到一般正圆的图形变换](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/z_x_relations_in_circle.png) ![从单位圆到一般正圆:z1/z2是正圆在坐标系,x1/x2是一般正圆的坐标系, x1/x2和z1/z2有变换关系:z先等比例缩放再平移得到x](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/unit_circle_to_general_circle.png) - 单位圆到旋转椭圆:缩放 -> 旋转 -> 平移 `P463` 正圆坐标系z变换到椭圆坐标系x下的公式 ![z和x的变换关系,带动了原来的正圆到椭圆的图形变换: z->x的过程是缩放->旋转->平移的过程](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/axix_with_elippse.png) ![从正圆到椭圆的变换:z是单位正圆,x是椭圆坐标系](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/transform_to_ellipse.png) `P465` 椭圆x->单位正圆z的过程是:平移->旋转->缩放的过程 ![x->z的过程,以及椭圆解析式](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/x_to_z.png) `P465` 已经知道z和x的关系,这里进行带入,可以得到旋转椭圆x的表达式,化简为 (x-c)^T Q(x-c) - 1 = 0 `P465` 对Q进行特征值分解研究,发现Q的特征值矩阵和缩放矩阵S有关系,也即得到椭圆半长轴和半短轴长度和矩阵Q 特征值之间的关系 `P466` 给出一系列不同旋转角度椭圆解析式和对应Q 的特征值分解。表中给出了不同椭圆的半长轴和半短轴长度保持一致,唯一变化的就是旋转角度。大家如果对几个不同Q 特征值分解,容易发现它们特征值完全相同,也就是椭圆的半长轴、半短轴长度一致。 `P467` 给出了没有平移项的旋转椭圆解析式,会发现解析式特别负责。而用矩阵形式的解析式 (x-c)^T Q(x-c) - 1 = 0 就特别简洁,而且还能利用矩阵工具分析出椭圆的几何特点,如中心位置、长短轴长度、旋转等。 - 多元高斯分布:矩阵分解、几何变换、距离 `P468` 介绍如何用上一节介绍的“平移 → 旋转 → 缩放”解剖多元高斯分布。“平移 → 旋转 → 缩放” 是椭圆变单位正圆的过程。 `P468` 多元高斯分布的概念,其中有部分结构和旋转椭圆解析式一致,其中的Σ取不同形态还会一想到椭圆的形状 ![多元高斯分布,其中Σ是协方差矩阵,P468](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/PDF_1.png) 多元高斯分布中的x,其实是多元函数的各个变量,如x=(花瓣长、花瓣宽、花萼长、花萼宽)。公式里面的x是个变量,可以画出曲线。一个样本点(含有4个特征),是一个x的特定值。 `P469` 对协方差矩阵进行特征值分解,并化简多元高斯分布中的椭圆解析式。化简后的椭圆解析式中的平移、旋转、缩放参数和特征值分解的V和Λ有关,并用一元高斯分布的概率密度函数做举例。其实都是前面二次型而二次曲线的关系的应用。 ![对PDF中的部分进行特征值分解](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/PDF_2.png) ![从N(μ,Σ) -> N(0,I)](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/PDF_3.png) `P470` 可以将 (x-μ)^TΣ^(-1)(x-μ) 写成L^2范数平方的形式,从而得到马氏距离。注意马氏距离的表达式,其实是欧拉距离x^Tx的扩宽,总之都有距离信息。马氏距离,也叫马哈距离 (Mahal distance),全称马哈拉诺比斯距离 (Mahalanobis distance)。马氏距离是机器学习中重要的距离度量。马氏距离的独特之处在于,它通过引入协方差矩阵在计算距离时考虑了数据的分布。此外,马氏距离无量纲量 (unitless 或dimensionless),它将各个特征数据标准化 ![马氏距离定义,针对多元高斯分布的](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/definition_mahal_distance.png) `P471` 中用鸢尾花的2个特征为案例,对比了欧氏距离和马氏距离 ![欧氏距离和马氏距离](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/mahal_distance.png) `P472` 左图所示的两个同心圆距离质心μ 为1 cm 和2 cm。欧氏距离显然没有考虑数据之间的亲疏关系。举个例子,左图中红色点 ● 距离质心的欧氏距离略大于1 cm。但是对于整体样本数据,● 显得鹤立鸡群,格格不入。右图中红色点 ●,它的马氏距离远大于2。也就是说,考虑整体数据分布亲疏情况,红色点 ● 离样本数据“远的多。可以用scipy.spatial.distance.mahalanobis() 函数计算马氏距离,Scikit-Learn 库中也有计算马氏距离的函数。 `P472` 将马氏距离d 代入多元高斯分布概率密度函数,看到高斯函数把“距离度量”转化成“亲近度” ![高斯函数和马氏距离](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/gaussian_function.png) `P473` 解释了多元高斯分布的概率密度函数的**分母**中的|Σ|^(1/2)的理解,,对应到分子就是|Σ|^(-1/2)。这里关键是|Σ^(-1)|表示行列式,注意行列式是这个变换(Σ^-1)的体积 `P473` 介绍了父母中的常数项的作用:分母中(2π)^(D/2) 一项起到归一化作用,为了保证概率密度函数曲面和整个水平面包裹的体积为1,即概率为1 `P474` 汇总了PDF的直观理解 ![高斯函数和马氏距离。分母的|Σ|的理解,关键是知道行列式是表示体积](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/understanding_pdf.png) - 从单位双曲线到旋转双曲线 `P474` 前面讲过怎么从单位正圆到一般椭圆的变换,这一节将如何从单位双曲线到一般双曲线的转换。总结就是对单位正圆的z,首先对z 通过S 缩放,再通过R 逆时针旋转θ,最后平移c,得到的x坐标系,就会将z下的单位双曲线变换为一般双曲线 - 切线:构造函数,求梯度向量 `P476` 给出了二次椭圆、二次双曲线在任意点的切线的解析式。法向量即为二元函数的梯度,然后通过切向量和法向量垂直的关系,可以求得切向量。 `P478` 给出了一般圆锥曲线(二次)的切线解析式 - 法线:法向量垂直于切向量 `P479` 给出了标准椭圆上点P(p1,p2)处的切向量τ并推导了法线公式。同时也给出了一般圆锥曲线的切向量和法线方程 补充知识:椭圆切向量(一般圆锥曲线切向量)的理解 ![椭圆切向量公式](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/understand_tangent.png) ![切向量理解1:直接求导](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/tangent_1.png) ![切向量理解1:直接求导](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/tangent_2.png) ![切向量理解2:对构造的f进行求导的理解,注意切线和f没关系,是x1,x2之间的关系](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch20/tangent_3.png) --- ### 曲线和正定性 - 正定性 `P483` 正定性的定义,以及判定矩阵是否为正定矩阵的2种方法:特征值分解(要求对称矩阵)和Cholesky分解 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch21/check_possitive.png" alt="判定正定矩阵" style="width:100%;"> <div style="width: 100%;"></div> </div> `P484` 格拉姆矩阵至少是半正定矩阵 - 几何视角看正定性 `P485` 不同正定性的几何意义 - 开口朝上抛物面:正定 - 山谷面:半正定 - 开口朝下抛物面:负定 - 山脊面:半负定 - 双曲抛物面:不定 - 多极值曲面:局部正定性 `P497~498` 一般多元函数,在梯度向量为0的xp处,根据黑塞矩阵的正定性判断xp是极大值还是极小值 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch21/Hessian_positive.png" alt="一般多元函数判断,联合梯度和黑塞矩阵判断极值点" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch21/understanding_extream_value.png" alt="黑塞矩阵正定性和特征值分析" style="width:100%;"> </div> --- ### 数据与统计 本章以鸢尾花数据为例,给出了均值、质心、中心化、方差、协方差、相关性系数等的例子 - 统计+线性代数:以鸢尾花数据为例 - 均值:线性代数视角 `P503` 均值,以鸢尾花数据集X为例,就是每个特征的均值,有4个特征(4列),所以有4个均值。 E(x_j) = E(Xj)= 标量。 j表示第几个特征,或者第几列。 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/centroid_1.png" alt="均值的定义" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/understand_Ex_I.png" alt="xj向量在1方向的投影和均值E(xj) 关系" style="width:100%;"> </div> - 质心:均值排列成向量 主要讲了本书中质心的符号表示 `P506-507` 质心是各个特征的均值构成的列向量, μX是列向量。这本书还将E(X)定义为行向量,等于 (μX)^T。但同时本书也说明了,E(chi)还是列向量。 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/centroid_2.png" alt="质心的列向量符号约定" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/centroid_3.png" alt="质心的行向量符号约定" style="width:100%;"> </div> - 中心化:平移 `P508` 介绍质心 Xc=X-E(X),注意Xc还是150x4,相当于每个样本(的4个特征) - 均值 `P508` 介绍了中心化矩阵Xc=MX=X-Ex,M就是中心化矩阵。中心化矩阵M可用后后面的协方差的计算(`P515`) `P509` 介绍了对Xc进一步标准化,就是Z分数,含义是距离均值若干倍的标准差偏移。比如说,标准化得到的数值为3,也就是说这个数据距离均值3 倍标准差偏移。数值的正负表达偏移的方向。 `P509` 介绍了数据惯性(inertia)SSD的概念 - 分类数据:加标签 - 方差:均值向量没有解释的部分 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/variance.png" alt="方差和均值的关系" style="width:100%;"> <div style="width:100%;"></div> </div> - 协方差和相关性系数 `P514` 协方差定义。 x^Ty=y^Tx=标量。理解的时候,把x和y理解成数据矩阵X的一列(e.g, 第一列,第3列),x和y的每行都是一个样本的某个特征值 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/deduce_cov_2.png" alt="协方差的矩阵写法和代数写法.(40)中也给出了协方差和方差/相关系数的关系" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/deduce_cov.jpg" alt="协方差矩阵推导" style="width:100%;"> </div> `P515~P516` 给出了相关性系数、协方差的定义及向量写法。同时说明了相关性系数和余弦相似度类似,取值范围都是[-1,1]。最后总结了2个随机变量的方差和协方差的关系、这个关系和余弦定理类似。或者说余弦定理可以用在向量内积和协方差上。 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/cosine_rule.png" alt="余弦定理可以用在向量内积和协方差上" style="width:100%;"> <div style="width:100%;"></div> </div> - 协方差矩阵和相关性系数矩阵 `P517` 给出了协方差矩阵的定义和用数据矩阵X来计算Σ `P517` 对协方差矩阵求二次型,x^TΣx,其图像是一般椭圆(不带平移,带平移的话就是(x-μ)$^TΣ(x-μ)),然后对Σ进行特征值分解后带入x^TΣx并新增变换y=V^Tx进行简化,会得到一般旋转椭圆(x坐标系)到正椭圆(y坐标系)的几何转换 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/covariance_maxtrix_definition.png" alt="" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch22/covariance_matrix_curve.png" alt="" style="width:100%;"> </div> `P518` 相关性系数矩阵定义 --- ### 数据空间 - 从数据矩阵X说起 `P526 ` 再次明确了本书的各类符号 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch23/notation.png" alt="" style="width:100%;"> <div style="width:100%;"></div> </div> - 向量空间:从SVD分解角度理解 介绍X列向量和行向量张成的四个空间以及它们之间关系 `P527` 列向量:列空间、左零空间;行向量:行空间、零空间 `P528` 总结前面所学,再次来认识完全型SVD分解 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch23/understand_svd.png" alt="S叫奇异值矩阵" style="width:100%;"> <div style="width:100%;"></div> </div> - 紧凑型SVD分解:剔除零空间 `P529~531` 从紧凑型SVD分解讲解4个空间 [4个空间.excalidraw](https://github.com/wumin199/wm-blog-image/blob/raw/main/images/2023/power-of-matrix/4_spaces.excalidraw) - 几何视角说空间 `P532~536` 用实际例子解释了 XV=US 以及 X^TU=VS^T。如何找到U和V呢,可以用SVD和特征值分解,注意特征值分解也可以得到U和V,不是过不是直接对X特征值分解,而是对XX^T特征值分解 -> U; X^TX特征值分解可以得到V 需要重新理解下:[XV和XVV^T的理解.drawio](https://github.com/wumin199/wm-blog-image/blob/raw/main/images/2023/power-of-matrix/power-of-matrix.drawio) 可以对任意矩阵进行SVD并得到UVS,而只能对可对角化矩阵进行特征值分解,所以这里构造了XX^T和X^TX来得到U和V 从前文的SVD分解中得知,SVD的U和V就是和特征值分解是有关系的。 - 格拉姆矩阵:向量模、夹角余弦值的集合体 `P538` X的格拉姆矩阵有G=X^TX和H=XX^T。 格拉姆矩阵G包含信息:X 列向量的模、列向量两两夹角余弦值 格拉姆矩阵H包含的信息:X 行向量的模、行向量之间两两夹角余弦值 `P539` 特征值分解可以知道SVD分解中的U和V,且特征值非零部分都一样(其他的都是零,零的数量不一样) 对G特征值分解 -> V 对H特征值分解 -> U 对G和H特征值分解的结果:2个分解的非零特征值都一样,且和X的奇异值是开根号的关系 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch23/gram_matrix.png" alt="" style="width:100%;"> <div style="width:100%;"></div> </div> - 标准差向量:以数据质心为起点 `P540` 协方差矩阵可以看成特殊的格拉姆矩阵。有X,X_c, Z_x,他们各自有4个空间 `P541` 介绍了标准差向量,可以用于协方差矩阵中。标准差向量是认为构造出来的 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch23/standard_deriva_vector.png" alt="标准差向量:以E(x)为起点,以x1为终点,长度为标准差的向量。其中的sqrt(n-1)应该是没有用的,是为了让其平方就等于δ^2" style="width:100%;"> <div style="width:100%;"></div> </div> - 白话说空间:以鸢尾花数据为例 `P543-P546` 以鸢尾花数据为例,解释了4个空间,其中的行空间用到了y=Xv的欧氏距离等于对应的特征值的前置知识。 --- ### 数据分解 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch24/data_decomposition.png" alt="" style="width:100%;"> <div style="width:100%;"></div> </div> - 为什么要分解矩阵 `P551` 总结了4中常见矩阵分解的前提,几何视角,特殊类型,向量空间和优化视角 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch24/decomposition_1.png" alt="" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch24/decomposition_2.png" alt="" style="width:100%;"> </div> `P552` 谱分解、特征值分解和奇异值分解的关系 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch24/relation_decomposition.png" alt="" style="width:100%;"> <div style="width:100%;"></div> </div> `P554` 介绍了本书中用到的会对其进行分解的矩阵,如X,Σ,G等 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch24/related_X.png" alt="" style="width:100%;"> <div style="width:100%;"></div> </div> `P555` 各类矩阵(X、Xc、Zx、G、Σ、P)和矩阵分解之间的关系 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch24/matrix_and_matrix_decomposition.png" alt="" style="width:100%;"> <div style="width:100%;"></div> </div> - QR分解:获得正交系 `P555` 对X进行QR分解,Q 的列向量 [q1, q2, q3, q4] 是规范正交基。[q1, q2, q3, q4] 相当于 [x1, x2, x3, x4] 正交化的结果,x1 和q1 平行。QR 分解和格拉姆-施密特正交化 (Gram–Schmidt process) 之间联系 - Cholesky:找到列向量的坐标 `P557` X是n x D,通过对G=X^TX进行 Cholesky分解,可以得到R(DxD的矩阵),R可以装下nxn的所有数据 `P558` 协方差矩阵再次用到标准差向量来表示 - 特征值分解:获得行空间和零空间 对数据的格拉姆矩阵、协方差矩阵、相关性系数矩阵进行特征值分解,并从优化角度解释其含义 `P560` 特征值分解格拉姆矩阵对应的优化问题——找到一个单位向量v,使得X 在v 上投影结果y 的模最大。另有:特征值分解得到的特征值之和,等于原矩阵对角线元素之和 `P561` 对协方差矩阵特征值分解,就是要找到一个单位向量v,使得中心化数据Xc在v 上投影结果yc 的方差最大。另有:Σ 的特征值之和,等于X 的每列数据方差之和 `P562` 也对相关性系数矩阵进行特征值分解并解释其含义,不过不太懂 - SVD分解:获得四个空间 `P563~P564` 分别对原始数据矩阵X,中心化数据Xc,标准化数据Zx,进行SVD分解,可以获取其4个空间 --- ### 数据应用 - 从线性代数到机器学习 `P570` 介绍了有监督学习(回归、分类)、无监督学习(降维、聚类)的概念。其中《数据有道》讲回归、分类;无监督学习讲降维、聚类。 本书是:一元到多元的基础,如多元微积分、多元概率统计、多元优化等 - 从随机变量的线性变换说起 `P572` 介绍了随机变量X的**线性变换**,可以得到Y,并得到期望和方差之间的关系。如Y=aX+b,则E(Y)=aE(X)+b, var(Y)=var(aX+b)=a^2var(X) `P572` 介绍了二元随机变换,如果是线性映射,其期望和方差之间的关系 <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch25/2_variable_X.png" alt="" style="width:100%;"> <div style="width:100%;"></div> </div> `P573` 扩展到D维随机变量:可以认为X的一列就是1个随机变量,一般可能有4列 - 单方向映射 hat(y) = Xv `P574-577` 数据矩阵X的每一列被当成了随机变量,然后从线性变换的列空间(投影)和行空间(降维)视角看单方向映射,并给出了期望、方差及几何视角 var(hat(y)) = v^T(Σ_X)v <div style="display: flex; justify-content: center; align-items: center;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch25/single_direction.png" alt="投影和降维" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch25/Ex_single_direction.png" alt="期望" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch25/var_single_direction.png" alt="方差,是个变量" style="width:100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch25/understandign_single_direction.png" alt="几何视角" style="width:100%;"> </div> - 线性回归 上一节是投影,没有残差。这一节是回归,有残差。 y = Xb + ε 目标是找到这样的b,使得ε最小。 `P579~582` 分别从投影视角、QR分解、奇异值分解、最优化(最小二乘法OLS,即求导法)角度给出b的值 其中用最小二乘法,用到了矩阵求导:一阶和二阶求导,参考了`<the matrix cookbook>` 的(69)(81)(98) - 多方向映射 Y=XV `P582~583` 给出了X向多个方向投影的向量空间理解,以及期望,协方差 协方差:Σ_Y=V^T(Σ_X)V - 主成分分析(PCA) `P584` 主成分分析就是多方向映射 通过线性变换,PCA 将多维数据投影到一个新的正交坐标系,把原始数据中的最大方差成分提取出来。PCA 也是数据降维的重要方法之一。 作为重要的降维工具,PCA 可以显著减少数据的维数,同时保留数据中对方差贡献最大的成分。另外对于多维数据,PCA 可以作为一种数据可视化的工具 给出了PCA六条主要技术路线,其中用到了奇异值分解、特征值分解两种矩阵分解工具。矩阵分解的对象对应六种不同矩阵,这六种矩阵都衍生自原始数据矩阵X ## 费曼笔记 - 线性代数中的线性是什么意思 - 矩阵运算符号 列向量·列向量 -> 逐项积/内积/标量积/点积,< v1,v2 > == < v2, v1> == 列向量v1·v2 == v2·v1 == 矩阵乘法:(v1)^T(v2) == (v2)^T(v1) == (a_1 * b_1 + a_2 * b_2) == ||v1||||v2||cos(θ) (`P218`) -> 有转置的是矩阵运算,有·的是向量内积运算 列矩阵 @ 行矩阵 或者 (列矩阵)(行矩阵)(中间没有点)-> 矩阵乘法,是个长方形矩阵 -> 有@符号或者没有·的运算直接相乘,都是矩阵运算,即使是写成向量方式 列向量 ⊗ 列向量 -> 张量积,是个矩阵,同 列矩阵 @ 行矩阵 列向量 x 列向量 -> 叉积,结果是个向量,方向是右手法则 - 左乘还是右乘 - 取决于是行向量还是列向量 - 如果 x是列向量,则 BAx = b 的意思是先进行A再进行B - 在上面的基础上进行转置,则是(x^T)(A^T)(B^T)=b^T,此时x^T是行向量,此时先进行A^T变换,再进行B^T变换,得到b^T - 在运动学中,分为绕固定轴或者旋转轴 - 以列向量代表点位,则:左固右动 - 样本点、行向量/列向量与矩阵M 约定俗成,各种线性代数工具定义偏好列向量;但是,在实际应用中,更常用行向量代表数据点。两者之间的桥梁就是——转置。 如本书中的: ![鸢尾花数据矩阵X](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch01/IrisDataSet.png) 我们常见的Ax=b -> 这里的x是一个列向量,即一个样本点(花萼长宽/花瓣长宽),b也是一个列向量(样本点)。 A的每一列可以看成是新的坐标系的坐标轴的值,b是x在新坐标系下的每个坐标的坐标值。如果是很多个样本点,则是AX=B。 <div style="display: flex;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch07/coordinate-values.png" alt="坐标值的理解" style="width: 100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch07/matrix-basis.png" alt="坐标系和坐标值" style="width: 100%;"> </div> <div style="display: flex;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/geo_view.png" alt="旋转矩阵1和矩阵乘向量理解1" style="width: 100%;"> <img src="https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/geo_view2.png" alt="旋转矩阵1和矩阵乘向量理解2" style="width: 100%;"> </div> 但如果用行向量表示一个样本点,从上面的(Ax)^T=b^T = (x^T)(A^T)=b^T,此时x^T是行向量,表示一个样本点, b^T也是一个行向量,表示样本点。 A^T和原来的A也已经是转置的关系。 想想鸢尾花数据矩阵X,每一行代表一个样本点,每一列代表一个特征。这一点和Ax=b的理解恰好相反。 - 向量 - 可以表示:坐标系的坐标轴(标准的如e1/e2,也可以是非标的)、方向(法线、方向...) - 一个样本点,可以是列向量或者行向量,取决于相关领域的习惯 - 矩阵 - 矩阵M:(坐标系的)线性变换 - (坐标系的)线性变换特点:平行且等距,原点保持不变 - 坐标系发生线性变换,那么依赖于原先坐标系的x,也会发生相应的线性变换(y) -> Mx=y (x这里是列向量,M是线性变换或者新的坐标系) - 旋转矩阵、缩放矩阵、置换矩阵、镜像矩阵、方程组的系数矩阵... - [几何变换](#ch08_geometric_ransformation) ![线性变换](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch09/understand_transform.png) - 数据矩阵X: - 鸢尾花数据矩阵,可以是每行表示一个样本点(花瓣长宽、花萼长宽);也可以是每列表示一个样本点 - 高阶含义: - 各类特殊矩阵 - 格拉姆矩阵:其对角线元素含有L^2范数信息,在二次型中会用到 - 雅克比矩阵:导数信息 - 海森矩阵:二阶导数信息 - 。。。 - 矩阵和向量 - 矩阵表示线性变换 假设这里的向量都是列向量(x,y,b) - Mx = y - 含义:M表示变换, x是某个样本点,含义是样本点x经过M变换后得到y - 也即在标准坐标系下的x,将标准坐标系变换(线性变换)到M(e1,e2 -> 新坐标轴(M的第一列和第二列))后,原来的点x也同步变成了y(其各个坐标值也是用标准坐标系下的分量来表示) - 线性方程组:Ax=b - 几何变换:y=Ax=RSx = Mx - ... - 矩阵表示数据 假设这里的数据矩阵X是每行表示一个样本点,类似鸢尾花数据矩阵。 - Xv=z - 是个降维的过程:将n个样本点,每个样本点有4维(4个特征值:花瓣长宽、花萼长宽),降维到还是n个样本点,但是每个样本点只有1维的z,降维方法是v - 降维是降低样本点特征的维度,样本点的数量不会减少 - 这里的v和z仍然是列向量 - v是表示如何将多维数据矩阵X变换为一维,z表示降低为1维的每个样本点的新数据 ![P128](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/Xv.png) - 一个数据和很多个样本数据,降维运算是一样的 - 1x4(X) * 4x1(v) = 1x1(z) <-- --> 1个样本点,4个维度 * v(4x1) = 1个样本点,1个维度 - 150x4(X) * 4x1(v) = 150x1(z) <-- --> 150个样本点,4个维度 * v(4x1) = 1个样本点,1个维度 - 矩阵和矩阵 - 一个矩阵表示数据矩阵,一个矩阵表示维度变换方式矩阵 - Xv=z --> XV=Z - 1x4(X) * 4x2(V) = 1x2(Z) <-- --> 1个样本点,4个维度 * v(4x2) = 1个样本点,2个维度 - 150x4(X) * 4x2(V) = 150x2(Z) <-- --> 150个样本点,4个维度 * v(4x2) = 150个样本点,2个维度 - 1x4(X) * 4x4(V) = 1x4(Z) <-- --> 1个样本点,4个维度 * v(4x4) = 1个样本点,4个维度 - 150x4(X) * 4x4(V) = 1x4(Z) <-- --> 150个样本点,4个维度 * v(4x4) = 150个样本点,4个维度 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/XV.png) ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/XV2.png) - 将上面的V看成M,则 XV=Z - 一般理解的MX=Y,这里的X是每列是一个样本点 - (MX)^T=Y^T = X^TM^T=Y^T -> 这样就把X^T存在左边了 ![](https://github.com/wumin199/wm-blog-image/raw/main/images/2023/power-of-matrix/ch05/MX.png) 其他参考: - [常见几何变换](#ch08_transform) - 向量的矩阵表达法 **参考** - [矩阵转置](#ch04_transpose) - [向量和向量](#ch05_vector_vector) - 矩阵求导 如果想真正学习矩阵求导的话,建议把 Old and New Matrix Algebra Useful for Statistics from <NAME> 过一遍。矩阵求导麻烦就在于很多时候,直接用链式法则不管用,强行用的话需要做很多转置、reshape的变换,才能让矩阵之间的维度匹配。而Thomas这本书走的是另一个路子,写出矩阵的“微分形式”,把这一套学到手后,基本任何形式的矩阵求导的推导都不再是问题,也不需要再死记硬背了。 参考:[关于矩阵(矩阵求导、矩阵范数求平方之类)](https://www.zhihu.com/question/338548610/answer/835833420) 可以看看这个教程:The Matrix Calculus You Need For Deep Learning,ANTLR之父和<NAME>写的如果只是想计算矩阵微积分,可以参考里奇微积分(Ricci Calculus):一种计算向量求导,矩阵求导,张量求导的简单方法,在matrixcalculus.org上直接就能计算矩阵微积分如果想培养一下数学直觉,也可以看看《The mathematics you missed》的第一到三章,后面的章节对于机器学习也很有帮助。 参考:[关于矩阵(矩阵求导、矩阵范数求平方之类)](https://www.zhihu.com/question/338548610/answer/835833420),[里奇微积分](https://zhuanlan.zhihu.com/p/63176747) 书籍:[Old and New Matrix Algebra Useful for Statistics](https://tminka.github.io/papers/matrix/minka-matrix.pdf)、[The Matrix Calculus You Need For Deep Learning](https://arxiv.org/abs/1802.01528)、数学符号理解手册、[在线版Matrix Calculus](https://www.matrixcalculus.org/matrixCalculus)、那些年你没学明白的数学:攻读研究生必知必会的数学 - 欧拉角中的Sxyz和Rzyx的关系 - 一些口诀 - 单行矩阵@单列矩阵=数,多行矩阵@单列矩阵=单列矩阵,多行矩阵@多列矩阵=多行多列矩阵 - 行(向量)·列(向量) = 数字,“行列式”,可能是距离/缩放信息:cos距离,范数,投影距离,行列式等等 - 单列矩阵@单行矩阵 = 矩阵 -> 对应到列向量的张量积 --- ## Cheat Sheet - [The Matrix Cookbook](https://www.math.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf) - [Old and New Matrix Algebra Useful for Statistics](https://tminka.github.io/papers/matrix/minka-matrix.pdf) - [The Matrix Calculus You Need For Deep Learning](https://arxiv.org/abs/1802.01528) - [在线版Matrix Calculus](https://www.matrixcalculus.org/matrixCalculus) - [线性代数的艺术](https://github.com/kenjihiranabe/The-Art-of-Linear-Algebra)(Graphic notes on Gilbert Strang's "Linear Algebra for Everyone") - [线性代数的艺术中文版](https://github.com/kf-liu/The-Art-of-Linear-Algebra-zh-CN) - [Thesaurus of Mathematical Languages, or MATLAB synonymous commands in Python/NumPy](https://mathesaurus.sourceforge.net/)(网站整理了常用MATLAB-R-Python命令、函数之间关系) - [Matrix calculus](https://en.wikipedia.org/wiki/Matrix_calculus) - [Old and New Matrix Algebra Useful for Statistics](https://tminka.github.io/papers/matrix/minka-matrix.pdf)(矩阵的“微分形式”) --- ## 参考资料 - [streamlit](https://streamlit.io/) - [Streamlit documentation](https://docs.streamlit.io/) - [KATEX](https://katex.org/docs/supported.html)(streamlit.latex和notion中可以用到) - [Table Generator](https://www.tablesgenerator.com/html_tables) - [符号表](https://typst.app/docs/reference/symbols/sym/) - [3Blue1Brown](https://space.bilibili.com/88461692?spm_id_from=333.337.0.0) - [immersive linear algebra](http://immersivemath.com/ila/index.html) - [GeoGeBra](https://www.geogebra.org/) - [ghProxy](https://gh-proxy.com/) - [wm-blog-image](https://github.com/wumin199/wm-blog-image)
https://github.com/justmejulian/typst-documentation-template
https://raw.githubusercontent.com/justmejulian/typst-documentation-template/main/utils/userStory.typ
typst
#let count = state("x", 0) #let userStory(body) = { count.update(x => x + 1) [*US-#count.display():* #body #linebreak()] }
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/035%20-%20Core%202019/004_Chronicle%20of%20Bolas%3A%20Whispers%20of%20Treachery.typ
typst
#import "@local/mtgstory:0.2.0": conf #show: doc => conf( "Chronicle of Bolas: Whispers of Treachery", set_name: "Core 2019", story_date: datetime(day: 11, month: 07, year: 2018), author: "<NAME>", doc ) Grandmother was a formidable woman, once known as Yasova Dragonclaw of the Temur clan. Now that the title had been outlawed by the dragonlord, she was called First Mother to the Atarka tribespeople. The old woman stood amid a jumble of boulders beside the still-warm carcass of a dead broodling. But instead of examining the dragon, she was looking down on a young man whose shoulder bore a shallow cut from a dragon's claw. His blood oozed down over the shining mark of a ghostfire warrior that curved over his shoulder and down onto his chest. "You concealed your magic from us, Tae Jin. All our lives are forfeit if the dragons discover we have sheltered a ghostfire warrior. Tell me the truth, or I must kill you." Naiva supposed the ghostfire blade Tae Jin could call up using forbidden Jeskai magic might be a match even for Grandmother's fighting ability, maybe even for the entire hunting party, but the young man knelt with head humbly bowed. He made no threats. He offered no bluster. Yet he also did not tremble. He wasn't afraid of her, or of death. "My mother was a scribe who served Shu Yun before the fall. She survived Ojutai's purge and dedicated herself to saving what she could of the history and knowledge of the Jeskai Way. A few wanderers and scouts managed to escape and hide in the mountains. These people carry all that remains of the old way. My mother sent me into the wilderness to study with the man who became my master. He is the one who sent me to you. He taught me the way of the ghostfire blade so it would not be lost." #figure(image("004_Chronicle of Bolas: Whispers of Treachery/01.jpg", width: 100%), caption: [Ghostfire Blade | Art by: <NAME>], supplement: none, numbering: none) "That you are a ghostfire warrior is an unpleasant surprise," said Grandmother. "Is this some kind of trap on the part of Ojutai? This is exactly the sort of roundabout trick a cunning and unscrupulous opponent might use to flush its prey out of hiding. His prey being me, and what he believes I know." "My master received a vision from the Spirit Dragon." "Ugin is dead." Naiva thought she would have to repeat herself forever. "Isn't that right, Grandmother?" "Go on, <NAME>." Grandmother raised a hand to signal Naiva to silence. How the gesture grated at Naiva, dismissed so casually. Tae Jin didn't even look at her as he replied. "Yes, Ugin is dead, but my master received a vision nevertheless. The Spirit Dragon told him it was time to share the story told to our Jeskai ancestors." "A story I've never heard of or even suspected." Grandmother grunted to mark her displeasure. "Shu Yun liked his secrets—" "He's not the only one," Naiva muttered, even knowing how childish and disrespectful she sounded. Baisya elbowed her with a disapproving hiss. Grandmother kept speaking as if she hadn't just been interrupted. "—so it's no surprise he kept Ugin's story from the rest of us." "The Jeskai Way hangs by a thread. My master says if the story is known in more than one place, then it is more likely to survive." "To survive for what purpose?" Naiva demanded. "The dragons rule us now. The old ways are just a corpse left out to be consumed by carrion eaters." "If we lose the past, we lose ourselves," scolded Grandmother. She brushed a hand along her mantle, made from the pelt of her beloved Anchin, and was about to say more when Fec called softly. The old orc had climbed atop a flat rock, his form visible as a darker shadow as the last daylight died. Stars shone overhead, but he gazed toward the horizon where no stars were visible. He lifted his face to the air and took in a deep inhalation. "There's a storm coming," he said. The clouds to the north had piled up in a portentous way over the rugged borderlands that Atarka considered the edge of her hunting territory. Flashes of lightning spanned the higher reaches, streaks of light that flashed and died. They were too far away to hear thunder. #figure(image("004_Chronicle of Bolas: Whispers of Treachery/02.jpg", width: 100%), caption: [Island | Art by: <NAME>t], supplement: none, numbering: none) "It's a dragon tempest, and it's moving in fast," Fec added. "I know their scent and taste well." Grandmother frowned. "I don't like to remain so close to the dead dragons, but we can't weather a dragon tempest out on the open tundra. It will be even more dangerous at night. We'll shelter in the rocks until it passes. I'll examine the young man's wound once we're in the shelter. Can you walk?" Before Tae Jin could answer, Fec interrupted. "You already expended a great deal of strength healing him, First Mother. Too much more, and you'll harm yourself." "I can walk." Tae Jin gritted his teeth as he got to his feet. When Naiva took a step forward to assist him he waved her off, and Baishya took hold of her elbow as if she thought her twin couldn't take the hint. Grandmother assigned Mattak, Oiyan, and the quiet ainok Darka to sentry duty around the concealed entrance to the rock chamber. The rest had to bend over double to make their way through a low passageway cut with several chimney shafts. No dragon could enter, and the vents meant any fire breath would dissipate before reaching the central chamber. Deep in the rock, Rakhan kindled a fire. By its dim light, Grandmother examined the cut. "It's shallow and can heal on its own. Girls, guard our visitor." "Where are you going?" Baishya asked. "This is a rare chance for Fec and I to take the liver and hearts from the broodling now that it's belly is already cut open. Atarka need never know." "Don't you want my help, Grandmother?" Baishya asked just as Naiva said, "I'd like to see what the insides of a dragon look like!" "Not today, with a dragon tempest blowing in. You two stay here, under cover." "Yes, Grandmother," said Baishya obediently. Naiva fumed, exhaling sharply. She wanted to complain, but not in front of the stranger. Grandmother pinched her cheek. She didn't have a gentle touch, but the gesture was a sign of affection even though it hurt. "You can see to the lad's cut, Naiva." She went out with Fec, leaving Rakhan and Sorya to soak dried meat from their provisions in boiling water. Baishya gave Naiva a questioning look as if to say, "What is wrong with you?" Naiva turned away as Tae Jin settled on the ground, rubbing droplets of blood off his face. "Does it hurt?" she asked him. "Not enough to matter." Baishya heated water steeped with petals of Heart of the Earth flowers over the fire in a small copper pot. She wrung out a damp cloth. Naiva snatched it from her but hesitated. Tae Jin's bare skin gleamed in the firelight. The thought of touching him, even with a cloth, made her breathe as if she was caught in a storm of beating wings. <NAME> caught her eye and nodded to show it was acceptable to him to be tended by her. With the slightest wince, he pulled off his torn tunic, exposing the golden-brown skin and wiry muscles of his shoulders and chest. She cleared her throat self-consciously, aware of Bai's sly gaze on her shot through with mocking amusement. As if Bai wouldn't have felt a similar awkwardness! Yet it occurred to her that she and her twin never gossiped about the other young people and whether they were attractive. Bai turned her attention to washing the damp blood off the tunic in a trough cut into the rock. That a young man's well-built torso was a subject of no interest to her twin gave Naiva a lift of confidence. Lips primly closed, she carefully dabbed away the blood from the shallow cut, working her way down its length, which cut across the shining mark. His breathing never skipped in its even in and out, although, once or twice, his eyelids flickered. After a bit, she handed the now blood-stained cloth back to Baishya and squeezed the juice of freshly picked leaves onto the cut. "What herb is this? I don't know it from my own mountains." "We call it all-heal because it keeps wounds from festering and eases bruising," she said, and boldly went on. "How old were you when your mother sent you away?" "I was twelve." "Did you ever see her again?" "No." "Do you miss her?" His grave expression made her wish she had asked him a question that got him to smile instead. "Of course, I miss her. She is an educated, accomplished woman. As I said, she is one of the few scribes who served Shu Yun to survive the fall. She always knew her duty was to send me into the wilderness. What of you?" "Our mother is dead. Atarka killed her for being a whisperer." "A whisperer? You used that word before. I don't know it." "She means a shaman, like your people have." Baishya wedged an elbow into Naiva's ribs as a reminder that only Temur shamans knew the secret of whispering, speaking mind to mind with other shamans. Naiva knew this skill existed because the two girls shared everything, part of the bond of being twins. But evidently that was no longer true. #figure(image("004_Chronicle of Bolas: Whispers of Treachery/03.jpg", width: 100%), caption: [Whisperer of the Wilds | Art by: David Gaillet], supplement: none, numbering: none) He glanced between them, reading something in their expressions. "It's true the dragons fear our magic. They fear anything they think they cannot control or which does not belong to them." "Is it worth it?" Naiva asked, unable to keep a trace of bitterness from her voice. "What do you mean?" "Losing our mothers. Or anyone, really, just for the sake of keeping old traditions alive. The dragons rule us now. Maybe it's better to discard what they've forbidden." "Better for whom? Better for the dragonlords, certainly. What about the respect and duty we owe to our ancestors?" "Maybe it's best to let the dead go and concentrate on this day's hunt and this day's survival." He cast her a sidelong look then shook his head with a frown. She'd disappointed him, and she glared at the ground to hide her chagrin. She wanted him to think well of her, and now, she didn't know what to say. In a cool tone he said, "Do you think it would be best for Atarka Dragonlord to kill your sister, as she did your mother? Is that what you propose?" "Of course not! I just meant that everyone dies. Maybe we are trying too hard to keep alive the old ways when they would naturally die in the course of time," Naiva muttered. "What is natural about their death?" Tae Jin asked calmly. "The old ways, as you call them, did not die of old age or neglect on the part of the people who followed them. They have been deliberately hunted down and killed by the dragons, piece by piece, memory by memory. By keeping them alive, we defy the dragons rather than accept defeat. Maybe it is a small thing. Maybe none of it will matter when generations have passed. But maybe it will. But only if there is something left to be found, however small, however unremarkable. That is why my mother sent me into the wilderness." Baishya crouched on the other side of Tae Jin, offering him a needle and thread. "Yes, I understand, Tae Jin. I follow a similar path. What we keep alive is what sews us to the past. The future is unwritten. Do you want the dragonlords to be the sole arbiters of what comes to pass, Nai?" "Of course I don't. That's not what I meant." But in a way, it had been what her words had meant. How annoying to be shown up as wrong! Tae Jin reached for the needle. The shift of his arm and shoulder made him wince. Naiva leaned in and plucked the needle from his fingers. "Let the cut heal. I can repair your tunic." "We have much in common," Tae Jin said to Baishya. The two of them began cautiously to discuss their training, although it was clear they were both speaking obliquely, not willing to say too much about the secret lore of their respective traditions. And especially not in front of anyone who wasn't a shaman! Naiva loved the lore of hunting because it was straightforward. Skill and experience mattered but the goal was simple and the outcome clear. People must eat. Those who brought down game could feed others and thus be the most valued members of the tribe. But she didn't know how to say that when Baishya and Tae Jin had clearly delved into lore and magic that she knew nothing about and would never comprehend. The thought of that lack plagued her like rats gnawing on her insides. With mouth pressed tightly, she set to work to repair the tunic. If she kept her hands busy, then she did not have to resent her sister. It was quiet in the shelter with the fire crackling and a pot of broth simmering. Sorya and Rakhan were hauling water from the river for a cistern carved into the back of the chamber, working to make everything secure. "You have a neat hand at stitching, Naiva," <NAME> said abruptly. It was warm by the fire; her cheeks felt scalded. "Every hunter must be able to repair every piece of their equipment." She ran the cloth through her hands. The fabric was smoother and thinner than any cloth she had ever touched before. "What is this made of? We use hides and felt." "You've never worn wool?" "Nothing as delicate as this. A few of the elders have wool cloaks they use for sleeping since it's hard for them to keep warm. We don't weave such cloaks ourselves. We trade for them from your people and the Dromoka." "It's woven from goats' wool." "Goats? Like mountain goats?" "No, a different sort of goat. A smaller, domesticated goat that lives alongside humanoids. They're hardy creatures who thrive in the mountains where I come from." #figure(image("004_Chronicle of Bolas: Whispers of Treachery/04.jpg", width: 100%), caption: [Mountain | Art by: <NAME>], supplement: none, numbering: none) "Are those mountains different from our mountains?" He grinned. "I have never traveled in your mountains, so I would not know." "How did you get here? I mean, how did you know the way? Did the dragon chase you the entire time? Or did it come after you later?" "Tae Jin will have to wait on those questions," said Grandmother. She came over, leaning on her spear, looking exhausted. Both girls sprang up at once to take hold of her arms, one on each side. They settled her on the mantle made from Anchin's pelt. She leaned back against the rock with a weary sigh. "Where is Fec?" Naiva asked. "Stashing the offal in sacks in the river, to hide the smell. My bones are old." She closed her eyes. For a terrifying moment Naiva thought she had fainted, but she was just resting. After a silence, she addressed the young man in her usual curt tone. "There is more to your story. I'll listen." He pulled on the repaired tunic. The damp spots where Baishya had washed out the blood spatter steamed in the fire's heat. The wind was picking up outside, heard as a plaintive moaning down the entry tunnel. Smoke drifted upward to the cracks in the rock chamber, and as he began to speak, it seemed to Naiva the tendrils of smoke twisted and coiled to the rhythm of his telling as if to bend into images of the tale itself, for voices and words carry a magic that allows listeners to see what they have not personally witnessed. #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) I suffered through a miserable night washed by successive waves of sweating and shivering as the venom's potency slowly faded. No wonder four dragon skulls had joined that of our sister, <NAME>, as adornments atop gates. They need only wound their target and then track it as it weakens. But I was made of sterner stuff, or perhaps only fortunate enough to receive but a scratch rather than a deeper injury where venom could reach my hearts. By dawn I felt sluggish, but at least I could extend and retract my claw without pain, although a numbness persisted in my foreleg. Watchfires had blazed all night far below. We had heard a distant buzz of activity as if we had shaken ants out of their nest. As the light changed, the great fires were doused. Horns blared with shrill eagerness. Nicol had spent all night in silent contemplation, perched at the apex of the mountain. At the sound of the horns, he chuckled softly as if he found it all terribly amusing. I wasn't amused at all. "We should go," I said. "They're not afraid of us." "They will soon learn to be afraid." He craned his neck, shifting to get a better look down the mountain. A hiss of fire steamed from his nostrils. "How odd. A lone traveler climbs toward us. What frail human would dare?" #figure(image("004_Chronicle of Bolas: Whispers of Treachery/05.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) "Maybe it's a trap." Curiosity piqued, I flew up out of the shadows to join him. The rising sun flooded my vision. A small shape trudged steadily upward, picking its way through a long scatter of rock that was the debris from an ancient eruption. As the biped drew closer it waved merrily and, with a curiously relaxed grin, kept climbing toward us. "Don't burn it," I whispered as Nicol lifted his head and leaned forward as if to leap upon the brave soul. "Burning is so crude, Ugin. I'm developing subtler methods. Anyway, I don't think it is a true humanoid at all." "Brothers! Greetings to you." The biped called out. "I'm surprised to see you here. This place is no longer safe for our kind." "Chromium Rhuell?" I reared back in astonishment. Nicol settled on his haunches with a huff of annoyance. "How do you do that?" "Do what?" asked the biped, who appeared outwardly as a pregnant human except for the way his eyes shone like sapphires, refulgent with a dragon's power. "Change yourself into a human so convincingly." Nicol sniffed the air with a grimace. "You even smell like one. Rancid and credulous." "It's a trick I taught myself so I can walk among them." Nicol cast a glance at me to see how I would respond to this remarkable statement. "What have you observed, Brother?" I asked. "Humans are quite fascinating, and there is so much about them to know. Where should I start?" "With the ones who live here, in the shadow of our birth mountain," Nicol said. The human face wears expressions like clothing, casting emotion on and off at whim. With a frown, Rhuell shook his human head disapprovingly and tapped his fists together. "These humans are dragon killers. Their chief is an old man who hunted a dragon when young and still gloats of it endlessly while sitting on a chair made of its bones. He has decreed that any person who kills a dragon will join the ranks of his heirs." "His heirs?" "The ones who may hope to rule as chief after he dies." Nicol gave a low rumble, as if the answer contented him. "I see. How convenient." I would have asked what he meant by saying it was "convenient," but Chromium Rhuell had already gone on. "That's not all. The chief claims that divine favor elevated him above his lowly subjects. Those who are touched by dragon's blood, or who drink or eat it, are considered holy and may live a life of ease and plenty while the less fortunate serve them as slaves." #figure(image("004_Chronicle of Bolas: Whispers of Treachery/06.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) Nicol chuckled. His sly amusement troubled me. "Those who are strong or clever enough will stand atop those who are weak and stupid, will they not? These are the first humans I have seen who have not disgusted me with their feebleness and unctuous groveling." With a snarl of sparks, I turned on him. "Nicol! How can you speak so approvingly of people who murdered our sister? I thought you returned here to avenge her death." "Do you approve of vengeance now, Ugin? I thought you favored tedious bouts of meditation and Arcades's bland dominion." "I have done nothing to deserve your disdain. In truth, I don't like this tone of contempt from you. Especially considering I saved you from Vaevictis's jaws!" I expected him to snap back at me in a temper, but instead, he sunk his head between his forelegs and half closed his eyes. Someone who didn't know him well might think he was basking in the sun, relaxed and easy, bored by our exchange. But I had often seen him lounging about watching Arcades and the humans in just this manner, and a niggling apprehension clawed at my gut. "What do you propose to do now that you have walked among them and studied their ways, <NAME>?" he asked in his most reasonable tone. "I intend to consult with Arcades. My recommendation is that we destroy the chief, his heirs, and his acolytes, burn all the temples, and salt the fields. We will need the cooperation of our siblings and cousins to manage it." "Such destruction seems more like Vaevictis's way of doing things and quite unlike you and your detached observation, Brother," said Nicol with a flicker of his muzzle that bent into a sneer. "If you have flown over this territory, you will know what I mean." In a soft beguiling voice, Nicol said, "<NAME>, let us not be too hasty in raining down fire. Wouldn't you be the first to say there is something to be learned from them?" "To be learned from them? To be avoided is the truth of it! After the disappearance of three dragons I came to this place to find out what was going on. I saw the Chief's hunters trap and kill a small dragon, recently hatched and thus young and vulnerable. Besides the ballistae, whose bolts can pierce our scales, their magic workers have instilled sorceries into a venom to make it strong enough to poison even our flesh. The threat to all of us is dire, should they share this knowledge of how to slaughter us with other humanoids." Nicol blew a thread of smoke from his mouth with a sardonic smile. "So, you are content if we kill the innocent who toil as well as the prideful rulers?" "No, that isn't what I meant. Cut off the head and kill the monster. Destroy their chief's house and temples and force them to move away from our birth mountain and our cousins' bones, that's what I mean." "Such destruction will more likely cause the least of them to die. Those with weapons can still forge a path out of the destruction and cut their way to a new foothold elsewhere. Isn't that correct?" "I do not care where the survivors end up. They are sapient creatures and can manage their own destinies as long as they do not take their dragon-killing ways with them." "Are you saying the humans may kill and torment each other, just as long as they leave dragons alone?" The human eyes flashed with a pulse of annoyance, a glimpse into Chromium Rhuell's hidden power. "You twist my words. I observe. I do not interfere with how they behave among themselves." "I confess, such a philosophy sounds a trifle hollow to me. One law for them, and a different law for us." "Nicol is right," I said hastily, foolishly attempting to placate both of them, "but that doesn't mean we should not consult with Arcades about what to do." But our elder brother's rage flared in a flash of staggeringly bright blue light. The air around us swirled. A strong gust shoved me backward like a blow. When the blinding-white haze faded, <NAME> in all his draconic magnificence loomed over us, shining like a mirror ablaze with light. His wings were spread wide and the flat crest of his face reflected the sun in my eyes so I could barely see. #figure(image("004_Chronicle of Bolas: Whispers of Treachery/07.jpg", width: 100%), caption: [Art by: Chase Stone], supplement: none, numbering: none) "I hear what you are doing, <NAME>. You twist words to whatever shape you wish them to make, then twist them again to suit your wishes. You are the least of us, last fallen, not even a whole dragon but only half of one, bound as you are to Ugin. Do not ever again attempt to challenge me or you will regret it." In a clamorous rush of wings, he flew, catching an updraft off the heights and spiraling quickly up and up into the heavens until even our keen sight lost track of him. Nicol sighed on a long exhale of warmth. "Why did you provoke him?" I demanded. "You did twist his words." He said nothing, staring still at the heavens, shifting his gaze to the sun's sky-altering brilliance. Humans could not look upon the sun for long, or they would blind themselves, but we dragons can stare into its luminous splendor for as long as we wish. As <NAME> had once told me, all creatures depend on the sun for life, but dragons are the only creatures who, like the sun, can burn without consuming themselves. "Temples, heirs, and blood," murmured Nicol. With a thoughtful expression, he bent his head and scraped his horns on the ground to leave a mark, the sign of his presence here high upon the rocks of our birth mountain. Then he stretched up from his hind legs. "Do you see, Ugin? Our enemies are coming. Let us go down to meet them." A large group of armed people had left the main settlement, led by a company of scale-clad warriors on horseback and a curtained sedan chair carried by six strapping young men. This small army was accompanied by mules harnessed to haul four ballistae mounted on wheels. The well-fed and well-clothed inhabitants stood on scaffolding to toss flower wreaths down over the warriors. The ill-clothed, thin, overworked people knelt on either side of the roadway, heads bowed, hands over their eyes, calling out praise in rote phrases: "May the mighty ones protect us" and "blood rules the bloodless." Singing a robust martial tune, the proud warriors strode along a road cut through the forest that led to the base of the mountain. Here, in a clearing on the lower slopes, a handsome log palisade enclosed a large rectangular area divided into three separate sections. The ballistae were drawn up outside the palisade. The rest of the army filed into the outermost section, passing under a gate carved in the shape of a dying dragon. On this large assembly ground, the foot soldiers formed into ranks and knelt, bowing with hands pressed over their faces. The mounted contingent rode under a second, more elaborately carved and painted gate depicting a man clad in blood holding a spear in one hand and a dragon's claw in the other. Here, grooms took the horses into the shelter of open-sided stables while the dismounted riders accompanied the curtained sedan chair on foot to the third and final gate. Here, they too also knelt and covered their faces in submission, all but two: a middle-aged man with a proud demeanor and a young woman with a scarred face and a fierce gaze. These two were each wearing a helmet adorned with a crest of dragon's teeth. They were allowed to cross under a gateway that was, to my horror, the curved spine of our sister held together with wire and leather cord. The innermost courtyard contained a beautiful temple, perfectly proportioned in an exact square, with a cunningly built stack of three roofs, one above the next, each painted with alternating eyes and suns. The sedan chair was carried up steps to the temple's forecourt and set down, after which the bearers immediately retreated to a small closed shed. The two attendants drew aside the curtains, and a stout, white-haired man clambered out with their assistance. He had a greedy expression and the thick, grasping hands of a man who has grown accustomed to taking whatever he wants. Beneath the wrinkles and age spots and double chin lay the vaguely familiar lineaments of the leader of the hunters who had killed <NAME>. By human measure, it had happened a long time ago, for he had been a young, strong, hale man then. It was difficult to reconcile my memory of that forceful hunter with the blustering, impatient chief who excoriated the two younger people who attended on him because they did not seat him quickly enough on a padded couch set beneath the temple's portico. They suffered the abuse without blinking, only once exchanging a glance, and that glance held its own ripe tension like two tigers stalking the same prey. My bones hummed. Whispers chased through my head as the wind moaned over the peak. #emph[She is younger than you, and the chief likes her better because he thinks she's bolder and braver. She intends to outlast you and have you throttled when he dies.] #emph[He doesn't trust you and never has. He considers you an upstart, unworthy, fickle, and he'll have one of his spies stab you in the back the moment he sees an opportunity.] #figure(image("004_Chronicle of Bolas: Whispers of Treachery/08.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) A cloud briefly covered the sun, shaking my mind loose from these vexed imaginings. Far below, a priestess whose eyes had been burned out ventured forward from the dark interior. She brought a cup carved from dragon bone. The cup held dragon's blood, congealed and musty, yet the chief drank it down with relish and offered the dregs to his two companions. More priestesses hastened out to wash his swollen feet and flushed face. "Prove your worth," he said to his companions. "Bring me the head of the dragon my ballista wounded." Bells rang and drums clapped. The warriors in the outer courtyard howled with a screech that, even from this distance, shivered horribly through my bones. Bones that these terrible humans wished to use to adorn their palaces and temples. "It's curious, isn't it?" said Nicol. "What's curious is why we're still here watching and haven't flown away after our brother." "Don't you find this all very illuminating? Those two who attend him so assiduously are two of his heirs." "How do you know that?" He chuckled and did not answer. "So where are the other two heirs?" "In the other dragon-crowned settlements, surely." "Exactly. This will be easy." "What will be easy?" "Have you not sorted out the weakness in their philosophy, Ugin? I'm disappointed in you." He gave a thundering roar and leaped into the sky, wings spread. He was so sure I would follow him, and I did. Chromium Rhuell might speak sensibly, but I had no reason to trust him more than I trusted Nicol. He wasn't my twin, after all, just a wingbeat sibling who wasn't any too respectful of Nicol and me regardless. That comment about us two being "the least of the fallen" had stung me too, even if it had been meant for my twin. We flew toward the farthest flung heir's settlement. Messengers had been sent out from the chief's home compound during the night. When Nicol caught sight of a youth running at a steady pace in the same direction we were heading, he swooped down, caught up the youth in his claws and, as the young human screamed and struggled, bit off his head. With casual disregard, he dropped the body into the forest. "Nicol! Was it necessary to take that innocent youth's life?" "How is your claw, Ugin? Does it still hurt? Is your flesh still numb? Or would you like the entire countryside to be raised against us when these messengers reach them?" "We can just fly away." "And leave them to kill other dragons? To spread their customs and knowledge to other humanoids? I think not. I am doing what is best for all of us. Isn't that what you want, too?" It was hard to argue with my foreleg throbbing. Built along a lakeside, the most distant settlement boasted its own miniature version of the square temple, a modest chief's longhouse adorned with a dragon skull, and a palisade separating the inner compounds of the favored from the humble huts of the lowly. The shore of the lake was lined with racks and racks of drying fish set out in the sun, vats of fish guts and salt fermenting with a reek that rose into the heavens. The palisade was so new, the scars of its building still tore through the earth, revealing fragile roots and plump pale worms. This heir had a single ballista placed by the settlement's gate, facing the road as if he were more concerned with human enemies than dragon flights. I flew out over the lake, not wanting to get too close to the weapon's venom-tipped bolts. Nicol swept a wide circle around the settlement and its fields, making sure everyone knew he was there. #figure(image("004_Chronicle of Bolas: Whispers of Treachery/09.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) When horns blew and drums pounded out the alert, a young man dressed in a crested helmet strode out of the chief's longhouse. He was tall and handsome, his arms and neck adorned with twisted gold jewelry that shone like trapped sunlight. Like him, his warriors were clad in armor made of dragon scales. These scales had once belonged to the dragon he had killed, I was sure: the scales shimmered with delicate green tones under the sunlight, giving the warriors a luminous beauty they had stolen from one of us. There was something anticipatory and yet indecisive in the dragon-killer's manner as he stared up at Nicol as Nicol had once stared at the sun. What was Nicol waiting for? What was his plan? His slow circling glide had such a strangely hypnotic effect that as I hovered on a high updraft, I could not tear my eyes from the curious tableau, wondering what was going to happen. The drums fell silent and the horns quieted. A breeze teased its way through the branches. Lake water lapped the shore with short sighs. My bones hummed. Whispers chased in my head in a voice that sounded less and less like the twisted mutterings of a cursed wind and more and more like Nicol. #emph[The old chief has lived long past his prime. Who is he to demand obedience when he can no longer even cast a spear accurately or with enough force to kill a deer, much less a man, much less a dragon? He has raised three to be his favored heirs while his own firstborn son he neglects, even though that worthy son has killed a dragon at long last after so many years being mocked for his insufficiencies. The gods granted their favor to the old man, everyone agrees. That favor ought to pass on to his son, shouldn't it? Yet he has been pushed to the farthest edge of the chiefdom, forced to rule over fishermen and live amid the stink.] #emph[What if such a worthy son has something better than a dragon's skull as his trophy? What if he has dragons at his command? Killing a dragon is a bold hunter's deed, of course, not to be scorned. But for a dragon to serve a human? Now that is the standard of a leader.] #emph[It could be your measure. If you march against the other heirs. If you defeat them, and kill your father. A dragon could respect such a person as that, could he not?] I was slow to understand. Te Ju Ki's calm and measured teachings had found a home in my heart; they made sense to me. Even when the young man mobilized his warriors and gave a mighty speech to them about the portent of the dragons and how they had shown their favor by flying overhead and not burning the settlement or killing anyone, I did not understand. Even when they marched out with brisk purpose, he mounted on a splendid steed with his scale-clad officers beside him, I did not understand. I was convinced they were going to join the others, to make common cause against us, even when such a course of action made no sense. We two dragons were there, right in front of them. Again and again the chief's son gestured toward Nicol, who remained aloft keeping a cautious eye upon the ballista but with his attention focused mostly upon the chief's son. As the last of the foot soldiers passed under the gate, Nicol dropped down to the longhouse. He raked his claws along its ridge beam, marking it, and roared, just once, like a challenge or a benediction. A great answering cheer rose from the ranks. Singing their violent songs, they marched away toward the central settlement. Nicol flew out to me where I had remained hanging back, over the lake. "Now we return to the birth mountain," he said. "What are you doing?" I demanded. "Oh, Ugin, do you still not understand? Humans are riddled with hate and envy and fear and greed. They will easily do our bidding. You just have to know where to stick your claw in to get the response you want." The chief's son marched to the central settlement, now without its garrison of fearsome warriors, and he killed the chief's supporters and installed himself on the throne. Meanwhile Nicol roosted atop the birth mountain and with his presence there lured the two heirs each with their band of warriors higher and higher up the slopes, round and around until the two factions came face to face upon a rugged field of ancient lava. There they fought bitterly amid the sharp stones, the middle-aged man against the young woman. While the two armies struggled, Nicol flew down to the unguarded temple and burned it and its acolytes to the ground. #figure(image("004_Chronicle of Bolas: Whispers of Treachery/10.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none) But he left the bewildered chief alive amid the charred bones and beams. He picked up the old man almost tenderly in his claws and flew with him to the fourth and final settlement where the chief's second wife had set up as one of his heirs after she, too, had killed a dragon. She was the mage who had first ensorcelled venom. When Nicol gently deposited the old man alone and unprotected in her courtyard, she strode out. She was an impressive woman with the shine of intelligence in her face. Her braided hair, wrapped atop her head, was wreathed with pearls and gems. Armed attendants knelt before the old chief, who even in his disheveled and terrified state barked orders at her, demanding a bath and food and fresh clothing appropriate to his exalted station. My bones hummed. The whispers grew louder and louder. #emph[He wrested the secret of the venom from you. He shared it with others and stole what was your right: to succeed him as chief because you had the cunning and the intelligence, not like the other heirs, who merely benefited from your brilliance. You are the worthy one. Yet those two usurpers who sit by his side and flatter him think they deserve the dragon killer's banner, while his first wife's puling son grabs for what belongs to you.] She snapped her fingers. Her attendants jumped up and formed a ring around him, with their weapons pointing not out, to protect him, but in, to threaten him. "What treachery is this?" he cried. "You owe everything to me. I raised you from the swamp grass hut where you were born. I allowed you to learn from my cleverest mages. You will bow before me as is fitting." She stalked forward and pressed the tip of her dragon claw staff against his face until, trembling, he fell to his knees before her. "You old fool! I raised myself despite you using me as if I were your slave. You stole what should be mine by right." She stabbed him once, twice, and thrice, and had his bloody, bloated body thrown into the stinking refuse of a latrine. "We march!" she cried to her people. "The unworthy and the usurpers will all bow before me!" You, my Jeskai students, have not heard of the dragon-killers' war. It happened a long time ago and in a place unknown to you. No one wrote its history because writing did not yet exist, and those who survived told a different tale than the one I am telling you now. So the truth of those events was lost, even to their descendants. As for me, I crouched atop the birth mountain shocked by what I witnessed because I did not know what to do or why the humans behaved so violently and horribly to each other. The fighting raged in a storm of destruction until only the wife and the son remained, entrenched behind higher walls, the remnants of the other two heirs' armies split between them. The fields went untended. People began to starve. There was nothing I could do, or at least that's what I kept thinking, my thoughts running in circles after circles after circles. Until the night, I woke from a troubled sleep to find Nicol gone. I flew on his trail, for all dragons are able to follow the ember-strewn wake left by our kind. It seemed his voice caught in my mind as if he was still speaking to me. "Come witness the end, Ugin. Come witness the beginning." In the central settlement, in the grand courtyard in front of the chief's longhouse, torches burned. Nicol perched atop the longhouse with his eyes glittering like gems against the night. It was a strange piece of magic that he could stretch atop the roof beam without his great weight collapsing the structure, but we dragons have many strands of magic woven into our being. In the courtyard, the chief's son and the chief's second wife faced each other. How they had come there, and why they were both unarmed, I could not say, but they looked so handsome together, like the fitting end to a romantic tale. "This day is the wedding of the heirs of the dragon killer, he who first slew one of the dread beasts." Who spoke I did not know. My ears were clouded, and my heart was dark with foreboding. "Let you clasp hands with your oath." She extended her arms; he met hers; their fingers intertwined. "Let your oath be sealed with blood." They released each other. The torchlight twisted shadow across the scene as they each took the dragon claw of their reign, she the staff and he a long knife. Each plunged their claw into the breast of the other, and they fell together and, soaked in each other's blood, they died. "They have made the proper sacrifice," said the voice. It was Nicol, rising from the roof beam, his horns gleaming and his eyes shining with a glamor that dizzied me. "For now, you understand the truth of dragon's blood. I rule you now. I am your true leader. Bow before me." A vast and fearful sigh passed through the assembly. People sank to their knees, pressing hands against faces. "What are you doing?" I cried. "This isn't what you learned from Arcades!" "Of course it's what I learned from Arcades," he said, turning to look at me. Deep in his coruscating gaze I caught a glimpse of the brothers with the wagon, back in Arcades's orderly realm, working in amity. That peace had been shattered by the abrupt upwelling of a long-buried grudge because Nicol had stuck a claw of doubt and envy into a vulnerable heart. The man, so stricken, had succumbed to a whisper that roused the worst in him. #figure(image("004_Chronicle of Bolas: Whispers of Treachery/11.jpg", width: 100%), caption: [Murder | Art by: <NAME>], supplement: none, numbering: none) "Ugin, you know I am right," my twin said softly, beguilingly, his voice so gentle a pressure, so persuasive, so credible in its argument. "Now that we grasp the magic, there is nothing that will stop us from building a greater chiefdom, from spreading our rule, from getting our revenge on Vaevictis and his surly brothers, from putting our siblings in their place. Least of the fallen! They'll see. We'll show them, won't we? We'll no longer be least. They'll bow before us. You know it's what you want. The power can be ours. It will be ours." But power wasn't what I wanted. He didn't understand me at all. He didn't even care to understand me. All he cared about was getting what he wanted, no matter the cost to those around him. No matter the cost to me. Ah! What a pain flowered in my hearts, a cascade of searing shock and betrayal. My brother, my twin. It's bad enough that he had so callously, so gleefully, torn through the minds of these humans to get what he wanted from them. I understood that now, but he intended to violate my mind, too. My brother, my twin. He meant to rouse the worst in me, because he had succumbed to the worst in himself, and he wanted to drag me down with him. No, it was worse even than that. He wanted to use me for his own ends, because he had never truly cared for me at all. The bond we shared. The trust we held in each other. It was empty, broken, false. A harsh, hot spark burst in my heart and in my head. My flesh burned as if incinerated and charred. A scouring wind whirled down from inside and outside the heavens and dragged me into a terrifying storm of darkness where I could not even draw breath and felt my lungs being crushed by a weight of dread. A force twisted my body as if trying to turn me inside out. For an instant, my mind went blank, unseeing, unfeeling, and then with a wrench, I came back to myself. To my astonishment, I found myself floating above a featureless sea, so flat and still I could see my own reflection in the water: my horns, my scales, my eyes like twin sparks burning bright. I drifted in bewilderment, rended by the grief of losing the brother I had trusted and stupefied by the sheer jarring astonishment of being torn from the only place I had never known and flung into the space between the planes. For I understood then that <NAME> had taught me the truth, that she had seen this place in a vision. She was physically frail, tied to the soil of her home, but her mind could range where her body and magic could not go. She thought no one could cross between worlds, but now I was there, walking between the planes she had told me about. With that thought like an anchor, I fell as a shooting star falls: helplessly, burning up, obliterated by its passage. When I woke again in my body, I stood here, awake, afresh, alive, on Tarkir. And I felt the land welcome me, as if I had finally come home. Nicol had been right after all: I had witnessed the end, and this was my new beginning. #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) <NAME> broke off. Thunder boomed overhead, trembling through the rock. The wind's whine had picked up to a higher, more frantic pitch. "And then what happened?" Naiva demanded. Grandmother raised a hand to remind her that Fec, Rakhan, and Sorya were sleeping so they could take a later watch. In a low voice, she said, "You may go on with the story, <NAME>." He shook his head. "That's all I know. The scroll I memorized ends there." #figure(image("004_Chronicle of Bolas: Whispers of Treachery/12.jpg", width: 100%), caption: [Scroll of the Masters | Art by: Lake Hurwitz], supplement: none, numbering: none) Naiva groaned. Baishya pressed her hands against her mouth. Grandmother nodded with her usual calm, firelight flickering on her face so she seemed a spirit from the past fading into a measureless gloom. "So. It seems we are being called to Ugin's grave to finish the story." "What is left to tell?" asked <NAME>. "Is the story not about how the Spirit Dragon came to Tarkir?" "Eighteen years ago, I witnessed a battle in the sky that ended with the death of Ugin. That battle ended the Tarkir I knew. That battle set all the clans on a new path, a new beginning. There was another dragon in the storm that day." "There must have been many dragons. The tempests birth dragons." "This was no tempest-born dragon. This dragon vanished in a flash of golden light, like a second sun. It did not fly away. It was simply there, and then not there." #figure(image("004_Chronicle of Bolas: Whispers of Treachery/13.jpg", width: 100%), caption: [Crux of Fate | Art by: <NAME>], supplement: none, numbering: none) "That's impossible," said Naiva. Naiva had never seen Grandmother look so grave, and she was a woman who rarely smiled. "Not impossible if there are other planes and a few powerful individuals who can walk between those planes, passing from one world to the next as we might cross a stream on stepping stones." "It's so hard to believe it could be true," said Baishya softly. "I certainly did not believe it when the knowledge was first revealed to me," said Grandmother with a stern look for Naiva. "I made a terrible mistake at that time. A voice spoke to me, telling me I acted for the good of the clans. But I was merely a tool used by a power greater than myself. That dragon, called Bolas, killed Ugin. I saw the Spirit Dragon's body in the chasm. I heard his last breath, felt the cessation of his spirit. But the hedrons cast by a Planeswalker named Sarkhan Vol held a magic I did not understand then and am only coming to comprehend. Some essence of Ugin still survives, however frail and faint it may be. It can be no coincidence that Ugin is struggling to reach us now. The visions are a warning." "A warning against what?" Naiva asked. Tae Jin echoed, "Against what, Yasova Dragonclaw? The worst already happened when the dragonlords outlawed our clans and our khans and our knowledge of the ancestors." "Maybe that is not the worst that can happen," said Grandmother. Thunder crashed again, and this time muffled howls and roars echoed back. A shudder rolled through the ground as if a huge weight had just dropped onto the earth. Fec opened his eyes and sat up. He shook awake Rakhan and Sorya, and they all grabbed their weapons. A scuff sounded from the tunnel. Naiva grabbed her spear and settled into a crouch by the opening. The click of a ptarmigan's call announced the presence of one of their own. She stepped back as Mattak emerged into the chamber with a knife in hand. "First Mother, you'd best come see."
https://github.com/fabriceHategekimana/master
https://raw.githubusercontent.com/fabriceHategekimana/master/main/3_Theorie/Évaluation.typ
typst
#import "../src/module.typ" : * #pagebreak() == Sémantique d'Évaluation #Definition()[Rèlges d'évaluation part.1 $ #proof-tree(eval("NUM", $Delta tack.r "n" --> "n"$)) $ $ #proof-tree(eval("PLUS", $Delta tack.r "E1" + "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1p" + "E2p" --> "E3"$)) $ $ #proof-tree(eval("TIME", $Delta tack.r "E1" * "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1p" * "E2p" --> "E3"$)) $ $ #proof-tree(eval("BOOL-T", $Delta tack.r "true" --> "true"$)) $ $ #proof-tree(eval("BOOL-F", $Delta tack.r "false" --> "false"$)) $ $ #proof-tree(eval("AND", $Delta tack.r "E1" "and" "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1" sect "E2" --> "E3"$)) $ $ #proof-tree(eval("OR", $Delta tack.r "E1" "or" "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1" union "E2" --> "E3"$)) $ $ #proof-tree(eval("EQ", $Delta tack.r "E1" == "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1p" == "E2p" --> "E3"$)) $ $ #proof-tree(eval("LOW", $Delta tack.r "E1" < "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1p" < "E2p" --> "E3"$)) $ $ #proof-tree(eval("GRT", $Delta tack.r "E1" > "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1p" > "E2p" --> "E3"$)) $ $ #proof-tree(eval("LOW-EQ", $Delta tack.r "E1" <= "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1p" <= "E2p" --> "E3"$)) $ $ #proof-tree(eval("GRT-EQ", $Delta tack.r "E1" >= "E2" --> "E3"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r "E2" --> "E2p"$, $Delta tack.r "E1p" >= "E2p" --> "E3"$)) $ $ #proof-tree(eval("IF-T", $Delta tack.r "if" "E1" "then" "E2" "else" "E3" --> "E2"$, $Delta tack.r "E1" --> "true"$)) $ $ #proof-tree(eval("IF-F", $Delta tack.r "if" "E1" "then" "E2" "else" "E3" --> "E3"$, $Delta tack.r "E1" --> "false"$)) $ ] #Definition()[Règles d'évaluation part.2 $ #proof-tree(eval("LET", $Delta tack.r "let" x: T = "E1" "in" "E2" --> "E2p"$, $Delta tack.r "E1" --> "E1p"$, $Delta, "x" = "E1p" tack.r "E2" --> "E2p"$ )) $ $ #proof-tree(eval("VAR", $Delta tack.r "x" --> "E"$, $Delta tack.r "x" = E$, )) $ $ #proof-tree(eval("FUNC", $Delta tack.r "func"< overline( "a")>( overline( "x":"P")) -> "T" { "E" } --> "func"<overline("a")>(overline("x":"P")) -> "T" { "Ep" }$, $"E" --> "Ep"$ )) $ $ #proof-tree(eval("FUNC-APP", $Delta tack.r ("E1")< overline( "T")>( overline( "E")) --> "Ep"$, $Delta tack.r "E1" --> "func" < overline("a")>( overline( "x":"P")) -> "T" { "E" }$, $Delta, overline("x:E") tack.r "E" --> "Ep"$)) $ $ #proof-tree(eval("ARR", $Delta tack.r [overline( "E")] --> [overline( "Ep")]$, $Delta tack.r overline("E") --> overline("Ep")$)) $ $ #proof-tree(eval("CONC", $Delta tack.r [overline("E1")]::[overline("E2")] --> [overline("E1p"), overline("E2p")]$, $Delta tack.r [overline("E1")] --> [overline("E1p")]$, $Delta tack.r [overline("E2")] --> [overline("E2p")]$)) $ $ #proof-tree(eval("FIRST-ARR", $Delta tack.r "first"([ "E1", overline( "E2")]) --> "E1p"$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r overline("E2") --> overline("E2p")$ )) $ $ #proof-tree(eval("REST-ARR", $Delta tack.r "rest"([ "E1", overline( "E2")]) --> overline("E2p")$, $Delta tack.r "E1" --> "E1p"$, $Delta tack.r overline("E2") --> overline("E2p")$ )) $ ]
https://github.com/MrToWy/Bachelorarbeit
https://raw.githubusercontent.com/MrToWy/Bachelorarbeit/master/Code/authGuard.typ
typst
#import("../Template/customFunctions.typ"): * #codly( highlights:( (line:13, label: <canActivateLine>), ) ) ```ts export class JwtAuthGuard extends AuthGuard('jwt') { canActivate(context: ExecutionContext) { const isPublic = this.reflector.get<boolean>( 'isPublic', context.getHandler(), ); if (isPublic) { return true; } return super.canActivate(context); } } ```
https://github.com/MattiaOldani/Generatore-Turni-Grest
https://raw.githubusercontent.com/MattiaOldani/Generatore-Turni-Grest/master/generator/template.typ
typst
#set align(center + horizon) #set page(flipped: true) = Turni animatori \ #table( columns: (auto, auto, auto, auto, auto, auto), inset: 10pt, align: horizon, [], [*Lunedì*], [*Martedì*], [*Mercoledì*], [*Giovedì*], [*Venerdì*],
https://github.com/sebaseb98/clean-math-thesis
https://raw.githubusercontent.com/sebaseb98/clean-math-thesis/main/README.md
markdown
MIT License
# clean-math-thesis [![Build Typst Document](https://github.com/sebaseb98/clean-math-thesis/actions/workflows/build.yml/badge.svg)](https://github.com/sebaseb98/clean-math-thesis/actions/workflows/build.yml) [![Repo](https://img.shields.io/badge/GitHub-repo-blue)](https://github.com/sebaseb98/clean-math-thesis) [![License: MIT](https://img.shields.io/badge/License-MIT-success.svg)](https://opensource.org/licenses/MIT) [Typst](https://typst.app/home/) thesis template for mathematical theses built for simple, efficient use and a clean look. Of course, it can also be used for other subjects, but the following math-specific features are already contained in the template: - theorems, lemmas, corollaries, proofs etc. prepared using [great-theorems](https://typst.app/universe/package/great-theorems) - equation settings - pseudocode package [lovelace](https://typst.app/universe/package/lovelace) included. Additionally, it has headers built with [hydra](https://typst.app/universe/package/hydra). ## Set-Up The template is already filled with dummy data, to give users an impression how it looks like. The thesis is obtained by compiling `main.typ`. To fit it to your needs - edit the data in `meta.typ` - (optional) change colors and appearance of the theorem environment in the `customization/`-folder. When adding chapters remember to also add them into `main.typ`. ### Disclaimer This template was created after I finished my master's thesis. I do not guarantee that it will be accepted by any university, please clarify in advance if it fulfills all requirements. If not, this template might still be a good starting point. ### Feedback & Improvements If you encounter problems, please open issues. In case you found useful extensions or improved anything I am also very happy to accept pull requests.
https://github.com/typst-community/glossarium
https://raw.githubusercontent.com/typst-community/glossarium/master/tests/non-regression/references-in-description.typ
typst
MIT License
// https://github.com/typst-community/glossarium/issues/55#issuecomment-2388176204 // #import "@preview/glossarium:0.4.1": make-glossary, print-glossary, gls, glspl #import "../../themes/default.typ": * #show: make-glossary #let glossary-terms = ( (key: "a", short: "a", long: "A", desc: [test a @b]), (key: "b", short: "b", long: "B", desc: [test b @c]), (key: "c", short: "c", long: "C", desc: [test c @d]), (key: "d", short: "d", long: "D", desc: [test d @e]), (key: "e", short: "e", long: "E", desc: [test e]), ) #register-glossary(glossary-terms) @a @b // @c #print-glossary(glossary-terms)
https://github.com/drupol/master-thesis
https://raw.githubusercontent.com/drupol/master-thesis/main/src/thesis/disclaimer.typ
typst
Other
#import "theme/disclaimer.typ": * #disclaimer( title: title, degree: degree, author: author, submissionDate: submissionDate, )
https://github.com/TechnoElf/mqt-qcec-diff-thesis
https://raw.githubusercontent.com/TechnoElf/mqt-qcec-diff-thesis/main/content/implementation/postprocessing.typ
typst
#import "@preview/gentle-clues:0.9.0": example, code == Post-processing of Edit Scripts Using the implementation of the diff algorithms and the benchmarking framework, initial tests of the complete equivalence checking flow could be performed. Naively applying gates based on the outputs of the diff algorithm generally results in a worse overall runtime for most test cases compared to the state of the art application scheme, however. Comparing the output sequences of the proportional application scheme to that of the diff application scheme reveals a few possible reasons for this performance regression. For instance, the diff algorithms tend to produce large blocks of insertion or deletion operations. This makes sense when the goal is to produce a human-readable edit script, however, this property is counterproductive for the equivalence checking flow. A good application schemes ideally interleaves corresponding gates so that the size of the @dd remains minimal. Based on these observations, a series of post-processing steps are introduced in an attempt to alleviate this issue. An alternative approach would have been to develop a new diff algorithm that produces edit scripts that are more suitable to equivalence checking, however post-processing proves to be effective and efficient enough to produce the desired results. This is possible due to the unique properties of the alternating equivalence checker based on @dd[s]. The correctness of the result only depends on all gates from both circuits being applied in the right order. The exact sequence in which left and right gates are applied is irrelevant. It is therefore possible to use such heuristics to modify the application sequence. The post-processing steps are explained in the next sections, followed by a discussion of the final sequence that was used to achieve the best performance. *Removing Empty Operations* This step simply removes any operation that applies neither left nor right gates. While this shouldn't have a great impact on performance, it does reduce the memory footprint of the array. #example[ As shown in @example_remove_empty_ops, entries in the sequence that contain only zeros are removed in this step. #figure( grid( columns: (4fr, 1fr, 4fr), [$(0, 2) \ (0, 0) \ (2, 2) \ (0, 0) \ (2, 0)$], align(horizon)[$->$], [$(0, 2) \ (2, 2) \ (2, 0)$] ), caption: [Removing empty operations.] ) <example_remove_empty_ops> ] *Merging Same Operations* The edit script sometimes contained consecutive operations that apply gates from the same side. This makes sense for a normal edit script, where operations may usually only operate on a single element, however, this restriction does not apply here. The alternating equivalence checker can apply any number of gates in a single step. It may therefore make sense to combine these operations wherever possible to reduce the length of the edit script. #example[ This step combines two consecutive operations by taking their sum. It does this wherever the left sides are both zero or the right sides are both zero. In @example_merge_same_ops, the first two operations are summed together this way. #figure( grid( columns: (4fr, 1fr, 4fr), [$(0, 1) \ (0, 1) \ (2, 2) \ (2, 0)$], align(horizon)[$->$], [$(0, 2) \ (2, 2) \ (2, 0)$] ), caption: [Merging same operations.] ) <example_merge_same_ops> ] *Swapping Left and Right Operations* The idea behind this post-processing step stemmed from the uncertainty of the way @mqt @qcec handles the left and right application of gates. If this was opposite to the expected direction, swapping the insertion and deletion operations should improve the run time. Applying this step, however, resulted in consistently worse run times. As such, this step served as a sanity check of whether or not the algorithm was producing the correct output. It was therefore not used in the final post processing sequence. #example[ @example_swap_ops demonstrates how insertion and deletion operations are swapped. Keep operations remain unchanged as they are symmetrical. This was achieved by simply swapping the first and second element of each tuple. #figure( grid( columns: (4fr, 1fr, 4fr), [$(0, 2) \ (2, 2) \ (2, 0)$], align(horizon)[$->$], [$(2, 0) \ (2, 2) \ (0, 2)$] ), caption: [Swapping left and right operations.] ) <example_swap_ops> ] *Splitting Large Operations* This step essentially implements the inverse of the "merging same" step. It aims to split up large operations. While splitting application operations like this should not affect the run time, this step was used to develop other, more effective post-processing methods. Two different approaches were implemented for this step. The initial implementation iteratively split up each operation where the size was above a certain threshold. The second implementation calculated the number of splits needed to reduce the size below a certain threshold and split the operation accordingly. #example[ As shown in @example_split_ops, each operation is split into two smaller operation. The threshold would be 1 in this case. #figure( grid( columns: (4fr, 1fr, 4fr), [$(0, 2) \ (2, 2) \ (2, 0)$], align(horizon)[$->$], [$(0, 1) \ (0, 1) \ (1, 1) \ (1, 1) \ (1, 0) \ (1, 0)$] ), caption: [Split large operations.] ) <example_split_ops> ] *Merging Left and Right Operations* When the @dd\-based equivalence checker is given an operation with both left and right gates (such as a "keep" operation in the diff), it applies the gates from either side sequentially. This is identical to having two consecutive operations that apply gates from opposite directions. The aim of this step is therefore to reduce the size of the edit script by combining such operations that would result in the same application order anyway. #example[ This step works similarly to the "merge same" step, however, it instead checks whether the opposite directions of two consecutive operations are zero. If this is the case, it sums them together, as shown in @example_merge_left_right_ops. #figure( grid( columns: (4fr, 1fr, 4fr), [$(0, 1) \ (1, 1) \ (1, 0) \ (1, 1) \ (0, 1) \ (1, 0)$], align(horizon)[$->$], [$(0, 1) \ (1, 1) \ (1, 0) \ (1, 1) \ (1, 1)$] ), caption: [Merging consecutive left and right operations.] ) <example_merge_left_right_ops> ] *Interleaving Left and Right Operations* This is the post processing step that had the most impact on the performance of the application scheme. It aims to split up operations, similar to the "splitting large operations" step, however, it does so only where it can interleave left and right application operations Interleaving the operations this way is analogous to creating a diagonal step pattern in the edit graph. This shape is exactly the path that produces the optimal sequence of applications to keep the @dd as close as possible to the identity by ensuring that each left gate is matched to a right gate. #example[ @example_interleave_left_right_ops demonstrates one iteration of this step with a threshold of less than 4. The two consecutive and opposite operations are split into four operations of which each consecutive pair has opposite application directions. #figure( grid( columns: (4fr, 1fr, 4fr), [$(4, 0)$ \ $(0, 4)$], align(horizon)[$->$], [$(2, 0) \ (0, 2) \ (2, 0) \ (0, 2)$] ), caption: [Interleaving consecutive left and right operations.] ) <example_interleave_left_right_ops> ] *Final Post-processing Steps* Various combinations of the procedures described in the previous sections were implemented in an attempt to reduce the run time. Most sequences either had no discernible effect or worsened the results. The best results were achieved with the following sequence of post processing steps: 1. Merge same operations. 2. Interleave left and right operations down to a threshold of 5 iteratively 3 times 3. Merge left and right operations 4. Remove empty operations The rationale behind these steps is as follows: Step one ensures that step two can work effectively. It makes it more likely for there to be two consecutive operations that apply gates from different sides. The second step then ensures that the @dd stays as close to the identity as possible while keeping the length of the edit script reasonably low. Step three reduces the size of the edit script by combining operations that would have been applied in the same sequence anyway, reducing the need to query the application scheme. The fourth step is simply there to clean up any empty operations that may be left by the merge and interleave steps. This is the sequence that was used to benchmark the diff-based equivalence checking approach in the next section.
https://github.com/ClazyChen/Table-Tennis-Rankings
https://raw.githubusercontent.com/ClazyChen/Table-Tennis-Rankings/main/history/2009/MS-12.typ
typst
#set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (1 - 32)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [1], [WANG Hao], [CHN], [3239], [2], [MA Long], [CHN], [3209], [3], [BOLL Timo], [GER], [3083], [4], [MA Lin], [CHN], [3052], [5], [SAMSONOV Vladimir], [BLR], [3041], [6], [WANG Liqin], [CHN], [3015], [7], [HAO Shuai], [CHN], [2989], [8], [ZHANG Jike], [CHN], [2943], [9], [XU Xin], [CHN], [2921], [10], [JOO Saehyuk], [KOR], [2833], [11], [CHEN Qi], [CHN], [2828], [12], [KISHIKAWA Seiya], [JPN], [2763], [13], [<NAME>], [DEN], [2720], [14], [MIZUTANI Jun], [JPN], [2718], [15], [YOSHIDA Kaii], [JPN], [2703], [16], [OVTCHAROV Dimitrij], [GER], [2691], [17], [APOLONIA Tiago], [POR], [2663], [18], [JIANG Tianyi], [HKG], [2656], [19], [<NAME>], [AUT], [2638], [20], [CHEUNG Yuk], [HKG], [2634], [21], [OH Sangeun], [KOR], [2630], [22], [#text(gray, "ZHANG Chao")], [CHN], [2611], [23], [HOU Yingchao], [CHN], [2610], [24], [KIM Junghoon], [KOR], [2605], [25], [<NAME>], [JPN], [2596], [26], [<NAME>], [GER], [2594], [27], [YOON Jaeyoung], [KOR], [2593], [28], [KO Lai Chak], [HKG], [2590], [29], [<NAME>], [AUT], [2587], [30], [TANG Peng], [HKG], [2585], [31], [<NAME>oran], [CRO], [2578], [32], [LEE Jungwoo], [KOR], [2576], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (33 - 64)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [33], [<NAME>], [SWE], [2574], [34], [PROKOPCOV Dmitrij], [CZE], [2568], [35], [KREANGA Kalinikos], [GRE], [2562], [36], [LI Ching], [HKG], [2556], [37], [<NAME>], [GER], [2548], [38], [GAO Ning], [SGP], [2547], [39], [<NAME>], [GER], [2545], [40], [CHUANG Chih-Yuan], [TPE], [2535], [41], [LI Ping], [QAT], [2531], [42], [#text(gray, "<NAME>")], [CHN], [2514], [43], [<NAME>], [KOR], [2514], [44], [<NAME>], [CRO], [2509], [45], [<NAME>], [PRK], [2502], [46], [<NAME>], [GRE], [2499], [47], [<NAME>], [AUT], [2490], [48], [<NAME>], [DOM], [2488], [49], [<NAME>], [KOR], [2486], [50], [<NAME>], [JPN], [2485], [51], [<NAME>], [FRA], [2478], [52], [<NAME>], [SWE], [2474], [53], [RUBTSOV Igor], [RUS], [2461], [54], [<NAME>], [KOR], [2454], [55], [SKACHKOV Kirill], [RUS], [2441], [56], [#text(gray, "<NAME>")], [CHN], [2439], [57], [<NAME>], [POL], [2428], [58], [<NAME>], [POL], [2425], [59], [KEINATH Thomas], [SVK], [2417], [60], [LUNDQVIST Jens], [SWE], [2416], [61], [TUGWELL Finn], [DEN], [2413], [62], [<NAME>], [KOR], [2401], [63], [<NAME>], [ROU], [2394], [64], [#text(gray, "<NAME>")], [SWE], [2391], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (65 - 96)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [65], [<NAME>], [CRO], [2385], [66], [<NAME>], [PRK], [2382], [67], [CHT<NAME>], [BLR], [2380], [68], [KORBEL Petr], [CZE], [2367], [69], [<NAME>], [SLO], [2366], [70], [<NAME>], [JPN], [2357], [71], [<NAME>], [IND], [2349], [72], [<NAME>], [KOR], [2349], [73], [MONTEIRO Thiago], [BRA], [2348], [74], [BLASZCZYK Lucjan], [POL], [2343], [75], [<NAME>], [ESP], [2341], [76], [LEGOUT Christophe], [FRA], [2340], [77], [<NAME>], [FRA], [2335], [78], [SMIRNOV Alexey], [RUS], [2333], [79], [<NAME>], [GER], [2324], [80], [TAKAKIWA Taku], [JPN], [2323], [81], [KIM Minseok], [KOR], [2317], [82], [MONRAD Martin], [DEN], [2317], [83], [KOSOWSKI Jakub], [POL], [2315], [84], [KUZ<NAME>], [RUS], [2314], [85], [SEO Hyundeok], [KOR], [2313], [86], [<NAME>], [KOR], [2313], [87], [<NAME>], [SWE], [2302], [88], [<NAME>], [ROU], [2302], [89], [<NAME>], [SGP], [2302], [90], [<NAME>], [JPN], [2301], [91], [<NAME>], [LAT], [2299], [92], [MATSUDAIRA Kenji], [JPN], [2294], [93], [<NAME>], [HKG], [2294], [94], [<NAME>], [TPE], [2293], [95], [<NAME>], [SVK], [2291], [96], [<NAME>], [ESP], [2290], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (97 - 128)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [97], [<NAME>], [SVK], [2290], [98], [PETO Zsolt], [SRB], [2286], [99], [SHMYREV Maxim], [RUS], [2278], [100], [<NAME>], [NGR], [2277], [101], [<NAME>], [AUT], [2275], [102], [<NAME>], [KOR], [2275], [103], [<NAME>], [BEL], [2274], [104], [CH<NAME>-Chieh], [TPE], [2272], [105], [<NAME>], [ENG], [2271], [106], [BOBOCICA Mihai], [ITA], [2270], [107], [#text(gray, "YANG Min")], [ITA], [2269], [108], [<NAME>], [PRK], [2267], [109], [<NAME>], [POL], [2267], [110], [<NAME>], [CRO], [2267], [111], [LIVENTSOV Alexey], [RUS], [2260], [112], [<NAME>], [SVK], [2260], [113], [#text(gray, "<NAME>henhua")], [CHN], [2255], [114], [<NAME>], [POR], [2254], [115], [MONTEIRO Joao], [POR], [2254], [116], [SHIMOYAMA Takanori], [JPN], [2252], [117], [KARAKASEVIC Aleksandar], [SRB], [2247], [118], [WU Chih-Chi], [TPE], [2237], [119], [HUANG Sheng-Sheng], [TPE], [2231], [120], [CHANG Yen-Shu], [TPE], [2225], [121], [WOSIK Torben], [GER], [2225], [122], [YANG Zi], [SGP], [2224], [123], [<NAME>], [ROU], [2221], [124], [<NAME>], [AUT], [2221], [125], [ERLANDSEN Geir], [NOR], [2221], [126], [<NAME>], [HUN], [2220], [127], [<NAME>], [DEN], [2205], [128], [<NAME>], [FRA], [2200], ) )
https://github.com/Mc-Zen/tidy
https://raw.githubusercontent.com/Mc-Zen/tidy/main/examples/funny-math/funny-math-complex.typ
typst
MIT License
/// Construct a complex number of the form /// $ z= a + i b in CC. $ /// /// - real (float): Real part of the complex number. /// - imag (float): Imaginary part of the complex number. /// -> float #let complex(real, imag) = { (radius * calc.cos(phi), radius * calc.sin(phi)) } /// Construct a complex number from polar coordinates: @@funny-sqrt() /// $ z= r e^(i phi) in CC. $ /// #image-polar /// - phi (float): Angle to the real axis. /// - radius (float): Radius (euclidian distance to the origin). /// -> float #let polar(phi, radius: 1.0) = { (radius * calc.cos(phi), radius * calc.sin(phi)) }
https://github.com/hzkonor/bubble-template
https://raw.githubusercontent.com/hzkonor/bubble-template/main/README.md
markdown
# Bubble template Simple and colorful template for [Typst](https://typst.app). Also available as a [package](https://typst.app/universe/package/bubble). This template includes the package [codelst](https://github.com/jneug/typst-codelst), and you can add others if you want. ## Features You can select a main color (default is `#E94845`) which is coloring : - list items - links - inline blocks - headings - words in the `color-words` array (be careful to put a comma if you're highlighting one word : `("word",)`) Every page is numbered and has the title of the document and the name of the author at the top. ## Examples You can find an example Typst file [here](https://github.com/hzkonor/bubble-template/blob/main/main.typ) and the corresponding [pdf](https://github.com/hzkonor/bubble-template/blob/main/main.pdf) ### Default color | Main page | TOC | List of features | Page | | -- | -- | -- | -- | | ![main page](assets/red_1.png) | ![Table of Contents](assets/red_2.png) | ![List of features](assets/red_3.png) | ![Example page](assets/red_4.png) | ### Other color Here, `#4DA6FF` | Main page | TOC | List of features | Page | | -- | -- | -- | -- | | ![main page](assets/blue_1.png) | ![Table of Contents](assets/blue_2.png) | ![List of features](assets/blue_3.png) | ![Example page](assets/blue_4.png) |
https://github.com/songoffireandice03/simple-template
https://raw.githubusercontent.com/songoffireandice03/simple-template/main/templates/hop.typ
typst
#import "@preview/showybox:2.0.1": * #import "@preview/ctheorems:1.1.2": * #show: thmrules #let oran = rgb("#877ac6") #let brown = rgb("#964b00") #let truered = rgb("#ff0000") #let showythm1(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: gray, title-color: black, footer-color: gray.lighten(20%), thickness: (left: 1pt), radius: 0pt ), body-style: ( color: black ), footer-style: ( color: white ), title-style: ( color: white, weight: "bold", ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head, ) } #let showythm2(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: gray, title-color: white, footer-color: gray.darken(20%), thickness: (left: 1pt), radius: 0pt ), body-style: ( color: black ), footer-style: ( color: white ), title-style: ( color: black, weight: "bold", ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm3(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: fuchsia, title-color: fuchsia.lighten(80%), footer-color: fuchsia.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: fuchsia.darken(50%), weight: "bold", ), footer-style: ( color: fuchsia.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm4(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: purple, title-color: purple.lighten(80%), footer-color: purple.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: purple.darken(50%), weight: "bold", ), footer-style: ( color: purple.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm5(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: teal, title-color: teal.lighten(80%), footer-color: teal.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: teal.darken(50%), weight: "bold", ), footer-style: ( color: teal.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm6(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: orange, title-color: orange.lighten(80%), footer-color: orange.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: orange.darken(50%), weight: "bold", ), footer-style: ( color: orange.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm7(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: green, title-color: green.lighten(80%), footer-color: green.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: green.darken(50%), weight: "bold", ), footer-style: ( color: green.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm8(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: red, title-color: red.lighten(80%), footer-color: red.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: red.darken(50%), weight: "bold", ), footer-style: ( color: red.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm9(head, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: blue, title-color: blue.lighten(80%), footer-color: blue.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: blue.darken(50%), weight: "bold", ), footer-style: ( color: blue.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm10(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: yellow, title-color: yellow.lighten(80%), footer-color: yellow.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: yellow.darken(50%), weight: "bold", ), footer-style: ( color: yellow.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm11(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: olive, title-color: olive.lighten(80%), footer-color: olive.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: olive.darken(50%), weight: "bold", ), footer-style: ( color: olive.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm12(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: navy, title-color: navy.lighten(80%), footer-color: navy.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: navy.darken(50%), weight: "bold", ), footer-style: ( color: navy.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm13(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( title-color: aqua.lighten(80%), footer-color: aqua.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: aqua.darken(50%), weight: "bold", ), footer-style: ( color: aqua.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm14(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: maroon, title-color: maroon.lighten(80%), footer-color: maroon.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: maroon.darken(50%), weight: "bold", ), footer-style: ( color: maroon.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm15(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: lime, title-color: lime.lighten(80%), footer-color: lime.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: lime.darken(50%), weight: "bold", ), footer-style: ( color: lime.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm16(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: eastern, title-color: eastern.lighten(80%), footer-color: eastern.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: eastern.darken(50%), weight: "bold", ), footer-style: ( color: eastern.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm17(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: silver, title-color: silver.lighten(80%), footer-color: silver.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: silver.darken(50%), weight: "bold", ), footer-style: ( color: silver.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm18(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: gray, title-color: gray.lighten(80%), footer-color: gray.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: gray.darken(70%), weight: "bold", ), footer-style: ( color: gray.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm19(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: oran, title-color: oran.lighten(80%), footer-color: oran.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: oran.darken(70%), weight: "bold", ), footer-style: ( color: oran.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm20(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: oran, title-color: oran.lighten(80%), footer-color: oran.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: oran.darken(70%), weight: "bold", ), footer-style: ( color: oran.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let showythm21(head, number: 0, base: "heading", base_level: 1) = { thmenv( head, base, base_level, (name, number, body, ..args) => { name = if name != none {[(#name)]} else [] showybox( title: [#head #number #name], frame: ( border-color: brown, title-color: brown.lighten(80%), footer-color: brown.lighten(90%), thickness: (left: 1pt), radius: 0pt ), title-style: ( color: brown.darken(70%), weight: "bold", ), footer-style: ( color: brown.darken(30%) ), sep: ( dash: "loosely-dashed" ), ..args.named(), ..args.pos(), ..body ) }).with( supplement: head ) } #let _guidedquestion = showythm1("Guided Question") #let _claim = showythm2("Claim") #let _hint = showythm3("Gợi ý") #let _theorem = showythm13("Định lý") #let _note = showythm5("Lưu ý") #let _lemma = showythm6("Bổ đề") #let _warning = showythm7("Warning") #let _problem = showythm4("Vấn đề") #let _axiom = showythm8("Tiên đè") #let _remark = showythm10("Remark") #let _proposition = showythm11("Mệnh đề") #let _example = showythm12("Ví dụ") #let _exercise = showythm9("Bài tập") #let _question = showythm19("Câu hỏi") #let _workedexample = showythm14("Worked Example") #let _definition = showythm15("Định nghĩa") #let _proposal = showythm16("Proposal") #let _convention = showythm17("Quy ước") #let _assumption = showythm18("Assumption") #let _corollary = showythm20("Hệ quả") #let _placeholder = showythm21("Placeholder") // showythm color-number correspondence // 1 black // 2 white // 3 fuchsia // 4 purple // 5 teal // 6 orange // 7 green // 8 red // 9 blue // 10 yellow // 11 olive // 12 navy // 13 aqua // 14 maroon // 15 lime // 16 eastern // 17 silver // 18 gray // 19 oran // 20 oran // 21 brown #let definition(name: none, ..args) = { _definition(name, args.pos(), ..args.named()) } #let placeholer(name: none, ..args) = { _placeholer(name, args.pos(), ..args.named()) } #let proposition(name: none, ..args) = { _proposition(name, args.pos(), ..args.named()) } #let lemma(name: none, ..args) = { _lemma(name, args.pos(), ..args.named()) } #let assumption(name: none, ..args) = { _assumption(name, args.pos(), ..args.named()) } #let corollary(name: none, ..args) = { _corollary(name, args.pos(), ..args.named()) } #let axiom(name: none, ..args) = { _axiom(name, args.pos(), ..args.named()) } #let problem(name: none, ..args) = { _problem(name, args.pos(), ..args.named()) } #let example(name: none, ..args) = { _example(name, args.pos(), ..args.named()) } #let remark(name: none, ..args) = { _remark(name, args.pos(), ..args.named()) } #let proposal(name: none, ..args) = { _proposal(name, args.pos(), ..args.named()) } #let workedexample(name: none, ..args) = { _workedexample(name, args.pos(), ..args.named()) } #let convention(name: none, ..args) = { _convention(name, args.pos(), ..args.named()) } #let claim(name: none, ..args) = { _claim(name, args.pos(), ..args.named()) } #let warning(name: none, ..args) = { _warning(name, args.pos(), ..args.named()) } #let theorem(name: none, ..args) = { _theorem(name, args.pos(), ..args.named()) } #let guidedquestion(name: none, ..args) = { _guidedquestion(name, args.pos(), ..args.named()) } #let hint(name: none, ..args) = { _hint(name, args.pos(), ..args.named()) } #let question(name: none, ..args) = { _question(name, args.pos(), ..args.named()) } #let exercise(name: none, ..args) = { _exercise(name, args.pos(), ..args.named()) } #let note(name: none, ..args) = { _note(name, args.pos(), ..args.named()) }
https://github.com/42CrMo4/InvLabel
https://raw.githubusercontent.com/42CrMo4/InvLabel/main/Text+Barcode.typ
typst
MIT License
// Import necessary libraries #import "@preview/tiaoma:0.1.0": qrcode // Read CSV file #let results = csv("part.csv", delimiter: ";") // Set the page margins #set page( width: 25.91mm, height: 16mm, margin: ( y: 0mm, x: 0.5mm, ), ) // Loop through the CSV data #for c in results [ // Set text position #set text(2mm) #align(center)[= #c.at(2)] // Center-align the text of the second column #set text(5pt) // Create a QR code with part information #let x = "{\"" + c.at(4) + "\":" + c.at(0) +"}" #align(center)[ #qrcode(x, height: 10.5mm) #let y = c.at(4) + ": " + c.at(0) #pad(top:-1.5mm, text(y)) ] ]
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/acrostiche/0.1.0/README.md
markdown
Apache License 2.0
# Acrostiche (0.1.0) Manages acronyms so you don't have to. ## Usage The main goal of Acrostiche is to keep track of which acronym to define. ### Define acronyms and proxy functions First, define the acronyms in a dictionary named `acronyms` with the keys being the acronyms, and the values an array of their definition. If there is only a singular version of the definition, the array contain only one value (don't forget the trailing comma to force typst to consider it as an array). If there are both singular and plural versions, define the definition as an array where the first item is the singular definition and the second item is the plural. Then, initialize arostiche with the acronyms you just defined with the `#init-acronyms(...)` function: Here is a sample of the `acronyms.typ` file: ``` #import "@preview/acrostiche:0.1.0": * #let acronyms = ( "NN": ("Neural Network",), "OS": ("Operating System",), "BIOS": ("Basic Input/Output System", "Basic Input/Output Systems"), ) #init-acromyns(acronyms) ``` ### Call acrostiche functions Once the acronyms and proxy functions are defined, you can use them in the text with the `#acr(...)` function. The argument is the acronym as a string (for example "BIOS"). On the first call of the function, it returns the acronym with its definition (for example "Basic Input/Output System (BIOS)"). To get the plural version of the acronym, you can use the `#acrpl(...)` function that adds an 's' after the acronym. If a plural version of the definition is provided, it will be used if the first use of the acronym is plural. Otherwise, the singular version is used and a trailing 's' is added. At any point in the document you can reset acronyms with the functions `#reset-acronym(...)` (for a single acronym) or `reset-all-acronyms()` (to reset all acronyms). After a reset, the next use of the acronym is expanded. You can also print an index of all acronyms used in the document with the `#print-index()` function. The index is printed as a section for which you can choose the heading level and outline parameters (with respectively the `level: int` and `outlined: bool` parameters). You can also choose their order with the `sorted: string` parameter that accept either an empty string (print in the order their are defined), "up" (print in ascending alphabetical order), or "down" (print in descending alphabetical order). The index contains all the acronyms you defined. Finally, you can call the `#display-def(...)` function to get the definition of an acronym. Set the `plural` parameter to true to get the plural version. ## Possible Errors: * If an acronyms are not defined, an error will tel you which acronym is not defined. Simply add it to the dictionary or check the spelling. * For every acronym "ABC" that you define, the associate state named "acronym-state-ABC" is initialized and used. To avoid errors do not try to use this state manually for other purposes. Similarly the state named "acronyms" is reserved to acrostiche, avoid using it. Have fun acrostiching!
https://github.com/Seanwanq/Typst-Course-Report-Template
https://raw.githubusercontent.com/Seanwanq/Typst-Course-Report-Template/main/README.md
markdown
https://typst.app/project/rVH06qelWgRtY0AaCkhNoT Used [codly/README.md at main · Zheoni/codly (github.com)](https://github.com/Zheoni/codly/blob/main/README.md).
https://github.com/sthenic/technogram
https://raw.githubusercontent.com/sthenic/technogram/main/src/grouped-outline.typ
typst
MIT License
/* Convenience functions to generate grouped outlines. */ #import "keep-with-next.typ": * /* We use a figure (taking up no space on the page) to place an outlineable item so that we can construct a custom outline later on. We set the kind based on the group and the supplement to something that all objects will have in common. That way, we can filter by groups and also look up all elements and later sort them by their groups. */ /* From https://github.com/typst/typst/discussions/2681 */ #let grouped-outline-entry( caption, group, default-group, ) = hide(box(height: 0pt, figure( none, kind: if group != none { group } else { default-group }, supplement: default-group, caption: caption, outlined: true, ))) /* Insert a grouped outline, optionally filtering on a list of groups. */ #let grouped-outline( groups, show-title, supplement, default-group, ) = context { show outline: set par(leading: 0.8em, first-line-indent: 0pt) set outline(fill: repeat[#h(3pt).#h(3pt)]) /* Custom outline entry to remove the supplement. */ show outline.entry: it => { if it.at("label", default: none) == <technogram-grouped-outline-entry> { it } else { let indent = if show-title and it.element.kind != default-group { h(2em) } else { none } [#outline.entry( it.level, it.element, indent + it.element.caption.body, it.fill, it.page )<technogram-grouped-outline-entry>] } } /* Determine which object groups to include in the outline. */ let outline-groups = if groups != none { groups } else { /* Put the objects without a group first. */ let result = () result.push(default-group) /* Query by the supplement and push unique entries using the `kind` field. */ for it in query(figure.where(supplement: supplement)) { if it.kind not in result { result.push(it.kind) } } result } for group in outline-groups { if outline-groups.len() > 0 { /* Don't place a heading for the default group or if disabled altogether. */ if show-title and group != default-group { /* Attempt to locate the page of any label with the same name as the group. We have to gate behind a `query` because `locate` must be successful. */ let (label, page) = if query(label(group)).len() > 0 { let location = locate(label(group)) (link(location)[#text(weight: "bold", fill: text.fill)[#group]], strong[#location.page()]) } else { (strong(group), none) } /* We keep the heading together with the first entry. */ keep-with-next(threshold: 2em)[ #grid( columns: (auto, 1fr), align: (left, right), label, page ) ] } } outline( title: none, target: figure.where(kind: group) ) } }
https://github.com/timon-schelling/uni-phi111-logic-essay-2023-2024
https://raw.githubusercontent.com/timon-schelling/uni-phi111-logic-essay-2023-2024/main/src/main.typ
typst
#import "template/template.typ": * #show: project.with( title: "Title", authors: ( "<NAME>", ) ) = Zitate == Direkte Zitate "Das ist ein direktes Zitat". @roux2013[&12] == Indirekte Zitate Das ist ein indirektes Zitat. @roux2013[vgl.&12] == Mehrere Quellen Das ist ein Zitat mit mehreren Quellen. @roux2013[vgl&!12]@beckmann2015a[vgl.&!34] == Zitate mit gleicher Quelle Das ist ein Zitat. @roux2013[vgl.&12] Das ist ein Zitat mit gleicher Quelle. @roux2013[vgl.&34] == Zitat mit `cite` Funktion Das ist ein indirektes Zitat. #cite(<roux2013>, supplement: "vgl.&12") #pagebreak() = Einleitung #lorem(20) @beckmann2015a[vgl.&345] #lorem(20) @hazewinkel1993[vgl.&386-389]@beckmann2015b[vgl.&18-20] = Hauptteil #lorem(10) @beckmann2015b[vgl.&35-38] #lorem(20) @roux2013[vgl.&3]@beckmann2015a[vgl.&239-241] @beckmann2015a[vgl.&345] == Thema #lorem(20) @metzsch2011[vgl.&75-78] "#lorem(10)" @roux2013[437] === Thema #lorem(16) @roux2013[vgl.&21-23] #lorem(15) @roux2013[vgl.&24] === Thema #lorem(120) = Fazit #lorem(20) = Ausblick #lorem(20)
https://github.com/bkorecic/curriculum
https://raw.githubusercontent.com/bkorecic/curriculum/main/english.typ
typst
#import "template.typ": conf, entry, emoji, sensitive // Template setup #show: conf = #emoji.page.pencil Summary Currently pursuing a Master's degree in Computer Science. Interested in software development, security, low-level programming, algorithms and data structures, mathematics, and education. = #emoji.mortarboard Education #entry( title: [Universidad de Chile], subtitle: [Computer Science Engineering], location: [Santiago, Chile], date: [2018 -- Present], ) #entry( title: [Universidad de Chile], subtitle: [MSc. in Computer Science], location: [Santiago, Chile], date: [2024 -- Present], ) = #emoji.wrench Experience #entry( title: [Inria], subtitle: [Research Intern], location: [Paris, France], date: [January 2024 -- April 2024], description: ( [Three month internship in the Inria-AIO team.], [Participated in various academic projects, including topics like hardware security, embedded systems, IoT and multi-robot systems.] ) ) #entry( title: [Millennium Institute Foundational Research on Data], subtitle: [Software Engineering Intern], location: [Santiago, Chile], date: [January 2022 -- February 2022], description: ( [Modernization of a C++ project.], [Reimplementation of compression and search algorithms for large string dictionaries.] ) ) #entry( title: [SARCAN], subtitle: [Software Engineering Intern], location: [Santiago, Chile], date: [January 2021 -- February 2021], description: ( [Development of a web application for performing CRUD operations on a database and interacting with an optimizer.], [Creation of a static website built with Hugo for internal company documentation.], ) ) #entry( title: [Easy Program Checking], subtitle: [Developer], location: [Santiago, Chile], date: [August 2020 -- January 2021], description: ( [Open source web application created with Django used for the grading of students' assignments in computer science subjects.], ) ) #entry( title: [Preuniversitario <NAME>], location: [Santiago, Chile], date: [2020], description: ( [Volunteered as mathematics teacher at an institution that assists economically disadvantaged students in accessing higher education.], ) ) #entry( title: [Brazilian ICPC Summer School], location: [Campinas, Brasil], date: [January 2020], description: ( [Participated in the ICPC Brazil Summer Camp, World Finals class.], ) ) #entry( title: [Universidad de Chile], subtitle: [Teaching Assistant], location: [Santiago, Chile], date: [2020 -- Present], description: ( [CC4005 Competitive Programming (2021 to 2024).], [CC3101 Discrete Mathematics for Computer Science (2023).], [CC3301 Systems Programming (2021 and 2022).], [CC3003 Algorithms and Data Structures (2020 and 2021).] ) ) = #emoji.trophy Achievements #entry( title: [International Collegiate Programming Contest], subtitle: [Competitor], description: ( [*ICPC 2023:* Placed 7th in the South America/South finals. Second place in Chile. Qualified to the 2024 ICPC Latin America Championship in Guadalajara, Mexico.], [*ICPC 2021:* Placed 6th in the South America/South finals. First place in Chile.], [*ICPC 2019:* Placed 16th in the South America/South finals. Third place in Chile.], [*ICPC 2018:* Placed 31st in the South America/South finals. Sixth place in Chile.], ) ) #entry( title: [IEEExtreme], subtitle: [Competitor], description: ( [*IEEExtreme 15.0:* Placed 21st out of 2402 teams worldwide.], [*IEEExtreme 13.0:* Placed 116th out of 2534 teams worldwide.], ) ) #columns[ = #emoji.computer Skills - *Programming:* C, C++, Python, Java, SQL, Javascript, Bash, Scheme, OCaml. - *Frameworks:* React, Django, Flask, Qt. - *Other:* Docker, Linux, Git, PostgreSQL, NoSQL, Firebase, AWS, DigitalOcean. #colbreak() = #emoji.globe.meridian Languages - *Spanish:* Native - *English:* Advanced ]
https://github.com/AU-Master-Thesis/thesis
https://raw.githubusercontent.com/AU-Master-Thesis/thesis/main/sections/2-background/technical-introduction.typ
typst
MIT License
#import "../../lib/mod.typ": * == Gaussian Models <s.b.gaussian-models> // Reasons from @gbp-visual-introduction // (1) they accurately represent the distribution for many real world events , (2) they have a simple analytic form, (3) complex operations can be expressed with simple formulae and (4) they are closed under marginalization, conditioning and taking products (up to normalization). // reword these reasons! // Rewording from Gemini: // Realistic Modeling: Gaussian models effectively capture the way many physical phenomena and sensor readings are distributed in the real world. // Mathematical Simplicity: Gaussian models have a clean mathematical structure, making them easy to work with. // Computational Efficiency: Calculations involving Gaussian models can be performed using straightforward formulas, keeping computations fast. // Flexibility: Gaussian models maintain their form under common statistical operations (marginalization, conditioning, products), ensuring ease of manipulation within robotic systems. To eventually understand #acr("GBP"), the underlying theory of Gaussian models is detailed in this section. Gaussian models are often chosen when representing uncertainty due to the following reasons: #set enum(numbering: req-enum.with(prefix: "Reason ", color: accent)) + _*Realistic Modeling:*_ Gaussian models effectively capture the way many physical phenomena and sensor readings are distributed in the real world.@gbp-visual-introduction + _*Mathematical Simplicity:*_ Gaussian models have a clean mathematical structure, making them easy to work with.@gbp-visual-introduction + _*Computational Efficiency:*_ Calculations involving Gaussian models can be performed using straightforward formulas, keeping computations fast.@gbp-visual-introduction + _*Flexibility:*_ Gaussian models maintain their form under common statistical operations (marginalization, conditioning, products), ensuring ease of manipulation within robotic systems.@gbp-visual-introduction // Explain the two ways of representing Gaussian models in the exponential energy form // - Moments form // - Canonical form // First describe what exponential energy form is A Gaussian distribution can be represented in the exponential energy form, which is a common way of representing probability distributions. The exponential energy form is defined as in @eq-exponential-energy@gbp-visual-introduction: $ p(x) = 1/Z exp(-E(x)) $<eq-exponential-energy> // #jens[What does $Z$ and $E$ mean?] // Then describe the two ways of representing Gaussian models in the exponential energy form // A Gaussian model can be written in two ways; the _moments form_ and the _canonical form_. In the exponential energy form, a Gaussian model can be represented in two ways; the _moments form_ and the _canonical form_. The moments form is defined by the mean vector, $mu$, and the covariance matrix, $Sigma$@gbp-visual-introduction. The canonical form is defined by the information vector, $eta$, and the precision matrix, $Lambda$. The energy parameters, energy equations, and computational efficiency for certain aspects of the two forms are compared in @f.gaussian-models. #{ let title(content) = text(black, weight: 400, content + ":", style: "italic") let fc-size = 55% let f-size = 1.2em set par(first-line-indent: 0em) [ #figure( gridx( columns: (1fr, 1fr), blocked(title: "Moments Form")[ #set text(size: f-size) #v(0.5em) #boxed(color: theme.mauve)[*Parameters:*] // - Mean vector, #text(theme.mauve, $mu$) // - Covariance matrix, #text(theme.mauve,$Sigma$). \ \ #move(dx: -0.25em, gridx( columns: (fc-size, 1fr), title("Mean"), text(theme.mauve, $mu$), title("Covariance"), text(theme.mauve, $Sigma$) )) #v(0.5em) #boxed(color: theme.yellow)[*Energy Equation:*] #v(0.35em) $E(x) = 1/2 (x - #text(theme.mauve, $mu$))^top #text(theme.mauve, $Sigma$)^(-1) (x - #text(theme.mauve, $mu$))$ \ \ #boxed(color: theme.teal)[*Computational Efficiency:*] \ #move(dx: -0.25em, gridx( columns: (fc-size, 1fr), title("Marginalization"), [#cost.cheap], title("Conditioning"), [#cost.expensive], title("Product"), [#cost.expensive] )) #v(-0.5em) ], blocked(title: "Canonical Form")[ #set text(size: f-size) #v(0.5em) #boxed(color: theme.mauve)[*Parameters:*] // - Information vector #text(theme.mauve, $eta = Sigma^-1 mu$) // - Precision matrix #text(theme.mauve, $Lambda = Sigma^-1$). \ \ #move(dx: -0.25em, gridx( columns: (fc-size, 1fr), title("Information"), [$#text(theme.mauve, $eta$) = #text(theme.mauve, $Sigma$)^(-1)$ #text(theme.mauve, $mu$)], title("Precision"), [$#text(theme.mauve, $Lambda$) = #text(theme.mauve, $Sigma$)^(-1)$] )) #v(0.5em) #boxed(color: theme.yellow)[*Energy Equation:*] #v(0.35em) $E(x) = 1/2 x^top #text(theme.mauve, $Lambda$) x - #text(theme.mauve, $eta$)^top x$ \ \ #boxed(color: theme.teal)[*Computational Efficiency:*] \ #move(dx: -0.25em, gridx( columns: (fc-size, 1fr), title("Marginalization"), [#cost.expensive], title("Conditioning"), [#cost.cheap], title("Product"), [#cost.cheap] )) #v(-0.5em) ] ), caption: [Camparison between the moments form and the canonical form of representing Gaussian models.@gbp-visual-introduction] )<f.gaussian-models> ] } As outlined in @f.gaussian-models the #gaussian.canonical is much more computationally efficient when it comes to conditioning and taking products, while the #gaussian.moments excels at marginalization. This is due to the fact that the canonical form is closed under conditioning and taking products, while the moments form is closed under marginalization@gbp-visual-introduction. In the context of factor graphs in software, the #gaussian.moments is often preferred due to its efficiency in marginalization, which is a common operation in factor graph inference@gbp-visual-introduction. Furthermore, the #gaussian.moments is unable to represent unconstrained distributions, as would be yielded by an unanchored factor graph. However, this is not a problem encountered in practice for this thesis, as the factor graphs are anchored. More detail on this in @s.m.factor-graph. // why is that? == Probabilistic Inference <s.b.probabilistic-inference> To contextualize factor graph inference, the underlying probabilistic inference theory is introduced. The goal of probabilistic inference is to estimate the probability distribution of a set of unknown variables, $#m.Xb$, given some observed or known quantities, $#m.D$. This is done by combining prior knowledge with $#m.D$, to infer the most likely distribution of the variables@gbp-visual-introduction. See @ex.probabilistic-inference. #example( caption: [Probabilistic Inference in Meteorology] )[ // Everyday example describing how meteorological forecasts are made An everyday example of probabilistic inference is in the field of meteorology. Meteorologists use prior knowledge of weather patterns ($#m.D$), combined with observed data to infer the most likely weather forecast for the upcoming days ($#m.Xb$). ]<ex.probabilistic-inference> // @ex.probabilistic-inference // Explain bayesian inference Baye's rule is the foundation of probabilistic inference, and is used to update the probability distribution of a set of variables, $#m.Xb$, given some observed data, $#m.D$. The rule is defined as in @eq-bayes-theorom[Equation]@gbp-visual-introduction: $ p(#m.Xb|#m.D) = (p(#m.D|#m.Xb)p(#m.Xb)) / (p(#m.D)) $<eq-bayes-theorom> This posterior distribution describes our belief of $#m.Xb$, after observing $#m.D$, which can then be used for decision making about possible future states@gbp-visual-introduction. Furthermore, when we have the posterior, properties about $#m.Xb$ can be computed: #set enum(numbering: req-enum.with(prefix: "Property ", color: theme.green)) + The most likely state of $#m.Xb $, the #acr("MAP") estimate $#m.Xb _"MAP"$, is the state with the highest probability in the posterior distribution. See @eq-map-estimate@gbp-visual-introduction: $ #m.Xb _"MAP" = "argmax"_#m.Xb p(#m.Xb|D) $<eq-map-estimate> + The marginal posteriors, summarising our beliefs of individual variables in $#m.Xb $, can be computed by marginalising the posterior distribution, see @eq-marginal-posterior@gbp-visual-introduction, where $#m.Xb \\#m.x _i$ denotes the set difference operation: $ p(#m.Xb _i|D) = sum_(#m.Xb \\ #m.x _i) p(#m.Xb|D) $<eq-marginal-posterior> // The most common methods for probabilistic inference are exact inference and approximate inference. // #jonas[have not gotten around to rounding this section off]
https://github.com/EpicEricEE/typst-plugins
https://raw.githubusercontent.com/EpicEricEE/typst-plugins/master/droplet/README.md
markdown
# droplet A package for creating dropped capitals in typst. > [!WARNING] > This repository has been archived. The package has been moved to the [EpicEricEE/typst-droplet](https://github.com/EpicEricEE/typst-droplet) repository. ## Usage The package comes with a single `dropcap` function that takes content and a few optional parameters. The first letter can either be passed as a positional parameter, or is automatically extracted from the passed body. The rest of the content will be wrapped around the dropped capital by splitting it into two paragraphs. The parameters are as follows: | Parameter | Description | Default | |------------------|-------------------------------------------------------------------|---------| | `height` | The height of the dropped capital in lines or as length. | `2` | | `justify` | Whether the text should be justified. | `auto` | | `gap` | The space between the first letter and the text. | `0pt` | | `hanging-indent` | The indent of lines after the first. | `0pt` | | `overhang` | The amount by which the first letter should hang into the margin. | `0pt` | | `depth` | The space below the dropped capital in lines or as length. | `0pt` | | `transform` | A function to be applied to the first letter. | `none` | | `..text-args` | Named arguments to be passed to the text function. | `(:)` | ```typ #import "@preview/droplet:0.2.0": dropcap #set par(justify: true) #dropcap( height: 3, gap: 4pt, hanging-indent: 1em, overhang: 8pt, font: "Curlz MT", )[ *Typst* is a new markup-based typesetting system that is designed to be as _powerful_ as LaTeX while being _much easier_ to learn and use. Typst has: - Built-in markup for the most common formatting tasks - Flexible functions for everything else - A tightly integrated scripting system - Math typesetting, bibliography management, and more - Fast compile times thanks to incremental compilation - Friendly error messages in case something goes wrong ] ``` ![Result of example code.](assets/example.svg) ## Extended Customization To further customize the appearance of the dropped capital, you can apply a `transform` function, which takes the first letter as a string and returns the content to be shown. The font size of the letter is then scaled so that the height of the transformed content matches the given height. ```typ #import "@preview/droplet:0.2.0": dropcap #dropcap( height: 2, justify: true, gap: 6pt, transform: letter => style(styles => { let height = measure(letter, styles).height grid(columns: 2, gutter: 6pt, align(center + horizon, text(blue, letter)), // Use "place" to ignore the line's height when // the font size is calculated later on. place(horizon, line( angle: 90deg, length: height + 6pt, stroke: blue.lighten(40%) + 1pt )), ) }), lorem(21) ) ``` ![Result of example code.](assets/example-transform.svg)
https://github.com/JakkuSakura/MyResume
https://raw.githubusercontent.com/JakkuSakura/MyResume/master/resume_english.typ
typst
/* =============================== ===== RESUME TEMPLATE 2.0 ===== =============================== ===== April 21st 2022 ===== =============================== Welcome to the 2.0 version of the Super Cool Resume Template: now with 100% less LaTeX! This is a second major iteration of the Resume Template made by <NAME>, originally created for the University of Utah's Triangle Engineering Professional Education students. It is now also used for Chaotic Good Computing professional development mentoring & consulting. You can find more resources at https://chaoticgood.computer/tags/mentoring/professional-dev If you have any questions, feedback, or advice, please feel free to contact me at <EMAIL> If you publicly post or share the source code to your resume, you're totally allowed (and I would encourage you) to delete all of the commented sections in the template, or use the `resume.typ` file instead. This will help keep your resume looking clean and professional. ====================== ===== QUICKSTART ===== ====================== 1. If you haven't already, create a (free!) Typst account at https://typst.app 2. Once you have an account, go to https://typst.app/universe/package/resume-starter-cgc 3. Click on "Create Project in App", give your project a title, and press "Create" 4. Start editing! This copy is your own personal copy to edit however you want! - If you would like to edit a copy of the resume without the guide, use the `resume.typ` file. === Basics of Resumes === In general, resumes ought to be *one page* of concise, bulleted, well-formatted descriptions of things about yourself and things you've done that explain who you are and what you can do to somebody who's looking to hire somebody like you. While there are exceptions to the one-page rule (which would make it a CV, reserved for people with Ph.Ds and many publications, or those with decades in their field and significant and notable achievements), you should keep it to one page. Having more than one page on your resume will lead to one of two likely reactions: 1. "This person clearly didn't need to use two (or more) pages", which immediately shifts the reviewer to a mindset that you're overestimating your credentials; or 2. The person reviewing your resume doesn't even think to check how many pages there are and only sees the first one anyway In general, if you want to include more information about yourself that would spill your resume past the first page, you should use LinkedIn as your "full" resume and continue to keep this document to just a one-page review of the most relevant things about yourself. Along with this, there are two sections that people expect to see on resumes: 1. Education (or equivalent) section (see the Education section for more details) 2. Experience section (see the Experience section for more details) === Basics of Typst === Previously, this template was created in LaTeX, another PDF typesetting language. To celebrate its 40th(!) birthday, we're killing it in favor of Typst! Typst is a gentler PDF typesetting language that supports putting far more of the "noise" of your formatting into a separate file. That way, the only thing you really have to worry about is putting your content into this file. To learn more about Typst, you can find the documentation here: https://typst.app/docs === Opinion: Why should you use this template? === This template will handle 99.9% of your resume's formatting for you so you don't have to spend time massaging the formatting in an editor like Word or Google Docs, or worry that the template you're using doesn't mesh with the jobs you're applying for. Having the formatting pre-baked means you can take more time to focus on your content - easily the most important part of your applications. To be clear: the formatting here is OPINIONATED. Although the format has been refined over a period of about 4 years based on a number of meetings with recruiters, hiring managers, and employees at both small and large companies across a number of technical and professional industries, it does still represent many of my own opinions. That said, it'll provide you with a good starting point to work off of as you slowly develop your own resume & style moving forward. If this is your first resume, I'd recommend sticking with this formatting for now. However, if you're either recreating a previous resume, or if you get far along enough into your career that you want to flavor it up a bit, you can find all of the templating in the `resume.typ` file included in this project. */ #import "@preview/guided-resume-starter-cgc:2.0.0": * #import "@preview/fontawesome:0.2.1": * #show: resume.with( author: "QIU, Jiangkun", location: "Hong Kong", contacts: ( "WA/Tel: 91408309", [#link("mailto:<EMAIL>")[Email]], [#link("https://github.com/JakkuSakura")[GitHub]], [#link("https://www.linkedin.com/in/jiangkun-qiu-181486176/")[LinkedIn]], [WeChat: JakkuSakura] ), // footer: [#align(center)[#emph[References available on request]]] ) /* ======================================== ===== HEADER & CONTACT INFORMATION ===== ======================================== This is where you should put your name, your contact information, and your general location! === Opinion: Specifying Your Location === Sometimes, people put their full mailing address on their resume. I personally believe that you should leave your location to ONLY the general metropolitan area you're in. This is for a few reasons: - Full mailing addresses are noisy, and wherever possible you should try to eliminate noise from your resume. Recruiters only really need to know your general location, so it's better to just keep it short and simple. - As a general safety rule-of-thumb, you should try to not publicly post the address of the place you sleep on the internet. ¯\_(ツ)_/¯ === Opinion: Including Your Phone Number === Personally, I would HIGHLY advise you leave your personal phone number off of your resume. Odds are, you'll be sending this resume to one of two types of places: 1. Public areas, such as LinkedIn, Indeed, a website you own, etc. 2. Private areas, such as a potential employer's application portal or a private message Given that this may be in public areas, posting your phone number on the resume itself may pose the risk of opening you up to unsolicited calls & harassment. As somebody who has had their number leaked and been harassed with it since then, that's a hard genie to put back into the bottle - I strongly advise against taking that risk. However, when you're privately sending your resume, you're likely to be putting your phone number into a separate application field anyway, or even sending your resume over a private channel directly. In that case, a private recipient will *already have your contact information, including your phone number*. This means that having your phone number here has a lot of risk and virtually no added reward. Unless you have a good, explicit reason for doing so, don't put your phone number on your resume. === Opinion: Use Hyperlinks! === In the year of our lord 20XX, it is *vastly* more likely that somebody reviewing your resume is using a digital, internet-connected device. This may vary industry-to-industry, but the chances of a person printing your resume to review it become lower and lower each year. When somebody is viewing your resume digitally, you have the massive advantage of being able to include hyperlinks to other areas of the internet on your resume! This effectively turns the document into a landing page for other valuable resources: - Your LinkedIn, email, GitHub, website, etc. - The sites of companies that you've worked for to provide additional context about where you worked - Elaborate or "follow up" projects you've done and skills you've had with real-world proof that you've posted on the internet On the other hand, there is a risk that somebody out there is still printing stacks of resumes to review. Additionally, you may have to print off your resume from time to time - something that can come of often if you're, for example, a student attending your university's job fairs. In that case, you may need to tune your hyperlinks to still be usable on printed paper. > IF YOU'RE WORRIED YOUR RESUME WILL BE PRINTED, MODIFY THE TEXT OF THE HYPERLINK TO BE THE SAME AS THE LINK ITSELF. */ = Education #edu( institution: "Hong Kong University of Science and Technology", date: "2020-2025", location: "Hong Kong", degrees: ( ("Undergraduate", "Computer Engineering"), ), ) #edu( institution: "Osaka University", date: "2023", location: "Osaka, Japan", degrees: ( ("Exchange", "Humantities Courses"), ), ) /* ===================== ===== EDUCATION ===== ===================== This is where formal education goes! While this is usually university education, it doesn't have to be. You can also include: - Certification Programs - Boot Camps - Associates/college degrees If what you put here is not "education" in the normal sense and fits more with the subjects above, you may want to consider renaming it. However, the general advice I've received from technical recruiters, technical interviewers, and fellow professionals over the years is that an Education section containing university degrees should usually stay at the top of your resume. **TIP FOR UNIVERSITY STUDENTS:** Companies will use this information to background check to confirm you have the degree you claim to have. Because this is one of the background check entries that HAS to check out, **DO NOT MODIFY THE TYPE, NAME, OR GRADUATION DATE OF YOUR DEGREES, MINORS, OR EMPHASES.** Believe me — as somebody who has a degree in "Quantitative Analysis of Markets and Organizations," I sure do wish I could abbreviate that down to "Quantitative Economics" for the sake of space and not having to explain what the hell that means. *However* — because that is the God-given name of my degree, that HAS to stay EXACTLY consistent in order to comply properly with background checks. However, as a sneaky way around that requirement, you *can* add additional information here in an *unofficial* way. For example, "Focus" is not typically a University-registered piece of information, and something you have a bit of wiggle room on. For example, if you studied Computer Science and your coursework *mainly focused* on front-end development, but you didn't get a *formal emphasis* in "Frontend Development", you could do: ```typ degrees: ( ("Bachelor's of Science", "Computer Science"), ("Focus", "Frontend Development") ) ``` Degree paths on the university level can vary from very broad to very specific - especially on a graduate level. This additional degree entree field trick is a good way to sneak additional context into your education section in a way that won't hit snags during a background check. === Opinion: Including Your GPA === GPA is a testy subject. Some of us have great GPAs, some of us have alright GPAs, and some of us had an off year (or two, if you were in college during COVID) and if you ask us about it, we'll avoid the subject entirely. Additionally, some companies require a GPA, others would prefer you have it, and some (the cool ones) don't give a hoot what your GPA is. Here is the general rule-of-thumb for when to (or to not) include your GPA: - **DEFINITELY** include your GPA **IF**: - it is above a ~3.5/4.0 (which is usually the threshold of Deans List or your university's equivalent); OR - you know for a fact that the company you're applying for requires it. - **POSSIBLY** include your GPA **IF**: - your GPA is between a 3.0 and 3.5, and you feel it would help your applications. - **PROBABLY** don't include your GPA **IF**: It's below a 3.0. If you do want to include your GPA, the `#edu` section will automatically format it for you if you add a `gpa` value to your entry. You can also use the `gpa:` field to elaborate on extra tags like "Dean's List", "Honors", "(Summa) Cum Laude", etc. === Opinion: Including a Graduation Date === If you're currently in an education program, you should put the estimated month and year you believe you'll be finishing your program. You have two ways you can do this: 1. Set the `date` field to some variant of "Estimated MONTH 20XX" 2. Just put the month and year in the future that you intend to graduate. Prior to graduating, I opted to go with option 2 and never ran into issues. In general, people and Applicant Tracking Systems (ATS) are smart enough to intuit that a graduation date in the future means that you're still a student. */ = Skills #skills(( ("Rust", ( [Rust for 4 years in High Frequency Trading and web3.], )), ("HFT", ( [Solo "full stack" High Frequency Trading systems builder about market-making and arbitraging], )), ("Algorithm", ( [Algorithm and Data Structure training and competitions in middle and high school], )), ("Others", ( [A wide technical stack, all main stream languages in fields from backend to basic frontend, from machine learning to smart contracts], )) )) /* ================== ===== SKILLS ===== ================== The Skills section is where you can give an overarching view of what you're good at and what you know! This section is broken out into categories. In general, here are some breakouts that I've used in the past: - **Expertise/Key Skills:** Subjects, fields, and "soft" skills that you're knowledgeable in. KEEP THIS ONE. - **Software:** specific pieces of software relevant to your industry that you're comfortable using - **Languages:** Usually this means "programming languages," but I've seen the polyglots among us use a Languages section for written/spoken languages as well - **Certifications:** If you feel like certifications you have don't fit into your Education section well, or you don't want to spend as much vertical space listing them, you can place them here instead === Opinion: What Should You Put Here? === So, one thing you *have* to understand is that human reviewers are *not* the only audience for your resume. When you're applying to for jobs and not personally handing off your resume to another human being, you should assume that your resume is going to be reviewed by an Applicant Tracking System (ATS) before it ever even sees human eyes. ATS are bots used to pre-review resumes. *In general,* these bots are doing a comparison analysis of your resume against the description of the job you're applying for. One of the primary things it does is a *keyword analysis,* where it is more-or-less asking the question: > How many keywords in this resume match keywords in the job description? THIS SECTION IS THE PLACE TO MATCH THOSE KEYWORDS. This section will be the part of your resume that changes *the most.* Ideally, you'll be fine-tuning this section for each application you do to best fit your resume against the description of the job you're applying for. This is where "commenting out" comes in handy. In Typst, you can add `//` (or `Ctrl+/`, if you're using the Typst editor) before any text to remove the text from your final resume WITHOUT removing it from this file. This makes it very easy to make new versions of your resume without actually permanently deleting it. In general, the workflow I advise for creating this section is an "everything in the kitchen sink" approach: 1. Put in ALL of your skills and interests, all the languages you comfortably know, all the software you know how to use, etc., into each category. 2. Order each section by how comfortable or skilled you are with what you've listed. For example, if you put "Python" and "JavaScript" into the Languages section and are more comfortable with Python, put that first in the list. 3. Comment out the entire list. 4. Take the job description of a job you'd like to apply for and put it into a keyword analysis service like JobScan (https://jobscan.io) or ChatGPT to get all the job's keywords out of the description. 5. Uncomment (remove the `//`) of things in each section that match the job description until the category is a line long OR you hit the end of your list 6. (Optional) If you noticed keywords in the job description that you would be comfortable adding, add them to the list. === Opinion: Including Programming Languages === Engineers get real weird about which programming languages you include on your resume. In general, here is the unspoken, unwritten policy around programming languages on your resume: > If a technical interviewer sees a programming language on your resume, they will assume it's fair game for a technical interview. Now - how does this mesh with the advice above to add things in the job description to your resume? Here's the rule of thumb for whether or not to include a language on your resume: You should include a programming language **IF**: 1. You are already comfortable enough with that language to do a technical interview using that language; OR 2. You are reasonably acquainted with a language AND feel that you can learn enough — fast enough — to do a technical interview in that programming language in 2 or less full-time, dedicated days of brushing up on that language Option 2 is an ethically dicey and professionally risky move to make, but not totally unrealistic. I'd advise that the line you should draw is: > If I'll need to frequently look up basic syntax in that language by the time I apply for this job, I probably shouldn't include it. === Opinion: Including Software === Software will be incredibly industry- and job-specific. It would be impossible to give a comprehensive list of things you should include across all industries - however, I can give you some advice on what *not* to include: - Do NOT include text editors. If you're in the software industry, this includes your IDE! - Do NOT include operating systems UNLESS: - It is a niche and specific operating system (e.g., Red Hat Linux); AND/OR - It is because you've done OS-level development on it, in which case you should be VERY specific (e.g., Linux Kernel Dev, Windows PowerShell, etc.); OR - It is specifically mentioned in the requirements for the job. - Do NOT include professional chat apps like Slack, Teams, Discord, etc. UNLESS: - You have done some kind of advanced development on it, in which case you should be VERY specific (e.g., Slack Bots) - For whatever reason, the job description explicitly mentions it. Keep in mind: if the job description says anything along the lines of "Familiar with [APP]", you should giggle to yourself because that's an objectively weird thing to list in your job description. - AND PLEASE - FOR THE LOVE OF GOD - DO NOT - INCLUDE - MICROSOFT WORD OR OFFICE 365 - BECAUSE IF YOU INCLUDE THOSE - EVERYONE WHO READS YOUR RESUME - WILL MAKE FUN OF YOU BEHIND YOUR BACK - OR POSSIBLY EVEN TO YOUR FACE - BECAUSE IT IS - THE MODERN EQUIVALENT - OF LISTING "TYPING" AS A SKILL If you have a buddy, contact, or even friend-of-a-friend working in the industry you're applying for, it'd be in your best interest to ask them for a once-over to make sure nothing you put here feels silly. === Opinion: Stating Proficiency in a Language === For both natural languages and programming languages, I have sometimes seen people list their proficiency next to the languages: e.g. > Languages: C# (advanced), Python (proficient), ... or > Languages: English (fluent), Spanish (fluent), Arabic (conversational)... I would highly recommend this for natural languages. I would somewhat, possibly — *maybe* — recommend it for programming languages. If you do it for one language, though, you should really do it for all languages. Only doing it for one or two languages — but none of the others — may seem to imply you don't know the other languages as well and are listing it as a form of cheap talk. If you want to emphasize particular skill with a programming language, you can also: 1. List it towards the start of the list; and 2. Inline-bold it to emphasize expertise. This strategy allows the design to convey the idea of proficiency through emphasis, and doesn't require you to waste valuable space to declare proficiency for all the languages you list. === Opinion: Hyperlink Your Skills === I personally believe that this area is a good candidate for hyperlinks. For example, I tend to hyperlink my strongest areas/software/languages in particular to examples of when I've worked with or done those things in the wild. This is a good reason you should strive to make projects of yours open source with good `README`s, or post your accomplishments somewhere (a website, blog, LinkedIn, Twitter, Instagram, etc.). === Opinion: Dedicating an Entire Section to Skills === When you're trying to keep your resume down to one page, vertical space is a valuable resource. In that regard, section headers are pretty expensive, taking up about ~3 bullet points for each one you use. While they're important for breaking up your resume into sections for comprehensibility reasons, too many can become a waste of vertical space that could otherwise be used in better ways. I included a Skills header in this template because people explicitly break this section out often enough that I wanted to make it plug-and-play for those transferring old resumes over. However, I'd highly recommend rolling your Skills section into your Education section by deleting (or commenting out) the `Skills` line below. The exception to this rule is that you should have a dedicated skills section if you're largely self-taught and feel that an Education section may not be a good fit. */ = Experience #exp( role: "System Engineer", project: "Vincella Limited", date: "Aug 2024 - Present", details: [ - Vincella Limited is a start-up trading firm in Hong Kong, with founders from Citadel and Goldman Sachs - Design overall trading architecture including data processing, research, order management, and backtesting - Develop low-latency trading infrastructure from scratch with modern C++ ] ) #exp( role: "Intern Market Access", project: "Qube Research and Technologies", date: "Feb 2023 - Jul 2024", details: [ - QRT is a global quant trading company split from Credit Suisse - Implemented and optimized high-performance links in C++ for processing incoming market data and executing outgoing orders - Developed a comprehensive framework and advanced tools for efficiently managing and converting terabytes of historical market data - Created graphical analyzers to assess and improve the performance of trading links, providing valuable insights for decision-making and optimization - Designed and developed simulators for various exchanges, enabling accurate testing and evaluation of software and hardware order management system in simulated real-time environments - Optimized the machine learning framework to achieve 3x predict speed improvement ], ) #exp( role: "Consultant", project: "High Frequency Trading of Cryptocurrencies", date: "Jul 2020 - Feb 2023", details: [ - Designed and developed trading systems in Rust from scratch, modular design, with focus on ultimate low latency. tick2order latency 10us - Implemented market-making and arbitraging algorithms that earn profits in production, supporting 5 researchers and traders. APR 50% - Built highly efficient links about a range of centralized and decentralized exchanges - Worked on a TCP stack in Rust, running on DPDK to work around limitation of linux kernal network stack - Invented various tools like json parser and http request formatter, outperforming the defacto library by a margin - Designed and developed Order Management System and Accounting System, to ensure consistency and correctness ], ) #exp( role: "Intern Server Arch", project: "Beijing ByteDance", date: "Apr 2022 - Sep 2022", details: [ - Proposed and implemented independently git-fuse, designed for frequent codegen service for huge repos, minimizing the total processing time to 1/20, disk usage to 1/100, used in Overpass. Shared a talk with 100+ audience in the company - Implemented a universal and customizable linter for ProtoBuf and Thrift, to facilitate automatic code review - Maintained and improved on DevFlow, a platform that integrates a fluent online editor, peer review for API changes, linting, compatibility check, code generation - Maintained and improved on Overpass, a widely used platform that collects RPC definition files and generate RPC client for other go projects ], ) #exp( role: "Consultant", project: "Various Companies", date: "~", details: [ - Built a MVP exchange from scratch, implemented in-memory limit-order book, database API, user management, statistics dashboard, with special attention to compliance in Thailand - Built ColdVault, bringing Hardware Secure Module to Ethereum and Solana - Built $"MC"^2$, a copy trading platform but runs on Decentralized Exchanges - Built RedAlert, providing quick notification to price hikes in crypto world - Built various smart contracts on Tezos, Ethereum and Solana ], ) #exp( role: "Intern Backend Dev", project: "Mesoor AI", date: "Dec 2020 - June 2021", details: [ - Mesoor AI is a company in Shanghai, providing AI hiring platform to customers. - Implemented a distributed throttler for very slow yet critical requests, with modified Sliding Log algorithm in Scala Akka and Redis - Build a Slow Refresh Service, channeling PostgreSQL changelog to Kafka ] ) /* =========================== ===== WORK EXPERIENCE ===== =========================== This is where you make your resume shine! By and large, the advice here applies to all other sections of your resume, as the pattern through the rest of the resume uses the same "Experience" (`#exp`) method for formatting. Each experience entry has the following attributes you can add: 1. Job Title (`role:`) 2. Employer/Project Title (`project:`) 3. Date (`date:`) - This should be a `MONTH 20XX - MONTH 20XX` entry, using "Present" or "Current" to denote the position you currently work at. - For these dates — and, in general, all dates on your resume - I'd recommend abbreviating months (e.g., `January -> Jan`, `December -> Dec`, etc.) to conserve space. 4. Location (`location:`) (OPTIONAL) - In the era of remote work, the location of a job has lost quite a bit of signal. IN MY OPINION, the location you state in your header would provide an interviewer or recruiter with enough information about your location, causing additional role locations to fall a bit into the same "noise" category we talked about above. However, some reasons you may want to include it are: - You're applying for a job that you know will be doing a more thorough background check, such as a government, military-adjacent, or high-security position - You want to put "Remote" for some of your positions to make it incredibly clear that you are a remote worker with no interest in relocating to an office. - You're using cool places you've worked to flavor your resume and start conversations in your interviews (e.g., "Oh, wow, you've been to France/worked in New York/yodeled in Singapore/etc. etc.? Tell me more about that!") 5. Role/employer/project summary (`summary:`) (OPTIONAL) - I've seen this on enough resumes, and have warmed up to it over time. This can be used to give a *brief(!!!)* description of the company you worked at, projects you focused on, or role you worked in. - This can be especially helpful at both larger companies to specify what specific vertical you worked in, or at smaller companies to give on-page context to who they are and what they do. - In some circumstances, it can substitute as a bullet point and give you more room in your bullet points to drill down into specifics without having to give overarching context. 6. Details — VERY IDEALLY BULLET POINTS — describing the entry (`details:`) === Opinion: Creating New Entries === For the details section of your experience entries, I would HIGHLY recommend keeping it to exclusively bullet points. Typically, the range of bullet points you should have for an experience entry is: - Three bullet points by default; with - (Maybe) Four bullet points for your current (or particularly cool or relevant) positions and projects; and - (Possibly) Two bullet points for old or "thinner" projects or experiences (e.g. seasonal employments, short-term projects, old experience, etc.) *That's a lot of bullet points*, which means that the bulk of your resume will be SHORT, CONCISE SNIPPETS describing aspects of your experiences. === Opinion: Creating Well-Structured Bullet Points === > IF YOU TAKE NOTHING ELSE AWAY FROM THIS TEMPLATE, IT SHOULD BE THIS. Bullet points are going to be making up the bulk of your resume, so it's important to make sure that they're concise, to-the-point, and convey exactly why you're a good fit for the job you're applying for. This structure is informed by a *lot* of reviews with technical recruiters, professionals/engineers, and hiring managers at companies of many different sizes. You should do your best to make sure that every bullet point has these three components - known as an XYZ structure: - **X:** What you did - **Y:** How you did it - **Z:** The (measurable) result While there are *a lot* of ways to include these three components in your bullet points, the general "out-of-the-box" structure is below: > [VERB] a [NOUN] using [METHOD] for [REASON], resulting in [RESULT] If that makes zero sense, don't worry — here's an example: > Optimized data pipelines written in **Spark/AWS** for financial analysis, resulting in >$1M annual compute cost reductions That one matches almost one-to-one with the structure above and has all three components: - **X:** What you did (Optimized data pipelines) - **Y:** How you did it (Used knowledge of Spark and AWS) - **Z:** The (measurable) result (Saved lots of money on compute costs) For the sake of brevity, we'll do just the one example up here. However, I'll post samples of other bullet points from other resumes that do a good job of including these three components. If you're trying to hammer out your first few bullet points in that structure and are thinking to yourself, "Wow, this is hard!" — don't worry! It takes awhile (and a lot of trial-and-error) to get the hang of, but will become a lot easier as you write more. Additionally, this is a really good reason to have somebody else review your bullet points (and your resume in general) — to this day, I still ask people to review my resume to make sure my bullet points get the point across well, and convey the three points from that structure concisely. === Opinion: Including Measurable Results === In general, if you have measurable results of your actions that you can include in bullet points, you should. It demonstrates to others the effectiveness of the actions you took in terms of metrics that people understand how to interpret. However, it is *by far* the hardest part of a bullet point to include, and you may not be able to include a measurable result for a couple different reasons: 1. You simply don't have a measurable result associated with the bullet point 2. You may be constrained by an NDA or equivalent restriction on publicly providing hard numbers, metrics, or details If you don't have a measurable result to include, don't worry — the X (what) and Y (how) components are still enough to make a good bullet point. However, if you're in a position to gather those metrics (for example, if you're still at your current company and have the ability to measure or find that data), I'd advise taking the time to go do that. This is also a matter of opinion! Sometimes — especially if you work at a company that doesn't religiously measure Key Performance Indicators (KPIs) — the exactness of the metrics you have access to will vary wildly. If you're in a scientific field, you may have *very precise* measurements down to a lot of significant figures. On the other hand, in industry, maybe your measurements are ballpark estimates, like the type you'd find in an executive summary. In general, I'd limit the number of "significant figures" of your metrics to 2 digits. 2 digits is enough to get a whole-number percent (e.g. 25%) or a good monetary estimate (e.g. $120,000 or $120k). Additionally, the exactness of a measurable result you include should be something you can justify to both yourself and others. Philosophically, I'd consider the ability to justify a statement to be the difference between "an estimate" and "bullshit." **FOR EXAMPLE:** I worked in a job where, as an employee, I proposed a new system we use now for replicating AWS environments and spinning up new infrastructure (TL;DR copy and pasting big pieces of technology automagically). Before we had that system, engineers would just do the whole thing by hand. Before I worked there, there was an occasion where the team had to reconstruct an entirely sandboxed copy of an application, by hand, for a new client. If memory serves, this took a few engineers roughly 4 months. Now, with the new system, we can do the same task in about 3 hours. *On paper*, the actual optimization would be: > 3 engineers * 40 hours * 12 weeks = 1440 hours > 1440 hours previously - 3 hours now, > 1437 saved / 1440 hours originally = > > a 99.7% time optimization. HOWEVER — I hadn't done that math until literally just now, as I was typing it. When I wrote the bullet point for that entry on my own resume, I vaguely went "3 hours now versus 3 months before? That's probably more than 90% ¯\_(ツ)_/¯" As of writing, that bullet point on my entry is: > Create **Terraform/AWS** deployment systems, reducing new AWS application spin-up times by >90% Is it precise? Absolutely not. Can I justify it? Probably, if I had to. So that's the metric that I used. (Although I probably will make it more specific now that I've done the math.) When it comes to results that you know exist beyond a shadow of a doubt, but don't have incredibly hard data on, using a `~` in front of the number is your best friend. (Of all the characters available on the standard keyboard, `~` is certainly the one that most represents the mathematical equivalent of "vibes.") For example, if you improve, refine, or automate a tedious process at work and the consensus among the people you've helped is "This is about twice as fast now!", you shouldn't hesitate to throw down a "~50% improvement" as a measurable result. If you're looking for measurable results at your current position, you have the incredible advantage of *still being at your current position.* KPIs - the things you can measure to gauge the success of your work - are both a difficult thing to collect and a valuable thing to have, as they can help you get new job or build a case for increased compensation at your current job now. If you can, take time at your current job to build structures that allow you to accurately measure results of your actions. === Opinion: Keep Your Bullets Concise! === When you're writing bullet points, you should try to keep them to a whole-integer number of lines used. Here's a less-weirdly-phrased example to illustrate what I mean: ```typ - Lead development of time travel devices, resulting in the <LINE BREAK> ability to travel back and forth through time ........................ ``` In that case, see how there's quite a bit of space remaining on the second line? We usually refer to this as a *"hanging bullet point"*. Hanging bullet points are an issue for a few reasons: 1. Vertical space on your resume is a valuable resource, especially if you're doing a RESUME resume (and not a CV) where you should limit yourself to one page. In this case, you're sacrificing an extra line for only half as much information, when it may be better spent creating a separate bullet point. 2. The reader has to now read into a second line. When somebody is quickly reviewing your resume, they may not bother reading that far into a single bullet point. 3. In a very wishy-washy "the-vibes-are-off" kind of way, it causes the whitespace of your resume to look uneven and your resume to look slightly incomplete, especially if the second line is only one or two words. In general, you should really aim to avoid these instances altogether. A few solutions you have (in the order I'd recommend them) are: 1. Trim the bullet point to fit onto a single line. - This is what I recommend most of the time, as it also has the added benefit of forcing you to be more concise in your wording to get the point across 2. Split the bullet point into two distinct bullet points. - In this case, you may be able to massage things around in a way that gives you two concise points rather than one inconcise one 3. Add more context to the bullet point (a method you used or another measurable result) to strengthen the point in the space that you have - **I don't recommend this**. While I've seen it done well (in cases where there was no logical way to split the bullet point AND the extra space was used to add really good metrics), I'd wager that 99% of the time people use two lines for a bullet point, it's because they're rambling and should've done Option 1 or Option 2 instead. === Opinion: Mention Your Skills (and make them bold!) === Often, in constructing your bullet points, the Y component (how you did it) will involve a specific technology, process, skill, or programming language. In that case, I highly advise that you inline bold (surround the text with asterisks, e.g. `*Python*`, `*Illustrator*`, etc). The reason I recommend this is because of the "talk is cheap" principal. In the Skills section of a resume, it is very, *very* easy for people to overestimate their skill in things. I can vividly recall the time I put `SQL` in my Skills section, only to absolutely eat shit on a SQL technical interview I got as a result. (I did not get the job.) Interviewers understand that this section is very easy to overpack, which is why I said above that the section is largely for the benefit of strengthening your ability to get past ATS by including tokens from the job description. However, your projects and experience - especially ones that you can hyperlink to - are far less likely to be total bullshit, and so mentions of specific technologies, languages, and skills here hold far more signal potential for reviewers. By inline-bolding specific mentions of technology, software, and languages you use, you're both encouraged to mention them more often (which strengthens your match score with ATS) and also gives interviewers a very quick second confirmation that you can back up the skills you've put in your Skills section. I have also seen people inline bold the measurable results they include in their bullet points. I'm personally pretty neutral on this practice, as it has the potential to highlight your more impressive achievements, but also potentially adds noise to your resume. *Caveat lector* - reader beware! === Opinion: "But I don't want to use bullet points!" === You really should. Especially at large companies, your resume will largely be viewed at a glance and the conciseness of well-structured bullet points reflects that reality. The exception is those of you making a CV, which means you probably (you *should*) have a PhD or many, *many* years of professional experience and massive accomplishments to boot. If that's the case, this template is still able to accommodate much of what you need. In your case, though, the expectation is likely that you describe things like publications, papers, presentations, etc. with concise abstracts (abstract-of-your-abstract) rather than bullet points. If that does apply to you (once again, if you're not sure it does then it probably doesn't), the `details:` field of the `#exp` format does allow you to do non-bulleted descriptions while still taking advantage of the built-in formatting for everything else. === Opinion: Ordering Your Experience === As you get further into your working life, old experiences may start to feel "stale", either because they were many years ago or because they don't fit as well with your current career aspirations. If you start running out of vertical space to keep your resume under one page and feel you want to trim down your Experience section, my general guidelines would be: 1. Always order your experiences chronologically. - There is a bit of wiggle room with jobs that you hold (or have held) concurrently. In those cases, I'd recommend breaking ties for which experience should go first by which one feels more relevant to the job you're currently applying for. 2. If you don't have a very long history of work (for example, you're still very new to working professionally), trim bullet points that aren't relevant to your current applications off of some entries. Prioritize trimming bullets from older experiences first! 3. If you're trimming an experience to just one bullet point, you should remove it altogether. WHEN YOU'RE TRIMMING THINGS OFF *ANYWHERE* OFF OF YOUR RESUME, YOU SHOULD PREFER TO COMMENT THEM OUT RATHER THAN DELETE THEM ENTIRELY. From the bajillion requisites of what constitutes a good bullet point, you should assume that they're a real pain in the ass to get right. Once you've made good bullet points for an entry, lean towards commenting that entry (or individual bullet points) out rather than deleting them entirely. It could be the case later that an entry you've trimmed previously would be a good fit with your current applications. In that case, rather than have to re-make the entry from scratch, you can simply uncomment the relevant information and restore it to your resume as-is. === Opinion: Listing Gap Periods === When trimming experience, one thing you want to avoid is gaps on your resume. The entries in your experience section should ideally represent one continuous block of time, with potentially some occasional one-month gaps between entries. While I (as a reviewer) tend to ignore gaps because there's a billion totally valid reasons those can happen (Maybe they were a full-time student, or taking care of a loved one, or got laid off and worked in an unrelated field to make ends meet, or took care of a child or parent, or they stumbled on a bag of money and fucked off to bike Europe for a year, etc.). However, sometimes significant resume gaps freak people out. If you're in the process of removing non-relevant experience from your resume and find yourself with a noticeable gap (>4 months), I'd recommend adding a summarized-but-not-detailed entry for the gap period. For example: ```typ #exp( role: "Caretaker", project: "Gap Period", date: "April 2020 - March 2021", summary: "Provided full-time support to vulnerable family members during COVID-19", details: [] ) ``` This entry is concise, explains the gap period, and conserves vertical space on your resume. Honestly? If anybody has a problem with a well-explained gap period, they have no business leading or hiring people. === Opinion: Hyperlinking in your Experience === As usual, I'd recommend including some hyperlinks in these sections under the assumption that a reviewer will be seeing this on a digital device and could hypothetically click on the links for additional context. In general, the hyperlinks I tend to include are: - In the headers, with links to the company's website or product that you worked on; and - Sparingly in the bullet points, with links to publicized achievements or products you helped work on and mention explicitly in a bullet point. - In some cases, links to additional resources mentioned in your bullet points - I see this used most often in fields related to "real science" (e.g. chemistry, biology, mechanical engineering) or in cases where industries are regulated (education, manufacturing, safety, environmental consulting) where it can be worth relating to specific documentation for procedures, legal compliance documentation, public-use datasets, or firm-level certification processes */ = Projects #exp( role: "Personal", project: "Sakura Trading", date: "Feb 2023-Now", summary: "Bbuild HFT trading system in Rust emphasizing correctness and personal usage", details: [ - No compromise among correctness, performance and elegancy, with help of SHLL(see below) - Automatic selective computation of technical analysis indicators used in strategies - Versatile data server for debugging, dashboard and backtesting - Trade and backtest dashboard with E-Chart and React ] ) #exp( role: "Personal", project: "High Level Staged Language", date: "Jan 2022-Now", details: [ - SHLL enhances Rust's type system for greater expressiveness at build time. - Implements advanced optimizations like monomorphization and staging. - Enables cross-language compatibility for code translation and optimization. - Offers flexibility with optimization and interpretation modes. - Bridges high-level abstractions with low-level code generation. ] ) = Awards and Certifications - China Computer Federation Certified Student Member #h(1fr) Jul 2019-Now - First Prize in High School Group of National Informatics Olympiad in Provinces #h(1fr) Nov 2017, Nov 2018 - Gold Award of RoboCom2018 Global Championship(Robot Competition) #h(1fr) Jul 2018 // - First Prize in Personal Skills of RoboCom2018 Global Championship #h(1fr) Jul 2018 // - Best Programmer Prize of RoboCom2018 Global Championship #h(1fr) Jul 2018 - Second Prize in 2017 Tsinghua University Dengfeng Cup Data Mining Competition #h(1fr) Jul 2018 // - Second Prize in China Shandong Student Maker (CSSM) Competition #h(1fr) May 2017 - National Computer Rank Examination Level 4, Network Engineer #h(1fr) Nov 2016 - First Prize(6th) in the Middle School Group of National Informatics Olympiad in Provinces #h(1fr) Oct 2016 - First Prize(1st) in national finals of 19th He Education Cup Computer Competition #h(1fr) Jul 2016 // - 3rd in the Weifang Experimental and Practical Competition #h(1fr) Jul 2015 // - Qualification Certify for National Youth Robotics Level Test, Second Class #h(1fr) Oct 2018 // - National Computer Rank Examination Level 3, Network Technology #h(1fr) May 2016 // - National Computer Rank Examination Level 2, C language // Nov 2015 /* =============================== ===== ADDITIONAL SECTIONS ===== =============================== In general, the only hard-advised sections of a resume that I've seen consistently recommended are the Education (or equivalent) and Experience sections. The other sections are largely up to you. However, here are some recommendations based on other sections I've seen people use to great effect, or use on my own resume: - Projects, especially if you're in the tech industry where personal projects are encouraged or expected - Volunteering - Charity - Leadership - Awards (which, depending on your preferences, could reasonably use a different entry format) A flavor of section that I see a lot - and would NOT recommend - is something along the lines of "Hobbies" or "Interests". This is occasionally recommended to give "flavor" to your resume or "humanize" you in some way. (I understand that putting quotes around "flavor" and "humanize" make me sound like a boring robot of a person, but bear with me, here.) > If you're tempted to make (or are transferring over from an old resume that has) a Hobbies (or Hobbies-adjacent) section, I would advise you structure your hobbies as Projects and use a Projects section instead. Many hobbies (sports, programming, gaming, knitting(?), graphic design/drawing, writing, woodworking, baking, etc) can be safely structured in the same way Projects would be, and allow you to highlight interesting things about yourself in a way that follows the same design pattern as the rest of your experiences. === Opinion: Making Additional Sections Work === If you're making a resume for the first time or are early in your career, you may feel yourself straining to fill vertical space. If that's the case - or if you're just looking to liven up your resume a bit - I'd recommend doing a "throw it all in the kitchen sink" approach. With this approach, create new entries for anything that you could possibly conceive of as being interesting, taught you skills, or could be an even half-viable answer to somebody asking you "So, what have you done with your life?" A lot of things that don't feel like they'd fit into the hand-shakey, back-pat-y world of business, industry, and academia can be spun into things that feel like they belong on a resume. Some examples of experiences people have put that have been used to great effect, and some general examples of how I've seen them stated, are: - Sports Leagues/Fitness (intramural, professional, etc) - Constructing routines - Designing training plans - Cooperation/collaboration - Gaming (competitively, recreationally, collaboratively (e.g. D&D)) - Competitively (cooperation/team-building/recruiting) - Speedrunning (attention to detail, QA, methodology) - Creating games as a learning experience - Playing/leading D&D as a design experience (homebrewed content, especially), coordinating people, etc. - Woodworking/Construction - Planning projects - Creating designs - Solving problems - Making brownies - This isn't even a bit. The guy's name is Dylan, and his brownies kicked so much ass that they got these-brownies-kicked-ass-type awards. He had it on his CV and got into MIT — probably not *solely* off the brownies, but I'd take an even-money bet that it helped. In general, whatever you throw in the kitchen sink, the key is describing it with the same structure and detail as your experience, trying to fit it into the XYZ bullet structure as well as possible. Even if your experience is really weird, the way you describe it can be the difference between "Why did they even bother mentioning that?" and "Oh, that is pretty impressive!" I would also recommend having the same approach with these entries as you'd take for your Skills section, where you pretty judicially add and remove (comment out!) things from this section for the jobs you're applying for, based on what might fight best with the general "vibe" of the applications you're doing. While your job experience is a pretty binary "Describe the last X jobs you've had over the last Y years", this section is very fluid by comparison. In this section especially, I'd recommend following the guidance for hyperlinking mentioned in the Experience section above. */
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/meta/figure-localization_01.typ
typst
Apache License 2.0
#import "/contrib/templates/std-tests/preset.typ": * #show: test-page // Test Chinese #set text(lang: "zh") #figure( rect(), caption: [一个矩形], )
https://github.com/MrToWy/Bachelorarbeit
https://raw.githubusercontent.com/MrToWy/Bachelorarbeit/master/Code/compareFields.typ
typst
```ts const fields = Object.keys(unchangedObject); fields.forEach(field => { if (Array.isArray(unchangedObject[field])) { if (field === "translations") { compareTranslations(unchangedObject, newObject, baseFieldName); } else { compareArrayField(unchangedObject, newObject, baseFieldName, field); } } else { comparePrimitiveField(unchangedObject, newObject, baseFieldName, field); } }); ```
https://github.com/typst-doc-cn/tutorial
https://raw.githubusercontent.com/typst-doc-cn/tutorial/main/typ/embedded-typst/example.typ
typst
Apache License 2.0
#import "lib.typ": * #let doc = svg-doc(``` #set page(header: [ #set text(size: 20pt) The book compiled by embedded typst ]) #set text(size: 30pt) #v(1em) = The first section <embedded-typst> #lorem(120) = The second section #lorem(120) ```) #let query-result = doc.header.at(0) The selected element is: #query-result.func#[[#[#query-result.body.text]]] #grid(columns: (1fr, 1fr), column-gutter: 0.6em, row-gutter: 1em, ..doc.pages.map(data => image.decode(data)).map(rect))
https://github.com/MatheSchool/typst-g-exam
https://raw.githubusercontent.com/MatheSchool/typst-g-exam/develop/test/draft/test-001-show-draft.typ
typst
MIT License
#import "../../src/lib.typ": * #show: g-exam.with( show-grade-table: false, show-draft: true, ) Hello, how are you doing? #pagebreak() Page 2 #pagebreak() Page 3 #pagebreak() Page 4 #pagebreak() Page 5 #pagebreak() Page 6 #pagebreak() Page 7 #pagebreak()
https://github.com/gmax9803/nd-assignment-templates
https://raw.githubusercontent.com/gmax9803/nd-assignment-templates/master/README.md
markdown
MIT License
# ND Assignment Templates ### About Although the respository might contain more templates in the future, currently it just contains my main typesetting template for Typst that I use for Theory of Computing and similar proof-based math classes. In `general/` you can find the general dynamic [typst](https://typst.app) template I've created and used for most of my assignments. [_*View on Typst here*_](https://typst.app/project/rMbq_AyCwbEcPnz6IrXDtQ) for most up-to-date version. ## Usage Notes: - When you first use it/download it, go to `utils.typ` and personalize the dictionary information at the top. It will look something like the following. Everything is dynamically updated from `utils.typ`, so if something is not updating like you might want it to, you need to change a setting. ```js #let ddata = ( hw_num: "##", // int, insert HW number (i.e. for HW1 -> 01) due_date: datetime(year: 2024, month: 4, day: 5), // Due Date author: "<NAME>", // Author fullname net_id: "netid", // Your netid (i.e. jshmoe2) outline: false, // Print table of contents? (true | false)... table of contents not working right now.. slug: "toc", // Class slug, toc = theory of computing cname: "Theory of Computing", // Full class name atype: "hw" // assignment type: hw, ps (problem set), etc ) ``` - Every iteration of `#problem()` keeps track of the problem numbering. - Likewise with `#subprob()`, but you can provide a custom lettering like this should you prefer: `#subprob("a")`. - See custom functions below. ## Some Custom Functions: - `#proof()[]` ``` #proof(b: true)[ This will make a proof box with a border. Prefixed with "proof:" and suffixed with QED. If you dont want a border, simply omit the 'b: true' -> proof()[content]. ] ``` - `#cbox()[]` ``` #cbox(b: true)[ Works exactly the same as '#proof', just doesn't have the proof items. ] ``` - `#qed` Appends a QED to the end, right aligned. ## Changelog - [3/6/24] - Reworked headings, fixed outline issue ## Screenshot <img width="690" alt="image" src="https://github.com/gmax9803/nd-assignment-templates/assets/27639180/5a85b3a9-f941-41c7-b404-88e724dfb889">
https://github.com/Sckathach/hackademint-presentations
https://raw.githubusercontent.com/Sckathach/hackademint-presentations/main/AI_in_cybersecurity/main.typ
typst
Apache License 2.0
#import "@preview/polylux:0.3.1": * #import themes.simple: * #set text(font: "Inria Sans") #show: simple-theme.with( footer: [<NAME>], ) #title-slide[ = AI in Cyber Security #v(2em) Le magicien quantique #footnote[Aka Sckathach, Caml Master, Fan2Thermo] <f1> #h(1em) 2023 ] #slide[ == A bit of Geopolitics - Japan: no law on copyright, researchers have full access to data to train their models #pause - United States: laws, regulations and recommandations #figure( image("resources/very_white_house.png") ) ] #centered-slide[ = AI & Defense ] #slide[ == AI for Defense (ML4SEC) #set text(size: 20pt) - Spams detection ($tilde$ 1960) - Network intrusion detection (2000) #pause - Code review #pause - Reverse and malware detection $arrow$ Google Sec-PaLM #figure( image("resources/workbench-2x.png", height: 45%), ) ] #centered-slide[ = AI & Attacks ] #slide[ == AI for Attack - Adversarial attacks on AI powered defenses - Phishing, spear phishing - Deepfakes - Targetted missinformation - Web fuzzing - Botnet control - Hiding malwares insides images - $dots$ ] #slide[ == Attacking AI models #align( center, grid( columns: (auto, auto, auto), [ #pause === Data poisoning #pause #figure( image("resources/data_poisonning.png", width: 70%) ) ], [ #pause === Data extraction #pause #figure( image("resources/extraction.png", width: 70%) ) ], [ #pause === Adversarial attacks #pause #figure( image("resources/hot_dog.png", width: 70%) ) ] ) ) ] #focus-slide[ == _Attacking Classifiers_ ] #slide[ == What is a classifier? #figure( image("resources/classifier1.png", height: 78%) ) ] #slide[ == $L_infinity$ norm #figure( image("resources/norme_linf.png", height: 78%) ) ] #slide[ == $L_2$ norm #figure( image("resources/norme_l2.png", height: 78%) ) ] #slide[ == $L_0$ norm #figure( image("resources/norme_l0.png", height: 78%) ) ] #slide[ == Whitebox Adversarial Attacks - Fast Gradient Sign Method (FGSM): $L_infinity$ - Basic Iterative Method (BIM): $L_infinity$ #pause - DeepFool (DF): $L_2$ #pause - Jacobian-based Saliency Maps Attacks (JSMA): $L_0$ #pause - <NAME> (CW): $L_infinity, L_2, L_0$ ] #slide[ == Blackbox Adversarial Attacks - Zeroth Order Optimisation attack (ZOO) - Transferable Attentive Attack (TAA) - Attack Inspired GAN (AI-GAN) ] #centered-slide[ == Examples ] #slide[ == FGSM noise attack: $L_infinity$ #figure( image("resources/adv_stop.png") ) ] #slide[ == JSMA patch attack: $L_0$ #figure( image("resources/banana_attack_diagram.png", height: 78%) ) ] #focus-slide[ == _Practice!_ ]
https://github.com/YDX-2147483647/herglotz
https://raw.githubusercontent.com/YDX-2147483647/herglotz/main/herglotz.typ
typst
#import "@preview/physica:0.9.3": dd, dv, Re, Im, Res as _Res, Order, eval, difference #import "@preview/xarrow:0.2.0": xarrow #import "template.typ": project, remark, example, small, pseudonyms #show: project.with(title: "<NAME>", date: "2023年10月9–10、11、26–28日,12月16日") #let Res = math.limits(_Res) #let comb = math.op("Ш") = 倒数和 <sec:intro> 众所周知,调和级数 $ sum_(n in ZZ^+) 1 / n = 1/1 + 1/2 + 1/3 + dots.c = +oo. $ 若*将 $n$ 平移* $1/2$,得到下面这个级数,它发散还是收敛呢? $ sum_(n in ZZ^+) 1 / (n+1/2) = 1/1.5 + 1/2.5 + 1/3.5 + dots.c. $ 比较每一项,可知它的部分和总超过调和级数的一半,而调和级数发散,那它也只好发散了。 $ 1/(n+0.5) > 1/2 times 1/n space ==> space sum_(n=1)^N 1/(n+0.5) > 1/2 sum_(n=1)^N 1/n. $ 同理,任取 $x in RR$,$sum_(n in ZZ^+) 1 / (n+x)$ 都发散,当然这只有 $n+x$ 取不到零时才有意义。 回顾调和级数,因有 $1/n$,$n$ 不能取零;而 $sum 1 / (n+1/2)$ 不再有此限制,那*把 $ZZ^+$ 改成 $ZZ$* 会怎么样?#small[(这是个脑筋急转弯)] $ sum_(n in ZZ) 1 / (n+1/2) = 1/0.5 - 1/0.5 + 1/1.5 - 1/1.5 + dots.c = 0. $ #remark[求和顺序][ $sum_(n in ZZ^+)$ 是指 $lim_(N -> +oo) sum_(n=1)^N$,$sum_(n in ZZ)$ 也应理解为 $lim_(N -> +oo) sum_(n=-N)^N$。上下限取 $N$ 或 $N+1$ 都行,关键是从 $0$ 往 $plus.minus oo$ 求和,而非 $lim_(L -> -oo) sum_(n=L)^(+oo)$ 等。 ] 综合以上两处改动,就是我们要研究的函数: $ f(x) := sum_(n in ZZ) 1 / (x + n), space x in RR without ZZ. $ #remark[定义域][ $x in ZZ$ 时,$x + ZZ = ZZ$,$x+n$ 会取到零,不能定义。 另外其实 $CC without ZZ$ 上也能定义,我们后面会根据需要随意切换两种定义域,尽管用 $RR without ZZ$ 推测 $CC without ZZ$ 并不严谨。 ] = 分析 == $ZZ$ 的影响 - *收敛*——$x in.not ZZ$ 时,$f(x)$ 存在 将 $ZZ$ 划分成 ${0}, ZZ^+, ZZ^-$,再折起来: $ sum_(n in ZZ) 1 / (x+n) = 1/(x+0) + sum_(n in ZZ^+) (1/(x+n) + 1/(x-n)) = 1/x + 2x sum_(n in ZZ^+) 1 / (x^2 - n^2), $ 而 $sum_(n in ZZ^+) 1/n^2$ 收敛,于是按先前同样论证可知 $f$ 收敛。 这一折叠,不仅看出收敛,也看出了发散的程度。$x -> 0$ 时,第一项 $1/x -> oo$,第二项的 $2x$ 是无穷小,$sum 1 / (x^2 - n^2)$ 有界(绝对值不超过 $sum 1/n^2$)。因此, $ f tilde 1/x. $ - *极点* 知道了 $f tilde 1/x$,大胆的人可能会断言:$f$ 已按极点展开为分式之和,显然#footnote[ 本文所有“显然”都是指“已按极点展开为分式之和”。`⚆_⚆` ] $f$ 有单极点 $ZZ$,且留数都是 $1$,除此以外无极点。 - *周期*——$f(x+1) = f(x)$ $x + 1 + ZZ = x + ZZ$,于是求和时分母变化范围不变,故和也不变。#footnote[ 如果不偷换求和顺序,会发现这依赖于 $lim_(n -> +oo) 1/(x+n) = 0$。 ] 固定 $x$,令 $n -> plus.minus oo$,则 $1/(x+n) -> 0$。然而周期性告诉我们,求完和后,级数并不会随 $x -> plus.minus oo$ 衰减。 - *奇*——$f(-x) = -f(x)$ 类似周期性,因为 $-x+ZZ = -(x+ZZ)$。 结合周期性可知 $f(1-x) = f(-x) = -f(x)$,故 $f$ 也关于 $x = 1/2$ 奇对称。 可以看到,把求和范围换成平移不变、翻转对称的 $ZZ$ 后,$f$ 更“正常”了。 #remark[零点][ @sec:intro 事实上说明了 $f(1/2) = 0$。这也是两种对称性(周期、奇)的推论。 一般 $0$ 是奇函数的零点,但这里 $f(0)$ 没有定义,极限 $f(0^plus.minus)$ 也不存在。(前面论证了 $f tilde 1/x$) ] == 导数 $ dv(f, x) = sum_(n in ZZ) dv(,x) 1/(x+n) = - sum_(n in ZZ) 1/(x+n)^2 < 0. $ —— $f$ 在每一定义区间内*单调递减*。 #remark[可导][ 这是子闭区间上一致收敛的结论。 ] = 怀疑 == 定性 现在我们能描出 $f$ 的图象了。 - 具有周期 $1$,中心对称点有 $(1/2 ZZ, 0)$。 - 渐近线 $x = ZZ$。 - 在相邻渐近线间单调递减。 #figure( image("fig/plot.svg", width: 60%), caption: [$f(x)$ 的草图] ) // Mathematica: // Plot[Cot[\[Pi] x], {x, -1.4, 2.6}, GridLines -> {Range[-1, 2], None}, // Ticks -> {Range[-1, 3, 1/2], None}, // AxesLabel -> Map[TraditionalForm, {x, f@x}]] 合理怀疑 $f$ 是*某种缩放的三角函数*。 == 定量 <sec:quantitative> 1. 根据性状,$f$ 接近 $cot$。 #remark[词源][ 正切 $tan$ 的 tangent 来自拉丁语 _tangens_ (≈ 英语的#text(lang: "en")[“touching”]),因为它是切线段长,而切线 _touches_ 单位圆。 余切 $cot$ 等的前缀 co- 来自 _complementi_ (≈ #text(lang: "en")[“complementary”]),指余角(complementary angle)。 ] 2. 根据周期 $1$,$f$ 可能是 $cot(pi x)$ 的倍数。 3. 根据 $f tilde 1/x$,$cot(pi x) = 1/(tan(pi x)) tilde 1/(pi x)$,$f$ 大约是 $pi cot(pi x)$。 4. $f$ 和 $cot$ 满足相同的*递归*性质,或者说二倍角公式。 #remark[要多想][ 如果你在 @sec:intro 动手处理过 $sum_n 1/(n+1/2)$,可能已发现类似性质。 ] $2f(2x) = f(x) + f(x+1/2)$: $ 2 f(2x) &= sum_(n in ZZ) 1 / (x+n/2) \ &= sum_(n in 2ZZ) 1 / (x+n/2) + sum_(n in 2ZZ+1) 1 / (x+n/2) \ &= sum_(n in ZZ) 1 / (x+n) + sum_(n in ZZ) 1/ (x + 1/2 + n) \ &=: f(x) + f(x+1/2). $ $2 cot(2 theta) = cot theta + cot(theta + pi/2)$: $ 2 cot(2 theta) &= (cos^2 theta - sin^2 theta) / (cos theta sin theta) \ &= cot theta - tan theta \ &= cot theta + cot(theta + pi/2). $ $f$ 大约的确是 $x |-> pi cot(pi x)$ 了。 #remark[递归性质的推广][ 取 $N in ZZ^+$,则 $ N f(N x) &= sum_(n in ZZ) 1/(x+n/N) \ &= sum_(k=0)^(N-1) sum_(n in N ZZ + k) 1/(x + k/N + ZZ) \ &= sum_(k=0)^(N-1) f(x+k/N). \ $ ] = Herglotz trick <sec:herglotz> 现在证明二者严格相等。 1. *作差* $g := f - pi cot(pi x).$ $g$ 保有上述周期、奇、递归性质。 2. *连续* - 在 $RR without ZZ$ 上,$g$ 自然连续。 - 在 $ZZ$ 上,$f$ 和 $cot$ 的 $oo$ 相互抵消,奇点可去。 具体来说,$x -> 0$ 时, - 前面判断 $f$ 收敛时已得 $f - 1\/x = Order(x)$; - 又知 $cot x - 1\/x = (x - tan x)/(x tan x) tilde o(x^2) \/ x^2 = o(1)$。 故 $g -> 0$。若补充定义 $g(0)=0$,$g$ 即连续。 3. *递归 $and$ 连续 $=>$ 全零* 考虑第一个正周期 $[0, 1]$。由连续,$g$ 存在最大值点 $xi$ 及最大值 $m$。注意 $g$ 具有周期,因此 $m$ 也是全局最大值。 由递归性质,$g(xi/2) + g(xi/2 + 1/2) = 2 g(xi) = 2m$——两点函数值的算术平均是最大值,那么两点必须都取最大值,于是 $g(xi/2) = m$。 以此类推,$xi, xi/2, xi/2^2, xi/2^3, ...$ 处的 $g$ 都是 $m$。这一点列趋于 $0$,由连续,$g(0) = m$。 然而按先前定义,$g(0) = 0$,于是只好 $m = 0$。 $g$ 恒非正,由奇,也恒非负,从而必恒零。 #remark[只能这么连用递归性质][ 应用递归性质也能得到 $xi + 1/2$ 和 $2xi$ 处 $g = m$。 按周期 $1$,只需在 $[0,1)$ 上考虑。 每应用一次递归性质,能从 $xi$ 推出以下点处 $g$ 也取 $m$: - $xi/2, (xi+1)/2$(下图绿线) - $xi plus.minus 1/2$(下图蓝线) - $2xi, 2xi-1$(下图橙线) #figure( image("fig/spider.svg", width: 40%), caption: [蛛网图底板] ) // Mathematica: // Show@{ // Plot[{Mod[x + 1/2, 1], Mod[2 x, 1], (x + {0, 1})/2}, {x, 0, 1}, // GridLines -> Automatic, AspectRatio -> 1], // Plot[x, {x, 0, 1}, PlotStyle -> Directive[Dashed, Gray]] // } 根据蛛网图的规则($(xi,xi) |-> (xi, xi') |-> (xi', xi') |-> (xi', xi'') |-> dots.c$),只有 $xi |-> xi/2$ 能走向极限点。 ] #remark[另法][ 利用 $N f(xi) = f(xi/N) + dots.c + f((xi + N-1)/N)$,得到 $f(xi/N) = m$。再令 $N -> +oo$。 ] = $CC$ 的威力 $RR$ 的论证在 $CC$ 仍成立,但 $CC$ 自有它的特点。 == 三角恒等式 @sec:quantitative 的注推广了递归性质,它用 $cot$ 表示是 $ N cot(N theta) = sum_(k=0)^(N-1) cot(theta + (pi k)/N). $ 这怎么理解呢? 众所周知, $ sum_(k=0)^(N-1) cos(theta + (2pi k)/N) &= Re sum_(k=0)^(N-1) e^(i theta) e^(i (2pi k)/N) &= Re e^(i theta) sum_(k=0)^(N-1) omega^k &= Re e^(i theta) (1 - omega^N) / (1 - omega) &= 0, $ 其中 $N$ 次单位根 $omega = e^(i (2pi)/N)$,$omega^N = 1$。 $cot$ 的恒等式可能类似? 记 $z = e^(i theta)$,则 $ 1/i cot theta = (cos theta)/(i sin theta) = (z + 1\/z)/(z - 1\/z) = 1 + 2/(z^2 - 1). $ 改记 $z = e^(2 i theta)$,于是 $1/i cot theta = 1 + 2/(z-1)$。进而 $ 1/i sum_k cot(theta + (pi k)/N) = sum_k (1 + 2/(z omega^k - 1)) = N + 2 sum_k 1/(z omega^k - 1). $ 转化为证明 $ sum_k 1/(z omega^k - 1) attach(=, t: ?) N / (z^N - 1). $ 从右到左是有理分式的部分分式展开问题。 - RHS 分母有单零点 $1, omega, ..., omega^(N-1)$,与 LHS 的极点 $1, omega^(-1), ..., omega^(-k), ..., omega^(1-N)$ 及阶数一致。 - 接着检查各个极点的留数。LHS 在 $omega^k$ 的留数显然#footnote[ 因为已按极点展开为分式之和。`(⊙_⊙)` ]是 $omega^k$,RHS 的我们用 L'Hôpital 法则算一下: $ Res_(z=omega^k) N/(z^N - 1) &= lim_(z -> omega^k) N(z-omega^k)/(z^N-1) \ &= lim_(z -> omega^k) N/(N z^(N-1)) \ &= 1/(omega^(k(N-1))) = (omega/omega^N)^k = omega^k. $ 从而得证。 全纯相当强硬地限制了复变函数,常常用一些个别条件就能唯一确定整个函数。 == $f(x + i oo)$ 1844年 Cauchy 证明了 Liouville 定理:$CC$ 上的全纯函数若有界,则只能是常数。下面将用它证明 $g(z) := f(z) - pi cot(pi z) equiv 0$。 - $CC$ 上*全纯*:$CC without ZZ$ 自不必说,$ZZ$ 处单极点相消,可去。 - *有界*:待证。 - *常数 $=>$ 全零*:任取一点,分析 $ZZ$ 处极限是零(→ @sec:herglotz Herglotz trick)或利用 $f(1/2) = 0 = cot pi/2$。 现在证明有界。 1. 由周期 $1$、奇,只要关心 $[0,1] + i RR^+$ 即可。 2. 这又只需论证 $g(x + i oo)$ 有界。 3. 注意 $cot z$ 在 $Im z -> +oo$ 时有界,于是进一步转化为论证 $f(x+i oo)$ 有界。 取 $x,y in RR$,$z = x + y i in CC without ZZ$,再令 $y -> +oo$,看 $f(z)$ 是否有界。 #remark[$cot z$ 在 $Im z -> plus.minus oo$ 时有界][ $ abs(cot z) = abs(1 + 2/(z^2 -1)) <= 1 + 2/abs(z^2-1). $ - 一般 $abs(z^2 - 1) >= abs(Im z^2) = 2 abs(x y) -> +oo$,从而 $cot z$ 有界。 - 若 $x = 0$,则 $abs(z^2 - 1) = y^2 + 1 -> +oo$,结论不变。 ] #remark[不太严谨的论证][ $ f(z) = sum_(n in ZZ) 1/(i + (x+n)/y) 1/y. $ 将 $(x+n)/y$ 看作 $u$,将 $1/y$ 看作 $difference(u)$,令 $y -> +oo$,则 Riemann 和趋于 $ integral_RR dd(u)/(i+u) = eval(ln(i+u))_(-oo)^(+oo) = -pi i, $ 故 $f(z)$ 存在极限,从而有界。 这一结果与 $pi cot(x + i oo) = -pi i$ 一致,可只是结果正确而已。 ] 初步尝试会发现因 $sum 1/n$ 并不绝对收敛,很难处理,故转而折叠求和范围: $ f(z) &= 1/z + sum_(n in ZZ^+) (2z)/(z^2-n^2) \ &= 1/z + sum_(n in ZZ^+) 2/(1 - (n/z)^2) 1/z. $ 第一项有界,第二项类似 Riemann 和。$x=0$ 时,第二项的模等于 $ sum_(n in ZZ^+) 2/(1 + (n/y)^2) 1/y xarrow(sym: -->, y->+oo) integral_(RR^+) (2 dd(u))/(1+u^2) = eval(2 arctan u)_0^(+oo) = pi. $ 于是 $f(+i oo)$ 有界。 #remark[无穷区间上的 Riemann 和][ 一般不能这么写到无穷积分;不过这里被积函数不变号、单调,而且无穷积分收敛。 ] $x != 0$ 时怎么办呢?考虑更易收敛的导数: $ abs(f'(z)) <= sum_(n in ZZ) 1 / abs(z+n)^2 = 1/y sum_(n in ZZ) 1 / (1 + (x+n)^2/y^2) 1/y = 1/y Order(pi/2) -> 0. $ 由导数有界,$f(0+i oo)$ 有界,可得 $f([0,1] + i oo)$ 有界。至此得证。 = 应用 == 类似公式 $ sum_(n in ZZ) (-1)^n / (x+n) = pi csc(pi x). $ == 用留数计算等距和 $u: CC -> CC$ 全纯,设回路 $Gamma$ 是 $[-R-1/2,R+1/2]^2$ 的边界,$R in ZZ^+$,由留数定理, $ 1/(2pi i) integral.cont_Gamma u(z) f(z) dd(z) = sum_(n=-R)^R u(n), $ 因为 $Res_(z=n) f(z) = 1$,于是 $Res_(z=n) u(z) f(z) = u(n)$。 现在令 $R -> +oo$,RHS 变为等距和 $sum_(n in ZZ) u(n)$,LHS 一般也容易估计。 #example[重算原问题][ 在上述方法中,$f$ 当作 $pi cot(pi z)$ 即可完成推理,用不着 $ f(zeta) = sum_(n in ZZ) 1/(zeta+n), space zeta in CC without ZZ, $ 故可用这一方法重算上式。 取 $u(z) = 1/(zeta+z)$,有唯一极点 $-zeta$。$R$ 充分大后,公式变为 $ 1/(2pi i) integral.cont_Gamma (pi cot(pi z))/(z+zeta) dd(z) = Res_(z=-zeta) (pi cot(pi z))/(z+zeta) + sum_(n=-R)^R 1/(zeta+n). $ 令 $R -> +oo$, $ f(zeta) &= "LHS" - Res_(z=-zeta) (pi cot(pi zeta))/(z+zeta) \ &= "LHS" + pi cot(pi zeta). $ 最后说明 $"LHS" = 0$。 1. $zeta = 0$ 时,被积函数 $(pi cot(pi z))/z$ 是偶函数,围道积分按定义是零。 2. 即使 $zeta != 0$,误差也可以忽略。因为被积函数只比 $zeta = 0$ 时多了 $ (1/(z+zeta) - 1/z) pi cot(pi z) = -zeta/(z(z+zeta)) pi cot(pi z) = Order(1/R^2), $ 而边界长 $Order(R)$,误差最多 $Order(1/R)$。 ] #example[Basel 问题][ 求 $ S = sum_(n in ZZ^+) 1/n^2. $ (Riemann $zeta(s) = sum 1/n^s$ 在 $s=2$ 处的值) 取 $u(z) = 1/z^2$。它在 $z=0$ 有极点,不过没关系,单独处理即可: $ 1/(2pi i) integral.cont_Gamma f(z)/z^2 dd(z) = Res_(z=0) f(z)/z^2 + 2 sum_(n=1)^R 1/n^2. $ 令 $R -> +oo$,同理 $"LHS" = 0$,$"RHS" = Res_(z=0) f(z)/z^2 + 2S$。 移项得 $ S &= -1/2 Res_(z=0) f(z)/z^2 \ &= -1/2 Res_(z=0) (pi cot(pi z))/z^2 \ &= -pi^2/2 Res_(z=0) (cot z)/z^2. $ 另外,从 $f = 1/z + 2z sum 1/(z^2-n^2)$ 也能看出 $-2S$ 等于 $f$ 在 $0 < abs(z) < 1$ 的 Laurent 展式中 $z$ 项的系数。 现在计算留数。 $ (cot z - 1\/z - 0)/z = (z - tan z)/(z^2 tan z) tilde (-1/3 z^3 + Order(z^5))/z^3 -> -1/3. $ 因此 $ S = sum_(n in ZZ^+) 1/n^2 = pi^2/6. $ ] == 离散时间 Fourier 变换 #remark[其实这是我接触本问题的来源。] #remark[Poisson 求和公式][ $f: RR -> CC$ 属于 Schwarz 类#footnote[增长不超过幂函数。],$F: RR -> CC$ 是其连续时间 Fourier 变换#footnote[ $F(f) = integral_RR f(t) e^(-i 2 pi f t) dd(t).$ ],则 $ sum_(n in ZZ) f(n) = sum_(k in ZZ) F(k). $ LHS 是 $f$ 按 $1$ 周期化后在 $t=0$ 处的值,RHS 是 $F$ 按 $1$ 采样后的和。 具体来说,$f$ 按 $1$ 周期化即 $ tilde(f)(t) := sum_(n in ZZ) f(t + n), $ 它的 Fourier 级数 $ tilde(F)_k &:= integral_[0,1] tilde(f)(t) e^(-i 2pi k t) dd(t) \ &= integral_[0,1] sum_(n in ZZ) f(t+n) space e^(-i 2pi k t) dd(t) \ &= sum_(n in ZZ) integral_[0,1] f(t+n) space e^(-i 2pi k t) dd(t) \ &= sum_(n in ZZ) integral_[n,n+1] f(t) space e^(-i 2pi k t) dd(t) \ &= integral_RR f(t) space e^(-i 2pi k t) dd(t) \ &= F(k). $ 又由 Fourier 级数的综合公式, $ tilde(f)(0) = sum_(k in ZZ) tilde(F)_k. $ 代入即得证。 更进一步,若用含 Dirac $delta$ 的 Fourier 变换表示 Fourier 级数,则上述论证相当于 $ f * comb <-> F comb, $ 其中 $*$ 表示卷积,$comb(u) = sum_(v in ZZ) delta(u-v)$ 是间距为 $1$ 的 Dirac 梳。 ] $omega |-> sinc (T omega)/2$ 按 $Omega$ 周期化是 $ tilde(H) = sum_(n in ZZ) sinc (T(omega - n Omega))/2 = sum_(n in ZZ) sin((T omega)/2 - n (T Omega)/2) / (T/2 (omega - n Omega)). $ 若 $T Omega in 2 pi ZZ$,则分子可用 $sin$ 的对称性化简。记 $N = (T Omega)/(2pi) in ZZ$,$tilde(omega)/(2pi) = omega/Omega$,于是 $T omega = N tilde(omega)$, $ tilde(H) = sum_(n in ZZ) sin(N/2 tilde(omega) - n N pi) / (N/2 tilde(omega) - n N pi). $ - 若 $N in 2 ZZ$,则 $ tilde(H) &= sum_(n in ZZ) (sin (N tilde(omega))/2) / (N/2 tilde(omega) - n N pi) &= (sin (N tilde(omega))/2) / (N pi) sum_(n in ZZ) 1 / (tilde(omega)/(2pi) - n) &= (sin (N tilde(omega))/2) / (N tan tilde(omega)/2) &= (sin (N tilde(omega))/2) / (N sin tilde(omega)/2) cos tilde(omega)/2. $ - 若 $N in 2 ZZ + 1$,则 $ tilde(H) &= sum_(n in ZZ) ((-1)^n sin (N tilde(omega))/2) / (N/2 tilde(omega) - n N pi) &= (sin (N tilde(omega))/2) / (N pi) sum_(n in ZZ) (-1)^n / (tilde(omega)/(2pi) - n) &= (sin (N tilde(omega))/2) / (N sin tilde(omega)/2). $ 其实从时域看, $ integral_RR bold(1)_[-T/2,T/2] e^(-i omega t) dd(t) &= sinc (T omega)/2. \ 1/N sum_(n in ZZ + 1/2) bold(1)_[-N/2, N/2] e^(-i tilde(omega) n) &= (sin (N tilde(omega))/2) / (N sin tilde(omega)/2), &space N in 2 ZZ. \ 1/N sum_(n in ZZ) (bold(1)_[-N/2, N/2) + bold(1)_(-N/2, N/2])/2 e^(-i tilde(omega) n) &= (sin (N tilde(omega))/2) / (N sin tilde(omega)/2) cos tilde(omega)/2, &space N in 2 ZZ. \ 1/N sum_(n in ZZ) bold(1)_[-N/2, N/2] e^(-i tilde(omega) n) &= (sin (N tilde(omega))/2) / (N sin tilde(omega)/2), &space N in 2ZZ + 1. \ $ 其中 $bold(1)$ 是集合的示性函数。 #remark[等比数列求和][ $alpha != beta$ 时, $ sum_(a, b in NN \ a + b = n-1) alpha^a beta^b = (alpha^n - beta^n)/(alpha - beta). $ ] #set heading(numbering: none) = 他典等 - #link("https://en.wikipedia.org/wiki/Trigonometric_functions")[Trigonometric functions - Wikipedia] - #link("https://math.stackexchange.com/questions/581162/how-does-the-herglotz-trick-work")[sequences and series - How does the Herglotz trick work? - Mathematics Stack Exchange] - #link("https://math.stackexchange.com/questions/141470/find-the-sum-of-sum-frac1k2-a2-when-0a1/143179")[sequences and series - Find the sum of $sum 1/(k^2 - a^2)$ when $0<a<1$ - Mathematics Stack Exchange] - #link("https://math.stackexchange.com/questions/110494/possibility-to-simplify-sum-limits-k-infty-infty-frac-left/110495")[calculus - Possibility to simplify $sum_(k = -oo)^oo (-1)^k/(a + k) = pi/sin(pi a)$ - Mathematics Stack Exchange] - #link("https://math.stackexchange.com/questions/1393943/riemann-sum-on-infinite-interval")[real analysis - Riemann sum on infinite interval - Mathematics Stack Exchange] - #link("https://en.wikipedia.org/wiki/Residue_theorem")[Residue theorem - Wikipedia] - #link("https://en.wikipedia.org/wiki/Poisson_summation_formula")[Poisson summation formula - Wikipedia] - #link("https://proofwiki.org/wiki/Poisson_Summation_Formula")[Poisson Summation Formula - Pr∞fWiki] = 致谢 离散时间 Fourier 变换的问题是刘备遇到的。级数的故事与杜甫讨论过,杜甫分析了导数,并用导数在奇点的等价无穷大得到了相同系数,还提出了若干替代思路。 #pseudonyms("pseudonym", subset: ("刘备", "杜甫"))
https://github.com/TimPaasche/Typst.Template.SimpleDocument
https://raw.githubusercontent.com/TimPaasche/Typst.Template.SimpleDocument/master/README.md
markdown
MIT License
# Typst.Template.SimpleDocument
https://github.com/JinBridger/chicv-cn
https://raw.githubusercontent.com/JinBridger/chicv-cn/main/README.md
markdown
# Typst 简历模板 基于 [skyzh/chicv](https://github.com/skyzh/chicv) 制作 A simple CV template for [typst.app](https://typst.app). ## 如何使用 ### 快速开始 在 [typst.app](https://typst.app) 创建一个项目, 把 https://github.com/JinBridger/chicv-cn/blob/master/template/cv.typ 里面的内容全部复制进去即可! ### 自定义你的简历 要更改文本大小,你可以在 `cv.typ` 文件中取消注释相应的行,并根据需要进行设置。(简历推荐的文本大小为10pt到12pt) 你还可以更改 `cv.typ` 文件中的页面边距,以便在单页中容纳更多内容。边距默认设置为 `(x: 0.9cm, y: 1.3cm)`。 每次打开新的部分时,别忘了包含 `#chiline()`,这行代码是一个完美的分隔。 对于基础的 typst 语法,可以参考这个模板,它非常易于理解和使用! 对于更高级的主题,请参考 typst 的[官方参考文档](https://typst.app/docs/reference/)。 ## 展示 ### 样例 ![Preview](cv.png)
https://github.com/Julian-Wassmann/chapter-utils
https://raw.githubusercontent.com/Julian-Wassmann/chapter-utils/main/0.1.0/lib.typ
typst
#import "./util/chapter-header.typ": chapter-header, page-chapter, page-number #import "./util/chapter-numbering.typ": chapter-numbering
https://github.com/Dr00gy/Typst-thesis-template-for-VSB
https://raw.githubusercontent.com/Dr00gy/Typst-thesis-template-for-VSB/main/thesis_template/show_rules.typ
typst
#let template(firstLineIndent: true, body) = { set page( margin: 2.5cm, // Default size from the official styleguide is "a4", however, the official latex template uses "us-letter" if you're a masochist paper: "a4", ) // Font text and size set text( // There are more fonts allowed, visit the links above font: "Calibri", size: 11pt, ) show heading: set text( // TODO spacing is questionable spacing: .3em, weight: "bold", ) // Styling of headers and normal text // TODO font size is questionable show heading.where(level: 1): set block(spacing: 1.5cm) show heading.where(level: 1): set text(size: 28pt) show heading.where(level: 1): it => [ #pagebreak() #it ] show heading.where(level: 2): set text(size: 20pt) show heading.where(level: 2): set block(spacing: .8cm) show heading.where(level: 3): set text(size: 14pt) set par( leading: 1.2em, // Basically 120% of the font size justify: true, first-line-indent: if firstLineIndent {.5cm} else {0pt}, // Line indenting is on by default ) show par: set block( spacing: if firstLineIndent {1.2em} else {2em}, ) set list(indent: 1.5em) set enum(indent: 1.5em) show figure.where(kind: table): set figure.caption(position: top) // this will be working in next typst release show figure.where(kind: raw): set align(left) show raw.where(block: true): set block( stroke: (y: 1pt), inset: .8em, width: 100% ) show raw.where(block: false): set text(weight: "semibold") set math.equation(numbering: "(1)") body } #let appendix(body) = { counter(heading).update(0) set heading(numbering: "A", supplement: [Appendix]) body }
https://github.com/ammar-ahmed22/typst-resume
https://raw.githubusercontent.com/ammar-ahmed22/typst-resume/main/src/cover.typ
typst
#import "./templates/coverLetter.typ": coverLetter #let data = yaml("./data.yml") #coverLetter( data, accentColor: rgb("#764BA2"), block(width: 100%)[ #text()[ *Behaviour Interactive Inc.* ] #h(1fr) #text()[January 19th, 2024] \ #text()[ 6666 Saint-Urbain \ 5e etage \ H2S 3H1 \ Montreal, QC, Canada ] \ \ Dear Hiring Manager, \ \ I'm writing to express my interest in the Behaviour Interactive Programming internship. I am excited about the chance to contribute to your game projects and backend services due to my strong background in software development and fundamentals in Engineering from the University of Waterloo.\ \ As a software developer at Nokia, I am working on important Network Services Platform components and improving user experience with using React.js for front-end development. I created interesting user interface (UI) elements for a fighter game on a web platform while working at AI Arena. This greatly enhanced user engagement and game performance. My comprehension of software development has been strengthened by these experiences, especially in front-end and full-stack development, which I think will be helpful in the game development industry. \ \ I am proficient in several programming languages, including Python, NodeJS, and C++. Working on game features and backend services that improve user engagement and application efficiency excites me in particular.\ \ I am especially interested in the chance to learn from and advance within the gaming industry under the guidance of senior members of Behaviour Interactive. The prospect of working for a company that is renowned for its creative game development methods and commitment to producing captivating gaming experiences excites me. \ \ Enclosed is my resume for your consideration. I look forward to the opportunity to discuss how my background, skills, and enthusiasm for game development make me a strong fit for this position. Thank you for considering my application. I am eager to contribute to the continued success of Behaviour Interactive. \ \ Sincerely, \ \ <NAME> ] )
https://github.com/RandomcodeDev/FalseKing-Design
https://raw.githubusercontent.com/RandomcodeDev/FalseKing-Design/main/game/timeline.typ
typst
= Timeline This is a general timeline for getting to a demo of the game that can be sent to console companies and probably released in Early Access on Steam, or at least used to make a trailer. #table( columns: 5, [*Task/feature*], [*Type*], [*Status*], [*Notes*], [*Expected completion*], [Basic rendering], [Engine programming/design], [Designed], [Still need to implement everything, [05/2024], [GUI library integration], [Engine programming], [Not started], [none], [05/2024], [Physics engine], [Engine programming/design], [Not started], [Will be based on Game Physics Cookbook], [06/2024], [Basic player controls], [Game programming], [Not started], [none], [07/2024], [Entity storage], [Engine programming/design], [Not started], [Will likely use flecs's JSON serialization and components that reference resources with systems to load them], [08/2024], [AI], [Engine programming/design], [Not started], [none], [09/2024], [Enemies], [Game programming], [Not started], [none], [10/2024], [Scene system], [Engine programming/design], [Not started], [none], [11/2024], [Scene storage], [Engine programming/design], [Not started], [none], [12/2024], [Testing/refinement], [Testing, programming], [Ongoing], [none], [01/2025] )
https://github.com/Wh4rp/OCI-Solutions
https://raw.githubusercontent.com/Wh4rp/OCI-Solutions/main/main.typ
typst
#import "lib/problem.typ": * #import "lib/project.typ": * #show: doc => project( title: "Olimpiada Chilena de Informática 2015-2023", subtitle: "Problemas de la OCI", author: "<NAME>", date: "18 de Diciembre de 2023", presentation: [ La Olimpiada Chilena de Informática (OCI) es una competencia nacional de programación para estudiantes de secundaria organizada por la Sociedad Chilena de Ciencia de la Computación. La OCI es una competencia que busca fomentar el interés por la informática y la programación entre los estudiantes de secundaria en Chile. La competencia se lleva a cabo en varias etapas. - Fase reginal: se lleva a cabo en varias ciudades de Chile y está abierta a todos los estudiantes. Los mejores de cada región se clasifican para la final nacional. - Fase final nacional: se realiza en una región de Chile y se reúne a los mejores de cada región. - Campamento IOI: los 10 mejores en la final nacional son seleccionados para participar en un campamento de entrenamiento de 2 semanas en Santiago, donde reciben entrenamiento especializado para prepararse para la IOI. Al final de este se seleccionan los 4 mejores para representar a Chile en la IOI. La IOI es una competencia internacional de programación para estudiantes de secundaria. La competencia se lleva a cabo anualmente en diferentes países de todo el mundo. Son dos días de competencia, donde los estudiantes deben resolver cuatro problemas de programación en cada día. Los estudiantes son evaluados por un jurado internacional y reciben medallas de oro, plata o bronce según su desempeño. ], doc, ) = OCI 2015 #include "chapters/2015/main.typ" = OCI 2021 #include "chapters/2021/main.typ"
https://github.com/shuosc/SHU-Bachelor-Thesis-Typst
https://raw.githubusercontent.com/shuosc/SHU-Bachelor-Thesis-Typst/main/contents/acknowledgement.typ
typst
Apache License 2.0
衷心感谢导师 xxx 教授对本人的精心指导。感谢上海大学开源社区提供的 Typst 模板。
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/layout/transform-02.typ
typst
Other
// Test setting rotation origin. #rotate(10deg, origin: top + left, image("test/assets/files/tiger.jpg", width: 50%) )
https://github.com/coco33920/.files
https://raw.githubusercontent.com/coco33920/.files/mistress/typst_templates/statuts/example.typ
typst
#import "template.typ": template #let nom = [Mon Association] #let objet = [ - Association ] #let adresse = [Adresse] #let dates = [01 janvier 1970] #let taille_ca = 0 #let mandat = 1 #show: template.with( name: nom, object: objet, address: adresse, date: dates, size_ca: taille_ca, duree_mandat: mandat ) = Présentation de l'association == Nom Il est fondé entre les adhérents aux présents status une association régie par la loi du 1er juillet 1901 et le décret du 16 août 1901 ayant pour titre #nom. == Objet Cette association a pour objet de : #objet == Siège social Le siège social est fixé à #adresse. \ Il pourra être transféré par simple décision du conseil d'administration. == Durée La durée de l'association est illimité. = Composition de l'association == Membres L'association se compose de : - Membre actifs (ou Adhérents); - Membre d'honneur; - Membre bienfaiteur; #v(0.25em) Les membres actifs, personnes physiques ou morales, acquittent une cotisation fixée annuellement par l'Assemblée Générale. Ils sont membres de l'Assemblée Générale avec voix délibérative. #v(0.25em) Les membres d'honneur sont désignés par l'Assemblée Générale pour les services qu'ils ont rendus ou rendent à l'association. Ils sont dispensés du paiement de la cotisation annuelle et ont le droit de participer à l'Assemblée Générale sans voix délibérative. #v(0.25em) Les membres bienfaiteurs qui acquittent une cotisation spéciale fixée par l'Assemblée Générale ont le droit de participer à l'Assemblée Générale avec voix délibérative. == Admission Pour faire partie de l'association, il faut être agréé par le conseil d’administration, qui statue, lors de chacune de ses réunions, sur les demandes d'admission présentées. == Radiation La qualité de membre se perd par : - La démission - Le décès - La radiation prononcée par le conseil d'administration pour non paiment de la cotisation ou pour motif grave, l'intéressé ayant été invité par lettre recommandée à fournir des explications devant le conseil d'administration et/ou par écrits. = Fonctionnement de l'association == Assemblée Générale Ordinaire L'assemblée générale ordinaire comprend tous les membres de l'association à quelques titre qu'ils soient #v(0.25em) L'assemblée générale ordinaire se réunit chaque année au moins une fois par an. Quinze jour au moins avant la date fixée, les membres de l'association sont convoqués par les soins du secretaire. L'ordre du jour est indiqué sur les convocations. #v(0.25em) Le président, assisté des membres du bureau, préside l'assemblée et expose la situation morale de l’association. Le trésorier rend compte de sa gestion et soumet le bilan à l’approbation de l’assemblée. Il est procédé, après épuisement de l’ordre du jour, au remplacement, au scrutin secret, des membres du conseil sortants. #v(0.25em) Ne devront être traitées, lors de l’assemblée générale, que les questions soumises à l’ordre du jour. == Assemblée Générale Extraordinaire Si besoin est, ou sur la demande de la moitié plus un des membres inscrits, le président peut convoquer une assemblée générale extraordinaire, suivant les formalités prévues par l’article précédent. == Conseil d'administration L'association est dirigée par un conseil de #taille_ca membres, élus pour #mandat années par l'assemblée générale. Les membres sont rééligibles. En cas de vacances, le conseil pourvoit provisoirement au remplacement de ses membres. Il est procédé à leur remplacement définitif par la plus prochaine assemblée générale. Les pouvoirs des membres ainsi élus prennent fin à l'expiration le mandat des membres remplacés. #v(0.25em) Le conseil d'administration se réunit au moins une fois tous les six mois, sur convocation du président, ou à la demande du quart de ses membres. Les décisions sont prises à la majorité des voix; en cas de partage, la voix du président est prépondérante. #v(0.25em) Tout membre du conseil qui, sans excuse, n'aura pas assisté à trois réunions consécutives sera considéré comme démissionnaire. == Bureau Le conseil d'administration élit parmi ses membres, au scrutin secret, un bureau composé de : - Un-e président-e; - Un-e ou plusieurs vice-président-e-s; - Un-e trésorier-e, et, si besoin est, un tréssorier-ère adjoint-e; - Un-e secretaire. == Règlement intérieur Un règlement intérieur peut être établi par le conseil d’administration, qui le fait alors approuver par l’assemblée générale. Ce règlement éventuel précise certains points des statuts, notamment ceux qui ont trait à l’administration interne de l’association. = Ressources de l'association == Ressources Les ressources de l'associations se composent : - Des cotisations; - Des subventions de l’État, des collectivités territoriales et des établissements publics; - Du produit des manifestations qu’elle organise; - Des intérêts et redevances des biens et valeurs qu’elle peut posséder; - Des rétributions des services rendus ou des prestations fournies par l'association; - De dons manuels; - De toutes autres ressources autorisées par la loi, notamment, le recours en cas de nécessité, à un ou plusieurs emprunts bancaires ou privés. = Dissolution de l'association == Dissolution En cas de dissolution prononcée par les deux tiers au moins des membres présents à l’assemblée générale, un ou plusieurs liquidateurs sont nommés par celle-ci et l’actif, s’il y a lieu, est dévolu conformément à l’article 9 de la loi du 1er juillet 1901 et au décret du 16 août 1901.
https://github.com/werifu/HUST-typst-template
https://raw.githubusercontent.com/werifu/HUST-typst-template/main/sample.typ
typst
MIT License
// #import "cs-template.typ": * #import "cse-template.typ": * #import "@preview/codelst:2.0.0": sourcecode #show: setup-lovelace #let algorithm = algorithm.with(supplement: "算法") #show: project.with( anonymous: false, title: "基于 ChatGPT 的狗屁通文章生成器但是把标题加长到两行", author: "作者", abstract_zh: [ 先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。然侍卫之臣不懈于内,忠志之士忘身于外者,盖追先帝之殊遇,欲报之于陛下也。诚宜开张圣听,以光先帝遗德,恢弘志士之气,不宜妄自菲薄,引喻失义,以塞忠谏之路也。 宫中府中,俱为一体;陟罚臧否,不宜异同。若有作奸犯科及为忠善者,宜付有司论其刑赏,以昭陛下平明之理,不宜偏私,使内外异法也。 ], abstract_en: [ The founding emperor passed away before his endeavor was half completed, and now the empire is divided into three parts. Yizhou is exhausted and in decline, and this is truly a critical moment of survival or destruction. However, the palace guards are tirelessly serving within, and loyal subjects are sacrificing themselves outside, all in order to repay the late emperor's kindness and show loyalty to the current emperor. It is appropriate to listen to wise advice, to honor the late emperor's virtues, to inspire the courage of loyal subjects, and not to belittle oneself or distort the truth, in order to keep the path of loyal counsel open. The palace and government are one entity, and punishments should be consistent. If there are those who commit crimes or show loyalty and virtue, they should be judged by the legal system to demonstrate your fairness as emperor, rather than showing partiality that would create different laws for those inside and outside the palace. ], keywords_zh: ("关键词1", "关键词2", "关键词3"), keywords_en: ("Keyword 1", "Keyword 2", "Keyword 3"), school: "复制粘贴写报告学院", id: "U000114514", mentor: "你的老板", class: "XXXX 专业 0000 班", date: (1926, 8, 17) ) = 绪论 == typst 介绍 typst 是最新最热的标记文本语言,定位与 LaTeX 类似,具有极强的排版能力,通过一定的语法写文档,然后生成 pdf 文件。与 LaTeX 相比有以下的优势: 1. 编译巨快:因为提供增量编译的功能所以在修改后基本能在一秒内编译出 pdf 文件,typst 提供了监听修改自动编译的功能,可以像 Markdown 一样边写边看效果。 2. 环境搭建简单:原生支持中日韩等非拉丁语言,不用再大量折腾字符兼容问题以及下载好几个 G 的环境。只需要下载命令行程序就能开始编译生成 pdf。 3. 语法友好:对于普通的排版需求,上手难度跟 Markdown 相当,同时文本源码阅读性高:不会再充斥一堆反斜杠跟花括号 个人观点:跟 Markdown 一样好用,跟 LaTeX 一样强大 #figure( image("assets/avatar.jpeg", height: 20%), caption: "我的 image 实例 0", ) == 基本语法 === 代码执行 正文可以像前面那样直接写出来,隔行相当于分段。 个人理解:typst 有两种环境,代码和内容,在代码的环境中会按代码去执行,在内容环境中会解析成普通的文本,代码环境用{}表示,内容环境用[]表示,在 content 中以 \# 开头来接上一段代码,比如\#set rule,而在花括号包裹的块中调用代码就不需要 \#。 === 标题 类似 Markdown 里用 \# 表示标题,typst 里用 = 表示标题,一级标题用一个 =,二级标题用两个 =,以此类推。 间距、字体等会自动排版。 \#pagebreak() 函数相当于分页符,在华科的要求里,第一级标题应当分页,请手动分页。 #pagebreak() = 本模板相关封装 == 图片 改用模块 #link("https://typst.app/universe/package/i-figured")[i-figure] 实现图片,表格与公式的编号。 #figure( image("assets/avatar.jpeg", height: 20%), caption: "我的 image 实例 1", ) <img1> 引用的话就在 figure 后加上标签,在原标签前加上前缀 `fig:, tbl:, eqt:`(分别对应图片,表格与公式)。 #figure( image("assets/avatar.jpeg", height: 20%), caption: "我的 image 实例 2", ) <img2> 引用 2-1: @fig:img1 == 表格 表格跟图片差不多,但是表格的输入要复杂一点,建议在 typst 官网学习,自由度特别高,定制化很强。 同样使用 figure 函数包裹表格 #figure( table( columns: (100pt, 100pt, 100pt), inset: 10pt, stroke: 0.7pt, align: horizon, [], [*Area*], [*Parameters*], image("assets/avatar.jpeg", height: 10%), [$ pi h (D^2 - d^2) / 4 $ <->], [ $h$: height \ $D$: outer radius \ $d$: inner radius ], image("assets/avatar.jpeg", height: 10%), [$ sqrt(2) / 12 a^3 $ <->], [$a$: 边长] ), caption: "芝士样表" ) <tbl1> #figure( three_line_table( ( ("Country List", "Country List", "Country List"), ("Country Name or Area Name", "ISO ALPHA Code", "ISO ALPHA"), ("Afghanistan", "AF", "AFT"), ("Aland Islands", "AX", "ALA"), ("Albania", "AL", "ALB"), ("Algeria", "DZ", "DZA"), ("American Samoa", "AS", "ASM"), ("Andorra", "AD", "AND"), ("Angola", "AP", "AGO"), )), kind: table, caption: "三线表示例" ) #figure( three_line_table( ( ("Country List", "Country List", "Country List", "Country List"), ("Country Name or Area Name", "ISO ALPHA 2 Code", "ISO ALPHA 3", "8"), ("Afghanistan", "AF", "AFT", "7"), ("Aland Islands", "AX", "ALA", "6"), ("Albania", "AL", "ALB", "5"), ("Algeria", "DZ", "DZA", "4"), ("American Samoa", "AS", "ASM", "3"), ("Andorra", "AD", "AND", "2"), ("Angola", "AP", "AGO", "1"), )), kind: table, caption: "三线表示例2" ) == 公式 公式用两个\$包裹,但是语法跟 LaTeX 并不一样,如果有大量公式需求建议看官网教程 https://typst.app/docs/reference/math/equation/。 不需要封装即可为公式编号 $ A = pi r^2 $ <eq1> 根据@eqt:eq1 ,推断出@eqt:eq2 $ x < y => x gt.eq.not y $ <eq2> 然后也有多行的如@eqt:eq3,标签名字可以自定义 $ sum_(k=0)^n k &< 1 + ... + n \ &= (n(n+1)) / 2 $ <eq3> 如果不想编号就在公式后面使用标签 `<->` $ x < y => x gt.eq.not y $ <-> == 列表 - 无序列表1: 1 - 无序列表2: 2 #indent()列表后的正文,应当有缩进。这里加入一个 \#indent() 函数来手动生成段落缩进,是因为在目前的 typst 设计里,按英文排版的习惯,连续段落里的第一段不会缩进,也包括各种列表。 1. 有序列表1 2. 有序列表2 列表后的正文,应当有缩进,但是这里没有,请自己在段首加上\#indent() 想自己定义可以自己set numbering,建议用 \#[] 包起来保证只在该作用域内生效: #[ #set enum(numbering: "1.a)") + 自定义列表1 + 自定义列表1.1 + 自定义列表2 + 自定义列表2.1 ] == 代码 === 代码块 //代码块使用的是库codelst,语法和markdown类似 #sourcecode[```typ #show "ArtosFlow": name => box[ #box(image( "logo.svg", height: 0.7em, )) #name ] This report is embedded in the ArtosFlow project. ArtosFlow is a project of the Artos Institute. ```] === 伪代码 计算机学院建议使用如下的伪代码模版进行伪代码书写。 reference link: https://typst.app/universe/package/lovelace #algorithm( caption: [The Euclidean algorithm], pseudocode( no-number, [*input:* integers $a$ and $b$], no-number, [*output:* greatest common divisor of $a$ and $b$], [*while* $a != b$ *do*], ind, [*if* $a > b$ *then*], ind, $a <- a - b$, ded, [*else*], ind, $b <- b - a$, ded, [*end*], ded, [*end*], [*return* $a$] ) ) #pagebreak() = 其他说明 == 文献引用 引用支持 LaTeX Bib 的格式,也支持更简单好看的 yml 来配置(尚未流行,推荐优先使用`.bib`)在引用时使用`#bib_cite(<tag>)`,像这样#bib_cite(<impagliazzo2001problems>,<Burckhardt:2013>)以获得右上的引用标注#bib_cite(<刘星2014恶意代码的函数调用图相似性分析>)#bib_cite(<papadimitriou1998combinatorial>)。 记得在最后加入\#references("path/to/ref.bib")函数的调用来生成参考文献。 由于华科使用自创引用格式,基本上为 GB/T 7714 去掉[J]、[C]、[M] 刊物类型。Typst 已支持 `csl` 自定义参考文献列表,基于#link("https://github.com/redleafnew/Chinese-STD-GB-T-7714-related-csl/blob/main/462huazhong-university-of-science-and-technology-school-of-cyber-science-and-engineering.csl")[#underline()[这个]]修改,如果想再自定义新的格式,请修改 `template.typ` 中 `bibliography` 函数中 style 参数。 == 致谢部分 致谢部分在最后加入\#acknowledgement()函数的调用来生成。 == 模板相关 这个模板应该还不是完全版,可能不能覆盖到华科论文的所有case要求,如果遇到特殊 case 请提交 issue 说明,或者也可以直接提 pull request 同时,由于 typst 太新了,2023年4月初刚发布0.1.0版本,可能会有大的break change发生,模板会做相应修改。 主要排版数据参考来自 https://github.com/zfengg/HUSTtex 同时有一定肉眼排版成分,所以有可能不完全符合华科排版要求,如果遇到不对的间距、字体等请提交 issue 说明。 === 数据相关 所有拉丁字母均为 Times New Roman,大小与汉字相同 正文为宋体12pt,即小四 图表标题为黑体12pt 表格单元格内容宋体10.5pt,即五号 一级标题黑体18pt加粗,即小二 二级标题14pt加粗,即四号 正文行间距1.24em(肉眼测量,1.5em与与word的1.5倍行距并不一样) a4纸,上下空2.5cm,左右空3cm #pagebreak() = 这是一章占位的 == 占位的二级标题 1 == 占位的二级标题 2 == 占位的二级标题 3 == 占位的二级标题 4 === 占位的三级标题 1 === 占位的三级标题 2 ==== 占位的四级标题 1 ==== 占位的四级标题 2 == 占位的二级标题 5 == 占位的二级标题 6 #pagebreak() #acknowledgement()[ 完成本篇论文之际,我要向许多人表达我的感激之情。 首先,我要感谢我的指导教师,他/她对本文提供的宝贵建议和指导。所有这些支持和指导都是无私的,而且让我受益匪浅。 其次,我还要感谢我的家人和朋友们,他们一直以来都是我的支持和鼓励者。他们从未停止鼓舞我,勉励我继续前行,感谢你们一直在我身边,给我幸福和力量。 此外,我还要感谢我的同学们,大家一起度过了很长时间的学习时光,互相支持和鼓励,共同进步。因为有你们的支持,我才能不断地成长、进步。 最后,我想感谢笔者各位,你们的阅读和评价对我非常重要,这也让我意识到了自己写作方面的不足,同时更加明白了自己的研究方向。谢谢大家! 再次向所有支持和鼓励我的人表达我的谢意和感激之情。 本致谢生成自 ChatGPT。 ] #pagebreak() #references("./ref.bib")
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-109A0.typ
typst
Apache License 2.0
#let data = ( ("MEROITIC CURSIVE LETTER A", "Lo", 0), ("MEROITIC CURSIVE LETTER E", "Lo", 0), ("MEROITIC CURSIVE LETTER I", "Lo", 0), ("MEROITIC CURSIVE LETTER O", "Lo", 0), ("MEROITIC CURSIVE LETTER YA", "Lo", 0), ("MEROITIC CURSIVE LETTER WA", "Lo", 0), ("MEROITIC CURSIVE LETTER BA", "Lo", 0), ("MEROITIC CURSIVE LETTER PA", "Lo", 0), ("MEROITIC CURSIVE LETTER MA", "Lo", 0), ("MEROITIC CURSIVE LETTER NA", "Lo", 0), ("MEROITIC CURSIVE LETTER NE", "Lo", 0), ("MEROITIC CURSIVE LETTER RA", "Lo", 0), ("MEROITIC CURSIVE LETTER LA", "Lo", 0), ("MEROITIC CURSIVE LETTER KHA", "Lo", 0), ("MEROITIC CURSIVE LETTER HHA", "Lo", 0), ("MEROITIC CURSIVE LETTER SA", "Lo", 0), ("MEROITIC CURSIVE LETTER ARCHAIC SA", "Lo", 0), ("MEROITIC CURSIVE LETTER SE", "Lo", 0), ("MEROITIC CURSIVE LETTER KA", "Lo", 0), ("MEROITIC CURSIVE LETTER QA", "Lo", 0), ("MEROITIC CURSIVE LETTER TA", "Lo", 0), ("MEROITIC CURSIVE LETTER TE", "Lo", 0), ("MEROITIC CURSIVE LETTER TO", "Lo", 0), ("MEROITIC CURSIVE LETTER DA", "Lo", 0), (), (), (), (), ("MEROITIC CURSIVE FRACTION ELEVEN TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION ONE HALF", "No", 0), ("MEROITIC CURSIVE LOGOGRAM RMT", "Lo", 0), ("MEROITIC CURSIVE LOGOGRAM IMN", "Lo", 0), ("MEROITIC CURSIVE NUMBER ONE", "No", 0), ("MEROITIC CURSIVE NUMBER TWO", "No", 0), ("MEROITIC CURSIVE NUMBER THREE", "No", 0), ("MEROITIC CURSIVE NUMBER FOUR", "No", 0), ("MEROITIC CURSIVE NUMBER FIVE", "No", 0), ("MEROITIC CURSIVE NUMBER SIX", "No", 0), ("MEROITIC CURSIVE NUMBER SEVEN", "No", 0), ("MEROITIC CURSIVE NUMBER EIGHT", "No", 0), ("MEROITIC CURSIVE NUMBER NINE", "No", 0), ("MEROITIC CURSIVE NUMBER TEN", "No", 0), ("MEROITIC CURSIVE NUMBER TWENTY", "No", 0), ("MEROITIC CURSIVE NUMBER THIRTY", "No", 0), ("MEROITIC CURSIVE NUMBER FORTY", "No", 0), ("MEROITIC CURSIVE NUMBER FIFTY", "No", 0), ("MEROITIC CURSIVE NUMBER SIXTY", "No", 0), ("MEROITIC CURSIVE NUMBER SEVENTY", "No", 0), (), (), ("MEROITIC CURSIVE NUMBER ONE HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER TWO HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER THREE HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER FOUR HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER FIVE HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER SIX HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER SEVEN HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER EIGHT HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER NINE HUNDRED", "No", 0), ("MEROITIC CURSIVE NUMBER ONE THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER TWO THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER THREE THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER FOUR THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER FIVE THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER SIX THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER SEVEN THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER EIGHT THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER NINE THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER TEN THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER TWENTY THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER THIRTY THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER FORTY THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER FIFTY THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER SIXTY THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER SEVENTY THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER EIGHTY THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER NINETY THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER ONE HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER TWO HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER THREE HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER FOUR HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER FIVE HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER SIX HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER SEVEN HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER EIGHT HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE NUMBER NINE HUNDRED THOUSAND", "No", 0), ("MEROITIC CURSIVE FRACTION ONE TWELFTH", "No", 0), ("MEROITIC CURSIVE FRACTION TWO TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION THREE TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION FOUR TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION FIVE TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION SIX TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION SEVEN TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION EIGHT TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION NINE TWELFTHS", "No", 0), ("MEROITIC CURSIVE FRACTION TEN TWELFTHS", "No", 0), )
https://github.com/noahjutz/CV
https://raw.githubusercontent.com/noahjutz/CV/main/sidebar/section.typ
typst
#import "/theme.typ": theme #let section(title) = table( columns: (auto, 1fr), align: horizon, inset: 0pt, stroke: none, table.cell( inset: (right: 6pt), text(font: "Roboto Slab", title) ), line(length: 100%), )
https://github.com/chamik/gympl-skripta
https://raw.githubusercontent.com/chamik/gympl-skripta/main/cj-autori/shakespeare.typ
typst
Creative Commons Attribution Share Alike 4.0 International
#import "/helper.typ": autor #autor("<NAME>", "1564", "1616 (52 let)", "dramatik", "King Edward VI School, Stratford-upon-Avon", "renesance, humanismus", "/cj-autori/media/shakespeare.jpg") O jeho osobním životě se toho moc nedochovalo. Ve svých 18 letech se oženil s 26letou Annou Hathawayovou. Obřad byl pravděpodobně připraven ve spěchu, protože šest měsíců poté se narodila dcera Susanna. Následovala dvojčata, syn Hamnet a dcera Judith. Hamnet však zemřel z neznámých příčin ve věku jedenácti let. Po narození dvojčat následuje období, ze kterého o Shakespearovi neexistují prakticky žádné ověřené informace, označované jako "ztracená léta". Shakespeare se stal členem nové divadelní společnosti Služebníci lorda komořího (Lord Chamberlain's Men), ve které působil jako herec a dramatik. Služebníci se brzy stali předním hereckým souborem Londýna. Po smrti královny Alžběty I. roku 1603 získala tato společnost od nového krále Jakuba I. privilegium a název společnosti byl změněn na Královská společnost (King's Men). V roce 1599 se společnost Lord Chamberlain's Men přemístila do divadla Globe a Shakespeare se stal vlastníkem jedné její desetiny. Je obecně uznáván jako nejdůležitější anglický dramatik a spisovatel. Vytvořil zhruba 1700 nových anglických slov, které se dodnes používají. Kromě her je známý pro své básně a sonety (spekuluje se že milostné sonety co psal, mohly být pro muže namísto ženy, ovšem kvůli dvojznačnostem se tahle spekulace stále nevyvrátila ani naopak). Mezi jeho známá díla patří: 1. *Hamlet* -- Tragický příběh dánského prince Hamleta, který se po smrti svého otce snaží pomstít vraždu, kterou spáchal jeho strýc. "Být, či nebýt". 2. *Sen noci svatojánské* -- Fantastická komedie, ve které se proplétají milostné intriky několika párů v kouzelném lese, kde zasahují skřítci a čarodějové. *Současníci*\ _<NAME>_ -- Božská komedie, \~1310\ _<NAME>_ -- Dekameron, \~1350\ _M. de Cervantes y Saavedra_ -- Důmyslný rytíř Don Quijote de la Mancha, 1605\ _<NAME>_ -- Sonety Lauře, \~1350 #pagebreak()
https://github.com/HKFoggyU/hkust-thesis-typst
https://raw.githubusercontent.com/HKFoggyU/hkust-thesis-typst/main/hkust-thesis/imports.typ
typst
LaTeX Project Public License v1.3c
#import "@preview/physica:0.8.1": * #import "@preview/outrageous:0.1.0" #import "@preview/i-figured:0.2.4" #import "@preview/t4t:0.3.2": is #import "@preview/anti-matter:0.0.2": anti-front-end #import "utils/utils.typ": * #import "utils/constants.typ" as constants
https://github.com/alperari/cyber-physical-systems
https://raw.githubusercontent.com/alperari/cyber-physical-systems/main/week13/solution.typ
typst
#import "@preview/diagraph:0.1.2": * #set text( size: 15pt, ) #set page( paper: "a4", margin: (x: 1.8cm, y: 1.5cm), ) #align(center, text(21pt)[ *Cyber Physical Systems - Discrete Models \ Exercise Sheet 13 Solution* ]) #grid( columns: (1fr, 1fr), align(center)[ <NAME> \ <EMAIL> ], align(center)[ <NAME> \ <EMAIL> ] ) #align(center)[ January 29, 2023 ] == Exercise 1: LTL and Set Notation === (a) $ "Words"(phi_1) = \ { A_0 A_1 ... in (2^"AP")^omega | forall i in NN . space (a in A_i -> exists j in NN . space j >= i and b in A_j) } $ === (b) $ "Words"(phi_2) = \ { A_0 A_1 ... in (2^"AP")^omega | exists i in NN . space (b in A_(i + 1) and (forall j in NN . space j < i -> a in A_j)) } $ === (c) $ phi_3 = diamond (a and circle b) $ === (d) It's not possible to notate this property in LTL. A close formulation is $a and (a -> circle circle a$). But it also forces if $a$ occurs in index one, then $a$ must occur in index 3 as well and so on. But in the original language $a$ only occurs in index one and not continue for odd numbers. === (e) $ phi_5 = square ( \ &(a and b -> circle circle (a and b)) and \ &(a and not b -> circle circle (a and not b)) and \ &(not a and b -> circle circle (not a and b)) and \ &(not a and not b -> circle circle (not a and not b)) \ ) $ #pagebreak() == Exercise 2: From LTL to NBA === (a) #raw-render()[```dot digraph { rankdir=LR; start [style="invis"]; s0 [shape="rect"]; start -> s0; s0 -> s0 [label="a"]; s0 -> s1 [label="true"]; s1 -> s0 [label="! b"]; } ```] === (b) #raw-render()[```dot digraph { rankdir=LR; start [style="invis"]; start2 [style="invis"]; s1 [shape="rect"]; s3 [shape="rect"]; start -> s0; s0 -> s0 [label="true"]; s0 -> s1 [label="a"]; s1 -> s1 [label="true"]; start2 -> s2; s2 -> s2 [label="true"]; s2 -> s3 [label="a <-> b"]; s3 -> s2 [label="true"]; } ```] === (c) #raw-render()[```dot digraph { rankdir=LR; start [style="invis"]; s3 [shape="rect"]; s5 [shape="rect"]; start -> s1 [label="true"]; s1 -> s2 [label="true"]; s2 -> s3 [label="a"]; s3 -> s3 [label="true"]; s2 -> s4 [label="true"]; s4 -> s4 [label="true"]; s4 -> s5 [label="true"]; s5 -> s5 [label="b"]; } ```] #pagebreak() == Exercise 3: LTL Equivalence === Part 1: $"Words"(phi) = "Words"(psi) -> forall tau . space tau tack.double phi <=> tau tack.double psi$ Let $phi$ and $psi$ be LTL properties and a Transition System $tau$. Assume $"Words"(phi) = "Words"(psi)$. If $tau tack.double phi$ then it means $"Traces"(tau) subset.eq "Words"(phi)$. Since $"Words"(phi) = "Words"(psi)$, we can substitute $"Words"(psi)$, therefore $"Traces"(tau) subset.eq "Words"(psi) eq.triple tau tack.double psi space qed$ === Part 2: $forall tau . space tau tack.double phi <=> tau tack.double psi -> "Words"(phi) = "Words"(psi)$ Let $phi$ and $psi$ be LTL properties. We can prove it via proof by contraposition. Assume $"Words"(phi) != "Words"(psi)$. If we find that this implies $not (forall tau . space tau tack.double phi <=> tau tack.double psi)$ then we prove the original claim. Then there exists a word $omega$ such that one of the two holds: 1. $omega in "Words"(phi) and omega in.not "Words"(psi)$ 2. $omega in.not "Words"(phi) and omega in "Words"(psi)$ Without loss of generality we will only consider the first case. The second case can be handled in the same way. Then there exists a Transition System $tau$ such that $"Traces"(tau) = {omega}$. It immediately follows that $"Traces"(tau) subset.eq "Words"(phi) and "Traces"(tau) subset.eq.not "Words"(psi)$. Which means $tau tack.double phi and tau tack.double.not psi$. So $not (forall tau : tau tack.double phi <=> tau tack.double psi)$ holds from the counter example we found. Since $"Words"(phi) != "Words"(psi) -> not (forall tau : tau tack.double phi <=> tau tack.double psi)$, we conclude that $forall tau : tau tack.double phi <=> tau tack.double psi -> "Words"(phi) = "Words"(psi) space qed$
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/xarrow/0.2.0/README.md
markdown
Apache License 2.0
# typst-xarrow Variable-length arrows in Typst, fitting the width of a given content. ## Usage This library mainly provides the `xarrow` functions. This function takes one positional argument, which is the content to display on top of the arrow. Additionally, the library provides the following arrow styles: - `xarrowDashed` using arrow `sym.arrow.dashed`. - `xarrowDouble` using arrow `sym.arrow.double.long`; - `xarrowHook` using arrow `sym.arrow.hook`; - `xarrowSquiggly` using arrow `sym.arrow.long.squiggly`; - `xarrowTwoHead` using arrow `sym.arrow.twohead`; - ... These names use camlCase in order to be simply called from math mode. This may change in the future, if it becomes possible to have the function names mirror the name of the symbols themselves. ### Arguments Users can provide the following arguments to any of the previously-mentioned functions: - `width` defines the width of the arrow. It defaults to `auto`, which makes the arrow adapt to the size of the body. - `margins` defines the spacing on each side of the `body` argument. Ignored when `width` is not `auto`. ### Example ``` #import "@preview/xarrow:0.2.0": xarrow, xarrowSquiggly, xarrowTwoHead $ a xarrow(sym: <--, QQ\, 1 + 1^4) b \ c xarrowSquiggly("very long boi") d \ c / ( a xarrowTwoHead("NP" limits(sum)^*) b times 4) $ ``` ## Customisation The `xarrow` function has several named arguments which serve to create new arrow designs: - `sym` is the base symbol. - `sections` defines the way the symbol is divided. Drawing an arrow consists of drawing its tail, then repeating a central part that is defined by `sections`, then drawing the head. This is the parameter that has to be tweaked if observing artefacts. `sections` are given as two ratios, delimiting respectively the beginning and the end of the central, repeated part of the symbol. - `partial_repeats` indicates whether the central part of the symbol can be partially repeated at the end in order to match the exact desired width. This has to be disabled when the repeated part has a clear period (like the squiggly arrow). ### Example ``` #let xarrowSquiggly = xarrow.with( sym: sym.arrow.long.squiggly, sections: (20%, 45%), partial_repeats: false ) ``` ## Limitations - The predefined arrows are tweaked with the Computer Modern Math font in mind. With different glyphs, more sophisticated arrows will require manual modifications (of the `sections` argument) to be rendered correctly. - The `width` argument cannot be given ratio/fractions like other shapes. This would be a nice feature to have, in order to be able to create an arrow that takes 50% of the available line width for instance. - I would like to make a proper manual for this library in the future, using something cool like [mantys](https://github.com/jneug/typst-mantys).
https://github.com/fufexan/cv
https://raw.githubusercontent.com/fufexan/cv/typst/modules/skills.typ
typst
#import "../src/template.typ": * #cvSection("Skills") #cvSkill( type: [Spoken languages], info: [English, Romanian], ) #cvSkill( type: [Prog. languages], info: [Bash, C/C++, Java, JavaScript, Matlab, Nix, PHP, Python, Rust], ) #cvSkill( type: [Databases], info: [Microsoft SQL, MySQL, Firestore], ) #cvSkill( type: [Build tools], info: [CMake, Meson, Nix], ) #cvSkill( type: [DevOps], info: [NixOS, QEMU, Terraform], ) #cvSkill( type: [Social skills], info: [Worked in multiple teams, participated in team-building activities. Working with people is a strong point.], )
https://github.com/Wh4rp/Presentacion-Typst
https://raw.githubusercontent.com/Wh4rp/Presentacion-Typst/master/ejemplos/2_modo-matematico.typ
typst
= Ecuación en línea El área de un círculo de radio $r$ es $A = pi r^2$. = Ecuación en línea aparte Llamaremos $cal(A)$ al conjunto definido por $ cal(A) = {x in RR | x > 0} $
https://github.com/Iris-830/research-project
https://raw.githubusercontent.com/Iris-830/research-project/main/Dissertation/main.typ
typst
#import "template.typ": * // Take a look at the file `template.typ` in the file panel // to customize this template and discover how it works. #show: project.with( title: "research project", authors: ((name: "<NAME>", email: "<EMAIL>"),), // Insert your abstract after the colon, wrapped in brackets. // Example: `abstract: [This is my abstract...]` abstract: [abstract], date: "August 13, 2024", ) // We generated the example code below so you can see how // your document will look. Go ahead and replace it with // your own content! #show link: underline #show outline.entry.where(level: 1): it => { v(12pt, weak: true) strong(it) } #outline(title: [Table of Contents], indent: auto, depth: 3) #show figure: set block(breakable: true) = Introduction In many parts of Africa, women face severe health challenges, with complications from pregnancy and childbirth being the leading cause of death among women of reproductive age. @noauthor_womens_2024 Among these complications, fistula is a significant health threat related to childbirth. While fistula has been nearly eliminated in developed countries, women in developing nations continue to suffer from this debilitating condition. @noauthor_towards_2022 However, fistula is a preventable condition, and its incidence can be significantly reduced through effective community education and timely medical interventions. @noauthor_obstetric_2005 Given the complexity of the fistula issue, this research aims to use quantitative analysis methods to explore the social determinants of fistula among women of reproductive age in West Africa, focusing on the distribution and impact of fistula prevalence and related factors across the region. Specifically, this research will examine the interaction between upstream factors (wealth, education, and occupation) and downstream factors to further reveal how these variables jointly influence the risk of fistula. Additionally, this study will analyze key influencing factors in individual West African countries, comparing their differences to identify critical risk factors unique to each nation. To enhance the practical application of the results, a data visualization dashboard will also be developed. This tool will help policymakers and researchers better understand the key determinants of fistula, supporting the formulation of effective intervention policies for West Africa and its individual countries. Fistula has devastating consequences for women, not only affecting their physical health but also leading to severe psychological and social repercussions. Women with fistula often experience social isolation, stigmatization, and rejection from their families and communities, which significantly diminishes their quality of life. @baba_birth_nodate In addition to physical pain and incontinence, fistula patients frequently suffer from depression and mental health issues, as studies in Kenya have shown. @weston_obgyn_nodate These combined effects stress the urgency of addressing fistula as both a medical and social issue, particularly in low-resource settings like West Africa. Although a large number of studies have explored the risk factors for fistula, there are still limited systematic analyses in West Africa. This research deeply analyzed the determinants of fistula in West African countries and revealed the impact of the interaction of upstream and downstream factors on fistula risk. It not only expanded the understanding of fistula risk factors, but also compared the differences in key factors among countries, providing theoretical support for more targeted intervention measures in the future. Additionally, by identifying the major social determinants of fistula in West Africa and developing a data visualization dashboard, this research offers policymakers more targeted intervention strategies. The dashboard provides a clearer understanding of the factors contributing to the prevalence of fistula, helping decision-makers implement more effective policies adapted to the needs of specific regions. == Research Objectives This study not only highlights the key social determinants of fistula, but also provides tools for more targeted interventions. The specific research objectives are as follows: 1. Identify regional gaps in the determinants of fistula in West Africa. Understand the special circumstances of fistula in various areas through analyzing the prevalence in West Africa and each country, as well as the prevalence under different factors. Analyze the similarities and differences in influencing factors among countries. 2. Investigate the economic and social, personal background, health care utilization, family planning, and sexual health aspects related to fistula in women of reproductive age in West Africa. Using quantitative analysis methods, determine how related factors affect the prevalence of fistula in different West African countries. And explore how economic status, education, and occupation interact with other factors to influence fistula prevalence. 3. Create a data dashboard to visualize the prevalence of fistula in West Africa, as well as the social determinants of women of childbearing age. The design of the dashboard can help users to have a better knowledge of the social determinants of fistula in women of reproductive age in West Africa, supporting the implementation of appropriate policies for different areas. == Structure of the Research This research is organized into 7 chapters. Chapter 1 introduces background of the study and the research objectives. Chapter 2 provides a review of relevant literature on fistula and research gaps. Chapter 3 describes the research methodology, including data sources and analysis techniques. Chapter 4 focuses on data visualization, showcasing the dashboard developed for this research. Chapter 5 presents the results of the analyses, including descriptive, bivariate, and multivariate findings. Chapter 6 discusses the key findings, research contributions, policy suggestions, limitations, and future research directions. Finally, Chapter 7 concludes the study. = Literature Review The devastating consequences of fistula, both physically and socially, are well-documented, as affected women often face significant stigma, social isolation, and economic challenges. Addressing these issues requires a multifaceted approach that focuses on treatment. @capes_obstetric_nodate @khisa_understanding_2017 With this in mind, the following section reviews existing literature on the various determinants of fistula prevalence and the research gaps that this research aims to address. == Definition of Key Terms === Fistula Fistula is an abnormal connection or passage that forms between two organs or vessels that do not normally connect @medlineplus_hemoglobin_2024. In the context of obstetric complications, obstetric fistula refers to an abnormal opening between the vagina and the bladder (vesicovaginal fistula) or the rectum (rectovaginal fistula), which can lead to the leakage of urine or stool. This condition is often caused by prolonged obstructed labor without timely medical intervention, resulting in tissue damage due to prolonged pressure during childbirth @cook_obstetric_2004. Common types of fistulas in women are obstetric fistulas, vesicovaginal fistulas, and rectovaginal fistulas. Obstetrical fistula is the most common, accounting for 79% to 100%, followed by rectovaginal fistula (1% to 8%) and vesicovaginal with rectovaginal fistula (1% to 23%) @tebeu_risk_2012. Due to the structure of the DHS dataset, it is not possible to distinguish between the specific types of fistula experienced by women. Therefore, in this research, fistula is broadly considered as any experience of continuous leakage of urine or stool, as indicated by the DHS survey question: Have you ever experienced a problem of urine or stool leakage from the vagina? === West Africa West Africa covers more than a quarter of the African continent and consists of 16 countries, including Benin, Burkina Faso, Cape Verde, Côte d'Ivoire, The Gambia, Ghana, Guinea, Guinea-Bissau, Liberia, Mali, Mauritania, Niger, Nigeria, Senegal, Sierra Leone, and Togo. @bossard_regional_2009 This research finally chose 6 West African countries: Côte d'Ivoire, Guinea-Bissau, Mali, Nigeria, Sierra Leone, and Togo. These 6 countries include both coastal and inland areas, with diverse languages and customs. It is economically diverse, with Nigeria having the greatest economy and Guinea-Bissau the smallest. Therefore, these 6 countries are representative and can well reflect the characteristics of West Africa. === Women of Reproductive Age According to the World Health Organization, women of reproductive age range from 15 to 49 years. @who_family_2024 Following this standard, this research explored the factors related to fistula in West African women of childbearing age. == Theoretical Framework After clarifying the concepts of fistula, West Africa, and women of childbearing age, it is necessary to explore the factors influencing fistula in West African women of reproductive age. As a health problem, in order to better understand the relevant factors at various levels, social determinants of health are chosen as the starting point, and then a specific analysis will be conducted through a comprehensive framework of health factors. Social determinants of health (SDH) are non-medical factors that have an impact on health outcomes. These determinants extend beyond individual behavior, encompassing broader economic, social, and structural elements such as wealth, education, and access to healthcare @marmot_who_2012. While personal health behaviors are essential, a more comprehensive approach that addresses structural determinants like economic status, cultural norms, healthcare systems, and social institutions is also crucial @navarro_what_2009. Fistula, as a health issue affecting women, is deeply shaped by these social and economic factors, aligning closely with the SDH model @den_hollander_obstetric_2020. Based on this framework, this study focuses on four dimensions: personal and family background, family planning and sexual health (individual-level factors), as well as economic and social status and medical services and health (structural-level factors), to analyze the determinants of fistula among women of reproductive age in West Africa." In order to have a more comprehensive understanding of the factors affecting fistula, these determinants are classified into upstream and downstream categories. Health outcomes are jointly influenced by a series of upstream and downstream factors. Upstream factors are fundamental determinants that address health inequities at their root. Economic and societal variables influence living conditions. The lower the socioeconomic class, the worse the health @braveman_social_2011 @marmot_health_2010. Economic and social status (wealth, education, and occupation) are considered upstream factors, which not only directly affect the risk of fistula but also indirectly influence it through downstream factors. For example, women with limited economic resources often have restricted access to medical services @deribe_measuring_2020. In contrast, women with higher levels of education are more likely to seek postpartum care, reducing their risk of fistula. Similarly, employed women tend to have better economic conditions and higher awareness, making them more likely to access healthcare services @alie_counting_2021. On the other hand, downstream factors directly influence the risk of fistula but are often shaped by upstream social determinants. Personal behavior, family planning, and access to medical care are key downstream factors that directly affect fistula risk. For instance, postpartum care is a crucial factor in preventing fistula, and it is influenced by upstream factors like education and wealth @deribe_measuring_2020. According to the SDH theory and the upstream and downstream framework of health, the theoretical framework of this research is as follows: #figure( image("理论框架.svg", width: 80%), caption: [Theoretical Framework of Social Determinants of Fistula], ) == Related Factors Based on the theoretical framework, the factors affecting fistula will be investigated from the upstream and downstream levels. === Upstream Factors Wealth The Wealth Index is a composite measure that reflects the cumulative living standard of a household, calculated through data on asset ownership, housing characteristics, and access to services. It categorizes households into five wealth quintiles, allowing for the analysis of economic disparities and their impact on health outcomes. @dhs_program_wealth Wealth, as an economic indicator, has a significant impact on the risk of obstetric fistula. However, research shows that higher wealth groups are not always avoid the fistula risk. For example, in a study conducted in Ethiopia, the prevalence of obstetric fistula was higher among wealthier groups (26.3%) compared to poorer groups (13.2%). @andargie_determinants_2017 In West Africa's poorer regions, the situation is different. Due to limited financial resources, many women face difficulties accessing necessary medical services, leading to persistently high rates of obstetric fistula. @deribe_measuring_2020 @nathan_obstetric_2009 Wealth influences the accessibility of healthcare services, thus impacting the risk of fistula in different regions, and this impact may vary significantly across regions. Education Education level is one of the factors. The uneducated women in Ethiopia have the highest incidence rate. @andargie_determinants_2017 This trend is consistent across West Africa, where women with lower levels of education also face higher risks. For example, an analysis of 14 African countries, including several in West Africa, found that educated women have a significantly lower risk of fistula. @alie_counting_2021 It is due to more educated women have better access to healthcare facilities and being more likely to recognize fistula and seek timely treatment, which minimizes the possibility of fistula. @rettig_female_2020 Occupation In this study, the variable "occupation", derived from the DHS dataset, is used to represent employment status. Another factor influencing fistula is employment status. In Ethiopia, unemployed women have higher chance of suffering from fistula. @andargie_determinants_2017 Furthermore, a research in Kenya discovered that unemployed women with fistulas were more likely feel depression. This demonstrates how unemployment influences the prevalence of fistula in women. @weston_obgyn_nodate Similarly, in West Africa, employment status plays a crucial role in determining fistula risk. Women who are employed in West African countries have a significantly lower risk of developing fistula, as employment provides them with better financial resources and access to healthcare services. @alie_counting_2021 This highlights the importance of employment not only in reducing the physical risk of fistula but also in improving women's overall quality of life. === Downstream Factors ==== Personal and Family Background Age Age is also a factor. According to research, adolescent pregnant women are more likely to suffer from fistula. @tebeu_risk_2012 This is because fistula is primarily caused by difficult delivery. Due to inadequate pelvic development in teenagers, the size of the fetal head and the maternal pelvis may not match, leading to Obstructed labour. @noauthor_obstetric_2005 Early pregnancy may be linked to poor education levels and a lack of sex education. In West Africa, particularly in Niger, where early marriage and early pregnancy are widespread, fistula is extremely common. @ouedraogo_obstetric_2018 Religion Religion emerged as a confounding variable in a study conducted in Sub-Saharan Africa. @maheu-giroux_risk_2016 In rural communities, religious beliefs play an important role in women's experience with fistula. @gatwiri_better_2017 Different religions have different attitudes on illnesses such as fistula, which can prevent women from seeking medical care in a timely manner. For example, in Nigeria, a country in West Africa, religious people are more likely to prefer spiritual treatments than medical care. @oluwabamide_assessment_2011 This may lead to delays in care before and after childbirth, increasing the risk of fistula. Residence Residence is a significant factor influencing fistula incidence. In Ethiopia, rural women had a higher prevalence of fistula than urban women. @andargie_determinants_2017 @gedefaw_estimating_2021 Similar trends have been observed in other regions of Africa, including West Africa. Some studies involving West African countries have found that women in urban areas have a lower risk of fistula than women in rural areas. @alie_counting_2021 However, some studies have found that urban women had a higher prevalence. This could be owing to easier access to care in cities, which may encourage more patients to relocate. @maheu-giroux_prevalence_2015 These findings indicate that the impact of residence on fistula may differ by geography. Height and Weight Height and weight are additional variables that could influence a fistula. For example, research from Ethiopia has shown that Obese women with a body mass index (BMI) above 30 are at a higher risk of developing obstetric fistulas. @andargie_determinants_2017 BMI can be computed using weight and height. Although these variables are relevant, they are not included in the final analysis of this research due to a high proportion of missing data. ==== Medical Services and Health Postpartum Care Postpartum care plays a direct role in reducing the risk of fistula by helping women detect and address gynecological issues early. However, access to postpartum care is influenced by factors such as education and wealth. For instance, a study across 14 African nations, including those in West Africa, found that women with higher levels of education are more likely to seek postpartum care, which consequently lowers their risk of developing fistula. @alie_counting_2021 Similarly, wealthy women are more likely to have access to healthcare services, further lowering their risk of fistula. @deribe_measuring_2020 Place of Delivery The place of delivery is also essential. In Ethiopia, women who give birth at home have a much higher incidence of fistula than those who give birth in health facilities or other places. @andargie_determinants_2017 Delivering in a hospital enables for early diagnosis and treatment. In Nigeria, a West African country, most obstetric fistula patients delivered at home with unskilled attendants, which significantly increases the risk of fistula. @ijaiya_vesicovaginal_2010 Distance Distance to health facilities is a key factor affecting the risk of fistula. A study using data from the 2016 Ethiopian Demographic and Health Survey indicated that women who live distant from health facilities face a higher risk of fistula due to lack of timely access to necessary medical interventions. @gedefaw_estimating_2021 A study on maternal mortality in 8 West African countries showed that maternal referral service utilization in remote areas was low, which exacerbated the risk of childbirth. @ronsmans_maternal_2003 These findings demonstrate that long distances and inconvenient transportation may cause pregnant women to have prolonged labor and increase the risk of fistula. @tebeu_risk_2012 In contrast, being closer to health facilities makes it easier to receive professional delivery and postpartum care, which effectively prevents the occurrence of fistula. Professional Delivery It is also important to consider whether the delivery was performed professionally. Lack of access to safe cesarean sections during hard labor and exposure to dangerous birthing methods can make fistulas more prevalent, since they have a greater tendency to be at risk of iatrogenic injury. @mama_pelvic_2022 Areas with a lack of trained hospital staff and suitable surgical options during labor might result in major complications, such as fistula. @ijaiya_vesicovaginal_2010 ==== Family Planning and Sexual Health Contraception Use Not using contraception is a risk factor for fistula. Contraception can reduce pregnancy-related health risks for women, particularly adolescent girls. @who_family_2024 According to a 2016 study in Ethiopia, women who did not use contraception had a 3.43 times higher risk of getting a fistula than those who did. @gedefaw_estimating_2021 Similarly, in West African countries like Nigeria, many women didn't use contraception, which increased the risk of fistula. Age of First Sexual Intercourse A study covering West African countries found that the age of first sexual intercourse is also associated with the occurrence of fistulas. Having first sexual intercourse at a younger age is easier to result in a fistula. @maheu-giroux_risk_2016 Being younger means that the pelvis may not be fully developed, increasing the chance of a fistula when one is become pregnant. Delaying the age of first sexual intercourse and using proper contraception are excellent approaches to lower the risk. Total Births The number of births should also be considered. In a study conducted in Nigeria, a West African country, primiparas proved to be more fragile and thus more prone to fistula. @ijaiya_vesicovaginal_2010 Furthermore, limiting the total number of births through family planning can effectively lower the chance of pregnancy causing fistula. @gedefaw_estimating_2021 It means that limiting the number of pregnancies, particularly in high-risk women, can reduce the chance of getting fistula. Sexual Violence The final factor is sexual violence. Sexual violence is not a common cause of fistula. However, more than one in five women in conflict zones report having fistula caused by sexual violence. @maheu-giroux_prevalence_2015 A research in sub-Saharan Africa have also shown that sexual violence significantly affects vaginal fistula. @maheu-giroux_risk_2016 Moreover, sexual violence was a major indicator of traumatic fistula in Rwanda and Malawi. @peterman_incontinence_2009 While due to the limited data available on this issue in the DHS dataset, sexual violence is not included in the final analysis of this study. == Research Gaps === Gaps Found in Current Research Obstetric fistula is still not a priority in many resource-poor countries, especially West Africa. This is reflected in the lack of data on fistula prevalence in some areas. @cowgill_obstetric_2015 In addition, the reliability of some existing data must be enhanced. @noauthor_research_2018 This has inhibited some research on local factors influencing fistula, and thus prevented targeted policy recommendations from being made. While current research has investigated various features of fistula, there is missing of data on specific fistula forms. @tweneboah_awareness_2023 There is also a lack of scientific study on fistula, including a lack of prevalence studies and a lack of research on barriers to fistula treatment. @baker_barriers_nodate @creanga_prevention_2007 This research also lacks data to identify specific categories. This issue restricts study into the factors that influence each fistula type and does not provide specific recommendations for different fistula types. In addition, while there have been studies on factors influencing fistula, such as the economy and education, there has been inadequate study on how these factors combine. Furthermore, there is a dearth of research on the impact of cultural practices and psychological aspects. @elkins_fistula_1997 This research will involve religious factors as a supplement to the study on cultural customs. === Research Gaps in the West African Context From the 19 studies chosen for risk factors for fistula, 15 were from Sub-Saharan Africa and four from the Middle East. @tebeu_risk_2012 This reflects a lack of studies focused on West Africa. Furthermore, West African countries such as Côte d'Ivoire face issues with poor data quality and potential underestimate. @noauthor_towards_2022 == Summary Although current research proves that fistula is a severe problem in Africa, and some studies have explored the fistula problem in some West African countries, there is a lack of data on the prevalence and influencing factors of fistula in West Africa as a whole. This study will analyze the prevalence and regional differences of fistula in six West African countries. At the same time, different influencing factors in West Africa and specific countries will be explored. And a data dashboard will be built to visually represent the research findings. This work contributes to the current literature on regional variations in fistula in West Africa and provides a dashboard for presenting and analyzing these data. This will allow for a more comprehensive understanding of the prevalence and determinants of fistula in West Africa. = Methodology == Data Source The data used in this study are from the Demographic and Health Survey (DHS) dataset. The DHS program has conducted more than 400 surveys in more than 90 countries to collect and analyze accurate and representative demographic and health data. @dhs_program At first, data from 9 West African countries were considered. After data preparation, the decision was made to concentrate the analysis on 6 countries. The detailed information for each country dataset is shown in @Dataset-Information: #figure( caption: "Dataset Information", table( columns: (25%, 15%, 35%, 25%), align: center, stroke: none, table.hline(), table.header([*Country*], [*Year*], [*Sample Range*], [*Sample size*]), table.hline(), [Cote d'Ivoire], [2021], [All women 15-49 years], [14877], [Guinea Bissau], [2018], [All women 15-49 years], [10874], [Mali], [2018], [All women 15-49 years], [10519], [Nigeria], [2018], [All women 15-49 years], [41821], [Sierra Leone], [2019], [All women 15-49 years], [15574], [Togo], [2013], [All women 15-49 years], [9480], table.hline(), ), ) <Dataset-Information> This study uses data from the Demographic and Health Survey (DHS), which used a complicated multi-stage sampling design. The survey includes both stratified and cluster sampling. To ensure sample representativeness, stratified sampling takes place at the national, residential, and regional levels. A two-stage cluster sampling design is developed using stratified sampling. Data collecting involves selecting households at random from each urban block or village.@dhs_program_methodology To verify that the results are nationally representative, this research used the DHS dataset's weight column. After the weight adjustment, the results can better reflect the characteristics of the disease. == Research Flow Chart The flow chart of this research is shown in Figure 2: #figure( image("framework.svg", width: 200%), caption: [Research Flow Chart], ) == Data Preprocessing Before data analysis, preprocessing was performed to ensure data integrity. The specific steps are as follows: 1. Dataset merging: The initial data consisted of 9 independent DHS datasets. First, variables were screened for each dataset. All variables relevant to the research objectives were selected. Subsequently, these variables were recoded to ensure consistency in variable classification. Finally, the 9 processed datasets were combined into one complete dataset. 2. Missing value processing: First, all missing value samples in the target variable experienced_fistula were deleted in the integrated complete data set. Secondly, the missing values of three variables (sexual violence, weight, and height) were removed by a cross-tabulation analysis. Although the factors of postpartum care and professional delivery have more missing values than others, they are maintained due to their significant impact on the study. Furthermore, the cross-analysis revealed that because the number of women who reported having a fistula in Gambia and Niger was less than 50, the proportion in each sample was less than 0.04%. This proportion is extremely low, making it difficult to conduct effective analysis. As for Burkina Faso, although the number of women who reported having fistula is relatively large, there are a large number of missing answers to related factors. After removing missing values from the relevant variables, the remaining data accounted for less than 0.02%. To verify the reliability and representativeness of the data analysis, data from Burkina Faso, Gambia, and Niger were removed. 3. Processing weights: The DHS dataset contains a weight variable, V005, which is used to adjust the sample to ensure that the analysis results are nationally representative. In the process of processing weights, V005 is first divided by 1,000,000, and then the processed weights are applied to the data in the analysis design. This process ensures that the data analysis results can be utilized across the country. 4. Variable Definition and Classification: The variable definitions and classifications maintained in this research are as follows: experienced_fistula: The survey question "Have you ever experienced a problem of urine or stool leakage from the vagina?" is the source of this variable. The responses are coded as 0 for "No" and 1 for "Yes," indicating whether the respondent has ever had a fistula. V005: This variable represents the sample weight provided in the dataset, which is used to ensure that the survey results are representative of the national population. country: This variable specifies the name of the country where the data was collected. wealth: Wealth is categorized into five levels, with 1 being the poorest and 5 being the wealthiest: 1: Poorest; 2: Poorer; 3: Middle; 4: Richer; 5: Richest. education: Education level is categorized as follows: 0: No education; 1: Primary education; 2: Secondary education; 3: Higher education. occupation: Employment status is categorized into three groups: 0: Not working; 1: Working; 2: Don't know. religion: Religion is categorized into five groups: 1: Muslim; 2: Christian; 3: Animist; 4: No religion; 5: Other religions. residence: This variable indicates the respondent's place of residence, coded as: 1: Urban; 2: Rural. age: Age is categorized into seven groups, each representing a five-year interval: 1: 15-19 years; 2: 20-24 years; 3: 25-29 years; 4: 30-34 years; 5: 35-39 years; 6: 40-44 years; 7: 45-49 years. distance: This variable represents whether the respondent perceives the distance to a health facility as a significant problem in obtaining medical help. The responses are coded as: 0: Not a big problem; 1: A big problem. delivery_place: This variable represents the place of delivery. Considering that the respondents may have given birth more than once, the answers are divided into: 1: Never delivered in a health facility; 2: Occasionally delivered in a health facility; 3: Always delivered in a health facility. postpartum_care: This variable indicates whether the respondent received postpartum care, considering all births, and is categorized as: 1: Always received postpartum care; 2: Occasionally received postpartum care; 3: Never received postpartum care. delivery_professional: This variable indicates whether the delivery was assisted by a professional, considering all births, and is categorized as: 1: Always had professional assistance; 2: Occasionally had professional assistance; 3: Never had professional assistance. contraception_use: This variable indicates the current contraceptive method used, categorized as: 1: Modern medical methods; 2: No contraceptive use; 3: Other contraceptive methods. And modern medical contraceptive methods include contraceptive pills, condoms, IUDs, sterilization, etc. age_sex: This variable indicates the age at which the respondent first had sexual intercourse. It is categorized into four groups: 0: Never had sexual intercourse; 1: First sexual intercourse between 8-19 years; 2: First sexual intercourse between 20-49 years; 3: First sexual intercourse at the time of first cohabitation. The age group of 8-19 is significant because the pelvis may be underdeveloped during these years compared to adult. number_birth: This variable represents the total number of births. It is categorized as: 0: Three or fewer children; 1: Four or more children. This classification allows for the distinction between lower and higher birth rates and their potential impact on fistula incidence. == Analytical Methods This research uses a comprehensive approach, incorporating multiple statistical methods to investigate the determinants of fistula in West Africa. First, descriptive statistics provide an overview of the key variables. Then, bivariate analysis is used to explore associations between independent variables and the prevalence of fistula. Finally, survey-weighted generalized linear models (svyglm) are applied to more precisely identify factors influencing fistula prevalence across the region. === Descriptive Statistics Descriptive statistics help to grasp the basic characteristics and distribution of data, laying the foundation for subsequent research. First, all variables need to be converted into categorical variables. Secondly, the frequency of each variable is calculated for West Africa as a whole and for each country. And a bar chart is used to visualize the distribution characteristics of West African women under different variables. After that, the prevalence of West Africa and each country under different variable classifications is calculated respectively. These results are also presented in bar charts to help understand the impact of various factors on fistula. Finally, a multiple correspondence analysis (MCA) is performed on the overall data of West Africa to explore the relationship between key variables that affect fistula in West African women. The analysis results can evaluate the contribution of different variables to the risk of fistula, thereby identifying the main influencing factors in West Africa. === Bivariate Analysis Bivariate analysis explored the association between two variables. Considering the existence of weights, chose the weighted generalized linear model analysis. In the GLM analysis, use the quasibinomial family since the target variable is a dichotomous variable. The analysis of West Africa and each country separately assists in determining whether factors are significantly connected with the development of fistula. The weighted chi-square test follows to confirm the relationship between each variable and the occurrence of fistula. The outcomes of the GLM analysis may also be supported by the chi-square test. It also helpful in identifying significant correlations that may exist in different areas. === Survey-weighted Generalised Linear Models Survey-weighted Generalized Linear Models (svyglm) are used to identify the important determinants influencing fistula in West African women of reproductive age. The analysis steps are as follows: multicollinearity check, basic model fitting, final model selection, and interaction term analysis. 1. Multicollinearity Check The variance inflation factor (VIF) is calculated before constructing the weighted regression model to determine whether there is an issue with multicollinearity among the independent variables. First, the selected variables are subjected to regression analysis using the ordinary generalized linear model (GLM). Then the VIF is computed. If the VIF is larger than 5, it indicates a multicollinearity concern. The VIF test results for West Africa and other countries show that all variables' VIF values below 5. As a result, it is assumed that there is no significant multicollinearity problem. The multicollinearity problem will have no effect on the succeeding svyglm model's variable estimate. 2. Basic Model Fitting Use the survey-weighted generalized linear model (svyglm) for analysis after checking that there is no multicollinearity issue. This is because the data set has a complex sampling design and the target variable is a binary variable (experienced_fistula). Svyglm is an extension of the generalized linear model (GLM) that considers complicated sampling designs. It can adjust the model estimation by considering sample weights, stratification by country, and clustering within the data to make the results more accurate and representative of the population. In the analysis of the entire West African region, stratification by country ('strata') is used to account for differences in sampling design across countries, ensuring the sampling design is properly considered at a regional level. The significance of each variable is determined by its p-value, which helps to see if the observed relationships are statistically meaningful. Additionally, 95% confidence intervals are calculated for each coefficient to show a range that likely includes the true effect size, giving more insight into the accuracy and reliability of the estimates. The basic model formula is as follows: $ "logit(P(Y=1))" = beta_0+beta_1 X_1+beta_2 X_2+ dots + beta_k X_k $ Y is the target variable experienced_fistula, which indicates whether a fistula has been experienced. X1, X2,..., and Xk are independent variables. The logit function turns the dependent variable into log odds, making it suitable for binary data. In order to ensure the validity of the model, it is necessary to test the five key assumptions of the model. The model assumptions are as follows: 1. Assume that there is no significant multicollinearity between the independent variables: each variable in the model is independent of the others, and there is no high correlation to assure the model's estimation reliability. 2. Assume that the samples are independent of one another: Each sample in the data is independent of the others. This means that the results of one sample will have no effect on the results of the others. 3. Assume that the model has no overdispersion: the model residuals follow the theoretical binomial distribution. 4. Assume the model uses a suitable link function: the chosen link function can represent the relationship between the independent variable and the binary dependent variable. 5. Assume that the model has a reasonable fit: the model fits the data well and can explain the variability of the data. This research uses the following strategies to verify the hypothesis: 1. Multicollinearity: The generalized linear model (GLM) is used to conduct regression analysis on the independent variables and calculate the variance inflation factor (VIF). The results demonstrate that the values for the VIF are less than 5, implying that there is no significant multicollinearity. 2. Sample Independence: To create the svyglm model, set id = ~1. In this way, each observation can be considered independent. 3. Overdispersion: When creating the svyglm model, the quasibinomial family is used to adjust the potential overdispersion problem. 4. Link Function: Logit is the standard function for dealing with binary dependent variables. The quasibinomial family chosen for the model uses the logit function by default, thus it fits the hypothesis. 5. Model Fit: The Akaike Information Criterion (AIC) is used to evaluate and compare the fit between the original and final models. The lower the AIC value, the better the model fits. The final model's fit, which confirms the rationality of the validated significant variables, is indicated by a reduced AIC value. The results are shown in @AIC-Comparison. #figure( caption: "Model Performance Comparison", table( columns: (auto, auto, auto), align: center, stroke: none, table.hline(), table.header([*Region*], [*AIC(original)*], [*AIC(current)*]), table.hline(), [West Afirca], [5022.23776], [5009.574994], [Cote d'Ivoire], [777.1836], [738.044482], [GuineaBissau], [2000.545597], [1975.36238], [Mali], [381.6466946], [363.6374215], [Nigeria], [381.83354], [373.2536296], [Sierra Leone], [930.523684], [927.050836], [Togo], [192.5654303], [182.5412551], table.hline(), ), ) <AIC-Comparison> 3. Model Determination and Evaluation The final factors influencing fistula are determined by the variables that are significant in the 'svyglm' regression analysis. These significant variables are used to fit the final models for West Africa and each country, and the AIC is calculated to assess the model fit. The AIC of the final model is then compared to that of the base model. If the AIC of the final model is lower, it indicates a better fit than the base model, confirming the robustness of the final model. 4. Exploration of Upstream and Downstream Factor Interaction Terms Given the large number of variables, this research uses a stepwise addition approach to examine the interaction between upstream characteristics (wealth, education, occupation) and downstream factors. The process involves adding only one interaction term at a time to the final model. These interaction terms consist of upstream and downstream factors. For example, an interaction term like wealth*age_sex is added to the final model, and then the svyglm model is run to evaluate the significance of the interaction. In subsequent analyses, different downstream factors in the final model are tested by replacing age_sex with another variable, and the model is rerun to assess the significance of the new interaction term. If the interaction term is significant (p-value < 0.05) and results in a lower AIC value compared to the final model without the interaction term, this indicates a meaningful interaction between the upstream and downstream factors. = Data Visualization (Dashboard) = Results Analysis == Descriptive Analysis === Overview of Fistula Prevalence #figure( caption: "Overview of Fistula Prevalence", table( columns: (auto, auto), align: left, stroke: none, table.hline(), table.header([**Area**], [**Prevalence**]), table.hline(), [West Africa],[1.25%], [Cote d'lvoire],[1.18%], [Guinea-Bissau],[4.60%], [Mali],[0.46%], [Nigeria],[0.20%], [Sierra Leone],[1.44%], [Togo],[1.02%], table.hline(), ), ) <overview-prevalence> The overall fistula prevalence in West Africa is 1.25%, indicating that fistula remains an important public health issue, with significant differences across countries. Specifically, Guinea-Bissau has the highest prevalence, reaching 4.60%. In contrast, Nigeria has the lowest prevalence, at only 0.20%. Mali follows with a prevalence of 0.46%. Togo (1.02%), Cote d'Ivoire (1.18%), and Sierra Leone (1.44%) have moderate prevalence rates but still warrant attention. Overall, these differences suggest that countries face varying challenges in addressing fistula prevalence. In Côte d'Ivoire, the 2016 data indicated a fistula prevalence rate of 0.07%, but it was considered underestimated @noauthor_towards_2022. My research, based on 2021 data, shows a prevalence rate of 1.18%, suggesting that the situation may be more severe than previously estimated. For Togo, it reported a prevalence rate of 1%, while my research, using the same year data source, shows a rate of 1.02%, which is consistent. === Frequency and Prevalence Distributions #figure( caption: "West Africa: Frequency Distribution and Prevalence", table( columns: (auto, auto, auto), align: left, stroke: none, table.hline(), table.header([**Variable**], [**Category**], [**Frequency (%) and Prevalence**]), table.hline(), [**Wealth**], [Poorest (1)], [10448.50 (26.47%) - 0.99%], [], [Poor (2)], [8773.27 (22.25%) - 1.19%], [], [Middle (3)], [7952.63 (20.16%) - 1.05%], [], [Richer (4)], [7341.33 (18.42%) - 1.69%], [], [Richest (5)], [6433.43 (16.23%) - 1.44%], table.hline(), [**Education**], [No Education (0)], [31192.33 (65.94%) - 1.47%], [], [Primary (1)], [10001.12 (21.16%) - 1.08%], [], [Secondary (2)], [5675.87 (12.00%) - 0.93%], [], [Higher (3)], [982.42 (2.08%) - 0.77%], table.hline(), [**Occupation**], [Not Working (0)], [11645.71 (24.60%) - 1.20%], [], [Working], [25284.87 (53.41%) - 1.35%], [], [Don't Know], [10357.72 (22.00%) - 1.05%], table.hline(), [**Age**], [15-19 Years], [3094.80 (7.86%) - 1.43%], [], [20-24 Years], [8301.82 (21.08%) - 1.23%], [], [25-29 Years], [10049.34 (25.51%) - 1.20%], [], [30-34 Years], [7941.18 (20.16%) - 1.17%], [], [35-39 Years], [6140.57 (15.59%) - 1.29%], [], [40-44 Years], [2814.62 (7.14%) - 1.26%], [], [45-49 Years], [1044.97 (2.65%) - 1.67%], table.hline(), [**Religion**], [Muslim], [28051.66 (71.22%) - 1.43%], [], [Christian], [10025.26 (25.45%) - 0.86%], [], [Animist], [697.30 (1.77%) - 0.31%], [], [No Religion], [574.72 (1.46%) - 0.57%], [], [Other Religions], [38.35 (0.10%) - 0.00%], table.hline(), [**Residence**], [Urban], [13723.77 (34.84%) - 1.42%], [], [Rural], [25663.53 (65.16%) - 1.20%], table.hline(), [**Delivery Place**], [Home (1)], [24592.33 (58.95%) - 1.32%], [], [Health Facility (2)], [17439.27 (41.05%) - 1.02%], table.hline(), [**Distance**], [Big Problem (1)], [20333.77 (51.87%) - 1.31%], [], [Not a Problem (2)], [18889.23 (48.13%) - 1.12%], table.hline(), [**Delivery Professional**], [Always Assisted (1)], [21188.77 (52.91%) - 1.18%], [], [Occasionally Assisted (2)], [6454.22 (16.13%) - 1.15%], [], [Never Assisted (3)], [12509.97 (31.26%) - 1.34%], table.hline(), [**Postpartum Care**], [Received Care (1)], [24650.45 (65.35%) - 1.21%], [], [No Care (2)], [11736.85 (30.65%) - 1.40%], table.hline(), [**Age at First Sexual Intercourse**], [8-19 Years], [34633.88 (87.93%) - 1.30%], [], [20-49 Years], [4139.14 (10.51%) - 0.76%], [], [At First Cohabitation], [614.28 (1.56%) - 1.57%], table.hline(), [**Number of Births**], [Three or Fewer Children], [21243.76 (53.94%) - 1.38%], [], [Four or More Children], [18143.54 (46.06%) - 1.10%], table.hline(), [**Contraception Use**], [No Use (0)], [38702.16 (84.00%) - 1.25%], [], [Traditional Methods (1)], [3033.91 (6.59%) - 1.07%], [], [Modern Methods (2)], [4351.23 (9.41%) - 1.38%], table.hline(), ), ) <distribution> Wealth: In West Africa, the distribution of women across wealth categories is fairly even, though the poorest groups have a slightly larger share. The highest fistula prevalence is found among the wealthiest women (1.69%), while the poorest have the lowest prevalence (0.99%), suggesting a higher risk among wealthier women. When examining individual countries within West Africa, distinct trends emerge: fistula prevalence is higher among wealthier women in Cote d'Ivoire, Guinea, and Togo. In contrast, in Mali and Sierra Leone, poorer women are more affected. Nigeria shows the highest prevalence among women in the middle wealth category, though overall prevalence remains low. (Appendix for detailed country data) Education: In West Africa, over half of the women are uneducated (65.94%), with the highest fistula prevalence among this group (1.47%), and showing a generally negative trend between education and fistula risk. This pattern is consistent in Nigeria, Sierra Leone, and Togo, where higher education is linked to lower prevalence. However, in Côte d'Ivoire, despite a majority being uneducated, higher education correlates with the highest prevalence (2.74%). In Guinea and Mali, while most women are uneducated and prevalence is high, those with secondary education have the highest prevalence, but the risk drops to the lowest among women with higher education. (Appendix for detailed country data) Occupation: In West Africa, the majority of women are employed, comprising approximately 70.58% of the population. The prevalence of fistula among working women is 1.27%, which is lower than the 1.64% prevalence observed among non-working women. Across individual countries, most women are also employed. Specifically, in Sierra Leone and Togo, fistula prevalence is higher among working women, which could be attributed to the larger sample size of working women (80.18% in Sierra Leone and 85.75% in Togo). In contrast, in Cote d'Ivoire, Guinea-Bissau, Mali, and Nigeria, the prevalence of fistula is lower among working women compared to those who are not working. Nigeria stands out with an overall very low prevalence of fistula and no sample of non-working women. These patterns suggest that occupation may influence fistula prevalence, although the impact varies across different contexts in West Africa. (Appendix for detailed country data) Age: In West Africa, young women aged 15-19 have a relatively high fistula prevalence of 1.43%, but they make up only 7.86% of the total population. As women move into the 20-34 age range, the prevalence decreases to its lowest (1.17% to 1.23%), with this age group comprising 66.75% of the population. However, as women age further, particularly in the 45-49 age group, the prevalence sharply rises to 1.67%, although this age group accounts for only 2.65% of the population. This trend suggests that while the risk of fistula may decrease during peak childbearing years, it appears to increase in later years. In the analysis by country, similar trends and significant differences emerge. In Guinea Bissau, Mali, Sierra Leone, and Togo, older women have higher prevalence rates, despite representing a smaller proportion of the population, indicating that health concerns among older women warrant more attention. Notably, in Cote d'Ivoire, women aged 25-29 have a significantly higher prevalence rate of 1.99% compared to other age groups. Conversely, in Nigeria, the prevalence is consistently low across all age groups, not exceeding 0.5%. Additionally, in most countries, except for Guinea Bissau, the prevalence among younger women is relatively low. (Appendix for detailed country data) Residence: In West Africa, most women (65.16%) live in rural areas, with a fistula prevalence of 1.16%. In contrast, 34.84% of women reside in urban areas, where the prevalence is slightly higher at 1.42%. This suggests that although more women live in rural areas, those in urban areas may face a slightly higher risk of developing fistula. Similarly, in Cote d'Ivoire, the distribution between urban and rural areas is relatively even, but the prevalence of fistula is higher in urban areas (1.6%). Likewise, in Togo, although the majority of women live in rural areas (83.92%), the fistula prevalence is higher in urban regions (2.03%). On the other hand, in Guinea Bissau, Mali, Nigeria, and Sierra Leone, rural populations are larger. And in these countries, rural women show a higher fistula prevalence compared to their urban counterparts. Although the higher prevalence in rural areas might be influenced by the larger sample size, it also highlights the need for greater attention to fistula risk in rural areas. (Appendix for detailed country data) Religion: In West Africa, Muslims make up the majority of the population (71.22%) and have the highest fistula prevalence at 1.43%. Christians represent 25.45% of the population, with a lower prevalence of 0.86%. The remaining groups, including Animists, those with no religion, and other religions, account for a very small portion of the population and show very low fistula prevalence. In Sierra Leone, Christians make up 21.25% of the population, while Muslims account for 78.73%. However, the highest fistula prevalence is found among Christians at 1.62%. In Togo, the religious landscape is more diverse. Christians are the largest group at 36.97%, with a fistula prevalence of 1.4%, the second highest. Animists, who comprise 34.85% of the population, have a very low prevalence at 0.43%. Those with no religious affiliation, making up 14.6% of the population, have the highest prevalence at 1.52%. The trends in other countries are similar to those observed across West Africa overall. In summary, while Muslims are the majority in West Africa and generally exhibit the highest fistula prevalence, there are significant exceptions. This suggests that the relationship between religion and fistula risk may vary significantly across different regions. (Appendix for detailed country data) Postpartum_Care: In West Africa, the majority of women (74.23%) never received postpartum care, yet their fistula prevalence is relatively low at 0.80%. About a quarter of women (25.75%) consistently received postpartum care, but this group exhibits a significantly higher fistula prevalence of 2.54%. In specific countries, such as Nigeria, 84.59% of women never received postpartum care, and while their prevalence is higher than those who received care, it remains low at 0.22%. In Togo, 59.14% of women did not receive postpartum care, and their prevalence is higher at 1.08%. Other countries show patterns similar to the overall trend in West Africa. This highlights the complexity of the relationship between postpartum care and fistula prevalence, suggesting that other factors may be at play in determining the risk. (Appendix for detailed country data) Delivery_place: In West Africa, most women (57.03%) always deliver in health facilities, and this group shows the highest fistula prevalence at 1.47%. A significant portion (37.04%) never delivers in health facilities and has a lower prevalence of 0.94%. A small percentage (5.92%) occasionally delivers in health facilities, with a prevalence of 1.07%. In Mali, Nigeria and Sierra Leone, women deliver in health facilities (65.92%, 36.18% and 62.88%, respectively) have the lowest prevalence rates (0.34%, 0.15% and 0.21%, respectively). The higher prevalence in health facilities could be linked to the complexity of cases referred to these settings. @tebeu_risk_2012 (Appendix for detailed country data) Delivery_professional: In West Africa, the majority of women (84.32%) consistently receive professional assistance during childbirth, with a fistula prevalence of 1.36%. A smaller portion of women (15.66%) never receive professional assistance, and their fistula prevalence is lower, at 0.67%. The higher fistula incidence observed among women who receive professional care during childbirth may be attributed to the fact that these women are already at higher risk due to underlying complications. @filippi_effects_nodate In Mali, Nigeria, and Togo, 19.25%, 26.34%, and 20.91% of women, respectively, do not receive professional assistance during childbirth, and they exhibit higher fistula prevalence rates of 0.65%, 0.28%, and 1.21%. Other countries follow a similar trend to the overall pattern in West Africa. This suggests that the presence of professional care, while essential, often accompanies more complex or high-risk pregnancies. (Appendix for detailed country data) Distance: In West Africa, 38.07% of women consider distance to a medical facility a significant issue, and this group has the highest fistula prevalence at 1.46%. In countries like Côte d'Ivoire, Sierra Leone, and Togo, the distribution of women who view distance as a problem versus those who do not is relatively balanced. Interestingly, in these countries, women who do not perceive distance as a major issue have higher fistula prevalence rates of 1.28%, 1.57%, and 1.71%, respectively. In Guinea Bissau, both the distribution and prevalence rates are more evenly spread. The trends in Mali, Nigeria, and across West Africa as a whole are similar to the overall pattern observed. This suggests that while distance is a recognized barrier, the perception of its impact on health outcomes, such as fistula prevalence, may vary significantly across different countries. (Appendix for detailed country data) Age_sex: In West Africa, the majority of women (87.93%) report having their first sexual intercourse between the ages of 8-19, with a fistula prevalence of 1.30%. A small percentage (1.56%) experienced their first sexual intercourse at the time of first cohabitation, and this group has the highest prevalence at 1.57%. These data suggest that earlier sexual debut is associated with a higher prevalence of fistula, but the highest risk is among those who begin sexual activity at the time of cohabitation. In Mali, the prevalence of fistula is nearly the same regardless of the age of first intercourse (0.46%, 0.47%). Interestingly, in Togo, the lowest prevalence is observed among those whose first sexual intercourse occurred between ages 8-19. The trends in other countries are similar to the overall pattern in West Africa. This observation aligns with a study conducted in Sub-Saharan Africa, which found that early sexual debut significantly increases the risk of developing vaginal fistula symptoms. @maheu-giroux_risk_2016 This supports the notion that early initiation of sexual activity is a critical risk factor for fistula prevalence in the region. (Appendix for detailed country data) Number_birth: In West Africa, the majority of women (53.94%) have three or fewer children, and this group has the highest prevalence of fistula at 1.38%. In Guinea-Bissau and Mali, the prevalence of fistula is nearly the same regardless of whether women have more or fewer children. However, the situation in Togo is different: 55.40% of women have four or more children, and this group has the highest fistula prevalence at 1.56%. The trends in other countries are similar to the overall pattern in West Africa. This suggests that while lower fertility rates are generally associated with higher fistula prevalence in West Africa, in some countries like Togo, higher fertility rates correspond to a greater risk. (Appendix for detailed country data) Contraception_use: In West Africa, the majority of women (80.98%) do not use any form of contraception, and this group has a fistula prevalence of 1.27%. A smaller percentage (15.51%) use modern medical methods of contraception, which is associated with a lower prevalence of 0.74%. In Nigeria, 5.27% of women use other forms of contraception, with a prevalence rate of 1.32%, but these women have a prevalence of 0%. Both modern contraception users and non-users in Nigeria exhibit very low prevalence rates of 0.24% and 0.21%, respectively. In Togo, the majority of women (83.23%) do not use contraception, and this group has the highest prevalence at 1.16%. In other countries, the trends are similar to the overall pattern in West Africa, where the highest prevalence is found among those using other, presumably less effective, forms of contraception, while those using modern medical methods have the lowest prevalence. This suggests that the type of contraception used may be associated with the risk of developing fistula, with less effective or traditional methods potentially leading to higher risks. === MCA The relationships between the relevant variables are examined using Multiple Correspondence Analysis (MCA). The findings are provided in terms of how different variables contribute to the MCA's primary dimensions. #figure( image("var_contrib_dim1.svg", width: 80%), caption: [Variable Contributions to Dimension 1 (Dim-1)], ) In the first dimension (Dim 1), the most significant contributing variables are residence, wealth, and delivery_place. This dimension prominently features upstream factors such as wealth and education, with both the wealthiest and poorest groups contributing significantly. Multiple levels of education also show notable contributions, indicating the broad impact of educational background. Downstream factors mainly encompass personal background aspects (residence) and access to medical services (delivery place, delivery professional). This analysis highlights the complex interplay between socioeconomic status and access to healthcare, illustrating how both upstream and downstream factors influence fistula in West Africa. #figure( image("var_contrib_dim2.svg", width: 80%), caption: [Variable Contributions to Dimension 2 (Dim-2)], ) In the second dimension (Dim 2), the most significant contributing variables are number_birth and age. This dimension shows minor contributions from upstream factors such as occupation and education. Downstream factors primarily include personal background factor (age) and aspects related to family planning and sexual health (number_birth, age_sex). This analysis highlights the importance of downstream factors such as number of births and age on fistula in West Africa == Bivariate Analysis In the bivariate analysis across West Africa, age and residence are not significantly associated with the outcome (p>0.05 ). Wealth, education, occupation, religion, distance, delivery_place, delivery_professional, postpartum_care, age_sex, number_birth and contraception_use show significant associations, highlighting their potential impact. The importance of these variables varies across countries. (see Appendix for details) Given the possibility of confounding, non-significant variables are also remained for multivariate analysis as they may still be important in interpreting the results. == Multivariate Analysis #figure( caption: "West Africa: Regression Results", table( columns: (30%, auto, auto, auto, auto, auto), align: left, stroke: none, table.hline(), table.header([**Factor**], [**Intercept**], [**p-value**], [**CI: 2.5%**], [**CI: 97.5%**], [**Sig.**]), table.hline(), [age_sex2], [-0.49546], [0.014125], [-0.8911554], [-0.09976301], [\*], [age_sex3], [0.89625], [0.00449], [0.2780767], [1.51443206], [\*\*], [distance1], [0.31944], [0.004312], [0.1001024], [0.53878206], [\*\*], [number_birth1], [-0.27143], [0.012871], [-0.4853154], [-0.05755219], [\*], [religion2], [-0.42067], [0.021844], [-0.7802366], [-0.06111184], [\*], [religion3], [-1.79006], [0.013989], [-3.217665], [-0.3624595], [\*], [religion4], [-1.21644], [0.011397], [-2.1586797], [-0.27419727], [\*], [religion5], [-10.80461], [< 2e-16], [-11.4875737], [-10.12164603], [\*\*\*], [wealth2], [0.18812], [0.25666], [-0.1369319], [0.51316947], [ ], [wealth3], [0.09739], [0.57146], [-0.2399269], [0.43471148], [ ], [wealth4], [0.6331], [0.000199], [0.2996342], [0.96657001], [\*\*\*], [wealth5], [0.60692], [0.001736], [0.2271354], [0.98670762], [\*\*], [education1], [-0.46497], [0.00731], [-0.8047113], [-0.12523024], [\*\*], [education2], [-0.75965], [8.67E-06], [-1.0943468], [-0.42494963], [\*\*\*], [education3], [-0.89376], [0.020253], [-1.6482844], [-0.13923874], [\*], [occupation1], [-0.08495], [0.50963], [-0.3374407], [0.16754566], [ ], [occupation2], [-1.01591], [0.002794], [-1.6819106], [-0.34989941], [\*\*], [contraception_use2], [0.64497], [0.000669], [0.2734097], [1.01653609], [\*\*\*], [contraception_use3], [1.64405], [2.70E-11], [1.1605054], [2.12760273], [\*\*\*], [delivery_place2], [0.02667], [0.905512], [-0.4136858], [0.46702299], [], [delivery_place3], [0.43798], [0.000774], [0.182647], [0.69331302], [\*\*\*], [delivery_professional2], [-10.31191], [< 2e-16], [-11.9478008], [-8.6760137], [\*\*\*], [delivery_professional3], [-0.28544], [0.134665], [-0.6594178], [0.08853977], [ ], [postpartum_care2], [-11.42399], [< 2e-16], [-12.3330881], [-10.51488996], [\*\*\*], [postpartum_care3], [-1.1411], [< 2e-16], [-1.356798], [-0.92539472], [\*\*\*], table.hline(), ) ) <west-africa> According to the results from svyglm (@west-africa), age_sex, distance, number_birth, religion, wealth, education, occupation, contraception_use, delivery_place, delivery_professional, and postpartum_care are significant (p-value < 0.05), indicating that these factors have an important impact on fistula. #figure( caption: "Countries: Regression Results", table( columns: (30%, auto, auto, auto, auto, auto, auto), align: left, stroke: none, table.hline(), table.header([**Factor**], [**Cote d'Ivoire**], [**Guinea-Bissau**], [**Mali**], [**Nigeria**], [**<NAME>**], [**Togo**]), table.hline(), [age2], [ ], [ ], [ ], [ ], [ ], [< 2e-16], [age3], [0.0255], [ ], [ ], [ ], [ ], [< 2e-16], [age4], [ ], [ ], [ ], [ ], [ ], [< 2e-16], [age5], [ ], [ ], [ ], [ ], [ ], [< 2e-16], [age6], [ ], [ ], [ ], [< 2e-16], [ ], [< 2e-16], [age7], [< 2e-16], [ ], [ ], [< 2e-16], [0.046886], [< 2e-16], [age_sex2], [ ], [ ], [ ], [ ], [< 2e-16], [ ], [distance1], [ ], [0.04986], [ ], [ ], [ ], [0.0201], [number_birth1], [ ], [ ], [ ], [ ], [0.000264], [0.0492], [religion2], [ ], [ ], [< 2e-16], [ ], [0.044288], [ ], [religion3], [< 2e-16], [< 2e-16], [ ], [< 2e-16], [ ], [ ], [religion4], [< 2e-16], [< 2e-16], [ ], [ ], [< 2e-16], [ ], [religion5], [< 2e-16], [ ], [ ], [< 2e-16], [ ], [ ], [wealth2], [ ], [ ], [0.00933], [ ], [ ], [ ], [wealth3], [ ], [ ], [0.03844], [0.03682], [ ], [ ], [wealth4], [ ], [ ], [0.03663], [0.0149], [0.029268], [ ], [wealth5], [ ], [ ], [0.04353], [0.00661], [ ], [0.04], [education1], [ ], [ ], [ ], [0.02263], [ ], [ ], [education2], [ ], [ ], [0.00925], [ ], [ ], [< 2e-16], [education3], [ ], [ ], [0.00397], [ ], [ ], [< 2e-16], [occupation1], [ ], [ ], [ ], [ ], [0.01499], [ ], [occupation2], [< 2e-16], [ ], [ ], [ ], [ ], [5.1e-05], [contraception_use2], [ ], [ ], [ ], [ ], [0.000644], [ ], [contraception_use3], [ ], [0.00886], [0.01602], [< 2e-16], [< 2e-16], [< 2e-16], [delivery_place3], [ ], [0.0054], [0.03597], [ ], [0.000321], [ ], [delivery_professional2], [< 2e-16], [ ], [ ], [ ], [ ], [ ], [postpartum_care2], [< 2e-16], [ ], [ ], [ ], [ ], [ ], [postpartum_care3], [ ], [2.54e-07], [ ], [ ], [< 2e-16], [ ], table.hline(), ) ) <country-table> From the @country-table, it is evident that significant factors vary across different countries. Cote d'Ivoire: In Cote d'Ivoire, the significant factors include age, religion, occupation, delivery_professional, and postpartum_care. Compared to West Africa as a whole, only occupation stands out as an upstream factor, while the downstream factors are more concentrated on personal background and healthcare services. Guinea-Bissau: In Guinea-Bissau, the significant factors are distance, religion, contraception_use, delivery_place, and postpartum_care. Unlike West Africa overall, Guinea-Bissau has no significant upstream factors. The downstream factors are mainly related to personal background, sexual health, and healthcare services, indicating that these aspects have a stronger influence in this country. Mali: In Mali, the significant factors include religion, wealth, occupation, contraception_use, and delivery_place. The upstream factors wealth and occupation highlight the influence of economic status and employment, while the downstream factors relate to personal background, sexual health, and healthcare services. Nigeria: In Nigeria, age, religion, wealth, education, and contraception_use are significant. Compared to West Africa overall, Nigeria's significant upstream factors include wealth and education, while the downstream factors focus on personal background and sexual health. This suggests that education and economic status play a more prominent role in the risk of fistula in Nigeria. Sierra Leone: In Sierra Leone, the significant factors include age, age_sex, number_birth, religion, wealth, occupation, contraception_use, delivery_place, and postpartum_care. Compared to other countries, Sierra Leone has the most significant factors, with wealth and occupation as upstream factors and personal background, sexual health, and healthcare services as downstream factors, reflecting a more complex set of influences on fistula risk. Togo: In Togo, the significant factors are age, distance, number_birth, wealth, education, occupation, and contraception_use. Compared to other countries, Togo has a more complete set of upstream factors. The downstream factors encompass personal background, sexual health, and healthcare services, showing a broad range of influences on fistula risk. Overall, the significant factors in West Africa cover a wide range of socio-economic, personal background, medical services, family planning, and sexual health influences, indicating their widespread impact across the region. However, at the country level, the distribution of significant factors between upstream and downstream varies. For instance, Cote d'Ivoire and Guinea-Bissau have significant factors more concentrated on downstream factors like healthcare and sexual health, while countries like Nigeria and Mali are more affected by upstream factors like economic status and education. Sierra Leone and Togo exhibit a broader range of significant factors, encompassing both upstream and downstream factors, indicating a more complex set of causes for fistula risk. Therefore, in developing preventive strategies, it is crucial to consider the specific significant factors in each country to create more targeted and effective interventions. == Exploring Upstream and Downstream Interactions Exploring upstream and downstream interactions across West Africa to gain a deeper understanding of factors influencing fistula. The larger sample size in the West African dataset provides a more reliable foundation for analysis. Downstream factors are identified from the significant variables in the model. The final model is then used to further analyze the significant interaction terms. === Wealth The interaction between wealth and delivery_professional suggests that occasional assistance significantly reduces the risk of adverse outcomes such as fistula, especially for wealthier women. Statistics show that the coefficients for wealth groups 2, 3, and 5 are -11.01, -10.78, and -11.81, respectively, and the p-values are extremely low (all between 4.36E-15 and < 2e-16), indicating that this effect is highly significant. This means that although wealthier women may have more access to continuous care, they still benefit from any form of professional assistance. This suggests that it is critical to ensure that all women receive some professional care during childbirth, regardless of their wealth. The interaction between wealth and first sexual intercourse during cohabitation also shows a significant protective effect against fistula, particularly for wealthier women (coefficient: -13.10371, p-value: < 2e-16). This suggests that wealth and the timing of sexual behavior together reduce the risk of adverse outcomes. The interaction between wealth and religion shows Animists experience significant variations in fistula risk based on wealth levels. Specifically, Animists with pooer wealth face a substantially higher risk of fistula (coefficient = 13.85746, p < 2e-16), while those in higher wealth brackets show a significantly lower risk across multiple levels, like wealth4 (coefficient = -14.90821, p < 2e-16). This indicates that wealth serves as a crucial upstream factor that indirectly affects fistula risk by significantly altering risk levels for Animists. For other religious groups, the relationship is less pronounced, emphasizing the unique impact of wealth on fistula risk within the Animist community. In conclusion, the impact of wealth on fistula prevalence in West Africa is complex. It is similar to findings in Ethiopia where the wealthiest women had a prevalence of 26.3% compared to 13.2% for the poorest. @andargie_determinants_2017 Wealth, as an upstream factor, can also indirectly influence fistula prevalence by affecting downstream factors like postpartum care. This underscores the importance of addressing both direct and indirect pathways through which socioeconomic status impacts health outcomes in the region. === Education The interaction analysis reveals that education significantly moderates the risk of fistula associated with the timing of first sexual intercourse. Women who experienced their first sexual intercourse at the time of cohabitation, with either secondary education (coefficient = -12.45415, p < 2e-16) or higher education (coefficient = -11.42680, p < 2e-16), show a markedly lower risk of fistula compared to those without education. This indicates that education acts as a strong protective factor, effectively reducing the risks associated with sexual initiation at cohabitation. Notably, secondary education has a slightly stronger effect, suggesting that education at this level may be particularly influential in mitigating fistula risk. Overall, these findings highlight how education may reduce the risk of fistula by influencing the downstream factor of age_sex. The interaction between education and delivery_place reveals that higher education significantly reduces fistula risk, particularly for women who occasionally deliver in health facilities (interaction coefficient = -12.2334, p < 2e-16). This suggests that higher education enhances women's ability to manage health risks even with variable access to delivery services. This indicates that how upstream factors like education can influence downstream outcomes such as fistula risk through their effects on healthcare utilization. The interaction between distance and education shows that women with primary education who perceive distance as a significant problem have a significantly lower risk of fistula (coefficient = -0.9807, p = 0.0045). This suggests that upstream factors like education help mitigate the negative impact of downstream factors such as access to healthcare, reducing fistula risk. However, the protective effect of education diminishes at higher levels, as secondary and higher education do not significantly alter the risk associated with distance. These findings highlight how basic education can indirectly reduce fistula risk by enabling better navigation of healthcare challenges. The interaction between religion and education shows that higher education levels significantly reduce the risk of fistula for most religious groups, particularly among Animist (coefficient = -11.4957, p < 2e-16) and No religion women (coefficient = -12.3696, p < 2e-16) with primary education. For these groups, the protective effect of education increases with higher levels of schooling. This highlights the protective role of education in mitigating the effects of certain religious affiliations on fistula risk. The analysis of West Africa indicates that education significantly impacts the prevalence of fistula, a finding consistent with previous studies. For instance, research in Ethiopia revealed that uneducated women have the highest prevalence of obstetric fistula (19.4%). Additionally, women who delivered at home had the highest prevalence of fistula (20.5%) @andargie_determinants_2017 Similarly, a study across 14 African countries found that women with secondary and higher education levels have a 41% and 60% lower risk of developing obstetric fistula, respectively. Furthermore, this research finds that education influences fistula prevalence through its interaction with postpartum care is supported by the same study across 14 African countries, which highlights that educated women are more likely to utilize maternal health services, thereby reducing their risk of fistula. @alie_counting_2021 This shows that education has an impact not just on the prevalence of fistula, but also on health outcomes through interactions with downstream determinants. === Occupation The interaction between occupation and postpartum care shows that working women who never received postpartum care have a significantly lower risk of fistula (coefficient = -0.8015, CI= -1.3121 -0.2909), since the main effect of being employed showing an increased risk (coefficient = 0.3318, CI= -0.0695, 0.7331). This suggests that upstream factors like occupation, when combined with downstream factors such as lack of postpartum care, influence fistula risk in unexpected ways. In contrast, occasional postpartum care has no significant impact on the risk for working women. The interaction between occupation and contraceptive_use reveals that women in the "Don't know" employment category who use other contraceptive methods experience a significantly lower risk of fistula (coefficient = -13.7277, CI= -15.9423 -11.5131). This suggests that in this group, using non-modern methods is associated with a reduced risk, highlighting the complex relationship between upstream factors like occupation and downstream factors like contraceptive choices. The interaction between religion and occupation shows that women who identify as Animist and are working have a significantly higher risk of fistula (coefficient = 12.06, p < 2e-16), as do those with no religion who are working (coefficient = 12.75, p < 2e-16). This suggests that upstream factors like occupation, combined with downstream cultural or religious practices, significantly increase health risks for these groups. These findings highlight the critical role of both cultural and socio-economic factors in influencing fistula prevalence. These analyzes highlight interactions between occupation and downstream factors. The differences in the impact of different factors indicate that specific socioeconomic and cultural backgrounds, as well as medical services and other factors need to be comprehensively considered when formulating interventions for fistulas. = Discussion == Findings === Upstream Factors The analysis shows that upstream factors (wealth, education, occupation) play a significant role in influencing fistula prevalence across West Africa. Wealth distribution presents a unique pattern where wealthier women generally experience a higher prevalence of fistula, despite the poorest groups having a slightly larger population share. This is consistent with findings in Ethiopia, where wealthier groups also showed a higher prevalence of fistula @andargie_determinants_2017. Education is a critical factor, with uneducated women showing the highest prevalence overall, and a clear trend of lower fistula risk with higher education, though exceptions exist in some countries. This finding aligns with research conducted across 14 African countries, including West Africa, which found that higher education levels are associated with lower fistula risk @alie_counting_2021 @rettig_female_2020. In terms of occupation, non-working women face a higher prevalence of fistula compared to their employed counterparts across the region. It is consistent with findings from studies in both Ethiopia and Kenya @andargie_determinants_2017 @weston_obgyn_nodate. These findings emphasize the direct influence of upstream socioeconomic factors on fistula risk, highlighting the importance of addressing wealth disparities, improving education access, and supporting women's employment as part of broader efforts to reduce fistula prevalence in West Africa. === Downstream Factors While age and residence are recognized in the literature as influential factors, in West Africa overall, they do not significantly affect fistula prevalence. This contrasts with previous research, such as studies in Ethiopia and Niger, which found that younger women are more likely to suffer from fistula due to early pregnancies @tebeu_risk_2012 @ouedraogo_obstetric_2018. However, in this research, age only shows important influence in certain countries like Nigeria, Sierra Leone, and Togo, where younger or older women are more at risk, suggesting country-specific variations rather than a regional trend. And religion is a significant factor influencing fistula prevalence, consistent with findings from studies conducted in Sub-Saharan Africa @maheu-giroux_risk_2016 @gatwiri_better_2017. The analysis in Nigeria also confirms religion as an important determinant, aligning with previous research conducted in the country @oluwabamide_assessment_2011. These findings highlight the crucial role of religion in determining fistula risk across West African countries. Postpartum care, place of delivery, distance to medical facilities, and professional delivery assistance are significant factors influencing fistula risk in West Africa. This is consistent with findings from previous studies that highlight the importance of postpartum care @alie_counting_2021 @deribe_measuring_2020, place of delivery @andargie_determinants_2017 @ijaiya_vesicovaginal_2010, distance to healthcare facilities @gedefaw_estimating_2021 @ronsmans_maternal_2003, and professional delivery assistance @mama_pelvic_2022 @ijaiya_vesicovaginal_2010. Interestingly, women who consistently receive postpartum care or deliver in health facilities tend to have higher prevalence rates, possibly due to underlying complications that require medical intervention. In the domain of family planning and sexual health, contraception use, age of first sexual intercourse, and total births are significant factors. Women who use modern contraception methods show lower fistula prevalence @who_family_2024 @gedefaw_estimating_2021, while those who begin sexual activity at younger ages @maheu-giroux_risk_2016 face higher risks. And total births is also a significant risk factor, consistent with previous studies @ijaiya_vesicovaginal_2010 @gedefaw_estimating_2021. These findings emphasize the critical role of sexual health education and access to family planning in reducing fistula prevalence across West Africa. === Interactions Wealth significantly influences the risk of fistula through interactions with various factors. Wealthier women benefit from any professional care during childbirth, reducing their risk of fistula.It consistent with previous studies @deribe_measuring_2020. Additionally, while previous research has not explored the interaction between wealth and religion in detail, this research offers new insights. Wealth combined with the timing of first sexual intercourse (during cohabitation) shows a strong protective effect, particularly for wealthier women. Wealth also interacts with religion, notably affecting Animists, where lower wealth levels increase the risk of fistula, while higher wealth levels reduce it. Education plays a crucial role in moderating fistula risk. Women with secondary or higher education who experienced their first sexual intercourse during cohabitation have a markedly lower risk of fistula. Education also interacts with healthcare access @alie_counting_2021: higher education reduces fistula risk even with variable access to health facilities. Basic education mitigates the negative impact of distance on healthcare access, while the protective effect of higher education diminishes in this context. In addition, the Tostan program in West Africa raised women's health risk awareness and effectively prevented fistula through community education. @noauthor_obstetric_2005 Overall, education influences fistula risk through its effects on sexual behavior and healthcare utilization. The interaction between occupation and postpartum care shows that working women without postpartum care have a lower risk of fistula, contrary to the general increased risk associated with occupation. This contrasts with previous research, which generally links postpartum care, along with higher wealth and education, to a reduced risk of fistula @alie_counting_2021 @deribe_measuring_2020. Additionally, women in the "Don't know" employment category who use non-modern contraceptive methods experience a lower risk of fistula. The interaction between occupation and religion reveals that working Animists and those with no religion face a higher risk of fistula, indicating that occupation and religion or sexual health factors jointly affect fistula. === Country Variations The prevalence of fistula across West Africa reveals a significant variation, with overall rates ranging from 0.20% in Nigeria to 4.60% in Guinea-Bissau. This difference emphasizes significant regional differences in fistula risk. While West Africa as a whole shows a diverse set of influential factors, individual countries highlight different aspects of this complex issue. In general, upstream factors (wealth, education, occupation) play crucial roles in influencing fistula risk across the region. However, the impact of these factors varies by country. For instance, Nigeria and Mali show an obvious influence of economic status and education, whereas countries like Guinea-Bissau and Cote d'Ivoire emphasize the role of downstream factors such as healthcare access and personal background. These findings indicate that while some factors have widespread significance across West Africa, specific interventions are necessary to address the specific influences of each country. == Research Contributions This research makes important contributions to the existing literature on fistula prevalence in West Africa. First, this research systematically explored upstream and downstream factors that affect fistula risk in the region, revealing in depth how socioeconomic levels and other variables work together to influence the occurrence of fistula. This research analyzes multiple dimensions, thereby providing a more comprehensive understanding of the determinants of fistula. In addition, it also deeply analyzed regional differences among West African countries, exploring not only the influencing factors throughout West Africa, but also identifying unique risk factors for each country, reflecting the breadth and meticulousness of the study. Another notable contribution is the development of a data visualization dashboard that allows for more effective exploration of fistula prevalence in the West African region and across different countries. This makes the data more understandable, and researchers and policymakers can develop more effective fistula prevention policies through the exploration of the dashboard. == Policy Suggestions Although wealth is generally associated with better health care, this research found that women with higher wealth have a higher prevalence of fistula. This suggests that even women with better economic conditions may face potential medical risks. Policymakers should conduct in-depth research on the health behaviors of high-income women. In addition, the interaction between wealth and religion has an important impact on fistula risk, like Animists. Policies should combine religious beliefs and economic status to develop comprehensive intervention measures. Education is closely associated with fistula risk, with the highest fistula prevalence in mostly uneducated women in West Africa. Policies should focus on and promote female education. At the same time, there was a significant interaction between education and age at sexual intercourse. This suggests that sexual health education can be strengthened in schools to improve women's awareness of fistula risks. The higher prevalence of fistula among non-working women suggests that policies need to further encourage women to work. Policymakers can promote women's employment by providing more jobs. == Limitations Accuracy of Self-reported Data: Using the question "Have ever experienced a problem of leakage of urine or stool from vagina" from the DHS data to infer the prevalence of fistula has limitations, as it is not based on medical diagnosis. This self-reporting approach may lead to an over- or underestimation of the actual prevalence of fistula, thereby affecting the accuracy of the results. Data Missingness: Due to some respondents skipping certain questions in the DHS questionnaire, a large number of samples had to be removed during the data preprocessing stage. This missing data may introduce potential bias, especially after the sample size is reduced, making the analysis results less representative of the general population. Time Differences in Data Collection: The dataset from Togo is from 2013, while the data from other countries is from 2018, 2019, and 2021. This time difference was not specifically considered in the analysis and may lead to a certain degree of bias, as social, economic, and healthcare conditions could have changed during these years. Therefore, the time difference may affect the accuracy of comparisons and introduce uncertainty to the results. Data Imbalance: The proportion of fistula cases in the dataset is extremely low, making the dataset highly imbalanced. Even though Survey-weighted Generalized Linear Models (svyglm) were used to account for the complex survey design, this imbalance may still result in the model being biased towards the majority class, affecting the robustness and interpretability of the results. == Future Research Directions Future studies should focus on how stigma affects fistula patients. @changole_i_2017 It is vital to treat not only the medical disease, but also any psychological issues that occur. For example, research can focus on eliminating misconceptions that contribute to stigma. @roush_social_2009 @bashah_consequences_2018 Research might also be undertaken on how to successfully reintegrate into society. @khisa_understanding_2017 Furthermore, prevention measures for fistulas should better identify specific risk factors in different countries. @tebeu_risk_2012 West African countries urgently require efficient national fistula treatment and prevention initiatives. @noauthor_towards_2022 When developing strategies, consider close integration with the Sustainable Development Goals. @slinger_obgyn_2020 Future research should prioritize not only the medical treatment of fistula patients but also consider the psychological and social dimensions, such as how stigma affects affected women. Previous studies have shown that stigma often exacerbates the emotional and mental health challenges faced by fistula patients. @changole_i_2017 Research can focus on identifying and eliminating the misconceptions that contribute to stigma, which is crucial for improving the quality of life for these women. @roush_social_2009 @bashah_consequences_2018 Additionally, how these women reintegrate into society should be a key area of study, as stigma and isolation often hinder their successful reintegration. @khisa_understanding_2017 Fistula prevention should also be a priority, especially in regions such as West Africa, where socioeconomic and healthcare settings vary widely across countries. @tebeu_risk_2012 In addition, West African countries urgently need to develop effective national fistula treatment and prevention measures. @noauthor_towards_2022 In developing such strategies, it is important to integrate these efforts with the Sustainable Development Goals, particularly improving maternal health and reducing health inequalities. @slinger_obgyn_2020 In addition, future research should also focus on solving the common data imbalance problem in fistula research. Since fistula cases account for a very small proportion of the data, research should explore more appropriate methods to handle imbalanced datasets to improve the performance of the model and the reliability of the results. = Conclusions This research offers important insights into the prevalence and determinants of fistula in women of reproductive age across West Africa, emphasizing the critical role of both upstream and downstream factors. The findings reveal that while wealthier women surprisingly face higher fistula risks, education remains a key protective factor, with uneducated women experiencing the highest prevalence of fistula. Furthermore, the research highlights significant national variations, stressing the need for targeted interventions in different regions. A notable contribution of this research is the development of a data visualization dashboard, which allows for more effective exploration and understanding of fistula prevalence across the region. This tool enhances both research and policy-making by making the data more accessible and actionable. Despite these contributions, the study has several limitations, including data imbalance and the reliance on self-reported data, which may affect the accuracy of the results. Additionally, the differences in data collection periods across countries, such as Togo's earlier dataset, may introduce some bias in comparisons. Future research should address these limitations, focusing on stigma-related issues, the reintegration of fistula survivors into society, and the development of more robust methods to handle data imbalance. Moreover, it is crucial to prioritize prevention strategies that are tailored to the specific needs of each country, integrating these efforts with broader global initiatives to improve the health of women of reproductive age. #bibliography("fistula1.bib")
https://github.com/coalg/notebook
https://raw.githubusercontent.com/coalg/notebook/main/exercises/basic-exercise.typ
typst
#import "@preview/ttt-exam:0.1.0": * #import "@preview/wrap-it:0.1.0": * #import components: frame, field, point-tag #import "@preview/codelst:2.0.1": sourcecode #set text(lang:"ja", font: "<NAME>", weight: 300, size: 12pt) #set list(indent: 2em) #set enum(indent: 2em, numbering: "a)") #show link: underline #show raw.where(block: false): box.with( fill: luma(240), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, ) #let question(body, points: none, number: auto) = { grid( inset: (0.5em, 0em), columns: (1fr, auto), column-gutter: 0.5em, _question(points: points)[ #context q-nr(style: if-auto-then(number, { if is-assignment() { "問1:" } else { "1." } })) #body ], if points != none { place(end, dx: 1cm,point-tag(points)) } ) } #align(center, text(20pt)[ *プログラミング練習問題集* ], ) #align(center, text(14pt)[ 第 0.1 版 ], ) #set page(numbering: "1") = 1. プログラミングの基礎 #assignment[ *(基本文法の確認)* 以下のプログラムを作成せよ。 #question(points: 1)[ *(変数の定義)* 始点、終点、そして始点から終点まで到達するまでの経過時間を元に速度を計算するプログラムを作れ。 #sourcecode[ ```py def speed(start: int, end: int, time_elapsed: int) -> int: # TODO: 以下に`distance` 変数を定義して正しい値を計算せよ。 # 以下の行は変更しないこと return distance // time_elapsed assert speed(10, 30, 10) == 2 assert speed(10, 30, 2) == 15 assert speed(10, 31, 10) == 2 ``` ] 以降のプログラム作成問題では、特に指示がない限り `assert` でプログラムの動作チェックを行うことをおすすめする。 ] #question(points: 1)[ *(分岐)* 奇数を判定するプログラムを書け。 #sourcecode[ ```py def is_odd(n: int) -> bool: pass assert is_odd(1) == True assert is_odd(2) == False assert is_odd(101) == True ``` ] ] #question(points: 1)[ *(分岐)* 夏日は最高気温が25℃以上の日のことである。その日の最高気温から夏日か判定するプログラムを書け。 #sourcecode[ ```py def is_summerday(high_temperature: int) -> bool: pass assert is_summerday(25) == True assert is_summerday(24) == False ``` ] ] #question(points: 2)[ *(分岐)* 気象庁では温度ごとに天候が以下のように定義されている。 - 最低気温が0℃未満: 冬日 - 最高気温が0℃未満: 真冬日 - 最高気温が25℃以上: 夏日 - 最高気温が30℃以上: 真夏日 - 最高気温が35℃以上: 猛暑日 最高気温と最低気温に基づいて、各天候を文字列として返す関数を書け。条件に当てはまらない場合の呼称を考慮してみよ。 #sourcecode[ ```py def weather(high_temperature: int, low_temperature: int) -> str: pass ``` ] ] #question(points: 2)[ *(エラー処理)* 速度を計算するプログラムについて、経過時間が 0 の場合エラー処理を行え。必要に応じてエラー処理、ゼロ除算について調べよ。 #sourcecode[ ```py from typing import Union def speed(start: int, end: int, time_elapsed: int) -> Union[int, str]: # TODO pass assert speed(10, 30, 0) == "Zero division error" assert speed(10, 30, 10) == 2 assert speed(10, 30, 2) == 15 assert speed(10, 31, 10) == 2 ``` ] ] #question(points: 2)[ *(再帰)(基本情報技術者試験 サンプル問題 改題)* 非負整数 `n` を引数に取り、階乗を計算する関数 `fact` の正しいプログラムを作れ。実装には再帰を使え。 #sourcecode[ ```py def fact(n: int) -> int: pass assert fact(0) == 1 assert fact(1) == 1 assert fact(2) == 2 assert fact(5) == 120 ``` ] ] #question(points: 1)[ *(`while`)* 非負整数 `n` を引数に取り、階乗を計算する関数 `fact` の正しいプログラムを作れ。実装には `while` を使え。 #sourcecode[ ```py def fact(n: int) -> int: pass assert fact(0) == 1 assert fact(1) == 1 assert fact(2) == 2 assert fact(5) == 120 ``` ] ] #question(points: 1)[ *(`for`)* 非負整数 `n` を引数に取り、階乗を計算する関数 `fact` の正しいプログラムを作れ。実装には `for` を使え。 #sourcecode[ ```py def fact(n: int) -> int: pass assert fact(0) == 1 assert fact(1) == 1 assert fact(2) == 2 assert fact(5) == 120 ``` ] ] \ *(変数と関数)* BMI(Body Mass Index)は体重と身長から算出される、肥満度を表す体格指標である。計算式は以下の通りである。 $ "BMI" = "体重(kg)" / "身長(m)"^2 $ #question(points: 1)[ 身長と体重を表す変数を各々用意して、BMIを計算してみよ。 ] #question(points: 1)[ BMIを計算する関数を設計せよ。 ] #question(points: 1)[ 関数が正しく計算されていることを確認するための `assert` 文を書け。 ] #question(points: 2)[ #link("https://ja.wikipedia.org/wiki/%E3%83%9C%E3%83%87%E3%82%A3%E3%83%9E%E3%82%B9%E6%8C%87%E6%95%B0")[ WikipediaのBMIの項 ] を参考に、体重と身長を入力値として、状態を出力するプログラムを作成せよ。 ] #question(points: 2)[ BMI計算の入力値について何か注意する点はあるか。気付いた点について意見を述べよ。 ] \ *(プログラムの読解)* 以下にプログラムを挙げる。問に回答せよ。 #question(points: 1)[ 以下は `Hello, World` を出力することを意図した1行のプログラムである。バグを指摘し修正せよ。 #sourcecode[ ```python print(Hello, World) ``` ] ] #question(points: 1)[ *(基本情報技術者試験 R5類題)* 以下のプログラムについて、`proc2`を呼び出した際の動作を説明せよ。 #sourcecode[ ```python def proc1(): print("A") def proc2(): proc3() print("B") proc1() def proc3(): print("C") proc1() ``` ] ] #question(points: 1)[ *(基本情報技術者試験 サンプル問題)* 以下のプログラムの動作を説明せよ。 #sourcecode[ ```python x = 1 y = 2 z = 3 x = y y = z z = x print(y, z) ``` ] ] #question(points: 1)[ *(基本情報技術者試験 サンプル問題 改題)* 関数`calc`は $x$, $y$ を受け取り $sqrt(x^2 + y^2)$ を計算する。`+` 演算子と`**` 演算子のみを使ってこの関数を実装せよ。 #sourcecode[ ```python def calc(x: float, y: float): pass ``` ] ] #question(points: 2)[ *(基本情報技術者試験 サンプル問題)* 以下の関数 `makeNewArray` を `makeNewArray([3, 2, 1, 6, 5, 4])` と呼び出した時、返り値のリストの添字 `4` 番目の値は何になるか。 #sourcecode[ ```py def makeNewArray(input: list[int]) -> list[int]: out = [input[0]] for i in range(1, len(input)): tail = out[len(out)-1] out.append(tail + input[i]) return out ``` ] ] *(プログラムにバグを混入する)* 以下に正しく動作するPythonプログラムを示す。指定したエラーメッセージを表示させるようプログラムにバグ埋め込み(エンバグ, enbugging)を行え。コードの編集文字数については、多くても概ね3文字以内となることに注意せよ。 - 参考:#link("https://product.st.inc/entry/2024/05/27/113038")[Ruby "enbugging" quiz の解説] - 参考:#link("https://dl.acm.org/doi/10.1145/3587102.3588823")[ Mind the Error Message: An Inverted Quiz Format to Direct Learner's Attention to Error Messages ] #question(points: 1)[ 以下のコードをエンバグせよ。 #sourcecode[ ```py n = 1000 print(n + 1) print("No Error") ``` ] 期待エラー: `NameError: name '***' is not defined.` ] #question(points: 1)[ 以下のコードをエンバグせよ。 #sourcecode[ ```py array = ["NO ERROR"] print(array[0].lower()) ``` ] 期待エラー: `IndexError: list index out of range` ] #question(points: 1)[ 以下のコードをエンバグせよ。 #sourcecode[ ```py a = 10 print(a // 2) print("No Error") ``` ] 期待エラー: `TypeError: unsupported operand type(s) for //: *** and ***` ] #question(points: 1)[ 以下のコードをエンバグせよ。 #sourcecode[ ```py def f(): return 1 print(f()) ``` ] 期待エラー: `TypeError: f() takes 0 positional arguments but 1 was given` ] ] #pagebreak() #assignment[ *(数値演算と条件分岐 基本)*以下のプログラムを作成せよ。 #question(points: 1)[ `input()` 関数を使い、入力した文字列をそのまま表示するプログラムを作成せよ。 ] #question(points:1)[ `input()` 関数から2つの数字を受け取り、大きい数を表示するプログラムを作成せよ。 ] #question(points: 1)[ `input()` 関数から1つの整数を受け取り、絶対値を表示するプログラムを作成せよ。 ] #question(points: 2)[ アクションゲームの判定部を作る。操作キャラクターがスター状態かつ敵と体当たりしている場合、敵を倒すことができる。「スター状態であるか」と「体当たり状態か」を真偽値として入力し、「敵を倒すことができるか」を真偽値として返却する関数を作れ。テストに必要なassert文が足りていないため追加せよ。 #sourcecode[ ```py def beatable(is_star: bool, is_bumped: bool) -> bool: pass assert beatable(True, True) == True assert beatable(False, True) == False ``` ] ] #question(points: 2)[ アクションゲームのミス判定部を作る。操作キャラクターが「パワーアップ状態か」と「敵と接触しているか」を受け取り、操作キャラクターがやられたかどうか(ミス)を判定する。パワーアップ状態でないのに敵と接触した場合ミスとし、それ以外ではやられていないと判定する。 #sourcecode[ ```py def has_beaten(is_powerup: bool, is_bumped: bool) -> bool: pass ``` ] ] #question(points: 1)[ 割り算を実行し、商 (quotient) と余り (reminder) のペアを返す関数を実装せよ。 #sourcecode[ ```py def quot_rem(x: int, y: int) -> (int, int): pass assert quot_rem(4, 3) == (1, 1) assert quot_rem(8, 3) == (2, 2) assert quot_rem(10, 5) == (2, 0) ``` ] ] #question(points: 2)[ 時間を分で受け取り、時間と分のタプル値 `(hour, minutes)`を返却するプログラムを作成せよ。 #sourcecode[ ```py def minute2hours(m: int) -> (int, int): pass assert minute2hours(30) == (0, 30) # 30分は0時間30分 assert minute2hours(150) == (2, 30) # 150分は2時間30分 ``` ] ] #question(points: 1)[ 通貨を両替するプログラムを書け。両替する額(budget)と両替レート(exchange_rate)が与えられる。両替レートは外貨1単位に対して必要な自国通貨を表す。 #sourcecode[ ```py def exchange_money(budget: float, exchange_rate: float) -> float: pass assert exchange_money(127.5, 1.2) == 106.25 ``` ] ] #question(points: 1)[ 両替金額と紙幣の単位を入力し、両替するのに紙幣が何枚必要になるかを計算するプログラムを作れ。例えば10,500円を1,000円で両替する場合、お札は10枚必要になる(端数は切り捨てる)。 #sourcecode[ ```py def number_of_bills(amount: float, denomination: int) -> int: pass assert number_of_bills(10500, 1000) == 10 ``` ] ] #question(points: 2)[ *(Excercismより)* ある通貨を両替した時の額を出力せよ。両替する額(budget)と両替レート(exchange_rate)、手数料率(spread)と両替単位(denomination)が与えられる。 手数料率は `整数値` %として与えられる。そのため、例えば両替レート `1.10`, 手数料率 `10` %の場合、実際の両替レートは `1.21` となる。 両替単位は両替を行う紙幣単位を表す。両替は指定された両替単位未満で行うことができる。そのため、両替額に対して実際の両替レートで除した後、両替単位未満の端数は切り捨てたものを両替額とする。 #sourcecode[ ```py def exchangeable_value(budget: float, exchange_rate: float, spread: int, denomination: int) -> int: pass assert exchangeable_value(127.25, 1.20, 10, 20) == 80 assert exchangeable_value(127.25, 1.20, 10, 5) == 95 ``` ] ] #question(points:1)[ ある年齢が、日本の法律に基づき成年か未成年か判定するプログラムを作成せよ。 #sourcecode[ ```py def is_adult(age: int) -> bool: pass assert is_adult(17) == False assert is_adult(18) == True ``` ] ] #question(points:2)[ 現在の年齢と年を与えて、その人物が令和、平成、昭和、大正、明治のいずれの生まれであるかを判定するプログラムを設計せよ。 ] #question(points: 2)[ ある映画館の料金は以下のようになっている。 - 一般料金2,000円 - 6歳未満 無料 - 6歳以上18歳未満 1,000円 - 18歳以上22歳未満 1,500円 - シニア(60歳以上)1,400円 入力を年齢として、映画料金を算定するプログラムを書け。 #sourcecode[ ```py def admission_fee(age: int) -> int: pass ``` ] ] \ *(数値演算 演習)* 以下のプログラムを作成せよ。 #question(points: 3)[ *(フィボナッチ数)* 与えられた整数 `n` について、n番目のフィボナッチ数を計算するプログラムを書け。 #sourcecode[ ```py def fib(n: int) -> int: pass assert fib(1) == 1 assert fib(2) == 1 assert fib(3) == 2 assert fib(4) == 3 assert fib(5) == 5 assert fib(6) == 8 assert fib(7) == 13 ``` ] ] #question(points: 3)[ *(ユークリッドの互除法)* 2つの正整数を受け取り、最大公約数を表示するプログラムを作成せよ。不明な場合はユークリッドの互除法を調べよ。 #sourcecode[ ```py def gcd(a: int, b: int) -> int pass assert gcd(10, 8) == 4 assert gcd(31, 7) == 1 assert gcd(100, 50) == 50 ``` ] ] #question(points: 4)[ *(エラトステネスの篩)* 与えられた正整数について素数かどうか判定するプログラムを書け。不明な場合はエラトステネスの篩を調べよ。 #sourcecode[ ```py def is_prime(n: int) -> bool pass assert is_prime(1) == False assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(105) == False assert is_prime(109) == True ``` ] ] #question(points: 2)[ うるう年を判定するプログラムを書け。ここでうるう年は以下の条件に当てはまる年である。 - 4の倍数かつ100の倍数ではない - 400の倍数である ] #question(points: 2)[ *(FizzBuzz)* 1から100までの数を表示せよ。ただし数値が3の倍数の時は`Fizz`、5の倍数の時は`Buzz`、15の倍数であれば`FizzBuzz`と表示せよ。 この問題を解かせる理由については、以下のジェフ・アトウッドの有名なエッセイを参照せよ。 - #link("http://www.aoky.net/articles/jeff_atwood/why_cant_programmers_program.htm")[ 『どうしてプログラマに・・・プログラムが書けないのか?』 ] ] #question(points: 3)[ *(ピタゴラス数)* 100以下のピタゴラス数を列挙せよ。ここでピタゴラス数とは $a^2 + b^2 = c^2$ となるような数の組 $(a, b, c)$ である。 ] #question(points: 4)[ 二次方程式 $a x^2 + b x + c = 0$ の解を求めるプログラムを書け。解がない場合または虚数解である場合には適切なメッセージを表示するようにせよ。 ] #question(points: 2)[ *(コラッツの問題)* 任意の正整数 $n$ について、以下の操作を繰り返す。 - $n$ が偶数の場合、$n$ を $2$ で割る - $n$ が奇数の場合、$3n + 1$ とする 「有限回の操作で $n$ は必ず $1$ に到達する」という主張がコラッツ予想と呼ばれる。$n=27$ について操作により数がどのように変化するか確認せよ。また操作回数は何回になるか。 ] #question(points: 4)[ 前問について、$2 <= n <= 1000$ の範囲で操作回数が最大になる数は何か。また操作中の数の最大値はいくらになるか。 ] #question(points: 4)[ *(アームストロング数)* $n$ 桁の正整数 $N$ について、各桁を$n$ 乗した総和が元の数に等しいとき $N$ をアームストロング数と呼ぶ。例: $372 = 3^3 + 7^3 + 2^3$。 - 1つの数を受け取り、アームストロング数であるか判定する関数を作れ。 - $1 <= N <= 1000000$ のアームストロング数をすべて求めよ。 ] #question()[ *(1995年 京都大)* 自然数 $n$ の関数 $f(n)$, $g(n)$ を $ f(n) = n "を " 7 "で割った余り," $ $ g(n) = 3 f(sum_(k=1)^7 k^n) $ によって定める。 あなたの好きな自然数 $n$ を一つ決めて $g(n)$ を定めよ。その $g(n)$ の値をこの設問におけるあなたの得点とする。 ] ] #pagebreak() #assignment[ *(文字列)* 以下のプログラムを作成せよ。 #question(points: 2)[ ある文字列に対して、与えられた文字の数をカウントする関数を定義せよ。ただし大文字・小文字を区別せずカウントすること。 #sourcecode[ ```py def count(s: str, c: str) -> int: pass assert count("AaAa", "a") == 4 ``` ] ] #question(points: 4)[ ある文字列に対して、与えられた文字列の数をカウントする関数を定義せよ。 #sourcecode[ ```py def counts(s: str, c: str) -> int: pass assert counts("aaaa", "a") == 4 assert counts("aaa", "aa") == 2 assert counts("yayay", "yay") == 2 assert counts("111-111-111-111", "111-111") == 3 ``` ] ] #question(points: 1)[ 「よいしれうらなうなかよいあのこ」 を逆順にして文字列として表示せよ。 ] #question(points: 1)[ スライス記法を使って「パタトクカシーー」の先頭文字から1文字おきに文字列を取り出し、文字列として表示するプログラムを完成させよ。 ] #question(points: 2)[ *(たぬき暗号)* たぬきの絵と一緒に `どたたうくしつのたなかた` という暗号が見つかった。このような暗号を解く関数 `solve_tanuki` を作れ。 #sourcecode[ ```py def solve_tanuki(s: str): pass ``` ] ] #question(points: 1)[ `"Hello"` と `"world"` を比較演算子で比較した時、どちらが大きな文字と判定されるか、なぜそうなるか説明せよ。 ] #question(points: 2)[ ある英文字列を大文字化&母音を削除するようなプログラムを書け。 #sourcecode[ ```py def upper_remove_vowels(s: str) -> str: pass assert upper_remove_vowels("FM Yokohama") == "FM YKHM" ``` ] ] #question(points: 3)[ ある文字列が回文か判定するプログラムを書け。 #sourcecode[ ```py def is_palindrome(s: str) -> bool: pass assert is_palindrome("madamimadam") == True assert is_palindrome("madammadam") == True assert is_palindrome("abcd") == False assert is_palindrome("") == True assert is_palindrome("a") == True ``` ] ] #question(points: 3)[ ある単語がイソグラム(#link("https://en.wiktionary.org/wiki/isogram")[isogram])か判定するプログラムを書け。イソグラムとは、単語中の各アルファベットが1回だけ出現する単語を指す。 #sourcecode[ ```py def isogram(s: str) -> bool: pass assert is_isogram("isogram") == True assert is_isogram("computer") == True assert is_isogram("algorithm") == True assert is_isogram("six-years-old") == True assert is_isogram("aadvark") == False ``` ] ] #question(points: 4)[ ある単語が#link("https://ja.wikipedia.org/wiki/%E3%83%91%E3%83%B3%E3%82%B0%E3%83%A9%E3%83%A0")[パングラム(pangram)] か判定するプログラムを書け。 パングラムとは、すべてのアルファベットが使われている文字である(アルファベットの使用回数は問わない)。 #sourcecode[ ```py def is_pangram(s: str) -> bool: pass assert is_pangram("The quick brown fox jumps over the lazy dog.") == True assert is_pangram("Jackdaws love my big sphinx of quartz.") == True ``` ] ] #question(points: 5)[ *(ISBN検証: ITパスポートH24春期 中間Dに類題あり)* 書籍の識別番号である ISBN-10 についてその正当性を検証するプログラムを書け。 *説明: * ISBN-10はハイフンで区切られた9桁の数字と1桁のチェック数字から構成される。チェック数字は 0~9の数字または `X` の場合があり、`X` は 10 を表す。ハイフンはある場合もあるし、ない場合もある。 チェックディジットの正しさは以下の式で検証される(modは左の式を右で割ったときの余りとなる)。 ``` (d₁ * 10 + d₂ * 9 + d₃ * 8 + d₄ * 7 + d₅ * 6 + d₆ * 5 + d₇ * 4 + d₈ * 3 + d₉ * 2 + d₁₀ * 1) mod 11 == 0 ``` 結果が真であれば正しいISBN-10コードであり、そうでなければ無効なISBNである。 例として `3-598-21508-8`を取り上げる。これは以下の通り計算される。 ``` (3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 == 0 ``` 結果が真であるためこれは正しいISBN-10コードである。 #sourcecode[ ```py def is_isbn10(s: str) -> bool: pass assert is_isbn10("3-598-21508-8") == True ``` ] - 参考:#link("https://note.com/fukuidharu/n/nca0390441108")[ おなじ本?ちがう本?:図書館における「書誌の同定」というお仕事 ] ] #question(points: 5)[ ある文字列が回文か判定するプログラムを書け。ただし、自然な英文が回文と判定されるよう注意せよ。考慮としては以下のassertが通る程度でよい。 #sourcecode[ ```py def is_palindrome(s: str) -> bool: pass assert is_palindrome("madamimadam") == True assert is_palindrome("madammadam") == True assert is_palindrome("Madam, I'm Adam.") == True assert is_palindrome("abcd") == False assert is_palindrome("") == True assert is_palindrome("a") == True ``` ] ] #question(points: 2)[ 改行文字 `\n` で区切られた文字列について、`\n`を削除して半角スペースで結合する関数を書け。 #sourcecode[ ```py def split_join(s: str) -> str: pass assert split_join("Hello\nWorld\nPython") == "Hello World Python" ``` ] ] #question(points: 3)[ 文字列が整数かそうでないかを判定せよ。 #sourcecode[ ```py def is_integer(s: str) -> bool: pass assert is_integer("123") == True assert is_integer("-123") == True assert is_integer("-123e4") == False assert is_integer("-123.4") == False assert is_integer("0") == True assert is_integer("-0") == True assert is_integer("") == False ``` ] ] #question(points: 3)[ *(言語処理100本ノックより)* 以下の文字列`Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.` について、単語に分解し、各単語のアルファベットの文字数を出現順に並べたリストを出力せよ。 ] #question(points: 5)[ *(IPアドレスの検証)* IPアドレスは `192.168.0.1` のような ドット `.` で区切られた4つの数字で構成されている。各数字の値は `0` から `255` の範囲である必要がある。文字列がIPアドレスであるか否か判定するプログラムを書け。 #sourcecode[ ```py def is_valid_ip(s: str) -> bool: pass assert is_valid_ip("192.168.0.1") == True assert is_valid_ip("256.0.0.0") == False assert is_valid_ip("192.168.1") == False ``` ] ] #question(points: 5)[ *(HTMLタグの除去)* HTML文書の本文からタグを取り除いて出力する関数を作成せよ。正規表現を使う場合は適宜調べよ。 #sourcecode[ ```py def remove_html_tags(html_str): pass html_doc = """ <html> <head> <title>HTML リムーバー</title> </head> <body> <h1>はじめに</h1> <p>この文書は <a href="https://example.com">HTML</a> タグの取り除き方について説明しています。</p> <p>さまざまな方法がありますが、Pythonの<b>正規表現</b>を用いると比較的簡単に実装できます。</p> </body> </html> """ assert remove_html_tags(html_doc) == "はじめに\nこの文書は HTMLタグの取り除き方について説明しています。\nさまざまな方法がありますが、Pythonの正規表現を用いると比較的簡単に実装できます。" ``` ] ] #question(points: 3)[ *(パスワード検証)* パスワード文字列の書式を検証するプログラムを書け。書式の要件は以下の通りである。 - 長さ8文字以上 - 英大文字、英小文字、数字、記号(`!@#$%^&*()_+`)を各1文字以上含むこと #sourcecode[ ```py def is_valid_password(s: str) -> bool: pass assert is_valid_password("<PASSWORD>!@") == True assert is_valid_password("<PASSWORD>!@") == False assert is_valid_password("abcdefgh") == False assert is_valid_password("<PASSWORD>") == False ``` ] ] #question(points: 3)[ 小文字を大文字に変換するプログラムを書け。ただし組み込みの `upper` メソッドは使わず、`ord`, `chr`を使って書け。適宜ASCIIコード表を参照せよ。 #sourcecode[ ```py def upper(s: str) -> str: pass assert upper("Hello, World") == "HELLO, WORLD" ``` ] ] #question(points: 4)[ *(シーザー暗号)* シーザー暗号とは、アルファベットを `N` 文字ずらした文字に置き換えることで平文を暗号化する、簡単な暗号化手法である。特に13文字ずらしたものをROT13と呼び、アルファベットが26文字であることから 2回 ROT13 をかけると元に戻る性質を持つ。 例えば `"ABC"` にROT13をかけると `"NOP"`となる。`rot13` 関数を実装せよ。 #sourcecode[ ```py def rot13(s: str) -> str: pass assert rot13("Hello, World") == "Uryyb, Jbeyq" assert rot13("Uryyb, Jbeyq") == "Hello, World" ``` ] ] #question(points: 6)[ 九九の表を表示せよ。表が崩れないよう文字幅に注意せよ。 ] #question(points: 7)[ 今年のカレンダーを表示せよ。表が崩れないよう文字幅に注意せよ。 ] #question(points: 7)[ *(メールアドレスの検証)* メールアドレスが正しい書式か判定するプログラムを書け。ただし検証するのは以下の簡略化した条件とする。 メールアドレスは `username@hostname` という書式をしている。 `username` をローカル部、`hostname`をドメイン部と呼ぶ。 - ローカル部 - 英数字、アンダースコア `_`、ピリオド `.` のみを使用可能 - 1文字目は英字のみを使える - 末尾にピリオドは使えない - ピリオドは連続できない - ドメイン部 - 英数字、ハイフン `-`、ピリオド `.` のみを使用可能 - 1文字目は英字のみを使える - 末尾にピリオドは使えない - ピリオドは連続できない - ローカル部とドメイン部以外は存在しない #sourcecode[ ```py def is_valid_email(address: str) -> bool: pass assert is_valid_email("<EMAIL>") == True assert is_valid_email("<EMAIL>") == True assert is_valid_email("<EMAIL>") == False assert is_valid_email("<EMAIL>") == False assert is_valid_email("<EMAIL>") == False assert is_valid_email("_<EMAIL>") == False assert is_valid_email("<EMAIL>") == True assert is_valid_email("<EMAIL>") == False assert is_valid_email("<EMAIL>.") == False assert is_valid_email("<EMAIL>") == False assert is_valid_email("<EMAIL>") == False ``` ] ] ] #pagebreak() #assignment[ *(リスト)* 以下のプログラムを作成せよ。 #question(points: 1)[ 整数のリストについて、各要素を2乗する関数を作成せよ。 #sourcecode[ ```py def square(ls: list[int]) -> list[int]: pass assert square([1,2,3,4]) == [1,4,9,16] ``` ] ] #question(points: 1)[ 整数のリストについて、偶数のリストのみ抽出する関数を作成せよ。 #sourcecode[ ```py def filter_even(ls: list[int]) -> list[int]: pass assert filter_even([1,2,3,4]) == [2,4] ``` ] ] #question(points: 2)[ 2つのリストについて、要素を交互に含む新しいリストを作成する関数を作成せよ。 #sourcecode[ ```py def interleave(xs: list, ys: list) -> list: pass assert interleave([1,3,5], [2,4,6]) == [1,2,3,4,5,6] ``` ] ] #question(points: 2)[ リストの各要素に指定した要素を挿入するプログラムを作れ。 #sourcecode[ ```py def intersperse(e, xs: list) -> list: pass assert intersperse(',', ["a", "b", "c"]) == ["a", ",", "b", ",", "c"] ``` ] ] #question(points: 2)[ リストの各要素に指定した要素を挿入したのち、文字列結合するプログラムを作れ。 #sourcecode[ ```py def intercalate(e, xs: list) -> list: pass assert intercalate(',', ["a", "b", "c"]) == "a,b,c" ``` ] ] #question(points: 3)[ リストのリストを転置するプログラムを作れ。 #sourcecode[ ```py def transpose(xs: list[list]) -> list[list]: pass assert transpose([[1,2,3], [4,5,6]]) == [[1,4],[2,5],[3,6]] ``` ] ] #question(points: 4)[ リストの各要素に関数を適用する関数を作れ。必要であれば `map` について調べよ。 #sourcecode[ ```py def my_map(f, xs: list) -> list: pass def square(x: int) -> int: return x * x assert my_map(square, [1,2,3,4]) == [1,4,9,16] ``` ] ] #question(points: 4)[ リストの各要素を条件に基づいてフィルタする関数を作れ。必要であれば `filter` について調べよ。 #sourcecode[ ```py def my_filter(f, xs: list) -> list: pass def even(x: int) -> bool: return x % 2 == 0 assert my_filter(even, [1,2,3,4]) == [2,4] ``` ] ] #question(points: 4)[ リストを条件に基づいて分割する関数を作れ。 #sourcecode[ ```py def partition(f, xs: list) -> (list, list): pass def even(x: int) -> bool: return x % 2 == 0 assert partition(even, [1,2,3,4]) == ([2,4], [1,3]) ``` ] ] #question(points: 2)[ リストの長さを返す関数を実装せよ。ただし `len()` は使うな。 #sourcecode[ ```py def length(xs: list) -> int: pass assert length([]) == 0 assert length([1,2,3]) == 3 ``` ] ] #question(points: 2)[ リストを逆順にする関数を実装せよ。ただし `.reverse()`, `reversed()` あるいはスライスの逆順記法は使うな。 #sourcecode[ ```py def reverse(xs: list) -> str: pass assert reverse([]) == [] assert reverse([1,2,3]) == [3,2,1] ``` ] ] #question(points: 2)[ 英語の文章について、単語の順序を逆順にした文字列を返す関数を作れ。句読点は考慮しなくてよい。 #sourcecode[ ```py def reverse_words(text: str) -> str: pass assert reverse_words("The quick brown fox") == 'fox brown quick The' ``` ] ] #question(points: 2)[ 英語の文章について、各単語を逆にした文字列を返す関数を作れ。句読点は考慮しなくてよい。 #sourcecode[ ```py def reverse_each_words(text: str) -> str: pass assert reverse_each_words("The quick brown fox") == 'ehT kciuq nworb xof' ``` ] ] #question(points: 3)[ 2つのリストの共通リストを返すプログラムを作れ。 #sourcecode[ ```py def intersection(xs: list, ys: list) -> list: pass assert intersection(["Good", "morning", "everyone"], ["Good", "evening", "everyone", "!"]) == ["Good", "everyone"] ``` ] ] #question(points: 3)[ リストの連続かつ重複した要素を1つにしたリストを返せ。 #sourcecode[ ```py def uniq_consecutive(xs: list) -> list: pass assert uniq_consecutive(['a','b','b','a','c','c','c']) == ['a','b','a','c'] ``` ] ] #question(points: 3)[ リストの連続かつ重複した要素をサブリストとしたリストを返せ。 #sourcecode[ ```py def pack(xs: list) -> list[list]: pass assert pack(['a','b','b','a','c','c','c']) == [['a'],['b', 'b'],['a'],['c','c','c']] ``` ] ] #question(points: 5)[ *(ランレングス圧縮)* リストをランレングス圧縮(run-length encoding)せよ。リストのランレングス圧縮とは、リストの連続かつ重複した要素 $E$ とその要素数 $N$ をタプル$(N, E)$で表現したリストである 。必要であれば前問の結果を使ってよい。 #sourcecode[ ```py def encode_run_length(xs: list) -> list[(int, Any)]: pass assert encode_run_length(['a','b','b','a','c','c','c']) == [(1,'a'), (2, 'b'), (1, 'a'), (3, 'c')] ``` ] ] #question(points: 3)[ *(ランレングス圧縮の解凍)* 前問からの続きで、ランレングス圧縮したデータを解凍(decode)せよ #sourcecode[ ```py def decode_run_length(xs: list[(int, Any)]) -> list: pass assert decode_run_length(encode_run_length(['a','b','b','a','c','c','c'])) == ['a','b','b','a','c','c','c'] ``` ] ] #question(points: 2)[ リストの各要素を重複させたリストを作れ。 #sourcecode[ ```py def duplicate(xs: list) -> list: pass assert duplicate([1,2,3]) == [1,1,2,2,3,3] ``` ] ] #question(points: 2)[ リストの各要素を `n` 回重複させたリストを作れ。 #sourcecode[ ```py def duplicate_n(xs: list, n: int) -> list: pass assert duplicate([1,2,3], 2) == [1,1,2,2,3,3] assert duplicate([1,2,3], 3) == [1,1,1,2,2,2,3,3,3] ``` ] ] #question(points: 4)[ リストの各要素をグループ化する関数を作れ。 #sourcecode[ ```py def group(xs: list) -> list[list]: pass assert group([1,1,2,2,3,3]) == [[1,1], [2,2], [3,3]] ``` ] ] #question(points: 4)[ 文字列を区切り文字で分割したリストにする関数を作れ。 #sourcecode[ ```py def split(s: str, text: str) -> list: pass assert split(',', "Hello,World") == ["Hello", "World"] ``` ] ] #question(points: 5)[ リストの順列を作る関数を作れ。必要であれば `itertools.permutation` を参考にしてよいが、実装にこの関数を使うな。 #sourcecode[ ```py def permutation(xs: list) -> list: pass assert sorted(permutation(["a", "b", "c"])) == sorted([('a', 'b', 'c'), ('a', 'c', 'b'), ('b', 'a', 'c'), ('b', 'c', 'a'), ('c', 'a', 'b'), ('c', 'b', 'a')]) ``` ] ] #question(points: 5)[ リストの組み合わせを列挙する関数を作れ。ここでリストの組み合わせ(combination)とは $N$ 個の要素を持つリストから $K$ 個選んだ場合の組み合わせを重複なしで列挙するものである。必要であれば `itertools.combination` を参考にしてよいが、実装にこの関数を使うな。 #sourcecode[ ```py def combination(xs: list, k: list) -> list: pass assert list(combinations(['a','b','c'], 2)) == [('a', 'b'), ('a', 'c'), ('b', 'c')] ``` ] ] #question(points: 4)[ 整数 $0, 1, 2, 3, 4, 5$ から異なる4つの数字を選んで4桁の整数を作る。2400より大きくなる数字を列挙せよ。 ] #question(points: 6)[ *(4つの4)* 4つの$4$と四則演算を用いて$10$を作れ。計算式を出力せよ。この問題については以下を参照せよ。 - #link("https://ja.wikipedia.org/wiki/4%E3%81%A4%E3%81%AE4")[4つの4 - Wikipedia] ] #question(points: 2)[ リストをスライスする関数を作れ。スライスは2つの添字 $I$ と $K$ を指定して行われる。$I$ はスライスを開始する添字、$K$ は自身を含まないスライス終端の添字である。 #sourcecode[ ```py def slice(i: int, k: int, xs: list) -> list: pass assert slice(2, 5, [1,2,3,4,5,6]) == [3,4,5] ``` ] ] #question(points: 2)[ リストを指定した数の要素だけ回転させる関数を作れ。 #sourcecode[ ```py def rotate(n: int, xs: list) -> list: pass # 左側に回転 assert rotate(3, ['a', 'b', 'c', 'd', 'e', 'f', 'g']) == ['d', 'e', 'f', 'g', 'a', 'b', 'c'] # 右側に回転 assert rotate(-3, ['a', 'b', 'c', 'd', 'e', 'f', 'g']) == ['e', 'f', 'g', 'a', 'b', 'c', 'd'] ``` ] ] #question(points: 2)[ リストの指定した位置に指定した要素を挿入するプログラムを書け。 #sourcecode[ ```py def insert(elem, n: int, xs: list) -> list: pass assert insert('b', 1, ['a', 'c', 'd']) == ['a', 'b', 'c', 'd'] ``` ] ] #question(points: 2)[ 指定した範囲に含まれる整数のリストを返す関数を書け。ただし終端の数は含まない。 #sourcecode[ ```py def my_range(start: int, end: int) -> list[int]: pass assert my_range(2, 10) == [2,3,4,5,6,7,8,9] ``` ] ] #question(points: 2)[ 指定された要素数でゼロ埋めされたリストを返す関数を書け。 #sourcecode[ ```py def zeros(n: int) -> list[int]: pass assert zeros(5) == [0, 0, 0, 0, 0] ``` ] ] #question(points: 2)[ 指定された要素数$n,m$でゼロ埋めされた二次元リストを返す関数を書け。 #sourcecode[ ```py def zeros(n: int, m: int) -> list[list[int]]: pass assert zeros(3, 2) == [[0, 0], [0, 0], [0, 0]] ``` ] 一般の次元に拡張された関数については `numpy.zeros` を参考にせよ。 ] #question(points: 2)[ 指定された要素数$n,m$で1埋めされた二次元リストを返す関数を書け。 #sourcecode[ ```py def ones(n: int, m: int) -> list[list[int]]: pass assert ones(3, 2) == [[1, 1], [1, 1], [1, 1]] ``` ] 一般の次元に拡張された関数については `numpy.ones` を参考にせよ。 ] #question(points: 2)[ 指定された要素数$n,m$の二次元リストを返す関数を書け。ただし各要素について0または1のランダムな値をセットせよ。必要であれば`random`モジュールについて調べよ。余裕があればこの関数をテストする方法を考えてみよ。 #sourcecode[ ```py def rand_field(n: int, m: int) -> list[list[int]]: pass ``` ] ] #question(points: 2)[ 前問の `rand_field` で生成した2次元リストについて、要素が`1`なら`#`、`0`なら`.`を描画するプログラムを書け。各行の描画が終わったら改行するようにせよ。 #sourcecode[ ```py def print_field(ls: list[list]): pass ``` ] ] #question(points: 7)[ *(ライフゲーム)* 前問からの続きで、生成した2次元リスト $L$ の各要素について、以下の条件で値を更新する関数を作成せよ。 - 2次元リスト $L$ の*要素* $L(x,y)$ について($x$, $y$は要素の添字)、$L(x+d x, y+d y)$ を*隣接セル*と呼ぶ。ここで $(d x, d y) in {(1, 1),(1, 0),(1,-1),(0, 1), (0, -1), (-1, 1), (-1, 0), (-1, -1)}$ - 要素の値が $1$ の時 *生存*、$0$ の時 *死* と呼ぶ。 - 要素 $L(x, y)$ が死で隣接セルの値が3つ生存している場合、要素を生存に更新する(*誕生*)。 - 要素 $L(x, y)$ が生存で隣接セルが2つないし3つ生存している場合、要素は生存のままとする(*維持*)。 - 要素 $L(x, y)$ が生存で隣接セルが1以下ないし4つ以上生存の場合、要素は死に更新する(*過疎*および*過剰*による死)。 #sourcecode[ ```py def tick_field(ls: list[list]) -> list[list]: pass ``` ] 完成したら、`sleep` 関数などを参考に、ある程度の大きさのフィールドを作り、更新を繰り返しながら適当な時間間隔で表示してみよ。 #link("https://www.mext.go.jp/content/000166207.pdf")[ この問題の出題意図についてはリンク先(【実践事例】情報I(3) P.83-90)を参照せよ。 ] ] ] #pagebreak() #assignment[ *(実践問題)以下の問題を解け。必要に応じて `dict`, `set`, 正規表現について調べよ。* #question(points: 2)[ 以下のリンクを開き、ページを保存せよ。 https://raw.githubusercontent.com/dolph/dictionary/master/enable1.txt これは英単語が1行1語で辞書順に格納されたファイルである。このファイルの単語数をカウントするプログラムを書け。必要であれば `open`, `close`, `readlines` について調べよ。 以降の問題は下記リンクの問題を参考にしている。 #link("https://www.reddit.com/r/dailyprogrammer/comments/onfehl/20210719_challenge_399_easy_letter_value_sum/")[ [2021-07-19] Challenge #399 [Easy] Letter value sum ] ] #question(points: 2)[ 文字数20以上の単語はいくつあるか。それはどのような単語か。 ] #question(points: 2)[ 辞書中で最も長い単語は何か。 ] #question(points: 3)[ 各単語を頭文字が同じものにグループ化したとき、各頭文字ごとの単語数を表示せよ。 ] #question(points: 4)[ 辞書からアナグラムを探して表示せよ。アナグラムとは `debit`, `bited` のように並び替えると同じになる単語である。 ] #question(points: 3)[ 単語のスコアを以下のように定義する。 - 単語の点数は、各文字の点数の総和になる。 - 各文字の点数は、`a` は1点から `z` は26点までアルファベット順に増加する。 単語のスコアを計算するプログラムを作れ。 #sourcecode[ ```py def lettersum(s: str) -> int: pass assert lettersum("") == 0 assert lettersum("a") == 1 assert lettersum("z") == 26 assert lettersum("cab") == 6 assert lettersum("excellent") == 100 assert lettersum("microspectrophotometries") == 317 ``` ] ] #question(points: 3)[ 辞書から最大のスコアを持つ単語を探せ。 ] #question(points: 3)[ スコアが偶数となる単語はいくつあるか? ] #question(points: 4)[ スコアが100になる単語は1921存在する。100の次に単語の存在頻度が多いものは何か。 ] #question(points: 6)[ `cytotoxicity` と `unreservedness` は同じスコア 188 を持つが、互いに共通する文字を持たない。このような単語は他にあるか調べ、存在するなら挙げてみよ。 ] #question(points: 2)[ 30人のクラスで誕生日が同じクラスメートが存在する確率を計算せよ。ここで1年は365日としてよい。 ] #question(points: 2)[ 前問についてシミュレーションを行い、実際に誕生日が衝突する様子を確認してみよ。 `random` モジュールについて調べよ。 ] #question(points: 4)[ じゃんけんを行うプログラムを作ってみよ。 ] #question(points: 7)[ ビデオゲーム上での戦闘をシミュレーションするプログラムを作成する。 戦闘は以下の条件で推移するものとする。キャラクターシートと行動パターンの表を参照しつつ、どちらが勝ったか出力するプログラムを作成せよ。 - 自分と敵が交互に行動する - 自分と敵双方の行動が完了したことをターンが経過したといい、1ターン加算する - ターンは1から起算する - 各キャラクターは行動パターンの行動を条件に従い行う。orで書かれた行動は均等な確率でいずれかが実行される - すばやさの高いキャラクターが先に行動する - 敵のHPを0にすれば勝ち、自分のHPが0になれば負け - 自分を「ゆうしゃ」、敵を「りゅうおう」とする - ゆうしゃはステータスに装備の値を加算する - りゅうおうは$n+4$ターン目で$n$ターン目の行動を繰り返す #figure( caption: "キャラクターシート", table( columns: (auto, auto, auto, auto), align: left, table.header( [名前], [ステータス], [そうび],[行動パターン] ), "ゆうしゃ", [ HP: 210 \ MP: 190 \ こうげき: 140 \ すばやさ: 130 \ しゅび: 60 ], [ ロトのつるぎ: こうげき+40 \ ロトのよろい: しゅび+28 \ みかがみのたて: しゅび+20 \ りゅうのうろこ: しゅび+5 ], [ たたかう \ ベホイミ(HP50%未満時) ] , "りゅうおう", [ HP: 350 \ こうげき: 150 \ すばやさ: 90 \ しゅび: 150 ], "なし", [ 1ターン: はげしいほのお \ 2ターン: こうげき \ 3ターン: ひのいき or かえんのいき \ 4ターン: こうげき or ひのいき \ ] ), ) 各行動パターンとその効果は以下の通り。 #figure( caption: "行動パターン", table( columns: (auto, auto), align: left, table.header( [行動パターン], [効果] ), "たたかう", [ 自分がたたかう際は以下の点数を敵HPから減算する \ `(乱数 * (こうげき - (敵しゅび/2) + 1)/256 + こうげき - 敵しゅび/2)/4` \ ここで乱数は0~255の値である。 敵がたたかう際は以下の点数を自分のHPから減算する \ `(乱数 * (敵こうげき - しゅび/2 + 1)/256 + 敵こうげき - しゅび/2)/4` \ ], "ベホイミ", [ 自分のMP8点を減算し自分の現在HPに85~100点加算する。\ 加算されたHPはHPの初期値を超えることはない。 \ MPが8以上残っていない場合は使用せず他の行動を取る。 ], "はげしいほのお", [ 敵使用時、自分のHPから48~54点を減算する。 ], "かえんのいき", [ 敵使用時、自分のHPから12~16点を減算する。 ], "ひのいき", [ 敵使用時、自分のHPから9~15点を減算する。 ] ) ) ] #question(points: 7)[ 前問について、さらなるシミュレーション機能を提案し追加せよ。以下のような仕様案を参考にしてもよい。 - 行動のバリエーションを追加する - そうびのバリエーションや機能を追加する - アイテムという概念を導入する - 一定の確率で大ダメージを与える - 一定の確率で回避・ミスする - 味方を複数にする - 敵を複数にする - 行動順にも乱数による幅を持たせる ] #question(points: 5)[ *(HQ9+)* 難解プログラミング言語HQ9+を実装せよ。HQ9+の仕様は以下の通り。 - HQ9+は4つの命令 $"H,Q,9,+"$から構成される。 - $"H"$ コマンドは`Hello, world`を表示する。 - $"Q"$ コマンドは実行しているプログラム自身を表示する(Quine) - $"9"$ コマンドは #link("https://dic.nicovideo.jp/a/99%20bottles%20of%20beer")[『99 Bottles of Beer』の歌詞]を出力する。 - $"+"$ コマンドはアキュムレータをインクリメントする ] #question(points: 7)[ *(Brainfuck)* 難解プログラミング言語 #link("https://ja.wikipedia.org/wiki/Brainfuck")[Brainfuck] を実装せよ。Brainfuckの仕様は以下の通り。 Brainfuck処理系はインストラクションポインタ、配列(30000要素以上)、前記の配列を指すデータポインタ、入出力からなる。また命令語は以下の8つであり、以下ポインタとはデータポインタのことを指す。 - `>` ポインタをインクリメントする - `<` ポインタをデクリメントする - `+` ポインタが指す値をインクリメントする - `-` ポインタが指す値をデクリメントする - `-` ポインタが指す値をデクリメントする - `.` ポインタが指す値を出力する - `,` 入力から1バイト読み込み、ポインタが指す先に代入する - `[` ポインタが指す値が0なら対応する `]` の直後にジャンプする。 - `]` ポインタが指す値が0でないなら対応する `[` の直後にジャンプする。 #sourcecode[ ```py def bf(program: str): pass bf("++++++++++[>+++++++>++++++++++>+++++++++++>+++>+++++++++>+<<<<<<-]>++.>+.>--..+++.>++.>---.<<.+++.------.<-.>>+.>>.") # Hello World! と出力される(らしい) ``` ] ] ] #pagebreak() #assignment[ 以下のテーマについて自分なりに説明せよ。 #question(points: 4)[ 変数とは何か? ] #question(points: 4)[ 関数とは何か? ] #question(points: 4)[ 順次、分岐、反復とは何か? ] #question(points: 4)[ データ型とは何か? ] \ *(ストラウストラップのプログラミング入門より)* 以下に挙げたテーマから少なくとも1つを選んで議論せよ(800文字以上1200文字以下)。根拠に基づいて議論すること。 #question(points: 10)[ ソフトウェアとは何か。ソフトウェアはなぜ重要なのか。 ] #question(points: 10)[ 計算機科学(コンピュータサイエンス)とプログラミングの違いはなにか。何が重要なのか。 ] #question(points: 10)[ ソフトウェアが正常に動作しない場合、どのような問題が起きるか。具体例を挙げること。 ] #question(points: 10)[ ソフトウェア開発が困難になる理由はなにか。 ] \ *(ストラウストラップのプログラミング入門より)* 以下に挙げたテーマから少なくとも1つを選んで議論せよ。文字数は問わないが端的かつ必要十分な議論をすること。また、根拠に基づいて意見を述べること。 #question(points: 10)[ 自分が何らかの知識を持っている職業について、その仕事にソフトウェアがどのように関わっているかを分析してみよ。 ] #question(points: 10)[ 優れたプログラマないしエンジニアに共通する特性を議論せよ。 ] #question(points: 10)[ 自分が関心のあるソフトウェアを複数挙げ、その中で自分が将来関わりたいものを選び、なぜ選んだか理由を述べよ。 ] #question(points: 10)[ 人間が行う活動のうち、いかなる形(間接的に)でもコンピュータが関わらない活動を挙げよ。根拠を述べること。 ] \ *(令和5年度 技術士第二次試験(情報工学部門)改題)* 生成AIの技術レベルが著しく向上し、用途も広がっている一方で、その利活用・普及に伴う社会的課題も顕在化してきている。このような状況を踏まえ、生成AIを活用する具体的なサービスを想定し、その構築や運用を行う立場で以下の問いに答えよ。 #question(points: 10)[ 技術者としての立場で多面的な観点から3つの課題を抽出し、それぞれの観点を明記した上で、その課題の内容を示せ。課題を表す用語としては以下を参考にせよ。 幻覚(ハルシネーション)、差別(バイアス)、プライバシー、環境問題(計算コスト)、データ汚染、悪用。 ] #question(points: 10)[ 前問で抽出した課題のうち最も重要と考える課題を1つ挙げ、その課題に対する解決策を、情報工学の専門技術用語を交えて示せ。 ] #question(points: 10)[ 前問で示した解決策を実施するに当たり生じる波及効果と専門技術を踏まえた懸案事項への対応策を示せ。 ] #question(points: 10)[ 上記の業務遂行に当たり、技術者としての倫理・社会の持続可能性の観点から必要となる要件・留意点を題意に即して述べよ。 ] ] #pagebreak() #point-table #h(1fr) #point-sum-box
https://github.com/we-data-ch/shiny_tpg_project
https://raw.githubusercontent.com/we-data-ch/shiny_tpg_project/master/_extensions/quarto-ext/ams/typst-show.typ
typst
#show: ams-article.with( $if(title)$ title: "$title$", $endif$ $if(by-author)$ authors: ( $for(by-author)$ ( name: "$it.name.literal$", email: "$it.email$", url: "$it.url$", $for(it.affiliations/first)$department: [$it.department$], organization: [$it.name$], location: [$it.city$, $it.region$ $it.postal-code$], $endfor$ )$sep$, $endfor$, ), $endif$ $if(abstract)$ abstract: [$abstract$], $endif$ $if(bibliography)$ bibliography-file: "$bibliography$", $endif$ )
https://github.com/nath-roset/suiviProjetHekzamGUI
https://raw.githubusercontent.com/nath-roset/suiviProjetHekzamGUI/master/typ%20sources/Cahier_des_charges.typ
typst
Apache License 2.0
#import "template.typ": base #show: doc => base( // left_header:[], right_header : [Equipe scan-GUI-Printemps-2024], title: [Projet Hekzam-GUI], subtitle: [Cahier des charges], version: [1.1], doc ) //TODO : make it so requirement list numbering keeps incrementing properly past other headings //can't query numbered lists (enums), currently a Typst limitation #set enum( numbering: ("EX_1.a :"), tight: false, full: true, spacing: 2em, ) #set list( tight: false, spacing: 1fr, indent: 5pt ) #outline( title: none, target : heading ) = Objectifs Le but du projet est de réaliser une interface graphique principale pour le logiciel Hekzam, dont l'objectif est d'évaluer automatiquement des copies d'examens afin d'en extraire des informations statistiques. Les utilisateurs ciblés font partie du personnel de l'université (enseignants, secrétaires). = Definitions : (*HYPOTHÈSES DE DÉBUT DE PROJET*) - *projet* : représente un répertoire regroupant tous les fichiers relatifs à la l'évaluations des copies - *sujet* : fichier pdf obtenu en compilant un fichier source avec Typst, peut comprendre plusieurs pages - *programme* : Logiciel Hekzam complet#link("https://github.com/hekzam")[(GUI + parser + generator)], supposé fonctionnel - *pages*: image extraite d'un fichier pdf; scan d'une page associé à une page d'un sujet - *copie*: ensemble de pages regroupées, l'ensemble formant une copie d'examen associée à un étudiant #pagebreak() = Capture du besoin == Exigences non-fonctionnelles - Le programme doit être performant et léger - Le programme doit être développé de manière maintenable // - #strike[Le programme doit proposer des fonctions unitaire] // ne pas modifier autre chose que les paramètres - Le programme doit proposer une documentation utilisateur devra être robuste, mais minimale et simple - Le programme doit être développé dans un des langages mentionnés Qt C++, GTK Rust // - #strike[Le programme ne doit pas utiliser de templates (méta-programmation)] // pas une obligation - Le programme doit proposer une interface simple pour tout utilisateur (informaticien on non) - Le programme doit être open source sous licence APACHE2 - Les tests du programme doivent être effectués en même temps que le développement - Le projet utilisera le système de Version contrôle Git - Fournir un fichier README - Faire des commits de moins de 50 caractères à l'impératif - Un compte rendu sera fait à chaque réunion avec l'encadrant - Les fonctionnalités (features) devront être séparées sous différentes branches dans GitHub == Exigence fonctionnelles // mieux sous forme de schéma ? // #show figure: set block(breakable: true) #figure( image("Exigences_rev1_f1.svg" ), ) #figure( image("Exigences_rev1_f2.svg" ), ) #figure( image("Exigences_rev1_f3.svg" ), ) // === Création du sujet // - L'utilisateur doit pouvoir accéder aux autres fonctionnalités du programme après avoir satisfait l'une de ces pré-conditions // - L'utilisateur doit pouvoir *ouvrir* un "projet" localisé dans un dossier // - L'utilisateur doit pouvoir *créer* un projet en sélectionnant un fichier source // === Import des copies scannées // #set enum(start: 6) //why do I have to do this // - L'utilisateur devrait pouvoir importer tout ou partie des items suivants: // - un *fichier de scans de copies* au format pdf // - des scans de copies au format jpeg // === Identification des pages en copies // #set enum(start: 9) // - L'utilisateur devrait pouvoir importer une "*feuille de présence*" ( liste de copies attendues) qui devrait être analysable par le programme *ou* garder les copies anonymes. // - L'interface devra remonter si certaines copies manquent en fonction du nombre d'entrées présentes sur la feuille de présence // === Analyse de la copie // #set enum(start: 12) // - L'interface devra indiquer à l'utilisateur la qualité des scans grâce à des indicateur numériques (RMSE, taux de certitude...) // - L'interface devra porter à l'attention de l'utilisateur les erreurs : // - relatives à la qualité de la numérisation // - syntaxiques // - sémantiques // - Le programme devra porter à l'attention de l'utilisateur si certaines copies scannées sont *illisibles* par le parser, ou se trouve en deçà d'un *seuil d'acceptabilité* // === Correction des copies // #set enum(start: 16) // - Le programme devrait retourner *en sortie* des fichiers (*json?*) pour *visualiser les données* // - le programme devrait laisser la possibilité à l’utilisateur de *modifier la correction* de chaque copie si besoin // - L'interface devra indiquer si *l'utilisateur a modifié une valeur*, telle que réponse à une question ou numéro étudiant... // - L'interface doit afficher chaque question présente sur chaque copie individuellement // === Déroulement du programme // #set enum(start: 23) // - on doit pouvoir sauvegarder le projet et exporter le fichier de sortie // - Le programme devra avoir une interface navigable au clavier = Rôles #figure( image("wbs-OBS.svg", width: 100%), // caption: [ // #grid(columns: 2, // stroke: (x, y) => if x == 0 and y == 0 { // (right: ( // paint: luma(50), // thickness: 1.5pt, // dash: "dotted" // )) // },)[ // - <NAME>, <NAME> : // rédactions des spécifications et cas de tests, briques de codes // ][ // - <NAME>, REGRAGUI <NAME> : // chargés prototypages et documentation // ] // ] ) = Délivrables - Rapport de groupe - Cahier des charges - Code prototype - Comptes rendu personnels - Dépôt GIT - Soutenance - Documentation utilisateur + Fichier README #figure( image("wbs-WBS.drawio.svg", format: "svg", ) ) = Echéancier #figure( image("SCANGUI.png", width: 100%) )
https://github.com/Jollywatt/typst-fletcher
https://raw.githubusercontent.com/Jollywatt/typst-fletcher/master/tests/edge-options/test.typ
typst
MIT License
#set page(width: auto, height: auto, margin: 1em) #import "/src/exports.typ" as fletcher: diagram, node, edge Explicit named arguments versus implicit positional arguments. Each row should be the same thing repeated. #let ab = node((0,0), $A$) + node((1,0), $B$) #grid( columns: (3cm,)*3, diagram(ab, edge((0,0), (1,0), marks: "->")), diagram(ab, edge((0,0), (1,0), "->")), diagram($A edge(->) & B$), diagram(ab, edge((0,0), (1,0), label: $pi$)), diagram(ab, edge((0,0), (1,0), $pi$)), diagram($A edge(pi) & B$), diagram(ab, edge((0,0), (1,0), marks: "|->", label: $tau$)), diagram(ab, edge((0,0), (1,0), "|->", $tau$)), diagram($A edge(tau, |->) & B$), diagram(ab, edge((0,0), (1,0), marks: "->>", label: $+$)), diagram(ab, edge((0,0), (1,0), "->>", $+$)), diagram($A edge(->>, +) & B$), ) #pagebreak() #diagram( axes: (ltr, btt), edge((0,0), (1,1), "->", "double", bend: 45deg), edge((1,0), (0,1), "->>", "crossing"), edge((1,1), (2,1), $f$, "|->"), edge((0,0), (1,0), "-", "dashed"), ) #pagebreak() Diagram and edge stroke options. $ #block(diagram( edge-stroke: red, edge(stroke: 2pt), )) &equiv #line(stroke: (paint: red, thickness: 2pt, cap: "round")) \ #block(diagram( edge-stroke: 2pt, edge(stroke: (cap: "butt")) )) &equiv #line(stroke: 2pt) \ #block(diagram( edge-stroke: 1pt + green, edge(dash: "dashed") )) &equiv #line(stroke: (paint: green, dash: "dashed", cap: "round")) \ #block(diagram( edge(stroke: none) )) &equiv & "(none)" $
https://github.com/alxsimon/quarto-pci
https://raw.githubusercontent.com/alxsimon/quarto-pci/main/README.md
markdown
# PCI Format ## Installing ```bash quarto use template alxsimon/typst-pci ``` This will install the format extension and create an example qmd file that you can use as a starting place for your document. ## To Do - [ ] Properly handle authors and affiliations - [ ] Wait for pandoc 3.1.12 to be integrated in quarto for the in-text citation to work - [ ] Follow development in typst to have line numbers - [ ] Simplify the front page for PCI template - [ ] Make two options PCI/PCJ for submission to PCI and upload to PCJ (PCJ should be simplified so that the automatic formatting can be applied) - [ ] Document how to use the template
https://github.com/ludwig-austermann/typst-funarray
https://raw.githubusercontent.com/ludwig-austermann/typst-funarray/main/CHANGELOG.md
markdown
MIT License
# v0.4.0 - added `accumulate`, `scan`, `unfold` and `iterated` # v0.3.0 - removed `intersperse` as it is now included by typst itself (see [here](https://typst.app/docs/reference/foundations/array/#definitions-intersperse)) - changed `unzip` to match changed [`zip` method](https://typst.app/docs/reference/foundations/array/#definitions-zip) behaviour. The new signature is `Vec<[T; N]> -> [Vec<T>; N]` - fixed type checks respecting [typst v0.8.0](https://typst.app/docs/changelog/#v0.8.0)
https://github.com/7sDream/fonts-and-layout-zhCN
https://raw.githubusercontent.com/7sDream/fonts-and-layout-zhCN/master/chapters/05-features/lookup.typ
typst
Other
#import "/template/template.typ": web-page-template #import "/template/components.typ": note #import "/lib/glossary.typ": tr #show: web-page-template // ## Features and lookups == 特性与#tr[lookup] // We've been putting our *rules* into a *feature*. Features are part of the way that we signal to the shaper which rules to apply in which circumstances. For example, the feature called `liga` is the "ligatures" features, and is always processed in the case of text in the Latin script unless the user specifically requests it to be turned off; there is another feature (`rlig`) for required ligatures, those which should always be applied even if the user doesn't want explicit ligatures. Some features are *always* processed as a fundamental part of the shaping process - particularly the case when dealing with scripts other than Latin - while others are optional and aesthetic. We will introduce different features, and what they're recommended to be used for, as we come across them, but you can also look up any unfamiliar features in the [OpenType Feature Registry](https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist) 目前的代码结构是规则包含在特性中。特性是我们用来告诉#tr[shaper]在某种特定情形下,需要使用哪些规则的一种组织结构。比如我们这里使用的`liga`其实是#tr[ligature](ligature)特性,这一特性在处理拉丁文本时会自动开启,除非用户明确指定才会关闭。还有另一个特性叫做`rlig`,表示必要(required)#tr[ligature]。这一特性即使用户明确指出不需要#tr[ligature]也仍然会被应用。像这样永远会被使用的特性被视为文本#tr[shaping]流程中(特别是处理拉丁以外的#tr[scripts]时)的基础步骤。除此之外的则是可选特性,它们主要服务于美学上的需求。我们会逐步向你介绍这些不同的特性以及它们各自推荐的使用场景。在遇到不熟悉的特性时,你也可以通过OpenType特性列表#[@Microsoft.OpenTypeRegistered]进行查询。 // We've only seen rules and features so far but it's important to know that there's another level involved too. Inside an OpenType font, rules are arranged into *lookups*, which are associated with features. Although the language we use to write OpenType code is called "feature language", the primary element of OpenType shaping is the *lookup*. So rules are grouped into sets called *lookups*, and lookups are placed into *features* based on what they're for. You might want to refine your typography in different ways at different times, and turning on or off different combinations of features allows you to do this. 现在我们只使用了特性和规则,但其中还隐含了另一个等级的重要组织结构。在OpenType字体中,规则首先被组织成*#tr[lookup]*,然后再与特性关联。虽然我们写代码的语言叫做特性语言,但OpenType进行文本#tr[shaping]时最主要的元素其实是#tr[lookup],它们按照自己的作用放置在相应的特性中。你可能希望字体的#tr[typography]效果能根据需求进行调整,通过开关不同的特性可以做到这一点。 // For instance, if you hit the "small caps" icon in your word processor, the word processor will ask the shaping engine to turn on the `smcp` feature. The shaping engine will run through the list of features in the font, and when it gets to the `smcp` feature, it will look at the lookups inside that feature, look at each rule within those lookups, and apply them in turn. These rules will turn the lower case letters into small caps: 比如你在 Word 中点击“小型大写字母”图标,Word 软件会让#tr[shaping]引擎打开字体的`smcp`特性。此时#tr[shaping]引擎就会遍历字体的特性列表,当他找到`smcp`特性时,会逐条查看其中的#tr[lookup],并对每个#tr[lookup]中的规则按顺序进行应用。@figure:feature-hierarchy 展现了将小写字母转换为小型大写字母流程。 #figure( caption: [启用`smcp`特性], )[#include "feature-hierarchy.typ"] <figure:feature-hierarchy> // **To really understand OpenType programming, you need to think in terms of lookups, not features**. *为了能够真正地理解OpenType编程,你需要站在#tr[lookup]的角度进行思考,而不是站在特性的角度。* // So far our lookups have been *implicit*; by not mentioning any lookups and simply placing rules inside a feature, the rules you specify are placed in a single, anonymous lookup. So this code which places rules in the `sups` feature, used when converting glyphs to their superscript forms (for example, in the case of footnote references): 至今为止的代码中,#tr[lookup]都是隐式的。像这样在特性里直接写规则的话,这些规则都会被直接放在同一个匿名#tr[lookup]中。以`sups`特性为例,其中的代码用于将#tr[glyph]转换为(可能用于书写脚注的引用标号的)上标形式: ```fea feature sups { sub one by onesuperior; sub two by twosuperior; sub three by threesuperior; } sups; ``` // is equivalent to this: 这段代码等价于: ```fea feature sups { lookup sups_1 { sub one by onesuperior; sub two by twosuperior; sub three by threesuperior; } sups_1; } sups; ``` // We can manually organise our rules within a feature by placing them within named lookups, like so: 我们也可以通过将规则放入手动命名的#tr[lookup]中来组织特性中的规则。就像下面这样: ```fea feature pnum { lookup pnum_latin { sub zero by zero.prop; sub one by one.prop; sub two by two.prop; ... } pnum_latin; lookup pnum_arab { sub uni0660 by uni0660.prop; sub uni0661 by uni0661.prop; sub uni0662 by uni0662.prop; ... } pnum_arab; } pnum; ``` // In fact, I would strongly encourage *always* placing rules inside an explicit `lookup` statement like this, because this helps us to remember the role that lookups play in the shaping process. As we'll see later, that will in turn help us to avoid some rather subtle bugs which are possible when multiple lookups are applied, as well as some problems that can develop from the use of lookup flags. 我永远强烈推荐把规则放进手动创建的#tr[lookup]中,因为这样可以帮助我们记住#tr[lookup]在整个#tr[shaping]过程中的角色和作用。这也能帮助我们在需要使用多个#tr[lookup]或复杂的#tr[lookup]选项时避免一些微妙的Bug。后面我们会看到其中的原因。 // Finally, you can define lookups outside of a feature, and then reference them within a feature. For one thing, this allows you to use the same lookup in more than one feature, sharing rules and reducing code duplication: 最后,你也可以在特性之外定义#tr[lookup],并在特性内引用它们。这也就让你能在多个特性中重复使用同一个#tr[lookup],像这样共享规则可以减少重复代码: ```fea lookup myAlternates { sub A by A.001; # 替代形式 ... } myAlternates; feature salt { lookup myAlternates; } salt; feature ss01 { lookup myAlternates; } ss01; ``` // The first clause *defines* the set of rules called `myAlternates`, which is then *used* in two features: `salt` is a general feature for stylistic alternates (alternate forms of the glyph which can be selected by the user for aesthetic reasons), and `ss01` which selects the first stylistic set. The ability to name and reference sets of rules in a lookup will come in extremely useful when we look at chaining rules - when one rule calls another. 第一条语句将一些规则定义为`myAlternates`#tr[lookup],后续它被用在 `salt` 和 `ss01` 两个特性中。`salt` 是一种通用特性,供用户选择#tr[glyph]在美学上的替代样式。而 `ss01` 特性用于启用第一种样式。这种可以为#tr[lookup]命名并通过名称引用其中的规则的功能非常有用,特别是在后续介绍#tr[chaining rules](一个规则调用另一个规则)时。
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/math/font-features_00.typ
typst
Apache License 2.0
#import "/contrib/templates/std-tests/preset.typ": * #show: test-page $ nothing $ $ "hi ∅ hey" $ $ sum_(i in NN) 1 + i $ #show math.equation: set text(features: ("cv01",), fallback: false) $ nothing $ $ "hi ∅ hey" $ $ sum_(i in NN) 1 + i $
https://github.com/lucifer1004/leetcode.typ
https://raw.githubusercontent.com/lucifer1004/leetcode.typ/main/problems/p0001.typ
typst
#import "../helpers.typ": * #import "../solutions/s0001.typ": * = Two Sum Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`. You may assume that each input would have *exactly one solution*, and you may not use the same element twice. You can return the answer in any order. #let two-sum(nums, target) = { // Solve the problem here } #testcases(two-sum, two-sum-ref, ( (nums: (2, 7, 11, 15), target: 9), (nums: (3, 2, 4), target: 6), (nums: (3, 3), target: 6), (nums: (0, 0), target: 1), (nums: range(1, 100, step: 3), target: 191), ))
https://github.com/ClazyChen/Table-Tennis-Rankings
https://raw.githubusercontent.com/ClazyChen/Table-Tennis-Rankings/main/history/2010/MS-03.typ
typst
#set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (1 - 32)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [1], [MA Long], [CHN], [3246], [2], [WANG Hao], [CHN], [3120], [3], [BOLL Timo], [GER], [3069], [4], [WANG Liqin], [CHN], [3064], [5], [XU Xin], [CHN], [3034], [6], [ZHANG Jike], [CHN], [3024], [7], [MA Lin], [CHN], [2995], [8], [SAMSONOV Vladimir], [BLR], [2985], [9], [HAO Shuai], [CHN], [2955], [10], [RYU Seungmin], [KOR], [2836], [11], [CHEN Qi], [CHN], [2828], [12], [JOO Saehyuk], [KOR], [2810], [13], [KISHIKAWA Seiya], [JPN], [2711], [14], [MAZE Michael], [DEN], [2707], [15], [YOSHIDA Kaii], [JPN], [2705], [16], [MIZUTANI Jun], [JPN], [2691], [17], [LEE Jungwoo], [KOR], [2689], [18], [SEO Hyundeok], [KOR], [2686], [19], [TANG Peng], [HKG], [2681], [20], [CHEUNG Yuk], [HKG], [2634], [21], [SUSS Christian], [GER], [2631], [22], [OVTCHAROV Dimitrij], [GER], [2630], [23], [<NAME>], [AUT], [2628], [24], [<NAME>], [POR], [2626], [25], [#text(gray, "ZHANG Chao")], [CHN], [2611], [26], [HOU Yingchao], [CHN], [2610], [27], [JIANG Tianyi], [HKG], [2608], [28], [YOON Jaeyoung], [KOR], [2606], [29], [OH Sangeun], [KOR], [2601], [30], [KO Lai Chak], [HKG], [2590], [31], [KREANGA Kalinikos], [GRE], [2584], [32], [<NAME>], [FRA], [2575], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (33 - 64)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [33], [CHUANG Chih-Yuan], [TPE], [2572], [34], [KIM Junghoon], [KOR], [2566], [35], [<NAME>], [CRO], [2564], [36], [PROKOPCOV Dmitrij], [CZE], [2557], [37], [LI Ching], [HKG], [2556], [38], [<NAME>], [AUT], [2554], [39], [<NAME>], [SWE], [2553], [40], [<NAME>], [GER], [2548], [41], [SKACHKOV Kirill], [RUS], [2541], [42], [<NAME>], [SGP], [2538], [43], [CHEN Weixing], [AUT], [2538], [44], [LUNDQVIST Jens], [SWE], [2537], [45], [<NAME>], [QAT], [2531], [46], [MATSUDAIRA Kenta], [JPN], [2529], [47], [#text(gray, "QIU Yike")], [CHN], [2514], [48], [KIM Hyok Bong], [PRK], [2505], [49], [<NAME>], [KOR], [2486], [50], [KAN Yo], [JPN], [2485], [51], [<NAME>], [CRO], [2477], [52], [<NAME>], [GER], [2475], [53], [<NAME>], [GRE], [2474], [54], [LIN Ju], [DOM], [2460], [55], [RUBTSOV Igor], [RUS], [2449], [56], [<NAME>], [IND], [2446], [57], [<NAME> Su], [KOR], [2444], [58], [#text(gray, "KONG Linghui")], [CHN], [2439], [59], [FEJER-KONNERTH Zoltan], [GER], [2439], [60], [VLASOV Grigory], [RUS], [2436], [61], [WANG Zengyi], [POL], [2435], [62], [SUCH Bartosz], [POL], [2432], [63], [KIM Minseok], [KOR], [2429], [64], [GERELL Par], [SWE], [2427], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (65 - 96)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [65], [YAN An], [CHN], [2424], [66], [SMIRNOV Alexey], [RUS], [2423], [67], [<NAME>], [ROU], [2414], [68], [JEOUNG Youngsik], [KOR], [2410], [69], [<NAME>], [KOR], [2410], [70], [<NAME>], [DEN], [2404], [71], [<NAME>], [KOR], [2401], [72], [<NAME>], [PRK], [2396], [73], [#text(gray, "<NAME>")], [SWE], [2391], [74], [<NAME>], [CZE], [2390], [75], [<NAME>], [SVK], [2390], [76], [<NAME>], [CRO], [2385], [77], [DRINKHALL Paul], [ENG], [2369], [78], [<NAME>], [RUS], [2364], [79], [<NAME>], [JPN], [2357], [80], [<NAME>], [KOR], [2349], [81], [<NAME>], [FRA], [2345], [82], [<NAME>], [ESP], [2341], [83], [LEGOUT Christophe], [FRA], [2340], [84], [<NAME>], [SLO], [2333], [85], [CHT<NAME>], [BLR], [2324], [86], [TAKAKIWA Taku], [JPN], [2323], [87], [<NAME>], [BRA], [2321], [88], [BLASZCZYK Lucjan], [POL], [2317], [89], [<NAME>], [DEN], [2317], [90], [<NAME>], [BEL], [2312], [91], [<NAME>], [SRB], [2309], [92], [<NAME>], [GER], [2308], [93], [<NAME>], [ROU], [2302], [94], [<NAME>], [JPN], [2301], [95], [MATSUDAIRA Kenji], [JPN], [2298], [96], [BOBOCICA Mihai], [ITA], [2297], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (97 - 128)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [97], [<NAME>], [ESP], [2296], [98], [<NAME> Yan], [HKG], [2294], [99], [CHI<NAME>-Lung], [TPE], [2293], [100], [<NAME>], [SWE], [2292], [101], [<NAME>], [SVK], [2291], [102], [KOSOWSKI Jakub], [POL], [2287], [103], [YANG Zi], [SGP], [2281], [104], [BURGIS Matiss], [LAT], [2281], [105], [JAKAB Janos], [HUN], [2280], [106], [FREITAS Marcos], [POR], [2278], [107], [<NAME>], [KOR], [2275], [108], [LIVENTSOV Alexey], [RUS], [2272], [109], [<NAME>], [SVK], [2272], [110], [WOSIK Torben], [GER], [2272], [111], [<NAME>], [TPE], [2272], [112], [#text(gray, "Y<NAME>")], [ITA], [2269], [113], [<NAME>], [PRK], [2267], [114], [MONTEIRO Joao], [POR], [2265], [115], [<NAME>], [SGP], [2264], [116], [TORIOLA Segun], [NGR], [2259], [117], [#text(gray, "<NAME>henhua")], [CHN], [2255], [118], [<NAME>], [GER], [2255], [119], [<NAME>], [SGP], [2254], [120], [SHIMOYAMA Takanori], [JPN], [2252], [121], [SHMYREV Maxim], [RUS], [2251], [122], [<NAME>], [POL], [2251], [123], [FANG Bo], [CHN], [2249], [124], [<NAME>], [CRO], [2240], [125], [WU Chih-Chi], [TPE], [2237], [126], [HU<NAME>], [TPE], [2231], [127], [<NAME>], [SVK], [2231], [128], [CHANG Yen-Shu], [TPE], [2225], ) )
https://github.com/Kasci/LiturgicalBooks
https://raw.githubusercontent.com/Kasci/LiturgicalBooks/master/X_misal/advent.typ
typst
#import "../utils.typ": * #import "/style.typ": * #let bg = { rect(width: 95%, height: 95%, inset: 10pt, radius: 5pt, stroke: (paint: primary, thickness: 2pt), rect(width: 100%, height: 100%, outset: 0pt, radius: 5pt, stroke: (paint: primary, thickness: 2pt)) ) } #let project(body) = { set page(paper:"a4", numbering: "1", number-align: center, background: bg, margin: (bottom: 90pt)) set text(font: "Monomakh Unicode", lang: "cu") // HEADINGS show heading.where(level: 1): it => [ #align(center, text(0pt, rgb("ffffff"), upper(it))) ] show heading.where(level: 2): it => [ #align(center, text(0pt, rgb("ffffff"), it)) ] show heading.where(level: 3): it => [ #align(center, text(0pt, rgb("ffffff"), it)) ] // Main body. set par(justify: true) body } #show: project #let adv1Ne = ( ("VSTUPNÝ SPEV (Cf. Ps 24, 1-3)",), ("Ad te levávi ánimam meam, Deus meus, in te confído, non erubéscam. Neque irrídeant me inimíci mei, étenim univérsi qui te exspéctant non confundéntur.", "K tebe, Pane, dvíham svoju dušu, tebe dôverujem, Bože môj. Nech nie som zahanbený a nech moji nepriatelia nejasajú nado mnou. Veď nik, čo dúfa v teba, nebude zahanbený."), ("> <NAME>ohu na výsostiach sa vynecháva.",), ("KOLEKTA",), ("Da, quǽsumus, omnípotens Deus, hanc tuis fidélibus voluntátem, ut, Christo tuo veniénti iustis opéribus occurréntes, eius déxteræ sociáti, regnum mereántur possidére cæléste. Per Dóminum. ", "Prosíme ťa, všemohúci Bože, daj nám ochotu konať dobré skutky a pomáhaj nám kráčať v ústrety Kristovi tak, * aby nás pri svojom druhom príchode postavil po svojej pravici — a voviedol do nebeského kráľovstva. Skrze nášho Pána."), ("> Vy<NAME>.",), ("<NAME>",), ("Súscipe, quǽsumus, Dómine, múnera quæ de tuis offérimus colláta benefíciis, et, quod nostræ devotióni concédis éffici temporáli, tuæ nobis fiat prǽmium redemptiónis ætérnæ. Per Christum.","Prosíme ťa, Pane, prijmi obetné dary, ktoré ti prinášame z toho, čo nám udelila tvoja dobrota; * a čo ti teraz so synovskou oddanosťou obetujeme, — nech nám prinesie večnú spásu. Skrze Krista, nášho Pána."), ("> Prefácia Adventná I.", ), ("SPEV NA PRIJÍMANIE (Ps 84, 13)", ), ("Dóminus dabit benignitátem, et terra nostra dabit fructum suum", "Pán dá požehnanie a svoje plody vydá naša zem."), ("PO PRIJÍMANÍ", ), ("Prosint nobis, quǽsumus, Dómine, frequentáta mystéria, quibus nos, inter prætereúntia ambulántes, iam nunc instítuis amáre cæléstia et inhærére mansúris. Per Christum.", "Prosíme ťa, Pane, nech je nám na osoh účasť na tejto sviatostnej hostine, * pri ktorej nás už v tomto pominuteľnom svete učíš milovať veci nebeské — a hľadať hodnoty trváce. Skrze Krista, nášho Pána."), ("> Možno použiť formulár slávnostného požehnania", ), ) #let adv1Po = ( ("VSTUPNÝ SPEV (Cf. Ier 31, 10; Is 35, 4)",), ("Audíte verbum Dómini, gentes, et annuntiáte illud in fínibus terræ: Ecce Salvátor noster advéniet, et iam nolíte timére", "Čujte, národy, slovo Pánovo a ohlasujte ho až do končín zeme: náš Spasiteľ príde, nebojte sa!"), ("KOLEKTA",), ("Fac nos, quǽsumus, Dómine Deus noster, advéntum Christi Fílii tui sollícitos exspectáre, ut, dum vénerit pulsans, oratiónibus vigilántes, et in suis invéniat láudibus exsultántes. Qui tecum.", "Pane a Bože náš, pomôž nám bedlivo očakávať príchod tvojho Syna Ježiša Krista; * a keď príde a zaklope, nech nás nájde bdieť v modlitbách — a jasať na jeho slávu. Lebo on je."), ("NAD OBETNÝMI DARMI",), ("Súscipe, quǽsumus, Dómine, múnera quæ de tuis offérimus colláta benefíciis, et, quod nostræ devotióni concédis éffici temporáli, tuæ nobis fiat prǽmium redemptiónis ætérnæ. Per Christum.","Prosíme ťa, Pane, prijmi obetné dary, ktoré ti prinášame z toho, čo nám udelila tvoja dobrota; * a čo ti teraz so synovskou oddanosťou obetujeme, — nech nám prinesie večnú spásu. Skrze Krista, nášho Pána."), ("> Prefácia Adventná I.", ), ("SPEV NA PRIJÍMANIE (Cf. Ps 105, 4-5; Is 38, 3)", ), ("Veni, Dómine, visitáre nos in pace, ut lætémur coram te corde perfécto.", "Príď, Pane, a navštív nás svojím pokojom, aby sme sa radovali pred tebou celým srdcom."), ("PO PRIJÍMANÍ", ), ("Prosint nobis, quǽsumus, Dómine, frequentáta mystéria, quibus nos, inter prætereúntia ambulántes, iam nunc instítuis amáre cæléstia et inhærére mansúris. Per Christum.", "Prosíme ťa, Pane, nech je nám na osoh účasť na tejto sviatostnej hostine, * pri ktorej nás už v tomto pominuteľnom svete učíš milovať veci nebeské — a hľadať hodnoty trváce. Skrze Krista, nášho Pána."), ) #let adv1Ut = ( ("VSTUPNÝ SPEV (Cf. Zac 14, 5.7)",), ("Ecce Dóminus véniet, et omnes sancti eius cum eo; et erit in die illa lux magna.", "Hľa, Pán príde a s ním všetci jeho svätí; a v ten deň zažiari veľké svetlo."), ("KOLEKTA",), ("Propitiáre, Dómine Deus, supplicatiónibus nostris, et tribulántibus, quǽsumus, tuæ concéde pietátis auxílium, ut, de Fílii tui veniéntis præséntia consoláti, nullis iam polluámur contágiis vetustátis. Per Dóminum.", "Pane a Bože náš, dobrotivo vypočuj naše pokorné prosby a láskavo nám pomáhaj v našich slabostiach, * aby nás povzbudila prítomnosť tvojho prichádzajúceho Syna, — a tak sme sa chránili pred nebezpečenstvami hriechu. Skrze nášho Pána."), ("<NAME>",), ("Placáre, Dómine, quǽsumus, nostræ précibus humilitátis et hóstiis, et, ubi nulla súppetunt suffrágia meritórum, tuæ nobis indulgéntiæ succúrre præsídiis. Per Christum.","Prosíme ťa, Pane, nech ťa uzmieria naše pokorné modlitby a obetné dary, * a pretože sa nemôžeme spoliehať na vlastné zásluhy, — pomáhaj nám svojou milosrdnou láskou. Skrze Krista, nášho Pána."), ("> Prefácia Adventná I.", ), ("SPEV NA PRIJÍMANIE (Cf. 2 Tim 4, 8)", ), ("Corónam iustítiæ reddet iustus iudex iis qui díligunt advéntum eius.", "Spravodlivý sudca dá veniec spravodlivosti tým, čo milujú jeho príchod."), ("PO PRIJÍMANÍ", ), ("Repléti cibo spiritális alimóniæ, súpplices te, Dómine, deprecámur, ut, huius participatióne mystérii, dóceas nos terréna sapiénter perpéndere, et cæléstibus inhærére. Per Christum.", "Pane, nasýtil si nás duchovným pokrmom; * pokorne ťa prosíme, daj, aby sme sa účasťou na tejto sviatosti naučili správne hodnotiť pozemské veci — a milovať hodnoty nebeské. Skrze Krista, nášho Pána."), ) = Tempus Adventus \ (Adventné obdobie) == Dominica I Adventus \ (Prvá adventná nedeľa) #make(adv1Ne) == Feria secunda \ (Pondelok) #make(adv1Po) == Feria tertia \ (Utorok) #make(adv1Ut)
https://github.com/AliothCancer/AppuntiUniversity
https://raw.githubusercontent.com/AliothCancer/AppuntiUniversity/main/capitoli_fisica/trasmissione_stazionaria.typ
typst
= Trasmissione del calore: Regime Stazionario == Coefficiente di conduzione (k) - *Si indica con* $k$ - *Si misura in* $W / (m K)$ - Si usa per i vari strati della parete - Differente per ogni materiale, gas, solido, liquido. - È una misura di quanto velocemente un materiale scambia calore (Potenza termica $dot(Q)$), *indipendentemente* *dalla superficie di scambio* e *dalla differenza di temperatura* che viene applicata alle estremità considerate. == Coefficiente di convezione (h) - *Si indica con* $h$ - *Si misura in* $W / (m^2 K)$ - Si usa per i fluidi convettivi - prima della parete - dopo la parete == Coefficiente di scambio termico globale (U) - È un coefficiente equivalente che tiene conto dei vari coefficienti di convezione e conduzione. - *Si indica con U* - *Si misura in* $W / (m^2 K)$ == Conduttanza termica - *Si misura in* $W/K$ - È l'inverso della resistenza termica == Caso: Parete Piana === Resistenza alla Conduzione - *Si indica con* $R_k$ - *Si misura in* $K/W$ $ R_k = L / (S dot k) $ - L $[m]$: spessore dello strato della parete - k $[W/ (m K)]$: coeff. di conduzione - S $[m^2]$: superficie di scambio dello strato === Resistenza alla Convezione - *Si indica con* $R_h$ - *Si misura in* $K/W$ $ R_h = 1 / (S dot h) $ - h $[W/ (m^2 K)]$: coeff. di conduzione - S $[m^2]$: superficie di scambio dello strato === Potenza Termica $ dot(Q) = (Delta T) / R_"tot" \ \ dot(Q) = U dot S dot Delta T $ Dove $S$ è una superficie rettangolare: $ S = a dot b $ == Caso: <NAME> === Resistenza alla Conduzione - *Si indica con* $R_k$ - *Si misura in* $K/W$ $ R_k = ln(r_e / r_i) / (2 pi L k) $ - L $[m]$: spessore dello strato - k $[W/ (m K)]$: coeff. di conduzione - S $[m^2]$: superficie di scambio dello strato === Resistenza alla Convezione - *Si indica con* $R_h$ - *Si misura in* $K/W$ $ R_h = 1 / (S dot h) \ S = 2 pi r c $ \**Nota*: ci sarà una superficie interna ed una esterna. - c $[m]$ : altezza del cilindro - h $[W/ (m K)]$: coeff. di conduzione - S $[m^2]$: superficie di scambio dello strato === Potenza Termica $ dot(Q) = (T_"e" - T_"i") / R_k = -(2 pi L k dot (T_"e" - T_"i")) / ln(r_"e" / r_"i") $ \* è positivo se $T_i$ > $T_e$ cioè uscente rispetto all'interno del cilindro - *SEGNO :* Per il II° principio della term. il calore va da un corpo più caldo a uno più freddo. Una volta che si sa quale delle temperature tra esterne ed interna si capisce qual è il verso. In alternativa si assume un verso a scelta e se esce negativo il verso effettivo è l'opposto rispetto a quello scelto. == Calcolo resistenze - Valide sia per *conduzione* che per *convezione* === Serie $ R_"tot" = R_1 + R_2 + ... + R_i $ === Parallelo $ R_"tot" = (1 / R_"tot")^(-1) = (1/R_1 + 1/R_2 + ... + 1/R_i)^(-1) $ === Complessiva - *Si misura in* $K/W$ $ R_"tot" = 1 / (S dot U) = sum R_"serie" + sum R_"parallele" $ - S: superficie di scambio - U: coeff. globale di scambio $ R_"tot" = (Delta T) / dot(Q) $ - $dot(Q):$ potenza termica scambiata - $Delta T:$ differenza di temperatura tra interno ed esterno