repo
stringlengths
26
115
file
stringlengths
54
212
language
stringclasses
2 values
license
stringclasses
16 values
content
stringlengths
19
1.07M
https://github.com/rxt1077/it610
https://raw.githubusercontent.com/rxt1077/it610/master/markup/exercises/volumes.typ
typst
#import "/templates/exercise.typ": exercise, code, admonition #show: doc => exercise( course-name: "Systems Administration", exercise-name: "Docker Volumes", doc, ) == Goals + Create a new volume in Docker + Run a postgres container with the volume mounted + Create a new database on the volume + Back up the volume == Creating a Volume Create a volume with the `docker volume create` command and check to see if it is there with the `docker volume ls` command: #code()[ ```console $ docker volume create db-data db-data $ docker volume ls DRIVER VOLUME NAME local db-data ``` ] #admonition[ Docker volumes are stored in `/var/lib/docker/volumes/<volume-name>`. If you're not running Docker natively (in Linux) that means your volumes live in that folder in a virtual drive used by your Docker Linux VM. That makes them pretty tough to get to without using Docker! ] == Running PostgreSQL Now let's run a postgres container in the background with our volume mounted in `/var/lib/postgresql/data`, which is the path where the PostgreSQL database information is stored by default: #code([ ```console $ docker run -d --mount source=db-data,target=/var/lib/postgresql/data -e \ <1> <2> POSTGRES_PASSWORD=<PASSWORD>me postgres 26618a503c688c19728c87190beb7497f68b6e7d350b09e3eae7f2f71b1c8738 <3> $ docker ps <4> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS \ NAMES 26618a503c68 postgres "docker-entrypoint.s…" 28 seconds ago Up 28 seconds 5432/tcp \ gifted_montalcini ``` ], callouts: ( ("<1>", [ The `\` character is a line continuation. It means that the text below it, starting with "POSTGRES_PASSWORD", is actually on the same line but it couldn't fit on the screen.]), ("<2>", [ Here's an explanation of some of the options and arguments: / `-d`: run in the background (daemon) / `--mount source=db-data,target=/var/lib/postgresql/data`: mount the `exercise4-db` local volume in the `/var/lib/postgresql/data` directory of the container / `-e POSTGRES_PASSWORD=<PASSWORD>`: set the environment variable fo the postgres password to `<PASSWORD>`. PostgreSQL won't start without a password. / `postgres`: run the postgres image]), ("<3>", [Your output may be slightly different if you don't have the `postgres` image available locally.]), ("<4>", [This is just to confirm that it's running]), )) You can also check the logs to see how things went with `docker logs <CONTAINER ID>` where `<CONTAINER ID>` is the id from your `ps` command. == Creating a New Database The easiest way to create a new database on our running container would be with the psql command. Fortunately the psql command is already on our container so we can `exec` it from there. Let's connect to our database and put some data in there: #code([ ```console $ docker exec -it <CONTAINER_ID> psql --username=postgres <1> psql (16.1 (Debian 16.1-1.pgdg120+1)) Type "help" for help. postgres=# CREATE DATABASE top_secret; <2> CREATE DATABASE postgres=# \c top_secret You are now connected to database "top_secret" as user "postgres". top_secret=# CREATE TABLE spies (name VARCHAR(64)); CREATE TABLE top_secret=# INSERT INTO spies (name) VALUES ('Bob'); INSERT 0 1 top_secret=# \q <3> ``` ], callouts: ( ("<1>", [ Here is an explanation of the options: / `exec`: run a command _on an already running container_ / `-it`: run interactively / `<CONTAINER ID>`: your container id as listed in the `ps` output above / `psql`: run the psql command (command line SQL client) / `--username=postgres`: this argument is passed to the `psql` command, it says you want to connect as the default postgres user]), ("<2>", [These psql commands create a bit of data for us to use]), ("<3>", [`\q` exits psql]) )) == Backing up the Database Directory Now we will start another container, that uses the same volume as our postgres container. On the new container we will use the `tar` command to make a compressed archive the database directory: #code([ ```console $ docker run --rm --volumes-from 26618a503c68 -v "$(pwd):/backup" ubuntu \ <1> tar caf /backup/db-backup.tar.gz /var/lib/postgresql/data tar: Removing leading `/' from member names $ ls Directory: C:\Users\rxt1077\temp\ Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 9/19/2024 5:32 PM 6749916 db-backup.tar.gz <2> ``` ], callouts: ( ("<1>", [ This is a long command, so lets take it argument-by-argument: / `run`: start a new container and run a command on it / `--rm`: don't archive this container when we are done, it's temporary / `--volumes-from <CONTAINER ID>`: give us the same volumes at the same mountpoints as our running postgres container / `-v "$(pwd):/backup"`: bind mount the local working directory to `/backup` on the container we are creating / `ubuntu`: use the `ubuntu` base image / `tar caf /backup/db-backup.tar.gz /var/lib/postgresql/data`: This is the command that is run on the container. It #link("https://www.gnu.org/software/tar/manual/html_node/gzip.html")[creates a compressed tar archive] from the database directory and writes it to `/backup/db-backup.tar.gz`. ]), ("<2>", [Here's our backup in the directory where we were working on the host machine.]) )) == Deliverables Submit your `db-backup.tar.gz` file as your work for this exercise. == Resources - #link("https://docs.docker.com/storage/volumes/")[Docker Documentation: Use volumes] - #link("https://hub.docker.com/_/postgres")[Docker Hub: postgres]
https://github.com/OrangeX4/typst-pinit
https://raw.githubusercontent.com/OrangeX4/typst-pinit/main/pinit-core.typ
typst
MIT License
#let empty-box = box(height: 0pt, width: 0pt, outset: 0pt, inset: 0pt) // ----------------------------------------------- // Code from https://github.com/ntjess/typst-drafting // ----------------------------------------------- #let _run-func-on-first-loc(func, label-name: "loc-tracker") = { // Some placements are determined by locations relative to a fixed point. However, typst // will automatically re-evaluate that computation several times, since the usage // of that computation will change where an element is placed (and therefore update its // location, and so on). Get around this with a state that only checks for the first // update, then ignores all subsequent updates let lbl = label(label-name) [#metadata(label-name)#lbl] context { let use-loc = query(selector(lbl).before(here())).last().location() func(use-loc) } } /// Place content at a specific location on the page relative to the top left corner /// of the page, regardless of margins, current container, etc. /// /// > This function comes from [typst-drafting](https://github.com/ntjess/typst-drafting), Thanks to [ntjess]((https://github.com/ntjess/). /// /// - `dx`: [`length`] &mdash; Length in the x-axis relative to the left edge of the page. /// - `dy`: [`length`] &mdash; Length in the y-axis relative to the top edge of the page. /// - `body`: [`content`] &mdash; The content you want to place. #let absolute-place(dx: 0em, dy: 0em, body) = { _run-func-on-first-loc(loc => { let pos = loc.position() place(dx: -pos.x + dx, dy: -pos.y + dy, body) }) } // ----------------------------------------------- // Core // ----------------------------------------------- #let _pin-label(loc, name) = label("page-" + str(loc.position().page) + ":" + repr(name)) /// Pinning a pin in text, the pin is supposed to be unique in one page. /// /// - `name`: [`integer` or `string` or `any`] &mdash; Name of pin, which can be any types with unique `repr()` return value, such as integer and string. #let pin(name) = { _run-func-on-first-loc(loc => { [#empty-box#_pin-label(loc, name)] }) } /// Query positions of pins in the same page, then call the callback function `func`. /// /// - `callback`: [`(..positions) => { .. }`] &mdash; A callback function accepting an array of positions (or a single position) as a parameter. Each position is a dictionary like `(page: 1, x: 319.97pt, y: 86.66pt)`. You can use the `absolute-place` function in this callback function to display something around the pins. /// - `..pins`: [`pin`] &mdash; Names of pins you want to query. It is supposed to be arguments composed with pin or a group of pins. #let pinit(callback: none, ..pins) = { assert(callback != none, message: "The callback function is required.") assert(pins.named().len() == 0, message: "The pin names should not be named.") pins = pins.pos() _run-func-on-first-loc(loc => { let positions = () for pin-group in pins { let poss = () if type(pin-group) != array { pin-group = (pin-group,) } for pin-name in pin-group { let elems = query( selector(_pin-label(loc, pin-name)), ) assert(elems.len() > 0, message: "Pin not found: " + repr(pin-name)) poss.push(elems.at(0).location().position()) } if poss.len() == 1 { positions.push(poss.at(0)) } else { positions.push(( page: poss.at(0).page, x: poss.map(p => p.x).sum() / poss.len(), y: poss.map(p => p.y).sum() / poss.len(), )) } } callback(..positions) }) } /// Place content at a specific location on the page relative to the pin. /// /// - `pin-name`: [`pin`] &mdash; Name of the pin to which you want to locate. /// - `body`: [`content`] &mdash; The content you want to place. /// - `dx`: [`length`] &mdash; Offset X relative to the pin. /// - `dy`: [`length`] &mdash; Offset Y relative to the pin. #let pinit-place( pin-name, body, dx: 0pt, dy: 0pt, ) = { pinit( pin-name, callback: pos => { absolute-place(dx: pos.x + dx, dy: pos.y + dy, body) }, ) }
https://github.com/jneug/typst-nassi
https://raw.githubusercontent.com/jneug/typst-nassi/main/src/draw.typ
typst
MIT License
#import "@preview/cetz:0.3.0" as cetz: draw #import cetz.util: measure, resolve-number #import "elements.typ": TYPES, empty #let if-auto(value, default, f: v => v) = if value == auto { f(default) } else { f(value) } #let rebalance-heights(elements, height-growth, y: auto) = { // Count elements that can have a dynamic height let dynamic = 0 for e in elements { if e.type in (TYPES.PROCESS, TYPES.CALL, TYPES.EMPTY) { dynamic += 1 } } // Adjust height and position of elements if y == auto { y = elements.first().pos.at(1) } if dynamic > 0 { let growth = height-growth / dynamic for (i, e) in elements.enumerate() { e.pos.at(1) = y if e.type in (TYPES.PROCESS, TYPES.CALL, TYPES.EMPTY) { e.height += growth //e.grow += growth elements.at(i) = e } y -= e.height + e.grow } } else { let growth = height-growth / elements.len() for (i, e) in elements.enumerate() { e.grow += growth e.pos.at(1) = y if e.type in (TYPES.LOOP, TYPES.FUNCTION) { e.elements = rebalance-heights(e.elements, growth, y: e.pos.at(1) - e.height) } else if e.type == TYPES.BRANCH { e.left = rebalance-heights(e.left, growth, y: e.pos.at(1) - e.height) e.right = rebalance-heights(e.right, growth, y: e.pos.at(1) - e.height) } elements.at(i) = e y -= e.height + e.grow } } return elements } #let layout-elements(ctx, (x, y), width, inset, elements, i: 0) = { let elems = () for element in elements { i += 1 element.name = if-auto(element.name, "e" + str(i)) element.pos = (x, y) element.width = width element.inset = if-auto( element.inset, inset, f: resolve-number.with(ctx), ) element.height = if element.height == auto { measure(ctx, block(width: width * ctx.length, element.text)).at(1) + 2 * element.inset } else { element.height } if element.type in (TYPES.LOOP, TYPES.FUNCTION) { if element.elements == none or element.elements == () { element.elements = empty() } (element.elements, i) = layout-elements( ctx, (x + 2 * element.inset, y - element.height), width - 2 * element.inset, inset, () + element.elements, i: i, ) element.grow = element.elements.fold(0, (h, e) => h + e.height + e.grow) if element.type == TYPES.FUNCTION { element.grow += 2 * element.inset } } else if element.type == TYPES.BRANCH { if element.left == none or element.left == () { element.left = empty() } (element.left, i) = layout-elements( ctx, (x, y - element.height), width * element.column-split, inset, () + element.left, i: i, ) if element.right == none or element.right == () { element.right = empty() } (element.right, i) = layout-elements( ctx, (x + width * element.column-split, y - element.height), width * (1 - element.column-split), inset, () + element.right, i: i, ) let (height-left, height-right) = ( element.left.fold(0, (h, e) => h + e.height + e.grow), element.right.fold(0, (h, e) => h + e.height + e.grow), ) if height-left < height-right { element.left = rebalance-heights(element.left, (height-right - height-left)) } else if height-right < height-left { element.right = rebalance-heights(element.right, (height-left - height-right)) } element.grow = calc.max(height-left, height-right) } else if element.type == TYPES.SWITCH { for (index, key) in element.branches.keys().enumerate() { if element.branches.at(key) == none or element.branches.at(key) == () { element.branches.at(key) = empty() } (element.branches.at(key), i) = layout-elements( ctx, (x + width * index / element.branches.len(), y - element.height), width / element.branches.len(), inset, () + element.branches.at(key), i: i, ) } let heights = element.branches.values().map(branch => branch.fold(0, (h, e) => h + e.height + e.grow)) element.grow = calc.max(..heights) for (index, key) in element.branches.keys().enumerate() { element.branches.at(key) = rebalance-heights(element.branches.at(key), element.grow - heights.at(index)) } } elems.push(element) y -= element.height + element.grow } return (elems, i) } #let draw-elements(ctx, layout, stroke: 1pt + black, theme: (:), labels: ()) = { for element in layout { let (x, y) = element.pos let stroke = if-auto(element.stroke, stroke) if element.type == TYPES.EMPTY { draw.rect( (x, y), (x + element.width, y - element.height - element.grow), stroke: stroke, fill: if-auto( element.fill, theme.at("empty", default: rgb("#fffff3")), ), name: element.name, ) draw.content( (x + element.width * .5, y - element.height * .5), element.text, anchor: "center", name: element.name + "-text", ) } else if element.type == TYPES.PROCESS { draw.rect( (x, y), (x + element.width, y - element.height - element.grow), stroke: stroke, fill: if-auto( element.fill, theme.at("process", default: rgb("#fceece")), ), name: element.name, ) draw.content( (x + element.inset, y - element.height * .5), element.text, anchor: "west", name: element.name + "-text", ) } else if element.type == TYPES.CALL { draw.rect( (x, y), (x + element.width, y - element.height - element.grow), stroke: stroke, fill: if-auto( element.fill, theme.at("call", default: rgb("#fceece")).darken(5%), ), name: element.name, ) draw.rect( (x + element.inset * .5, y), ( x + element.width - element.inset * .5, y - element.height - element.grow, ), stroke: stroke, fill: if-auto( element.fill, theme.at("call", default: rgb("#fceece")), ), ) draw.content( (x + element.inset, y - element.height * .5), element.text, anchor: "west", name: element.name + "-text", ) } else if element.type == TYPES.LOOP { draw.rect( (x, y), (x + element.width, y - element.height - element.grow), stroke: stroke, fill: if-auto( element.fill, theme.at("loop", default: rgb("#dcefe7")), ), name: element.name, ) draw.content( (x + element.inset, y - element.height * .5), element.text, anchor: "west", name: element.name + "-text", ) draw-elements(ctx, element.elements, stroke: stroke, theme: theme, labels: labels) } else if element.type == TYPES.FUNCTION { draw.rect( (x, y), (x + element.width, y - element.height - element.grow), stroke: stroke, fill: if-auto( element.fill, theme.at("function", default: rgb("#ffffff")), ), name: element.name, ) draw.content( (x + element.inset, y - element.height * .5), strong(element.text), anchor: "west", name: element.name + "-text", ) draw-elements(ctx, element.elements, stroke: stroke, theme: theme, labels: labels) } else if element.type == TYPES.BRANCH { draw.rect( (x, y), (x + element.width, y - element.height - element.grow), fill: if-auto( element.fill, theme.at("branch", default: rgb("#fadad0")), ), stroke: stroke, name: element.name, ) let content-width = measure(ctx, element.text).at(0) + 2 * element.inset draw.content( ( x + element.column-split * element.width + (.5 - element.column-split) * content-width, y - element.inset, ), element.text, anchor: "north", name: element.name + "-text", ) draw.line( (x, y), (x + element.width * element.column-split, y - element.height), (x + element.width, y), stroke: stroke, ) draw.content( (x + element.inset * .5, y - element.height + element.inset * .5), text(.66em, element.labels.at(0, default: labels.at(0, default: "true"))), anchor: "south-west", ) draw.content( ( x + element.width - element.inset * .5, y - element.height + element.inset * .5, ), text(.66em, element.labels.at(1, default: labels.at(1, default: "false"))), anchor: "south-east", ) draw-elements(ctx, element.left, stroke: stroke, theme: theme, labels: labels) draw-elements(ctx, element.right, stroke: stroke, theme: theme, labels: labels) } else if element.type == TYPES.SWITCH { draw.rect( (x, y), (x + element.width, y - element.height - element.grow), fill: if-auto( element.fill, theme.at("branch", default: rgb("#fadad0")), ), stroke: stroke, name: element.name, ) let content-width = measure(ctx, element.text).at(0) + 2 * element.inset draw.content( ( x + element.column-split * element.width + (.5 - element.column-split) * content-width, y - element.inset, ), element.text, anchor: "north", name: element.name + "-text", ) draw.line( (x, y), (x + element.width * element.column-split, y - element.height), (x + element.width, y), stroke: stroke, ) for i in range(element.branches.len() - 1) { let key = element.branches.keys().at(i) draw.line( ( x + element.width * i / element.branches.len(), y - element.height * i / (element.branches.len() - 1), ), (x + element.width * i / element.branches.len(), y - element.height), ) draw.content( ( x + element.width * i / element.branches.len() + element.inset * .5, y - element.height + element.inset * .5, ), text(.66em, element.labels.at(i, default: key)), anchor: "south-west", ) } draw.content( ( x + element.width - element.inset * .5, y - element.height + element.inset * .5, ), text(.66em, element.branches.keys().at(-1, default: labels.at(1, default: "default"))), anchor: "south-east", ) for branch in element.branches.values() { draw-elements(ctx, branch, stroke: stroke, theme: theme, labels: labels) } } } } #let diagram( pos, anchor: "center", name: "nassi", width: 12, inset: .194, theme: (:), stroke: 1pt + black, labels: (), elements, ) = { draw.get-ctx(ctx => { let (layout, _) = layout-elements( ctx, pos, resolve-number(ctx, width), resolve-number(ctx, inset), elements, ) draw.group( anchor: anchor, name: name, draw-elements(ctx, layout, stroke: stroke, theme: theme, labels: labels), ) }) }
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/text/quotes_05.typ
typst
Apache License 2.0
#import "/contrib/templates/std-tests/preset.typ": * #show: test-page // Test changing properties within text. "She suddenly started speaking french: #text(lang: "fr")['Je suis une banane.']" Roman told me. Some people's thought on this would be #[#set smartquote(enabled: false); "strange."]
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/teig/0.1.0/lib.typ
typst
Apache License 2.0
#let _plugin = plugin("teig.wasm") #let eigenvalues(matr) = { let rows = matr.len() let cols = int(matr.map(x => x.len()).sum() / rows) if matr.filter(x => x.len() == cols).len() != rows { panic("Matrix size not consistent") } let data = bytes(matr.flatten().map(x => str(x)).join(",")) let eig_string = str(_plugin.eigenvalues(bytes((rows, cols)), data)) eig_string.split(",").map(float) }
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-1F300.typ
typst
Apache License 2.0
#let data = ( ("CYCLONE", "So", 0), ("FOGGY", "So", 0), ("CLOSED UMBRELLA", "So", 0), ("NIGHT WITH STARS", "So", 0), ("SUNRISE OVER MOUNTAINS", "So", 0), ("SUNRISE", "So", 0), ("CITYSCAPE AT DUSK", "So", 0), ("SUNSET OVER BUILDINGS", "So", 0), ("RAINBOW", "So", 0), ("BRIDGE AT NIGHT", "So", 0), ("WATER WAVE", "So", 0), ("VOLCANO", "So", 0), ("MILKY WAY", "So", 0), ("EARTH GLOBE EUROPE-AFRICA", "So", 0), ("EARTH GLOBE AMERICAS", "So", 0), ("EARTH GLOBE ASIA-AUSTRALIA", "So", 0), ("GLOBE WITH MERIDIANS", "So", 0), ("NEW MOON SYMBOL", "So", 0), ("WAXING CRESCENT MOON SYMBOL", "So", 0), ("FIRST QUARTER MOON SYMBOL", "So", 0), ("WAXING GIBBOUS MOON SYMBOL", "So", 0), ("FULL MOON SYMBOL", "So", 0), ("WANING GIBBOUS MOON SYMBOL", "So", 0), ("LAST QUARTER MOON SYMBOL", "So", 0), ("WANING CRESCENT MOON SYMBOL", "So", 0), ("CRESCENT MOON", "So", 0), ("NEW MOON WITH FACE", "So", 0), ("FIRST QUARTER MOON WITH FACE", "So", 0), ("LAST QUARTER MOON WITH FACE", "So", 0), ("FULL MOON WITH FACE", "So", 0), ("SUN WITH FACE", "So", 0), ("GLOWING STAR", "So", 0), ("SHOOTING STAR", "So", 0), ("THERMOMETER", "So", 0), ("BLACK DROPLET", "So", 0), ("WHITE SUN", "So", 0), ("WHITE SUN WITH SMALL CLOUD", "So", 0), ("WHITE SUN BEHIND CLOUD", "So", 0), ("WHITE SUN BEHIND CLOUD WITH RAIN", "So", 0), ("CLOUD WITH RAIN", "So", 0), ("CLOUD WITH SNOW", "So", 0), ("CLOUD WITH LIGHTNING", "So", 0), ("CLOUD WITH TORNADO", "So", 0), ("FOG", "So", 0), ("WIND BLOWING FACE", "So", 0), ("HOT DOG", "So", 0), ("TACO", "So", 0), ("BURRITO", "So", 0), ("CHESTNUT", "So", 0), ("SEEDLING", "So", 0), ("EVERGREEN TREE", "So", 0), ("DECIDUOUS TREE", "So", 0), ("PALM TREE", "So", 0), ("CACTUS", "So", 0), ("HOT PEPPER", "So", 0), ("TULIP", "So", 0), ("CHERRY BLOSSOM", "So", 0), ("ROSE", "So", 0), ("HIBISCUS", "So", 0), ("SUNFLOWER", "So", 0), ("BLOSSOM", "So", 0), ("EAR OF MAIZE", "So", 0), ("EAR OF RICE", "So", 0), ("HERB", "So", 0), ("FOUR LEAF CLOVER", "So", 0), ("MAPLE LEAF", "So", 0), ("FALLEN LEAF", "So", 0), ("LEAF FLUTTERING IN WIND", "So", 0), ("MUSHROOM", "So", 0), ("TOMATO", "So", 0), ("AUBERGINE", "So", 0), ("GRAPES", "So", 0), ("MELON", "So", 0), ("WATERMELON", "So", 0), ("TANGERINE", "So", 0), ("LEMON", "So", 0), ("BANANA", "So", 0), ("PINEAPPLE", "So", 0), ("RED APPLE", "So", 0), ("GREEN APPLE", "So", 0), ("PEAR", "So", 0), ("PEACH", "So", 0), ("CHERRIES", "So", 0), ("STRAWBERRY", "So", 0), ("HAMBURGER", "So", 0), ("SLICE OF PIZZA", "So", 0), ("MEAT ON BONE", "So", 0), ("POULTRY LEG", "So", 0), ("RICE CRACKER", "So", 0), ("RICE BALL", "So", 0), ("COOKED RICE", "So", 0), ("CURRY AND RICE", "So", 0), ("STEAMING BOWL", "So", 0), ("SPAGHETTI", "So", 0), ("BREAD", "So", 0), ("FRENCH FRIES", "So", 0), ("ROASTED SWEET POTATO", "So", 0), ("DANGO", "So", 0), ("ODEN", "So", 0), ("SUSHI", "So", 0), ("FRIED SHRIMP", "So", 0), ("FISH CAKE WITH SWIRL DESIGN", "So", 0), ("SOFT ICE CREAM", "So", 0), ("SHAVED ICE", "So", 0), ("ICE CREAM", "So", 0), ("DOUGHNUT", "So", 0), ("COOKIE", "So", 0), ("CHOCOLATE BAR", "So", 0), ("CANDY", "So", 0), ("LOLLIPOP", "So", 0), ("CUSTARD", "So", 0), ("HONEY POT", "So", 0), ("SHORTCAKE", "So", 0), ("BENTO BOX", "So", 0), ("POT OF FOOD", "So", 0), ("COOKING", "So", 0), ("FORK AND KNIFE", "So", 0), ("TEACUP WITHOUT HANDLE", "So", 0), ("SAKE BOTTLE AND CUP", "So", 0), ("WINE GLASS", "So", 0), ("COCKTAIL GLASS", "So", 0), ("TROPICAL DRINK", "So", 0), ("BEER MUG", "So", 0), ("CLINKING BEER MUGS", "So", 0), ("BABY BOTTLE", "So", 0), ("FORK AND KNIFE WITH PLATE", "So", 0), ("BOTTLE WITH POPPING CORK", "So", 0), ("POPCORN", "So", 0), ("RIBBON", "So", 0), ("WRAPPED PRESENT", "So", 0), ("BIRTHDAY CAKE", "So", 0), ("JACK-O-LANTERN", "So", 0), ("CHRISTMAS TREE", "So", 0), ("FATHER CHRISTMAS", "So", 0), ("FIREWORKS", "So", 0), ("FIREWORK SPARKLER", "So", 0), ("BALLOON", "So", 0), ("PARTY POPPER", "So", 0), ("CONFETTI BALL", "So", 0), ("TANABATA TREE", "So", 0), ("CROSSED FLAGS", "So", 0), ("PINE DECORATION", "So", 0), ("JAPANESE DOLLS", "So", 0), ("CARP STREAMER", "So", 0), ("WIND CHIME", "So", 0), ("MOON VIEWING CEREMONY", "So", 0), ("SCHOOL SATCHEL", "So", 0), ("GRADUATION CAP", "So", 0), ("HEART WITH TIP ON THE LEFT", "So", 0), ("BOUQUET OF FLOWERS", "So", 0), ("MILITARY MEDAL", "So", 0), ("<NAME>", "So", 0), ("MUSICAL KEYBOARD WITH JACKS", "So", 0), ("STUDIO MICROPHONE", "So", 0), ("LEVEL SLIDER", "So", 0), ("CONTROL KNOBS", "So", 0), ("BEAMED ASCENDING MUSICAL NOTES", "So", 0), ("BEAMED DESCENDING MUSICAL NOTES", "So", 0), ("FILM FRAMES", "So", 0), ("ADMISSION TICKETS", "So", 0), ("<NAME>", "So", 0), ("<NAME>", "So", 0), ("ROLLER COASTER", "So", 0), ("FISHING POLE AND FISH", "So", 0), ("MICROPHONE", "So", 0), ("MOVIE CAMERA", "So", 0), ("CINEMA", "So", 0), ("HEADPHONE", "So", 0), ("ARTIST PALETTE", "So", 0), ("TOP HAT", "So", 0), ("CIRCUS TENT", "So", 0), ("TICKET", "So", 0), ("CLAPPER BOARD", "So", 0), ("PERFORMING ARTS", "So", 0), ("VIDEO GAME", "So", 0), ("DIRECT HIT", "So", 0), ("SLOT MACHINE", "So", 0), ("BILLIARDS", "So", 0), ("GAME DIE", "So", 0), ("BOWLING", "So", 0), ("FLOWER PLAYING CARDS", "So", 0), ("MUSICAL NOTE", "So", 0), ("MULTIPLE MUSICAL NOTES", "So", 0), ("SAXOPHONE", "So", 0), ("GUITAR", "So", 0), ("MUSICAL KEYBOARD", "So", 0), ("TRUMPET", "So", 0), ("VIOLIN", "So", 0), ("MUSICAL SCORE", "So", 0), ("RUNNING SHIRT WITH SASH", "So", 0), ("TENNIS RACQUET AND BALL", "So", 0), ("SKI AND SKI BOOT", "So", 0), ("BASKETBALL AND HOOP", "So", 0), ("CHEQUERED FLAG", "So", 0), ("SNOWBOARDER", "So", 0), ("RUNNER", "So", 0), ("SURFER", "So", 0), ("SPORTS MEDAL", "So", 0), ("TROPHY", "So", 0), ("HORSE RACING", "So", 0), ("AMERICAN FOOTBALL", "So", 0), ("RUGBY FOOTBALL", "So", 0), ("SWIMMER", "So", 0), ("WEIGHT LIFTER", "So", 0), ("GOLFER", "So", 0), ("RACING MOTORCYCLE", "So", 0), ("RACING CAR", "So", 0), ("CRICKET BAT AND BALL", "So", 0), ("VOLLEYBALL", "So", 0), ("FIELD HOCKEY STICK AND BALL", "So", 0), ("ICE HOCKEY STICK AND PUCK", "So", 0), ("TABLE TENNIS PADDLE AND BALL", "So", 0), ("SNOW CAPPED MOUNTAIN", "So", 0), ("CAMPING", "So", 0), ("BEACH WITH UMBRELLA", "So", 0), ("BUILDING CONSTRUCTION", "So", 0), ("HOUSE BUILDINGS", "So", 0), ("CITYSCAPE", "So", 0), ("DERELICT HOUSE BUILDING", "So", 0), ("CLASSICAL BUILDING", "So", 0), ("DESERT", "So", 0), ("DESERT ISLAND", "So", 0), ("NATIONAL PARK", "So", 0), ("STADIUM", "So", 0), ("HOUSE BUILDING", "So", 0), ("HOUSE WITH GARDEN", "So", 0), ("OFFICE BUILDING", "So", 0), ("JAPANESE POST OFFICE", "So", 0), ("EUROPEAN POST OFFICE", "So", 0), ("HOSPITAL", "So", 0), ("BANK", "So", 0), ("AUTOMATED TELLER MACHINE", "So", 0), ("HOTEL", "So", 0), ("LOVE HOTEL", "So", 0), ("CONVENIENCE STORE", "So", 0), ("SCHOOL", "So", 0), ("DEPARTMENT STORE", "So", 0), ("FACTORY", "So", 0), ("<NAME>", "So", 0), ("JAPANESE CASTLE", "So", 0), ("EUROPEAN CASTLE", "So", 0), ("WHITE PENNANT", "So", 0), ("BLACK PENNANT", "So", 0), ("WAVING WHITE FLAG", "So", 0), ("WAVING BLACK FLAG", "So", 0), ("ROSETTE", "So", 0), ("BLACK ROSETTE", "So", 0), ("LABEL", "So", 0), ("BADMINTON RACQUET AND SHUTTLECOCK", "So", 0), ("BOW AND ARROW", "So", 0), ("AMPHORA", "So", 0), ("EMOJI MODIFIER FITZPATRICK TYPE-1-2", "Sk", 0), ("EMOJI MODIFIER FITZPATRICK TYPE-3", "Sk", 0), ("EMOJI MODIFIER FITZPATRICK TYPE-4", "Sk", 0), ("EMOJI MODIFIER FITZPATRICK TYPE-5", "Sk", 0), ("EMOJI MODIFIER FITZPATRICK TYPE-6", "Sk", 0), ("RAT", "So", 0), ("MOUSE", "So", 0), ("OX", "So", 0), ("WATER BUFFALO", "So", 0), ("COW", "So", 0), ("TIGER", "So", 0), ("LEOPARD", "So", 0), ("RABBIT", "So", 0), ("CAT", "So", 0), ("DRAGON", "So", 0), ("CROCODILE", "So", 0), ("WHALE", "So", 0), ("SNAIL", "So", 0), ("SNAKE", "So", 0), ("HORSE", "So", 0), ("RAM", "So", 0), ("GOAT", "So", 0), ("SHEEP", "So", 0), ("MONKEY", "So", 0), ("ROOSTER", "So", 0), ("CHICKEN", "So", 0), ("DOG", "So", 0), ("PIG", "So", 0), ("BOAR", "So", 0), ("ELEPHANT", "So", 0), ("OCTOPUS", "So", 0), ("SPIRAL SHELL", "So", 0), ("BUG", "So", 0), ("ANT", "So", 0), ("HONEYBEE", "So", 0), ("LADY BEETLE", "So", 0), ("FISH", "So", 0), ("TROPICAL FISH", "So", 0), ("BLOWFISH", "So", 0), ("TURTLE", "So", 0), ("HATCHING CHICK", "So", 0), ("BABY CHICK", "So", 0), ("FRONT-FACING BABY CHICK", "So", 0), ("BIRD", "So", 0), ("PENGUIN", "So", 0), ("KOALA", "So", 0), ("POODLE", "So", 0), ("DROMEDARY CAMEL", "So", 0), ("<NAME>", "So", 0), ("DOLPHIN", "So", 0), ("MOUSE FACE", "So", 0), ("COW FACE", "So", 0), ("TIGER FACE", "So", 0), ("RABBIT FACE", "So", 0), ("CAT FACE", "So", 0), ("DRAGON FACE", "So", 0), ("SPOUTING WHALE", "So", 0), ("HORSE FACE", "So", 0), ("MONKEY FACE", "So", 0), ("DOG FACE", "So", 0), ("PIG FACE", "So", 0), ("FROG FACE", "So", 0), ("HAMSTER FACE", "So", 0), ("WOLF FACE", "So", 0), ("BEAR FACE", "So", 0), ("PANDA FACE", "So", 0), ("PIG NOSE", "So", 0), ("PAW PRINTS", "So", 0), ("CHIPMUNK", "So", 0), ("EYES", "So", 0), ("EYE", "So", 0), ("EAR", "So", 0), ("NOSE", "So", 0), ("MOUTH", "So", 0), ("TONGUE", "So", 0), ("WHITE UP POINTING BACKHAND INDEX", "So", 0), ("WHITE DOWN POINTING BACKHAND INDEX", "So", 0), ("WHITE LEFT POINTING BACKHAND INDEX", "So", 0), ("WHITE RIGHT POINTING BACKHAND INDEX", "So", 0), ("FISTED HAND SIGN", "So", 0), ("WAVING HAND SIGN", "So", 0), ("OK HAND SIGN", "So", 0), ("THUMBS UP SIGN", "So", 0), ("THUMBS DOWN SIGN", "So", 0), ("CLAPPING HANDS SIGN", "So", 0), ("OPEN HANDS SIGN", "So", 0), ("CROWN", "So", 0), ("<NAME>", "So", 0), ("EYEGLASSES", "So", 0), ("NECKTIE", "So", 0), ("T-SHIRT", "So", 0), ("JEANS", "So", 0), ("DRESS", "So", 0), ("KIMONO", "So", 0), ("BIKINI", "So", 0), ("<NAME>", "So", 0), ("PURSE", "So", 0), ("HANDBAG", "So", 0), ("POUCH", "So", 0), ("<NAME>", "So", 0), ("<NAME>", "So", 0), ("HIGH-HEELED SHOE", "So", 0), ("<NAME>", "So", 0), ("<NAME>", "So", 0), ("FOOTPRINTS", "So", 0), ("BUST IN SILHOUETTE", "So", 0), ("BUSTS IN SILHOUETTE", "So", 0), ("BOY", "So", 0), ("GIRL", "So", 0), ("MAN", "So", 0), ("WOMAN", "So", 0), ("FAMILY", "So", 0), ("MAN AND WOMAN HOLDING HANDS", "So", 0), ("TWO MEN HOLDING HANDS", "So", 0), ("TWO WOMEN HOLDING HANDS", "So", 0), ("POLICE OFFICER", "So", 0), ("WOMAN WITH BUNNY EARS", "So", 0), ("BRIDE WITH VEIL", "So", 0), ("PERSON WITH BLOND HAIR", "So", 0), ("MAN WITH G<NAME>", "So", 0), ("MAN WITH TURBAN", "So", 0), ("<NAME>", "So", 0), ("<NAME>", "So", 0), ("BABY", "So", 0), ("CONSTR<NAME>ER", "So", 0), ("PRINCESS", "So", 0), ("<NAME>", "So", 0), ("<NAME>", "So", 0), ("GHOST", "So", 0), ("<NAME>", "So", 0), ("EXTRATERRESTR<NAME>", "So", 0), ("<NAME>", "So", 0), ("IMP", "So", 0), ("SKULL", "So", 0), ("INFORMATION DESK PERSON", "So", 0), ("GUARDSMAN", "So", 0), ("DANCER", "So", 0), ("LIPSTICK", "So", 0), ("<NAME>", "So", 0), ("FACE MASSAGE", "So", 0), ("HAIRCUT", "So", 0), ("<NAME>", "So", 0), ("SYRINGE", "So", 0), ("PILL", "So", 0), ("<NAME>", "So", 0), ("LOVE LETTER", "So", 0), ("RING", "So", 0), ("<NAME>", "So", 0), ("KISS", "So", 0), ("BOUQUET", "So", 0), ("COUPLE WITH HEART", "So", 0), ("WEDDING", "So", 0), ("BEATING HEART", "So", 0), ("BROKEN HEART", "So", 0), ("TWO HEARTS", "So", 0), ("SPARKLING HEART", "So", 0), ("GROWING HEART", "So", 0), ("HEART WITH ARROW", "So", 0), ("BLUE HEART", "So", 0), ("GREEN HEART", "So", 0), ("YELLOW HEART", "So", 0), ("PURPLE HEART", "So", 0), ("HEART WITH RIBBON", "So", 0), ("REVOLVING HEARTS", "So", 0), ("HEART DECORATION", "So", 0), ("DIAMOND SHAPE WITH A DOT INSIDE", "So", 0), ("ELECTRIC LIGHT BULB", "So", 0), ("ANGER SYMBOL", "So", 0), ("BOMB", "So", 0), ("SLEEPING SYMBOL", "So", 0), ("COLLISION SYMBOL", "So", 0), ("SPLASHING SWEAT SYMBOL", "So", 0), ("DROPLET", "So", 0), ("DASH SYMBOL", "So", 0), ("PILE OF POO", "So", 0), ("FLEXED BICEPS", "So", 0), ("DIZZY SYMBOL", "So", 0), ("SPEECH BALLOON", "So", 0), ("THOUGHT BALLOON", "So", 0), ("WHITE FLOWER", "So", 0), ("HUNDRED POINTS SYMBOL", "So", 0), ("MONEY BAG", "So", 0), ("CURRENCY EXCHANGE", "So", 0), ("HEAVY DOLLAR SIGN", "So", 0), ("CREDIT CARD", "So", 0), ("BANKNOTE WITH YEN SIGN", "So", 0), ("BANKNOTE WITH DOLLAR SIGN", "So", 0), ("BANKNOTE WITH EURO SIGN", "So", 0), ("BANKNOTE WITH POUND SIGN", "So", 0), ("MONEY WITH WINGS", "So", 0), ("CHART WITH UPWARDS TREND AND YEN SIGN", "So", 0), ("SEAT", "So", 0), ("PERSONAL COMPUTER", "So", 0), ("BRIEFCASE", "So", 0), ("MINIDISC", "So", 0), ("FLOPPY DISK", "So", 0), ("OPTICAL DISC", "So", 0), ("DVD", "So", 0), ("FILE FOLDER", "So", 0), ("OPEN FILE FOLDER", "So", 0), ("PAGE WITH CURL", "So", 0), ("PAGE FACING UP", "So", 0), ("CALENDAR", "So", 0), ("TEAR-OFF CALENDAR", "So", 0), ("CARD INDEX", "So", 0), ("CHART WITH UPWARDS TREND", "So", 0), ("CHART WITH DOWNWARDS TREND", "So", 0), ("BAR CHART", "So", 0), ("CLIPBOARD", "So", 0), ("PUSHPIN", "So", 0), ("ROUND PUSHPIN", "So", 0), ("PAPERCLIP", "So", 0), ("STRAIGHT RULER", "So", 0), ("TRIANGULAR RULER", "So", 0), ("BOOKMARK TABS", "So", 0), ("LEDGER", "So", 0), ("NOTEBOOK", "So", 0), ("NOTEBOOK WITH DECORATIVE COVER", "So", 0), ("CLOSED BOOK", "So", 0), ("OPEN BOOK", "So", 0), ("GREEN BOOK", "So", 0), ("BLUE BOOK", "So", 0), ("ORANGE BOOK", "So", 0), ("BOOKS", "So", 0), ("NAME BADGE", "So", 0), ("SCROLL", "So", 0), ("MEMO", "So", 0), ("TELEPHONE RECEIVER", "So", 0), ("PAGER", "So", 0), ("FAX MACHINE", "So", 0), ("SATELLITE ANTENNA", "So", 0), ("PUBLIC ADDRESS LOUDSPEAKER", "So", 0), ("CHEERING MEGAPHONE", "So", 0), ("OUTBOX TRAY", "So", 0), ("INBOX TRAY", "So", 0), ("PACKAGE", "So", 0), ("E-MAIL SYMBOL", "So", 0), ("INCOMING ENVELOPE", "So", 0), ("ENVELOPE WITH DOWNWARDS ARROW ABOVE", "So", 0), ("CLOSED MAILBOX WITH LOWERED FLAG", "So", 0), ("CLOSED MAILBOX WITH RAISED FLAG", "So", 0), ("OPEN MAILBOX WITH RAISED FLAG", "So", 0), ("OPEN MAILBOX WITH LOWERED FLAG", "So", 0), ("POSTBOX", "So", 0), ("POSTAL HORN", "So", 0), ("NEWSPAPER", "So", 0), ("MOBILE PHONE", "So", 0), ("MOBILE PHONE WITH RIGHTWARDS ARROW AT LEFT", "So", 0), ("VIBRATION MODE", "So", 0), ("MOBILE PHONE OFF", "So", 0), ("NO MOBILE PHONES", "So", 0), ("ANTENNA WITH BARS", "So", 0), ("CAMERA", "So", 0), ("CAMERA WITH FLASH", "So", 0), ("VIDEO CAMERA", "So", 0), ("TELEVISION", "So", 0), ("RADIO", "So", 0), ("VIDEOCASSETTE", "So", 0), ("FILM PROJECTOR", "So", 0), ("PORTABLE STEREO", "So", 0), ("PRAYER BEADS", "So", 0), ("TWISTED RIGHTWARDS ARROWS", "So", 0), ("CLOCKWISE RIGHTWARDS AND LEFTWARDS OPEN CIRCLE ARROWS", "So", 0), ("CLOCKWISE RIGHTWARDS AND LEFTWARDS OPEN CIRCLE ARROWS WITH CIRCLED ONE OVERLAY", "So", 0), ("CLOCKWISE DOWNWARDS AND UPWARDS OPEN CIRCLE ARROWS", "So", 0), ("ANTICLOCKWISE DOWNWARDS AND UPWARDS OPEN CIRCLE ARROWS", "So", 0), ("LOW BRIGHTNESS SYMBOL", "So", 0), ("HIGH BRIGHTNESS SYMBOL", "So", 0), ("SPEAKER WITH CANCELLATION STROKE", "So", 0), ("SPEAKER", "So", 0), ("SPEAKER WITH ONE SOUND WAVE", "So", 0), ("SPEAKER WITH THREE SOUND WAVES", "So", 0), ("BATTERY", "So", 0), ("ELECTRIC PLUG", "So", 0), ("LEFT-POINTING MAGNIFYING GLASS", "So", 0), ("RIGHT-POINTING MAGNIFYING GLASS", "So", 0), ("LOCK WITH INK PEN", "So", 0), ("CLOSED LOCK WITH KEY", "So", 0), ("KEY", "So", 0), ("LOCK", "So", 0), ("OPEN LOCK", "So", 0), ("BELL", "So", 0), ("BELL WITH CANCELLATION STROKE", "So", 0), ("BOOKMARK", "So", 0), ("LINK SYMBOL", "So", 0), ("RADIO BUTTON", "So", 0), ("BACK WITH LEFTWARDS ARROW ABOVE", "So", 0), ("END WITH LEFTWARDS ARROW ABOVE", "So", 0), ("ON WITH EXCLAMATION MARK WITH LEFT RIGHT ARROW ABOVE", "So", 0), ("SOON WITH RIGHTWARDS ARROW ABOVE", "So", 0), ("TOP WITH UPWARDS ARROW ABOVE", "So", 0), ("NO ONE UNDER EIGHTEEN SYMBOL", "So", 0), ("KEYCAP TEN", "So", 0), ("INPUT SYMBOL FOR LATIN CAPITAL LETTERS", "So", 0), ("INPUT SYMBOL FOR LATIN SMALL LETTERS", "So", 0), ("INPUT SYMBOL FOR NUMBERS", "So", 0), ("INPUT SYMBOL FOR SYMBOLS", "So", 0), ("INPUT SYMBOL FOR LATIN LETTERS", "So", 0), ("FIRE", "So", 0), ("ELECTRIC TORCH", "So", 0), ("WRENCH", "So", 0), ("HAMMER", "So", 0), ("NUT AND BOLT", "So", 0), ("HOCHO", "So", 0), ("PISTOL", "So", 0), ("MICROSCOPE", "So", 0), ("TELESCOPE", "So", 0), ("CRYSTAL BALL", "So", 0), ("SIX POINTED STAR WITH MIDDLE DOT", "So", 0), ("JAPANESE SYMBOL FOR BEGINNER", "So", 0), ("TRIDENT EMBLEM", "So", 0), ("BLACK SQUARE BUTTON", "So", 0), ("WHITE SQUARE BUTTON", "So", 0), ("LARGE RED CIRCLE", "So", 0), ("LARGE BLUE CIRCLE", "So", 0), ("LARGE ORANGE DIAMOND", "So", 0), ("LARGE BLUE DIAMOND", "So", 0), ("SMALL ORANGE DIAMOND", "So", 0), ("SMALL BLUE DIAMOND", "So", 0), ("UP-POINTING RED TRIANGLE", "So", 0), ("DOWN-POINTING RED TRIANGLE", "So", 0), ("UP-POINTING SMALL RED TRIANGLE", "So", 0), ("DOWN-POINTING SMALL RED TRIANGLE", "So", 0), ("LOWER RIGHT SHADOWED WHITE CIRCLE", "So", 0), ("UPPER RIGHT SHADOWED WHITE CIRCLE", "So", 0), ("CIRCLED CROSS POMMEE", "So", 0), ("CROSS POMMEE WITH HALF-CIRCLE BELOW", "So", 0), ("CROSS POMMEE", "So", 0), ("NOTCHED LEFT SEMICIRCLE WITH THREE DOTS", "So", 0), ("NOTCHED RIGHT SEMICIRCLE WITH THREE DOTS", "So", 0), ("SYMBOL FOR MARKS CHAPTER", "So", 0), ("WHITE LATIN CROSS", "So", 0), ("HEAVY LATIN CROSS", "So", 0), ("CELTIC CROSS", "So", 0), ("OM SYMBOL", "So", 0), ("DOVE OF PEACE", "So", 0), ("KAABA", "So", 0), ("MOSQUE", "So", 0), ("SYNAGOGUE", "So", 0), ("MENORAH WITH NINE BRANCHES", "So", 0), ("BOWL OF HYGIEIA", "So", 0), ("CLOCK FACE ONE OCLOCK", "So", 0), ("CLOCK FACE TWO OCLOCK", "So", 0), ("CLOCK FACE THREE OCLOCK", "So", 0), ("CLOCK FACE FOUR OCLOCK", "So", 0), ("CLOCK FACE FIVE OCLOCK", "So", 0), ("CLOCK FACE SIX OCLOCK", "So", 0), ("CLOCK FACE SEVEN OCLOCK", "So", 0), ("CLOCK FACE EIGHT OCLOCK", "So", 0), ("CLOCK FACE NINE OCLOCK", "So", 0), ("CLOCK FACE TEN OCLOCK", "So", 0), ("CLOCK FACE ELEVEN OCLOCK", "So", 0), ("CLOCK FACE TWELVE OCLOCK", "So", 0), ("CLOCK FACE ONE-THIRTY", "So", 0), ("CLOCK FACE TWO-THIRTY", "So", 0), ("CLOCK FACE THREE-THIRTY", "So", 0), ("CLOCK FACE FOUR-THIRTY", "So", 0), ("CLOCK FACE FIVE-THIRTY", "So", 0), ("CLOCK FACE SIX-THIRTY", "So", 0), ("CLOCK FACE SEVEN-THIRTY", "So", 0), ("CLOCK FACE EIGHT-THIRTY", "So", 0), ("CLOCK FACE NINE-THIRTY", "So", 0), ("CLOCK FACE TEN-THIRTY", "So", 0), ("CLOCK FACE ELEVEN-THIRTY", "So", 0), ("CLOCK FACE TWELVE-THIRTY", "So", 0), ("RIGHT SPEAKER", "So", 0), ("RIGHT SPEAKER WITH ONE SOUND WAVE", "So", 0), ("RIGHT SPEAKER WITH THREE SOUND WAVES", "So", 0), ("BULLHORN", "So", 0), ("BULLHORN WITH SOUND WAVES", "So", 0), ("RINGING BELL", "So", 0), ("BOOK", "So", 0), ("CANDLE", "So", 0), ("MANTELPIECE CLOCK", "So", 0), ("BLACK SKULL AND CROSSBONES", "So", 0), ("NO PIRACY", "So", 0), ("HOLE", "So", 0), ("MAN IN BUSINESS SUIT LEVITATING", "So", 0), ("SLEUTH OR SPY", "So", 0), ("DARK SUNGLASSES", "So", 0), ("SPIDER", "So", 0), ("SPIDER WEB", "So", 0), ("JOYSTICK", "So", 0), ("MAN DANCING", "So", 0), ("LEFT HAND TELEPHONE RECEIVER", "So", 0), ("TELEPHONE RECEIVER WITH PAGE", "So", 0), ("RIGHT HAND TELEPHONE RECEIVER", "So", 0), ("WHITE TOUCHTONE TELEPHONE", "So", 0), ("BLACK TOUCHTONE TELEPHONE", "So", 0), ("TELEPHONE ON TOP OF MODEM", "So", 0), ("CLAMSHELL MOBILE PHONE", "So", 0), ("BACK OF ENVELOPE", "So", 0), ("STAMPED ENVELOPE", "So", 0), ("ENVELOPE WITH LIGHTNING", "So", 0), ("FLYING ENVELOPE", "So", 0), ("PEN OVER STAMPED ENVELOPE", "So", 0), ("LINKED PAPERCLIPS", "So", 0), ("BLACK PUSHPIN", "So", 0), ("LOWER LEFT PENCIL", "So", 0), ("LOWER LEFT BALLPOINT PEN", "So", 0), ("LOWER LEFT FOUNTAIN PEN", "So", 0), ("LOWER LEFT PAINTBRUSH", "So", 0), ("LOWER LEFT CRAYON", "So", 0), ("LEFT WRITING HAND", "So", 0), ("TURNED OK HAND SIGN", "So", 0), ("RAISED HAND WITH FINGERS SPLAYED", "So", 0), ("REVERSED RAISED HAND WITH FINGERS SPLAYED", "So", 0), ("REVERSED THUMBS UP SIGN", "So", 0), ("REVERSED THUMBS DOWN SIGN", "So", 0), ("REVERSED VICTORY HAND", "So", 0), ("REVERSED HAND WITH MIDDLE FINGER EXTENDED", "So", 0), ("RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS", "So", 0), ("WHITE DOWN POINTING LEFT HAND INDEX", "So", 0), ("SIDEWAYS WHITE LEFT POINTING INDEX", "So", 0), ("SIDEWAYS WHITE RIGHT POINTING INDEX", "So", 0), ("SIDEWAYS BLACK LEFT POINTING INDEX", "So", 0), ("SIDEWAYS BLACK RIGHT POINTING INDEX", "So", 0), ("BLACK LEFT POINTING BACKHAND INDEX", "So", 0), ("BLACK RIGHT POINTING BACKHAND INDEX", "So", 0), ("SIDEWAYS WHITE UP POINTING INDEX", "So", 0), ("SIDEWAYS WHITE DOWN POINTING INDEX", "So", 0), ("SIDEWAYS BLACK UP POINTING INDEX", "So", 0), ("SIDEWAYS BLACK DOWN POINTING INDEX", "So", 0), ("BLACK UP POINTING BACKHAND INDEX", "So", 0), ("BLACK DOWN POINTING BACKHAND INDEX", "So", 0), ("BLACK HEART", "So", 0), ("DESKTOP COMPUTER", "So", 0), ("KEYBOARD AND MOUSE", "So", 0), ("THREE NETWORKED COMPUTERS", "So", 0), ("PRINTER", "So", 0), ("POCKET CALCULATOR", "So", 0), ("BLACK HARD SHELL FLOPPY DISK", "So", 0), ("WHITE HARD SHELL FLOPPY DISK", "So", 0), ("SOFT SHELL FLOPPY DISK", "So", 0), ("TAPE CARTRIDGE", "So", 0), ("WIRED KEYBOARD", "So", 0), ("ONE BUTTON MOUSE", "So", 0), ("TWO BUTTON MOUSE", "So", 0), ("THREE BUTTON MOUSE", "So", 0), ("TRACKBALL", "So", 0), ("OLD PERSONAL COMPUTER", "So", 0), ("HARD DISK", "So", 0), ("SCREEN", "So", 0), ("PRINTER ICON", "So", 0), ("FAX ICON", "So", 0), ("OPTICAL DISC ICON", "So", 0), ("DOCUMENT WITH TEXT", "So", 0), ("DOCUMENT WITH TEXT AND PICTURE", "So", 0), ("DOCUMENT WITH PICTURE", "So", 0), ("FRAME WITH PICTURE", "So", 0), ("FRAME WITH TILES", "So", 0), ("FRAME WITH AN X", "So", 0), ("BLACK FOLDER", "So", 0), ("FOLDER", "So", 0), ("OPEN FOLDER", "So", 0), ("CARD INDEX DIVIDERS", "So", 0), ("CARD FILE BOX", "So", 0), ("FILE CABINET", "So", 0), ("EMPTY NOTE", "So", 0), ("EMPTY NOTE PAGE", "So", 0), ("EMPTY NOTE PAD", "So", 0), ("NOTE", "So", 0), ("NOTE PAGE", "So", 0), ("NOTE PAD", "So", 0), ("EMPTY DOCUMENT", "So", 0), ("EMPTY PAGE", "So", 0), ("EMPTY PAGES", "So", 0), ("DOCUMENT", "So", 0), ("PAGE", "So", 0), ("PAGES", "So", 0), ("WASTEBASKET", "So", 0), ("SPIRAL NOTE PAD", "So", 0), ("SPIRAL CALENDAR PAD", "So", 0), ("DESKTOP WINDOW", "So", 0), ("MINIMIZE", "So", 0), ("MAXIMIZE", "So", 0), ("OVERLAP", "So", 0), ("CLOCKWISE RIGHT AND LEFT SEMICIRCLE ARROWS", "So", 0), ("CANCELLATION X", "So", 0), ("INCREASE FONT SIZE SYMBOL", "So", 0), ("DECREASE FONT SIZE SYMBOL", "So", 0), ("COMPRESSION", "So", 0), ("OLD KEY", "So", 0), ("ROLLED-UP NEWSPAPER", "So", 0), ("PAGE WITH CIRCLED TEXT", "So", 0), ("STOCK CHART", "So", 0), ("DAGGER KNIFE", "So", 0), ("LIPS", "So", 0), ("SPEAKING HEAD IN SILHOUETTE", "So", 0), ("THREE RAYS ABOVE", "So", 0), ("THREE RAYS BELOW", "So", 0), ("THREE RAYS LEFT", "So", 0), ("THREE RAYS RIGHT", "So", 0), ("LEFT SPEECH BUBBLE", "So", 0), ("RIGHT SPEECH BUBBLE", "So", 0), ("TWO SPEECH BUBBLES", "So", 0), ("THREE SPEECH BUBBLES", "So", 0), ("LEFT THOUGHT BUBBLE", "So", 0), ("RIGHT THOUGHT BUBBLE", "So", 0), ("LEFT ANGER BUBBLE", "So", 0), ("RIGHT ANGER BUBBLE", "So", 0), ("MOOD BUBBLE", "So", 0), ("LIGHTNING MOOD BUBBLE", "So", 0), ("LIGHTNING MOOD", "So", 0), ("BALLOT BOX WITH BALLOT", "So", 0), ("BALLOT SCRIPT X", "So", 0), ("BALLOT BOX WITH SCRIPT X", "So", 0), ("BALLOT BOLD SCRIPT X", "So", 0), ("BALLOT BOX WITH BOLD SCRIPT X", "So", 0), ("LIGHT CHECK MARK", "So", 0), ("BALLOT BOX WITH BOLD CHECK", "So", 0), ("WORLD MAP", "So", 0), ("MOUNT FUJI", "So", 0), ("TOKYO TOWER", "So", 0), ("STATUE OF LIBERTY", "So", 0), ("SILHOUETTE OF JAPAN", "So", 0), ("MOYAI", "So", 0), )
https://github.com/Edubmstr/typst_public
https://raw.githubusercontent.com/Edubmstr/typst_public/main/supercharged-dhbw1/main.typ
typst
#import "@preview/supercharged-dhbw:2.1.0": * #import "acronyms.typ": acronyms #show: supercharged-dhbw.with( title: "Erstellung einer Applikation zur Verwaltung von Enterprise Architecture Engagements in der Cloud Transformation Advisory", type-of-degree-specification: "Sales & Consulting", time-of-thesis: "29.07.2024 - 18.11.2024", authors: (( name: "<NAME>", student-id: "3468097", course: "WWI23SCB", course-advisor: "Prof. Dr. <NAME>", course-of-studies: "Wirtschaftsinformatik", company: (( name: "SAP SE", address: "Dietmar-Hopp-Allee 16", city: "69190 Walldorf") )), ), acronyms: acronyms, // displays the acronyms defined in the acronyms dictionary at-university: false, // if true the company name on the title page and the confidentiality statement are hidden bibliography: bibliography("sources.bib"), date: datetime.today(), language: "de", // en, de supervisor: ( company: ( name: "<NAME>", mail-address: "<EMAIL>", phone-number: "+491708555565"), university: ( name: "T.B.A.", mail-address: "T.B.A", phone-number: "T.B.A") ), university: "Duale Hochschule Baden-Württemberg", university-location: "Mannheim", // for more options check the package documentation (https://typst.app/universe/package/supercharged-dhbw) ) // Edit this content to your liking = Einleitung == Motivation & Problemstellung == Ziel und Gang = Theoretische Grundlage == Enterprise Architecture === TOGAF == Microsoft Power Platform === Microsoft Power Apps = Methodik == Anforderungsanalyse === Semistrukturierte Leitfadeninterviews === Fokusgruppeninterview === Brainstorming == inkrementelle Entwicklung mit XP = Anforderungsanalyse == Durchführung der Interviews === Leitfadeninterviews === Fokusgruppeninterviews == Architektur der Applikation = Entwicklung der Applikation == Festlegung der Increments == Praktische Umsetzung == Review & Feedback aus der Abteilung = Zusammenfassung == Fazit == Ausblick = Examples #lorem(30) == Acronyms Use the `acr` function to insert acronyms, which looks like this #acr("HTTP"). #acrlpl("API") are used to define the interaction between different software systems. #acrs("REST") is an architectural style for networked applications. == Lists Create bullet lists or numbered lists. - These bullet - points - are colored + It also + works with + numbered lists! == Figures and Tables Create figures or tables like this: === Figures #figure(caption: "Image Example", image(width: 4cm, "assets/ts.svg")) === Tables #figure(caption: "Table Example", table( columns: (1fr, auto, auto), inset: 10pt, align: horizon, table.header( [], [*Area*], [*Parameters*], ), text("cylinder.svg"), $ pi h (D^2 - d^2) / 4 $, [ $h$: height \ $D$: outer radius \ $d$: inner radius ], text("tetrahedron.svg"), $ sqrt(2) / 12 a^3 $, [$a$: edge length] ))<table> == Code Snippets Insert code snippets like this: #figure(caption: "Codeblock Example", 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. ```]) == References Cite like this #cite(form: "prose", <iso18004>). Or like this @iso18004. You can also reference by adding `<ref>` with the desired name after figures or headings. For example this @table references the table on the previous page. You can also generate footnotes #footnote[https://typst.app/docs/reference/model/footnote/] using #footnote [Text] = Conclusion #lorem(100) #lorem(120) #lorem(80)
https://github.com/frectonz/the-pg-book
https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/149.%20startupideas.html.typ
typst
startupideas.html How to Get Startup Ideas Want to start a startup? Get funded by Y Combinator. November 2012The way to get startup ideas is not to try to think of startup ideas. It's to look for problems, preferably problems you have yourself.The very best startup ideas tend to have three things in common: they're something the founders themselves want, that they themselves can build, and that few others realize are worth doing. Microsoft, Apple, Yahoo, Google, and Facebook all began this way. ProblemsWhy is it so important to work on a problem you have? Among other things, it ensures the problem really exists. It sounds obvious to say you should only work on problems that exist. And yet by far the most common mistake startups make is to solve problems no one has.I made it myself. In 1995 I started a company to put art galleries online. But galleries didn't want to be online. It's not how the art business works. So why did I spend 6 months working on this stupid idea? Because I didn't pay attention to users. I invented a model of the world that didn't correspond to reality, and worked from that. I didn't notice my model was wrong until I tried to convince users to pay for what we'd built. Even then I took embarrassingly long to catch on. I was attached to my model of the world, and I'd spent a lot of time on the software. They had to want it!Why do so many founders build things no one wants? Because they begin by trying to think of startup ideas. That m.o. is doubly dangerous: it doesn't merely yield few good ideas; it yields bad ideas that sound plausible enough to fool you into working on them.At YC we call these "made-up" or "sitcom" startup ideas. Imagine one of the characters on a TV show was starting a startup. The writers would have to invent something for it to do. But coming up with good startup ideas is hard. It's not something you can do for the asking. So (unless they got amazingly lucky) the writers would come up with an idea that sounded plausible, but was actually bad.For example, a social network for pet owners. It doesn't sound obviously mistaken. Millions of people have pets. Often they care a lot about their pets and spend a lot of money on them. Surely many of these people would like a site where they could talk to other pet owners. Not all of them perhaps, but if just 2 or 3 percent were regular visitors, you could have millions of users. You could serve them targeted offers, and maybe charge for premium features. [1]The danger of an idea like this is that when you run it by your friends with pets, they don't say "I would never use this." They say "Yeah, maybe I could see using something like that." Even when the startup launches, it will sound plausible to a lot of people. They don't want to use it themselves, at least not right now, but they could imagine other people wanting it. Sum that reaction across the entire population, and you have zero users. [2] WellWhen a startup launches, there have to be at least some users who really need what they're making — not just people who could see themselves using it one day, but who want it urgently. Usually this initial group of users is small, for the simple reason that if there were something that large numbers of people urgently needed and that could be built with the amount of effort a startup usually puts into a version one, it would probably already exist. Which means you have to compromise on one dimension: you can either build something a large number of people want a small amount, or something a small number of people want a large amount. Choose the latter. Not all ideas of that type are good startup ideas, but nearly all good startup ideas are of that type.Imagine a graph whose x axis represents all the people who might want what you're making and whose y axis represents how much they want it. If you invert the scale on the y axis, you can envision companies as holes. Google is an immense crater: hundreds of millions of people use it, and they need it a lot. A startup just starting out can't expect to excavate that much volume. So you have two choices about the shape of hole you start with. You can either dig a hole that's broad but shallow, or one that's narrow and deep, like a well.Made-up startup ideas are usually of the first type. Lots of people are mildly interested in a social network for pet owners.Nearly all good startup ideas are of the second type. Microsoft was a well when they made Altair Basic. There were only a couple thousand Altair owners, but without this software they were programming in machine language. Thirty years later Facebook had the same shape. Their first site was exclusively for Harvard students, of which there are only a few thousand, but those few thousand users wanted it a lot.When you have an idea for a startup, ask yourself: who wants this right now? Who wants this so much that they'll use it even when it's a crappy version one made by a two-person startup they've never heard of? If you can't answer that, the idea is probably bad. [3]You don't need the narrowness of the well per se. It's depth you need; you get narrowness as a byproduct of optimizing for depth (and speed). But you almost always do get it. In practice the link between depth and narrowness is so strong that it's a good sign when you know that an idea will appeal strongly to a specific group or type of user.But while demand shaped like a well is almost a necessary condition for a good startup idea, it's not a sufficient one. If <NAME> had built something that could only ever have appealed to Harvard students, it would not have been a good startup idea. Facebook was a good idea because it started with a small market there was a fast path out of. Colleges are similar enough that if you build a facebook that works at Harvard, it will work at any college. So you spread rapidly through all the colleges. Once you have all the college students, you get everyone else simply by letting them in.Similarly for Microsoft: Basic for the Altair; Basic for other machines; other languages besides Basic; operating systems; applications; IPO. SelfHow do you tell whether there's a path out of an idea? How do you tell whether something is the germ of a giant company, or just a niche product? Often you can't. The founders of Airbnb didn't realize at first how big a market they were tapping. Initially they had a much narrower idea. They were going to let hosts rent out space on their floors during conventions. They didn't foresee the expansion of this idea; it forced itself upon them gradually. All they knew at first is that they were onto something. That's probably as much as <NAME> or <NAME> knew at first.Occasionally it's obvious from the beginning when there's a path out of the initial niche. And sometimes I can see a path that's not immediately obvious; that's one of our specialties at YC. But there are limits to how well this can be done, no matter how much experience you have. The most important thing to understand about paths out of the initial idea is the meta-fact that these are hard to see.So if you can't predict whether there's a path out of an idea, how do you choose between ideas? The truth is disappointing but interesting: if you're the right sort of person, you have the right sort of hunches. If you're at the leading edge of a field that's changing fast, when you have a hunch that something is worth doing, you're more likely to be right.In Zen and the Art of Motorcycle Maintenance, <NAME> says: You want to know how to paint a perfect painting? It's easy. Make yourself perfect and then just paint naturally. I've wondered about that passage since I read it in high school. I'm not sure how useful his advice is for painting specifically, but it fits this situation well. Empirically, the way to have good startup ideas is to become the sort of person who has them.Being at the leading edge of a field doesn't mean you have to be one of the people pushing it forward. You can also be at the leading edge as a user. It was not so much because he was a programmer that Facebook seemed a good idea to <NAME> as because he used computers so much. If you'd asked most 40 year olds in 2004 whether they'd like to publish their lives semi-publicly on the Internet, they'd have been horrified at the idea. But Mark already lived online; to him it seemed natural.<NAME> says that people at the leading edge of a rapidly changing field "live in the future." Combine that with Pirsig and you get: Live in the future, then build what's missing. That describes the way many if not most of the biggest startups got started. Neither Apple nor Yahoo nor Google nor Facebook were even supposed to be companies at first. They grew out of things their founders built because there seemed a gap in the world.If you look at the way successful founders have had their ideas, it's generally the result of some external stimulus hitting a prepared mind. <NAME> and <NAME> hear about the Altair and think "I bet we could write a Basic interpreter for it." <NAME> realizes he's forgotten his USB stick and thinks "I really need to make my files live online." Lots of people heard about the Altair. Lots forgot USB sticks. The reason those stimuli caused those founders to start companies was that their experiences had prepared them to notice the opportunities they represented.The verb you want to be using with respect to startup ideas is not "think up" but "notice." At YC we call ideas that grow naturally out of the founders' own experiences "organic" startup ideas. The most successful startups almost all begin this way.That may not have been what you wanted to hear. You may have expected recipes for coming up with startup ideas, and instead I'm telling you that the key is to have a mind that's prepared in the right way. But disappointing though it may be, this is the truth. And it is a recipe of a sort, just one that in the worst case takes a year rather than a weekend.If you're not at the leading edge of some rapidly changing field, you can get to one. For example, anyone reasonably smart can probably get to an edge of programming (e.g. building mobile apps) in a year. Since a successful startup will consume at least 3-5 years of your life, a year's preparation would be a reasonable investment. Especially if you're also looking for a cofounder. [4]You don't have to learn programming to be at the leading edge of a domain that's changing fast. Other domains change fast. But while learning to hack is not necessary, it is for the forseeable future sufficient. As <NAME> put it, software is eating the world, and this trend has decades left to run.Knowing how to hack also means that when you have ideas, you'll be able to implement them. That's not absolutely necessary (<NAME> couldn't) but it's an advantage. It's a big advantage, when you're considering an idea like putting a college facebook online, if instead of merely thinking "That's an interesting idea," you can think instead "That's an interesting idea. I'll try building an initial version tonight." It's even better when you're both a programmer and the target user, because then the cycle of generating new versions and testing them on users can happen inside one head. NoticingOnce you're living in the future in some respect, the way to notice startup ideas is to look for things that seem to be missing. If you're really at the leading edge of a rapidly changing field, there will be things that are obviously missing. What won't be obvious is that they're startup ideas. So if you want to find startup ideas, don't merely turn on the filter "What's missing?" Also turn off every other filter, particularly "Could this be a big company?" There's plenty of time to apply that test later. But if you're thinking about that initially, it may not only filter out lots of good ideas, but also cause you to focus on bad ones.Most things that are missing will take some time to see. You almost have to trick yourself into seeing the ideas around you.But you know the ideas are out there. This is not one of those problems where there might not be an answer. It's impossibly unlikely that this is the exact moment when technological progress stops. You can be sure people are going to build things in the next few years that will make you think "What did I do before x?"And when these problems get solved, they will probably seem flamingly obvious in retrospect. What you need to do is turn off the filters that usually prevent you from seeing them. The most powerful is simply taking the current state of the world for granted. Even the most radically open-minded of us mostly do that. You couldn't get from your bed to the front door if you stopped to question everything.But if you're looking for startup ideas you can sacrifice some of the efficiency of taking the status quo for granted and start to question things. Why is your inbox overflowing? Because you get a lot of email, or because it's hard to get email out of your inbox? Why do you get so much email? What problems are people trying to solve by sending you email? Are there better ways to solve them? And why is it hard to get emails out of your inbox? Why do you keep emails around after you've read them? Is an inbox the optimal tool for that?Pay particular attention to things that chafe you. The advantage of taking the status quo for granted is not just that it makes life (locally) more efficient, but also that it makes life more tolerable. If you knew about all the things we'll get in the next 50 years but don't have yet, you'd find present day life pretty constraining, just as someone from the present would if they were sent back 50 years in a time machine. When something annoys you, it could be because you're living in the future.When you find the right sort of problem, you should probably be able to describe it as obvious, at least to you. When we started Viaweb, all the online stores were built by hand, by web designers making individual HTML pages. It was obvious to us as programmers that these sites would have to be generated by software. [5]Which means, strangely enough, that coming up with startup ideas is a question of seeing the obvious. That suggests how weird this process is: you're trying to see things that are obvious, and yet that you hadn't seen.Since what you need to do here is loosen up your own mind, it may be best not to make too much of a direct frontal attack on the problem — i.e. to sit down and try to think of ideas. The best plan may be just to keep a background process running, looking for things that seem to be missing. Work on hard problems, driven mainly by curiosity, but have a second self watching over your shoulder, taking note of gaps and anomalies. [6]Give yourself some time. You have a lot of control over the rate at which you turn yours into a prepared mind, but you have less control over the stimuli that spark ideas when they hit it. If <NAME> and <NAME> had constrained themselves to come up with a startup idea in one month, what if they'd chosen a month before the Altair appeared? They probably would have worked on a less promising idea. <NAME> did work on a less promising idea before Dropbox: an SAT prep startup. But Dropbox was a much better idea, both in the absolute sense and also as a match for his skills. [7]A good way to trick yourself into noticing ideas is to work on projects that seem like they'd be cool. If you do that, you'll naturally tend to build things that are missing. It wouldn't seem as interesting to build something that already existed.Just as trying to think up startup ideas tends to produce bad ones, working on things that could be dismissed as "toys" often produces good ones. When something is described as a toy, that means it has everything an idea needs except being important. It's cool; users love it; it just doesn't matter. But if you're living in the future and you build something cool that users love, it may matter more than outsiders think. Microcomputers seemed like toys when Apple and Microsoft started working on them. I'm old enough to remember that era; the usual term for people with their own microcomputers was "hobbyists." BackRub seemed like an inconsequential science project. The Facebook was just a way for undergrads to stalk one another.At YC we're excited when we meet startups working on things that we could imagine know-it-alls on forums dismissing as toys. To us that's positive evidence an idea is good.If you can afford to take a long view (and arguably you can't afford not to), you can turn "Live in the future and build what's missing" into something even better: Live in the future and build what seems interesting. SchoolThat's what I'd advise college students to do, rather than trying to learn about "entrepreneurship." "Entrepreneurship" is something you learn best by doing it. The examples of the most successful founders make that clear. What you should be spending your time on in college is ratcheting yourself into the future. College is an incomparable opportunity to do that. What a waste to sacrifice an opportunity to solve the hard part of starting a startup — becoming the sort of person who can have organic startup ideas — by spending time learning about the easy part. Especially since you won't even really learn about it, any more than you'd learn about sex in a class. All you'll learn is the words for things.The clash of domains is a particularly fruitful source of ideas. If you know a lot about programming and you start learning about some other field, you'll probably see problems that software could solve. In fact, you're doubly likely to find good problems in another domain: (a) the inhabitants of that domain are not as likely as software people to have already solved their problems with software, and (b) since you come into the new domain totally ignorant, you don't even know what the status quo is to take it for granted.So if you're a CS major and you want to start a startup, instead of taking a class on entrepreneurship you're better off taking a class on, say, genetics. Or better still, go work for a biotech company. CS majors normally get summer jobs at computer hardware or software companies. But if you want to find startup ideas, you might do better to get a summer job in some unrelated field. [8]Or don't take any extra classes, and just build things. It's no coincidence that Microsoft and Facebook both got started in January. At Harvard that is (or was) Reading Period, when students have no classes to attend because they're supposed to be studying for finals. [9]But don't feel like you have to build things that will become startups. That's premature optimization. Just build things. Preferably with other students. It's not just the classes that make a university such a good place to crank oneself into the future. You're also surrounded by other people trying to do the same thing. If you work together with them on projects, you'll end up producing not just organic ideas, but organic ideas with organic founding teams — and that, empirically, is the best combination.Beware of research. If an undergrad writes something all his friends start using, it's quite likely to represent a good startup idea. Whereas a PhD dissertation is extremely unlikely to. For some reason, the more a project has to count as research, the less likely it is to be something that could be turned into a startup. [10] I think the reason is that the subset of ideas that count as research is so narrow that it's unlikely that a project that satisfied that constraint would also satisfy the orthogonal constraint of solving users' problems. Whereas when students (or professors) build something as a side-project, they automatically gravitate toward solving users' problems — perhaps even with an additional energy that comes from being freed from the constraints of research. CompetitionBecause a good idea should seem obvious, when you have one you'll tend to feel that you're late. Don't let that deter you. Worrying that you're late is one of the signs of a good idea. Ten minutes of searching the web will usually settle the question. Even if you find someone else working on the same thing, you're probably not too late. It's exceptionally rare for startups to be killed by competitors — so rare that you can almost discount the possibility. So unless you discover a competitor with the sort of lock-in that would prevent users from choosing you, don't discard the idea.If you're uncertain, ask users. The question of whether you're too late is subsumed by the question of whether anyone urgently needs what you plan to make. If you have something that no competitor does and that some subset of users urgently need, you have a beachhead. [11]The question then is whether that beachhead is big enough. Or more importantly, who's in it: if the beachhead consists of people doing something lots more people will be doing in the future, then it's probably big enough no matter how small it is. For example, if you're building something differentiated from competitors by the fact that it works on phones, but it only works on the newest phones, that's probably a big enough beachhead.Err on the side of doing things where you'll face competitors. Inexperienced founders usually give competitors more credit than they deserve. Whether you succeed depends far more on you than on your competitors. So better a good idea with competitors than a bad one without.You don't need to worry about entering a "crowded market" so long as you have a thesis about what everyone else in it is overlooking. In fact that's a very promising starting point. Google was that type of idea. Your thesis has to be more precise than "we're going to make an x that doesn't suck" though. You have to be able to phrase it in terms of something the incumbents are overlooking. Best of all is when you can say that they didn't have the courage of their convictions, and that your plan is what they'd have done if they'd followed through on their own insights. Google was that type of idea too. The search engines that preceded them shied away from the most radical implications of what they were doing — particularly that the better a job they did, the faster users would leave.A crowded market is actually a good sign, because it means both that there's demand and that none of the existing solutions are good enough. A startup can't hope to enter a market that's obviously big and yet in which they have no competitors. So any startup that succeeds is either going to be entering a market with existing competitors, but armed with some secret weapon that will get them all the users (like Google), or entering a market that looks small but which will turn out to be big (like Microsoft). [12] FiltersThere are two more filters you'll need to turn off if you want to notice startup ideas: the unsexy filter and the schlep filter.Most programmers wish they could start a startup by just writing some brilliant code, pushing it to a server, and having users pay them lots of money. They'd prefer not to deal with tedious problems or get involved in messy ways with the real world. Which is a reasonable preference, because such things slow you down. But this preference is so widespread that the space of convenient startup ideas has been stripped pretty clean. If you let your mind wander a few blocks down the street to the messy, tedious ideas, you'll find valuable ones just sitting there waiting to be implemented.The schlep filter is so dangerous that I wrote a separate essay about the condition it induces, which I called schlep blindness. I gave Stripe as an example of a startup that benefited from turning off this filter, and a pretty striking example it is. Thousands of programmers were in a position to see this idea; thousands of programmers knew how painful it was to process payments before Stripe. But when they looked for startup ideas they didn't see this one, because unconsciously they shrank from having to deal with payments. And dealing with payments is a schlep for Stripe, but not an intolerable one. In fact they might have had net less pain; because the fear of dealing with payments kept most people away from this idea, Stripe has had comparatively smooth sailing in other areas that are sometimes painful, like user acquisition. They didn't have to try very hard to make themselves heard by users, because users were desperately waiting for what they were building.The unsexy filter is similar to the schlep filter, except it keeps you from working on problems you despise rather than ones you fear. We overcame this one to work on Viaweb. There were interesting things about the architecture of our software, but we weren't interested in ecommerce per se. We could see the problem was one that needed to be solved though.Turning off the schlep filter is more important than turning off the unsexy filter, because the schlep filter is more likely to be an illusion. And even to the degree it isn't, it's a worse form of self-indulgence. Starting a successful startup is going to be fairly laborious no matter what. Even if the product doesn't entail a lot of schleps, you'll still have plenty dealing with investors, hiring and firing people, and so on. So if there's some idea you think would be cool but you're kept away from by fear of the schleps involved, don't worry: any sufficiently good idea will have as many.The unsexy filter, while still a source of error, is not as entirely useless as the schlep filter. If you're at the leading edge of a field that's changing rapidly, your ideas about what's sexy will be somewhat correlated with what's valuable in practice. Particularly as you get older and more experienced. Plus if you find an idea sexy, you'll work on it more enthusiastically. [13] RecipesWhile the best way to discover startup ideas is to become the sort of person who has them and then build whatever interests you, sometimes you don't have that luxury. Sometimes you need an idea now. For example, if you're working on a startup and your initial idea turns out to be bad.For the rest of this essay I'll talk about tricks for coming up with startup ideas on demand. Although empirically you're better off using the organic strategy, you could succeed this way. You just have to be more disciplined. When you use the organic method, you don't even notice an idea unless it's evidence that something is truly missing. But when you make a conscious effort to think of startup ideas, you have to replace this natural constraint with self-discipline. You'll see a lot more ideas, most of them bad, so you need to be able to filter them.One of the biggest dangers of not using the organic method is the example of the organic method. Organic ideas feel like inspirations. There are a lot of stories about successful startups that began when the founders had what seemed a crazy idea but "just knew" it was promising. When you feel that about an idea you've had while trying to come up with startup ideas, you're probably mistaken.When searching for ideas, look in areas where you have some expertise. If you're a database expert, don't build a chat app for teenagers (unless you're also a teenager). Maybe it's a good idea, but you can't trust your judgment about that, so ignore it. There have to be other ideas that involve databases, and whose quality you can judge. Do you find it hard to come up with good ideas involving databases? That's because your expertise raises your standards. Your ideas about chat apps are just as bad, but you're giving yourself a Dunning-Kruger pass in that domain.The place to start looking for ideas is things you need. There must be things you need. [14]One good trick is to ask yourself whether in your previous job you ever found yourself saying "Why doesn't someone make x? If someone made x we'd buy it in a second." If you can think of any x people said that about, you probably have an idea. You know there's demand, and people don't say that about things that are impossible to build.More generally, try asking yourself whether there's something unusual about you that makes your needs different from most other people's. You're probably not the only one. It's especially good if you're different in a way people will increasingly be.If you're changing ideas, one unusual thing about you is the idea you'd previously been working on. Did you discover any needs while working on it? Several well-known startups began this way. Hotmail began as something its founders wrote to talk about their previous startup idea while they were working at their day jobs. [15]A particularly promising way to be unusual is to be young. Some of the most valuable new ideas take root first among people in their teens and early twenties. And while young founders are at a disadvantage in some respects, they're the only ones who really understand their peers. It would have been very hard for someone who wasn't a college student to start Facebook. So if you're a young founder (under 23 say), are there things you and your friends would like to do that current technology won't let you?The next best thing to an unmet need of your own is an unmet need of someone else. Try talking to everyone you can about the gaps they find in the world. What's missing? What would they like to do that they can't? What's tedious or annoying, particularly in their work? Let the conversation get general; don't be trying too hard to find startup ideas. You're just looking for something to spark a thought. Maybe you'll notice a problem they didn't consciously realize they had, because you know how to solve it.When you find an unmet need that isn't your own, it may be somewhat blurry at first. The person who needs something may not know exactly what they need. In that case I often recommend that founders act like consultants — that they do what they'd do if they'd been retained to solve the problems of this one user. People's problems are similar enough that nearly all the code you write this way will be reusable, and whatever isn't will be a small price to start out certain that you've reached the bottom of the well. [16]One way to ensure you do a good job solving other people's problems is to make them your own. When <NAME> decided to write software for restaurants, he got a job as a waiter to learn how restaurants worked. That may seem like taking things to extremes, but startups are extreme. We love it when founders do such things.In fact, one strategy I recommend to people who need a new idea is not merely to turn off their schlep and unsexy filters, but to seek out ideas that are unsexy or involve schleps. Don't try to start Twitter. Those ideas are so rare that you can't find them by looking for them. Make something unsexy that people will pay you for.A good trick for bypassing the schlep and to some extent the unsexy filter is to ask what you wish someone else would build, so that you could use it. What would you pay for right now?Since startups often garbage-collect broken companies and industries, it can be a good trick to look for those that are dying, or deserve to, and try to imagine what kind of company would profit from their demise. For example, journalism is in free fall at the moment. But there may still be money to be made from something like journalism. What sort of company might cause people in the future to say "this replaced journalism" on some axis?But imagine asking that in the future, not now. When one company or industry replaces another, it usually comes in from the side. So don't look for a replacement for x; look for something that people will later say turned out to be a replacement for x. And be imaginative about the axis along which the replacement occurs. Traditional journalism, for example, is a way for readers to get information and to kill time, a way for writers to make money and to get attention, and a vehicle for several different types of advertising. It could be replaced on any of these axes (it has already started to be on most).When startups consume incumbents, they usually start by serving some small but important market that the big players ignore. It's particularly good if there's an admixture of disdain in the big players' attitude, because that often misleads them. For example, after <NAME> built the computer that became the Apple I, he felt obliged to give his then-employer Hewlett-Packard the option to produce it. Fortunately for him, they turned it down, and one of the reasons they did was that it used a TV for a monitor, which seemed intolerably d�class� to a high-end hardware company like HP was at the time. [17]Are there groups of scruffy but sophisticated users like the early microcomputer "hobbyists" that are currently being ignored by the big players? A startup with its sights set on bigger things can often capture a small market easily by expending an effort that wouldn't be justified by that market alone.Similarly, since the most successful startups generally ride some wave bigger than themselves, it could be a good trick to look for waves and ask how one could benefit from them. The prices of gene sequencing and 3D printing are both experiencing Moore's Law-like declines. What new things will we be able to do in the new world we'll have in a few years? What are we unconsciously ruling out as impossible that will soon be possible? OrganicBut talking about looking explicitly for waves makes it clear that such recipes are plan B for getting startup ideas. Looking for waves is essentially a way to simulate the organic method. If you're at the leading edge of some rapidly changing field, you don't have to look for waves; you are the wave.Finding startup ideas is a subtle business, and that's why most people who try fail so miserably. It doesn't work well simply to try to think of startup ideas. If you do that, you get bad ones that sound dangerously plausible. The best approach is more indirect: if you have the right sort of background, good startup ideas will seem obvious to you. But even then, not immediately. It takes time to come across situations where you notice something missing. And often these gaps won't seem to be ideas for companies, just things that would be interesting to build. Which is why it's good to have the time and the inclination to build things just because they're interesting.Live in the future and build what seems interesting. Strange as it sounds, that's the real recipe. Notes[1] This form of bad idea has been around as long as the web. It was common in the 1990s, except then people who had it used to say they were going to create a portal for x instead of a social network for x. Structurally the idea is stone soup: you post a sign saying "this is the place for people interested in x," and all those people show up and you make money from them. What lures founders into this sort of idea are statistics about the millions of people who might be interested in each type of x. What they forget is that any given person might have 20 affinities by this standard, and no one is going to visit 20 different communities regularly.[2] I'm not saying, incidentally, that I know for sure a social network for pet owners is a bad idea. I know it's a bad idea the way I know randomly generated DNA would not produce a viable organism. The set of plausible sounding startup ideas is many times larger than the set of good ones, and many of the good ones don't even sound that plausible. So if all you know about a startup idea is that it sounds plausible, you have to assume it's bad.[3] More precisely, the users' need has to give them sufficient activation energy to start using whatever you make, which can vary a lot. For example, the activation energy for enterprise software sold through traditional channels is very high, so you'd have to be a lot better to get users to switch. Whereas the activation energy required to switch to a new search engine is low. Which in turn is why search engines are so much better than enterprise software.[4] This gets harder as you get older. While the space of ideas doesn't have dangerous local maxima, the space of careers does. There are fairly high walls between most of the paths people take through life, and the older you get, the higher the walls become.[5] It was also obvious to us that the web was going to be a big deal. Few non-programmers grasped that in 1995, but the programmers had seen what GUIs had done for desktop computers.[6] Maybe it would work to have this second self keep a journal, and each night to make a brief entry listing the gaps and anomalies you'd noticed that day. Not startup ideas, just the raw gaps and anomalies.[7] <NAME> points out that taking time to come up with an idea is not merely a better strategy in an absolute sense, but also like an undervalued stock in that so few founders do it.There's comparatively little competition for the best ideas, because few founders are willing to put in the time required to notice them. Whereas there is a great deal of competition for mediocre ideas, because when people make up startup ideas, they tend to make up the same ones.[8] For the computer hardware and software companies, summer jobs are the first phase of the recruiting funnel. But if you're good you can skip the first phase. If you're good you'll have no trouble getting hired by these companies when you graduate, regardless of how you spent your summers.[9] The empirical evidence suggests that if colleges want to help their students start startups, the best thing they can do is leave them alone in the right way.[10] I'm speaking here of IT startups; in biotech things are different.[11] This is an instance of a more general rule: focus on users, not competitors. The most important information about competitors is what you learn via users anyway.[12] In practice most successful startups have elements of both. And you can describe each strategy in terms of the other by adjusting the boundaries of what you call the market. But it's useful to consider these two ideas separately.[13] I almost hesitate to raise that point though. Startups are businesses; the point of a business is to make money; and with that additional constraint, you can't expect you'll be able to spend all your time working on what interests you most.[14] The need has to be a strong one. You can retroactively describe any made-up idea as something you need. But do you really need that recipe site or local event aggregator as much as Drew Houston needed Dropbox, or <NAME> and <NAME> needed Airbnb?Quite often at YC I find myself asking founders "Would you use this thing yourself, if you hadn't written it?" and you'd be surprised how often the answer is no.[15] <NAME> points out that trying to sell something bad can be a source of better ideas:"The best technique I've found for dealing with YC companies that have bad ideas is to tell them to go sell the product ASAP (before wasting time building it). Not only do they learn that nobody wants what they are building, they very often come back with a real idea that they discovered in the process of trying to sell the bad idea."[16] Here's a recipe that might produce the next Facebook, if you're college students. If you have a connection to one of the more powerful sororities at your school, approach the queen bees thereof and offer to be their personal IT consultants, building anything they could imagine needing in their social lives that didn't already exist. Anything that got built this way would be very promising, because such users are not just the most demanding but also the perfect point to spread from.I have no idea whether this would work.[17] And the reason it used a TV for a monitor is that Steve Wozniak started out by solving his own problems. He, like most of his peers, couldn't afford a monitor.Thanks to <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, and <NAME> for reading drafts of this, and <NAME>, <NAME>, <NAME>, <NAME>, <NAME> and <NAME> for answering my questions about startup history.Japanese TranslationItalian TranslationSpanish Translation
https://github.com/AHaliq/CategoryTheoryReport
https://raw.githubusercontent.com/AHaliq/CategoryTheoryReport/main/chapters/chapter1/notes.typ
typst
#import "../../preamble/lemmas.typ": * #import "../../preamble/catt.typ": * #import "@preview/fletcher:0.5.1" as fletcher: diagram, node, edge #definition(name: "Category")[ @sa[definition 1.1] A category is a collection of objects and morphisms between them satisfying some properties. $ C = (Ob(C), Hom(C)) \ $ #grid( columns: (1fr, 1fr), align: (center, center), $A, B, C, ... in Ob(C)$, $vec(delim: #none, arr(f,A,B), arr(g,B,C), dots.v) in Hom(C)$, ) #figure( table( columns: 2, align: (right, left), [properties], [definition], [composition], $forall arr(f,A,B), arr(g,B,C). exists arr(g comp f, A, C)$, [identity], $exists! arr(1_A,A,A)$, [associativity], $h comp (g comp f) = (h comp g) comp f$, [unital], $f comp 1_A = f = 1_B comp f$, ), ) ]<defn-cat> #definition(name: "Functor")[ @sa[definition 1.2] A functor is a structure preserving map from one category to another. $ arr(F,C,D) $ #figure( table( columns: 2, align: (right, left), [structure], [definition], [domains], $arr(F(f),F(A),F(B))$, [identity], $F(1_A)=1_F(A)$, [composition], $F(g comp f) = F(g) comp F(f)$, ), ) ]<defn-functor> #definition(name: "Isomorphism")[ @sa[definition 1.3] An isomorphism is a morphism that has an inverse. The objects on them are isomorphic. $ "isIso"(f) &= exists! g. g comp f = 1_A and f comp g = 1_B \ A iso B &= exists arr(f,A,B). "isIso"(f) $ ]<defn-isomorphism> #definition(name: "Constructions on Categories")[ @sa[definition 1.6] Here are categories that are constructed out of prior categories. #figure( table( columns: 3, align: (right, center, center), [category], [objects], [morphisms], [product $A times B$], $Ob(C) times Ob(B)$, $Hom(C) times Hom(B)$, [dual $op(C)$], $Ob(C)$, $A,B |-> Hom(C,s:B,t:A)$, [arrow $C^(->)$], $Hom(C)$, $f,f' |-> {(g,g') | g' comp f = f' comp g}$, [slice $slice(C,A)$], ${X | Hom(C,s:X,t:A) != emptyset}$, $Hom(C)$, [co-slice $coslice(C,A)$], ${X | Hom(C,s:A,t:X) != emptyset}$, $Hom(C)$, ), ) ]<defn-constructions> #definition(name: "Universal Mapping Property: Free Monoids and Categories")[ @sa[definition 1.7,1.9,1.10] - Alphabet: $A={a_0,a_1,a_2,...}$ - Words: concatenations of $a_i$ form words. along with $-$; an empty word, forms a monoid - Free Monoid: elements of $A$ freely generate the monoid $M(A)$ - Forgetful Functor: $arr(|-|,"Monoids","Sets")$, gives an underlying alphabet of a monoid #grid( columns: (1fr, 1fr), align: (center + horizon, center + horizon), figure( table( columns: 2, align: (right, left), [UMP], [definition], [existence], $forall i, f. exists! overline(f). |overline(f)| comp i = f$, [uniqueness], $|overline(f_a)| comp i &= f and \ |overline(f_b)| comp i &= f -> \ overline(f_a) &= overline(f_b)$, ), ), figure( diagram( cell-size: 10mm, $ #node($M(A)$, name: <MA>) edge("d", "=>", stroke: sstroke) edge("r", overline(f), "-->") & #node($N$, name: <N>) edge("d", "=>", stroke: sstroke) \ #node($|M(A)|$, name: <MBA>) edge("r", |overline(f)|, ->) & #node($|N|$, name: <BN>) \ #node($A$, name: <A>) edge("u", i, ->) edge("ur", f, ->) #node( align(bottom + right,text(silver)[$Mon$]), corner-radius: 5pt, stroke: silver, enclose: (<MA>, <N>), ) #node( align(bottom + right,text(silver)[$Set$]), corner-radius: 5pt, stroke: silver, enclose: (<MBA>, <BN>, <A>), ) $, ), ), ) - No Junk: all words are concatenations of $A$; implied by uniqueness - No Noise: equality of words by equality of alphabets; implied by existence - Free Category: if $A$ are the set of edges of a directed graph, the words are morphisms of a category excluding identity morphisms ]<defn-freemonoid> #definition(name: "Category Size")[ @sa[definition 1.11,1.12] A size of a category depends of its consituents are sets #figure( table( columns: 2, align: (right, left), [size], [definition], [small], [$Ob(C), Hom(C)$ are sets], [locally small], [$Hom(C,s:A,t:B)$ are sets], [large], [otherwise], ), ) ]
https://github.com/typst-jp/typst-jp.github.io
https://raw.githubusercontent.com/typst-jp/typst-jp.github.io/main/docs/reference/styling.md
markdown
Apache License 2.0
--- description: Typst で文書のスタイル設定をするために必要な概念 --- # スタイル設定 Typstには柔軟なスタイル設定機能を持ち、出力される文書に対して自動的に任意のスタイル設定を適用します。 _setルール_ ではエレメントの基本プロパティを設定できます。 しかし、やりたいことすべてに対応するプロパティがあらかじめ実装されているとは限りません。 このため、Typstはエレメントの外観を完全に再定義できる _showルール_ もサポートしています。 ## setルール { #set-rules } setルールを使うと、エレメントの外観をカスタマイズできます。 これらは、`{set}`キーワード(マークアップでは`[#set]`)を前に置いた[element 関数]($function/#element-functions)への[関数呼び出し]($function)として記述されます。 set ルールに指定できるのは、その関数のオプションのパラメーターだけです。 どのパラメーターがオプションであるかは、各関数のドキュメントを参照してください。 以下の例では、2 つの set ルールを使って、[フォント]($text.font)と[見出し番号]($heading.numbering)を変更しています。 ```example #set heading(numbering: "I.") #set text( font: "New Computer Modern" ) = Introduction With set rules, you can style your document. ``` setルールは、そのまま記述するとファイルの最後まで適用されます。 ブロックの中にネストすると、そのブロックの終わりまで適用されます。 ブロックを使えば、setルールの効果を指定した部分に限定できます。 以下では、contentブロックを用いてスコープすることで、特定のリストのスタイルのみを変更しています。 ```example This list is affected: #[ #set list(marker: [--]) - Dash ] This one is not: - Bullet ``` ときには、setルールを条件付きで設定したい場合もあるでしょう。 その場合には _set-if_ ルールを使用します。 ```example #let task(body, critical: false) = { set text(red) if critical [- #body] } #task(critical: true)[Food today?] #task(critical: false)[Work deadline] ``` ## showルール { #show-rules } showルールを使えば、特定の種類のエレメントの外観を詳細に設定できます。 showルールの基本的な記述方法は、show-setルールです。 `{show}` キーワードの後に [セレクター]($selector)、コロン、setルールと続けて記述します。 セレクターの基本的な記述方法は [element関数]($function/#element-functions)を置くことであり、setルールは選択されたエレメントにのみ適用されます。 下の例では、見出しは紺色になり、他のテキストは黒色のままです。 ```example #show heading: set text(navy) = This is navy-blue But this stays black. ``` show-setルールを使えば、さまざまな関数のプロパティを組み合わせることが可能です。 しかし、組み合わせられるプロパティはTypstであらかじめ定義されているものに限定されます。 最大限の柔軟性を得るには、エレメントをゼロからフォーマットする方法を定義するshowルールを書くことができます。 このようなshowルールを書くには、コロンの後のsetルールを任意の[関数]($function)に置き換えてください。 この関数は対象のエレメントを受け取り、任意の内容を返すことができます。 関数に渡されたエレメントで利用可能な[フィールド]($scripting/#fields)は、それぞれのelement関数のパラメーターと一致します。 以下は、ファンタジー百科事典の見出しをフォーマットするshowルールを定義する例です。 ```example #set heading(numbering: "(I)") #show heading: it => [ #set align(center) #set text(font: "Inria Serif") \~ #emph(it.body) #counter(heading).display( it.numbering ) \~ ] = Dragon With a base health of 15, the dragon is the most powerful creature. = Manticore While less powerful than the dragon, the manticore gets extra style points. ``` setルールと同様に、showルールは、現在のブロック内またはファイルの終わりまで有効です。 関数の代わりに、showルールのコロン右側は、エレメントに直接置換されるべきリテラル文字列またはコンテンツブロックを取ることもできます。 また showルールのコロン左側は、以下に示すように、変換を適用する対象を定義する _セレクター_ を受け取ることができます。 - **すべて:** `{show: rest => ..}` \ showルール以降のすべてを変換する。 個別の関数呼び出しでラップすることなく、複雑なレイアウトを文書全体に適用するのに便利です。 - **文字列:** `{show "Text": ..}` \ 設定した文字列に対して、スタイル変更や文字の置き換えを行います。 - **正規表現:** `{show regex("\w+"): ..}` \ 正規表現にマッチする文字列に対して、スタイル変更や文字の置き換えを行います。 正規表現については[regex 関数]($regex)を参照してください。 - **関数やフィールド:** `{show heading.where(level: 1): ..}` \ 指定されたフィールドを持つエレメントのみを変換します。 たとえば、レベル1の見出しのスタイルだけを変更したい場合などに有効です。 - **ラベル:** `{show <intro>: ..}` \ 指定されたラベルを持つエレメントに対して適用する。 ラベルについては[labelタイプ]($label)を参照してください。 ```example #show "Project": smallcaps #show "badly": "great" We started Project in 2019 and are still working on it. Project is progressing badly. ```
https://github.com/TypstApp-team/typst
https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/compiler/show-node.typ
typst
Apache License 2.0
// Test show rules. --- // Override lists. #show list: it => "(" + it.children.map(v => v.body).join(", ") + ")" - A - B - C - D - E --- // Test full reset. #show heading: [B] #show heading: set text(size: 10pt, weight: 400) A #[= Heading] C --- // Test full removal. #show heading: none Where is = There are no headings around here! my heading? --- // Test integrated example. #show heading: it => block({ set text(10pt) box(move(dy: -1pt)[📖]) h(5pt) if it.level == 1 { underline(text(1.25em, blue, it.body)) } else { text(red, it.body) } }) = Task 1 Some text. == Subtask Some more text. = Task 2 Another text. --- // Test set and show in code blocks. #show heading: it => { set text(red) show "ding": [🛎] it.body } = Heading --- // Test that scoping works as expected. #{ let world = [ World ] show "W": strong world { set text(blue) show: it => { show "o": "Ø" it } world } world } --- #show heading: [1234] = Heading --- // Error: 25-29 content does not contain field "page" #show heading: it => it.page = Heading --- #show text: none Hey --- // Error: 7-12 only element functions can be used as selectors #show upper: it => {} --- // Error: 16-20 expected content or function, found integer #show heading: 1234 = Heading --- // Error: 7-10 expected symbol, string, label, function, regex, or selector, found color #show red: [] --- // Error: 7-25 show is only allowed directly in code and content blocks #(1 + show heading: none)
https://github.com/mrwunderbar666/typst-apa7ish
https://raw.githubusercontent.com/mrwunderbar666/typst-apa7ish/main/src/apa7ish.typ
typst
MIT License
#let script-size = 8pt #let footnote-size = 8.5pt #let small-size = 9.25pt #let normal-size = 11pt #let large-size = 12pt #let conf( title: "", subtitle: none, abstract: none, authors: (), date: none, documenttype: none, keywords: none, disclosure: none, funding: none, anonymous: false, language: "en", fontfamily: "Libertinus Serif", papersize: "a4", body, ) = { // Set the document's basic properties. set document(author: authors.map(a => a.name), title: title) // todo: dont show header on first (title) page set page(numbering: "1", paper: papersize, number-align: top + right, margin: 33mm, header: { context if counter(page).get().at(0) > 1 [ #smallcaps(lower(title)) #h(1fr) #here().page() ] } ) set text(font: fontfamily, lang: language, size: normal-size) // Set paragraph spacing. // show par: set block(above: 0.58em, below: 0.58em) set par(spacing: 0.58em) // Set Heading styles show heading: it => { // set textsize: normal-size) if it.level == 1 { align(text(it, size: normal-size), center) v(15pt, weak: true) } else { let wght = "bold" if it.level > 2 { wght = "regular" } align(emph(text(it, size: normal-size, weight: wght))) v(normal-size, weak: true) } } // Bibliography set bibliography(title: "References", style: "american-psychological-association") show bibliography: set block(spacing: 0.58em) show bibliography: set par(first-line-indent: 0em) // Figures show figure: set block(above: 2em, below: 2em) // Title Page align(center)[ #if documenttype != none [ #smallcaps(lower(documenttype)) \ ] #text(1.5em, title) \ #if subtitle != none [ #text(1.2em, subtitle) \ ] #v(1em, weak: true) ] // utility function: go through all authors and check their affiliations // purpose is to group authors with the same affiliations // returns a dict with two keys: // "authors" (modified author array) // "affiliations": array with unique affiliations let parse_authors(authors) = { let affiliations = () let parsed_authors = () let corresponding = () let pos = 0 for author in authors { if "affiliation" in author { if author.affiliation not in affiliations { affiliations.push(author.affiliation) } pos = affiliations.position(a => a == author.affiliation) author.insert("affiliation_parsed", pos) } else { // if author has no affiliation, just use the same as the previous author author.insert("affiliation_parsed", pos) } parsed_authors.push(author) if "corresponding" in author { if author.corresponding { corresponding = author } } } (authors: parsed_authors, affiliations: affiliations, corresponding: corresponding) } // utility function to turn a number into a letter // simulates footnotes let number2letter(num) = { "abcdefghijklmnopqrstuvwxyz".at(num) } let authors_parsed = parse_authors(authors) // List Authors if not anonymous { pad( top: 0.3em, bottom: 0.3em, x: 2em, grid( columns: (1fr,) * calc.min(3, authors_parsed.authors.len()), gutter: 1em, ..authors_parsed.authors.map(author => align(center)[ #author.name#super[#number2letter(author.affiliation_parsed)] \ ]), ), ) let affiliation_counter = counter("affiliation_counter") affiliation_counter.update(1) align(center)[ #for affiliation in authors_parsed.affiliations [ #context super(affiliation_counter.display("a"))#h(1pt)#emph(affiliation) #affiliation_counter.step() \ ] #v(1em, weak: true) #date #v(2em, weak: true) ] } else { align(center)[ #date ] } set par(justify: true) // Abstract & Keywords if abstract != none { heading(outlined: false, numbering: none, text(11pt, weight: "regular", [Abstract])) align(center)[ #block(width: 90%, [ #align(left)[ #abstract \ #v(1em, weak: true) #if keywords != none [ #emph("Keywords: ") #keywords ] ] ] ) ] } let orcid(height: 10pt, o) = [ #box(height: height, baseline: 10%, image("assets/orcid.svg") ) #link("https://orcid.org/" + o) ] // Author Note if not anonymous { heading(outlined: false, numbering: none, text(11pt, weight: "bold", [Author Note])) // ORCID IDs for author in authors_parsed.authors [ #author.name #orcid(author.orcid) \ ] // Disclosures and Acknowledgements if disclosure != none [ #disclosure \ ] else [ We have no conflicts of interest to disclose. \ ] if funding != none [ #funding \ ] // Contact Information [Correspondence concerning this article should be addressed to #authors_parsed.corresponding.name,] if "postal" in authors_parsed.corresponding [ #authors_parsed.corresponding.postal] [ Email: #link("mailto:" + authors_parsed.corresponding.email, authors_parsed.corresponding.email) ] } pagebreak() // Main body. set par(first-line-indent: 2em) body }
https://github.com/Gekkio/gb-ctr
https://raw.githubusercontent.com/Gekkio/gb-ctr/main/chapter/cpu/instruction-set.typ
typst
Creative Commons Attribution Share Alike 4.0 International
#import "../../common.typ": * #import "../../timing.typ" #let ops = toml("../../opcodes.toml") #let instruction-block(body, ..grid-args) = [ #body #grid( columns: 1, gutter: 6pt, ..grid-args ) #pagebreak() ] #let simple-instruction-timing(mnemonic: str, timing_data: dictionary) = timing.diagram(w_scale: 0.9, ..{ import timing: diagram, clock as c, data as d, either as e, high as h, low as l, unknown as u, undefined as x, high_impedance as z let duration = timing_data.duration ( (label: "M-cycle", wave: ( x(1), ..range(duration).map((idx) => { let m_cycle = idx + 1 d(8, "M" + str(m_cycle)) }), x(1), )), (label: "Mem R/W", wave: ( x(1), ..timing_data.mem_rw.enumerate().map(((idx, label)) => { let m_cycle = idx + 2 if label == "U" { timing.unknown(8) } else { timing.data(8, label) } }), x(1, opacity: 40%), )), ) }) #let instruction-timing(mnemonic: str, timing_data: dictionary) = timing.diagram(w_scale: 0.9, ..{ import timing: diagram, clock as c, data as d, either as e, high as h, low as l, unknown as u, undefined as x, high_impedance as z let duration = timing_data.duration let map_cycle_labels(data) = data.enumerate().map(((idx, label)) => { let m_cycle = idx + 2 if label == "U" { timing.unknown(8) } else { timing.data(8, label) } }) ( (label: "M-cycle", wave: ( x(1), ..range(1 + duration).map((idx) => { let m_cycle = idx + 1 if m_cycle == duration + 1 { d(8, "M" + str(m_cycle) + "/M1") } else { d(8, "M" + str(m_cycle)) } }), x(1), )), (label: "Addr bus", wave: ( x(1), timing.data(8, [Previous], opacity: 40%), ..map_cycle_labels(timing_data.addr), x(1, opacity: 40%), )), (label: "Data bus", wave: ( x(1), timing.data(8, [IR ← mem], opacity: 40%), ..map_cycle_labels(timing_data.data), x(1, opacity: 40%), )), (label: "IDU op", wave: ( x(1), timing.data(8, [Previous], opacity: 40%), ..map_cycle_labels(timing_data.idu_op), x(1, opacity: 40%), )), (label: "ALU op", wave: ( x(1), timing.data(8, [Previous], opacity: 40%), ..map_cycle_labels(timing_data.alu_op), x(1, opacity: 40%), )), (label: "Misc op", wave: ( x(1), timing.data(8, [Previous], opacity: 40%), ..map_cycle_labels(timing_data.misc_op), x(1, opacity: 40%), )), ) }) #let instruction = (body, mnemonic: str, opcode: content, operand_bytes: array, cb: false, flags: [-], timing: dictionary, simple-pseudocode: [], pseudocode: content) => instruction-block( body, grid(columns: (auto, 1fr, auto, 1fr), gutter: 6pt, [*Opcode*], opcode, [*Duration*], if "cc_false" in timing [ #let cc_false = if timing.cc_false.duration > 1 { str(timing.cc_false.duration) + " machine cycles" } else { "1 machine cycle" } #let cc_true = if timing.cc_true.duration > 1 { str(timing.cc_true.duration) + " machine cycles" } else { "1 machine cycle" } #cc_true (cc=true)\ #cc_false (cc=false) ] else [ #let duration = timing.duration #if duration > 1 [ #duration machine cycles ] else [ 1 machine cycle ] ], [*Length*], { let length = if cb { 2 } else { 1 } + operand_bytes.len() if cb { "2 bytes: CB prefix + opcode" } else if operand_bytes.len() > 0 { str(length) + " bytes: opcode + " + operand_bytes.join(" + ") } else { "1 byte: opcode" } }, [*Flags*], flags, ), if "cc_false" in timing { [ #block(breakable: false)[ *Simple timing and pseudocode* #grid(columns: (auto, 1fr), gutter: 12pt, align(horizon, [_cc=true_]), simple-instruction-timing(mnemonic: mnemonic, timing_data: timing.cc_true), align(horizon, [_cc=false_]), simple-instruction-timing(mnemonic: mnemonic, timing_data: timing.cc_false), ) #simple-pseudocode ] #block(breakable: false)[ *Detailed timing and pseudocode* #grid(columns: (auto, 1fr), gutter: 12pt, align(horizon, [_cc=true_]), instruction-timing(mnemonic: mnemonic, timing_data: timing.cc_true), align(horizon, [_cc=false_]), instruction-timing(mnemonic: mnemonic, timing_data: timing.cc_false), ) #pseudocode ] ] } else { [ #block(breakable: false)[ *Simple timing and pseudocode* #simple-instruction-timing(mnemonic: mnemonic, timing_data: timing) #simple-pseudocode ] #block(breakable: false)[ *Detailed timing and pseudocode* #instruction-timing(mnemonic: mnemonic, timing_data: timing) #pseudocode ] ] } ) #let flag-update = awesome[\u{f005}] == Sharp SM83 instruction set === Overview ==== CB opcode prefix <op:CB> ==== Undefined opcodes <op:undefined> #pagebreak() === 8-bit load instructions #instruction( [ ==== LD r, r': Load register (register) <op:LD_r_r> Load to the 8-bit register `r`, data from the 8-bit register `r'`. ], mnemonic: "LD r, r'", opcode: [#bin("01xxxyyy")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([`r` ← `r'`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x41: # example: LD B, C B = C ```, pseudocode: ```python # M2/M1 if IR == 0x41: # example: LD B, C IR, intr = fetch_cycle(addr=PC); PC = PC + 1; B = C ``` ) #instruction( [ ==== LD r, n: Load register (immediate) <op:LD_r_n> Load to the 8-bit register `r`, the immediate data `n`. ], mnemonic: "LD r, n", opcode: [#bin("00xxx110")/various], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x06: # example: LD B, n B = read_memory(addr=PC); PC = PC + 1 ```, pseudocode: ```python # M2 if IR == 0x06: # example: LD B, n Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; B = Z ``` ) #instruction( [ ==== LD r, (HL): Load register (indirect HL) <op:LD_r_hl> Load to the 8-bit register `r`, data from the absolute address specified by the 16-bit register HL. ], mnemonic: "LD r, (HL)", opcode: [#bin("01xxx110")/various], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [`r` ← Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x46: # example: LD B, (HL) B = read_memory(addr=HL) ```, pseudocode: ```python # M2 if IR == 0x46: # example: LD B, (HL) Z = read_memory(addr=HL) # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; B = Z ``` ) #instruction( [ ==== LD (HL), r: Load from register (indirect HL) <op:LD_hl_r> Load to the absolute address specified by the 16-bit register HL, data from the 8-bit register `r`. ], mnemonic: "LD (HL), r", opcode: [#bin("01110xxx")/various], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [W: data],), addr: ([HL], [PC],), data: ([mem ← `r`], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x70: # example: LD (HL), B write_memory(addr=HL, data=B) ```, pseudocode: ```python # M2 if IR == 0x70: # example: LD (HL), B write_memory(addr=HL, data=B) # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LD (HL), n: Load from immediate data (indirect HL) <op:LD_hl_n> Load to the absolute address specified by the 16-bit register HL, the immediate data `n`. ], mnemonic: "LD (HL), n", opcode: [#bin("00110110")/#hex("36")], operand_bytes: ([`n`],), timing: ( duration: 3, mem_rw: ([opcode], [R: `n`], [W: `n`],), addr: ([PC], [HL], [PC],), data: ([Z ← mem], [mem ← Z], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U",), misc_op: ("U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x36: n = read_memory(addr=PC); PC = PC + 1 write_memory(addr=HL, data=n) ```, pseudocode: ```python # M2 if IR == 0x36: Z = read_memory(addr=PC); PC = PC + 1 # M3 write_memory(addr=HL, data=Z) # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LD A, (BC): Load accumulator (indirect BC) <op:LD_a_bc> Load to the 8-bit A register, data from the absolute address specified by the 16-bit register BC. ], mnemonic: "LD A, (BC)", opcode: [#bin("00001010")/#hex("0A")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([BC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x0A: A = read_memory(addr=BC) ```, pseudocode: ```python # M2 if IR == 0x0A: Z = read_memory(addr=BC) # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; A = Z ``` ) #instruction( [ ==== LD A, (DE): Load accumulator (indirect DE) <op:LD_a_de> Load to the 8-bit A register, data from the absolute address specified by the 16-bit register DE. ], mnemonic: "LD A, (DE)", opcode: [#bin("00011010")/#hex("1A")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([DE], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x1A: A = read_memory(addr=DE) ```, pseudocode: ```python # M2 if IR == 0x1A: Z = read_memory(addr=DE) # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; A = Z ``` ) #instruction( [ ==== LD (BC), A: Load from accumulator (indirect BC) <op:LD_bc_a> Load to the absolute address specified by the 16-bit register BC, data from the 8-bit A register. ], mnemonic: "LD (BC), A", opcode: [#bin("00000010")/#hex("02")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [W: data],), addr: ([BC], [PC],), data: ([mem ← A], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x02: write_memory(addr=BC, data=A) ```, pseudocode: ```python # M2 if IR == 0x02: write_memory(addr=BC, data=A) # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LD (DE), A: Load from accumulator (indirect DE) <op:LD_de_a> Load to the absolute address specified by the 16-bit register DE, data from the 8-bit A register. ], mnemonic: "LD (DE), A", opcode: [#bin("00010010")/#hex("12")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [W: data],), addr: ([DE], [PC],), data: ([mem ← A], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x12: write_memory(addr=DE, data=A) ```, pseudocode: ```python # M2 if IR == 0x12: write_memory(addr=DE, data=A) # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LD A, (nn): Load accumulator (direct) <op:LD_a_nn> Load to the 8-bit A register, data from the absolute address specified by the 16-bit operand `nn`. ], mnemonic: "LD A, (nn)", opcode: [#bin("11111010")/#hex("FA")], operand_bytes: ([LSB(`nn`)], [MSB(`nn`)]), timing: ( duration: 4, mem_rw: ([opcode], [R: lsb `nn`], [R: msb `nn`], [R: data],), addr: ([PC], [PC], [WZ], [PC],), data: ([Z ← mem], [W ← mem], [Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U", [A ← Z],), misc_op: ("U", "U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xFA: nn_lsb = read_memory(addr=PC); PC = PC + 1 nn_msb = read_memory(addr=PC); PC = PC + 1 nn = unsigned_16(lsb=nn_lsb, msb=nn_msb) A = read_memory(addr=nn) ```, pseudocode: ```python # M2 if IR == 0xFA: Z = read_memory(addr=PC); PC = PC + 1 # M3 W = read_memory(addr=PC); PC = PC + 1 # M4 Z = read_memory(addr=WZ) # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; A = Z ``` ) #instruction( [ ==== LD (nn), A: Load from accumulator (direct) <op:LD_nn_a> Load to the absolute address specified by the 16-bit operand `nn`, data from the 8-bit A register. ], mnemonic: "LD (nn), A", opcode: [#bin("11101010")/#hex("EA")], operand_bytes: ([LSB(`nn`)], [MSB(`nn`)]), timing: ( duration: 4, mem_rw: ([opcode], [R: lsb `nn`], [R: msb `nn`], [W: data],), addr: ([PC], [PC], [WZ], [PC],), data: ([Z ← mem], [W ← mem], [mem ← A], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U", "U",), misc_op: ("U", "U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xEA: nn_lsb = read_memory(addr=PC); PC = PC + 1 nn_msb = read_memory(addr=PC); PC = PC + 1 nn = unsigned_16(lsb=nn_lsb, msb=nn_msb) write_memory(addr=nn, data=A) ```, pseudocode: ```python # M2 if IR == 0xEA: Z = read_memory(addr=PC); PC = PC + 1 # M3 W = read_memory(addr=PC); PC = PC + 1 # M4 write_memory(addr=WZ, data=A) # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LDH A, (C): Load accumulator (indirect #hex("FF00")+C) <op:LDH_a_c> Load to the 8-bit A register, data from the address specified by the 8-bit C register. The full 16-bit absolute address is obtained by setting the most significant byte to #hex("FF") and the least significant byte to the value of C, so the possible range is #hex-range("FF00", "FFFF"). ], mnemonic: "LDH A, (C)", opcode: [#bin("11110010")/#hex("F2")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([#hex("FF00")+C], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xF2: A = read_memory(addr=unsigned_16(lsb=C, msb=0xFF)) ```, pseudocode: ```python # M2 if IR == 0xF2: Z = read_memory(addr=unsigned_16(lsb=C, msb=0xFF)) # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; A = Z ``` ) #instruction( [ ==== LDH (C), A: Load from accumulator (indirect #hex("FF00")+C) <op:LDH_c_a> Load to the address specified by the 8-bit C register, data from the 8-bit A register. The full 16-bit absolute address is obtained by setting the most significant byte to #hex("FF") and the least significant byte to the value of C, so the possible range is #hex-range("FF00", "FFFF"). ], mnemonic: "LDH (C), A", opcode: [#bin("11100010")/#hex("E2")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [W: data],), addr: ([#hex("FF00")+C], [PC],), data: ([mem ← A], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xE2: write_memory(addr=unsigned_16(lsb=C, data=msb=0xFF), data=A) ```, pseudocode: ```python # M2 if IR == 0xE2: write_memory(addr=unsigned_16(lsb=C, data=msb=0xFF), data=A) # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LDH A, (n): Load accumulator (direct #hex("FF00")+n) <op:LDH_a_n> Load to the 8-bit A register, data from the address specified by the 8-bit immediate data `n`. The full 16-bit absolute address is obtained by setting the most significant byte to #hex("FF") and the least significant byte to the value of `n`, so the possible range is #hex-range("FF00", "FFFF"). ], mnemonic: "LDH A, (n)", opcode: [#bin("11110000")/#hex("F0")], operand_bytes: ([`n`],), timing: ( duration: 3, mem_rw: ([opcode], [R: `n`], [R: data],), addr: ([PC], [#hex("FF00")+Z], [PC],), data: ([Z ← mem], [Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", [A ← Z],), misc_op: ("U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xF0: n = read_memory(addr=PC); PC = PC + 1 A = read_memory(addr=unsigned_16(lsb=n, msb=0xFF)) ```, pseudocode: ```python # M2 if IR == 0xF0: Z = read_memory(addr=PC); PC = PC + 1 # M3 Z = read_memory(addr=unsigned_16(lsb=Z, msb=0xFF)) # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; A = Z ``` ) #instruction( [ ==== LDH (n), A: Load from accumulator (direct #hex("FF00")+n) <op:LDH_n_a> Load to the address specified by the 8-bit immediate data `n`, data from the 8-bit A register. The full 16-bit absolute address is obtained by setting the most significant byte to #hex("FF") and the least significant byte to the value of `n`, so the possible range is #hex-range("FF00", "FFFF"). ], mnemonic: "LDH (n), A", opcode: [#bin("11100000")/#hex("E0")], operand_bytes: ([`n`],), timing: ( duration: 3, mem_rw: ([opcode], [R: `n`], [W: data],), addr: ([PC], [#hex("FF00")+Z], [PC],), data: ([Z ← mem], [mem ← A], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U",), misc_op: ("U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xE0: n = read_memory(addr=PC); PC = PC + 1 write_memory(addr=unsigned_16(lsb=n, msb=0xFF), data=A) ```, pseudocode: ```python # M2 if IR == 0xE0: Z = read_memory(addr=PC); PC = PC + 1 # M3 write_memory(addr=unsigned_16(lsb=Z, msb=0xFF), data=A) # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LD A, (HL-): Load accumulator (indirect HL, decrement) <op:LD_a_hld> Load to the 8-bit A register, data from the absolute address specified by the 16-bit register HL. The value of HL is decremented after the memory read. ], mnemonic: "LD A, (HL-)", opcode: [#bin("00111010")/#hex("3A")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([HL ← HL - 1], [PC ← PC + 1],), alu_op: ("U", [A ← Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x3A: A = read_memory(addr=HL); HL = HL - 1 ```, pseudocode: ```python # M2 if IR == 0x3A: Z = read_memory(addr=HL); HL = HL - 1 # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; A = Z ``` ) #instruction( [ ==== LD (HL-), A: Load from accumulator (indirect HL, decrement) <op:LD_hld_a> Load to the absolute address specified by the 16-bit register HL, data from the 8-bit A register. The value of HL is decremented after the memory write. ], mnemonic: "LD (HL-), A", opcode: [#bin("00110010")/#hex("32")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [W: data],), addr: ([HL], [PC],), data: ([mem ← A], [IR ← mem],), idu_op: ([HL ← HL - 1], [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x32: write_memory(addr=HL, data=A); HL = HL - 1 ```, pseudocode: ```python # M2 if IR == 0x32: write_memory(addr=HL, data=A); HL = HL - 1 # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LD A, (HL+): Load accumulator (indirect HL, increment) <op:LD_a_hli> Load to the 8-bit A register, data from the absolute address specified by the 16-bit register HL. The value of HL is incremented after the memory read. ], mnemonic: "LD A, (HL+)", opcode: [#bin("00101010")/#hex("2A")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([HL ← HL + 1], [PC ← PC + 1],), alu_op: ("U", [A ← Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x2A: A = read_memory(addr=HL); HL = HL + 1 ```, pseudocode: ```python # M2 if IR == 0x2A: Z = read_memory(addr=HL); HL = HL + 1 # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; A = Z ``` ) #instruction( [ ==== LD (HL+), A: Load from accumulator (indirect HL, increment) <op:LD_hli_a> Load to the absolute address specified by the 16-bit register HL, data from the 8-bit A register. The value of HL is decremented after the memory write. ], mnemonic: "LD (HL+), A", opcode: [#bin("00100010")/#hex("22")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [W: data],), addr: ([HL], [PC],), data: ([mem ← A], [IR ← mem],), idu_op: ([HL ← HL + 1], [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x22: write_memory(addr=HL, data=A); HL = HL + 1 ```, pseudocode: ```python # M2 if IR == 0x22: write_memory(addr=HL, data=A); HL = HL + 1 # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) === 16-bit load instructions #instruction( [ ==== LD rr, nn: Load 16-bit register / register pair <op:LD_rr_nn> Load to the 16-bit register `rr`, the immediate 16-bit data `nn`. ], mnemonic: "LD rr, nn", opcode: [#bin("00xx0001")/various], operand_bytes: ([LSB(`nn`)], [MSB(`nn`)]), timing: ( duration: 3, mem_rw: ([opcode], [R: lsb `nn`], [R: msb `nn`],), addr: ([PC], [PC], [PC],), data: ([Z ← mem], [W ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", "U", "U",), misc_op: ("U", "U", [`rr` ← WZ],), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x01: # example: LD BC, nn nn_lsb = read_memory(addr=PC); PC = PC + 1 nn_msb = read_memory(addr=PC); PC = PC + 1 nn = unsigned_16(lsb=nn_lsb, msb=nn_msb) BC = nn ```, pseudocode: ```python # M2 if IR == 0x01: # example: LD BC, nn Z = read_memory(addr=PC); PC = PC + 1 # M3 W = read_memory(addr=PC); PC = PC + 1 # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; BC = WZ ``` ) #instruction( [ ==== LD (nn), SP: Load from stack pointer (direct) <op:LD_nn_sp> Load to the absolute address specified by the 16-bit operand `nn`, data from the 16-bit SP register. ], mnemonic: "LD (nn), SP", opcode: [#bin("00001000")/#hex("08")], operand_bytes: ([LSB(`nn`)], [MSB(`nn`)]), timing: ( duration: 5, mem_rw: ([opcode], [R: Z], [R: W], [W: SPH], [W: SPL],), addr: ([PC], [PC], [WZ], [WZ], [PC],), data: ([Z ← mem], [W ← mem], [mem ← SPL], [mem ← SPH], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], [WZ ← WZ + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U", "U", "U",), misc_op: ("U", "U", "U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x08: nn_lsb = read_memory(addr=PC); PC = PC + 1 nn_msb = read_memory(addr=PC); PC = PC + 1 nn = unsigned_16(lsb=nn_lsb, msb=nn_msb) write_memory(addr=nn, data=lsb(SP)); nn = nn + 1 write_memory(addr=nn, data=msb(SP)) ```, pseudocode: ```python # M2 if IR == 0x08: Z = read_memory(addr=PC); PC = PC + 1 # M3 W = read_memory(addr=PC); PC = PC + 1 # M4 write_memory(addr=WZ, data=lsb(SP)); WZ = WZ + 1 # M5 write_memory(addr=WZ, data=msb(SP)) # M6/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== LD SP, HL: Load stack pointer from HL <op:LD_sp_hl> Load to the 16-bit SP register, data from the 16-bit HL register. ], mnemonic: "LD SP, HL", opcode: [#bin("11111001")/#hex("F9")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], "U",), addr: ([HL], [PC],), data: ("U", [IR ← mem],), idu_op: ([SP ← HL], [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xF9: SP = HL ```, pseudocode: ```python # M2 if IR == 0xF9: SP = HL # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== PUSH rr: Push to stack <op:PUSH_rr> Push to the stack memory, data from the 16-bit register `rr`. ], mnemonic: "PUSH rr", opcode: [#bin("11xx0101")/various], operand_bytes: (), timing: ( duration: 4, mem_rw: ([opcode], "U", [W: msb `rr`], [W: lsb `rr`],), addr: ([SP], [SP], [SP], [PC],), data: ("U", [mem ← msb `rr`], [mem ← lsb `rr`], [IR ← mem],), idu_op: ([SP ← SP - 1], [SP ← SP - 1], [SP ← SP], [PC ← PC + 1],), alu_op: ("U", "U", "U", "U",), misc_op: ("U", "U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xC5: # example: PUSH BC SP = SP - 1 write_memory(addr=SP, data=msb(BC)); SP = SP - 1 write_memory(addr=SP, data=lsb(BC)) ```, pseudocode: ```python # M2 if IR == 0xC5: # example: PUSH BC SP = SP - 1 # M3 write_memory(addr=SP, data=msb(BC)); SP = SP - 1 # M4 write_memory(addr=SP, data=lsb(BC)) # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== POP rr: Pop from stack <op:POP_rr> Pops to the 16-bit register `rr`, data from the stack memory. This instruction does not do calculations that affect flags, but POP AF completely replaces the F register value, so all flags are changed based on the 8-bit data that is read from memory. ], mnemonic: "POP rr", flags: [See the instruction description], opcode: [#bin("11xx0001")/various], operand_bytes: (), timing: ( duration: 3, mem_rw: ([opcode], [R: lsb `rr`], [R: msb `rr`],), addr: ([SP], [SP], [PC],), data: ([Z ← mem], [W ← mem], [IR ← mem],), idu_op: ([SP ← SP + 1], [SP ← SP + 1], [PC ← PC + 1],), alu_op: ("U", "U", "U",), misc_op: ("U", "U", [`rr` ← WZ],), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xC1: # example: POP BC lsb = read_memory(addr=SP); SP = SP + 1 msb = read_memory(addr=SP); SP = SP + 1 BC = unsigned_16(lsb=lsb, msb=msb) ```, pseudocode: ```python # M2 if IR == 0xC1: # example: POP BC Z = read_memory(addr=SP); SP = SP + 1 # M3 W = read_memory(addr=SP); SP = SP + 1 # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; BC = WZ ``` ) #instruction( [ ==== LD HL, SP+e: Load HL from adjusted stack pointer <op:LD_hl_sp_e> Load to the HL register, 16-bit data calculated by adding the signed 8-bit operand `e` to the 16-bit value of the SP register. ], mnemonic: "LD HL, SP+e", flags: [Z = 0, N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("11111000")/#hex("F8")], operand_bytes: ([`e`],), timing: ( duration: 3, mem_rw: ([opcode], [R: `e`], "U",), addr: ([PC], [#hex("0000")], [PC],), data: ([Z ← mem], "U", [IR ← mem],), idu_op: ([PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", [L ← SPL + Z], [H ← SPH +#sub[c] adj],), misc_op: ("U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xF8: e = signed_8(read_memory(addr=PC)); PC = PC + 1 result, carry_per_bit = SP + e HL = result flags.Z = 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0xF8: Z = read_memory(addr=PC); PC = PC + 1 # M3 result, carry_per_bit = lsb(SP) + Z L = result flags.Z = 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 Z_sign = bit(7, Z) # M4/M1 adj = 0xFF if Z_sign else 0x00 result = msb(SP) + adj + flags.C H = result IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) === 8-bit arithmetic and logical instructions #instruction( [ ==== ADD r: Add (register) <op:ADD_r> Adds to the 8-bit A register, the 8-bit register `r`, and stores the result back into the A register. ], mnemonic: "ADD r", flags: [Z = #flag-update, N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("10000xxx")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← A + `r`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x80: # example: ADD B result, carry_per_bit = A + B A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2/M1 if IR == 0x80: # example: ADD B result, carry_per_bit = A + B A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== ADD (HL): Add (indirect HL) <op:ADD_hl> Adds to the 8-bit A register, data from the absolute address specified by the 16-bit register HL, and stores the result back into the A register. ], mnemonic: "ADD (HL)", flags: [Z = #flag-update, N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("10000110")/#hex("86")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← A + Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x86: data = read_memory(addr=HL) result, carry_per_bit = A + data A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0x86: Z = read_memory(addr=HL) # M3/M1 result, carry_per_bit = A + Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== ADD n: Add (immediate) <op:ADD_n> Adds to the 8-bit A register, the immediate data `n`, and stores the result back into the A register. ], mnemonic: "ADD n", flags: [Z = #flag-update, N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("11000110")/#hex("C6")], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [A ← A + Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xC6: n = read_memory(addr=PC); PC = PC + 1 result, carry_per_bit = A + n A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0xC6: Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 result, carry_per_bit = A + Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== ADC r: Add with carry (register) <op:ADC_r> Adds to the 8-bit A register, the carry flag and the 8-bit register `r`, and stores the result back into the A register. ], mnemonic: "ADC r", flags: [Z = #flag-update, N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("10001xxx")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← A +#sub[c] `r`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x88: # example: ADC B result, carry_per_bit = A + B + flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2/M1 if IR == 0x88: # example: ADC B result, carry_per_bit = A + B + flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== ADC (HL): Add with carry (indirect HL) <op:ADC_hl> Adds to the 8-bit A register, the carry flag and data from the absolute address specified by the 16-bit register HL, and stores the result back into the A register. ], mnemonic: "ADC (HL)", flags: [Z = #flag-update, N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("10001110")/#hex("8E")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← A +#sub[c] Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x8E: data = read_memory(addr=HL) result, carry_per_bit = A + data + flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0x8E: Z = read_memory(addr=HL) # M3/M1 result, carry_per_bit = A + Z + flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== ADC n: Add with carry (immediate) <op:ADC_n> Adds to the 8-bit A register, the carry flag and the immediate data `n`, and stores the result back into the A register. ], mnemonic: "ADC n", flags: [Z = #flag-update, N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("11001110")/#hex("CE")], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [A ← A +#sub[c] Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xCE: n = read_memory(addr=PC); PC = PC + 1 result, carry_per_bit = A + n + flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0xCE: Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 result, carry_per_bit = A + Z + flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== SUB r: Subtract (register) <op:SUB_r> Subtracts from the 8-bit A register, the 8-bit register `r`, and stores the result back into the A register. ], mnemonic: "SUB r", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("10010xxx")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← A - `r`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x90: # example: SUB B result, carry_per_bit = A - B A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2/M1 if IR == 0x90: # example: SUB B result, carry_per_bit = A - B A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== SUB (HL): Subtract (indirect HL) <op:SUB_hl> Subtracts from the 8-bit A register, data from the absolute address specified by the 16-bit register HL, and stores the result back into the A register. ], mnemonic: "SUB (HL)", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("10010110")/#hex("96")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← A - Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x96: data = read_memory(addr=HL) result, carry_per_bit = A - data A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0x96: Z = read_memory(addr=HL) # M3/M1 result, carry_per_bit = A - Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== SUB n: Subtract (immediate) <op:SUB_n> Subtracts from the 8-bit A register, the immediate data `n`, and stores the result back into the A register. ], mnemonic: "SUB n", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("11010110")/#hex("D6")], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [A ← A - Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xD6: n = read_memory(addr=PC); PC = PC + 1 result, carry_per_bit = A - n A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0xD6: Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 result, carry_per_bit = A - Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== SBC r: Subtract with carry (register) <op:SBC_r> Subtracts from the 8-bit A register, the carry flag and the 8-bit register `r`, and stores the result back into the A register. ], mnemonic: "SBC r", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("10011xxx")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← A -#sub[c] `r`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x98: # example: SBC B result, carry_per_bit = A - B - flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2/M1 if IR == 0x98: # example: SBC B result, carry_per_bit = A - B - flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== SBC (HL): Subtract with carry (indirect HL) <op:SBC_hl> Subtracts from the 8-bit A register, the carry flag and data from the absolute address specified by the 16-bit register HL, and stores the result back into the A register. ], mnemonic: "SBC (HL)", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("10011110")/#hex("9E")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← A -#sub[c] Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x9E: data = read_memory(addr=HL) result, carry_per_bit = A - data - flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0x9E: Z = read_memory(addr=HL) # M3/M1 result, carry_per_bit = A - Z - flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== SBC n: Subtract with carry (immediate) <op:SBC_n> Subtracts from the 8-bit A register, the carry flag and the immediate data `n`, and stores the result back into the A register. ], mnemonic: "SBC n", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("11011110")/#hex("DE")], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [A ← A -#sub[c] Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xDE: n = read_memory(addr=PC); PC = PC + 1 result, carry_per_bit = A - n - flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0xDE: Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 result, carry_per_bit = A - Z - flags.C A = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== CP r: Compare (register) <op:CP_r> Subtracts from the 8-bit A register, the 8-bit register `r`, and updates flags based on the result. This instruction is basically identical to #link(<op:SUB_r>)[SUB r], but does not update the A register. ], mnemonic: "CP r", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("10111xxx")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A - `r`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xB8: # example: CP B result, carry_per_bit = A - B flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2/M1 if IR == 0xB8: # example: CP B result, carry_per_bit = A - B flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== CP (HL): Compare (indirect HL) <op:CP_hl> Subtracts from the 8-bit A register, data from the absolute address specified by the 16-bit register HL, and updates flags based on the result. This instruction is basically identical to #link(<op:SUB_hl>)[SUB (HL)], but does not update the A register. ], mnemonic: "CP (HL)", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("10011110")/#hex("9E")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A - Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xBE: data = read_memory(addr=HL) result, carry_per_bit = A - data flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0xBE: Z = read_memory(addr=HL) # M3/M1 result, carry_per_bit = A - Z flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== CP n: Compare (immediate) <op:CP_n> Subtracts from the 8-bit A register, the immediate data `n`, and updates flags based on the result. This instruction is basically identical to #link(<op:SUB_n>)[SUB n], but does not update the A register. ], mnemonic: "CP n", flags: [Z = #flag-update, N = 1, H = #flag-update, C = #flag-update], opcode: [#bin("11111110")/#hex("FE")], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [A - Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xFE: n = read_memory(addr=PC); PC = PC + 1 result, carry_per_bit = A - n flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0xFE: Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 result, carry_per_bit = A - Z flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ``` ) #instruction( [ ==== INC r: Increment (register) <op:INC_r> Increments data in the 8-bit register `r`. ], mnemonic: "INC r", flags: [Z = #flag-update, N = 0, H = #flag-update], opcode: [#bin("00xxx100")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([`r` ← `r` + 1],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x04: # example: INC B result, carry_per_bit = B + 1 B = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 ```, pseudocode: ```python if opcode == 0x04: # example: INC B # M2/M1 result, carry_per_bit = B + 1 B = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== INC (HL): Increment (indirect HL) <op:INC_hl> Increments data at the absolute address specified by the 16-bit register HL. ], mnemonic: "INC (HL)", flags: [Z = #flag-update, N = 0, H = #flag-update], opcode: [#bin("00110100")/#hex("34")], operand_bytes: (), timing: ( duration: 3, mem_rw: ([opcode], [R: data], [W: data],), addr: ([HL], [HL], [PC],), data: ([Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ("U", "U", [PC ← PC + 1],), alu_op: ("U", [mem ← Z + 1], "U",), misc_op: ("U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x34: data = read_memory(addr=HL) result, carry_per_bit = data + 1 write_memory(addr=HL, data=result) flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 ```, pseudocode: ```python # M2 if IR == 0x34: Z = read_memory(addr=HL) # M3 result, carry_per_bit = Z + 1 write_memory(addr=HL, data=result) flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== DEC r: Decrement (register) <op:DEC_r> Increments data in the 8-bit register `r`. ], mnemonic: "DEC r", flags: [Z = #flag-update, N = 1, H = #flag-update], opcode: [#bin("00xxx101")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([`r` ← `r` - 1],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 # example: DEC B if opcode == 0x05: result, carry_per_bit = B - 1 B = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 ```, pseudocode: ```python # M2/M1 if IR == 0x05: # example: DEC B result, carry_per_bit = B - 1 B = result flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== DEC (HL): Decrement (indirect HL) <op:DEC_hl> Decrements data at the absolute address specified by the 16-bit register HL. ], mnemonic: "DEC (HL)", flags: [Z = #flag-update, N = 1, H = #flag-update], opcode: [#bin("00110101")/#hex("35")], operand_bytes: (), timing: ( duration: 3, mem_rw: ([opcode], [R: data], [W: data],), addr: ([HL], [HL], [PC],), data: ([Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ("U", "U", [PC ← PC + 1],), alu_op: ("U", [mem ← Z - 1], "U",), misc_op: ("U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x35: data = read_memory(addr=HL) result, carry_per_bit = data - 1 write_memory(addr=HL, data=result) flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 ```, pseudocode: ```python # M2 if IR == 0x35: Z = read_memory(addr=HL) # M3 result, carry_per_bit = Z - 1 write_memory(addr=HL, data=result) flags.Z = 1 if result == 0 else 0 flags.N = 1 flags.H = 1 if carry_per_bit[3] else 0 # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== AND r: Bitwise AND (register) <op:AND_r> Performs a bitwise AND operation between the 8-bit A register and the 8-bit register `r`, and stores the result back into the A register. ], mnemonic: "AND r", flags: [Z = #flag-update, N = 0, H = 1, C = 0], opcode: [#bin("10100xxx")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← A and `r`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xA0: # example: AND B result = A & B A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 flags.C = 0 ```, pseudocode: ```python # M2/M1 if IR == 0xA0: # example: AND B result = A & B A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== AND (HL): Bitwise AND (indirect HL) <op:AND_hl> Performs a bitwise AND operation between the 8-bit A register and data from the absolute address specified by the 16-bit register HL, and stores the result back into the A register. ], mnemonic: "AND (HL)", flags: [Z = #flag-update, N = 0, H = 1, C = 0], opcode: [#bin("10100110")/#hex("A6")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← A and Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xA6: data = read_memory(addr=HL) result = A & data A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 flags.C = 0 ```, pseudocode: ```python # M2 if IR == 0xA6: Z = read_memory(addr=HL) # M3/M1 result = A & Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== AND n: Bitwise AND (immediate) <op:AND_n> Performs a bitwise AND operation between the 8-bit A register and immediate data `n`, and stores the result back into the A register. ], mnemonic: "AND n", flags: [Z = #flag-update, N = 0, H = 1, C = 0], opcode: [#bin("11100110")/#hex("E6")], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [A ← A and Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xE6: n = read_memory(addr=PC); PC = PC + 1 result = A & n A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 flags.C = 0 ```, pseudocode: ```python # M2 if IR == 0xE6: Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 result = A & Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 1 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== OR r: Bitwise OR (register) <op:OR_r> Performs a bitwise OR operation between the 8-bit A register and the 8-bit register `r`, and stores the result back into the A register. ], mnemonic: "OR r", flags: [Z = #flag-update, N = 0, H = 0, C = 0], opcode: [#bin("10110xxx")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← A or `r`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xB0: # example: OR B result = A | B A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 ```, pseudocode: ```python # M2/M1 if IR == 0xB0: # example: OR B result = A | B A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== OR (HL): Bitwise OR (indirect HL) <op:OR_hl> Performs a bitwise OR operation between the 8-bit A register and data from the absolute address specified by the 16-bit register HL, and stores the result back into the A register. ], mnemonic: "OR (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = 0], opcode: [#bin("10110110")/#hex("B6")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← A or Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xB6: data = read_memory(addr=HL) result = A | data A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 ```, pseudocode: ```python # M2 if IR == 0xB6: Z = read_memory(addr=HL) # M3/M1 result = A | Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== OR n: Bitwise OR (immediate) <op:OR_n> Performs a bitwise OR operation between the 8-bit A register and immediate data `n`, and stores the result back into the A register. ], mnemonic: "OR n", flags: [Z = #flag-update, N = 0, H = 0, C = 0], opcode: [#bin("11110110")/#hex("F6")], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [A ← A or Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xF6: n = read_memory(addr=PC); PC = PC + 1 result = A | n A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 ```, pseudocode: ```python # M2 if IR == 0xF6: Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 result = A | Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== XOR r: Bitwise XOR (register) <op:XOR_r> Performs a bitwise XOR operation between the 8-bit A register and the 8-bit register `r`, and stores the result back into the A register. ], mnemonic: "XOR r", flags: [Z = #flag-update, N = 0, H = 0, C = 0], opcode: [#bin("10101xxx")/various], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← A xor `r`],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xA8: # example: XOR B result = A ^ B A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 ```, pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xA8: # example: XOR B # M2/M1 result = A ^ B A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== XOR (HL): Bitwise XOR (indirect HL) <op:XOR_hl> Performs a bitwise XOR operation between the 8-bit A register and data from the absolute address specified by the 16-bit register HL, and stores the result back into the A register. ], mnemonic: "XOR (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = 0], opcode: [#bin("10101110")/#hex("AE")], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], [R: data],), addr: ([HL], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", [A ← A xor Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xAE: data = read_memory(addr=HL) result = A ^ data A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 ```, pseudocode: ```python # M2 if IR == 0xAE: Z = read_memory(addr=HL) # M3/M1 result = A ^ Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== XOR n: Bitwise XOR (immediate) <op:XOR_n> Performs a bitwise XOR operation between the 8-bit A register and immediate data `n`, and stores the result back into the A register. ], mnemonic: "XOR n", flags: [Z = #flag-update, N = 0, H = 0, C = 0], opcode: [#bin("11101110")/#hex("EE")], operand_bytes: ([`n`],), timing: ( duration: 2, mem_rw: ([opcode], [R: `n`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [A ← A xor Z],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xEE: n = read_memory(addr=PC); PC = PC + 1 result = A ^ n A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 ```, pseudocode: ```python # M2 if IR == 0xEE: Z = read_memory(addr=PC); PC = PC + 1 # M3/M1 result = A ^ Z A = result flags.Z = 1 if result == 0 else 0 flags.N = 0 flags.H = 0 flags.C = 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== CCF: Complement carry flag <op:CCF> Flips the carry flag, and clears the N and H flags. ], mnemonic: "CCF", flags: [N = 0, H = 0, C = #flag-update], opcode: [#bin("00111111")/#hex("3F")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([cf ← not cf],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x3F: flags.N = 0 flags.H = 0 flags.C = ~flags.C ```, pseudocode: ```python # M2/M1 if IR == 0x3F: flags.N = 0 flags.H = 0 flags.C = ~flags.C IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== SCF: Set carry flag <op:SCF> Sets the carry flag, and clears the N and H flags. ], mnemonic: "SCF", flags: [N = 0, H = 0, C = 1], opcode: [#bin("00110111")/#hex("37")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([cf ← 1],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x37: flags.N = 0 flags.H = 0 flags.C = 1 ```, pseudocode: ```python # M2/M1 if IR == 0x37: flags.N = 0 flags.H = 0 flags.C = 1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== DAA: Decimal adjust accumulator <op:DAA> TODO ], mnemonic: "DAA", flags: [Z = #flag-update, H = 0, C = #flag-update], opcode: [#bin("00100111")/#hex("27")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← A + adj],), misc_op: ("U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== CPL: Complement accumulator <op:CPL> Flips all the bits in the 8-bit A register, and sets the N and H flags. ], mnemonic: "CPL", flags: [N = 1, H = 1], opcode: [#bin("00101111")/#hex("2F")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← not A],), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x2F: A = ~A flags.N = 1 flags.H = 1 ```, pseudocode: ```python # M2/M1 if IR == 0x2F: A = ~A flags.N = 1 flags.H = 1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) === 16-bit arithmetic instructions #instruction( [ ==== INC rr: Increment 16-bit register <op:INC_rr> Increments data in the 16-bit register `rr`. ], mnemonic: "INC rr", opcode: [#bin("00xx0011")/various], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], "U",), addr: ([`rr`], [PC],), data: ("U", [IR ← mem],), idu_op: ([`rr` ← `rr` + 1], [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x03: # example: INC BC BC = BC + 1 ```, pseudocode: ```python # M2 if IR == 0x03: # example: INC BC BC = BC + 1 # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== DEC rr: Decrement 16-bit register <op:DEC_rr> Decrements data in the 16-bit register `rr`. ], mnemonic: "DEC rr", opcode: [#bin("00xx1011")/various], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], "U",), addr: ([`rr`], [PC],), data: ("U", [IR ← mem],), idu_op: ([`rr` ← `rr` - 1], [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x0B: # example: DEC BC BC = BC - 1 ```, pseudocode: ```python # M2 if IR == 0x0B: # example: DEC BC BC = BC - 1 # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== ADD HL, rr: Add (16-bit register) <op:ADD_hl_rr> Adds to the 16-bit HL register pair, the 16-bit register `rr`, and stores the result back into the HL register pair. ], mnemonic: "ADD HL, rr", flags: [N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("00xx1001")/various], operand_bytes: (), timing: ( duration: 2, mem_rw: ([opcode], "U",), addr: ([#hex("0000")], [PC],), data: ("U", [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ([L ← L + lsb `rr`], [H ← H +#sub[c] msb `rr`],), misc_op: ("U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x09: # example: ADD HL, BC result, carry_per_bit = HL + BC HL = result flags.N = 0 flags.H = 1 if carry_per_bit[11] else 0 flags.C = 1 if carry_per_bit[15] else 0 ```, pseudocode: ```python # M2 if IR == 0x09: # example: ADD HL, BC result, carry_per_bit = L + C L = result flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 # M3/M1 result, carry_per_bit = H + B + flags.C H = result flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== ADD SP, e: Add to stack pointer (relative) <op:ADD_sp_e> Loads to the 16-bit SP register, 16-bit data calculated by adding the signed 8-bit operand `e` to the 16-bit value of the SP register. ], mnemonic: "ADD SP, e", flags: [Z = 0, N = 0, H = #flag-update, C = #flag-update], opcode: [#bin("11101000")/#hex("E8")], operand_bytes: ([`e`],), timing: ( duration: 4, mem_rw: ([opcode], [R: `e`], "U", "U",), addr: ([PC], [#hex("0000")], [#hex("0000")], [PC],), data: ([Z ← mem], [ALU], [ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", [Z ← SPL + Z], [W ← SPH +#sub[c] adj], "U",), misc_op: ("U", "U", "U", [SP ← WZ],), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xE8: e = signed_8(read_memory(addr=PC)); PC = PC + 1 result, carry_per_bit = SP + e SP = result flags.Z = 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 ```, pseudocode: ```python # M2 if IR == 0xE8: Z = read_memory(addr=PC); PC = PC + 1 # M3 result, carry_per_bit = lsb(SP) + Z Z = result flags.Z = 0 flags.N = 0 flags.H = 1 if carry_per_bit[3] else 0 flags.C = 1 if carry_per_bit[7] else 0 # M4 result = msb(SP) + adj + flags.C W = result # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1; SP = WZ ``` ) #pagebreak() === Rotate, shift, and bit operation instructions #instruction( [ ==== RLCA: Rotate left circular (accumulator) <op:RLCA> TODO ], mnemonic: "RLCA", flags: [Z = 0, N = 0, H = 0, C = #flag-update], opcode: [#bin("00000111")/#hex("07")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← rlc A],), misc_op: ("U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RRCA: Rotate right circular (accumulator) <op:RRCA> TODO ], mnemonic: "RRCA", flags: [Z = 0, N = 0, H = 0, C = #flag-update], opcode: [#bin("00001111")/#hex("0F")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← rrc A],), misc_op: ("U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RLA: Rotate left (accumulator) <op:RLA> TODO ], mnemonic: "RLA", flags: [Z = 0, N = 0, H = 0, C = #flag-update], opcode: [#bin("00010111")/#hex("17")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← rl A],), misc_op: ("U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RRA: Rotate right (accumulator) <op:RRA> TODO ], mnemonic: "RRA", flags: [Z = 0, N = 0, H = 0, C = #flag-update], opcode: [#bin("00011111")/#hex("1F")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ([A ← rr A],), misc_op: ("U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RLC r: Rotate left circular (register) <op:RLC_r> TODO ], mnemonic: "RLC r", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#bin("00000xxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← rlc `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RLC (HL): Rotate left circular (indirect HL) <op:RLC_hl> TODO ], mnemonic: "RLC (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#hex("06")], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← rlc Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RRC r: Rotate right circular (register) <op:RRC_r> TODO ], mnemonic: "RRC r", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#bin("00001xxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← rrc `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RRC (HL): Rotate right circular (indirect HL) <op:RRC_hl> TODO ], mnemonic: "RRC (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#hex("0E")], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← rrc Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RL r: Rotate left (register) <op:RL_r> TODO ], mnemonic: "RL r", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#bin("00010xxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← rl `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RL (HL): Rotate left (indirect HL) <op:RL_hl> TODO ], mnemonic: "RL (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#hex("16")], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← rl Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RR r: Rotate right (register) <op:RR_r> TODO ], mnemonic: "RR r", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#bin("00011xxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← rr `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RR (HL): Rotate right (indirect HL) <op:RR_hl> TODO ], mnemonic: "RR (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#hex("1E")], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← rr Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SLA r: Shift left arithmetic (register) <op:SLA_r> TODO ], mnemonic: "SLA r", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#bin("00100xxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← sla `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SLA (HL): Shift left arithmetic (indirect HL) <op:SLA_hl> TODO ], mnemonic: "SLA (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#hex("26")], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← sla Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SRA r: Shift right arithmetic (register) <op:SRA_r> TODO ], mnemonic: "SRA r", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#bin("00101xxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← sra `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SRA (HL): Shift right arithmetic (indirect HL) <op:SRA_hl> TODO ], mnemonic: "SRA (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#hex("2E")], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← sra Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SWAP r: Swap nibbles (register) <op:SWAP_r> TODO ], mnemonic: "SWAP r", flags: [Z = #flag-update, N = 0, H = 0, C = 0], opcode: [#bin("00110xxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← swap `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SWAP (HL): Swap nibbles (indirect HL) <op:SWAP_hl> TODO ], mnemonic: "SWAP (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = 0], opcode: [#hex("36")], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← swap Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SRL r: Shift right logical (register) <op:SRL_r> TODO ], mnemonic: "SRL r", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#bin("00111xxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← srl `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SRL (HL): Shift right logical (indirect HL) <op:SRL_hl> TODO ], mnemonic: "SRL (HL)", flags: [Z = #flag-update, N = 0, H = 0, C = #flag-update], opcode: [#hex("3E")], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← srl Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== BIT b, r: Test bit (register) <op:BIT_b_r> TODO ], mnemonic: "BIT b, r", flags: [Z = #flag-update, N = 0, H = 1], opcode: [#bin("01xxxxxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [bit `b`, `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== BIT b, (HL): Test bit (indirect HL) <op:BIT_b_hl> TODO ], mnemonic: "BIT b, (HL)", flags: [Z = #flag-update, N = 0, H = 1], opcode: [#bin("01xxx110")/various], operand_bytes: (), cb: true, timing: ( duration: 3, mem_rw: ([CB prefix], [opcode], [R: data]), addr: ([PC], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", [bit `b`, Z],), misc_op: ("U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RES b, r: Reset bit (register) <op:RES_b_r> TODO ], mnemonic: "RES b, r", opcode: [#bin("10xxxxxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← res `b`, `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== RES b, (HL): Reset bit (indirect HL) <op:RES_b_hl> TODO ], mnemonic: "RES b, (HL)", opcode: [#bin("10xxx110")/various], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← res `b`, Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SET b, r: Set bit (register) <op:SET_b_r> TODO ], mnemonic: "SET b, r", opcode: [#bin("11xxxxxx")/various], operand_bytes: (), cb: true, timing: ( duration: 2, mem_rw: ([CB prefix], [opcode],), addr: ([PC], [PC],), data: ([IR ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", [`r` ← set `b`, `r`],), misc_op: ("U", "U",), ), pseudocode: ```python TODO ``` ) #instruction( [ ==== SET b, (HL): Set bit (indirect HL) <op:SET_b_hl> TODO ], mnemonic: "SET b, (HL)", opcode: [#bin("11xxx110")/various], operand_bytes: (), cb: true, timing: ( duration: 4, mem_rw: ([CB prefix], [opcode], [R: data], [W: data]), addr: ([PC], [HL], [HL], [PC],), data: ([IR ← mem], [Z ← mem], [mem ← ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], "U", "U", [PC ← PC + 1],), alu_op: ("U", "U", [mem ← set `b`, Z], "U",), misc_op: ("U", "U", "U", "U",), ), pseudocode: ```python TODO ``` ) #pagebreak() === Control flow instructions #instruction( [ ==== JP nn: Jump <op:JP> Unconditional jump to the absolute address specified by the 16-bit immediate operand `nn`. ], mnemonic: "JP nn", opcode: [#bin("11000011")/#hex("C3")], operand_bytes: ([LSB(`nn`)], [MSB(`nn`)]), timing: ( duration: 4, mem_rw: ([opcode], [R: lsb(`nn`)], [R: msb(`nn`)], "U",), addr: ([PC], [PC], [#hex("0000")], [PC],), data: ([Z ← mem], [W ← mem], "U", [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U", "U",), misc_op: ("U", "U", [PC ← WZ], "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xC3: nn_lsb = read_memory(addr=PC); PC = PC + 1 nn_msb = read_memory(addr=PC); PC = PC + 1 nn = unsigned_16(lsb=nn_lsb, msb=nn_msb) PC = nn ```, pseudocode: ```python # M2 if IR == 0xC3: Z = read_memory(addr=PC); PC = PC + 1 # M3 W = read_memory(addr=PC); PC = PC + 1 # M4 PC = WZ # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== JP HL: Jump to HL <op:JP_hl> Unconditional jump to the absolute address specified by the 16-bit register HL. ], mnemonic: "JP HL", opcode: [#bin("11101001")/#hex("E9")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([HL],), data: ([IR ← mem],), idu_op: ([PC ← HL + 1],), alu_op: ("U",), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xE9: PC = HL ```, pseudocode: ```python # M2/M1 if IR == 0xE9: IR, intr = fetch_cycle(addr=HL); PC = HL + 1 ``` ) #warning[ In some documentation this instruction is written as `JP [HL]`. This is very misleading, since brackets are usually used to indicate a memory read, and this instruction simply copies the value of HL to PC. ] #instruction( [ ==== JP cc, nn: Jump (conditional) <op:JP_cc> Conditional jump to the absolute address specified by the 16-bit operand `nn`, depending on the condition `cc`. Note that the operand (absolute address) is read even when the condition is false! ], mnemonic: "JP cc, nn", opcode: [#bin("110xx010")/various], operand_bytes: ([LSB(`nn`)], [MSB(`nn`)]), timing: ( cc_true: ( duration: 4, mem_rw: ([opcode], [R: lsb(`nn`)], [R: msb(`nn`)], "U",), addr: ([PC], [PC], [#hex("0000")], [PC],), data: ([Z ← mem], [W ← mem], "U", [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U", "U",), misc_op: ("U", [cc check], [PC ← WZ], "U",), ), cc_false: ( duration: 3, mem_rw: ([opcode], [R: lsb(`nn`)], [R: msb(`nn`)],), addr: ([PC], [PC], [PC],), data: ([Z ← mem], [W ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", "U", "U",), misc_op: ("U", [cc check], "U",), ) ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xC2: # example: JP NZ, nn nn_lsb = read_memory(addr=PC); PC = PC + 1 nn_msb = read_memory(addr=PC); PC = PC + 1 nn = unsigned_16(lsb=nn_lsb, msb=nn_msb) if !flags.Z: # cc=true PC = nn ```, pseudocode: ```python # M2 if IR == 0xC2: # example: JP NZ, nn Z = read_memory(addr=PC); PC = PC + 1 # M3 W = read_memory(addr=PC); PC = PC + 1 if !flags.Z: # cc=true # M4 PC = WZ # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 else: # cc=false # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== JR e: Relative jump <op:JR> Unconditional jump to the relative address specified by the signed 8-bit operand `e`. ], mnemonic: "JR e", opcode: [#bin("00011000")/#hex("18")], operand_bytes: ([`e`],), timing: ( duration: 3, mem_rw: ([opcode], [R: `e`], "U",), addr: ([PC], [PCH], [WZ],), data: ([Z ← mem], [ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], [W ← adj PCH], [PC ← WZ + 1],), alu_op: ("U", [Z ← PCL + Z], "U",), misc_op: ("U", "U", "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x18: e = signed_8(read_memory(addr=PC)); PC = PC + 1 PC = PC + e ```, pseudocode: ```python # M2 if IR == 0x18: Z = read_memory(addr=PC); PC = PC + 1 # M3 Z_sign = bit(7, Z) result, carry_per_bit = Z + lsb(PC) Z = result adj = 1 if carry_per_bit[7] and not Z_sign else -1 if not carry_per_bit[7] and Z_sign else 0 W = msb(PC) + adj # M4/M1 IR, intr = fetch_cycle(addr=WZ); PC = WZ + 1 ``` ) #instruction( [ ==== JR cc, e: Relative jump (conditional) <op:JR_cc> Conditional jump to the relative address specified by the signed 8-bit operand `e`, depending on the condition `cc`. Note that the operand (relative address offset) is read even when the condition is false! ], mnemonic: "JR cc, e", opcode: [#bin("001xx000")/various], operand_bytes: ([`e`],), timing: ( cc_true: ( duration: 3, mem_rw: ([opcode], [R: `e`], "U",), addr: ([PC], [PCH], [WZ],), data: ([Z ← mem], [ALU], [IR ← mem],), idu_op: ([PC ← PC + 1], [W ← adj PCH], [PC ← WZ + 1],), alu_op: ("U", [Z ← PCL + Z], "U",), misc_op: ([cc check], "U", "U",), ), cc_false: ( duration: 2, mem_rw: ([opcode], [R: `e`],), addr: ([PC], [PC],), data: ([Z ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ([cc check], "U",), ) ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x20: e = signed_8(read_memory(addr=PC)); PC = PC + 1 if !flags.Z: # cc=true PC = PC + e ```, pseudocode: ```python # M2 if IR == 0x20: Z = read_memory(addr=PC); PC = PC + 1 if !flags.Z: # cc=true # M3 Z_sign = bit(7, Z) result, carry_per_bit = Z + lsb(PC) Z = result adj = 1 if carry_per_bit[7] and not Z_sign else -1 if not carry_per_bit[7] and Z_sign else 0 W = msb(PC) + adj # M4/M1 IR, intr = fetch_cycle(addr=WZ); PC = WZ + 1 else: # cc=false # M3/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== CALL nn: Call function <op:CALL> Unconditional function call to the absolute address specified by the 16-bit operand `nn`. ], mnemonic: "CALL nn", opcode: [#bin("11001101")/#hex("CD")], operand_bytes: ([LSB(`nn`)], [MSB(`nn`)]), timing: ( duration: 6, mem_rw: ([opcode], [R: lsb(`nn`)], [R: msb(`nn`)], "U", [W: msb(PC#sub[0]+3)], [W: lsb(PC#sub[0]+3)],), addr: ([PC], [PC], [SP], [SP], [SP], [PC],), data: ([Z ← mem], [W ← mem], "U", [mem ← PCH], [mem ← PCL], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], [SP ← SP - 1], [SP ← SP - 1], [SP ← SP], [PC ← PC + 1],), alu_op: ("U", "U", "U", "U", "U", "U",), misc_op: ("U", "U", "U", "U", [PC ← WZ], "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xCD: nn_lsb = read_memory(addr=PC); PC = PC + 1 nn_msb = read_memory(addr=PC); PC = PC + 1 nn = unsigned_16(lsb=nn_lsb, msb=nn_msb) SP = SP - 1 write_memory(addr=SP, data=msb(PC)); SP = SP - 1 write_memory(addr=SP, data=lsb(PC)) PC = nn ```, pseudocode: ```python # M2 if IR == 0xCD: Z = read_memory(addr=PC); PC = PC + 1 # M3 W = read_memory(addr=PC); PC = PC + 1 # M4 SP = SP - 1 # M5 write_memory(addr=SP, data=msb(PC)); SP = SP - 1 # M6 write_memory(addr=SP, data=lsb(PC)); PC = WZ # M7/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== CALL cc, nn: Call function (conditional) <op:CALL_cc> Conditional function call to the absolute address specified by the 16-bit operand `nn`, depending on the condition `cc`. Note that the operand (absolute address) is read even when the condition is false! ], mnemonic: "CALL cc, nn", opcode: [#bin("110xx100")/various], operand_bytes: ([LSB(`nn`)], [MSB(`nn`)]), timing: ( cc_true: ( duration: 6, mem_rw: ([opcode], [R: lsb(`nn`)], [R: msb(`nn`)], "U", [W: msb(PC#sub[0]+3)], [W: lsb(PC#sub[0]+3)],), addr: ([PC], [PC], [SP], [SP], [SP], [PC],), data: ([Z ← mem], [W ← mem], "U", [mem ← PCH], [mem ← PCL], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], [SP ← SP - 1], [SP ← SP - 1], [SP ← SP], [PC ← PC + 1],), alu_op: ("U", "U", "U", "U", "U", "U",), misc_op: ("U", [cc check], "U", "U", [PC ← WZ], "U",), ), cc_false: ( duration: 3, mem_rw: ([opcode], [R: lsb(`nn`)], [R: msb(`nn`)]), addr: ([PC], [PC], [PC],), data: ([Z ← mem], [W ← mem], [IR ← mem],), idu_op: ([PC ← PC + 1], [PC ← PC + 1], [PC ← PC + 1],), alu_op: ("U", "U", "U",), misc_op: ("U", [cc check], "U",), ) ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xC4: # example: CALL NZ, nn nn_lsb = read_memory(addr=PC); PC = PC + 1 nn_msb = read_memory(addr=PC); PC = PC + 1 nn = unsigned_16(lsb=nn_lsb, msb=nn_msb) if !flags.Z: # cc=true SP = SP - 1 write_memory(addr=SP, data=msb(PC)); SP = SP - 1 write_memory(addr=SP, data=lsb(PC)) PC = nn ```, pseudocode: ```python # M2 if IR == 0xC4: # example: CALL NZ, nn Z = read_memory(addr=PC); PC = PC + 1 # M3 W = read_memory(addr=PC); PC = PC + 1 if !flags.Z: # cc=true # M4 SP = SP - 1 # M5 write_memory(addr=SP, data=msb(PC)); SP = SP - 1 # M6 write_memory(addr=SP, data=lsb(PC)); PC = WZ # M7/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 else: # cc=false # M4/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== RET: Return from function <op:RET> Unconditional return from a function. ], mnemonic: "RET", opcode: [#bin("11001001")/#hex("C9")], operand_bytes: (), timing: ( duration: 4, mem_rw: ([opcode], [R: lsb(PC)], [R: msb(PC)], "U",), addr: ([SP], [SP], [#hex("0000")], [PC],), data: ([Z ← mem], [W ← mem], "U", [IR ← mem],), idu_op: ([SP ← SP + 1], [SP ← SP + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U", "U",), misc_op: ("U", "U", [PC ← WZ], "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xC9: lsb = read_memory(addr=SP); SP = SP + 1 msb = read_memory(addr=SP); SP = SP + 1 PC = unsigned_16(lsb=lsb, msb=msb) ```, pseudocode: ```python # M2 if IR == 0xC9: Z = read_memory(addr=SP); SP = SP + 1 # M3 W = read_memory(addr=SP); SP = SP + 1 # M4 PC = WZ # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== RET cc: Return from function (conditional) <op:RET_cc> Conditional return from a function, depending on the condition `cc`. ], mnemonic: "RET cc", opcode: [#bin("110xx000")/various], operand_bytes: (), timing: ( cc_true: ( duration: 5, mem_rw: ([opcode], "U", [R: lsb(PC)], [R: msb(PC)], "U",), addr: ([#hex("0000")], [SP], [SP], [#hex("0000")], [PC],), data: ("U", [Z ← mem], [W ← mem], "U", [IR ← mem],), idu_op: ("U", [SP ← SP + 1], [SP ← SP + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U", "U", "U",), misc_op: ([cc check], "U", "U", [PC ← WZ], "U",), ), cc_false: ( duration: 2, mem_rw: ([opcode], "U",), addr: ([#hex("0000")], [PC],), data: ("U", [IR ← mem],), idu_op: ("U", [PC ← PC + 1],), alu_op: ("U", "U",), misc_op: ([cc check], "U",), ) ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xC0: # example: RET NZ if !flags.Z: # cc=true lsb = read_memory(addr=SP); SP = SP + 1 msb = read_memory(addr=SP); SP = SP + 1 PC = unsigned_16(lsb=lsb, msb=msb) ```, pseudocode: ```python # M2 if IR == 0xC0: # example: RET NZ if !flags.Z: # cc=true # M3 Z = read_memory(addr=SP); SP = SP + 1 # M4 W = read_memory(addr=SP); SP = SP + 1 # M5 PC = WZ # M6/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 else: # cc=false # M3 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== RETI: Return from interrupt handler <op:RETI> Unconditional return from a function. Also enables interrupts by setting IME=1. ], mnemonic: "RETI", opcode: [#bin("11011001")/#hex("D9")], operand_bytes: (), timing: ( duration: 4, mem_rw: ([opcode], [R: lsb(PC)], [R: msb(PC)], "U",), addr: ([SP], [SP], [#hex("0000")], [PC],), data: ([Z ← mem], [W ← mem], "U", [IR ← mem],), idu_op: ([SP ← SP + 1], [SP ← SP + 1], "U", [PC ← PC + 1],), alu_op: ("U", "U", "U", "U",), misc_op: ("U", "U", [PC ← WZ, IME ← 1], "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xD9: lsb = read_memory(addr=SP); SP = SP + 1 msb = read_memory(addr=SP); SP = SP + 1 PC = unsigned_16(lsb=lsb, msb=msb) IME = 1 ```, pseudocode: ```python # M2 if IR == 0xD9: Z = read_memory(addr=SP); SP = SP + 1 # M3 W = read_memory(addr=SP); SP = SP + 1 # M4 PC = WZ; IME = 1 # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) #instruction( [ ==== RST n: Restart / Call function (implied) <op:RST> Unconditional function call to the absolute fixed address defined by the opcode. ], mnemonic: "RST n", opcode: [#bin("11xxx111")/various], operand_bytes: (), timing: ( duration: 4, mem_rw: ([opcode], "U", [W: msb PC], [W: lsb PC],), addr: ([SP], [SP], [SP], [PC],), data: ("U", [mem ← PCH], [mem ← PCL], [IR ← mem],), idu_op: ([SP ← SP - 1], [SP ← SP - 1], [SP ← SP], [PC ← PC + 1],), alu_op: ("U", "U", "U", "U",), misc_op: ("U", "U", [PC ← addr], "U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xDF: # example: RST 0x18 n = 0x18 SP = SP - 1 write_memory(addr=SP, data=msb(PC)); SP = SP - 1 write_memory(addr=SP, data=lsb(PC)) PC = unsigned_16(lsb=n, msb=0x00) ```, pseudocode: ```python # M2 if IR == 0xDF: # example: RST 0x18 SP = SP - 1 # M3 write_memory(addr=SP, data=msb(PC)); SP = SP - 1 # M4 write_memory(addr=SP, data=lsb(PC)); PC = 0x0018 # M5/M1 IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` ) === Miscellaneous instructions ==== HALT: Halt system clock <op:HALT> TODO ==== STOP: Stop system and main clocks <op:STOP> TODO #instruction( [ ==== DI: Disable interrupts <op:DI> Disables interrupt handling by setting IME=0 and cancelling any scheduled effects of the EI instruction if any. ], mnemonic: "DI", opcode: [#bin("11110011")/#hex("F3")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ("U",), misc_op: ("IME ← 0",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xF3: IME = 0 ```, pseudocode: ```python # M2/M1 if IR == 0xF3: # interrupt checking is suppressed so fetch_cycle(..) is not used IR = read_memory(addr=PC); PC = PC + 1; IME = 0 ``` ) #instruction( [ ==== EI: Enable interrupts <op:EI> Schedules interrupt handling to be enabled after the next machine cycle. ], mnemonic: "EI", opcode: [#bin("11111011")/#hex("FB")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ("U",), misc_op: ("IME ← 1",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0xFB: IME_next = 1 ```, pseudocode: ```python # M2/M1 if IR == 0xFB: IR, intr = fetch_cycle(addr=PC); PC = PC + 1; IME = 1 ``` ) #instruction( [ ==== NOP: No operation <op:NOP> No operation. This instruction doesn't do anything, but can be used to add a delay of one machine cycle and increment PC by one. ], mnemonic: "NOP", opcode: [#bin("00000000")/#hex("00")], operand_bytes: (), timing: ( duration: 1, mem_rw: ([opcode],), addr: ([PC],), data: ([IR ← mem],), idu_op: ([PC ← PC + 1],), alu_op: ("U",), misc_op: ("U",), ), simple-pseudocode: ```python opcode = read_memory(addr=PC); PC = PC + 1 if opcode == 0x00: # nothing ```, pseudocode: ```python # M2/M1 if IR == 0x00: IR, intr = fetch_cycle(addr=PC); PC = PC + 1 ``` )
https://github.com/howardlau1999/sysu-thesis-typst
https://raw.githubusercontent.com/howardlau1999/sysu-thesis-typst/master/templates/cover.typ
typst
MIT License
#import "../functions/style.typ": * #import "../functions/underline.typ": * #import "../functions/hline.typ": * #import "../info.typ": * #import "../custom.typ": * #box( grid( columns: (auto, auto), gutter: 0.4em, image("../images/vi/sysu-emblem.svg", height: 3em, fit: "contain") ) ) #linebreak() #v(1em) #text("本科生毕业论文(设计)", font: 字体.宋体, size: 字号.小初, weight: "semibold", fill: 强调色) #hline(thickness: 3pt) #v(-1em) #hline(thickness: 1.2pt) #set text(字号.二号) #v(60pt) #grid( columns: (80pt, 300pt), [ #set align(right + top) 题目: ], [ #set align(center + horizon) #chineseunderline(论文中文题目, width: 300pt, bold: true) ] ) #v(60pt) #set text(字号.三号) #let fieldname(name) = [ #set align(right + top) #strong(name) #h(0.25em) ] #let fieldvalue(value) = [ #set align(center + horizon) #set text(font: 字体.宋体) #grid( rows: (auto, auto), row-gutter: 0.2em, value, line(length: 100%) ) ] #grid( columns: (80pt, 280pt), row-gutter: 1em, fieldname(text("姓") + h(2em) + text("名")), fieldvalue(中文作者名), fieldname(text("学") + h(2em) + text("号")), fieldvalue(学号), fieldname(text("学") + h(2em) + text("院")), fieldvalue(学院), fieldname(text("专") + h(2em) + text("业")), fieldvalue(专业), fieldname("研究方向"), fieldvalue(方向), fieldname("指导教师"), fieldvalue(中文导师名), ) #v(2em) #set text(字号.小二) #text(日期)
https://github.com/csimide/SEU-Typst-Template
https://raw.githubusercontent.com/csimide/SEU-Typst-Template/master/seu-thesis/utils/show-heading.typ
typst
MIT License
#import "fonts.typ": 字体, 字号 #import "packages.typ": show-cn-fakebold, i-figured #import "states.typ": * #import "to-string.typ": to-string #import "fake-par.typ": fake-par #let show-heading( // 下方以数组形式给出的参数,代表 level 1, level 2, ... 标题分别使用的参数。 // 超过明示参数范围(数组下标)的,使用数组内最后一个参数 // 标题的上边距和下边距 heading-top-margin: (0.2cm, 0cm, 0cm), heading-bottom-margin: (0cm, 0cm, 0cm), // 标题的固定缩进量 heading-indent: (0cm, 0em, 0em), // 标题编号与标题的间隔 heading-space: (0.5em,), // 标题对齐方式 heading-align: (center, left, left), // 标题的字体 heading-text: ( (font: 字体.黑体, size: 字号.三号, weight: "bold"), (font: 字体.黑体, size: 字号.四号, weight: "regular"), (font: 字体.宋体, size: 字号.小四, weight: "regular") ), // 每次一级标题都切换到新的页面,取值为 auto bool 或 function ,如果 function 则会以 function 作为分页时执行的操作 always-new-page: false, // 为 true 时,二字标题会变为 A #h(2em) B auto-h-spacing: true, it ) = { set par(first-line-indent: 0em) let chapter-name-string = to-string(it.body) // 处理新页面换页 if it.level == 1 and always-new-page != false { if type(always-new-page) == function { always-new-page() } else { pagebreak(weak: true) } } // 标题前间距 v( heading-top-margin.at( it.level - 1, default: heading-top-margin.last(), ), ) // 标题 { set align( heading-align.at( it.level - 1, default: heading-align.last(), ), ) set text( ..heading-text.at( it.level - 1, default: heading-text.last(), ), ) h( heading-indent.at( it.level - 1, default: heading-indent.last(), ), ) // if it.numbering == none { // 两个字标题的特殊处理 if auto-h-spacing and chapter-name-string.clusters().len() == 2 { chapter-name-string.clusters().first() h(2em) chapter-name-string.clusters().last() } else { it.body } } else { context counter(heading).display() // “第X章” “X.X” 与标题的间距 h( heading-space.at(it.level - 1, default: heading-space.last()) ) it.body } } // 标题后间距 v( heading-bottom-margin.at( it.level - 1, default: heading-bottom-margin.last(), ), ) i-figured.reset-counters((level: it.level), return-orig-heading: false) fake-par }
https://github.com/Error-418-SWE/Documenti
https://raw.githubusercontent.com/Error-418-SWE/Documenti/src/2%20-%20RTB/Documentazione%20esterna/Piano%20di%20Qualifica/Piano%20di%20Qualifica.typ
typst
#import "/template.typ": * #import "@preview/cetz:0.2.0" #show: project.with( title: "Piano di Qualifica", subTitle: "Metriche, qualità e valutazione", authors: ( "<NAME>", "<NAME>", ), showLog: true, isExternalUse: true, showImagesIndex: false, ); = Introduzione == Scopo del documento Il presente documento viene redatto con lo scopo di definire gli standard di qualità e di valutazione del prodotto. Essi saranno definiti conformemente ai requisiti e alle richieste del Proponente. Definire la qualità di un prodotto consiste nell'attuazione di un insieme di processi che vadano a definire una base con cui misurare efficienza ed efficacia del lavoro svolto. == Approccio al documento Il presente documento viene redatto in modo incrementale per assicurare la coerenza delle informazioni al suo interno con gli sviluppi in corso e le esigenze evolutive del progetto. I valori identificati come accettabili per le metriche riportate possono subire variazioni con l'avanzamento dello sviluppo. == Dashboard di monitoraggio Il gruppo si dota di una dashboard di monitoraggio per tenere traccia delle metriche di processo e di prodotto. La dashboard è accessibile a tutti i membri del gruppo. Essa è accessibile al seguente link: #align(center, link(grafana)) == Glossario #glo_paragrafo == Riferimenti <riferimenti> === Riferimenti a documentazione interna <riferimenti-interni> - Documento #glo_v: \ _#link("https://github.com/Error-418-SWE/Documenti/blob/main/2%20-%20RTB/Glossario_v" + glo_vo + ".pdf")_ #lastVisitedOn(13, 02, 2024) - Documento #ndp_v: \ _#link("https://github.com/Error-418-SWE/Documenti/tree/main/2%20-%20RTB/Documentazione%20interna/Norme%20di%20Progetto_v" + ndp_vo + ".pdf")_ #lastVisitedOn(13, 02, 2024) - Documento #pdp_v: \ _#link("https://github.com/Error-418-SWE/Documenti/tree/main/2%20-%20RTB/Documentazione%20esterna/Piano%20di%20Progetto_v" + pdp_vo + ".pdf")_ #lastVisitedOn(13, 02, 2024) === Riferimenti normativi <riferimenti-normativi> - ISO/IEC 9126 1:2001: \ _#link("https://www.iso.org/standard/22749.html")_ #lastVisitedOn(13, 02, 2024) - Capitolato "Warehouse Management 3D" (C5) di _Sanmarco Informatica S.p.A._: \ _#link("https://www.math.unipd.it/~tullio/IS-1/2023/Progetto/C5.pdf")_ #lastVisitedOn(13, 02, 2024) === Riferimenti informativi <riferimenti-informativi> - Dispense T7 (Qualità del software): \ _#link("https://www.math.unipd.it/~tullio/IS-1/2023/Dispense/T7.pdf")_ #lastVisitedOn(13, 02, 2024) - Dispense T8 (Qualità di processo): \ _#link("https://www.math.unipd.it/~tullio/IS-1/2023/Dispense/T8.pdf")_ #lastVisitedOn(13, 02, 2024) = Qualità di processo == Processi primari === Fornitura ==== *BAC (Budget at Completion)* Definito nel documento Piano di Progetto v2.0.0 con valore di € 13.055,00. ==== *PV (Planned Value)* La metrica PV rappresenta il valore pianificato, ovvero il costo preventivato per portare a termine le attività pianificate nello sprint. Per il calcolo del valore pianificato si considera la sommatoria delle ore preventivate per il costo del ruolo necessario al loro svolgimento, secondo quanto definito nel documento Piano di Progetto v2.0.0. Il calcolo di tale metrica è esteso anche all'intero progetto, dove il valore pianificato è definito come sommatoria dei PV di ogni singolo sprint. \ \ - *SPV*: Sprint Planned Value, valore pianificato per un determinato sprint; - *PPV*: Project Planned Value, valore pianificato per l'intero progetto. Dati: \ - $"r in R = {Responsabile, Amministratore, Analista, Progettista, Programmatore, Verificatore}"$ - $"OR"_r$: Ore ruolo; - $"CR"_r$: Costo ruolo. Si definisce: #figure( table( columns: 3, rows: (auto, 30pt), [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], align(center+horizon,$"SPV" = sum_(r in R) "OR"_r * "CR"_r$), align(center+horizon,$>"0"$), align(center+horizon,$>"0"$), ), caption: "Specifiche metrica SPV" ) Dato: - $"s in S, con S insieme degli sprint svolti."$ Si definisce: #figure( table( columns: 3, rows: (auto, 30pt), [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], align(center+horizon,$"PPV" = sum_(s in S)"SPV"_("s")$), align(center+horizon,$cases(>"0", <="BAC")$), align(center+horizon,$cases(>"0", <="BAC")$), ), caption: "Specifiche metrica SPV" ) La metrica è un indice necessario a determinare il valore atteso del lavoro svolto in un determinato sprint. Il suo valore strettamente maggiore di 0 indica che non sono contemplati periodi di inattività. ==== *AC (Actual Cost)* La metrica *AC* rappresenta la somma dei costi sostenuti dal gruppo in un determinato periodo di tempo. Tale metrica viene calcolata sia in riferimento all'intero progetto, sia come consuntivo dello sprint: - *SAC*: Sprint Actual Cost, costo effettivo sostenuto dal gruppo in un determinato sprint; - *PAC*: Project Actual Cost, costo effettivo sostenuto dal gruppo dall'inizio del progetto, definito come sommatoria dei *SAC*. #figure( table( columns: 3, [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], [SAC = Somma dei costi sostenuti nello sprint], [$<="SPV"$], [$<="SPV" + 10%$], ), caption: "Specifiche metrica SAC" ) Dato: - $"s in S, con S insieme degli sprint svolti."$ Si definisce: #figure( table( columns: 3, rows: (auto, 30pt), [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], align(center+horizon,$"PAC" = sum_(s in S)"SAC"_("s")$), align(center+horizon,$<="BAC"$), align(center+horizon,$<="BAC"$), ), caption: "Specifiche metrica PAC" ) ==== *EV (Earned Value)* L'Earned Value rappresenta il valore guadagnato dal progetto in un determinato periodo di tempo. Tale metrica viene calcolata sia in riferimento all'intero progetto, sia come valore guadagnato nello sprint: - *SEV*: Sprint Earned Value, valore guadagnato dal progetto in un determinato sprint, dove lo stato di completamento del lavoro è espresso mediante il rapporto tra gli story points completati e quelli pianificati per lo sprint; - *PEV*: Project Earned Value, valore guadagnato dal progetto dal suo inizio, definito come sommatoria dei *SEV*. *Calcolo del SEV* - *SPC*: Story Points Completati; - *SPP*: Story Points Pianificati. #figure( table( columns: 3, rows: (auto, 30pt), [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], align(center+horizon,$"SEV" = display("SPC"/"SPP")*"SPV"$), align(center+horizon, $="SPV"$), align(center+horizon, $>="80% del SPV"$), ), caption: "Specifiche metrica SEV" ) *Calcolo del PEV* - $"dato s in S, con S insieme degli sprint svolti"$ #figure( table( columns: 3, rows: (auto, 40pt), [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], align(center+horizon, $"PEV" = sum_(s in S)"SEV"_("s")$), align(center+horizon, $="PPV"$), align(center+horizon, $>="80% del PPV"$), ), caption: "Specifiche metrica PEV" ) \ ==== *CPI (Cost Performance Index)* Il *CPI* rappresenta l'indice di performance del costo, ovvero il rapporto tra il valore guadagnato e il costo effettivo sostenuto. Tale metrica viene calcolata in riferimento al valore totale raggiunto del progetto (*PEV*) in proporzione al costo effettivo sostenuto (*PAC*). #figure( table( columns: 3, rows: (auto, 30pt), [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], align(center+horizon,$"CPI" = display("PEV"/"PAC")$), align(center+horizon,$>=1$), align(center+horizon,$>=0.95$), ), caption: "Specifiche metrica CPI" ) Un rapporto maggiore di 1 indica che il valore raggiunto è superiore al costo effettivo sostenuto. Data la natura didattica del progetto e l'inesperienza del gruppo, si ritiene accettabile un valore di *CPI* $>= 0.95$, valore indicante un costo effettivo leggermente superiore al valore guadagnato. ==== *EAC (Estimated At Completion)* L'EAC rappresenta il costo stimato al termine del progetto. Tale metrica viene calcolata in riferimento al budget totale del progetto (*BAC*) in proporzione all'indice di performance del costo (*CPI*). #figure( table( columns: 3, rows: (auto,50pt), [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], align(center+horizon,$"EAC" = display("BAC"/"CPI")$), align(center+horizon,$<="BAC"$), align(center+horizon, $cases( <= "BAC + 5%", <= "BAC alla consegna", >= "12000 da regolamento" )$), ), caption: "Specifiche metrica EAC" ) Il costo totale del capitolato non può essere maggiore rispetto a quanto espresso in candidatura, pertanto gli unici valori accettbili (e ottimali) sono pari o inferiori rispetto al *BAC*. Dipendendo strettamente dall'indice di performance (*CPI*), il valore della metrica *EAC* può subire variazioni anche al rialzo. Sarà compito del gruppo assorbire eventuali costi aggiuntivi, al fine di mantenere il valore della metrica *EAC* entro i limiti stabiliti in prospettiva della milestone esterna *PB*. == Processi di supporto === Documentazione - *Errori ortografici* #figure( table( columns: 3, [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], [Numero di errori ortografici presenti nel testo], [0], [0], ), caption: "Specifiche errori ortografici" ) Il numero di errori ortografici presenti nei documenti deve essere pari a 0. La metrica evidenzia il numero di errori ortografici individuati durante la revisione precedente al rilascio del documento. === Miglioramento ==== Percentuale metriche soddisfatte Dati: - MS: Metriche soddisfatte; - MT: Metriche totali. #figure( table( columns: 3, rows: (auto, 30pt), [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], align(center+horizon, [% metriche soddisfatte = $display("MS"/"MT")*100$]), align(center+horizon,$100%$), align(center+horizon,$>=75%$), ), caption: "Specifiche metriche soddisfatte" ) Avere un resoconto delle metriche soddisfatte per ogni sprint permette di evidenziare eventuali criticità e di attuare le misure di correzione necessarie, seguendo, come stabilito nelle Norme di Progetto TODO paragrafo TODO _Processo di gestione dei modelli di ciclo di vita_, il ciclo PDCA per il miglioramento continuo. // = Qualità del prodotto // == Funzionalità // - *Requisiti soddisfatti* // #figure( // table( // columns: 3, // // [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], // [% requisiti obbligatori soddisfatti], [100%], [100%], // [% requisiti desiderabili soddisfatti], [$>=0%$], [0%], // [% requisiti opzionali soddisfatti], [$>=0%$], [0%], // ), // caption: "Specifiche Requisiti soddisfatti" // ) // == Affidabilità // - *Densità degli errori* // #figure( // table( // columns: 3, // rows: (auto, 30pt), // // [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], // align(center+horizon,$display(frac("Test con errori","Test eseguiti"))*100$), align(center+horizon,"0%"), align(center+horizon,$<=10%$), // ), // caption: "Specifiche Densità errori" // ) // == Efficienza // - *Efficienza del sistema* // #figure( // table( // columns: 3, // // [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], // [Efficienza del sistema], [TBD], [TBD], // ), // caption: "Specifiche Efficienza del sistema" // ) // == Usabilità // - *Facilità di utilizzo* // #figure( // table( // columns: 3, // // [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], // [Facilità di utilizzo del sistema], [TBD], [TBD], // ), // caption: "Specifiche Facilità di utilizzo" // ) // == Manutenibilità // #figure( // table( // columns: 3, // // [*Calcolo della metrica*],[*Valore ottimale*],[*Valore accettabile*], // [Manutenibilità del sistema], [TBD], [TBD], // ), // caption: "Specifiche Manutenibilità del sistema" // ) = Valutazione Metriche == Premessa Come stabilito dal Piano di Progetto v2.0.0 e dalle Norme di Progetto TODO, il gruppo ha imposto sprint della durata settimanale. Nel primo sprint si è confermato l'utilizzo dell'ITS Jira come strumento di tracciamento, ma per comprenderne a fondo le meccaniche e il corretto utilizzo, sono stati necessari i seguenti 4 sprint. Nel corso di questo periodo, sono state apportate modifiche di configurazione, anche consapevolmente non retrocompatibili, che hanno introdotto eterogeneità nei dati riportati dall'ITS. Per questo motivo, i dati utili al corretto calcolo delle metriche sono disponibili dal quinto sprint, iniziato il 04/12/2023. == Processi primari === Fornitura ==== Rapporto tra PPV, PAC e PEV #figure( cetz.canvas({ import cetz.plot let EV_points(offset: 0) = ((4,2040), (5,2655), (6,3111.85), (7,3528.52), (8,3948.14), (9, 4573.14), (10, 4848.14), (11, 5084.39), (12, 5178.90), (13, 5224.62)).map(((x,y)) => {(x,y + offset * 1.5)}) let AC_point(offset: 1) = ((4,2075), (5,2620), (6,3140), (7,3515), (8,4090), (9, 4520), (10, 4875), (11, 5105), (12, 5285), (13, 5395)).map(((x,y)) => {(x,y + offset * 1.5)}) let PV_point(offset: 1) = ((4,2040), (5,2655), (6,3190), (7,3690), (8,4200), (9, 4825), (10, 5155), (11, 5470), (12, 5625), (13, 5705)).map(((x,y)) => {(x,y + offset * 1.5)}) plot.plot(size: (12, 6), { plot.add(PV_point(offset: 1), line: "spline", label: "PPV") plot.add(AC_point(offset: 1), line: "spline", label: "PAC", style: (stroke: (paint: red))) plot.add(EV_points(offset: 0), line: "spline", label: "PEV", style: (stroke: (paint: green))) plot.add-hline(13055, label: "BAC" , style: (stroke: (paint: blue, dash: "dotted"))) plot.add-vline(13, label: "RTB", style: (stroke: (paint: black, dash: "dotted"))) plot.add-vline(20, label: "PB" , style: (stroke: (paint: red, dash: "dotted"))) }, y-max: 14000, x-max: 21, x-min: 4, x-tick-step: 1, y-tick-step: 1500, x-label: "Sprint", y-label: "Valore in €", ) }), caption: "Rapporto tra PPV, PAC e PEV" ) *RTB*: In questo primo periodo, il gruppo è consapevole che il valore pianficato *PPV* risulti superiore a quanto prodotto nell'effettivo indicato dal *PEV*. Nonostante ciò, il gruppo è sempre riuscito a mantenere il valore del *PEV* non solo in crescita, ma anche superiore all'80% del *PPV*. #pagebreak() ==== Cost Performance Index CPI #figure( cetz.canvas({ import cetz.plot let CPI_points(offset: 0) = ((4,0.98), (5,1.01), (6,0.99), (7,1.00), (8,0.97), (9, 1.01), (10, 0.99), (11, 1.00), (12, 0.98), (13, 0.97)).map(((x,y)) => {(x,y + offset * 1.5)}) plot.plot(size: (12, 6), { plot.add(CPI_points(offset: 0), line: "linear", label: "CPI", mark: "triangle") plot.add-hline(1.1, label: "Limite superiore" , style: (stroke: (paint: green, dash: "dotted"))) plot.add-hline(0.8, label: "Limite inferiore" , style: (stroke: (paint: red, dash: "dotted"))) plot.add-vline(13, label: "RTB", style: (stroke: (paint: black, dash: "dotted"))) plot.add-vline(20, label: "PB" , style: (stroke: (paint: red, dash: "dotted"))) }, y-max: 1.2, y-min: 0.6, x-max: 21, x-min: 4, x-tick-step: 1, y-tick-step: 0.1, x-label: "Sprint", y-label: "CPI", ) }), caption: "Andamento CPI" ) *RTB*: L'indice *CPI* risulta sempre in un range di valore accettabile.Seppur l'andamento non sia lineare, non si rilevano grandi variazioni, il che evidenzia un corretto avanzamento in termini di costi e lavoro prodotto. ==== Rapporto tra BAC e EAC #figure( cetz.canvas({ import cetz.plot let EAC_points(offset: 0) = ((4,13278.98), (5,12882.90), (6, 13173.08), (7, 13004.98), (8, 13524.07), (9, 12903.30), (10, 13127.33), (11, 13107.92), (12, 13322.45), (13, 13480.74)).map(((x,y)) => {(x,y + offset * 100)}) plot.plot(size: (12, 6), { plot.add(EAC_points(offset: 0), line: "linear", label: "EAC", mark: "triangle", style: (stroke: (paint: red))) plot.add-hline(13005*1.05, label: "Limite superiore (BAC + 5%)" , style: (stroke: (paint: red, dash: "dotted"))) plot.add-hline(12000, label: "Limite inferiore" , style: (stroke: (paint: blue, dash: "dotted"))) plot.add-hline(13055, label: "BAC" , style: (stroke: (paint: green, dash: "dotted"))) plot.add-vline(13, label: "RTB", style: (stroke: (paint: black, dash: "dotted"))) plot.add-vline(20, label: "PB" , style: (stroke: (paint: red, dash: "dotted"))) }, y-max: 16000, y-min: 10000, x-max: 21, x-min: 4, x-tick-step: 1, y-tick-step: 1000, x-label: "Sprint", y-label: "Valore in €", ) }), caption: "Rapporto tra EAC e BAC" ) *RTB*: Il valore dell'*EAC* oscilla attorno al valore del *BAC*. Il gruppo è consapevole che il valore stabilito dal *BAC* non possa essere superato, pertanto l'*EAC* al termine del progetto dovrà attenersi al rigido vincolo di $<=$ rispetto al *BAC*. == Processi di supporto === Documentazione ==== Errori ortografici *Documentazione esterna* #figure( cetz.canvas({ import cetz.plot let PdP_points(offset: 0) = ((4,1), (5,2), (6, 2), (7, 1), (8, 0), (9, 0), (10, 1), (11, 0), (12, 0), (13, 0)).map(((x,y)) => {(x,y + offset * 100)}) let PdQ_points(offset: 0) = ((4,0), (5,0), (6, 0), (7, 0), (8, 0), (9, 2), (10, 3), (11, 1), (12, 0), (13, 0)).map(((x,y)) => {(x,y + offset * 100)}) let AdR_points(offset: 0) = ((4,4), (5,4), (6, 2), (7, 2), (8, 3), (9, 1), (10, 0), (11, 0), (12, 0), (13, 0)).map(((x,y)) => {(x,y + offset * 100)}) let GLS_points(offset: 0) = ((4,3), (5,2), (6, 0), (7, 0), (8, 2), (9, 0), (10, 1), (11, 0), (12, 0), (13, 0)).map(((x,y)) => {(x,y + offset * 100)}) plot.plot(size: (12, 6), { plot.add(PdP_points(offset: 0), line: "linear", label: "PdP", mark: "o") plot.add(PdQ_points(offset: 0), line: "linear", label: "PdQ", mark: "o") plot.add(AdR_points(offset: 0), line: "linear", label: "AdR", mark: "o") plot.add(GLS_points(offset: 0), line: "linear", label: "Glossario", mark: "o") plot.add-vline(13, label: "RTB", style: (stroke: (paint: black, dash: "dotted"))) plot.add-vline(20, label: "PB" , style: (stroke: (paint: red, dash: "dotted"))) }, y-max: 8, x-max: 21, x-min: 4, x-tick-step: 1, y-tick-step: 1, x-label: "Sprint", y-label: "Numero di errori", ) }), caption: "Andamento errori ortografici nella documentazione esterna" ) *Documentazione interna* #figure( cetz.canvas({ import cetz.plot let NdP_points(offset: 0) = ((4,2), (5,3), (6, 4), (7, 3), (8, 3), (9, 2), (10, 1), (11, 1), (12, 0), (13, 0)).map(((x,y)) => {(x,y + offset * 100)}) let RIS_points(offset: 0) = ((4,2), (5,1), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 1), (12, 0), (13, 0)).map(((x,y)) => {(x,y + offset * 100)}) plot.plot(size: (12, 6), { plot.add(NdP_points(offset: 0), line: "linear", label: "NdP", mark: "o") plot.add(RIS_points(offset: 0), line: "linear", label: "Analisi dei Rischi", mark: "o") plot.add-vline(13, label: "RTB", style: (stroke: (paint: black, dash: "dotted"))) plot.add-vline(20, label: "PB" , style: (stroke: (paint: red, dash: "dotted"))) }, y-max: 8, x-max: 21, x-min: 4, x-tick-step: 1, y-tick-step: 1, x-label: "Sprint", y-label: "Numero di errori", ) }), caption: "Andamento errori ortografici nella documentazione interna" ) *RTB*: Gli errori ortografici nella documentazione rispecchiano i periodi in cui i documenti hanno subito la maggior parte delle modifiche. In particolare: - *Documentazione esterna*: - *PdP*: il documento ha inizialmente subito la maggior parte di aggiunte a livello testuale, come le sezioni di introduzione, amministrazione dei periodi e dei ruoli. Successivamente gli aggiornamenti sono stati minori, atti alla registrazione e al tracciamento dei preventivi e consuntivi dei vari periodi. Inoltre, l'implementazione di un sistema di creazione automatico delle tabelle dei preventivi e dei consuntivi implementato in _Google Apps Script_, ha permesso di ridurre ulteriormente l'insorgenza di errori; - *PdQ*: l'insorgenza di errori nel Piano di Qualifica è dettata dall'inizio della sua stesura dallo sprint 9; - *AdR*: data la natura del periodo di RTB, l'Analisi dei Requisiti è tra i documenti più corposi e maggiormente soggetti a revisioni e modifiche. Inoltre, l'incremento dei numero di errori è dovuto non solo a revisioni interne ma anche a modifiche dettate da revisioni esterne con i professori; - *Glossario*: il Glossario è stato soggetto a relativamente poche modifiche; la maggior parte degli errori è stata riscontrata inizialmente. - *Documentazione interna*: - *NdP*: l'adozione dello standard ISO/IEC 12207:2017 ha portato con sè anche un grado di complessità maggiore nella stesura del documento, il quale è aumentato di dimensione e complessità. La maggior parte degli errori è pertanto riscontrabile nel periodo di maggiore stesura, per poi ridursi quando le sezioni del documento inerenti e utili al periodo sono state redatte; - *Analisi dei Rischi*: la stesura del documento di Analisi dei Rischi non è stata caratterizzata da un numero elevato di errori. === Miglioramento ==== Metriche soddisfatte #figure( cetz.canvas({ import cetz.plot let Metrics_points(offset: 0) = ((4,7/9*100), (5,8/9*100), (6, 7/9*100), (7, 8/9*100), (8, 6/9*100), (9, 8/9*100), (10, 7/9*100), (11, 6/9*100), (12, 6/9*100), (13, 6/9*100)).map(((x,y)) => {(x,y + offset * 100)}) plot.plot(size: (12, 6), { plot.add(Metrics_points(offset: 0), line: "linear", label: "% Metriche soddisfatte", mark: "triangle", style: (stroke: (paint: red))) plot.add-hline(75, label: "Limite accettabile" , style: (stroke: (paint: red, dash: "dotted"))) plot.add-hline(100, label: "Limite ottimale" , style: (stroke: (paint: green, dash: "dotted"))) plot.add-vline(13, label: "RTB", style: (stroke: (paint: black, dash: "dotted"))) plot.add-vline(20, label: "PB" , style: (stroke: (paint: red, dash: "dotted"))) }, y-max: 110, y-min: 50, x-max: 21, x-min: 4, x-tick-step: 1, y-tick-step: 5, x-label: "Sprint", y-label: "% Metriche soddisfatte", ) }), caption: "Andamento percentuale metriche soddisfatte" ) *RTB*: La percentuale di metriche soddisfatte risulta per la maggior parte degli sprint superiore alla soglia di accettabilità del 75%. I periodi in cui tale soglia non è stata raggiunta sono gli sprint 8, 11, 12 e 13 in quanto: - Sprint 8: periodo dal 26/12/2023 al 02/01/2024, caratterizzato da festività natalizie e di fine anno; - Sprint 11, 12, 13: periodo dal 15/01/2024 al 05/02/2024, caratterizzato dalla sessione d'esami.
https://github.com/kdog3682/2024-typst
https://raw.githubusercontent.com/kdog3682/2024-typst/main/clip.typ
typst
#question({ If $a$ is 40% of b, what percentage of $a$ does $b$ exceed $a$ by? }) #let a40 = text(fill: blue, "40") #let a = text(fill: blue, "a")
https://github.com/takotori/PhAI-Spick
https://raw.githubusercontent.com/takotori/PhAI-Spick/main/sections/kosmologie.typ
typst
= Kosmologie *Umkreisung in geringer Höhe:* Gravitationskraft zwischen Satelliten und Erde $F_G$ ist gerade das Gewicht $m g$ des Satelliten, welches es er auch auf der Erde hätte $ m g=(m v^2)/r $ Daraus folgt die Formel für die #table( columns: (50%, 50%), fill: (_, row) => if row == 0 { gray }, [Geschwindigkeit], [Umlaufzeit], $v= sqrt(g r)$, [$T=2 pi sqrt(r/g)$] ) *Geostationär:* Geostationär bedeutet, dass der Satellit gleiche Umlaufzeit $T$ wie die Erde hat. \ ($"Umlaufzeit Erde" = T= 24 dot 3600s = 86400s$) #underline([*Gravitation:*]) #grid( columns: (auto, auto), inset: 5pt, [*Gravitationskraft \ zweier Massenpunkte:*], $ F_G=G (m_1 m_2)/r^2 \ arrow(F_G) =-G (m_1 m_2)/r^2 dot arrow(r)/r $, [*Potenzielle Energie:*], $ E_p=-G (m_1 m_2)/r $, [*Kreisbahngeschwindigkeit:*], $ v= sqrt((G M_E)/r_E ) $, [*Fluchtgeschwindigkeit:*], $ v= sqrt((2G M_E)/r_E ) $, [*Energie Änderung \ bei Bahnänderung:* \ #v(5pt) $ Delta E &=(G M_E m)/r (r'-r)/(r' r) \ r' &= "Radius neue Bahn"$], image("../figures/kosmologie.png") ) *Potenzielle Energie eines Objekts im Gravitationsfeld eines anderen:* $ E_p=(G M_E m)/r $
https://github.com/hemmrich/CV_typst
https://raw.githubusercontent.com/hemmrich/CV_typst/master/template/template.typ
typst
/* * Functions for the CV template */ #import "@preview/fontawesome:0.2.1": * #import "./styles.typ": latinFontList, latinHeaderFont, awesomeColors, regularColors, setAccentColor, hBar /// Insert the header section of the CV. /// /// - metadata (array): the metadata read from the TOML file. /// - headerFont (array): the font of the header. /// - regularColors (array): the regular colors of the CV. /// - awesomeColors (array): the awesome colors of the CV. /// -> content #let _cvHeader(metadata, profilePhoto, headerFont, regularColors, awesomeColors) = { // Parameters let hasPhoto = metadata.layout.header.display_profile_photo let align = eval(metadata.layout.header.header_align) let personalInfo = metadata.personal.info let firstName = metadata.personal.first_name let lastName = metadata.personal.last_name let headerQuote = metadata.lang.at(metadata.language).header_quote let displayProfilePhoto = metadata.layout.header.display_profile_photo // let profilePhoto = metadata.layout.header.profile_photo_path let accentColor = setAccentColor(awesomeColors, metadata) let nonLatinName = "" let nonLatin = false // Styles let headerFirstNameStyle(str) = { text( font: headerFont, size: 32pt, weight: "light", fill: regularColors.darkgray, str, ) } let headerLastNameStyle(str) = { text(font: headerFont, size: 32pt, weight: "semibold", str) } let headerInfoStyle(str) = { text(size: 10pt, fill: accentColor, str) } let headerQuoteStyle(str) = { text(size: 10pt, weight: "medium", style: "italic", fill: accentColor, str) } // Components let makeHeaderInfo() = { let personalInfoIcons = ( phone: fa-phone(), email: fa-envelope(), linkedin: fa-linkedin(), homepage: fa-pager(), github: fa-square-github(), gitlab: fa-gitlab(), orcid: fa-orcid(), researchgate: fa-researchgate(), location: fa-location-dot(), extraInfo: "", ) let n = 1 for (k, v) in personalInfo { // A dirty trick to add linebreaks with "linebreak" as key in personalInfo if k == "linebreak" { n = 0 linebreak() continue } if k.contains("custom") { let img = v.at("image", default: "") let awesomeIcon = v.at("awesomeIcon", default: "") let text = v.at("text", default: "") let link_value = v.at("link", default: "") let icon = "" if img != "" { icon = img.with(width: 10pt) } else { icon = fa-icon(awesomeIcon) } box({ icon h(5pt) link(link_value)[#text] }) } else if v != "" { box({ // Adds icons personalInfoIcons.at(k) h(5pt) // Adds hyperlinks if k == "email" { link("mailto:" + v)[#v] } else if k == "linkedin" { link("https://www.linkedin.com/in/" + v)[#v] } else if k == "github" { link("https://github.com/" + v)[#v] } else if k == "gitlab" { link("https://gitlab.com/" + v)[#v] } else if k == "homepage" { link("https://" + v)[#v] } else if k == "orcid" { link("https://orcid.org/" + v)[#v] } else if k == "researchgate" { link("https://www.researchgate.net/profile/" + v)[#v] } else { v } }) } // Adds hBar if n != personalInfo.len() { hBar() } n = n + 1 } } let makeHeaderNameSection() = table( columns: 1fr, inset: 0pt, stroke: none, row-gutter: 6mm, [#headerFirstNameStyle(firstName) #h(5pt) #headerLastNameStyle(lastName)], [#headerInfoStyle(makeHeaderInfo())], //[#headerQuoteStyle(headerQuote)], ) let makeHeaderPhotoSection() = { set image(height: 3.6cm) if displayProfilePhoto { box(profilePhoto, radius: 50%, clip: true) } else { v(3.6cm) } } let makeHeader(leftComp, rightComp, columns, align) = table( columns: columns, inset: 0pt, stroke: none, column-gutter: 15pt, align: align + horizon, { leftComp }, { rightComp }, ) if hasPhoto { makeHeader( makeHeaderNameSection(), makeHeaderPhotoSection(), (auto, 20%), align, ) } else { makeHeader( makeHeaderNameSection(), makeHeaderPhotoSection(), (auto, 0%), align, ) } } /// Insert the footer section of the CV. /// /// - metadata (array): the metadata read from the TOML file. /// -> content #let _cvFooter(metadata) = { // Parameters let firstName = metadata.personal.first_name let lastName = metadata.personal.last_name let footerText = metadata.lang.at(metadata.language).cv_footer // Styles let footerStyle(str) = { text(size: 8pt, fill: rgb("#999999"), smallcaps(str)) } place( bottom, table( columns: (1fr, auto), inset: 0pt, stroke: none, footerStyle([#firstName #lastName]), footerStyle(footerText), ), ) } /// Add the title of a section. /// /// - title (str): The title of the section. /// - highlighted (bool): Whether the first n letters will be highlighted in accent color. /// - letters (int): The number of first letters of the title to highlight. /// - metadata (array): (optional) the metadata read from the TOML file. /// - awesomeColors (array): (optional) the awesome colors of the CV. /// -> content #let cvSection( title, highlighted: true, letters: 3, metadata: metadata, awesomeColors: awesomeColors, ) = { let lang = metadata.language let nonLatin = false let beforeSectionSkip = eval( metadata.layout.at("before_section_skip", default: 1pt), ) let accentColor = setAccentColor(awesomeColors, metadata) let highlightText = title.slice(0, letters) let normalText = title.slice(letters) let sectionTitleStyle(str, color: black) = { text(size: 16pt, weight: "bold", fill: color, str) } v(beforeSectionSkip) if highlighted { sectionTitleStyle(highlightText, color: accentColor) sectionTitleStyle(normalText, color: black) } else { sectionTitleStyle(title, color: black) } h(2pt) box(width: 1fr, line(stroke: 0.9pt, length: 100%)) } /// Add an entry to the CV. /// /// - title (str): The title of the entry. /// - society (str): The society of the entr (company, university, etc.). /// - date (str): The date of the entry. /// - location (str): The location of the entry. /// - description (array): The description of the entry. It can be a string or an array of strings. /// - logo (image): The logo of the society. If empty, no logo will be displayed. /// - tags (array): The tags of the entry. /// - metadata (array): (optional) the metadata read from the TOML file. /// - awesomeColors (array): (optional) the awesome colors of the CV. /// -> content #let cvEntry( title: "Title", society: "Society", date: "Date", location: "Location", description: "Description", logo: "", tags: (), metadata: metadata, awesomeColors: awesomeColors, ) = { let accentColor = setAccentColor(awesomeColors, metadata) let beforeEntrySkip = eval( metadata.layout.at("before_entry_skip", default: 1pt), ) let beforeEntryDescriptionSkip = eval( metadata.layout.at("before_entry_description_skip", default: 1pt), ) let entryA1Style(str) = { //text(size: 10pt, weight: "bold", str) text(size: 11pt, weight: "bold", str) } let entryA2Style(str) = { align( right, //text(weight: "medium", fill: accentColor, style: "oblique", str), text(weight: "medium", fill: accentColor, style: "oblique", size: 10pt, str), ) } let entryB1Style(str) = { //text(size: 10pt, fill: accentColor, weight: "medium", smallcaps(str)) text(size: 11pt, fill: accentColor, weight: "medium", smallcaps(str)) } let entryB2Style(str) = { align( right, //text(size: 8pt, weight: "medium", fill: gray, style: "oblique", str), text(size: 9pt, weight: "medium", fill: luma(120), style: "oblique", str), ) } let entryDescriptionStyle(str) = { text( fill: regularColors.lightgray, { v(beforeEntryDescriptionSkip) str }, ) } let entryTagStyle(str) = { align(center, text(size: 8pt, weight: "regular", str)) } let entryTagListStyle(tags) = { for tag in tags { box( inset: (x: 0.25em), outset: (y: 0.25em), fill: regularColors.subtlegray, radius: 3pt, entryTagStyle(tag), ) h(5pt) } } let ifSocietyFirst(condition, field1, field2) = { return if condition { field1 } else { field2 } } let ifLogo(path, ifTrue, ifFalse) = { return if metadata.layout.entry.display_logo { if path == "" { ifFalse } else { ifTrue } } else { ifFalse } } let setLogoLength(path) = { return if path == "" { 0% } else { 4% } } let setLogoContent(path) = { return if logo == "" [] else { set image(width: 100%) logo } } v(beforeEntrySkip) table( columns: (ifLogo(logo, 4%, 0%), 1fr), inset: 0pt, stroke: none, align: horizon, column-gutter: ifLogo(logo, 4pt, 0pt), setLogoContent(logo), table( columns: (1fr, auto), inset: 0pt, stroke: none, row-gutter: 6pt, align: auto, { entryA1Style( ifSocietyFirst( metadata.layout.entry.display_entry_society_first, society, title, ), ) }, { entryA2Style( ifSocietyFirst( metadata.layout.entry.display_entry_society_first, location, date, ), ) }, { entryB1Style( ifSocietyFirst( metadata.layout.entry.display_entry_society_first, title, society, ), ) }, { entryB2Style( ifSocietyFirst( metadata.layout.entry.display_entry_society_first, date, location, ), ) }, ), ) entryDescriptionStyle(description) entryTagListStyle(tags) } /// Add a skill to the CV. /// /// - type (str): The type of the skill. It is displayed on the left side. /// - info (str | content): The information about the skill. It is displayed on the right side. Items can be seperated by `#hbar()`. /// -> content #let cvSkill(type: "Type", info: "Info") = { let skillTypeStyle(str) = { align(right, text(size: 10pt, weight: "bold", str)) } let skillInfoStyle(str) = { text(str) } table( columns: (16%, 1fr), inset: 0pt, column-gutter: 10pt, stroke: none, skillTypeStyle(type), skillInfoStyle(info), ) v(-6pt) } /// Add a Honor to the CV. /// /// - date (str): The date of the honor. /// - title (str): The title of the honor. /// - issuer (str): The issuer of the honor. /// - url (str): The URL of the honor. /// - location (str): The location of the honor. /// - awesomeColors (array): (optional) The awesome colors of the CV. /// - metadata (array): (optional) The metadata read from the TOML file. /// -> content #let cvHonor( date: "1990", title: "Title", issuer: "", url: "", location: "", awesomeColors: awesomeColors, metadata: metadata, ) = { let accentColor = setAccentColor(awesomeColors, metadata) let honorDateStyle(str) = { align(right, text(str)) } let honorTitleStyle(str) = { text(weight: "bold", str) } let honorIssuerStyle(str) = { text(str) } let honorLocationStyle(str) = { align( right, text(weight: "medium", fill: accentColor, style: "oblique", str), ) } table( columns: (16%, 1fr, 15%), inset: 0pt, column-gutter: 10pt, align: horizon, stroke: none, honorDateStyle(date), if issuer == "" { honorTitleStyle(title) } else if url != "" { [ #honorTitleStyle(link(url)[#title]), #honorIssuerStyle(issuer) ] } else { [ #honorTitleStyle(title), #honorIssuerStyle(issuer) ] }, honorLocationStyle(location), ) v(-6pt) } /// Add the publications to the CV by reading a bib file. /// /// - bib (bibliography): The `bibliography` object with the path to the bib file. /// - keyList (list): The list of keys to include in the publication list. /// - refStyle (str): The reference style of the publication list. /// - refFull (bool): Whether to show the full reference or not. /// -> content #let cvPublication(bib: "", keyList: list(), refStyle: "apa", refFull: true) = { let publicationStyle(str) = { text(str) } show bibliography: it => publicationStyle(it) set bibliography(title: none, style: refStyle, full: refFull) bib }
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/037%20-%20Ravnica%20Allegiance/006_The%20Gathering%20Storm%3A%20Chapter%2012.typ
typst
#import "@local/mtgstory:0.2.0": conf #show: doc => conf( "The Gathering Storm: Chapter 12", set_name: "Ravnica Allegiance", story_date: datetime(day: 28, month: 08, year: 2019), author: "<NAME>", doc ) "What about giants?" Kaya said, brightly. "The pair of them in the basement certainly gave me a workout. Can we scrape some of those together?" "I’m certain that can be arranged," said the Knight of Despair, a hollow-cheeked figure in dark armor. "Guildmaster," Teysa said, her patience fraying, "would you please #emph[listen] to me for a moment?" "I’m listening," Kaya said. "I just disagree." "You cannot expose yourself to needless risks," Teysa said. "Can," Kaya said, yawning. "And they’re not needless. What about gargoyles? Though those might not be much good underground—" "Could I speak to you alone?" Teysa grated. Kaya glanced at the Knight of Despair and his retinue, then shrugged. "I’ll expect a report on the field force you put together." "Very good, Guildmaster," the knight said. He left the room with a clank of heavy armor, soldiers and priests shuffling after him. Kaya was left alone with Teysa, in this small conference chamber high atop Orzhova. Like everything else in the great cathedral, it was opulently furnished, with gilt-framed portraits of bankers past staring down from the walls and heavy purple carpet softening the stone floor. The intricately inlaid table was polished to a mirror sheen. Kaya couldn’t help but wonder how many of the bonds of debt that weighed down her soul had been forged here, in this room, lives ruined by the stroke of some bureaucrat’s pen. "We need to have a discussion," Teysa said tightly. "You know—" "What is there to discuss?" Kaya said, staring back at the other woman defiantly. "You made me the guildmaster, so my decision is final." "#emph[I] made you the guildmaster because it was the only way to save your life," Teysa said. "The others were ready to kill you before you woke up, and take the risk that Grandfather’s personal debts would transfer to whoever slit your throat. I convinced them that this way was safer." She rubbed her eyes with the heel of her palms, as though she were beginning to regret that decision, and Kaya softened a little. "I get it," she said. "Really. And I’m grateful. I know you didn’t have to stick your neck out for me." "You helped #emph[me] when I needed it," Teysa said. "I can’t forget that." "I was getting paid," Kaya said. #emph[Or so I thought.] Bolas, the slimy snake, had known following his instructions would get her trapped here. "And I need to think about what’s best for the guild," Teysa said. "If you get yourself killed fighting Vraska or anyone else, it could be catastrophic for the Orzhov." "I understand that," Kaya said. "But I’m pretty good at not getting myself killed, you know." "I can imagine," Teysa said, with a slight smile. "But as I said. It’s an unnecessary risk." "It’s a necessary one," Kaya said. "I owe Ral." "Orzhov forces are going to support him—" "#emph[I] owe him. Not the Orzhov. So I have to be there. You understand?" Teysa stared at Kaya for a long moment, then shook her head. "No," she said. "But I can see I’m not going to change your mind." Kaya grinned. "Fair enough. I promise I’ll be careful." "You’d better be," Teysa said. She looked down at the force reports, scrolls scattered like seeds across the vast table, and sighed. "Do you need my help with those?" Kaya said. "No." Teysa waved a hand. "Go get some rest. I’ll make sure Ral has the troops he needs." Kaya stifled a relieved groan, gave Teysa and nod, and slipped out of the conference chamber, passing through the door in a wash of purple light. Not strictly necessary, of course, but she liked to walk through walls from time to time, just to prove to herself that she still could. The entire vast cathedral was starting to feel more and more like a cage, gilded and decadent but just as confining. She could feel the obligations she’d assumed from Karlov’s ghost, when her blades had cut him down. They wrapped around her like a thousand spiritual chains, each one tying her to some poor debtor who’d made a bargain with the Church of Deals. Releasing them cost her strength, and it cost the Orzhov money. Break too many at once, and one or the other of them would collapse. #emph[Would that be so terrible?] Kaya daydreamed, idly, as she ghosted down the corridors toward her own chambers, avoiding the guards out of habit. She could do it, tear all the chains free, declare a jubilee and cancel all the debts with a wave of her hand. The Orzhov would come crashing down, all the sumptuous gold and marble revealed to be rotten at the core. #emph[Maybe I’d be doing Ravnica a favor.] Of course, she’d die in the process. #emph[Which is sort of the sticking point.] It wasn’t that she was afraid, exactly, but there wasn’t anyone else. When Kaya had left her home, she’d vowed to sacrifice anything to fix the broken world she’d left behind. #emph[If I die here, everyone back home dies with me, if not now then in ten years or twenty as the sky rips itself apart.] #emph[Plus, all right, I’m a ] little#emph[ afraid.] She walked through the door to her quarters and shook her head to banish the dark thoughts. As guildmaster, she naturally had a disgustingly opulent suite at the heart of the Orzhova. It had come with a staff of a dozen servants, who were expected to live in it with her to wait on her hand and foot. Kaya had sent them away—having people in such proximity all the time made her nervous—and so her rooms felt oddly empty, too large for their occupant. She rattled around in them like a dried pea in a pod, and mostly stuck to the colossal bedroom and its adjacent bathroom. Today, as she materialized on the other side of the door in the grand entrance hall, she startled an old woman in the robes of a palace servant, who’d been standing awkwardly against a grand mirror with two small children by her side. The woman blinked at Kaya in shock, and one of the children, a boy of ten or eleven, squirmed free and gaped. "How do you #emph[do] that?" he said. "Walk through walls?" "It’s a knack," Kaya said modestly. "Svet!" the old woman said, yanking him back. A slightly younger girl peeked at Kaya from under her arm. "Both of you, show respect. This is your guildmaster." She bowed deep, forcing the children to bend along with her." "Thanks," Kaya said, feeling awkward. "Get up, please. What are you doing here?" There were guards outside her quarters, though she herself had circumvented them as usual. "My name is Olgaia," the old woman said. "I don’t mean to disturb you, Guildmaster. But we heard . . . that is . . ." "Grandma says you’ll forgive the debts of anyone who asks you in person," Svet said. Kaya winced. Word was starting to spread, then. #emph[I really shouldn’t.] If Teysa found out, she’d throw a fit. But there were so #emph[many] debtors, and each one contributed only fractionally to the burden on Kaya’s soul. #emph[Why not help them, if I have the chance?] "It’s not . . . quite like that." Kaya cocked her head. "How did you end up in debt to the Orzhov?" "I bought a necklace." Olgaia hung her head. "I was young and foolish, and I thought it would turn a young man’s head. It did, but . . ." She shrugged. "I have spent the last twenty years working in the laundries here. But the interest on what I owe is more than my wages, and so the debt only increases." She pulled her two grandchildren to her. "Since their parents died, I have cared for these two, but when they come of age they will inherit the debt too. Please, Guildmaster. I want only a chance for a better life for them." #emph[A necklace.] A mistake, maybe, but this woman had spent her entire life paying for it. #emph[How many children work for me, paying for their grandparents’ mistakes?] Kaya found the thread of debt that connected her to these three, like tracing a single fine thread from a thick bundle. With an effort of will, she snapped it, feeling a tiny pain in her chest. Olgaia gasped, and straightened up slightly. "You are forgiven," Kaya said. "Just . . . don’t tell everyone about it, all right?" "Of course, Guildmaster." Olgaia bowed frantically. "Thank you. Thank you." Kaya waved her away, and the old woman hustled her grandchildren out the door. When they were gone, Kaya sighed heavily and wandered into the bedroom, flopping face-first into the thick feather mattress on the ornate four-poster. She weighed the chain of obligations in her mind, the golden fetters that bound her. With one jerk, so many lives would be freed. #emph[All except mine.] If Bolas was to be believed, only he could manage that— Kaya sat up abruptly and shook her head. She clomped across to the bathroom, where there was an enormous marble bath, complete with hot and cold running water—an unthinkable luxury on many of the worlds she’d visited. The Orzhov might be a bunch of heartless banker-priests, Kaya reflected, but they certainly knew how to make a good bath. #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em)  #linebreak There was no true wilderness left on Ravnica. After ten thousand years or more of civilization, no patch of land had not been built on, burned down, plowed under, and built again a dozen times. The rubblebelts that fringed the Tenth District were not natural in any sense— they were the #emph[absence] of civilization, its negation and destruction. Probably, Ral thought, the Gruul clans liked it that way. Or else they didn’t know the difference— as a Planeswalker, he had seen true wilderness on other worlds, but no Ravnican could understand what that truly meant. In either case, while the Gruul ranted endlessly about nature and its power, they lived among ruins, parasites scavenging from what the other guilds created. They had never been the primary enemies of the Izzet League, but of all the guilds Ral found them perhaps the most incomprehensible. It was a cold day, but at least the rain had briefly abated, with only occasional spitting squalls under a gray, sunless sky. A few days of reasonable sleep hadn’t restored Ral completely, but it had gone quite a ways, as had an unfortunately brief visit from Tomik. Now he wore his long coat and the latest version of his accumulator, fully charged and ready. The mizzium bracer son his arms crackled in anticipation. Behind him walked a company of scorchbringers, viashino soldiers equipped with flamethrowers. The reptilian humanoids barked and growled to one another in their guttural variant of the common tongue, flicking tongues indicating their high spirits. They spent most of their time on guard duty, restrained from using their weapons lest they burn down the labs and workshops they protected, so Ral imagined they were looking forward to a chance to cut loose in the open field. The bulk of the force accompanying them, as Aurelia had promised, was provided by the Boros Legion. Two battalions of infantry marched in disciplined columns, shielded spearmen at the fore and archers behind. Sergeants in notched helmets prowled up and down the files, lambasting their soldiers for infractions of drill that were incomprehensible to Ral. At the head of each battalion, a battle flag with the Boros emblem flapped proudly, surrounded by an honor guard. Boros soldiers were overhead, too. Several flights of skyknights, roc-riding lancers, flew cover over the expedition, scouting out the ground in front of them. They shared the air uneasily with their Azorius counterparts, riding on griffins. More Azorius cavalry held the flanks of the ground force, several squadrons of hussars in brightly polished armor on each side. They rode over ancient roads and plazas, through buildings half-collapsed and tangled with vines and sprouting trees. Some patches of the rubblebelt had been ruined for a very long time, while others had fresh burn scars. This was the boundary of Gruul territory, where the Boros fought their endless war against the encroaching chaos. As they passed beyond it, the trees grew taller, the grass deeper, and the crumbling stone hulks of ancient structures were submerged in green, as though they were wrecked ships sinking below the waves. Commander Ferzhin, accompanied by a half-dozen young aides-de-camp, walked at the center of the Boros formation, her dark eyes watchful. She glanced in Ral’s direction as he fell in beside her, taking two strides for each of hers to keep pace. "We’re nearly there," Ral said. He glanced down at the gadget in his hand, a mizzium-and-crystal thing that the chemisters had hurriedly thrown together. A polished window on top grew brighter as they approached the node, and it hummed softly as he waved it in a circle. "Just past that wall, I think." "Looks like an old square," the minotaur rumbled, shading her eyes with one hand. A broad open space up ahead was fronted by ruined buildings on three sides, including one that stood at least four stories high. "I don’t like it. Good spot for an ambush." "The Gruul haven’t come after us so far. Maybe they won’t attack at all." "They’ll attack," Ferzhin said. Her lip curled. "They always do. Be ready." At the edge of the square, the minotaur growled a command, and the column came to a halt. Skyknights flew in lazy circles overhead, while the cavalry waited, horses giving the occasional soft snort. Ral and Ferzhin slipped forward through the ranks, to the front of the formation. Ahead of them, in the center of the square, a single figure was waiting. "Do you recognize him?" Ferzhin said. Ral shook his head, wishing for a moment Lavinia was there. #emph[She’s the one who knows everything about everyone.] "He pretty clearly wants to talk. So let’s talk." The minotaur rolled her eyes, but said nothing as Ral strode out to meet the lone stranger. He was a young man, clearly of the Gruul clans—heavily tattooed, with scraps of hide armor and a stiffened ridge of dark hair. He carried a pair of hand-axes at his belt, and rested his palms on them while he waited for his visitors to approach, giving them an insolent smile. "Lot of nerve, you lot have," he shouted, as they came up. "Lot of nerve, comin’ here." "You have some nerve yourself, meeting us on your own," Ral said. He looked the youth up and down. "I’m <NAME>, of the Izzet League." "I’m <NAME>, yeah? Of the Gruul clans." His lips split in a cruel smile. "Head man of #emph[all] the Gruul clans." Ferzhin chuckled. "Borborygmos might want a word with you if you go around saying things like that." Domri grinned wider. "Already had it. Duel of the century, they’re calling it." "And you won?" Ral said, doubtfully. "I’m here, ain’t I?" Domri spread his hands. "And he’s not. So here’s what. Take your shiny-assed toys and get yourselves out of here while you still can, understand? Else we’re going to have trouble." "We’re not here to stay," Ral said. "It’s only for the duration of the emergency." "Don’t give a #emph[damn] ," Domri said, leaning forward until he was only inches from Ral’s face. "About you, or your emergency. If this big bad dragon comes to mess with us, we’ll fight him too. Fight everyone. That’s Gruul, see? Old Bor-Bor, he tried talking, and look where that got him. I ain’t makin’ that mistake." "Big words for a man alone," Ferzhin said. "Oh, don’t worry." Domri took a step back and spread his arms. "I ain’t alone." A piercing cry rang through the air. Ral looked up to see a skyknight falling, his griffin’s flank ripped open in a shower of blood by a monstrous eagle. More birds were descending, flocks of them, hawks and owls and crows by the thousands. They #emph[glowed] , a dark, verdant green, and Ral could feel the pulse of magic around them. He raised his hands and closed his gauntlets into fists. Lightning crackled, all around him, then spearing up into the sky, catching the largest of the avian attackers. The eagle gave a screech as it burst into flame, falling into the grass square a burning mess, and power arced onward, from one bird to the next. Crows exploded in bursts of black feathers. "Back to the lines!" Ferzhin said, taking Ral by the shoulder. "I can deal with a few birds—" But more movement caught Ral’s eye. From around the periphery of the square, a cloud of dust was rising, and at the head of it he could see a solid line of wild boar. They were huge, as big as a man, with the same intricate tattoos as Domri and the same dark green glow. Each sported a pair of massive tusks, backed by a thousand pounds of porcine muscle. Domri drew an axe in each hand and laughed wildly as the boar surged past him. "Back to the lines," Ral agreed. They made it just in time, scrambling behind the wall formed by the front rank of Boros troops, their worn metal shields interlocking with practiced ease. Their levelled spears formed an impenetrable thicket, but the boars continued their charge with a suicidal fury, throwing themselves onto the line of steel points. The sheer mass of their impact disordered the line, driving soldiers back or knocking them off their feet. Even impaled and bleeding, the boars kept thrashing, snapping the shafts that harried them. When they got close enough, their tusks tore shields away and ripped through armor, leaving broken bodies bleeding into the grass. The Boros troops knew their business, however. Men and women in the front line dropped their spears when the boars shattered them and drew swords, closing in to slaughter the massive beasts. Behind them, the second line formed, and the archers nocked their arrows. Overhead, the sky had become a swirling melee of birds and griffins, a flock of harrying animals attacking each skyknight. The skyknights fired their bows with preternatural precision, sending a steady rain of eagles, hawks, and crows plummeting to the earth. "Here they come," Ferzhin bellow. "Archers, ready!" Through the dust thrown up by the charge of the boars, Ral could make out a host of fleeting shapes, pouring out of the ruined buildings in a tide of muscle, leather, and steel. Here and there, heads were visible above the murk, giants with shaggy, multicolored hair and massive stone clubs. Ral had a sudden moment of doubt—#emph[that’s a hell of a lot of them] —then bared his teeth in a savage grin and shouted to his viashino troops. "Go! Get out front!" The lizards bounded forward, threading around the knots of struggling Boros troopers and the few surviving boars to make a thin skirmish line in from of the Legion shield wall. Behind them, the archers loosed a flight of arrows with a sound like a flock of birds ascending, shafts #emph[zipping] overhead and descending like dark rain. The well-trained soldiers had another volley aloft before the first had landed, and figures shrieked, stumbled, and fell as the horde came on. Sudden, blinding light as the scorchbringers ignited their weapons. Tongues of flame licked out, touching the shrouded figures and leaving them ablaze, sweeping back and forth. Men and women danced like maddened puppets, engulfed in flames, shrieking as they burned. A wave of javelins and thrown axes came in response, and a few of the scorchbringers went down, one of them detonating in a spectacular explosion. The remainder fell back slowly, playing their fires over the advancing Gruul anarchs, then slipping back to safety behind the line of Boros spearmen. The Gruul came on, full of berserk fury, leaping over their own charred dead with swords and axes in hand. Most were human, hair wild, wearing leather armor or none at all, skin thick with tattoos and eyes wild with rage. Ogres loomed among them, too, larger and thick-skinned, wielding huge clubs that Ral doubted he could even lift. For a moment it seemed like they would smash the Boros line through sheer momentum, but the trained soldiers locked shields and grounded their spears, and the furious wave of anarchs broke against them like a wave against rock. They hacked at the protruding spears, tried to dodge between them, or simply hurled themselves forward and trusted to luck. The front line was suddenly thick with the dead and dying, and the Boros troops dropped their spears, drew their swords, and engaged the survivors. In moments, a wild melee developed, and it was difficult to see anything at all. One of the giants was down, pincushioned by a hundred arrows, but another waded gleefully into the press, its huge club sweeping back and forth, breaking friend and foe alike. The Boros line bent before it, and threatened to break. Ral reached over his head and yanked downward, and energy roared from the accumulator on his back and licked up into the sky. A moment later, the sky rumbled in answer, and a titanic bolt of lightning descended, striking the huge creature as it raised its club for another swing. The weapon slipped from its hand, falling heavily to the earth, as the giant was outlined in brilliant white for a moment. Then it toppled, smoking, and collapsed to a cheer from the Boros soldiers. "There!" Ferzhin said. "It’s Domri!" Something huge loomed out of the dust, taller and broader than the giants. It had a vaguely humanoid shape, squat-bodied and long-legged, but it was made of the stuff of the rubblebelt—vines, trees, chunks of rock, ancient columns and statues, all pressed together and grinding against one another to make a continual roar. Arrows slammed into it to little effect, and it swept one hand through a squad of Boros soldiers and left them scattered and broken on the turf. On the massive thing’s shoulder rode Domri, an axe in each hand, laughing gleefully at the carnage below. "Scorchbringers!" Ral beckoned. "Kill that thing!" He didn’t wait for the viashino to regroup, but charged himself, with Ferzhin at his side. Lightning exploded from his fingertips, playing across the huge ruin elemental, stone and wood exploding in its wake. The thing twisted, as though it could feel pain, and brought one huge hand down to crush Ral like an insect. He dodged backward, stumbling as the blow sent a shockwave through the earth, and sent a concentrated pulse of power into the elemental’s hand, blowing it apart in a shower of rocks and wooden splinters. Fire licked out from a dozen directions, scorching the elemental, and it reared up and cast about for its attackers. Domri jumped down from its shoulder and charged Ferzhin, who drew her greatsword and stood to meet him. Steel rang against steel, the laughing youth pressing the attack, spinning and twisting away from the stolid minotaur’s attacks with distressing ease. Ral sent a blast of lightning at him, and Domri ducked aside. Before Ral could press the attack, he had to dance away from the elemental again, narrowly avoiding being crushed. #emph[That’s about enough of ] that#emph[.] Normally, the best way to deal with an elemental would be to kill whoever had summoned it, but in the chaos of battle they could be anywhere. #emph[That leaves only the direct approach.] The thing was badly damaged, blazing in several places as flamethrowers continued to torment it. Ral pulled all the power he could from his accumulator, his gauntlets glowing white, and focused it to a lance of brilliant energy. When the elemental reared up again, he unleashed the blast, a beam of light that punched through the thing’s core and blew a huge spray of rocks and ancient masonry out of its back. The vast creature groaned, then started to come apart, rock and flaming trees thudding to the ground as it disintegrated. Domri gave a shout of triumph, and Ral turned in time to see Ferzhin’s sword knocked from her hands. The young man spun, burying one of his hand-axes deep in the minotaur’s ribs. But it stuck fast, and his triumphant shout cut off when she grabbed him and brought her horned skull down hard in a vicious headbutt. Domri’s nose broke with a #emph[crunch] Ral could hear across the battlefield, and he staggered backward into the billowing dust of the elemental’s collapse. Ral raised a hand to send lightning chasing after him, but the accumulator on his back only gave an empty whine. He swore as Domri vanished, then hurried to Ferzhin’s side. The minotaur had fallen to one knee, gripping the axe Domri had left behind. She jerked it free with a gasp and tossed it away, blood soaking her uniform. "Commander!" A Boros lieutenant jogged over and offered a crisp salute. "Get a healer," Ral snapped at him. "She needs—" "Later," Ferzhin said, pushing herself to her feet. "Report." "Yes, sir," the lieutenant said. "The enemy are in full retreat. The day is ours." "Deploy perimeter patrols," Ferzhin said. "Gather our wounded, and make certain the bastards haven’t left any nasty surprises behind." "Yes, sir." "And then," Ferzhin said, glancing at Ral. "Fetch me a healer. If there’s one to spare." "Yes, sir." The lieutenant saluted and hurried off. "You’re all right?" Ral said, eyeing her bleeding side. "I’ve had worse," Ferzhin said, breathing hard. "That was . . . more than I expected." Ral gave a slow nod. "Someone warned them we were coming." #emph[Bolas.] #emph[] #linebreak "Nevertheless." The minotaur gestured around them, at the ancient square now liberally strewn with corpses. "You’ve got your bit of ground. I hope your mad engineers can do something worthwhile with it." "Don’t worry on that score," Ral said, as a white-coated Boros medic hurried over. "We’ll take it from here."
https://github.com/davystrong/umbra
https://raw.githubusercontent.com/davystrong/umbra/main/README.md
markdown
MIT License
# Umbra Umbra is a library for drawing basic gradient shadows in [typst](https://typst.app). It currently provides only one function for drawing a shadow along one edge of a path. ## Examples <!-- img width is set so the table gets evenly spaced by GitHubs css --> ### Basic Shadow <a href="gallery/basic.typ"> <img src="gallery/basic.png" height="250px"> </a> ### Neumorphism <a href="gallery/neumorphism.typ"> <img src="gallery/neumorphism.png" height="250px"> </a> ### Torn Paper <a href="gallery/torn-paper.typ"> <img src="gallery/torn-paper.png" height="250"> </a> *Click on the example image to jump to the code.* ## Usage The following code creates a very basic square shadow: ``` #import "@preview/umbra:0.1.0": shadow-path #shadow-path((10%, 10%), (10%, 90%), (90%, 90%), (90%, 10%), closed: true) ``` The function syntax is similar to the normal path syntax. The following arguments were added: * `shadow-radius` (default `0.5cm`): The shadow size in the direction normal to the edge * `shadow-stops` (default `(gray, white)`): The colours to be used in the shadow, passed directly to `gradient` * `correction` (default `5deg`): A small correction factor to be added to round shadows at corners. Otherwise, there will be a small gap between the two shadows ### Vertex Order The order of the vertices defines the direction of the shadow. If the shadow is the wrong way around, just reverse the vertices. ### Transparency This package is designed in such a way that it should support transparency in the gradients (i.e. corners define shadows using a path which approximates the arc, instead of an entire circle). However, typst doesn't currently support transparency in gradients. ([issue](https://github.com/typst/typst/issues/2546)). In addition, the aforementioned correction factor would likely cause issues with transparent gradients.
https://github.com/EpicEricEE/typst-marge
https://raw.githubusercontent.com/EpicEricEE/typst-marge/main/tests/resolve/dir/test.typ
typst
MIT License
#import "/src/resolve.typ": resolve-dir #context assert.eq(resolve-dir(), ltr) #{ set text(dir: rtl) context assert.eq(resolve-dir(), rtl) } #{ set text(lang: "he") context assert.eq(resolve-dir(), rtl) }
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/visualize/gradient-text_04.typ
typst
Apache License 2.0
#import "/contrib/templates/std-tests/preset.typ": * #show: test-page // Test that gradients fills on text work with transforms. #set page(width: auto, height: auto, margin: 10pt) #show box: set text(fill: gradient.linear(..color.map.rainbow)) #rotate(45deg, box[World])
https://github.com/Enter-tainer/typstyle
https://raw.githubusercontent.com/Enter-tainer/typstyle/master/tests/assets/unit/grid/basic.typ
typst
Apache License 2.0
#table( columns: (auto, 1fr, auto), gutter: 3pt, [Name], [Age], [Strength], [Hannes], [36], [Grace], [Irma], [50], [Resourcefulness], [Vikram], [49], [Perseverance], ) #table( columns: 3, gutter: 3pt, [Name], [Age], [Strength], [Hannes], [36], [GraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGraceGrace], [Irma], [114514114514114514114514114514114514114514114514114514114514114514114514114514], [Resourcefulness], [Vikram], [49], [Perseverance], ) #table( columns: 3, [Substance], [Subcritical °C], [Supercritical °C], [Hydrochloric Acid], [12.0], [92.1], [Sodium Myreth Sulfate], [16.6], [104], [Potassium Hydroxide], [24.7], [114.514] )
https://github.com/magic3007/cv-typst
https://raw.githubusercontent.com/magic3007/cv-typst/master/RESUME_JingMai-EN.typ
typst
#show heading: set text(font: "Linux Biolinum") #show link: underline // Uncomment the following lines to adjust the size of text // The recommend resume text size is from `10pt` to `12pt` #set text( size: 10pt, ) // Feel free to change the margin below to best fit your own CV #set page( margin: (x: 0.9cm, y: 1.3cm), ) // For more customizable options, please refer to official reference: https://typst.app/docs/reference/ // This curriculum vitae is mainly for industrial job marketing, so its emphasis is on project experience. // References: // - https://skyzh.github.io/files/cv.pdf #set par(justify: true) #let chiline() = {v(-3pt); line(length: 100%); v(-5pt)} = <NAME> <EMAIL> | #link("https://github.com/magic3007")[github.com/magic3007] | #link("https://magic3007.github.io")[magic3007.github.io] | (+86)137-9865-3004 == Research / Job Interests #chiline() #include "doc/interests.typ" == Education #chiline() #include "doc/education.typ" == Research Projects #chiline() #include "doc/research_projects.typ" // == Open-Source Contributions // #chiline() == Honors & Awards #chiline() #include "doc/honor_awards.typ" == Publications #chiline() #include "doc/publications.typ" == Skills #chiline() #include "doc/skills.typ" #h(1fr) #text(gray)[Last Updated in March, 2024]
https://github.com/StanleyDINNE/php-devops-tp
https://raw.githubusercontent.com/StanleyDINNE/php-devops-tp/main/documents/Rapport/Typst/Constants.typ
typst
#import "Template_default.typ": set_config #let __constants_toml = toml("__private_tools/constants.toml") #let color = __constants_toml.color #let document_data = ( author: ( reb: __constants_toml.author.reb, stan: __constants_toml.author.stan, raf: __constants_toml.author.raf, ) ) #let figures_folder = __constants_toml.figures_folder #let line_separator = align(center, line(length: 50%)) #let size = ( foot_head: __constants_toml.size.foot_head * 1pt, ) #let char = ( em-dash: str.from-unicode(__constants_toml.char.em-dash), tab: str.from-unicode(__constants_toml.char.tab), // no-indent-fake-paragraph: text(0pt, white)[.], )
https://github.com/TypstApp-team/typst
https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/visualize/gradient-relative-conic.typ
typst
Apache License 2.0
// Test whether `relative: "parent"` works correctly on conic gradients. --- // The image should look as if there is a single gradient that is being used for // both the page and the rectangles. #let grad = gradient.conic(red, blue, green, purple, relative: "parent"); #let my-rect = rect(width: 50%, height: 50%, fill: grad) #set page( height: 200pt, width: 200pt, fill: grad, background: place(top + left, my-rect), ) #place(top + right, my-rect) #place(bottom + center, rotate(45deg, my-rect)) --- // The image should look as if there are multiple gradients, one for each // rectangle. #let grad = gradient.conic(red, blue, green, purple, relative: "self"); #let my-rect = rect(width: 50%, height: 50%, fill: grad) #set page( height: 200pt, width: 200pt, fill: grad, background: place(top + left, my-rect), ) #place(top + right, my-rect) #place(bottom + center, rotate(45deg, my-rect))
https://github.com/feiyangyy/Learning
https://raw.githubusercontent.com/feiyangyy/Learning/main/linear_algebra/矩阵代数.typ
typst
#import "@preview/cetz:0.2.2" #set text( font: "New Computer Modern", size: 6pt ) #set page( paper: "a5", margin: (x: 1.8cm, y: 1.5cm), ) #set par( justify: true, leading: 0.52em, ) #set heading(numbering: "1.",) = 映射 映射在测度、微积分、代数以及概率论中都有所体现,矩阵与向量相乘,可以看做对向量中的一种映射变换。新版的教材中删去了这个部分(反而显得矩阵代数这部分有点生硬) #let bs = $bold(S)$ #let bss = $bold(S^')$ #let x = $x$ #let y = $y$; #let f = $f$ == 映射 如果有一个映射法则$f$, 对于每一个$x in #bs$,都能在#bss 找到唯一一个对应的元素$y in #bss$。此时我们把#y 叫做 #x 在映射法则#f 下的象,记作$f(x)$, #x 被称作 #y 的原象。我们映射法则f记作: $f: #bs -> #bss \ x |-> y $ 集合#bs 叫做 #f 的#highlight()[定义域], #bss 叫做#f 的 #highlight()[陪域]。要注意#f 的取值的集合是陪域的一个子集 == 映射的象集 对于法则$ f: #bs -> #bss \ x |-> y$ , 所有的$x in #bs$ 对应的 $f(x)$的映射的结果的集合,叫做#f 的象集,简称象, 记作 $Im f := {f(x) | x in #bs} := f(#bs)$,显然$f(#bs) in #bss$ == 满射 如果$f(#bs) = #bss$,则称$f: #bs -> #bss$ 是一个满射。$f(#bs) = #bss$ 的充要条件是#bss 中的任意元素都能在#bs 中找到一个原象(注意,不一定是唯一一个) == 单射 如果对于任意 $a ,b in #bs, a != b <=> f(a) != f(b)$, 则称#f 是一个单射。 单射的充要条件是,对于$a,b in #bs, f(a), f(b) in #bss, 若 f(a) = f(b) -> a = b$ 可以用一次线性函数记忆单射,用二次函数记忆非单射 == 双射 如果映射#f 既是满射也是单射,则$forall y in #bss$ 都能在#bs 找到#highlight()[唯一一个]原象。此时称#f 是双射, 或者说一一对应 用一次函数记忆双射,用二次函数记忆非双射 双射和单射的主要区别是,$Im f in #bss and Im f != #bss$, 双射的话,就是单射#f 满足$Im f = #bss$ == 原象集 设$f:#bs -> #bss$, 则对应于$b in #bss$, 所有在#bs 中的元素集合$a in W$, 能使得$f(a) = b$。 我们把$W$ 称作$b$ 的原象集,记作$f^(-1)(b) := {x |x in #bs, f(x) = b}$,显然,如果$b in #bss \\ Im f -> f^(-1)(b) = emptyset$. 如果$b in Im f$, 则$f^(-1)(b)$ 成为 b 的纤维 == 相等映射 #let mf=$f$; #let mg=$g$ 如果映射#mf 和 #mg 有相同的#highlight()[定义域 陪域],并且$forall x in #bs, f(x) = g(x)$, 则称#mf 和 #mg 相等 == 恒等映射 如果映射$f: S -> S, f(x) = x$, 即将#bs 中的元素映射为自己,则称这个映射为恒等映射,或者单位映射, 记$1_s$(#highlight()[这等价于后文中的单位矩阵]) 可以用$y = f(x)$ 或者单位矩阵 记忆恒等映射,注意恒等映射的定义域是#bs, 象集也是#bs, 他是一个双射 如果一个$f: #bs -> #bs$, 我们通常把#f 称作一个变换, 如果一个$f:#bs -> K$ (K是数域),则我们把#f 叫做#highlight()[函数] == 复合映射 #let bsss = $bold(S^(''))$ #let g =$g$ 对于映射$g: #bs -> #bss, f:#bss -> #bsss$,我们把两者的复合定义为两者的乘积:$(f g)(a) := f(g(a))$, 我们用语言来描述这件事,#f #g 定义为 用#f 将#g 在#bss 下的象集映射到#bsss 中。 由此可见,映射的乘积#highlight()[不一定能交换], 且其乘积不一定有定义(需要满足映射的定义域的条件, 即#g 的象集要是#f 的定义域的子集) 在数学分析中,$u = g(x), f(g(u))$ 称为复合函数 由此直接体现了矩阵乘法的含义:#highlight()[映射的复合] 容易验证:$f 1_s = f$, $1_s f = f$. 让我们简单的证明这个东西,$forall x in #bs, 1_s(x) = x, ->f(1_s(x)) = f(x) = f, x in #bs$, $forall x in #bs, 1_s(f(x)) = f(x) = f$, 从而恒等映射与任意映射#f 的乘积都等于映射自身,并且满足#highlight()[交换律] === 定理 在有定义的情况下,映射的乘积满足结合律 #let bssss = $bold(S^(''''))$ 即$h: #bs -> #bss, g:#bss -> #bsss, f:#bsss -> #bssss, (f g h) = (f g) h = f (g h)$. 证明: $ forall x in #bs, (f g h) x = f(g(h(x))), (f(g h))x = f((g h) x) = f(g(h(x))), ((f g) h)x = ((f g)(h(x))) = f(g(h(x))) = (f g h) x $ 因此三者相等(威力强大啊,矩阵乘法的结合律直接就被清楚诠释了) == 逆映射 对于映射$f: #bs -> #bss, g:#bss -> #bs$,如果满足:$f g = 1_(#bss), g f = 1_(#bs)$ 那么称#f 是可逆的, #g 是 #f 的唯一一个逆映射。 下面证明唯一性:假设#g 和#h 都是#f 的逆映射,则 $h f g = (h f) g = 1_(#bs)g = g = h f g = h (f g) = h 1_(#bss) = h $,因此映射唯一 #let inf=$f^(-1)$ 如果#f 是可逆的,我们用$f^(-1)$ 表示$f$的逆,那么$f#inf = 1_(#bss), #inf f = 1_(#bs)$,因此#inf 也是可逆的,他的逆就是#f, 从而$(#inf)^(-1) = f$ === 定理(映射的可逆定理) 映射$f:#bs -> #bss$ 可逆的充要条件是#f 是双射 ==== 引理 如果映射$f:#bs ->#bss, g:#bss -> #bs$ 满足$g f= 1_#bs$,则f是一个单射,g是一个满射 证明#f 是单射:令$a_1, a_2 in #bs, 且 f(a_1) = f(a_2) => a_1 = (g f)a_1 = g(f(a_1)) = g(f(a_2))= (g f)a_2 = 1_#bs a_2 = a_2;$ 从而#f 是单射 证明#g 是满射, 这里要注意#f 的定义域是#bs, #f 的象集$in #bss$, #g 的定义域是#bss, $forall a in #bs, g(f(a)) = (g f) a = a$,按照满射的定义,$forall a in #bs, f(a)$是a 在映射#g 的一个原象。这里要注意,此处还没有要求$f(a)$的象集就是#bss ==== 定理证明: 必要性: 设#f 可逆,有引理可以知道$cases(#f #inf = 1_#bs -> f 单 射, #inf #f = 1_#bss -> f 满 射)$ 从而#f 是双射 充分性: 设#f 双射,对于$forall a^' in #bss$, 由#f 的满射性质可知,$exists a in #bs s.t. f(a) = a^'$. 又因为#f 为单射,从而这个$a$唯一。 设$g: #bss -> #bs, g(a^') = a$,那么$(f g)a^' = f(g(a^')) = f(a) = a^' => (f g) = 1_#bss$, $(g f)a = g(f(a)) = g(a^') = a => (g f) = 1_#bs $. 结合两者,#f 可逆 定理得证。 这里比较坑的是被定义域困住了,一直在想定义域的事情 === 习题 习题6. 对于#bs 和 #bss, 如果存在一个双射 $f:#bs -> #bss$, 则称#bs 和 #bss 有相同的基数,证明整数集$Z$ 和偶数集$O$ 有相同基数。 证: $forall x in Z, f := 2x -> f(x) in O$ ,并且,$forall a, b in Z, a != b, f(a) = 2a != 2b = f(b) ->$ f 是一个单射 $forall y in O => y/2 in Z => f(y/2) = y$ 即,$y/2 in Z$ 是 $y in O$ 在映射#f 下的原象,从而#f 是双射。 两者同基 这是一个很奇妙的性质,一个东西的子集和他同基(等势) #highlight()[所有和$Z$同基数的都是可数集合] 有理数集也是可数集,找个时间证一下。 == 线性映射 #let bkn = $bold(K)^n$; #let bks = $bold(K)^s$ #let ba=$bold(a)$; #let bb=$bold(b)$;#let bx=$bold(x)$ 设数域$K$上的向量空间有映射$#sym.sigma := bkn->bks$能满足线性条件两条规则: $ forall, ba, bb; sigma(ba+bb) = sigma(ba) + sigma(bb) \ sigma(k ba) = k sigma(ba) $ 这样的映射称为线性映射 设$A$ 是数域的$K$ 上的$s times n$的矩阵. 令$ba in bkn, AA:bkn->bks, ba |->A ba$. 即$A$是一个映射,容易验证他也是一个线性映射。 === 性质1. 设n元线性方程组$A bx = bb$ 有解$<=>exists ba in bkn, s.t. A ba = bb <=> exists ba in bkn, AA(ba) = bb <=> bb in Im AA$ === 性质2. $A bx = bb$有解,设$A = (ba_1, ba_2,...,ba_n)$, 则$bb in <ba_1, ba_2,...,ba_n>$, 因为所有有解的$bb$ 是由$AA$ 依据$bx$ 生成的, 而$bb$ 是$A$ 的列向量组的线性组合,从而$Im A = <ba_1, ba_2,...,ba_n>$(这实际上需要严格的证明,此处只能说明$AA$的象是矩阵列空间的子空间) == 映射的核 对于齐次线性方程组的解空间是$W$, 那么 $ bb in W, s.t. A bb = bold(0) <=> AA(bb)=bold(0) $ 从这点出发,我们设$sigma:bkn -> bks$, 设#bkn 的一个子集(类比上面的$W$),满足以下条件: $ (bb in bkn, sigma(bb) = bold(0)) $, 我们称其为$sigma$的核,记作Ker$sigma$, 由定义可见,$sigma$的核等价于其映射矩阵表示的齐次线性方程组的解空间 = 矩阵的基本运算 前面章节中,矩阵是通过线性方程组求解,我们研究其系数矩阵而直接引入的,除了线性方程组外,矩阵还可以表示具有关系型的表格、空间或平面中的变换等。本文主要就是介绍矩阵本身支持的运算及其性质。 == 矩阵的加法、数量乘法 === 定义1. 矩阵相等 #let A=$A$ ; #let B=$B$; #let K=$K$ ; #let C=$C$; #let sn=$s times n$ 如果#A 与 #B 都是数域 #K 上的$s times n$ 的矩阵, 并且$a_(i,j) = b(i,j)$ 则称#A #B 相等,记作#A = #B === 加法定义 在数域#K 上,令$C_(s times n) = (c_(i, j))_(s times n) = (a_(i,j) + b_(i, j))_(s times n)$, 称#C 是 #A #B 的和,记作$C = A + B$。从定义可以看出,两个矩阵只有形状相同才能相加(即两者要在同一空间) === 数量乘法定义 设有矩阵$A_(#sn) = (a_(i , j))_(#sn), k in K$, 令$M = (k a_(i,j))_(#sn)$,称M为矩阵A和k的数量积,记为$M=k A$ 在前面的向量空间中,我们除了要定义运算外,还要定义 0 元、 负元(回忆向量空间中,0元是所有分量为0的向量,$bold(a)$的负元是$-bold(a)$ ),类似的,我们定义$bold(0)_(s times n)$ (教材上没有个定义,我们暂且叫做0矩阵); 以及定义$-(a_(i,j))_(#sn) = -A$,把他叫做A的负矩阵。我们设有$C_(#sn)$,则可以验证 #A #B #C 满足以下8条规则: 1. 加法交换律 #A + #B = #B + #A 2. 加法结合律 #A + #B + #C = (#A + #B) + #C 3. #A 加上 0 矩阵等于 #A $A + bold(0) = A$ 4. #A 加上它的负矩阵(负元) 等于 0 矩阵 $A + (-A) = bold(0)$ - 0 元也称为 加法的单位元 5. 1#A = #A 6. 数量乘法结合律 $k l#A = k(l#A)$ 7. 数量乘法分配律 $(k+l)#A = k#A + l #A$ 8. $k (A + B)= k A + k B$ 可见,如果我们把所有$#sn$ 这样的矩阵看做一个集合,这个集合也满足我们在向量空间中定义(对于加法和数量乘法封闭),但唯一不同的是,这些元素都是矩阵而不是向量 == 矩阵乘法定义 // #set page(width: auto, height: auto, margin: .5cm) // 所有数学部分,填充色 // #show math.equation: block.with(fill: red, inset: 1pt) #grid( columns: (1fr, 0.5fr), align(left)[ #let t= $theta$ #let p=$phi$ 如右图所示,在平面坐标系上有个两个单位向量$bold(a) = (x,y)^T$ 以及$bold(b) = (x^',y^')^T$, 它们与$x$ 轴夹角分别时#sym.alpha, #sym.beta+#sym.alpha. 那么易知$cases(x=cos(alpha), y=sin(beta)), cases(x^' = cos(alpha + beta), y^' = sin(alpha + beta))$;$bold(b)$ 可以看做$bold(a)$ 逆时针旋转$beta$ 角度得来。我们考虑两者的坐标关系: $cases(x^' = cos(alpha)cos(beta) + sin(alpha)sin(beta), y^' = sin(alpha)cos(beta) - cos(alpha)sin(beta)) => cases( x^' = cos(beta)x - sin(beta)y, y^' = sin(beta)x + cos(beta)y ) => A=mat(cos(beta), -sin(beta);sin(beta), cos(beta))$ $A$为系数矩阵。即我们可以用$A$ 这样的矩阵(方程组)表达旋转,它将一个向量,变为另外一个向量并且它只和旋转度数$beta$有关(这个和前面方程组求解不同)由此对于平面空间中,任意旋转度数$phi$的旋转矩阵就定义为:$A = mat(cos(phi), -sin(phi); sin(phi), cos(phi))$.那么对于旋转$phi$ 再旋转$theta$度数而言,其旋转矩阵就表达为:$C = mat(cos(phi + theta), -sin(phi + theta); sin(phi + theta), cos(phi + theta)) = mat(cos(#p)cos(#t) - sin(phi)sin(theta), -(sin(#p)cos(#t)+ cos(#p)sin(#t));sin(#p)cos(#t)+ cos(#p)sin(#t), cos(#p)cos(#t) - sin(phi)sin(theta))$, 其中 #t 的旋转矩阵是$T= mat(cos(#t), -sin(#t); sin(#t), cos(#t))$ 观察可得:$cases(c_11= a_11 t_11 + a_12 t_21 , c_12= a_211 t_12 + a_12 t_22, c_21= a_21 t_11 + a_22 t_21, c_22= a_21 t_12 + a_22 t_22)$ ], align(right)[ #cetz.canvas({ import cetz.draw: * let vmin = -1.5; let vmax = 1.5 let a_x = calc.cos(30deg) let a_y = calc.sin(30deg) let b_x = calc.cos(60deg) let b_y = calc.sin(60deg) grid((vmin, vmin), (1.5, 1.5), step: 0.5, stroke: gray + 0.2pt) circle((0,0), radius: 1) line((vmin, 0), (vmax, 0), mark: (end: "stealth")) content((), $x$, anchor: "west") line((0, vmin), (0, vmax), mark: (end: "stealth")) content((), $ y $, anchor: "south") // 原点, 原点-> 起始边, 原点到终边 // 角度本身不画边 // 只不过它通过边来画角度,即使终点定义错了,影响貌似也不大 cetz.angle.angle((0,0), (1,0), (calc.cos(30deg), calc.sin(30deg)), label: text(black, [$alpha$]), inner:true) cetz.angle.angle((0,0), (calc.cos(30deg), calc.sin(30deg)), (calc.cos(60deg), calc.sin(60deg)), label: text(black, [$beta$]), mark: (end: "stealth"), radius: 0.8) // 第一个应该是原点,第二个是终点 line((0,0), (calc.cos(30deg), calc.sin(30deg))) content((a_x+0.3, a_y), $(x,y)$, anchor: "south") line((0,0), (calc.cos(60deg), calc.sin(60deg))) content((b_x+0.3, b_y+0.1), $(x^',y^')$, anchor: "south") }) ] ) 由此$C$ 可以由$A T$的某种运算关系表示,这种运算我们定义为矩阵的乘法(个人认为这个例子不是太好,作为引出矩阵乘法定义有点生硬,这里主要是为了练习排版和作图,才把这段记下来) == 矩阵乘法 设$A=(a_(i j))_(#sn), B = (b_(i j))_(n times m), C = (c_(i j))_(s times m)$ 并且有$c_(i j) = sum_k a_(i, k) b_(k, j)$ 用文字表达即,$c_(i j)$ 通过选定A 矩阵的第$i$ 行, 选定B矩阵的第$j$列,然后,从$k = 1->n$, 依次取A的第$i$行的第k个(列)元素 与 B矩阵第$j$列的第k个(行)元素相乘,然后求和 由矩阵乘法可见,能使得$a(i, k), b(k, j)$ 均有意义的条件是A矩阵的列数与B矩阵的行数相等,A矩阵也叫做#highlight()[左矩阵], B矩阵也叫#highlight()[右矩阵]。 矩阵的乘法运算中涉及到 乘法和加法,有时候这个运算会被定义到计算机的DSP指令集中,叫做乘加运算(muladd) == 矩阵乘法性质 以下均假设所引用的矩阵可以相乘 === 结合律 $A B C = (A B)C = A(B C)$ #let nm = $n times m$ #let mr = $m times r$ #let sr = $s times r$ #let ma= $A_(#sn)$;#let mb =$B_(#nm)$ #let b0 =$bold(0)$ 设$A=(a_(i j))_(#sn), B = (b_(i j))_(#nm) C= (c_(i j))_(m times r)$ 在矩阵的形状上, 等式两边都是#sr 矩阵。 下面证明其每个元素相等 $((A B)C)_(i j) = sum_k [(A B)_(i k) c_(k j)] = sum_k {[sum_l a_(i l) b_(l k)] c_(k j)} = sum_k sum_l [a_(i l) b_(l k) c_(k j)] -> c_(k j) 乘 法 分 配 到 左 侧\ (A(B C))_(i j) = sum_k [a_(i k) (B C)_(k j)] = sum_k {a_(i k) [sum_l b_(k l) c_(l j)]} = sum_k sum_l [a_(i l) b_(l k) c_(k j)] -> a_(i l) 乘 法 分 配 到 右 侧$ 可见两者相等 与实数域里面的乘法的交换律不同,矩阵乘法一般不满足交换律,首先$A B$ 交换的$B A$ 就不一定能相乘。当$s != m$ 时,$#mb #ma$ 就没有定义。其次即便是$B A$ 能够相乘,其结果也可能和$A B$ 不同。比如 $s = m != n$时,$#ma #mb = C_(s times s), #mb #ma= D_(n times n)$. $C$ $D$形状不同 === 零因子 设$A = mat(0, 1; 0, 0) , B = mat(0, 0; 0, 1;),则 A B = mat(0, 1; 0, 0); B A = mat(0, 0;0, 0)$ 可见 $A != 0 且 B != 0 <==>^(不 能 得 出) A B != 或 B A = 0$ 对于#A,如果存在一个矩阵$#B != 0$能够使得 #A #B = #b0, 则把#A 称作一个左零因子,如果存在一个$#C != #b0$,并且#C #A = #b0 则把A叫做一个右零因子。左右零因子统称为零因子 === 左分配律 $A(B+C) = A B + A C$ === 右分配律 $(B + C) A = B A + C A$ #let bdef = $(b_(i j))_(#sn)$; #let cdef = $(c_(i j))_(#sn)$; #let aef = $(a_(i j))_(#nm)$ 下面对右分配律证明,设$B=#bdef,C = #cdef, A = #aef$,那么$[(B + C) A]_(i j) = sum_k (A+B)_(i k) c_(k j) = sum_k [(a_(i k) + b_(i k))]c_(k j) = sum_k a_(i k) c_(k j) + sum_k b(i k) c(k j) = B A + C A$ 得证 左分配律证明方法类似 可见矩阵乘法相比较数域中的乘法性质较差一些,矩阵间的乘法不一定存在,且,矩阵的乘法定律也比较受限 === 数量乘法规律 $k(A B) = (k A)B = A (k B)$ 这是因为数量乘法可以提到求和符号外边,从而自然得证 === 单位矩阵 #let idef =$bold(I)$ 对于n阶#highlight()[方阵],只有对角线上的元素为1,其他全为0的矩阵,称为单位矩阵,记作$#idef _n$ 或者#idef, 容易验证: $#idef _s A_(#sn) = A_(#sn); A_(#sn) #idef _n = A_(#sn)$ ,我们证一下第一个$(#idef _s A_(#sn))_(i j) = sum_k #idef _(i k) a_(k j) = a_(i j) <== because cases(#idef _(i k) = 0 当 (k != i), #idef _(i k) = 1 当 (k = i))$ 如果 #A 是n阶方阵,那么$#idef A = A #idef = A$ === 数量矩阵 对角线元素全为$k$,其余元素全为0的方阵称为数量矩阵,那么显而易见其可以表示为$k #idef in W$, 那么很自然有 $ k#idef + l#idef = (k + l)#idef in W \ k(l #idef) = (k l)#idef in W \ (k#idef)(l#idef) = (k l)#idef in W $ 因此可见$W$ 是一个封闭的空间(特别是第三个公式),注意其中第三个公式需要展开得出=== 可交换矩阵 如果#A#B =#B#A 则称$A B$ 时刻可交换的,可交换蕴含两个强限制条件1. #A#B #B#A 有定义且两者的结果相等 。我们容易验证$k #idef A = A (k #idef)$. 并且当这个等式成立时,A一定是和$#idef$ 同阶的#highlight()[方阵] 对于n阶矩阵$A_n$,我们可以定义他的n次幂$A^m = A dot A dot A ..., m>=0, m in Z$, 同时我们定义$A^0 =^(d e f) bold(I)$, 那么,就有$A^k A^l = A^(k + l) => 形 式 定 义$, $(A^k)^l = A^(k l) => 形 式 定 义$ 即便$(A B)$ 是一个n阶方阵, $(A B)^k$ 有定义,由于 A B 一般不可交换,从而一般$(A B)^k != A^k B^k$. #highlight(fill: red)[如果#A #B 可以交换],则$(A B)^k = product_(i = 1)^k (A B)$,因为 #A #B 可以交换,则根据乘法的结合律,$(A B)_i (A B)_(i+1) = (A A)_i (B B)_(i+1) <- 交 换 中 间 的 A B$,这样,我们可以依次把所有的#A 逐个交换到乘积的前面,剩下的就是#B 的乘积,从而$product_i (A B)_i = product_i A_i product _i B_i = A^k B^k$ 矩阵的二项式定理(主要复习二项式定理) 对于实数域的二项式定理: $(a+b)^n = sum_k C_n^k a^k b^(n-k)$, 推理如下: 考虑乘法的分配律$(a+b)c = a c + b c$, 那么$(a+b)^2 = (a+b)(a+b) = a(a+b) + b(a+b) = a a + a b + b a + b b = a^2 + b^2 +2a b$ 这么展开来看: 1. 对于第1个乘法单元以分配律展开,a(a+b),#highlight()[相当于选择第一个乘法单元中的a 和后者相乘],b(a+b) 类似的是选择...中的b与后者相乘 2. 对第二个乘法单元展开,a a 相当于第2个乘法单元也选择a , 则产生$a^2$, $a b$ 是第二个乘法单元选择b产生的结果。 同理 $b a$是1.选择b展开时,加上本单元选择a 展开产生, $b^2$结论类似 由此,我们可以推论$(a+b)^n$ 中,$a^k b^(n-k)$, 其系数的产生由$n$个乘积累单元中选择$k$个a,再从剩余的乘积单元中选择$k$个b产生,则其系数就是$C_n^k C_(n-k)^(n-k)=C_n^k$ 这个只能便于理解和记忆,下面让我们来正式的证明他: step 0. 先证明帕斯卡法则 $C_(n-1)^k + C_(n-1)^(k-1) = C_n^k $ 左边: $C_(n-1)^k + C_(n-1)^(k-1) = frac((n-1)!, k! (n-1-k)!) + frac((n-1)!, (k-1)!(n-k)!) = (n-1)![frac(1, k!(n-k-1)!) + frac(1, (k-1)!(n-k)!)] = (n-1)!(frac((k-1)!(n-k)! + k!(n-1-k)!, k!(n-k-1)!(k-1)!(n-k)!)) = \ (n-1)!(k-1)![frac((n-k)! + k(n-k-1)!, k!(n-k-1)!(k-1)!(n-k)!)] = (n-1)!(n-k-1)![frac((n-k) + k, k!(n-k-1)!(n-k)!)] = (n-1)![frac((n-k) + k, k!(n-k)!)] = frac(n (n-1)!, k! (n-k)!) = n!/(k!(n-k)!) = C_n^k$ step 1. 假设$(a+b)^n = sum_(k=0)^n C_n^k a^k b^(n-k)$成立,易验证n = 1时, 等式成立,现在假设其在n=N 时成立 step 2. 我们证明(n= N+1)时也成立,证明如下: $(a+b)^(N+1) = (a+b)[sum_k C_N^k a^k b^(N-k)] = a sum_k C_N^k a^k b^(N-k) + b sum_k C_N^k a^k b^(N-k) = sum_k C_N^k a^(k+1) b^(N-k) + sum_k C_N^k a^k b^(N-k +1) = sum_k A_k + sum_k B_k $ 对于$A_k, B_k$ ,令$k=t, 0<=t<=N-1)$, 对于$B_k$,令$k=t+1$,那么可以发现 $A_t + B_(t+1) = C_N^t a^(t+1)b^(N-t) + C_N^(t+1) a^(t+1)b^(N-t) = [a^(t+1)b^(N-t)][C_N^t + C_N^(t+1)] = C_(N+1)^(t+1)(a^(t+1)b^(N+1-(t+1))) -> C_(N+1)^(tau)(a^(tau)b^(N+1-(tau))), 1 <= tau=t+1 <= N$, 这里$t $不能取N的原因是, 对于$B_k, 0 <= k <= N$ 再证明,$tau=N+1$ 时也成立: 当要取$b^0$项时,可知$B_k$任意项不能产生$b^0$, $A_k$ 能取$b^0$时 只有$A_k_(k=N) = C_N^N a^(N+1)b^0 = C_(N+1)^(N+1) a^(N+1) b^(N+1-(N+1)) = C_(N+1)^(tau)(a^(tau)b^(N+1-(tau))) _(tau=N+1)$ 再证明,$tau=0$ 时也成立:当要取$a^0$时,可知$A_k$ 不能产生$a^0$, 而$B_k$ 能取得$a^0$时 只有$B_k_(k=0) = C_(N)^N a^0 b^(N+1) = C_(N+1)^(tau)(a^(tau)b^(N+1-(tau))) _(tau=0)$ 从而,$forall 0<=k<=N+1, (a+b)^(N+1) = C_(N+1)^(k) a^(k) b^(n-k)$. 二项式定理得证 回到矩阵: 这里说明,当#A #B 不能交换时,二项式展开产生的#B #A 不一定有定义,即便有 他和#A#B 也不相等,即形如#B#A#A#B 这样的项不能合并,从而不适用二项式定理。对于可以交换的矩阵,不存在上述限制,则可以适用于二项式定理 === 矩阵运算的结果的转置 转置真的是最讨人厌的东西之一, 形状变了,又要用符号表示和原矩阵的关系 容易证明: 1. $(#A + #B)^T = #A^T + #B^T$ 2. $(k A)^T = k(A)^T$ 3. $(A B)^T = B^T A^T$ #highlight()[这个需要特别留意] 这里先证明一下1. 设$A_(#sn), B_(#sn), C = (A + B)_(#sn), D_(n times s) = C^T$ $D_(n times s)_(j i) = c_(i,j)= a_(i, j) + b_(i.j);\ (A^T + B^T)_(j, i) = (A^T_(j,i) + B^T_(j, i)) = a_(i,j) + b_(i,j) $ 可见两者相等 在证明一下3. 设$A_(#sn), B_(#nm), C_(s times m) = A B $, 所以 $c_(i ,j) = sum_k a_(i, k) b_(k, j) = C^T_(j, i) \ (B^T A^T) (j, i) = sum_k B^T_(j, k) A^T_(k, i) = sum_k b_(k, j) a_(i, k) = sum_k a_(i, k)b_(k, j) => \ (A B)^T_(j, i) = C^T(j, i) = (B^T A^T)(j,i) => (A B)^T = B^T A^T $ === 用矩阵表示线性方程组 #let bx=$bold(x)$ #let ba=$bold(a)$; #let bb=$bold(b)$ 严格来说,原书到目前为止并没有给出矩阵和向量的相乘定义,这里直接把列向量当做一个n行1列的矩阵来看其实缺少说明,因为毕竟不是同一个东西.同时也不能体现和前文中引入矩阵乘法时矩阵的"映射"作用 这里给一个来自#link("https://mbernste.github.io/posts/matrix_vector_mult/#:~:text=As%20a%20%E2%80%9Crow%2Dwise%E2%80%9D,of%20a%20vector%20as%20coefficients")[github]的参考定义: 假设#A 的列数和列向量#bx 的元素数目相等,则定义矩阵和向量的乘法 $#A #bx := sum_i x_i #ba _i = #bb, $ 其中$#ba _i$ 是矩阵的列向量,$x_i$ 是#bx 的各分量,#bb 是和#bx 同属于$K^n$空间,从而#A 是一个#highlight()[变换] 如果我们把线性方程组的未知量写成列向量$#bx = (x_1, x_2, ..., x_n)^'$,常数项写作$#bb = (b_1, b_2, ..., b_n)^'$, 那么线性方程组就可以写作:$A #bx = #bb$, A是方程组的系数矩阵,同理,齐次线性方程组就可写作$#A #bx = bold(0)$ === 从其他角度看矩阵乘法 #let avecs = $(#ba _1, #ba _2 , ..., #ba _n)$ 设$A_(#sn), B_(#nm)$, 如果把#A 以列向量形式表示,则$A = #avecs, #ba _i in K^s$,那么 $A B = #avecs mat(b_11, b_12, ..., b_(1 m);...; b_(n 1), b_(n 2), ..., b_(n m)) = (b_11#ba _1 + b_21 #ba _2 + ...+ b_(n 1)#ba _n,...,b_(1 m)#ba _1 + b_(2 m) #ba _2 + ...+ b_(n m)#ba _n)$, 即结果矩阵$C_(s times m)$ 列向量,#highlight()[是以矩阵B的各列的线性组合而生成],C矩阵的列向量个数等于B矩阵的列,C矩阵的#highlight(fill:red)[列]向量$bold(c)_i in <#ba _1, #ba _2, ..., #ba _n>$ 把#B 按照行向量形式表示,则$bold(B) = (#bb _1, #bb _2, ..., #bb _n)^', #bb _i in K^m$,那么矩阵乘法就可以写作$A bold(B) = mat(a_11, a_12, ..., a_(1 n); ...; a_(s 1), a_(s 2), ...,a_(s n))vec(#bb _1, ..., #bb _n) = vec(a_11 #bb _1 + a_12 #bb _2 + ... + a_(1 n)#bb _n, ..., a_(s 1) #bb _1 + a_(s 2) #bb _2 + ... + a_(s n)#bb _n)$, #C 的各行向量是#B 矩阵的各行向量通过以#A 的各行为系数线性组合而成,从而#C 的#highlight(fill:red)[行]向量一定在$<#bb _1, #bb _2, ..., #bb _n>$ 中 列列组合,行行组合 = 特殊矩阵 == 基本矩阵 在$M_(#sn)$ 中,除了0矩阵外, 我们定义只有一个元素为1,其他元素为0的矩阵为基本矩阵。我们把$(i, j)$ 元为1,其余元素为0的矩阵记作$E_(i,j)$. 因此在$M_(#sn)$ 中一共有$s times n$ 个基本矩阵。 $M_(#sn)$中的任意矩阵可以表示为$sum_i sum_j a_(i j)E_(i j)$ === 基本矩阵乘法(IMPORTANT) 前面说过,矩阵乘法,乘积的行向量是右矩阵的行向量的线性组合,组合系数是左矩阵的各行,让$E_(i j)A$,则相当于,结果矩阵只有第$i$行不为0,并且其取得是#A 的第$j$行. 从而,其相当于将$#ba _j$ 搬到了第$i$行。注意$A$的行数和乘积矩阵的行数不相等($r_j -> r_i$) 如果有$B E_(i j)$,按照矩阵乘法的第二种定义, 则代表乘积矩阵的各列是B的矩阵的各列的线性组合,从而,乘积矩阵的第$j$列有值,其取得是B的第$i$列。从而他的作用是将B矩阵的第$i$列变换到第$j$列 $(c_i -> c_j)$ === 定理, 和任意n级方阵可交换的矩阵,一定是数量矩阵 1. 设#B 为矩阵,且可以和 n级方阵#A 交换, 即 #A#B =#B#A $=>$ #B 也是n级方阵 2. 设#B 可以和任意n级方阵交换,那么$E_(1,j)A=A E_(1,j)$, 左侧: 选择A的第$j$行到1行;右侧,选择A的第1列到第$j$ 列,即如下的两个矩阵相等: $ mat(a_(j,1), a_(j,2), ..., a_(j,n); 0, 0,...,0; ...; 0, 0,...,0;) = mat(0, 0, ..., a_(1,1), 0, ..., 0; 0, 0, ..., a_(2,1), 0, ..., 0; ...; 0, 0, ..., a_(n,1), 0, ..., 0;) => a_(j,k) = 0, k != j; a_(j,j) = a_(1,1), j in [1, n]; $ 根据$a_(j,j) = a_(1,1), j in [1, n]; => A = a_(1,1) I$, 从而A是数量矩阵 . Q.E.D == 对角矩阵 #let diag=$d i a g$ 除了主对角线之外的元素全为0的方阵称为对角矩阵,形如$mat(a_1,0,...,0; 0,a_2, ..., 0; ...,...,...,...; 0,0,..., a_n)$ 记为$#diag{a_1, a_2, ..., a_n}$ === 对角矩阵和普通矩阵相乘 ==== 1. 左乘 对角矩阵: 设$D=diag{d_1, d_2, ..., d_n}$, 则$D A = mat(d_1, 0, ..., 0;0, d_2, ...,0; ...; 0, 0, ..., d_n)vec(#ba _1, #ba _2, ..., #ba _n) = vec(d_1 #ba _1, d_2 #ba _2 , ..., d_n #ba _n)$,(记住#highlight()[结果矩阵的各行是右矩阵的各行以左矩阵的各行线性组合而成] 总是记错,下意识觉得行列对称)。 这个式子表明,A 左乘以D,就是分别把A的各行乘以D对应的各行非0元 ==== 2. 右乘 对角矩阵 $A D= mat(#ba _1, #ba _2, #ba _3, ..., #ba _n) mat(d_1, 0, ..., 0;0, d_2, ...,0; ...; 0, 0, ..., d_n) = mat(d_1 #ba _1, d_2 #ba _2, ..., d_n #ba _n)$ (记住#highlight()[结果矩阵的各列是左矩阵的各列以右矩阵的各列线性组合而成])。 该式表明,A右乘以D,就是把A的各列乘以D的各列非0元 3. 对角矩阵之间的运算 #let da = $diag{a_1, a_2, ..., a_n}$ #let db = $ diag {b_1, ..., b_n} $ 根据 1. 2., $#da dot #db = diag{a_1 b_1, ..., a_n b_n}$; $#da + #db = diag{a_1 + b_1, ..., a_n + b_n}$ $k #da = diag{k a_1, ..., k a_n}$ == 初等矩阵 由单位矩阵经过一次初等变换,得到的矩阵,称为#highlight()[初等矩阵],联想我们前面所讨论的矩阵三个初等行变换:1. 行交换, 2. 行倍乘 3. 行倍加。 === 三个基本初等矩阵 #let j =$j$; #let i = $i$; #let k = $k$ 将#idef 的#j 行的#k 倍加到#i 行上,记作$P(i, j(k))$, 表示为: $P(i, j(k)) = mat(1,0,0,...,0,0, 0,0; ...; 0,0,..., 1, ..., k,...,0;...;0,0,...,0,...,1,...,0;...;0,0,...,...,...,...,...,1) <- r_j times k + r_i $; 将#idef 的#i 行 乘以#k, 记作$P(i(k))$,表示为: $P(i(k)) = mat(1,0,...,...,0; ...; 0,0,...,k,...; ...; 0,0,...,...,1) <- r_i times k $ 将#idef 的#i 行 #j 行交换,记作$P(i,j)$,表示为: $P(i, j) = mat(1,0,..., ..., ..., ..., 0;...; 0,...,0,...,1,...,0; ...;0,...,1,...,0,...,0;...; 0,...,0,...,0,...,1;) <- r_i r_j 交 换 $ 初等矩阵将矩阵乘法和矩阵的初等行变换联系了起来: === 定理 $A_(#sn)$ 左乘以一个$s$阶初等矩阵,等价于对#A 做一次 初等行变换; #A 右乘以一个$n$阶初等矩阵,就相当于#A 做一次初等列变换 下面只证明前半部分 #let avec = $vec(#ba _1, #ba _2, ..., #ba _s)$ 我们把#A 写成行向量形式, 则$A=mat(#ba _1, #ba _2, ..., #ba _s) ^T$. 那么$P(i(k))A$就是: $mat(1,0,...,...,0; ...; 0,0,...,k,...; ...; 0,0,...,...,1)vec(#ba _1, #ba _2, ..., #ba _s)= vec(#ba _1, #ba _2, ..., #ba _k, ..., #ba _s) <- k times #ba _k $. 那么$P(i, j(k))A = mat(1,0,0,...,0,0, 0,0; ...; 0,0,..., 1, ..., k,...,0;...;0,0,...,0,...,1,...,0;...;0,0,...,...,...,...,...,1) #avec = vec(#ba _1, #ba _2, ..., #ba _k + k times #ba _j, ..., #ba _j, ..., #ba _s) <- #ba _k + k #ba _j$, $P(i,j)A = mat(1,0,..., ..., ..., ..., 0;...; 0,...,0,...,1,...,0; ...;0,...,1,...,0,...,0;...; 0,...,0,...,0,...,1;) #avec = vec(#ba _1, ..., #ba _j, ..., #ba _i, ..., #ba _s) <- #ba _i #ba _j 交 换$,定理前半部分得证 这个定理也可以反过来叙述,对#A 做初等行变换,等价于#A 左乘以一个初等矩阵, 对#A 做列变换,就等价于右乘以一个初等矩阵 (反过来证明其实稍微复杂一点),这里主要表示两者等价 == 上下三角矩阵 主对角线下方全为0的矩阵,即$a(i, j) = 0, (i >j)$,叫做上三角矩阵。很显然,两个上三角矩阵的和仍然是上三角矩阵,一个上三角矩阵乘以数量$k$,仍然是一个上三角矩阵。 === 命题, 两个n阶上三角矩阵#A #B 的乘积仍然是上三角矩阵,并且$A B$主对角线上的元素等于#A #B 对应的主对角元乘积 证明: $(A_(n) B_(n))_(i, j)= sum_k a_(i k) b_(k j), 若 要 a_(i k)b_(k j) != 0 => i <= k, k <= j. $, 设$i > j$ 则$cases(a_(i,k) = 0 \, 1 <= k < i, b_(k j) = 0 \, i <= k <= n (because i > j -> b(k, j) = 0))$ 从而对于任意$i>j$, 乘积对应的元素均为0,从而#A #B 仍然是上三角矩阵。 后半部分不证了,留作以后复习的时候证明 主对角上方的元素全为0的方阵称为下三角矩阵。对应于$a(i, j)=0, i < j$ 下三角矩阵性质和上三角性质类似 == 对称矩阵(略) 这两个部分个人目前认为不重要,后面用到了再来学习 == 斜对称矩阵 (略) = 矩阵乘积的秩、行列式和方阵的迹 #let rank =$r a n k$ == 定理 $rank(A B) <= min {rank(A), rank(B)}$ 回忆 #rank 的定义:#highlight()[等于矩阵行向量组和或者列向量组的秩]。 那么根据矩阵乘法的三种表述形式中的后两种,即$A B$的每一个列向量$(A B)_j$ 是A的列向量组$#avecs$的线性组合,从而$rank(A B) <= rank(A)$, 同理,$A B$的每一个行向量都是#B 的行向量的线性组合,从而$rank(A B) <= rank(B)$ ,综合,$rank(A B) <= min(rank(A), rank(B))$. Q.E.D === 是$A_(#sn)$ 是实数域上的一个矩阵,那么:$rank(A^' A) = rank(A A^') = rank(A)$ #let beta=$bold(eta)$ 由上定理$rank(A^' A) <= min {rank(A^'), rank(A)} -> rank(A^' A) <= rank(A)$ 可见该定理不能直接证明相等关系。接下来我们从线性方程组的解的角度出发求证: #let AT=$A^'$;#let betaT = $beta^'$ 1. 设$beta$ 是$A #bx = #b0 $的一个解,那么$#AT A beta= #AT #b0 = #b0$, 从而#beta 是 方程$(#AT A)#bx = #b0$ 的一个解 2. 设$beta$ 是$#AT A #bx = #b0$的解,那么两边同时左乘#betaT, $betaT #AT A #bx = 0 = > (A beta)^' (A beta) = 0 <- 此 处 是 实 数 0$,设$A beta = vec(c_1, c_2, ..., c_n) => (A beta)^' (A beta) = sum_k c_k^2 = 0 => c_k = 0, 1 <= k <= n$, 从而#beta 也是$A #bx = #b0$ 的一个解 \1. 表明,$#AT A #bx$ 的解一定可以在$#A #bx$的解空间中,\2. 表明,$#A #bx$ 的解一定在$#AT A #bx$ 的解的空间中,从而两者同解(解空间维数相等),从而它们的秩相等。对于复数域上的矩阵,$sum_k c_k^2 = 0 $ 不能得出$ c_k = 0$ #let nn = $n times n$ == 定理 设$A_(#nn), B_(#nn)$, 则 $|A B| = |A||B|$ 为了构造$|A||B|$, 可以构造这样的矩阵$mat(A, b0; -#idef, B)$ 该矩阵的行列式为$|A||B|$, 接下来我们对这个矩阵进行初等行变换: $ mat(A, b0; -#idef, B) = mat(a_11, a_12, ..., a_(1 n), 0,0,...,0;a_21, a_22, ..., a_(2 n),0,0,...,0;...;a_(n 1), a_(n 2), ..., a_(n n), 0,0,...,0;-1, 0, ...,0, b_11, b_12, ..., b_(1 n); 0, -1, ...,0, b_21, b_22, ..., b_(2 n);...; 0, 0, ...,-1, b_(n 1), b_(n 2), ..., b_(n n)) =>^(1) mat(0, 0, ..., 0, sum_k a_(1 k) b_(k 1), sum_k a_(1 k) b_(k 2),..., sum_k a_(1 k) b_(k n);a_21, a_22, ..., a_(2 n),0,0,...,0;...;a_(n 1), a_(n 2), ..., a_(n n), 0,0,...,0;-1, 0, ...,0, b_11, b_12, ..., b_(1 n); 0, -1, ...,0, b_21, b_22, ..., b_(2 n);...; 0, 0, ...,-1, b_(n 1), b_(n 2), ..., b_(n n)) $ 这里重点解释一下第一步,即消去#A 的第一行,首先,我们消去$mat(A, b0; -#idef, B)$ 中的 $a_11$,消除方法是,用$A + -#idef _(r 1) * a_11$, 对应于$b0$ 的第一行就变成$(a_11 b_11, a_11 b_12, ... a_11 b_1n )$, 接下来校区$a_12$, 方法是$A + -#idef _(r 2) * a_12$, $b0$ 的第一行就变成$(a_11 b_11 + a_12 b_21, a_11 b_12 + a_12 b_22, ... a_11 b_1n + a_12 b_2n )$,依次类推可得,完全消去#A 的第一行,则#b0 的第一行就变成$(sum_k a_(1 k) b_(k 1), sum_k a_(1 k) b_(k 2),..., sum_k a_(1 k) b_(k n))$, 这个乘积可以看做$ba_1 B, A = avecs^T$. 我们在消去过程中,构造了这个乘积。因为$ba_1$的任意一列$k$的元素消去时,只需要选择$- idef_(r_k) * a_k + A $即可,对应于#B 也是第$B_(r_k) * a_k$, #b0 部分则是$B_(r_k) * a_k + #b0$. 前面说过$bold(alpha)^T B$的结果就是#B 的各行向量以$bold(alpha)^T$的各分量为系数做线性组合。此处同理。 依此类推,我们很容易可以将上面的矩阵化作: $ mat(0, 0, ..., 0, sum_k a_(1 k) b_(k 1), sum_k a_(1 k) b_(k 2),..., sum_k a_(n k) b_(k n);a_21, a_22, ..., a_(2 n),0,0,...,0;...;a_(n 1), a_(n 2), ..., a_(n n), 0,0,...,0;-1, 0, ...,0, b_11, b_12, ..., b_(1 n); 0, -1, ...,0, b_21, b_22, ..., b_(2 n);...; 0, 0, ...,-1, b_(n 1), b_(n 2), ..., b_(n n)) => mat(0, 0, ..., 0, sum_k a_(1 k) b_(k 1), sum_k a_(1 k) b_(k 2),..., sum_k a_(1 k) b_(k n);0, 0, ..., 0,sum_k a_(2 k) b_(k 1), sum_k a_(2 k) b_(k 2),..., sum_k a_(2 k) b_(k n);...;0, 0, ..., 0, sum_k a_(n k) b_(k 1), sum_k a_(n k) b_(k 2),..., sum_k a_(n k) b_(k n);-1, 0, ...,0, b_11, b_12, ..., b_(1 n); 0, -1, ...,0, b_21, b_22, ..., b_(2 n);...; 0, 0, ...,-1, b_(n 1), b_(n 2), ..., b_(n n)) = mat(b0, A B; -idef, B) $ 根据拉普拉斯定理,$mat(b0, A B; -idef, B)$ 的行列式就是$|A B|$;而矩阵的初等行变换的行倍加(参考行列式性质7.)不会改变矩阵的行列式,从而$|A B| = |A| |B|$ 这个定理可以根据数学归纳法推广到任意各n阶矩阵相乘 $ |A_1A_2...A_n|= |A_1||A_2|...|A_n| $ == 定理 比内-柯西公式 略 == 方阵的迹 n阶方阵的主对角线元素之和称为A的迹,记作T, 即:$T_r(A) = sum_i a_(i i)$ 性质略 = 可逆矩阵(噩梦系列) #set math.equation(numbering: "(1)", supplement: [式]) #let bk = $bold(K)$ 对于数域#bk 上的矩阵#A,如果存在#bk 上的矩阵#B 使得 $ A B = B A = I $ <aa>, 则称#A 是可逆的矩阵(或者非奇异矩阵). 根据 @aa , 设$A_(#sn), B_(#nm)$, 则易知$s = m$, 同理,由$B A = I = A B => s = n => $ #A 是一个n 阶方阵,同理B也时一个n 阶方阵。 == 定理1. 如果#A 可逆,则#A 的逆矩阵唯一 设$B_1$ 是A的逆矩阵,$B_2$ 是A的另外一个逆矩阵,从而有$B_1 = B_1 #idef = B_1 A B_2 = #idef B_2 = B_2$, 从而其逆矩阵唯一 == 定义2. 逆矩阵 #let inva = $A^(-1)$ @aa 中的 #B 称为A的逆矩阵,记作$A^(-1)$, 根据定义$ A inva = inva A = #idef $ <bb> , 并且$(inva)^(-1) = A$. 由@bb 可知#A 可逆的必要条件是$|A| != 0$ (由矩阵乘积的行列式定理可得) #let BA=$bold(A)$ #let BAS=$mat(BA_(1, 1), BA_(2,1), ..., BA_(n, 1);BA_(1, 2), BA_(2,2), ..., BA_(n, 2);...; BA_(1, n), BA_(2,n), ..., BA_(n, n);)$ #let BAStar=$BA^(*)$ 当$|A| != 0$时,设$A=a_(i,j)$,$BA_(i j)$ 是$a_(i j)$的代数余子式,那么我们构造一个这样的矩阵 $ A BAS = mat(a_11, a_12, ..., a_1n;a_21, a_22, ..., a_2n;...; a_(n 1), a_(n 2), ..., a_(n n)) BAS = BAStar $ <cc> 由行列式性质可知,乘积矩阵$C_(i, i) = sum_k a_(i, k) BAStar_(k, i) = sum_k a(i, k) BA_(i,k) = |A|$。而$i != j, C_(i,j) = sum_k a_(i,k)BA_(j,k)$, 由行列式性质5(第i行元素与第k行对应元素未知的代数余子式乘积之和为0,$i!=k$), 因此 @cc 就可以写作: $ A BAStar = mat(|A|, 0, 0, ..., 0; 0, |A|, 0, ...,0;...;0,0,0,..., |A|) = |A| #idef. $ <cc2> 一般把#BAStar 称作#A 的伴随矩阵。同样的,我们也可以得到$BAStar A = |A| #idef$. === 矩阵可逆定理 数域#bk 上的#highlight()[n阶方阵(一定是方阵)],可逆的充要条件是$|A| != 0$.并且如果$A$可逆,其逆矩阵为$inva = 1/(|A|)BAStar$. 证明: 1. 必要性:$A inva = I = > |A inva| = |A| |inva| = 1 => |A| != 0$ 2. 充分性:$|A| != 0$, 由@cc2 可以知道,$frac(1, |A|)BAStar A = 1/(|A|) |A| I = I; A(1/(|A|)BAStar) = 1/(|A|) A BAStar = I => inva = 1/(|A|) BAStar$ 根据矩阵可逆定理,可以得到一些推论,#BA 可逆时,可以得出$|A| != 0 <=> rank(A) = n <=>$ #BA 的行列向量线性无关 $<=>$ #BA 的行列向量是向量空间$K^n$的一个基 $<=>$ #BA 的行列空间都等价于$K^n$ === 命题 设 $A, B$ 是数域K上的n阶矩阵,并且满足$ A B = #idef$, 那么 #A #B 都是可逆矩阵,并且$#inva = B$, $B^(-1) = A$. 证明: 1. 因为$A B = #idef => |A| != 0, |B| != 0$, 从而$A, B$都是可逆矩阵 2. $A B = #idef$, 两边同时*左乘* $inva$, 得到$inva A B = inva => B = inva$, 同理可证另外一个 // TODO 编写函数写逆矩阵 === 性质 1. 单位矩阵可逆,并且$I^(-1) = I$ === 性质 2. 如果$A$ 可逆,那么$inva$ 也可逆,并且$(inva)^(-1) = A$ #let invb = $B^(-1)$ === 性质 3. 如果 $A, B$ 可逆,那么$A B$也可逆,并且$(A B)^(-1) = B^(-1) A^(-1)$ 证明: 1. $|A B| =|A||B|, because |A| != 0, |B| != 0, => |A B| != 0 =>$ $A B$可逆 2. $(A B)(invb inva) = A #idef inva = A inva = #idef; (invb inva)(A B)= invb B = #idef$ 利用数学归纳法, 如果$A_1, A_2, ..., A_s$ 可逆, 那么$A_1A_2...A_s$ 也可逆,并且其逆是$A_s^(-1)A_(s-1)^(-1)...A_1^(-1)$ #let ta = $A^(')$ === 性质4, 如果$A$可逆,则$ta$ 也可逆,并且$ta^(-1) = (inva)^(')$ 证明: $ta (inva)^(') = (inva A)^(') = idef^(') = idef$ (根据矩阵乘积的转置关系可得), 即转置的逆等于逆的转置 === 性质5, 矩阵$A$ 可逆的充要条件是其可以表示成一系列初等矩阵的乘积 1. 必要性: 如果$A$可逆,则$A$ 一定是满秩矩阵,则其可以经过一系列初等行变换化为简化阶梯型, 而满秩矩阵的简化阶梯型就是$idef$, 从而$A$ 可以初等行变换为$idef$。 根据前述定理,矩阵初等行变换,等于左乘以一系列初等矩阵,即:$(P_i ... P_(2) P_1)A = idef => A = (P_i ... P_2 P_1)^(-1)$. === 性质6. 矩阵 #A 左乘或者右乘一个可逆矩阵,#A 的秩不变 根据性质5,设#B 可逆,则#B 可以表示为一系列初等矩阵的乘积,而#A 和一些列初等矩阵相乘等价于做初等行变换或者列变换,其秩不会发生变化。 == #highlight()[总结:秩/行列式/可逆的关系] 1. 秩定义为矩阵的列或者行向量组的极大无关组的向量个数(或者向量组的秩),矩阵的秩不仅是定义在方阵上的 2. 行列式最重要的不是其定义(如何计算),但是要注意行列式仅定义在`方阵上`,而是其是否为0,一个矩阵我们可以化成阶梯型或者简化阶梯型$J$,其行列式的`绝对值`等于$J$ 对角线的元素的乘积 3. 矩阵的秩对应于阶梯型中的主元的个数, 从而,对于一个方阵而言, 如果满秩$<=>$$J$对角线元素全不为0$<=>$行列式不为0 4. 可逆矩阵一定是方阵,因此其具备行列式,而前面的可逆矩阵定理证明了,可逆矩阵的行列式必不为0,从而其也必是满秩矩阵 = 矩阵分块 一些大的矩阵,我们可以看成若干个小的矩阵的组合,比如:$A=mat(1,0,0, 2,5;0,1,0,3, -2; 0, 0, 1, -1, 6;0,0,0,4,0;0,0,0,0,4)= mat(I_3,B;#b0, 4I_2)<- 按 行 列 划 分$, 其中$B = mat(2,5;3,-2;-1,6)$。组成A的小矩阵称为矩阵的分块,A称为分块矩阵。 分块矩阵可以利用大矩阵中的局部的性质,使得运算变得简单(主要是矩阵乘法) 对于$A = mat(a_11, a_12, a_13; a_21, a_22, a_23; a_31, a_32, a_33;), B = mat(b_11, b_12, b_13, b_14;b_21, b_22, b_23, b_24;b_31, b_32, b_33, b_34;b_41, b_42, b_43, b_44;)$, 可以按照$A_11 = mat(a_11, a_12), A_12 = mat(a_13); A_21=mat(a_21, a_22; a_31, a_32;), A_22 = mat(a_23; a_33). B_11=mat(b_11;b_21;) B_12 = mat(b_12;b_22;), B_13 = mat(b_13, b_14;b_23, b_24;),B_21 = mat(b_31), B_22 = (b_32), B_23 = mat(b_33, b_34);$ 从而$A=mat(A_11, A_12; A_21, A_22), B = mat(B_11, B_12, B_13; B_21, B_22, B_23)$ 按照矩阵乘法的定义,我们使得这些分块矩阵相乘:$(A B)_(i j) = sum_k A_(i k) B_(k j)$ 注意这里有一个很重要的限制是,这些分块的小矩阵可以相乘。 == 矩阵划分 我们把一个矩阵$A_(e times f)$划分成$(M+1) times (N+1)$个小矩阵,则该矩阵按行要选定$(M)$个行 分割,列需要选定$(N)$个列分割,设选定的行分别是$(s_1, s_2, ...,s_M)$, 选定的列分别是$(j_1, j_2, ..., j_N)$,这些行列将原矩阵分解为$(M + 1) times (N+1)$个小矩阵,$A_11 = (s_1 - 0) times (j_1 - 0), A_12 = (s_1 - s_0 ) times (j_2 - j_1), A_21 = (s_2 - s_1) => A_(k p) = (s_k - s_(k-1)) times (j_p - j_(p-1)), 1<=k<=M+1, 1<= p <= N+1, s_0 = j_0 = 0, s_(M+1) = e, j_(N+1) = f$ 对于矩阵$B_(f times g)$, 也进行类似划分,将这些小的矩阵分块当做一个单元,那么#B 的划分应当满足矩阵乘法的要求,即B的分块至少有(N+1)行,那么还有一个问题是,即便是选定$N$个行去分割B,这些行能否和A矩阵的分块相乘呢?我们注意到$A_11$ 是一个$(s_1 times (j_1))$的矩阵,因此$B_(1, k)$ 必须是$(j_1 times ?)$的矩阵,同理,$A_12 = [(s_1) times (j_2 - j_1)]$, 这要求$B(2, k) = [(j_2 - j_1) times ?]$。由于左矩阵的第$k$列的单元 总是和 右矩阵的第$k$行的单元相乘,从而就可以得出,$A_(?, k)$的列数总是要和$B_(k, ?)$的行数相等,前者由$(j_1, j_2, ..., j_N)$决定,设B的分割行为$(r_1, r_2, ..., r_N)$(前文可知两者总数必须相等), 并且有$r_1 = j_1, r_i - r_(i - 1) = j_i - j_(i-1) ==>^(数 学 归 纳 法) r_i = j_i$ 即#B 也必须按照#A 的列划分方式分割行 矩阵分块以后,我们按照矩阵乘法来看待以这些小矩阵作为单元的乘积#C, #C 的每个单元是#A #B 的分块的乘积,将#C 的单元视作矩阵展开时,他和#A #B 直接相乘的结果是否相等呢?答案是肯定的,不过证明他时,描述的方法不太一样。前面的内容主要从如何对矩阵分块出发讨论。 == 定理 设#A #B, A 的行分解成 $u$ 组, 第#i 组有$s_i$行,A的列分解成$t$组,第$j$组有$n_j$列,#B 的行划分和 #A 的列划分一直, #B 的列 划分成$v$ 组, 第$l$ 组有$m_l$列。 则分块矩阵A和B的乘积,与 A B直接的乘积是相等的 证: 略 以后有时间的时候证明 #let bvecs=$(bold(b)_1, bold(b_2), ..., bold(b_m))$ #let avecs=$(ba_1, ba_2, ..., ba_s)$ === 命题1. 设$A_(#sn), B_(#nm)$, 并且设B的列向量表示为$#bvecs$, 则$A B = (A#bb _1, A#bb _2, ..., A#bb _m)$ 证明: B以列向量表示时,相当于将所有行划分为一组,那么按照定理,#A 的列划分也要变成所有列划分成一组,此时#A 可以表示为行向量形式$#avecs$; #B 每一列都单独划分出一个矩阵,即#B 的行的划分法为$v_i = 1$. A B 的乘积就等价于A 和 B的各分块矩阵的乘积,按照分块矩阵乘法定义,$A B = #avecs ^' #bvecs = mat(ba_1 bb_1, ba_1 bb_2, ..., ba_1, bb_m; ba_2 bb_1, ba_2 bb_2, ..., ba_2, bb_m;...; ba_s bb_1, ba_s bb_2, ..., ba_s, bb_m;)$, 乘积矩阵的列向量$bold(p r o _j) = #avecs ^' bb_j = A b_j, 1 <= j <= m => A B = (A#bb _1, A#bb _2, ..., A#bb _m)$ === 推论1. 设$A_(#sn) != b0, B_(#nm) = bvecs$,则, 若$A B = b0 => bvecs$ 均是$A bx = b0$的解 (结论显然) #let bc = $bold(c)$ #let cvecs = $(bc_1, bc_2, ..., bc_m)$ === 推论2. 设$A_(#sn) != b0, B_(#nm) = bvecs, C=cvecs, A B = C =>$, $bb_i in bvecs$ 是 $A bx = bc_i $的一个解 === 分块矩阵的初等行变换、列变换 略 = 正交矩阵和欧式空间 #let ta = $A^(')$ 在直角坐标系中,我们可以选定两个不共线向量$ba = (x_1, y_1), bb = (x_2, y_2)$,因他们不能互相表示,因此它们是平面坐标系的一个基,将他们以列向量形式组成一个矩阵$A = mat(x_1, x_2; y_1, y_2)$, 因为#ba #bb 不共线,因此该矩阵是一个满秩矩阵,从而其可逆。 当#ba #bb 互相正交且为单位向量时,则有$x_i^2 + y_i^2 = 1, i = 1, 2; ba bb = 0 = x_1x_2 + y_1y_2 = 0 => inva A = mat(x_1, y_1; x_2, y_2) mat(x_1, x_2; y_1, y_2) = mat(1, 0;0, 1) = #idef$, #A 的列向量互相垂直,且其模为1,很自然的,我们就把这样的矩阵称为正交矩阵. == 定义1 正交矩阵 如果n 阶矩阵#A 满足: $ ta A = #idef $ 那么称#A 是正交矩阵。 我们从定义可以得出, 若#A 是正交矩阵: 1. $ta A = idef$ 2. #A 可逆,且$inva = ta$ 3. $A ta = idef$ == 正交矩阵的性质 === 性质1. $idef$ 都是正交矩阵 === 性质2. 如果#A #B 是正交矩阵,则$A B$ 也是正交矩阵 证明: $(A B)^(') A B = B^(') A^(')A B$ 因为 #A #B 是正交矩阵,所以 $B^(') A^(')A B = B^(')idef B = idef => A B$也是正交矩阵 === 性质3. 如果#A 是正交矩阵,则#inva 也是正交矩阵 === 性质4 如果A是正交矩阵,则$abs(det A) = 1$ 证明: $ det(ta A)= |ta||A| = (det(A))^2 = det(idef) = 1 => abs(det(A)) = 1 $ === 命题1. #let avecs = $(ba_1, ba_2, ..., ba_n)$; #let bvecs = $(bb_1, bb_2, ..., bb_n)$ 设#A 为n阶矩阵,其行向量为$avecs^'$, 列向量为$bvecs$, 那么 1. #A 为正交矩阵,当且仅当#A 的行向量组满足:$cases(ba_i ba_j^(') = 1 \, i=j, ba_i ba_j^' = 0 \, i!=j)$. 2. #A 为正交矩阵,当且仅当#A 的列向量组满足:$cases(bb_i bb_j^(') = 1 \, i=j, bb_i bb_j^' = 0 \, i!=j)$. 证明: $ A ta = vec(ba_1, ba_2, ..., ba_n) bvecs = idef => C_(i j)= sum_k a_(i k) a_(k j) => cases(sum_k a_(i k) a_(k i) = 1, 0 \, e l s e) => \ cases(ba_i ba_i^' = 1, 0 \, e l s e) $ 从而 1 得证。 2的证明过程类似。 == 定义2. 内积 #let balp = $bold(alpha)$ #let bbet = $bold(beta)$ 我们把定义在$R^n$上的两个向量$balp = avecs$, $bbet = bvecs$, 其内积(标准内积)定义为: $ (balp, bbet) =^(d e f) sum(a_i b_i) $ 这是一个关于向量#balp #bbet 的实函数。该式也可以写作:$(balp, bbet) = balp bbet^'$ === 性质1. 对称性 $(balp, bbet) = (bbet, balp)$ 证明: 按照定义展开:$(balp, bbet) = sum_i a_i b_i = sum_i b_i a_i = (bbet, balp)$ === 性质2. 线性性质1 $(ba + balp, bbet) = (ba, bbet)+ (balp, bbet)$ 证明: 按照定义展开:设$ba = (k_1,k_2,...,k_n)$, $(ba + balp, bbet) = sum_i (a_i + k_i)b_i = sum_i a_i b_i + sum_i k_i b_i = (ba, bbet)+ (balp, bbet)$ === 性质3. 线性性质2 $(k balp, bbet) = k(balp, bbet)$ 按定义展开可直接得出 === 性质4. 正定性 $(balp, balp) >= 0$,且等号成立时当且仅当$balp = b0$ 按定义,$(balp, balp) = sum_i a_i^2 >= 0$, 显然,当$a_i = 0$时, 等号成立 综合性质2、性质3,向量内积是满足线性的。 #let brn = $R^n$ == 定义3. 欧几里得空间 n 维向量空间$R^n$ 有了标准内积后,我就把它称作一个#highlight()[欧几里得空间]。 欧式空间中,我们把向量#ba 的长度规定为:$|ba| =^(d e f) sqrt((ba, ba))$,长度为1的向量称为单位向量。显然单位向量满足$(a, a) = 1$. 同时对于$k ba, |k ba| = abs(k) abs(ba)$, 对于任意$ba != b0, 1/abs(ba) ba$一定是单位向量, 我们可以利用这个公式将任意非0向量单位化. 在欧式空间中,如果$(ba, bb) = 0$, 那么称$ba,bb$是正交的,记作$ba perp bb$. 显然$b0$和任何向量都正交 在欧式空间中,向量组$avecs, ba_i != b0$ 满足两两互相正交,即$(ba_i, ba_j) = 0, i != j$. 我们把它称为正交向量组。如果只有一个非0向量构成的向量组也是正交向量组。 如果正交向量组中的每个向量都是单位向量,那么我们把它称为正交单位向量组。 === 命题 欧式空间中,正交向量组一定线性无关 设向量组$avecs$ 是正交向量组, 再设$k_1 ba_1 + k_2 ba_2 + ... + k_n ba_n = b0$ 那么$(k_1 ba_1 + k_2 ba_2 + ... + k_n ba_n, ba_i) = (b0, ba_i) = 0, ba_i in avecs$,而$(k_1 ba_1 + k_2 ba_2 + ... + k_n ba_n, ba_i) = sum_j k_j ba_j ba_i^' + k_i ba_i ba_i^' = 0, j != i => k_i (ba_i, ba_i) = 0, because ba_i != b0 => k_i = 0$, 因此正交向量组线性无关 由该命题可知,$R^n$ 中的 n个向量组成的正交向量组一定是$R^n$的一个基, 我们称为#highlight()[正交基], 如果这个向量组是正交单位向量组,则称为#highlight()[标准正交基] === 命题 $R^n$ 上,#A 是正交矩阵的充要条件是#A 的行或列向量组是$R^n$的一组标准正交基 证明: 由正交矩阵定义可知,#A 是正交矩阵时,$ba_i ba_i^' = 1; ba_i ba_j^' = 0, i!=j$, 即各行向量的长度为1, 并且#A 的行向量组是正交向量组(两两正交), 从而它是$R^n$的一组标准正交基 列向量组证明类似 === 定理 正交向量组构造定理 设$avecs$ 是欧式空间#brn 中的一个线性无关向量组,令$ bb_1 = ba_1 \ bb_2 = ba_2 - ((ba_2, bb_1))/((bb_1, bb_1)) bb_1 \ ... \ bb_n = ba_n - sum_(k=1)^(n-1)((ba_n, bb_k))/((bb_k, bb_k))bb_k $ 则$bvecs$ 是正交向量组,且它和$avecs$等价 证明: 使用数学归纳法证明,容易验证,$n=2$时成立,现在假设,$n=N$时成立,我们证明$n=N+1$时也成立 $ (bb_(N+1), bb_i) &= (ba_(N+1) - sum_k ((ba_(N+1), bb_k))/((bb_k, bb_k)) bb_k, bb_i) , 1<=k <= N, \ &= (ba_(N+1), bb_i) - (sum_k ((ba_(N+1), bb_k))/((bb_k, bb_k)) bb_k, bb_i) = (ba_(N+1), bb_i) - ((ba_(N+1), bb_i))/((bb_i, bb_i)) (bb_i, bb_i) = 0 $ 定理得证。至于两者等价是因为两个向量组的秩相等,故而等价。 该定理给出了一个有$brn$ 中的一个线性无关组$avecs$构造出一个正交向量组的方法,该方法也称为#highlight()[施密特正交化],如果我们把该正交向量组进一步单位化,则得到的就是一个标准正交基
https://github.com/hotwords123/typst-assignment-template
https://raw.githubusercontent.com/hotwords123/typst-assignment-template/main/template.typ
typst
// Asssignment mode: problems #let problem-counter = counter("problem") #let problem-begin() = { problem-counter.step() [== Problem #problem-counter.display() <problem-begin>] } #let problem-body = block.with( fill: rgb(245, 255, 245), width: 100%, inset: 8pt, radius: 4pt, stroke: rgb(128, 199, 128), ) #let problem-end(meta: "") = [#metadata(meta) <problem-end>] #let problem(meta: "", body) = { problem-begin() problem-body(body) problem-end(meta: meta) } // Report mode: sections #let section-begin(title, ..args) = [#heading(title, ..args) <section-begin>] #let section-end(meta: "") = [#metadata(meta) <section-end>] #let section(meta: "", title, body, ..args) = { section-begin(title, ..args) body section-end(meta: meta) } #let assignment-class( title: "Title", author: "Author", course-name: "Course Name", mode: "assignment", header: auto, footer: auto, body, ) = { let wrap-default = (value, default) => { if value == auto { default } else { value } } set document(title: title, author: author) set page( paper: "a4", header: wrap-default(header, context { let (page-number,) = counter(page).get() if page-number > 1 { align(right, text(size: 10pt)[ *#course-name: #title* #if mode == "assignment" { // Display current problem let marker = query(selector(<problem-end>).after(here())) if marker.len() > 0 { let marker-loc = marker.first().location() let (problem-number,) = problem-counter.at(marker-loc) [| *Problem #problem-number*] } } else if mode == "report" { // Display current section let marker = query(selector(<section-end>).after(here())) if marker.len() > 0 { let marker-loc = marker.first().location() let section-elems = query(selector(<section-begin>).before(marker-loc)) if section-elems.len() > 0 { let section-title = section-elems.last().body [| *#section-title*] } } } ]) } }), footer: wrap-default(footer, context { let (page-number,) = counter(page).get() let (total-pages,) = counter(page).final() align(center, text(size: 10pt, if text.lang == "zh" [ 第 #page-number 页,共 #total-pages 页 ] else [ Page #page-number of #total-pages ] )) }), ) // Font settings let en-font = "New Computer Modern" set text(size: 11pt, font: (en-font, "FZShuSong-Z01S")) show strong: set text(font: (en-font, "FZHei-B01S")) show emph: set text(font: (en-font, "FZKai-Z03S")) show heading: set text(font: (en-font, "FZXiaoBiaoSong-B05S")) // Headings set heading(numbering: (..nums) => { let (first, ..more) = nums.pos() if more.len() == 0 { return numbering("一 ", first) } else { return numbering("1.", ..more) } }) if mode == "report" context { let indent = if text.lang == "zh" { 2em } else { 1em } set par(justify: true, first-line-indent: indent) // Workaround for first paragraph indent in CJK context show heading: it => { it if text.lang == "zh" { v(10pt, weak: true) box() v(5pt, weak: true) } } align(center, text(18pt)[#title]) body } }
https://github.com/MatejKafka/ctu-thesis-typst
https://raw.githubusercontent.com/MatejKafka/ctu-thesis-typst/main/template/template.typ
typst
// poznamky z tisku: // - zeptat se na studijnim, jestli by nemohli zadani tisknout se spravne zarovnanou zadni stranou (obe strany jsou prirazene doprava, coz pekne vychazi pro prvni stranu, ale ne pro druhou) // - tenke h1 nadpisy pusobi v tisku zvlastne, obzvlast v kontrastu s h2, a margin pod h1 nadpisem taky neni idealni; asi mel Kuba pravdu, ze Technika by na h1 dopadla lip // - marginy pro non-numbered nadpisy jsou moc male, pusobi to zmackle // - #line() je v tisku dost vyrazny, dal by se zesvetlit nebo ztencit, naopak v PDF je v nekterych viewerech spatne videt // - odrazeni o 8mm u title page vypada dobre // - 80g papir u Haronu je hodne pruhledny, 100g je dobry #import "./front.typ": * #let template(meta: (), print: false, ..intro-args, body) = { set document( author: meta.author.name, title: meta.title, date: meta.submission-date ) set text(font: "Linux Libertine", size: 11pt, lang: "en", fallback: false) // the idea behind the inner margin is that if you lay the book out flat, there should be the same amount of space in the middle as on the outside // however, with binding from Haron.cz, the sides do not lay flat; from discussion with the guy at Haron, 8mm is consumed by the binding, and quite a lot of extra space is lost, since the page does not lay flat due to the binding; when I measured it in my printed thesis, I think the inner margin should be roughly 34mm and the outer margin 36mm at the beginning and end (where one side lays flat), and a bit more than that in the middle, but the variance based on how much you press down on the page is quite high, so we can make our lives easier and go with a symmetric 35mm+35mm margin let a4-width = 210mm // chosen to fit roughly 85 chars per line; ideally, it should be 45-75 chars for maximum readability, but imo this looks a bit better; feel free to make it smaller let text-width = 140mm let margin = (a4-width - text-width) / 2 set page( paper: "a4", // same top/bottom margin as inner/outer; looks good in the PDF version margin: margin, ) // render title page before configuring the rest, which we don't use title-page(print, ..meta) set par(justify: true) set line(length: 100%, stroke: 1pt + luma(200)) set figure(placement: auto) show figure.caption: set text(0.9em) show figure.caption: box.with(width: 92%) show figure.caption: par.with(justify: false) // for printing, render code in a monochrome theme set raw(theme: "./res/bw-theme.tmTheme") if print // render code blocks with a grey background and external padding show raw.where(block: true): it => { set par(justify: false) set align(left) v(8pt) block( width: 100%, fill: luma(248), spacing: 0pt, outset: 8pt, radius: 4pt, )[#it] v(8pt) } import "@preview/outrageous:0.1.0" set outline(indent: true) show outline.entry: outrageous.show-entry.with( font: (none, none), // very hacky way to format appendices differently // there's gotta be a better way, but I don't see it body-transform: (lvl, body) => { if "children" in body.fields() { let (num, ..text) = body.children if regex("^[A-Z]$") in num.text { return "Appendix " + num + ": " + text.join() } } body } ) set heading(numbering: "1.1") show heading.where(level: 1): it => { // TODO: it is better to have a weak page break here, but currently, // Typst seems to have a bug: https://github.com/typst/typst/issues/2841 pagebreak(weak: false) show: block let use-supplement = it.outlined and it.numbering != none if (use-supplement) { text(size: 13pt, fill: rgb(120, 120, 120))[ #it.supplement #counter(heading).display(it.numbering) ] linebreak() v(-16pt) } text(size: 22pt, weight: "medium")[ #it.body ] if (use-supplement) { v(22pt) } else { v(5.5pt) } } show heading.where(level: 2): it => { block(it, below: 11pt) } // TODO: probably find a style that has footnotes, but also a usable // consistent indexing //set cite(style: "chicago-notes") set bibliography(style: "ieee", title: none) show bibliography: it => { heading("Bibliography") set text(size: 9pt) set par(justify: false) columns(2, it) } introduction(print, meta.submission-date, ..intro-args) // start numbering from the first page of actual text set page(numbering: "1") counter(heading).update(0) counter(page).update(1) body } // call this function after bibliography using an `everything show` rule: // #show: start-appendix #let start-appendix(body) = { set heading(supplement: "Appendix", numbering: "A.1") counter(heading).update(0) body } #let todo(msg) = { counter("todo").step() [#text(fill: red, weight: "bold")[TODO: #msg]] } #let note(msg) = { counter("note").step() [#block(fill: yellow, width: 100%, inset: 3pt, radius: 3pt)[NOTE: #msg]] }
https://github.com/saveriogzz/curriculum-vitae
https://raw.githubusercontent.com/saveriogzz/curriculum-vitae/main/modules_it/professional.typ
typst
Apache License 2.0
#import "../brilliant-CV/template.typ": * #cvSection("Esperienza Professionale") #cvEntry( title: [Data Engineer], society: [Spotify], logo: "../src/logos/spotify_square.png", date: [Lug. 2022 - Presente], location: [Remoto all'interno dell'EMEA], description: list( [Ciao], [Ciao], ), tags: ("Scio", "Apache Beam", "Scala2", "BigQuery", "Backstage") ) #cvEntry( title: [Data Engineer], society: [Università Tecnica di Delft], logo: "../src/logos/TU_logo/TUDelft_logo_cmyk.png", date: [Sett. 2020 - Giu. 2022], location: [Delft, Paesi Bassi], description: list( [Responsabile per la progettazione di sistemi di archiviazione e flusso distribuiti, distribuzione di applicazioni scalabili per ETL/ELT], [Forte focus sul formato NetCDF, operatori nc, dask.], ), tags: ("Apache Airflow", "MinIO") ) #cvEntry( title: [Analista dei Dati], society: [Nike], logo: "../src/logos/nike.png", date: [Ago. 2019 - Ago. 2020], location: [Hilversum, Paesi Bassi], description: list( [Analisi delle performance per il mercato europeo.], [Sfruttamento di soluzioni di infrastruttura cloud come AWS S3, Redshift, CloudFormation.], ), tags: ("Snowflake", "SQL") )
https://github.com/fky2015/resume-ng-typst
https://raw.githubusercontent.com/fky2015/resume-ng-typst/main/README-typst.md
markdown
MIT License
# Resume-ng (Typst Version) A typst resume designed for optimal information density and aesthetic appeal. A LaTeX version # QuickStart `main.typ` will be a good start. A minimal exmaple would be: ```typst #show: project.with( title: "Resume-ng", author: (name: "FengKaiyu"), contacts: ( "+86 188-888-8888", link("https://github.com", "github.com/fky2015"), // More items... ) ) #resume-section("Educations") #resume-education( university: "BIT", degree: "Your degree", school: "Your Major and school", start: "2021-09", end: "2024-06" )[ *GPA: 3.62/4.0*. My main research interest is in #strong("Byzantine Consensus Algorithm"), and I have some research and engineering experience in the field of distributed systems. ] #resume-section[Work Experience] #resume-work( company: "A company", duty: "Your duty", start: "2020.10", end: "2021.03", )[ - *Independently responsible for the design, development, testing and deployment of XXX business backend.* Implemented station letter template rendering service through FaaS, Kafka and other platforms. Provided SDK code to upstream, added or upgraded various offline and online logic. - *Participate in XXX's requirement analysis, system technical solution design; complete requirement development, grey scale testing, go-live and monitoring.* ] #resume-section[Projects] #resume-project( title: "Project name", duty: "Your duty", start: "2021.11", end: "2022.07", )[ - Implemented a memory pool manager based on an extensible hash table and LRU-K, and developed a concurrent B+ tree supporting optimistic locking for read and write operations. - Utilized the volcano model to implement executors for queries, updates, joins, and aggregations, and performed query rewriting and pushing down optimizations. - Implemented concurrency control using 2PL (two-phase locking), supporting deadlock handling, multiple isolation levels, table locks, and row locks. ] ```
https://github.com/wiuri/xjtu_bristol
https://raw.githubusercontent.com/wiuri/xjtu_bristol/main/README.md
markdown
<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 <a name="readme-top"></a> <!-- *** Thanks for checking out the Best-README-Template. If you have a suggestion *** that would make this better, please fork the repo and create a pull request *** or simply open an issue with the tag "enhancement". *** Don't forget to give the project a star! *** Thanks again! Now go create something AMAZING! :D --> <!-- PROJECT SHIELDS --> <!-- *** I'm using markdown "reference style" links for readability. *** Reference links are enclosed in brackets [ ] instead of parentheses ( ). *** See the bottom of this document for the declaration of the reference variables *** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use. *** https://www.markdownguide.org/basic-syntax/#reference-style-links --> <!-- [![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url] [![LinkedIn][linkedin-shield]][linkedin-url] <!-- PROJECT LOGO --> <!-- <br /> <div align="center"> <a href="https://github.com/wiuri/xjtu_bristol"> <img src="images/logo.png" alt="Logo" width="80" height="80"> </a> <h3 align="center">project_title</h3> <p align="center"> project_description <br /> <a href="https://github.com/wiuri/xjtu_bristol"><strong>Explore the docs »</strong></a> <br /> <br /> <a href="https://github.com/wiuri/xjtu_bristol">View Demo</a> · <a href="https://github.com/wiuri/xjtu_bristol/issues">Report Bug</a> · <a href="https://github.com/wiuri/xjtu_bristol/issues">Request Feature</a> </p> </div> --> <!-- TABLE OF CONTENTS --> <!-- <details> <summary>Table of Contents</summary> <ol> <li> <a href="#about-the-project">About The Project</a> <ul> <li><a href="#built-with">Built With</a></li> </ul> </li> <li> <a href="#getting-started">Getting Started</a> <ul> <li><a href="#prerequisites">Prerequisites</a></li> <li><a href="#installation">Installation</a></li> </ul> </li> <li><a href="#usage">Usage</a></li> <li><a href="#roadmap">Roadmap</a></li> <li><a href="#contributing">Contributing</a></li> <li><a href="#license">License</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#acknowledgments">Acknowledgments</a></li> </ol> </details> --> <!-- ABOUT THE PROJECT --> ## About The Project --- A britol template of typist slides modified for XJTU. ```xjtu_bristol.typ``` is the main file of the template. ```slides.typ``` is the original file of typist slides. ```xjtu_bristol.typ``` imports ```slides.typ``` and modifies it. ```xjtu_bristol.pdf``` is the output pdf file and acts as a test. There are 2 examples in ```./examples/```. Each of them has a ```*.typ``` file and a ```*.pdf``` file. The ```*.typ``` file is the source file and the ```*.pdf``` file is the output file. The two of them serve as examples of two different uses. <!-- [![Product Name Screen Shot][product-screenshot]](https://example.com) --> <!-- Here's a blank template to get started: To avoid retyping too much info. Do a search and replace with your text editor for the following: `wiuri`, `xjtu_bristol`, `twitter_handle`, `linkedin_username`, `email_client`, `email`, `project_title`, `project_description` --> <p align="right">(<a href="#readme-top">back to top</a>)</p> ## Built With --- * Visual Studio Code * Typst LSP <!-- * [![Next][Next.js]][Next-url] * [![React][React.js]][React-url] * [![Vue][Vue.js]][Vue-url] * [![Angular][Angular.io]][Angular-url] * [![Svelte][Svelte.dev]][Svelte-url] * [![Laravel][Laravel.com]][Laravel-url] * [![Bootstrap][Bootstrap.com]][Bootstrap-url] * [![JQuery][JQuery.com]][JQuery-url] --> <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- <!-- GETTING STARTED --> <!-- ## Getting Started This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps. --> <!-- ### Prerequisites --> <!-- This is an example of how to list things you need to use the software and how to install them. * npm ```sh npm install npm@latest -g ``` --> <!-- ### Installation --> <!-- 1. Get a free API Key at [https://example.com](https://example.com) 2. Clone the repo ```sh git clone https://github.com/wiuri/xjtu_bristol.git ``` 3. Install NPM packages ```sh npm install ``` 4. Enter your API in `config.js` ```js const API_KEY = 'ENTER YOUR API'; ``` <p align="right">(<a href="#readme-top">back to top</a>)</p> --> <!-- USAGE EXAMPLES --> ## Usage --- **Method 1: In your own typ file:** ```typ #import "xjtu_bristol.typ": * ``` Take care of the relative path. And there is no need to import the `slides.typ` file. For example, ```example/demo/demo.typ``` **Method 2: Or simply modify the `xjtu_bristol.typ` file.** For example, ```/example/Literature_Research_of_Financial_Engineering/deck_Literature_Research_of_Financial_Engineering.typ``` <!-- Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources. _For more examples, please refer to the [Documentation](https://example.com)_ --> <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- ROADMAP --> <!-- ## Roadmap - [ ] Feature 1 - [ ] Feature 2 - [ ] Feature 3 - [ ] Nested Feature See the [open issues](https://github.com/wiuri/xjtu_bristol/issues) for a full list of proposed features (and known issues). <p align="right">(<a href="#readme-top">back to top</a>)</p> --> <!-- CONTRIBUTING --> ## Contributing --- Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again! 1. Fork the Project 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the Branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- LICENSE --> ## License --- Distributed under the MIT License. <!-- See `LICENSE.txt` for more information. --> <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- CONTACT --> ## Contact --- <!-- Your Name - [@twitter_handle](https://twitter.com/twitter_handle) - <EMAIL> --> Wiuri - <EMAIL> Project Link: [https://github.com/wiuri/xjtu_bristol](https://github.com/wiuri/xjtu_bristol) <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- ACKNOWLEDGMENTS --> ## Acknowledgments --- Much appreciation to Typst and Typst LSP ~ <!-- * []() * []() * []() --> <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- MARKDOWN LINKS & IMAGES --> <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> [contributors-shield]: https://img.shields.io/github/contributors/wiuri/xjtu_bristol.svg?style=for-the-badge [contributors-url]: https://github.com/wiuri/xjtu_bristol/graphs/contributors [forks-shield]: https://img.shields.io/github/forks/wiuri/xjtu_bristol.svg?style=for-the-badge [forks-url]: https://github.com/wiuri/xjtu_bristol/network/members [stars-shield]: https://img.shields.io/github/stars/wiuri/xjtu_bristol.svg?style=for-the-badge [stars-url]: https://github.com/wiuri/xjtu_bristol/stargazers [issues-shield]: https://img.shields.io/github/issues/wiuri/xjtu_bristol.svg?style=for-the-badge [issues-url]: https://github.com/wiuri/xjtu_bristol/issues [license-shield]: https://img.shields.io/github/license/wiuri/xjtu_bristol.svg?style=for-the-badge [license-url]: https://github.com/wiuri/xjtu_bristol/blob/master/LICENSE.txt <!-- [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555 [linkedin-url]: https://linkedin.com/in/linkedin_username --> [product-screenshot]: images/screenshot.png [Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white [Next-url]: https://nextjs.org/ [React.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB [React-url]: https://reactjs.org/ [Vue.js]: https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge&logo=vuedotjs&logoColor=4FC08D [Vue-url]: https://vuejs.org/ [Angular.io]: https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white [Angular-url]: https://angular.io/ [Svelte.dev]: https://img.shields.io/badge/Svelte-4A4A55?style=for-the-badge&logo=svelte&logoColor=FF3E00 [Svelte-url]: https://svelte.dev/ [Laravel.com]: https://img.shields.io/badge/Laravel-FF2D20?style=for-the-badge&logo=laravel&logoColor=white [Laravel-url]: https://laravel.com [Bootstrap.com]: https://img.shields.io/badge/Bootstrap-563D7C?style=for-the-badge&logo=bootstrap&logoColor=white [Bootstrap-url]: https://getbootstrap.com [JQuery.com]: https://img.shields.io/badge/jQuery-0769AD?style=for-the-badge&logo=jquery&logoColor=white [JQuery-url]: https://jquery.com
https://github.com/lucifer1004/leetcode.typ
https://raw.githubusercontent.com/lucifer1004/leetcode.typ/main/problems/p0011.typ
typst
#import "../helpers.typ": * #import "../solutions/s0011.typ": * = Container With Most Water You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the i#super[th] line are `(i, 0)` and `(i, height[i])`. Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store. *Notice* that you may not slant the container. #let container-with-most-water(height) = { // Solve the problem here } #testcases( container-with-most-water, container-with-most-water-ref, ( (height: (1, 8, 6, 2, 5, 4, 8, 3, 7)), (height: (1, 1)) ) )
https://github.com/Dherse/typst-glossary
https://raw.githubusercontent.com/Dherse/typst-glossary/main/example/example.typ
typst
#import "../glossary.typ": * #set page(numbering: "I", paper: "a6") #show: glossary.with(( (key: "kuleuven", short: "KU Leuven", long: "Katholieke Universiteit Leuven"), (key: "uclouvain", short: "UCLouvain", long: "Université catholique de Louvain"), (key: "ughent", short: "UGent", long: "Universiteit Gent"), (key: "vub", short: "VUB", long: "Vrije Universiteit Brussel"), (key: "ulb", short: "ULB", long: "Université Libre de Bruxelles"), (key: "umons", short: "UMons", long: "Université de Mons"), (key: "uliege", short: "ULiège", long: "Université de Liège"), (key: "unamur", short: "UNamur", long: "Université de Namur"), )) There are many Belgian universities, like @kuleuven and @ulb. When repeating their names, they won't show as a long version: @kuleuven, @ulb. But we can still force them to be long using the `gloss` function: #gloss("kuleuven", long: true). We can also force them to be short: #gloss("kuleuven", short: true). Finally, we can make them plural using the `suffix` parameter: #gloss("kuleuven", suffix: "s") or using the additional `supplement` onto the `ref`: @kuleuven[s]. #pagebreak() #set page(numbering: "1") Numbering is, of course, correct when referencing the glossary: @kuleuven, @ulb, @ughent, @vub, @ulb, @umons, @uliege, @unamur. They are also sorted based on where the page is in the document and not the textual representation. #pagebreak() At the moment, customization is not built-in to the function and instead follows a modified version of @ughent's template. But you can easily customize it by modifying `glossary.typ`. It is short enough and well documented enough to be easily understood. Additionally, you can load data externally and pass it as a parameter to the `glossary.with` function to load data from an external format.
https://github.com/matchy233/typst-chi-cv-template
https://raw.githubusercontent.com/matchy233/typst-chi-cv-template/main/src/chicv.typ
typst
MIT License
#import "@preview/fontawesome:0.4.0": * #let cventry-padding = ( top: 0pt, bottom: 0pt, left: 10pt, right: 5pt, ) #let to-string(input) = { if type(input) == "string" { input } else if type(input) == "content" { if input.has("text") { input.text } else if input.has("children") { input.children.map(to-string).join("") } else if input.has("body") { to-string(input.body) } else if input == [ ] { "" } else { // fallback, I don't know how to handle this input input } } } #let short-uri(uri, get-path: false) = { let uri = to-string(uri); let cleaned = uri.replace("https://", "") .replace("http://", "") .replace("www.", "") .replace(regex("/$"), ""); if get-path { cleaned.split("/").at(-1).split("?").at(0) } else { cleaned } } #let chiline() = { v(-3pt); line(length: 100%, stroke: gray); v(-10pt) } #let iconlink( uri, text: "", icon: "link", solid: false ) = { let uri = to-string(uri); let icon = to-string(icon); if text != "" { [#box(fa-icon(icon, solid: solid), inset: (right: 2pt))#link(uri)[#text]] } else { link(uri)[#fa-icon(icon, solid: solid)] } } #let githublink( uri, text: "" ) = { iconlink(uri, text: text, icon: "github") } #let dates( from: "", to: "" ) = { let from = to-string(from); let to = to-string(to); if from != "" and to != "" { from + " " + sym.dash.em + " " + to } else if from != "" { from + " " + sym.dash.em + " Now" } else { "" } } #let personal-info( email: "", phone: "", github: "", website: "", linkedin: "", ..misc ) = { let email = if email != "" { iconlink("mailto:" + email, text: email, icon: "envelope", solid: true) } else { "" }; let phone = if phone != "" { iconlink("tel:" + phone, text: phone, icon: "phone") } else { "" }; let github = if github != "" { iconlink(github, text: short-uri(github, get-path: true), icon: "github") } else { "" }; let website = if website != "" { iconlink(website, text: short-uri(website), icon: "globe") } else { "" }; let linkedin = if linkedin != "" { iconlink(linkedin, text: short-uri(linkedin, get-path: true), icon: "linkedin") } else { "" }; let display = (email, phone, github, website, linkedin) .filter(it => it != "") .join(" | "); let kv = misc.named() for item in kv { let key = item.at(0); let value = item.at(1); display += " | " + iconlink(value, text: short-uri(value), icon: key); } let tuples = misc.pos() for t in tuples { if type(t) == "dictionary" { let link = if "link" in t { t.at("link") } else { "" }; let text = if "text" in t { t.at("text") } else { "" }; let icon = if "icon" in t { t.at("icon") } else { "link" }; let solid = if "solid" in t { t.at("solid") } else { false }; display += " | " + iconlink(link, text: text, icon: icon, solid: solid); } } display } #let cventry( tl: lorem(2), tr: "2333/23 - 2333/23", bl: "", br: "", padding: (:), content ) = { // if padding has value for override, use it // for key in ("top", "bottom", "left", "right") { // if not key in padding.keys() { // padding.insert(key, cventry-padding.at(key)); // } // } pad(..padding, block( inset: (left: 0pt), [ #if type(tl) == str { strong(tl) } else { tl } #h(1fr) #tr \ #if bl != "" or br != "" { bl + h(1fr) + br + linebreak() } #content ] )) } #let chicv( margin: (x: 0.9cm, y: 1.3cm), par-padding: cventry-padding, body ) = { set par(justify: true, leading: 0.7em) show heading.where( level: 1 ): set text( size: 22pt, font: ( "Avenir Next LT Pro", // original chi-cv font "Manrope", // a font available in the typst environment and looks similar to Avenir ), weight: "light", ) show heading.where( level: 2 ): it => text( size: 14pt, font: ( "Avenir Next LT Pro", "Manrope", ), weight: "light", block( chiline() + it, ) ) set list(indent: 0pt) set pad( top: if "top" in par-padding { par-padding.at("top") } else { cventry-padding.top }, bottom: if "bottom" in par-padding { par-padding.at("bottom") } else { cventry-padding.bottom }, left: if "left" in par-padding { par-padding.at("left") } else { cventry-padding.left }, right: if "right" in par-padding { par-padding.at("right") } else { cventry-padding.right }, ) show link: it => underline(offset: 2pt, it) set page( margin: margin, footer: context [ #if counter(page).get() != counter(page).final() { align(center, text(fill: gray)[ … continues on the next page …]) } else { // show nothing! } ], footer-descent: 10%, ) body } #let today() = { let month = ( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ).at(datetime.today().month() - 1); let day = datetime.today().day(); let year = datetime.today().year(); [#month #day, #year] }
https://github.com/DashieTM/ost-5semester
https://raw.githubusercontent.com/DashieTM/ost-5semester/main/experiment/weeks/week9.typ
typst
#import "../../utils.typ": * #section("Continuous Distribution") The issue with continuous distributions is that we no longer have specific intervals, aka we can't do regular math anymore -> we might need derivations and integrations.\ In other words, we are now calculating a range, and not specific timestamps. #align( center, [#image("../../Screenshots/2023_11_16_06_03_35.png", width: 80%)], ) #subsection("Rectangle Distribution") - all events have the same probability - events can appear within a certain timeframe -> aka within the rectangle #columns(2, [ #set text(16pt) $E(X) = (a + b)/2$ $#text("Var") (X) = sigma^2 = 1 / 12 * (b - a) ^ 2$ $sigma approx 0.289 𝑏 − 𝑎$ #set text(11pt) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_06_07_19.png", width: 80%)], ) ]) Examples: #align( center, [#image("../../Screenshots/2023_11_16_06_08_36.png", width: 80%)], ) #subsection("Triangle Distribution") #align( center, [#image("../../Screenshots/2023_11_16_06_10_35.png", width: 80%)], ) Examples: #align( center, [#image("../../Screenshots/2023_11_16_06_10_49.png", width: 80%)], ) #subsection("Exponential Distribution") #columns(2, [ #set text(16pt) $E(X) = 1/lambda$ $#text("Median") = ln(2)/Lambda approx 0.69/Lambda$ $#text("Modus") = 0$ $#text("Var") (X) = sigma^2 = 1/Lambda^2$ #set text(11pt) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_06_12_58.png", width: 80%)], ) #align( center, [#image("../../Screenshots/2023_11_16_06_13_08.png", width: 40%)], ) ]) Examples: #align( center, [#image("../../Screenshots/2023_11_16_06_13_26.png", width: 80%)], ) #columns(2, [ #align( center, [#image("../../Screenshots/2023_11_16_06_42_56.png", width: 100%)], ) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_06_43_23.png", width: 100%)], ) ]) #subsection("Weilbul Distribution") #align( center, [#image("../../Screenshots/2023_11_16_06_44_10.png", width: 80%)], ) #align( center, [#image("../../Screenshots/2023_11_16_06_44_38.png", width: 30%)], ) Examples: #columns(2, [ #align( center, [#image("../../Screenshots/2023_11_16_06_45_14.png", width: 100%)], ) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_06_45_26.png", width: 100%)], ) ]) #subsection("Gama Distribution") #set text(16pt) $E(X) = k * theta$ $#text("Var") (X) = sigma^2 = k * theta^2$ #set text(11pt) #align( center, [#image("../../Screenshots/2023_11_16_06_49_10.png", width: 80%)], ) #align( center, [#image("../../Screenshots/2023_11_16_06_54_56.png", width: 80%)], ) #subsection("Normal Distribution") - all variables that occur need to be independend of each other - variable count needs to be "enough" -> statistically significant - no random variable is an extreme value #align( center, [#image("../../Screenshots/2023_11_16_10_53_57.png", width: 80%)], ) #columns(2, [ #align( center, [#image("../../Screenshots/2023_11_16_10_54_21.png", width: 100%)], ) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_10_54_42.png", width: 100%)], ) ]) #columns(2, [ #align( center, [#image("../../Screenshots/2023_11_16_10_55_03.png", width: 100%)], ) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_10_55_13.png", width: 100%)], ) ]) #columns(2, [ #align( center, [#image("../../Screenshots/2023_11_16_10_55_32.png", width: 100%)], ) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_10_55_42.png", width: 100%)], ) ]) #columns(2, [ #align( center, [#image("../../Screenshots/2023_11_16_10_56_01.png", width: 100%)], ) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_10_56_10.png", width: 100%)], ) ]) #columns(2, [ #align( center, [#image("../../Screenshots/2023_11_16_10_56_28.png", width: 100%)], ) #colbreak() #align( center, [#image("../../Screenshots/2023_11_16_10_56_36.png", width: 100%)], ) ]) Example: #align( center, [#image("../../Screenshots/2023_11_16_10_56_48.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_11_16_10_57_01.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_11_16_10_57_12.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_11_16_10_57_27.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_11_16_10_57_36.png", width: 100%)], ) #subsection("Overview") #align( center, [#image("../../Screenshots/2023_11_16_10_57_55.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_11_16_10_58_15.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_11_16_10_58_28.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_11_16_10_58_37.png", width: 100%)], ) #subsection("Random Numbers") - random numbers are not reproducable -> hence bad - instead use pseudo-random numbers with known seeds #align( center, [#image("../../Screenshots/2023_11_16_10_59_53.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_11_16_11_00_04.png", width: 100%)], )
https://github.com/lastleon/tree-sitter-typst
https://raw.githubusercontent.com/lastleon/tree-sitter-typst/main/README.md
markdown
## THIS IS STILL A WIP See branch ```develop``` for current state. # Tree-Sitter Grammar For Typst
https://github.com/jasmerri/tsumo
https://raw.githubusercontent.com/jasmerri/tsumo/main/src/parser.typ
typst
MIT License
#import "./tile.typ": ids, types, variants #let _ignored = (" ") #let _z = ( "1": (which: ids.wind.east, type: types.wind), "2": (which: ids.wind.south, type: types.wind), "3": (which: ids.wind.west, type: types.wind), "4": (which: ids.wind.north, type: types.wind), "5": (which: ids.dragon.white, type: types.dragon), "6": (which: ids.dragon.green, type: types.dragon), "7": (which: ids.dragon.red, type: types.dragon), ) #let _specials = ( "X": ids.other.back, "-": ids.other.nothing, "?": ids.other.question, ) #let _suits = ( "m": types.character, "p": types.dot, "s": types.bamboo, "z": types.other, ) #let _numbers = ( "1": (which: ids.numbered.one, variant: none), "2": (which: ids.numbered.two, variant: none), "3": (which: ids.numbered.three, variant: none), "4": (which: ids.numbered.four, variant: none), "5": (which: ids.numbered.five, variant: none), "6": (which: ids.numbered.six, variant: none), "7": (which: ids.numbered.seven, variant: none), "8": (which: ids.numbered.eight, variant: none), "9": (which: ids.numbered.nine, variant: none), "0": (which: ids.numbered.five, variant: variants.akadora), ) #let _mpsz-generate-spec(state, symbol) = { let which = none let type = none let variant = none if state.char in _specials { which = _specials.at(state.char) type = types.other } else if(symbol != none) { if symbol == "z" { let item = _z.at(state.char, default: none) if item == none { panic("invalid tile in mpsz string: " + state.char + "z") } which = item.which type = item.type } else { let item = _numbers.at(state.char) which = item.which type = _suits.at(symbol) variant = item.variant } } else { panic("tile is missing a suit in mpsz string") } let attributes = (:) if "rotated" in state { attributes.rotated = state.rotated } if "stack" in state { attributes.stack = state.stack } return ( tile: (which: which, type: type, variant: variant), attributes: attributes ) } // Parse an mpsz string and return an array of tile specs. #let mpsz(str) = { let tiles = () let queued = () for c in str { if c in _numbers or c in _specials { // Add a new character. let new = (char: c) queued.push(new) } else if c in _suits { // Fill in the suit of all previous characters. tiles += queued.map((q) => _mpsz-generate-spec(q, c)) queued = () } else if c == "'" or c == "\"" { // Rotate previous tile. // Unlike LaTeX's mahjong package, this doesn't support being after a suit (1m' instead of 1'm). if queued.len() <= 0 { panic("mpsz: trying to rotate nonexistent tile") } let previous = queued.at(-1) previous.rotated = true if c == "\"" { previous.stack = 2 } queued.at(-1) = previous } else if _ignored.contains(c) { // Do nothing. } else { panic("invalid character in mpsz string: " + c) } } // Handle remaining tiles with no suit specified. tiles += queued.map((q) => _mpsz-generate-spec(q, none)) queued = () return tiles } // Turn an array of tiles into an array of tile specs with no attributes. #let only-tiles(arr) = arr.map(v => (tile: v, attributes: (:)))
https://github.com/pryhodkin/cv
https://raw.githubusercontent.com/pryhodkin/cv/master/template.typ
typst
#let _contact(text, icon, url) = { align(top)[ #box(height: 1em, baseline: 20%)[#pad(right: 0.4em)[#image("icons/" + icon)]] #link(url)[#text] ] } #let _contacts(email, linkedin, github) = { align(right + top)[ #set block(below: 0.5em) #if linkedin != "" { _contact(linkedin, "linkedin.svg", "https://linkedin.com/in" + linkedin) } #if email != "" { _contact(email, "envelope-regular.svg", "mailto:" + email) } #if github != "" { _contact(github, "github.svg", "https://github.com/" + github) } ] } #let cv_heading(author, title, linkedin, email, github) = { grid( columns: (1fr, 1fr), box[ #text([#author], size: 1.5em, weight: 800) #v(-1.2em) #block(text(weight: 400, 1.3em, title)) ], _contacts(email, linkedin, github) ) } #let cv_section(name) = { v(0.5em) text([#name], size: 1.2em, weight: 800) v(-1em) line(length: 100%) v(-0.5em) } #let cv_skillset(name, skills: ()) = { block[ #text([#name: ], weight: 1000) #skills.join(", "). #v(-0.4em) ] } #let cv_entry( description, start: (month: "", year: ""), end: (month: "", year: ""), place: "", role: [], icon: "") = { grid( columns: (5%, 0.5cm, 1fr, 1fr), align(center + horizon)[ #if icon != "" { image("icons/" + icon) } else { }], [], box[ #block(text([#role], weight: 800)) #block([#place]) ], align(right + top)[ #text[#start.month #start.year - #end.month #end.year] ] ) text([#description]) v(-1em) }
https://github.com/SWATEngineering/Docs
https://raw.githubusercontent.com/SWATEngineering/Docs/main/src/3_PB/PianoDiProgetto/sections/PianificazioneSprint/QuindicesimoSprint.typ
typst
MIT License
#import "../../functions.typ": glossary === Quindicesimo #glossary[sprint] *Inizio*: Venerdì 29/03/2024 *Fine*: Giovedì 04/04/2024 *Obiettivi dello #glossary[sprint]*: - Terminare la stesura del _Piano di Progetto v2.0_: - Aggiornare pianificazione e preventivo pertinenti allo #glossary[sprint] 15 e inserire il consuntivo pertinente allo #glossary[sprint] 14; - Trattandosi dell'ultimo #glossary("sprint"), inserire anche il consuntivo dello #glossary[sprint] 15 al termine dello stesso; - Terminare la stesura del _Manuale Utente v1.0_: - Aggiungere le API key necessarie per il corretto funzionamento del software alla sezione riguardante l'installazione; - Aggiungere una sezione riguardante la componente di allarmistica su Discord; - Aggiungere screenshot rilevanti. - Terminare la stesura del _Piano di Qualifica v2.0_ con l'aggiornamento di tutte le metriche; - Terminare la stesura della _Specifica Tecnica v1.0_ con l'aggiornamento del soddisfacimento dei requisiti nella sezione dedicata al tracciamento; - Terminare la stesura dell'_Analisi dei Requisiti v2.0_; - Revisione in stile #glossary("walkthrough") della documentazione e relativa approvazione finale; - Presentare il software alla Proponente per la validazione del prodotto come #glossary[MVP]\; - Presentare la candidatura alla prima fase della seconda revisione #glossary("PB") e preparare la relativa presentazione.
https://github.com/lxl66566/my-college-files
https://raw.githubusercontent.com/lxl66566/my-college-files/main/信息科学与工程学院/操作系统(选修)/实验/3.typ
typst
The Unlicense
#import "template.typ": * #show: project.with( title: "实验三 进程间管道通信", authors: ( "absolutex", ) ) #align(right)[] + *实验目的* - 理解Linux系统中进程管道通信的基本原理及实现。 + 实验内容: + 编写一个程序,建立一个管道pipe,同时父进程生成一个子进程,子进程向管道pipe中写入一字符串,父进程从pipe中读出该字符串,并每隔3秒输出打印一次。 #include_code("src/3.1.c") - 运行结果:程序每 3 秒钟输出一次 `receive: subprocess here\n`. - 解释说明:每三秒子进程向管道发送一次消息,每三秒父进程接收并打印。 + 进程的管道通信: 编制一段程序,实现进程的管道通信。使用系统调用`pipe()`建立一条管道线;两个子进程`P1`和`P2`分别向管道各写一句话: `Child1 is sending a message! Child2 is sending a message!`而父进程则从管道中读出来自于两个子进程的信息,显示在屏幕上。要求父进程先接收子进程`P1`发来的消息,然后再接收子进程`P2`发来的消息。 #include_code("src/3.2.c") - 运行结果:重复运行 100 次,全部输出均为 ``` receive: Child1 is sending a message! receive: Child2 is sending a message! ``` - 解释说明:此处控制先接收子进程`P1`发来的消息的方法是信号量,而不是`lockf`。由于本题只能使用一条管道,而管道一定是 FIFO 的,因此父进程无法选择性接收某一子进程消息。想要让输出有序,必须在发送端确定发送次序。即使在发送前就将管道加锁(此时两个线程均无法写入),两个进程都 wait for unlock,一旦解锁,也无法控制进程写入的先后顺序,因此试用信号量实现。
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/spread-08.typ
typst
Other
// Error: 13-16 only one argument sink is allowed #let f(..a, ..b) = none
https://github.com/frectonz/the-pg-book
https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/052.%20web20.html.typ
typst
web20.html Web 2.0 Want to start a startup? Get funded by Y Combinator. November 2005Does "Web 2.0" mean anything? Till recently I thought it didn't, but the truth turns out to be more complicated. Originally, yes, it was meaningless. Now it seems to have acquired a meaning. And yet those who dislike the term are probably right, because if it means what I think it does, we don't need it.I first heard the phrase "Web 2.0" in the name of the Web 2.0 conference in 2004. At the time it was supposed to mean using "the web as a platform," which I took to refer to web-based applications. [1]So I was surprised at a conference this summer when <NAME> led a session intended to figure out a definition of "Web 2.0." Didn't it already mean using the web as a platform? And if it didn't already mean something, why did we need the phrase at all?OriginsTim says the phrase "Web 2.0" first arose in "a brainstorming session between O'Reilly and Medialive International." What is Medialive International? "Producers of technology tradeshows and conferences," according to their site. So presumably that's what this brainstorming session was about. O'Reilly wanted to organize a conference about the web, and they were wondering what to call it.I don't think there was any deliberate plan to suggest there was a new version of the web. They just wanted to make the point that the web mattered again. It was a kind of semantic deficit spending: they knew new things were coming, and the "2.0" referred to whatever those might turn out to be.And they were right. New things were coming. But the new version number led to some awkwardness in the short term. In the process of developing the pitch for the first conference, someone must have decided they'd better take a stab at explaining what that "2.0" referred to. Whatever it meant, "the web as a platform" was at least not too constricting.The story about "Web 2.0" meaning the web as a platform didn't live much past the first conference. By the second conference, what "Web 2.0" seemed to mean was something about democracy. At least, it did when people wrote about it online. The conference itself didn't seem very grassroots. It cost $2800, so the only people who could afford to go were VCs and people from big companies.And yet, oddly enough, <NAME>'s article about the conference in Wired News spoke of "throngs of geeks." When a friend of mine asked Ryan about this, it was news to him. He said he'd originally written something like "throngs of VCs and biz dev guys" but had later shortened it just to "throngs," and that this must have in turn been expanded by the editors into "throngs of geeks." After all, a Web 2.0 conference would presumably be full of geeks, right?Well, no. There were about 7. Even <NAME> was wearing a suit, a sight so alien I couldn't parse it at first. I saw him walk by and said to one of the O'Reilly people "that guy looks just like Tim.""Oh, that's Tim. He bought a suit." I ran after him, and sure enough, it was. He explained that he'd just bought it in Thailand.The 2005 Web 2.0 conference reminded me of Internet trade shows during the Bubble, full of prowling VCs looking for the next hot startup. There was that same odd atmosphere created by a large number of people determined not to miss out. Miss out on what? They didn't know. Whatever was going to happen—whatever Web 2.0 turned out to be.I wouldn't quite call it "Bubble 2.0" just because VCs are eager to invest again. The Internet is a genuinely big deal. The bust was as much an overreaction as the boom. It's to be expected that once we started to pull out of the bust, there would be a lot of growth in this area, just as there was in the industries that spiked the sharpest before the Depression.The reason this won't turn into a second Bubble is that the IPO market is gone. Venture investors are driven by exit strategies. The reason they were funding all those laughable startups during the late 90s was that they hoped to sell them to gullible retail investors; they hoped to be laughing all the way to the bank. Now that route is closed. Now the default exit strategy is to get bought, and acquirers are less prone to irrational exuberance than IPO investors. The closest you'll get to Bubble valuations is <NAME> paying $580 million for Myspace. That's only off by a factor of 10 or so.1. AjaxDoes "Web 2.0" mean anything more than the name of a conference yet? I don't like to admit it, but it's starting to. When people say "Web 2.0" now, I have some idea what they mean. And the fact that I both despise the phrase and understand it is the surest proof that it has started to mean something.One ingredient of its meaning is certainly Ajax, which I can still only just bear to use without scare quotes. Basically, what "Ajax" means is "Javascript now works." And that in turn means that web-based applications can now be made to work much more like desktop ones.As you read this, a whole new generation of software is being written to take advantage of Ajax. There hasn't been such a wave of new applications since microcomputers first appeared. Even Microsoft sees it, but it's too late for them to do anything more than leak "internal" documents designed to give the impression they're on top of this new trend.In fact the new generation of software is being written way too fast for Microsoft even to channel it, let alone write their own in house. Their only hope now is to buy all the best Ajax startups before Google does. And even that's going to be hard, because Google has as big a head start in buying microstartups as it did in search a few years ago. After all, Google Maps, the canonical Ajax application, was the result of a startup they bought.So ironically the original description of the Web 2.0 conference turned out to be partially right: web-based applications are a big component of Web 2.0. But I'm convinced they got this right by accident. The Ajax boom didn't start till early 2005, when Google Maps appeared and the term "Ajax" was coined.2. DemocracyThe second big element of Web 2.0 is democracy. We now have several examples to prove that amateurs can surpass professionals, when they have the right kind of system to channel their efforts. Wikipedia may be the most famous. Experts have given Wikipedia middling reviews, but they miss the critical point: it's good enough. And it's free, which means people actually read it. On the web, articles you have to pay for might as well not exist. Even if you were willing to pay to read them yourself, you can't link to them. They're not part of the conversation.Another place democracy seems to win is in deciding what counts as news. I never look at any news site now except Reddit. [2] I know if something major happens, or someone writes a particularly interesting article, it will show up there. Why bother checking the front page of any specific paper or magazine? Reddit's like an RSS feed for the whole web, with a filter for quality. Similar sites include Digg, a technology news site that's rapidly approaching Slashdot in popularity, and del.icio.us, the collaborative bookmarking network that set off the "tagging" movement. And whereas Wikipedia's main appeal is that it's good enough and free, these sites suggest that voters do a significantly better job than human editors.The most dramatic example of Web 2.0 democracy is not in the selection of ideas, but their production. I've noticed for a while that the stuff I read on individual people's sites is as good as or better than the stuff I read in newspapers and magazines. And now I have independent evidence: the top links on Reddit are generally links to individual people's sites rather than to magazine articles or news stories.My experience of writing for magazines suggests an explanation. Editors. They control the topics you can write about, and they can generally rewrite whatever you produce. The result is to damp extremes. Editing yields 95th percentile writing—95% of articles are improved by it, but 5% are dragged down. 5% of the time you get "throngs of geeks."On the web, people can publish whatever they want. Nearly all of it falls short of the editor-damped writing in print publications. But the pool of writers is very, very large. If it's large enough, the lack of damping means the best writing online should surpass the best in print. [3] And now that the web has evolved mechanisms for selecting good stuff, the web wins net. Selection beats damping, for the same reason market economies beat centrally planned ones.Even the startups are different this time around. They are to the startups of the Bubble what bloggers are to the print media. During the Bubble, a startup meant a company headed by an MBA that was blowing through several million dollars of VC money to "get big fast" in the most literal sense. Now it means a smaller, younger, more technical group that just decided to make something great. They'll decide later if they want to raise VC-scale funding, and if they take it, they'll take it on their terms.3. Don't Maltreat UsersI think everyone would agree that democracy and Ajax are elements of "Web 2.0." I also see a third: not to maltreat users. During the Bubble a lot of popular sites were quite high-handed with users. And not just in obvious ways, like making them register, or subjecting them to annoying ads. The very design of the average site in the late 90s was an abuse. Many of the most popular sites were loaded with obtrusive branding that made them slow to load and sent the user the message: this is our site, not yours. (There's a physical analog in the Intel and Microsoft stickers that come on some laptops.)I think the root of the problem was that sites felt they were giving something away for free, and till recently a company giving anything away for free could be pretty high-handed about it. Sometimes it reached the point of economic sadism: site owners assumed that the more pain they caused the user, the more benefit it must be to them. The most dramatic remnant of this model may be at salon.com, where you can read the beginning of a story, but to get the rest you have sit through a movie.At Y Combinator we advise all the startups we fund never to lord it over users. Never make users register, unless you need to in order to store something for them. If you do make users register, never make them wait for a confirmation link in an email; in fact, don't even ask for their email address unless you need it for some reason. Don't ask them any unnecessary questions. Never send them email unless they explicitly ask for it. Never frame pages you link to, or open them in new windows. If you have a free version and a pay version, don't make the free version too restricted. And if you find yourself asking "should we allow users to do x?" just answer "yes" whenever you're unsure. Err on the side of generosity.In How to Start a Startup I advised startups never to let anyone fly under them, meaning never to let any other company offer a cheaper, easier solution. Another way to fly low is to give users more power. Let users do what they want. If you don't and a competitor does, you're in trouble.iTunes is Web 2.0ish in this sense. Finally you can buy individual songs instead of having to buy whole albums. The recording industry hated the idea and resisted it as long as possible. But it was obvious what users wanted, so Apple flew under the labels. [4] Though really it might be better to describe iTunes as Web 1.5. Web 2.0 applied to music would probably mean individual bands giving away DRMless songs for free.The ultimate way to be nice to users is to give them something for free that competitors charge for. During the 90s a lot of people probably thought we'd have some working system for micropayments by now. In fact things have gone in the other direction. The most successful sites are the ones that figure out new ways to give stuff away for free. Craigslist has largely destroyed the classified ad sites of the 90s, and OkCupid looks likely to do the same to the previous generation of dating sites.Serving web pages is very, very cheap. If you can make even a fraction of a cent per page view, you can make a profit. And technology for targeting ads continues to improve. I wouldn't be surprised if ten years from now eBay had been supplanted by an ad-supported freeBay (or, more likely, gBay).Odd as it might sound, we tell startups that they should try to make as little money as possible. If you can figure out a way to turn a billion dollar industry into a fifty million dollar industry, so much the better, if all fifty million go to you. Though indeed, making things cheaper often turns out to generate more money in the end, just as automating things often turns out to generate more jobs.The ultimate target is Microsoft. What a bang that balloon is going to make when someone pops it by offering a free web-based alternative to MS Office. [5] Who will? Google? They seem to be taking their time. I suspect the pin will be wielded by a couple of 20 year old hackers who are too naive to be intimidated by the idea. (How hard can it be?)The Common ThreadAjax, democracy, and not dissing users. What do they all have in common? I didn't realize they had anything in common till recently, which is one of the reasons I disliked the term "Web 2.0" so much. It seemed that it was being used as a label for whatever happened to be new—that it didn't predict anything.But there is a common thread. Web 2.0 means using the web the way it's meant to be used. The "trends" we're seeing now are simply the inherent nature of the web emerging from under the broken models that got imposed on it during the Bubble.I realized this when I read an interview with <NAME>, the co-founder of Excite. [6] Excite really never got the business model right at all. We fell into the classic problem of how when a new medium comes out it adopts the practices, the content, the business models of the old medium—which fails, and then the more appropriate models get figured out. It may have seemed as if not much was happening during the years after the Bubble burst. But in retrospect, something was happening: the web was finding its natural angle of repose. The democracy component, for example—that's not an innovation, in the sense of something someone made happen. That's what the web naturally tends to produce.Ditto for the idea of delivering desktop-like applications over the web. That idea is almost as old as the web. But the first time around it was co-opted by Sun, and we got Java applets. Java has since been remade into a generic replacement for C++, but in 1996 the story about Java was that it represented a new model of software. Instead of desktop applications, you'd run Java "applets" delivered from a server.This plan collapsed under its own weight. Microsoft helped kill it, but it would have died anyway. There was no uptake among hackers. When you find PR firms promoting something as the next development platform, you can be sure it's not. If it were, you wouldn't need PR firms to tell you, because hackers would already be writing stuff on top of it, the way sites like Busmonster used Google Maps as a platform before Google even meant it to be one.The proof that Ajax is the next hot platform is that thousands of hackers have spontaneously started building things on top of it. Mikey likes it.There's another thing all three components of Web 2.0 have in common. Here's a clue. Suppose you approached investors with the following idea for a Web 2.0 startup: Sites like del.icio.us and flickr allow users to "tag" content with descriptive tokens. But there is also huge source of implicit tags that they ignore: the text within web links. Moreover, these links represent a social network connecting the individuals and organizations who created the pages, and by using graph theory we can compute from this network an estimate of the reputation of each member. We plan to mine the web for these implicit tags, and use them together with the reputation hierarchy they embody to enhance web searches. How long do you think it would take them on average to realize that it was a description of Google?Google was a pioneer in all three components of Web 2.0: their core business sounds crushingly hip when described in Web 2.0 terms, "Don't maltreat users" is a subset of "Don't be evil," and of course Google set off the whole Ajax boom with Google Maps.Web 2.0 means using the web as it was meant to be used, and Google does. That's their secret. They're sailing with the wind, instead of sitting becalmed praying for a business model, like the print media, or trying to tack upwind by suing their customers, like Microsoft and the record labels. [7]Google doesn't try to force things to happen their way. They try to figure out what's going to happen, and arrange to be standing there when it does. That's the way to approach technology—and as business includes an ever larger technological component, the right way to do business.The fact that Google is a "Web 2.0" company shows that, while meaningful, the term is also rather bogus. It's like the word "allopathic." It just means doing things right, and it's a bad sign when you have a special word for that. Notes[1] From the conference site, June 2004: "While the first wave of the Web was closely tied to the browser, the second wave extends applications across the web and enables a new generation of services and business opportunities." To the extent this means anything, it seems to be about web-based applications.[2] Disclosure: Reddit was funded by Y Combinator. But although I started using it out of loyalty to the home team, I've become a genuine addict. While we're at it, I'm also an investor in !MSFT, having sold all my shares earlier this year.[3] I'm not against editing. I spend more time editing than writing, and I have a group of picky friends who proofread almost everything I write. What I dislike is editing done after the fact by someone else.[4] Obvious is an understatement. Users had been climbing in through the window for years before Apple finally moved the door.[5] Hint: the way to create a web-based alternative to Office may not be to write every component yourself, but to establish a protocol for web-based apps to share a virtual home directory spread across multiple servers. Or it may be to write it all yourself.[6] In Jessica Livingston's Founders at Work.[7] Microsoft didn't sue their customers directly, but they seem to have done all they could to help SCO sue them.Thanks to <NAME>, <NAME>, <NAME>, Peter Norvig, <NAME>, and <NAME> for reading drafts of this, and to the guys at O'Reilly and Adaptive Path for answering my questions.Interview About Web 2.0Spanish TranslationGerman TranslationRussian TranslationJapanese Translation If you liked this, you may also like Hackers & Painters.
https://github.com/ClazyChen/Table-Tennis-Rankings
https://raw.githubusercontent.com/ClazyChen/Table-Tennis-Rankings/main/history/2010/WS-11.typ
typst
#set text(font: ("Courier New", "NSimSun")) #figure( caption: "Women's Singles (1 - 32)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [1], [GUO Yan], [CHN], [3107], [2], [GUO Yue], [CHN], [3082], [3], [LI Xiaoxia], [CHN], [3017], [4], [LIU Shiwen], [CHN], [2989], [5], [DING Ning], [CHN], [2901], [6], [FAN Ying], [CHN], [2858], [7], [FENG Tianwei], [SGP], [2840], [8], [WANG Yuegu], [SGP], [2830], [9], [KIM Kyungah], [KOR], [2813], [10], [WU Yang], [CHN], [2786], [11], [#text(gray, "CAO Zhen")], [CHN], [2776], [12], [JIANG Huajun], [HKG], [2752], [13], [LI Jiao], [NED], [2706], [14], [SEOK Hajung], [KOR], [2684], [15], [YU Mengyu], [SGP], [2684], [16], [LI Jie], [NED], [2674], [17], [DANG Yeseo], [KOR], [2662], [18], [PARK Miyoung], [KOR], [2644], [19], [YAO Yan], [CHN], [2631], [20], [GAO Jun], [USA], [2624], [21], [LIU Jia], [AUT], [2622], [22], [SUN Beibei], [SGP], [2614], [23], [PAVLOVICH Viktoria], [BLR], [2610], [24], [TIE Yana], [HKG], [2609], [25], [ISHIKAWA Kasumi], [JPN], [2602], [26], [#text(gray, "LAU Sui Fei")], [HKG], [2599], [27], [LANG Kristin], [GER], [2595], [28], [LI Qian], [POL], [2593], [29], [POTA Georgina], [HUN], [2584], [30], [ISHIGAKI Yuka], [JPN], [2581], [31], [LI Jiawei], [SGP], [2581], [32], [NI Xia Lian], [LUX], [2580], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Women's Singles (33 - 64)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [33], [HU Melek], [TUR], [2573], [34], [ZHU Yuling], [MAC], [2560], [35], [HUANG Yi-Hua], [TPE], [2559], [36], [FUKUHARA Ai], [JPN], [2556], [37], [SHEN Yanfei], [ESP], [2555], [38], [HIRANO Sayaka], [JPN], [2551], [39], [TIKHOMIROVA Anna], [RUS], [2548], [40], [PASKAUSKIENE Ruta], [LTU], [2548], [41], [SAMARA Elizabeta], [ROU], [2541], [42], [WU Jiaduo], [GER], [2538], [43], [ZHU Fang], [ESP], [2517], [44], [CHANG Chenchen], [CHN], [2510], [45], [CHENG I-Ching], [TPE], [2506], [46], [<NAME>], [ROU], [2499], [47], [FE<NAME>], [SRB], [2487], [48], [#text(gray, "<NAME>")], [CHN], [2487], [49], [MOON Hyunjung], [KOR], [2482], [50], [ZHANG Rui], [HKG], [2469], [51], [LI Qiangbing], [AUT], [2467], [52], [KANG Misoon], [KOR], [2466], [53], [WANG Chen], [CHN], [2453], [54], [SKOV Mie], [DEN], [2448], [55], [LI Xue], [FRA], [2445], [56], [WAKAMIYA Misako], [JPN], [2444], [57], [WU Xue], [DOM], [2438], [58], [LI Xiaodan], [CHN], [2434], [59], [STEFANOVA Nikoleta], [ITA], [2431], [60], [ODOROVA Eva], [SVK], [2430], [61], [LIN Ling], [HKG], [2429], [62], [KIM Jong], [PRK], [2419], [63], [WEN Jia], [CHN], [2419], [64], [PAVLOVICH Veronika], [BLR], [2419], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Women's Singles (65 - 96)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [65], [STRBIKOVA Renata], [CZE], [2414], [66], [HAN Hye Song], [PRK], [2413], [67], [MISIKONYTE Lina], [LTU], [2410], [68], [LEE Ho Ching], [HKG], [2407], [69], [FUJII Hiroko], [JPN], [2406], [70], [LEE Eunhee], [KOR], [2401], [71], [VACENOVSKA Iveta], [CZE], [2397], [72], [<NAME>], [GER], [2394], [73], [TOTH Krisztina], [HUN], [2394], [74], [SUH Hyo Won], [KOR], [2393], [75], [M<NAME>], [FRA], [2392], [76], [RAO Jingwen], [CHN], [2390], [77], [BILENKO Tetyana], [UKR], [2389], [78], [NTOULAKI Ekaterina], [GRE], [2388], [79], [RAMIREZ Sara], [ESP], [2381], [80], [GU Yuting], [CHN], [2380], [81], [XU Jie], [POL], [2373], [82], [LOVAS Petra], [HUN], [2365], [83], [YANG Ha Eun], [KOR], [2363], [84], [HE Sirin], [TUR], [2360], [85], [MIKHAILOVA Polina], [RUS], [2358], [86], [<NAME>], [CRO], [2357], [87], [<NAME>], [KOR], [2347], [88], [<NAME>], [GER], [2347], [89], [<NAME>], [JPN], [2345], [90], [<NAME>], [CHN], [2334], [91], [<NAME>], [AUT], [2330], [92], [<NAME>], [ROU], [2330], [93], [<NAME>], [SRB], [2324], [94], [<NAME>], [FRA], [2316], [95], [<NAME>], [CHN], [2314], [96], [<NAME>], [NED], [2312], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Women's Singles (97 - 128)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [97], [<NAME>], [KOR], [2308], [98], [<NAME>], [JPN], [2302], [99], [<NAME>], [UKR], [2296], [100], [<NAME>], [CRO], [2287], [101], [<NAME>], [FRA], [2281], [102], [<NAME>], [RUS], [2280], [103], [<NAME>], [SWE], [2280], [104], [<NAME>], [JPN], [2276], [105], [<NAME>], [CZE], [2275], [106], [<NAME>], [HUN], [2269], [107], [#text(gray, "FU<NAME>i")], [JPN], [2267], [108], [BALAZOVA Barbora], [SVK], [2262], [109], [<NAME>], [ITA], [2258], [110], [<NAME>], [USA], [2256], [111], [<NAME>], [ESP], [2248], [112], [<NAME>], [ENG], [2247], [113], [<NAME>], [CHN], [2243], [114], [<NAME>], [AUS], [2241], [115], [<NAME>], [KOR], [2240], [116], [<NAME>], [CGO], [2234], [117], [<NAME>], [ISR], [2234], [118], [<NAME>], [ESP], [2224], [119], [BOROS Tamara], [CRO], [2222], [120], [<NAME>], [MAS], [2222], [121], [YAMANASHI Yuri], [JPN], [2222], [122], [KIM Minhee], [KOR], [2219], [123], [<NAME>], [THA], [2219], [124], [<NAME>], [RUS], [2219], [125], [FADEEVA Oxana], [RUS], [2218], [126], [<NAME>], [SRB], [2217], [127], [<NAME>], [RUS], [2212], [128], [<NAME>], [NED], [2209], ) )
https://github.com/f14-bertolotti/bedlam
https://raw.githubusercontent.com/f14-bertolotti/bedlam/main/src/measure-theory/lebesgue-measure.typ
typst
#import "introduction.typ": * #import "../notation/main.typ": extension, restriction #import "../theme.typ": proof, proposition, theorem, definition, example, comment == Lebesgue Measure #let lebesgue-pre-measure = ( tag : link(<lebesgue-pre-measure>)[Lebesgue pre-measure], sym : n => link(<lebesgue-pre-measure>)[$lambda^(#n)$] ) #definition("Lebesgue pre-measure")[ The *Lebesgue pre-measure* is a mapping $#(lebesgue-pre-measure.sym)("n") :#(half-open-rectangle.sym)("n") --> RR_(>=0) union {+oo}$ #comment[(#(half-open-rectangle.sym)("n") denotes the set half open rectangle)] such that $#(lebesgue-pre-measure.sym)("n") (times.big_(i=1)^(n) [a_i, b_i)) = product_(i=1)^n (b_i-a_i)$ for $a_i,b_i in RR$ and $a_i <= b_i$. ]<lebesgue-pre-measure> #proposition[ The Lebesgue pre-measure is a #pre-measure.tag. ]<lebesgue-pre-measure-is-a-pre-measure> #proof(text[of Proposition @lebesgue-pre-measure-is-a-pre-measure])[ 1. $#(lebesgue-pre-measure.sym)("n") (nothing) = #(lebesgue-pre-measure.sym)("n") (times.big_(i=1)^n [a_i, a_i)) = product_(i=1)^n (a_i - a_i) = 0$ 2. #grid( columns: (1fr,1fr), gutter: 1cm, text[ Let $I = times.big_(i=1)^n [a_i, b_i)$ and $I' = times.big_(i=1)^n [a'_i, b'_i)$ be disjoint #text[#half-open-rectangle.tag]s. The $I union I'$ belongs to #(half-open-rectangle.sym)("n") if we can stitch one to the other. This can only happen if there is an $i$ such that: 1. $j = i ==> b_j = a'_j$. 2. $j != i ==> b_j = b'_j$. 3. $j != i ==> a_j = a'_j$. This can be intuitively visualized in @stitched-rectangles where two 2-dimensional half open rectangles met at one side. The only difference between the rectangles is that one is shifted along a single dimension, in such a way that they met at the open and close edges. ], text[#figure(caption:text[Two half open rectangles that can be stitched together.])[#include "figs/stitched-rectangles.typ"]<stitched-rectangles>] ) In this situation we have that: $ #(lebesgue-pre-measure.sym)("n") (I) + #(lebesgue-pre-measure.sym)("n") (I') = & product_(j=1)^n (b_j - a_j) + product_(j=1)^n (b'_j, a'_j) && #comment[#lebesgue-pre-measure.tag definition] \ = & ((b_i - a_i) + (b'_i - a'_i)) product_(j = 1 \ j != i)^n b_j-a_j && #comment[factoring out $product_(j = 1 \ j != i)^n b_j-a_j$] \ = & ((b_i - a'_i)) product_(j = 1 \ j != i)^n b_j-a_j && #comment[stitching #text[#half-open-rectangle.tag]s together] \ = & #(lebesgue-pre-measure.sym)("n") (I union I') $ Thus it is verified that $#(lebesgue-pre-measure.sym)("n")$ is finitely additive. 3. The $forall E in #(half-open-rectangle.sym)("n"): #(lebesgue-pre-measure.sym)("n") (E) >= 0$ since the product of positive terms is positive. ] Given a #pre-measure.tag on a #set-algebra.tag is always possible to extend this #pre-measure.tag to a full-fledge #measure.tag over a #sigma-algebra.tag generated by the #set-algebra.tag. Further, such a #measure.tag is unique. This is the subject of the following theorem. #definition("Lebesgue Measure")[ TODO ]<lebesgue-measure> #theorem("Lebesgue Measure Existence and Uniqueness")[ TODO ]<lebesgue-measure-existence-and-uniqueness> #proof(text[of @lebesgue-measure-existence-and-uniqueness])[ TODO ]<lebesgue-measure-existence-and-uniqueness-proof>
https://github.com/sa-concept-refactoring/doc
https://raw.githubusercontent.com/sa-concept-refactoring/doc/main/weekly-updates.typ
typst
// Im ZIP Archive mit abgeben!! #set par(justify: true) #set page( margin: (top: 50pt, bottom: 50pt), header: [ #set text(10pt) #smallcaps[SA — C++ Concept Refactorings] #h(1fr) <NAME>, <NAME> ], ) #set page(numbering: "1 / 1") #set page(columns: 2) = Weekly Update Report == W1 No Updates == W2 === What did we do? - Get LLVM to build locally - Setup VSCode to use the locally built clangd - Played around with refactoring - Setup time tracking - Setup test project - Forked LLVM repo - Added repo for documentation - Started writing documentation (setup Typst etc.) - Looked for possible features to implement === What to do next week? - Define first feature to implement - Start to implement defined feature - Continue looking for more features to implement == W3 === What did we do? - Worked on first refactoring, which is about 65% done - Figured out a git workflow - Got debug builds working on both platforms - Looked at contribution guidelines === What to do next week? - Finish the first refactoring - Prepare git branch for PR (no PR will be created yet) - Write tests for first refactoring - Update documentation == W4 === What did we do? - Refactor first refactoring - Write down two new ideas - Got tests working - Updated Documentation === What to do next week? - Finish first refactoring (this time for real) - Add more tests for first refactoring - Restructure documentation - Write more documentation == W5 === What did we do? - More refactoring - Replaced `requires` clause - Discussed documentation reordering - Added unit tests === What to do next week? - Finish feature - Update documentation with what we did - Create Pull-Request on Github == W6 === What did we do? - Create Pull-Request on GitHub to llvm project - Resolve comments on Pull-Requests - Update and reorder documentation === What to do next week? - Work on documentation - Document refactoring - Start new refactoring - Improve first refactoring == W7 === What did we do? - Updated documentation - Analysis - New refactoring - Started with new refactoring feature - Research for second refactoring === What to do next week? - Work on documentation - Work on second refactoring - Remove template declaration - Figure out symbol lookup - Keep an eye on Pull-Request == W8 === What did we do? - Documented second refactoring - Worked on implementation of second refactoring - Updated test cases - Kept an eye on open Pull-Request === What to do next week? - Check why refactoring is not working on `const` - Add concept requirements to function parameters - Keep on working on documentation - Make documentation ready for review == W9 === What did we do? - Got pretty far with the second refactoring (feature complete) - Wrote a few tests for second refactoring - Worked on documentation === What to do next week? - Write more tests for second refactoring - Cleanup code and request feedback from advisor - Work on documentation (with focus on analysis, introduction and project management) - Create checklist for documentation - Keep an eye on the open PR for the first refactoring == W10 === What did we do? - Checked documentation feedback - Worked on documentation - Now using Pull-Requests - Cleaned up second refactoring - Kept an eye on open Pull-Request === What to do next week? - More documentation improvements - Finish cleaning up second refactoring - Create Pull-Request for second refactoring == W11 === What did we do? - Lots of documentation work - Minor fix for the open PR (1. refactoring) === What to do next week? - Address PR comments (2. refactoring) - Open public PR (2. refactoring) - More documentation work, especially abstract == W12 === What did we do? - Resolved Pull Request comments - Merged Abstract and Management Summary - Worked on documentation === What to do next week? - Create second Pull Request for LLVM - Finish first version of documentation to be ready for review == W13 === What did we do? - Created Pull Request for second refactoring - Worked on documentation and corrections === What to do next week? - Finish documentation - Submit abstract == W14 === What did we do? - Prepared documentation for review - Fixed reviewed parts in documentation - Wrote abstract for AVT === What to do next week? - Finalize documentation - Create poster - Hand in digital documentation - Hand in printed documentation - Party after all work is done
https://github.com/lucannez64/Notes
https://raw.githubusercontent.com/lucannez64/Notes/master/Texte_2.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: "Texte 2", authors: ( "<NAME>", ), date: "30 Octobre, 2023", ) #set heading(numbering: "1.1.") == Comment se poème exprime-t-il le manichéisme Hugoléen ? <comment-se-poème-exprime-t-il-le-manichéisme-hugoléen> \ \ L’#emph[étang] #emph[mystérieux], suaire aux #emph[blanches moires], (Nature Ambiance Fantastique) (Paronomase) \ #emph[Frissonne] ; au fond du bois, la #emph[clairière] apparaît ; (Rejet Hypallage) (Domestication) \ Les arbres sont #emph[profonds] et les #emph[branches sont noires]; (La forêt ressort plus que le bois)(Etrangeté) \ Avez-vous vu Vénus à travers la forêt ? (Question Rhétorique) (Divinisation de l’amour) \ \ Avez-vous vu Vénus au sommet des #emph[collines] ? (Anaphore) (Nature) \ Vous qui passez dans l’#emph[ombre], êtes-vous des amants ? (Défunts) \ Les sentiers #emph[bruns] sont pleins de #emph[blanches] mousselines ; (Antithèse) \ L’herbe s’éveille et parle aux sépulcres dormants. (Vivant parle aux morts) (autant de vie que de mort \=\> manichéisme) ~ \ \ Que dit-il, le brin d’herbe ? et que répond la tombe ? (Discours Direct)(Brind d’herbe parle à la mort) ~ Aimez, vous qui vivez ! on a froid sous les ifs. (<NAME>) (Mort donne un conseil à la vie)(Allitération v f) \ Lèvre, cherche la bouche ! aimez-vous ! la nuit tombe ; (Injonction !) (Difference des pronoms "on" "vous") \ Soyez heureux #emph[pendant que] nous sommes #emph[pensifs]. (Subordonnée conjonctive circonstanciel)(Introspection) \ \ #emph[Dieu] veut qu’#emph[on] ait aimé. #emph[Vivez] ! faites envie, (Sacré Divinité)(Lecteur)(Impératif: Sentiment amoureux \=\> volonté de dieu) \ #emph[Ô] couples #emph[qui passez] sous le #emph[vert coudrier]. (Emphase)(Subordonnée relative déterminative \=\> Couples) (Sym Amour et Abondance) \ Tout ce que dans la #emph[tombe], en sortant de la #emph[vie], (Antithèse) \ On #emph[emporta] d’amour, #emph[on] l’#emph[emploie] à prier. (Passé et présent \=\> Cycle de la vie)(Reprise anaphorique à l’hémistyche) \ \ Les #emph[mortes] d’#emph[aujourd’hui] furent #emph[jadis] les #emph[belles]. (Fuite du temps)(Opposition) \ Le #emph[ver luisant] dans l’#emph[ombre] erre avec son #emph[flambeau]. (Poésie)(Opposition) \ Le vent fait tressaillir, au milieu des javelles, (Dichotomie entre la nature et l’homme (nature artificiel)) \ Le brin d’herbe, et Dieu fait tressaillir le tombeau. (Réveille les morts) ~ \ \ La forme d’un toit #emph[noir] dessine une #emph[chaumière] ; (Opposition mort noir vie dans la chaumière) \ On entend #emph[dans les prés] le pas lourd du #emph[faucheur] ; (allégorie de la mort) (CCL) \ L’#emph[étoile] aux cieux, ainsi qu’une #emph[fleur] de lumière, (Comparaison: Beauté insaisissable) (ChampLex Lumière !\= mort noir) \ Ouvre et fait rayonner sa splendide fraîcheur. ~ \ \ #emph[Aimez-vous] ! c’est #emph[le mois où les fraises sont mûres]. (Injonction) (Synecdoque : mai) \ L’#emph[ange du soir] rêveur, qui flotte dans les vents, (Mort) \ Mêle, en les emportant sur ses ailes obscures, \ Les #emph[prières des morts] aux #emph[baisers des vivants]. (Antithèse) \ \ manichéisme la vie et la mort \=\=
https://github.com/iyno-org/Holistic-Clinical-Neurosurgery
https://raw.githubusercontent.com/iyno-org/Holistic-Clinical-Neurosurgery/main/1.%20Spinal%20Cord/Tract%20Pathologies/tracts.typ
typst
#import "@preview/tufte-memo:0.1.2": * #show: template.with( title: [1. Spinal Cord: Tract Pathologies], shorttitle: [], authors: ( ( name: "<NAME>", ), ), distribution: [iyno.org], toc: true, bib: bibliography("refs.bib") ) #pagebreak() Movement is crucial to human beings and animals in general and damage to motor systems lead to disabilities. Sensory systems are equally important which provide information to the brain about sensations. This chapter gives an overview of these motor and sensory pathways#note([Knowledge of general spinal cord anatomy is a prior requirement to study this chapter.], dy:-1in). The spinal cord can be divided into a part that contains white mater and a part that contains gray mater#note([Gray mater contains the cell bodies of the neurons while white mater is the collection of myelinated axons. Also, note that the arrangement of gray and white mater is different in the brain and the spinal cord. The details will be discussed in the chapter on Brain Pathologies.], dy:-0.8in). The spinal cord lies within the vertebral canal and is surrounded by three protective layers known as the meninges. It is cushioned against trauma by the CerebroSpinal Fluid (CSF). A point to note here is if the spinal cord is floating in the CSF, why doesn't it move around in the vertebral column. The answer are the denticulate ligaments (which are extensions of pia mater; the innermost layer of the meninges) and the filum terminale which is the inferior extension of the pia mater#note([The lower portion of the filum terminale is also covered by dura mater as well.], dy:-0.8in). As stated in the previous chapter, the spinal neves consist of motor or sensory roots from each segment of the spinal cord which leave through the intervertebral foramina. = Case 1 == Presentation A rugby athlete while talking to his friend casually tells him that he could not throw well today because he is feeling a burning sensation over his left shoulder and arm and that he will immediately take a cold shower after his rugby training; see @fig:boy-pain. #note([ #figure( image("images/body with pain.jpg"), caption: [The person with shoulder pain and burning sensation @boy-image.] ) <fig:boy-pain> ], dy:-1in, numbered: false) The friend, who is a medical student, inquires about the pain and asks how long he had the pain and if it was getting worse. The person replies that he had been experiencing this pain for the past two weeks and it was made worse by coughing or sneezing. The student touched his friend's right shoulder and the person frowned with pain. His friend immediately took him to the neurology clinic. The student told the neurologist about the weakness of his friend's right deltoid and biceps brachii muscles and the hyperesthesia in the same area. The neurologist asks the medical student about a differential diagnosis. The student replies that in his opinion the patient has spondylosis of the vertebral levels C5, C6 and C7. This could be because the patient is an athlete. The neurologist is impressed by the student's answer and praises his observational and medical skills. The neurologist turns to you and inquires how this medical student reached a diagnosis. What do you say? == Relavent Anatomical Background The patient was suffering from spondylosis, which is a general term used for degenerative changes in the vertebral column. Due to the patient's extensive exercise and using his body to its limits in athletics, the vertebral column has degenerated. Bone spurs#note([These are bone outgrowths that usually tend to form over joints due to extensive use of the joint. The cause is not known but they generally only form over joints. The formation is not concerning on its own but this growth can immobilized joints or press on nerves as is the case with our patient.], dy:-1.9in) (or Osteophytes) have formed over the intervertebral foramina with pressure on the nerve roots See @fig:spine-spondylosis. #note([ #figure( image("images/spine_spondylosis.jpg"), caption: [X-ray showing bone outgrowths at the Lumbar spine level @x-ray.], ) <fig:spine-spondylosis> ], dy:0in, numbered: false) The burning pain and hyperesthesia was due to the pressure on the posterior nerve roots. The muscle weakness was due to the compression of the anterior (motor) nerve roots. Coughing or sneezing also increase the pressure within the vertebral column and result in further pressure on the nerve roots. The Deltoid muscle is innervated by spinal nerves C5 and C6 and the biceps brachii muscle is innervated by C5, C6 and C7. This knowledge is the reason why the medical student could pinpoint the spinal cord levels where the degeneration had occured. #figure( image("images/Brachial_plexus_from_spine.png"), caption: [The spinal nerves C5 to T1 are the nerves that innervate the muscles of the arm and the hands#note([This image shows the .], dy:-1.9in) @brachial-plexus.] ) #wideblock[ This knowledge of which spinal nerve innervates which muscle (or muscles) is known as that nerve's myotome. The myotome of all the nerves that innervate the upper limb (the arm and the hands) is shown in @fig:myotome. Knowing all of the nerves and their spinal cord levels is not of extreme importance right now but a general understanding is invaluable. As an example, knowing that the shoulder area is innervated by C3 and C4 spinal nerves is enough. #figure( image("images/brachial plexus myotome.png"), caption: [The myotome of all the nerves innervating the arm and hands. These nerves collectively come from the brachial plexus. @myotome] ) <fig:myotome> ] = Case 2 == Presentation A 76-year-old woman presented to the hospital with progressive difficulty walking. Initially, she had been able to ambulate with the assistance of a cane, but over the last day, she became unable to walk altogether. Upon examination, both lower extremities exhibited muscular weakness, increased muscle tone, and hyperreflexia, particularly in the knees where the knee jerk reflex was exaggerated. #note([ #figure( image("images/patient-2.jpg"), caption: [A woman being examined by a doctor for her legs. @patient-2] ) ], dy:-1in, numbered:false) Sensory examination revealed a loss of pain sensation bilaterally below the level of the fifth thoracic dermatome. Additionally, proprioception in both great toes was impaired, and vibratory sense was absent below the level of the fifth thoracic segment. Suggest a possible diagnosis and what the treatment plan will be. How is pain conducted in the spinal cord and how is vibrational sense conducted. Comment also on the fact as to why the patient had difficulty walking. == Relevant Anatomical Background Radiological Examination showed a small swelling at the level of the first lumbar vertebra. Histological Examination revealed that it was a meningioma. The tumor was removed by performing a laminectomy of the first, second and third lumbar vertebrae and the patient started to recover. Initially walking with a stick and later without one. The lateral spinothalamic tracts are responsible for pain conduction. Postural and vibrational sense is transmitted in the posterior white column in the fasciculus cuneatus (for the upper limb) and the fasciculus gacilis (for the lower limb). The difficulty in walking was due to the pressure on the corticospinal tracts in the lateral white column. This ultimately resulted in the paralysis of the muscles of the lower limbs. Let us first start with pain conduction. It is conducted through the lateral spinothalamic tract. See @fig:tracts for an illustration. #wideblock([ #figure( image("images/spinothalamic tract.png"), caption: [Figure showing the spinal cord tracts. The spinothalamic tract is labelled at the bottom and is present on both sides @tracts.] ) <fig:tracts> ]) === Lateral Spinothalamic Tract #pagebreak()
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/math/matrix_00.typ
typst
Apache License 2.0
#import "/contrib/templates/std-tests/preset.typ": * #show: test-page // Test semicolon syntax. #set align(center) $mat() dot mat(;) dot mat(1, 2) dot mat(1, 2;) \ mat(1; 2) dot mat(1, 2; 3, 4) dot mat(1 + &2, 1/2; &3, 4)$
https://github.com/r8vnhill/keen-manual
https://raw.githubusercontent.com/r8vnhill/keen-manual/main/omp/definition.typ
typst
BSD 2-Clause "Simplified" License
The One Max Problem (OMP) is a fundamental optimization challenge that is frequently utilized as a benchmark within the field of evolutionary algorithms and other heuristic search strategies. Evolutionary algorithms, inspired by natural selection, such as genetic algorithms, and heuristic methods, which seek practical solutions at the expense of completeness, often leverage OMP to test their efficacy in navigating complex solution spaces. If you are familiar with genetic algorithms, you may wish to skip directly to @omp-impl. == The Core Challenge Consider the task described below: #quote(block: true)[ Given a binary string $x = (x_1, x_2, ..., x_n)$ of length $n$, where each $x_i$ is either 0 or 1, identify a binary string that maximizes the sum of its bits (essentially, the count of ones). ] For instance, in a binary string `1101`, the sum of its bits is 3, as there are three `1`s. The goal is to maximize this sum. == Defining Fitness The fitness function, $phi(x)$, crucial for evaluating potential solutions, is defined as: $ phi(x) = sum_(i = 1)^n x_i $ <omp_fitness> This function tallies the `1`s in the binary string. Achieving a fitness score equal to $n$ signifies an optimal solution, where every bit is `1`. The choice of this fitness function is intuitive, as it directly quantifies the objective of the OMP, making it an ideal measure for optimization. == The Significance of Unimodality OMP is characterized as a unimodal problem, which means it contains a singular peak or optimal solution in its landscape - all ones in the binary string. This feature simplifies the search process since any improvement in fitness unequivocally moves a solution closer to the global optimum. However, it's this simplicity that also makes OMP an intriguing test case, contrasting with multimodal problems that contain numerous local optima, complicating the path to the global maximum. == Navigating the Solution Space Given a string length $n$, the solution space, comprising $2^n$ potential strings, expands exponentially. This vastness renders exhaustive search impractical for large $n$. Efficient optimization algorithms, such as genetic algorithms, employ mechanisms like crossover and mutation - inspired by biological evolution - to explore this space creatively and efficiently, avoiding the computational cost of evaluating every possible solution. == Broader Implications While OMP serves primarily as a theoretical benchmark, the strategies and insights derived from solving it are applicable to more complex, real-world problems. For instance, the principles of incremental improvement and exploration versus exploitation, critical in solving OMP, are equally relevant in optimizing network configurations, financial portfolios, and many other domains where optimal solutions are sought within immense search spaces.
https://github.com/Enter-tainer/typstyle
https://raw.githubusercontent.com/Enter-tainer/typstyle/master/tests/assets/typstfmt/136-raw.typ
typst
Apache License 2.0
- ``` my beautiful raw block ! ``` - #{ let raw_block = ``` another beautiful block ! ``` } A code block: ```rust if b { let x = 2; } ``` #text[ J'ai fait un snippet neovim qui crée des banners ! ``` ////////////////////// // This is a banner // ////////////////////// ```]
https://github.com/SWATEngineering/Docs
https://raw.githubusercontent.com/SWATEngineering/Docs/main/src/2_RTB/VerbaliInterni/VerbaleInterno_231221/content.typ
typst
MIT License
#import "meta.typ": inizio_incontro, fine_incontro, luogo_incontro #import "functions.typ": glossary, team #let participants = csv("participants.csv") = Partecipanti / Inizio incontro: #inizio_incontro / Fine incontro: #fine_incontro / Luogo incontro: #luogo_incontro #table( columns: (3fr, 1fr), [*Nome*], [*Durata presenza*], ..participants.flatten() ) = Sintesi Elaborazione Incontro /*************************************/ /* INSERIRE SOTTO IL CONTENUTO */ /*************************************/ == Ampliamento delle _Norme di Progetto_ L'incontro si è aperto con una breve discussione riguardante la necessità di normare l'utilizzo di alcune automazioni realizzate recentemente dal team. In particolare, si è deciso di inserire una descrizione pertinente all'aggiornamento del contenuto del sito vetrina #link("https://swatengineering.github.io/") ogni qual volta vengono apportate modifiche al branch "main" della repository documentale. Questo riguarda anche lo script di verifica della corrispondenza tra i termini marcati come termini di glossario in un documento e quelli effettivamente presenti all'interno del _Glossario v1.0_ e lo script di generazione di tabelle e grafici relativi al consuntivo di ciascuno sprint all'interno del _Piano di Progetto v1.0_. == Modifica del _Piano di Progetto_ Il team, constatando che la pianificazione e i preventivi redatti per ciascun sprint fino alla conclusione del progetto (ovvero la terza revisione CA) non rispecchiano più l'attuale progresso del lavoro, ha deciso di eliminare la pianificazione a lungo termine dal _Piano di Progetto v1.0_ e di sostituirla con una pianificazione a breve termine (2 sprint in avanti). Le ragioni principali che hanno motivato questa scelta sono le seguenti: - Pianificazione e relativi preventivi a lungo termine sono stati realizzati al termine del secondo sprint quando il team non aveva ancora avuto tempo a sufficienza per poter fare una stima accurata della propria velocità di progressione e della portata della frazione di progetto da portare a termine in vista della prima revisione RTB. Di conseguenza, la pianificazione risultava poco flessibile e del tutto svincolata dalla realtà, fornendo inoltre una stima poco precisa della distribuzione delle ore complessive dedicate alle 3 milestone principali o revisioni; - La mancanza di flessibilità della pianificazione rende difficile modificarla nel caso in cui, come si è verificato, ci sia uno slittamento o un ritardo nel portare a termine il lavoro preventivato per una milestone di particolare importanza come può esserlo la prima revisione RTB. Nonostante il team avesse inizialmente pianificato di sostenere la revisione entro la fine di dicembre, la necessità di apportare modifiche approfondite e rivedere l'intera documentazione ha comportato un ritardo fino a metà gennaio circa. Pertanto, è indispensabile rendere la pianificazione più flessibile per affrontare imprevisti di questo genere; - La pianificazione deve anche essere sufficientemente flessibile da poter cambiare il quantitativo o la ripartizione delle ore preventivate per ruolo negli sprint futuri senza dover modificare fondamentalmente tutto fino al termine del progetto. Il team ha constatato che le ore inizialmente previste per il ruolo di Amministratore sono nettamente insufficienti per coprire le esigenze di redazione della documentazione, in particolare le _Norme di Progetto v1.0_ e il _Piano di Qualifica v1.0_. Di conseguenza, è necessario dedicare più ore a questo ruolo, evitando così di limitare l'uso di tali ore solo per rispettare la pianificazione iniziale. == Revisione in stile "walkthrough" dell'_Analisi dei Requisiti_ Avendo sostanzialmente ultimato la stesura dell'_Analisi dei Requisiti v1.0_, il team ha deciso di iniziarne la revisione in stile "walkthrough" o "lettura a pettine" in modo da individuare eventuali errori o inconsistenze e correggerli tempestivamente, dato che questo documento è il principale oggetto della revisione RTB assieme al PoC. == Inizio della presentazione per la revisione RTB Come ultimo punto il team ha discusso della necessità di cominciare a impostare il contenuto della presentazione RTB, compito che è stato affidato al Responsabile. == Assegnazione dei ruoli Su proposta dei componenti è stata assegnata la seguente distribuzione dei ruoli: - <NAME>: Analista, Amministratore; - <NAME>: Programmatore, Verificatore; - <NAME>: Amministratore, Verificatore; - <NAME>: Amministratore; - <NAME>: Responsabile, Amministratore; - <NAME>: Amministratore, Verificatore.
https://github.com/GeorgeDong32/GD-Typst-Templates
https://raw.githubusercontent.com/GeorgeDong32/GD-Typst-Templates/main/templates/exereport.typ
typst
Apache License 2.0
#import "../functions/style.typ": * #import "../functions/booktab.typ": * #import "../functions/dirac.typ": * #let fonts = ( text: ("Times New Roman", "SimSun"), sans: ("Times New Roman", "SimSun"), code: ("Cascadia Code", "Consolas", "SimSun"), ) #let textbf(it) = block( text( font: fonts.sans, weight: "bold", it ) ) #let textit(it) = block(text(style: "italic", it)) #let FS1 = 26pt #let FS2 = 21pt #let FS3 = 15.75pt #let FS4 = 14pt #let FS4S = 12pt #let CoverB = 0.6em #let report( name: "Test", stdid: "11223344", coursename: "Typst实验", expname: "实验一 Typst入门", body ) = { set page(paper: "a4", margin: (top: 2.54cm, bottom: 2.54cm, left: 2.54cm, right: 2.54cm), header: [ #set text(10pt) #coursename#h(2em)#expname#h(1fr)#name#h(2em)#stdid ]) set text(font: fonts.text, lang: "zh", size: FS4S) show raw.where(block: true): block.with( fill: rgb(248, 248, 248), inset: (x: 1.25em, y: 1em), width: 100%, radius: 4pt, ) show raw.where(block: true): par.with( first-line-indent: 0em, justify: true, leading: 8pt, ) show raw.where(block: false): box.with( fill: rgb(248, 248, 248), inset: (x: 5pt, y: 0pt), outset: (y: 4pt), radius: 3pt ) show raw: text.with( font: fonts.code, size: 1em, ) show heading: it => [ // Cancel indentation for headings of level 2 or above #set par(first-line-indent: 0em, hanging-indent: 2em) #let sized_heading(it, size, weight, mt, mb, ) = [ #set text(size, weight: weight) #v(mt) #if it.numbering != none { counter(heading).display() h(0.1em) } #text(size, weight: weight, it.body) #v(mb) ] #if it.level == 1 { [ #set text(16pt, weight: "regular") #v(0.5em) #counter(heading).step(level: 1) #context counter(heading).display("一、") #it.body #v(0.3em) ] } else if it.level == 2 { [ #set text(14pt, weight: "regular") #v(0.2em) #counter(heading).step(level: 2) #context counter(heading).display("1.1") #h(0.2em) #it.body #v(0.3em) ] } else if it.level == 3 { [ #set text(12pt, weight: "regular") #v(0.2em) #counter(heading).step(level: 3) #context counter(heading).display("1.1") #h(0.2em) #it.body #v(0.3em) ] } else { [ #set text(12pt, weight: "regular") #v(0.2em) #counter(heading).step(level: 4) #context counter(heading).display("1.1") #h(0.2em) #it.body #v(0.3em) ] } ] show link: underline let fieldname(name) = [ #set align(right + horizon) #set text(font: fonts.text) #name ] let fieldvalue(value) = [ #set align(left + horizon) #set text(font: fonts.text) #value ] counter(heading).update(4) body } #let title(content: "") = align(center)[ #v(0.8em) #set text(FS3) #content #v(1.35em) ]
https://github.com/YuxuanQin/typst-template
https://raw.githubusercontent.com/YuxuanQin/typst-template/master/README.md
markdown
# typst 模板 [typst](https://typst.app) 是前年冬天发起的年轻项目,旨在取代 `LaTeX` 的地位,其语法之简易令人喜爱不已!因此,我尝试制作了本模板,以供将来使用。 目前,本模板还不完善。 --- typst 仍在开发中,它的亮点基本在于语法简易,近来确有长足进展,能制作一部分与 `LaTeX` 媲美的文档,甚至在论文排版方面也有模有样。**然而**,它还不太成熟,很显然不能与 `LaTeX` 这样的软件巨兽相比较,同时也存在崩溃的风险。 (虽然我 `LaTeX` 崩溃次数更多)
https://github.com/JakMobius/courses
https://raw.githubusercontent.com/JakMobius/courses/main/mipt-os-basic-2024/sem01/main.typ
typst
#import "@preview/polylux:0.3.1": * #import "@preview/cetz:0.2.2" #import "../theme/theme.typ": * #import "./utils.typ": draw-compiler-lifecycle #show: theme #title-slide[ #align(horizon + center)[ = Базовые инструменты разработки АКОС, МФТИ 12 сентября, 2024 ] ] #show: enable-handout #slide[ #let row(image-path, link-url, link-text) = [ #white-box[ #box(baseline: 7pt)[#image(image-path, width: 30pt)] #link(link-url)[#link-text] ] ] #align(center + horizon)[ Ваш семинарист: #uncover((beginning: 2))[#text(45pt)[Артем]] #uncover((beginning: 2))[Так и запишите.] ] #uncover((beginning: 3))[ #place(bottom)[ #row("img/mail.png", "<EMAIL>")[*<EMAIL>*] ] #place(bottom + right)[ #row("img/telegram.png", "t.me/prostokvasha")[*\@prostokvasha*] ] ] ] #slide(header: [Ваши ассистенты:], place-location: horizon)[ #box(stroke: (left: black + 4pt), inset: (x: 15pt, y: 15pt))[ === <NAME> #box(baseline: 7pt, image("img/telegram.png", width: 30pt)) #link("t.me/tokreal")[ *\@tokreal* ] ] #box(stroke: (left: black + 4pt), inset: (x: 15pt, y: 15pt))[ === <NAME> #box(baseline: 7pt, image("img/telegram.png", width: 30pt)) #link("t.me/simpleus")[ *\@simpleus* ] ] ] #plain-slide[ #align(horizon + center)[ #image("img/what-is-acos.jpeg", width: 80%) ] ] #slide( header: [АКОС поможет вам глубже понимать вот это:], place-location: horizon + center, )[ #set text(size: 25pt) #cetz.canvas( length: 1cm, { import cetz.draw: * set-style( content: (padding: .2), fill: gray.lighten(70%), stroke: gray.lighten(70%), ) let element(base-color, inner-text) = { let background-color = color.mix((base-color, 20%), (white, 80%)) let stroke-color = color.mix((base-color, 50%), (black, 50%)) let text-color = stroke-color box( fill: background-color, radius: 20pt, width: 100%, height: 100%, stroke: 3pt + stroke-color, )[ #align(center + horizon)[ #text(fill: text-color, font: "Monaco", inner-text) ] ] } let width = 4 let margin = 3 let arr = ( (text: "exe", color: blue), (text: "OS", color: red), (text: "Железо", color: black), ) let x = 0 set-style(mark: (symbol: ">"), stroke: 3pt + black) for step in arr { content((x, 4), (x + width, 0), padding: 0)[ #element(step.color)[#step.text] ] if x != 0 { line((x - margin + 0.1, 2), (x - 0.1, 2)) } x = x + width + margin } }, ) ] #focus-slide[ #text(size: 40pt)[*Мотивационный пример*] ] #slide(header: [Общие утилиты], place-location: horizon)[ - #bash("man") : мануалы по чему угодно; - #bash("man man") : мануалы по мануалам; - #bash("touch") : создать файл; - #bash("mkdir") : создать директорию; - #bash("pwd") : вывести текущую директорию. - #bash("cd") : сменить директорию; - #bash("ls") : вывести содержимое директории. ] #slide( header: [Работа с файлами], place-location: horizon, )[ - #bash("nano") , #bash("micro") , #bash("vim") , #bash("emacs") : редакторы текста; - #bash("less") : быстрая навигация по файлу; - #bash("cat") : вывести содержимое файла; - #bash("grep") : найти какой-то текст в файле (директории); - #bash("find") : искать файлы по имени / дате создания / ...; - #bash("mv") : переместить / переименовать файл; - #bash("rm") : удалить файл / директорию. ] #slide(header: [Что делает нас программистами], place-location: horizon)[ - #bash("gcc") , #bash("clang") : компиляторы; - #bash("gdb") , #bash("lldb") : отладчики; - #bash("ld") : компоновщик; - #bash("strace") : перехватчик системных вызовов. ] #focus-slide[ #text(size: 40pt)[*Пользуйтесь консолью!*] #text(size: 20pt)[Это кажется неудобным только первый год.] ] #slide( header: [Как работает GCC], place-location: horizon + center, )[ #cetz.canvas( length: 1cm, { import cetz.draw: * set-style( content: (padding: .2), fill: gray.lighten(70%), stroke: gray.lighten(70%), ) let arr = ( (text: "Исходный код", color: blue, width: 5), // ( text: "Код без директив препроцессора", code: bash("gcc -E"), color: black, width: 7, ), // (text: "Ассемблерный код", code: bash("gcc -S"), color: black, width: 7), // (text: "Объектный файл", code: bash("gcc -c"), color: black, width: 5), // (text: "Исполняемый файл", color: blue, width: 6), // ) draw-compiler-lifecycle(arr) }, ) ] #slide( header: [Как работает Clang], place-location: horizon + center, )[ #cetz.canvas( length: 1cm, { import cetz.draw: * set-style( content: (padding: .2), fill: gray.lighten(70%), stroke: gray.lighten(70%), ) let arr = ( (text: "Исходный код", color: blue, width: 5), // ( text: "Код без директив препроцессора", code: bash("clang -E"), color: black, width: 7, ), // ( text: "Байткод LLVM", code: bash("clang -S -emit-llvm"), color: black, width: 9, ), // (text: "Объектный файл", code: bash("clang -c"), color: black, width: 5), // (text: "Исполняемый файл", color: blue, width: 6), // ) draw-compiler-lifecycle(arr) }, ) ] #slide( header: [Директивы препроцессора], place-location: horizon, background-image: none, )[ #code(numbers: true)[```c #define MACRO 42 // Определение макросов #include "my-header.h" // Включение других файлов с кодом #ifdef WIN32 // Проверка платформы #error Please, install Linux // Ошибки #endif #ifndef DEBUG // Условная компиляция void debug_function() { /* noop */ } #else void debug_function() { printf("debug_function called!\n"); } #endif ```] Макросы также можно определять флагами компилятора: #bash("gcc -D<MACRO_NAME>[=VALUE] ...") ] #slide(header: [Хитрости с препроцессором], background-image: none)[ #code(numbers: true)[```c #include <stdio.h> #include <stdlib.h> // Макрос для вывода ошибки c названием файла и номером строки: #define BAIL(message) { \ printf("%s:%d: Fatal error: %s\n", __FILE__, __LINE__, message); \ exit(1); } // Пример использования: int* allocate_int_array(int n) { int* result = (int*)calloc(n, sizeof(int)); if(!result) BAIL("Cannot allocate memory"); return result; } ```] #codebox("main.c:12: Fatal error: Cannot allocate memory") ] #slide( header: [Исполняемые файлы], place-location: horizon, )[ Файл считается *исполняемым*, если он имеет права на исполнение. Linux *не смотрит на расширение*. Чтобы понять, как запускать файл, Linux смотрит на его начало: - #codebox("0x7f 0x45 0x4c 0x46") : магический заголовок ELF-файла; - #codebox("#!/usr/bin/python3") : shebang, указывает на интерпретатор; - Ни то, ни другое - файл запускается как шелл-скрипт. ] #slide( header: [#emoji.sparkles Магические заголовки #emoji.sparkles], place-location: horizon + center, )[ #let formats = ( (".png", "89 50 4E 47 0D 0A 1A 0A"), (".gif", "GIF87a, GIF89a"), (".jpg, .jpeg", "FF D8 FF"), (".rar", "52 61 72 21 1A 07"), (".pdf", "25 50 44 46 2D"), ) #let rows = formats.map( line => ( text(font: "Monaco")[#line.at(0)], line.at(1).split(", ").map(code => codebox(code)).join(" , "), ), ).flatten() #table( columns: (auto, auto), inset: (x: 20pt, y: 10pt), align: horizon, table.header([*Формат*], [*Заголовок*]), ..rows, ) #white-box[ 🔗 #link( "https://en.wikipedia.org/wiki/List_of_file_signatures", )[*wikipedia.org/wiki/List_of_file_signatures*] ] ] #slide( header: [Автоматизация сборки: #bash("make")], place-location: horizon, background-image: none, )[ - Отслеживает даты изменений файлов; - Пересобирает то, что устарело, пользуясь явным деревом зависимостей. #uncover( (beginning: 2), )[ *#colbox(color: green)[Плюсы:]* - Пересобирает только то, что нужно; - Гибкий, не привязан к компилятору, работает с произвольными командами. ] #uncover((beginning: 3))[ *#colbox(color: red)[Минусы:]* - Нужно заморачиваться с зависимостями заголовков; - ...И с кроссплатформенностью; - Если заморочиться со всем, мейкфайл будет огромным. ] ] #slide( header: [Автоматизация сборки: #bash("cmake")], place-location: horizon, background-image: none, )[ - Скриптоподобный язык для генерации схем сборки. #uncover((beginning: 2))[ *#colbox(color: green)[Плюсы:]* - Знает особенности разных платформ; - Удобнее организована работа с библиотеками (vcpkg, pkg-config, ...); - Сам разбирается с зависимостями между заголовками. ] #uncover((beginning: 3))[ *#colbox(color: red)[Минусы:]* - Нужно учить целый отдельный язык; - Менее гибкий. ] ] #slide( header: [Рекомендации по написанию кода], place-location: horizon, background-image: none, )[ - Code Style может быть любым, главное - *консистентным*; #set par(leading: 12pt) #uncover((beginning: 1))[ - #bash("clang-format") поможет следить за этим; ] #uncover((beginning: 2))[ - За чем он *не* сможет следить: - За названиями переменных; - За освобождением памяти; - За обработкой ошибок; - За структурой кода; - За наличием комментариев в нетривиальных местах. ] #uncover( (beginning: 3), )[ - Умные IDE и #bash("clang-tidy") могут помочь и с этим, но лучше следить самим; ] #uncover((beginning: 4))[ - Постарайтесь не пользоваться нейросетями. ] ] #slide( header: [Инструменты дебага], place-location: horizon, )[ #set image(width: 40pt); #set box(baseline: 15pt); #box[#image("img/weak-doge.png")] #codebox(lang: "c", "printf(\"debug 374\\n\")") : конечно, способ; #set image(width: 60pt); #uncover( (beginning: 2), )[ Но куда проще использовать: #box(baseline: 25pt, inset: (x: 10pt))[#image("img/strong-doge-2.png")] #bash("strace") : перехватчик системных вызовов; #box(baseline: 25pt, inset: (x: 10pt))[#image("img/strong-doge.png")] #bash("gdb") или #bash("lldb") : отладчики для пошагового выполнения программы. ] ] #slide( header: [Как пользоваться gdb], place-location: horizon, background-image: none, )[ - Запуск отладочной консоли: #bash("gdb ./a.out"); - #codebox(lang: "bash", "run") : запустить программу; - #codebox(lang: "bash", "break <where>") : поставить точку останова; - #codebox(lang: "bash", "next") : выполнить следующую строку; - #codebox(lang: "bash", "step") : войти в процедуру; - #codebox(lang: "bash", "print <expression>") : вывести значение выражения; - #codebox(lang: "bash", "quit") : выйти из gdb. #let prefixes = ("r", "b", "n", "p", "q") - Команды можно сокращать: (#prefixes.map(p => codebox(p)).join(" , ")); - #link( "https://darkdust.net/files/GDB%20Cheat%20Sheet.pdf", )[🔗 *GDB cheat-sheet*]. #colbox(color: gray)[⚠️] Нужно сгенерировать отладочную информацию: #bash("gcc -g main.c"); ] #slide( header: [Как пользоваться strace], place-location: horizon, background-image: none, )[ - Запуск программы с помощью strace: #bash("strace ./a.out"); - Основные команды: - #bash("strace -e trace=open,exec,... ./a.out") : фильтрация системных вызовов; - #bash("strace -e trace=%file ./a.out") : отслеживать только работу с файлами; - #bash("strace -p <pid>") : подключиться к уже запущенному процессу; - #bash("strace -o output.txt ./a.out") : сохранить вывод в файл; - #bash("strace -c ./a.out") : собрать статистику по системным вызовам; - #link("https://strace.io/")[🔗 *Strace docs*] ] #slide( header: "Утечка памяти...", place-location: horizon )[ *...это потеря указателя на выделенную память:* #code[```c char* buffer = calloc(1024, 1); read(input, buffer, 1024); write(output, buffer, 1024); // free(buffer); buffer = NULL; ```] #uncover((beginning: 2))[ *Менее очевидный пример:* #code[```c buffer = realloc(buffer, 2048); ```] ] ] #slide( header: "Утечки файловых дескрипторов", place-location: horizon )[ #code[```c int file = open("input.txt", O_RDONLY); read(file, buffer, 1024); // close(file) file = open("output.txt", O_WRONLY); write(file, buffer, 1024); ```] *Открытые дескрипторы занимают память в ядре, так что это тоже утечка памяти.* ] #slide( header: "Чем череваты утечки?", place-location: horizon )[ - *В утилите, которая работает недолго* - ничем, ресурсы освободятся при завершении программы; - *В долгоживущей программе (веб-сервер, игра, ...)* - рано или поздно ресурсы закончатся; - *В ядре* - вы повторите судьбу CrowdStrike; #uncover((beginning: 2))[ - *В домашке по АКОСу* - бан. ] ] #slide( header: [Поиск утечек памяти: #bash("valgrind")] )[ - Эмулирует процессор и следит за аллокациями; - Использование: #bash("valgrind your-awesome-program"). #uncover( (beginning: 2), )[ *#colbox(color: green)[Плюсы:]* - Находит много других проблем (например, чтение неинициализированной памяти). ] #uncover((beginning: 3))[ *#colbox(color: red)[Минусы:]* - Очень медленный (замедляет в 10-100 раз); - Многопоточные программы становятся однопоточными. ] ] #slide( header: [Поиск утечек памяти: LeakSanitizer], background-image: none, )[ - Санитайзер компилятора #bash("clang"); - Встраивает код для отслеживания аллокаций прямо в исполняемый файл; - Использование: #bash("clang -fsanitize=leak"). #uncover( (beginning: 2), )[ *#colbox(color: green)[Плюсы:]* - Почти не замедляет программу; - Поддерживает многопоточность. ] #uncover((beginning: 3))[ *#colbox(color: red)[Минусы:]* - Доступен только в #bash("clang"); - Использует #codebox("ptrace()") $=>$ не работает под дебаггером, под #bash("strace") , и в некоторых контейнерах. ] ] #slide( header: [#codebox("-fsanitize=")] )[ - #codebox("address") : поиск ошибок использования памяти (переполнения, use-after-free, ...); - #codebox("thread") : поиск гонок; - #codebox("undefined") : поиск неопределённого поведения; - #codebox("memory") : поиск использования неинициализированной памяти; - #codebox("leak") : поиск утечек памяти. #colbox(color: red)[⚠️] : *MemorySanitizer и LeakSanitizer доступны только в #bash("clang").* #colbox(color: red)[⚠️] : *Не все санитайзеры совместимы друг с другом* ] #focus-slide[ #text(size: 40pt)[*Интерактив*] ] #title-slide[ #place(horizon + center)[ = Спасибо за внимание! ] #place( bottom + center, )[ // #qr-code("https://github.com/JakMobius/courses/tree/main/mipt-os-basic-2024", width: 5cm) #box( baseline: 0.2em + 4pt, inset: (x: 15pt, y: 15pt), radius: 5pt, stroke: 3pt + rgb(185, 186, 187), fill: rgb(240, 240, 240), )[ 🔗 #link( "https://github.com/JakMobius/courses/tree/main/mipt-os-basic-2024", )[*github.com/JakMobius/courses/tree/main/mipt-os-basic-2024*] ] ] ]
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/contrib/templates/std-tests/preset.typ
typst
Apache License 2.0
#let test(lhs, rhs) = { assert(lhs == rhs, message: "Expected \(lhs) to equal \(rhs)") } #let print(..args) = {} #let conifer = rgb("9feb52") #let forest = rgb("43a127") #let test-page(content) = { set page(width: 120pt, height: auto, margin: 10pt) set text(size: 10pt) content }
https://github.com/jrihon/multi-bibs
https://raw.githubusercontent.com/jrihon/multi-bibs/main/chapters/02_chapter/discussion.typ
typst
MIT License
#import "../../lib/multi-bib.typ": * #import "bib_02_chapter.typ": biblio = Discussion #lorem(20)
https://github.com/nvarner/typst-lsp
https://raw.githubusercontent.com/nvarner/typst-lsp/master/editors/vscode/README.md
markdown
MIT License
# Typst LSP VS Code Extension A VS Code extension for Typst. ## Features - Syntax highlighting, error reporting, code completion, and function signature help - Compiles to PDF on save (configurable to as-you-type, or can be disabled) ## Usage Tips - This extension compiles to PDF, but it doesn't have a PDF viewer yet. To view the output as you work, install a PDF viewer extension, such as `vscode-pdf`. - To configure when PDFs are compiled: 1. Open settings - File -> Preferences -> Settings (Linux, Windows) - Code -> Preferences -> Settings (Mac) 2. Search for "Typst Export PDF" 3. Change the Export PDF setting - `onSave` makes a PDF after saving the Typst file - `onType` makes PDF files live, as you type - `never` disables PDF compilation ## Technical The extension uses [Typst LSP](https://github.com/nvarner/typst-lsp) on the backend.
https://github.com/KVM-Explorer/AssignmentTemplate
https://raw.githubusercontent.com/KVM-Explorer/AssignmentTemplate/main/example.typ
typst
#import "template.typ": * #show: template.with( title: [Full Title], short_title: "Short Title", description: [ ], date: datetime(year: 2024, month: 07, day: 15), authors: ( ( name: "xxx", ), ), affiliations: ( (id: "1", name: "University"), ), bibliography_file: "ref.bib", paper_size: "a4", cols: 1, text_font: "XCharter", code_font: "Cascadia Mono", accent: black, ) = Basic #lorem(10) - Blod *Blod* - italics _Text_ - block `block` = image #lorem(10) @image_demo #figure( image("images/smallpt.png",height: 200pt), caption: "image demo" )<image_demo> = code block #lorem(10) @code_block #figure( ```cpp std::cout << "Hello World" << std::endl; ```, caption: "code_block" )<code_block> = table #lorem(10) @table_demo #figure( table( columns: 3, table.header("T1","T2","T3"), "1","2","3" ), caption: "table demo" )<table_demo> #lorem(10) #ref(<Kolb2005smallpt>)
https://github.com/hongjr03/shiroa-page
https://raw.githubusercontent.com/hongjr03/shiroa-page/main/WXAPP/lab2/main.typ
typst
#import "template.typ": * #import "@preview/tablex:0.0.8": tablex, cellx, rowspanx, colspanx, vlinex, hlinex #import "@preview/cetz:0.2.2" #import "/book.typ": book-page #show: book-page.with(title: "实验 2:天气查询小程序") #let title = "实验 2:天气查询小程序" #let author = "洪佳荣" #let course_id = "移动软件开发" #let instructor = "高峰老师" #let semester = "2024夏季" #let due_time = "2024年8月20日" #let id = "22070001035" #show: assignment_class.with(title, author, course_id, instructor, semester, due_time, id) // #show figure.caption: it => [ // #set text(size: 9pt) // // #v(-1.5em) // #it // ] *源代码*:#link("https://github.com/hongjr03/MiniProgram")\ *博客*:暂未更新 = 实验目的 <实验目的> 1. 掌握服务器域名配置和临时服务器部署; 2. 掌握 wx.request 接口的用法。 = 实验步骤 #prob[API密钥申请和配置][ 首先从和风天气官网申请一个免费的 API 密钥,用于查询天气信息。 #figure(image("assets/2024-08-19-21-18-10.png", width: 60%)) #figure(image("assets/2024-08-19-21-21-22.png", width: 60%)) 根据官网的#link("https://dev.qweather.com/docs/configuration/api-config/")[API 配置文档],要调取这个接口,需要使用以下 URL: ``` https://devapi.qweather.com/v7/weather/now?location=xxx&key=xxx ``` 要正确使用这个接口,需要在微信开发者工具中配置服务器域名,将 `devapi.qweather.com` 添加到 request 合法域名中。 #figure(image("assets/2024-08-19-21-31-07.png", width: 80%)) ] #prob[创建小程序][ 这里直接基于上一次实验的空白小程序继续开发。复制项目后,下载老师提供的图标素材,放到项目的对应目录下。目录结构如下: ``` . ├─images │ ├─weather_icon_s1_bw │ ├─weather_icon_s1_color │ └─weather_icon_s2 ├─pages │ └─index └─utils ``` ] #prob[视图设计][ 根据实验文档,进行页面设计。主要包括: - 页面中央的城市显示、温度、天气图标 - 页面下方的天气数据列表 涉及的代码可见#link("https://github.com/hongjr03/MiniProgram/commit/0af9ff0dbcad2f83ff65d980f568c06c9477ca5e")[commit]。 #figure( image("assets/2024-08-19-23-43-01.png", width: 60%), ) ] #prob[逻辑实现][ 省市区信息 #figure(image("assets/2024-08-20-00-07-05.png", width: 60%)) 自动刷新天气 #figure(image("assets/2024-08-20-00-07-21.png", width: 60%)) 注意到一直出现返回400的错误,查看请求头。 #figure(image("assets/2024-08-20-00-08-04.png", width: 50%)) 发现 location 为一串字符,而根据#link("https://dev.qweather.com/docs/api/weather/weather-now/")[API 文档]可知 location 应该为查询地区的LocationID或以英文逗号分隔的经纬度坐标。注意到老师给的文件中 utils 文件夹下有一个城市的 LocationID 数组和一个转换的方法,于是将这个方法引入到 index.js 中。使用 ```js location: util.getLocationID(that.data.region[1]), ``` 传入 location 参数。 #figure(image("assets/2024-08-20-00-11-32.png", width: 60%)) 修复后,可以正常获取天气信息。返回的是一个 JSON 对象,需要解析后才能使用,结构为: ```json { "code":"200","updateTime":"2024-08-20T00:03+08:00", "fxLink":"https://www.qweather.com/weather/hangzhou-101210101.html", "now":{ "obsTime":"2024-08-20T00:00+08:00", "temp":"30", "feelsLike":"33", "icon":"151", "text":"多云", "wind360":"135", "windDir":"东南风", "windScale":"2", "windSpeed":"10", "humidity":"71", "precip":"0.0", "pressure":"999", "vis":"30", "cloud":"91", "dew":"25" }, "refer":{ "sources":["QWeather"], "license":["CC BY-SA 4.0"] } } ``` 根据返回的 JSON 对象,将数据渲染到页面上。 ```js that.setData({ temp: res.data.now.temp, weather: res.data.now.text, icon: res.data.now.icon, humidity: res.data.now.humidity, pressure: res.data.now.pressure, visibility: res.data.now.vis, windDir: res.data.now.windDir, windSpeed: res.data.now.windSpeed, windScale: res.data.now.windScale, }); ``` #figure(image("assets/2024-08-20-00-21-34.png", width: 60%)) ] = 程序运行结果 <程序运行结果> #grid(columns: (1fr, 1fr, 1fr))[ #image("assets/2024-08-20-00-24-18.png") ][ #image("assets/2024-08-20-00-24-26.png") ][ #image("assets/2024-08-20-00-24-34.png") ] = 问题总结与体会 <问题总结与体会>
https://github.com/dismint/docmint
https://raw.githubusercontent.com/dismint/docmint/main/linear/pset4.typ
typst
#import "template.typ": * #show: template.with( title: "PSET 4", subtitle: "18.06", pset: true, toc: false, ) #set math.mat(delim: "[") #set math.vec(delim: "[") Collaborators: <NAME> = 3.5.31 For the incidence matrix, the columns from left to right are the vertices and the rows from top to bottom are the edges: $ mat(-1, 1, 0, 0; -1, 0, 1, 0; 0, -1, 1, 0; 0, -1, 0, 1; 0, 0, -1, 1; -1, 0, 0, 1) $ To find the nullspace $bold(N)(A)$, we can see that using the incidence matrix as $A$ in $A x = b$ and setting $b$ to equal $0$, it must be the case that $x_1 = x_2, x_1 = x_3, x_2 = x_3, x_2 = x_4, x_3 = x_4, x_1 = x_4$, meaning that all of the values must be the same. Therefore, the nullspace is defined by $(c, c, c, c)$ vectors. Thus we know that the rank of the matrix must be equal to $4 - 1 = boxed(3)$ This is an example of a vector in the nullspace: $ mat(1, 1, 1, 1)^T $ This is an example of a vector in the column space: $ mat(-1, -1, 0, 0, 0, -1)^T $ This is an example of a vector in the row space: $ mat(-1, 1, 0, 0) $ This is an example of a vector in the left nullspace: $ mat(1, 1, 0, 1, 1, -2) $ = 4.1.7 We can use the multipliers $boxed((1, 1, -1))$ $ x_1 - x_2 &= 1\ x_2 - x_3 &= 1\ x_3 - x_1 &= -1 $ Adding all the equations together cancels out the variables on the left side and we are left with $0 = 1$ as desired. = 4.1.9 If $A^T A x$ = 0 then $A x = 0$. Reason: $A x$ is in the nullspace of $A^T$ and also in the *column space* of $A$ and those spaces are *Orthogonal*. Conclusion: $A x = 0$ and therefore $A^T A$ has the same nullspace as $A$. This key fact will be repeated when we need it. It must be the case that it is in the column space since the rows of $A$ are just the columns of $A^T$. The nullspace of $A^T$ is orthogonal to the column space of $A^T$ = 4.1.21 We can solve this with $A x = 0$ for: $ A = mat(1, 2, 2, 3; 1, 3, 3, 2) $ We know that nullspace of a matrix is orthogonal to the row space. The row space in this case is the plane that was desire. Thus by solving this equation we can find the nullspace of the matrix. $ mat(1, 2, 2, 3; 1, 3, 3, 2) &=\ &= mat(1, 2, 2, 3; 0, 1, 1, -1)\ $ We solve for both free variables. When $x_3 = 1$ and $x_4 = 0$ we get the vector $boxed(mat(0, -1, 1, 0))$ When $x_3 = 0$ and $x_4 = 1$ we get the vector $boxed(mat(-5, 1, 0, 1))$ Thus these are the two vectors that are orthogonal to the plane, and are also the nullspace of the aforementioned matrix. = 4.1.30 It must be the case that $dim("row space") + dim("nullspace") = "#rows"$. Thus we know that the most either of the left hand quantities can be is equal to $3$. However, we know that the row space must be at least $1$ assuming that the matrix is not empty. Therefore, the nullspace must be at most $2$, the same can be said about the nullspace to the row space. Thus, since each of them are capped by $2$, it must be the case that $"rank"(A) = "rank"(B) <= 4$. However, it is also possible that the matrices are zero. If this is the case, we know that because $A$ is a $3 times 4$ matrix, the highest dimension that the row space can be is $3$. Thus if the nullspace is zero, the row space is at most $3$, and the sum of ranks is still at most $4$. Similarly on the other side, if the row space is zero, the nullspace is at most $4$ since $B$ is a $4 times 5$ matrix, and the sum of ranks is still at most $4$. = 4.2.10 The projection is equal to: $ p = (1, 2) dot ((1, 0) dot (1, 2)) / ((1, 2) dot (1, 2)) = (1/5, 2/5) $ Then projecting back to $(1, 0)$: $ p = (1, 0) dot ((1/5, 2/5) dot (1, 0)) / ((1, 0) dot (1, 0)) = (1/5, 0) $ Now let us find the two projection matrices: $ P_1 &= A (A^T A)^(-1) A^T\ &= mat(1; 0) times mat(1, 0) = mat(1, 0; 0, 0)\ $ Now to find the other projection matrix: $ P_2 &= A (A^T A)^(-1) A^T\ &= (mat(1; 2) times mat(1, 2)) / 5 = mat(1/5, 2/5; 2/5, 4/5)\ $ Now let us multiply the two projection matrices: $ P_1 P_2 &= mat(1, 0; 0, 0) times mat(1/5, 2/5; 2/5, 4/5)\ &= mat(1/5, 2/5; 0, 0)\ $ The resulting matrix is NOT a projection matrix because squaring it does not yield itself. This is the image of all the projections: #bimg("imgs/projection.png") = 4.2.14 The projection matrix is equal to: $ A^T A &= mat(1, 0, 0, 0; 0, 1, 0, 0; 0, 0, 1, 0;) times mat(1, 0, 0; 0, 1, 0; 0, 0, 1; 0, 0, 0) = mat(1, 0, 0; 0, 1, 0; 0, 0, 1)\ (A^T A)^(-1) &= mat(1, 0, 0; 0, 1, 0; 0, 0, 1)\ A (A^T A)^(-1) A^T &= mat(1, 0, 0; 0, 1, 0; 0, 0, 1; 0, 0, 0) times mat(1, 0, 0; 0, 1, 0; 0, 0, 1) times mat(1, 0, 0, 0; 0, 1, 0, 0; 0, 0, 1, 0)\ &= mat(1, 0, 0; 0, 1, 0; 0, 0, 1; 0, 0, 0) times mat(1, 0, 0, 0; 0, 1, 0, 0; 0, 0, 1, 0)\ &= mat(1, 0, 0, 0; 0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 0)\ $ Thus the projection of $(1, 2, 3, 4)^T$ onto this matrix is: $ mat(1, 0, 0, 0; 0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 0) times mat(1, 2, 3, 4)^T = mat(1, 2, 3, 0)^T $ P is a projection matrix that does amazing things and has a shape of $4 times 4$. Its most notable achievements include projecting vectors onto $RR^3$. = 4.2.27 If the square of matrix $A$ is itself, then it must be the case that $A (A x) = A x$ Thus, $A$ acts as a projection matrix. We know that $A$ also has a rank equal to its number of rows and columns. Therefore, it must be the case that this projection matrix is of full rank. If that is the case, it *must* be the identity matrix, since it is the only matrix that is of full rank and is a projection matrix.
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/tidy/0.2.0/README.md
markdown
Apache License 2.0
# Tidy *Keep it tidy.* <!-- [![Tests](https://github.com/Mc-Zen/tidy/actions/workflows/run_tests.yml/badge.svg)](https://github.com/Mc-Zen/tidy/actions/workflows/run_tests.yml) --> **tidy** is a package that generates documentation directly in [Typst](https://typst.app/) for your Typst modules. It parses docstring comments similar to javadoc and co. and can be used to easily build a beautiful reference section for the parsed module. Within the docstring you may use (almost) any Typst syntax − so markup, equations and even figures are no problem! Features: - **Customizable** output styles. - Call your own module's code within the docstring, e.g., to **render examples**. - **Annotate types** of parameters and return values. - Automatically read off default values for named parameters. - Docstring tests. The [guide](./docs/tidy-guide.pdf) describes the usage of this module and defines the format for the docstrings. ## Usage Using `tidy` is as simple as writing some docstrings and calling: ```typ #import "@preview/tidy:0.2.0" #let docs = tidy.parse-module(read("my-module.typ")) #tidy.show-module(docs, style: tidy.styles.default) ``` The available predefined styles are currenty `tidy.styles.default` and `tidy.styles.minimal`. Custom styles can be added by hand (see the [guide](./docs/tidy-guide.pdf)). Furthermore, it is possible to access user-defined functions and use images through the `scope` argument of `tidy.parse-module()`: ```typ #{ import "my-module.typ" let module = tidy.parse-module(read("my-module.typ")) let an-image = image("img.png") tidy.show-module( module, style: tidy.styles.default, scope: (my-module: my-module, img: an-image) ) } ``` The docstrings in `my-module.typ` may now access the image with `#img` and can call any function or variable from `my-module` in the style of `#my-module.my-function`. This makes rendering examples right in the docstrings as easy as a breeze! ## Example A full example on how to use this module for your own package (maybe even consisting of multiple files) can be found at [examples](https://github.com/Mc-Zen/tidy/tree/main/examples). ```typ /// This function does something. It always returns true. /// /// We can have *markdown* and /// even $m^a t_h$ here. A list? No problem: /// - Item one /// - Item two /// /// - param1 (string): This is param1. /// - param2 (content, length): This is param2. /// Yes, it really is. /// - ..options (any): Optional options. /// -> boolean, none #let something(param1, param2: 3pt, ..options) = { return true } ``` **tidy** turns this into: <h3 align="center"> <img alt="Tidy example output" src="docs/images/my-module-docs.svg" style="max-width: 100%; padding: 10px 10px; box-shadow: 1pt 1pt 10pt 0pt #AAAAAA; border-radius: 4pt; box-sizing: border-box; background: white"> </h3> ## Changelog ### v0.2.0 - New features: - Add executable examples to docstrings. - Documentation for variables (as well as functions). - Docstring tests. - Rainbow-colored types `color` and `gradient`. - Improvements: - Allow customization of cross-references through `show-reference()`. - Allow customization of spacing between functions through styles. - Allow color customization (especially for the `default` theme). - Fixes: - Empty parameter descriptions are omitted (if the corresponding option is set). - Trim newline characters from parameter descriptions. - ⚠️ Breaking changes: - Before, cross-references for functions using the `@@` syntax could omit the function parentheses. Now this is not possible anymore, since such references refer to variables now. - (only concerning custom styles) The style functions `show-outline()`, `show-parameter-list`, and `show-type()` now take `style-args` arguments as well. ### v0.1.0 Initial Release.
https://github.com/Trebor-Huang/HomotopyHistory
https://raw.githubusercontent.com/Trebor-Huang/HomotopyHistory/main/intro.typ
typst
#import "common.typ": * = 前言 一个 $n$ 维球面 $SS^n$ 可以以多少种不同的方式套在一个 $m$ 维球面 $SS^m$ 上? 对于 $n = m = 1$ 的情况, 一个圆可以在另一个圆上顺时针或逆时针缠绕任意多圈, 因此可以被整数集 $ZZ$ 描述, 我们写作 $[SS^1 -> SS^1] = ZZ$. 对于 $n < m$ 的情况, 无论怎么摆放, $n$ 维球面都会滑落下来, 因此可以收缩成一个点. 因此 $[SS^n -> SS^m] = 0$. 对于 $n > m$, 看似情况仍然是平凡的. 但是 Hopf 在 1931 年发现了一种方式, 将 $SS^3$ 套在 $SS^2$ 上, 并且无法收缩到一个点. 具体来说, 考虑空间 $CC^2$ 里的单位球 $SS^3$, 映射 $(z, w) |-> z/w$ 将 $SS^3$ 映射到 $CC union {oo} tilde.eq SS^2$ 上. 这就是 *Hopf 映射*. 事实上, $[SS^3 -> SS^2] = ZZ$. 这告诉我们, 看似简单的球面在高维情况下有非常丰富的结构. #[ #set align(center) #set text(10pt) #block(width: 100%)[ #table( stroke: 0.5pt, inset: (x: 3pt, y: 7pt), columns: (0.5fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr), $attach(without, tr: m, bl: n)$, $1$, $2$, $3$, $4$, $5$, $6$, $7$, $8$, $1$, $ZZ$, $0$, $0$, $0$, $0$, $0$, $0$, $0$, $2$, $0$, $ZZ$, $0$, $0$, $0$, $0$, $0$, $0$, $3$, $0$, $ZZ$, $ZZ$, $0$, $0$, $0$, $0$, $0$, $4$, $0$, $ZZ_2$, $ZZ_2$, $ZZ$, $0$, $0$, $0$, $0$, $5$, $0$, $ZZ_2$, $ZZ_2$, $ZZ_2$, $ZZ$, $0$, $0$, $0$, $6$, $0$, $ZZ_12$, $ZZ_12$, $ZZ_2$, $ZZ_2$, $ZZ$, $0$, $0$, $7$, $0$, $ZZ_2$, $ZZ_2$, $ZZ times ZZ_12$, $ZZ_2$, $ZZ_2$, $ZZ$, $0$, $8$, $0$, $ZZ_2$, $ZZ_2$, $ZZ_2^2$, $ZZ_24$, $ZZ_2$, $ZZ_2$, $ZZ$, $9$, $0$, $ZZ_3$, $ZZ_3$, $ZZ_2^2$, $ZZ_2$, $ZZ_24$, $ZZ_2$, $ZZ_2$, $10$, $0$, $ZZ_15$, $ZZ_15$, $ZZ_24 times ZZ_3$, $ZZ_2$, $0$, $ZZ_24$, $ZZ_2$, )]] 从表格中可以看出一些规律, 例如第二列与第三列只有一处不同. 但是大部分仍然杂乱无章. 从简单的规则中产生的这些代数对象变幻莫测, 也正是同伦论的魅力之一. 同伦论也在其他领域中有着应用. 例如在拓扑学中有代数拓扑利用同伦信息分类拓扑空间, 在微分方程领域有同伦原理给出偏微分方程的解, 在代数几何领域有 $AA^1$ 同伦用于解决重大猜想, 等等. == 什么是同伦论? 从最广义的角度, 同伦是指两个数学对象不仅有严格相等, 还有一些更弱的等价的情况. 这种现象最早的例子是连续映射: 给定两个映射 $f, g : X -> Y$, 将 $f$ 连续地移动到 $g$, 就是一种同伦. 由于同伦本身也是数学对象, 往往又能讨论同伦之间的同伦, 以此类推. 这种现象不仅出现在拓扑中, 在代数学、物理学、甚至计算机科学中都有类似的现象, 从而可以应用同伦论的研究方法. 同伦论经过了多次改革, 利用新的语言重新表达、整合、统一了旧的成果. 在当代, 同伦论是研究生象、同伦谱、无穷范畴与相关的高阶代数结构等的学科. 这种高度抽象的语言一方面深刻地揭示了许多同伦现象的本质, 一方面也为学习造成了一定的困难. 理清其历史脉络, 对于同伦论中概念的学习有很大帮助. == 如何阅读本文 本文会尽量为遇到的数学概念作简单介绍. 在介绍早期的数学发现时, 会提到这些事物的当代观点. 这些部分如果读者没有相应的知识储备, 跳过无妨. 但是学过对应的部分后再来看, 自然会有更深的理解. 数学发现的历史不是单线进行, 而常常是由原本没有关系的多线研究, 最终汇聚到一点, 揭示出这些想法内在的联系. 因此, 本文虽然基本按照时间顺序排列, 但是局部上为了逻辑通畅, 会将互相承接的成果一并介绍. 一般对此会标明重要事件的时间, 锚定先后次序. 本文涉及的代数拓扑的部分, 读者可以参考 Hatcher 的课本 @Hatcher. Weibel @Weibel 有简明易懂的同调代数入门. 对于无穷范畴与高阶代数, 可以参考 @InfCatTextbook 作为入门教材, @HTT 与 @HA 作为参考. 同伦论与数学的各个领域, 甚至数学之外的学科都有许多交集, 因此本文不可能尽数涵盖. 对于这些内容, 会推荐一些参考文献以供阅读. // 推荐 @EpistemologyOfHomology
https://github.com/TGM-HIT/typst-diploma-thesis
https://raw.githubusercontent.com/TGM-HIT/typst-diploma-thesis/main/template/chapters/konzept.typ
typst
MIT License
#import "../lib.typ": * = Konzept Nachdem die Studie abgeschlossen und der Weg bestimmt ist soll nun ein Konzept oder eher noch ein Ablauf zur Lösung beschrieben werden. Hier finden sich Diagramme, Skizzen, Drehbücher, Mockups, ..., welche als Basis für die eigentliche Entwicklung verwendet werden.
https://github.com/VadimYarovoy/CourseWork
https://raw.githubusercontent.com/VadimYarovoy/CourseWork/main/main.typ
typst
#import "template.typ": * #show: project.with( type: "КУРСОВАЯ РАБОТА", subject: "«Выполнение работ проекта в рамках выбранных процессов\n жизненного цикла разработки» по дисциплине \"Основы процесса разработки качественного\n программного продукта и его метрология\"", authors: ( (role: [Выполнили:], name: [<NAME>.]), (role: [], name: [<NAME>.]), (role: [], name: [<NAME>.]), (role: [Группа:], name: [5130904/00104]), (role: [Преподаватель:], name: [<NAME>.]), // (role: [], name: [#text(1.1em,"«15» декабря 2023 г.")]), ), abstract: none ) #show raw.where(block: true): block.with( width: 100%, fill: luma(240), inset: 10pt, radius: 4pt, stroke: black, breakable: true ) // Задание 20 Рабочая бригада (project team) организована для добавления новой функциональности // (НФ) в ранее выпущенное приложение. Известно, что работа над 1-й версией ПП длилась // 3 месяца, в разработке участвовали 6 человек. Заказчик настаивает на выпуске следующей версии // ПП с НФ не позднее 2 месяцев после начала работы. Планируемый объём функционала для НФ // составляет около 10% от общего объёма функционала приложения. Для новой функциональности есть // список ключевых сценариев использования ПП с НФ ( Key Use Cases). Сохранились следующие // артефакты проекта после выпуска 1-й версии ПП: список сценариев использования ПП, исходный // код, модульные, интеграционные и приёмочные тесты, руководство пользователя. // оглавление - automatic // // введение // #include "typ/introduction.typ" // // основная часть (выполнение пунктов задания курсовой работы) // = Основная часть #include "typ/stage_1.typ" #include "typ/stage_2.typ" #include "typ/stage_3.typ" // #include "typ/stage_4.typ" // #include "typ/stage_5.typ" // #include "typ/stage_6.typ" // #include "typ/stage_7.typ" // // заключение // // #include "typ/conclusion.typ" // // Список литературы //
https://github.com/FkHiroki/ex-D2
https://raw.githubusercontent.com/FkHiroki/ex-D2/main/README.md
markdown
MIT No Attribution
![Deploy workflow](https://github.com/kimushun1101/typst-jp-conf-template/actions/workflows/release.yml/badge.svg) ![Deploy workflow](https://github.com/kimushun1101/typst-jp-conf-template/actions/workflows/gh-pages.yml/badge.svg) # typst-jp-conf-template Typst で日本語論文を書くときのテンプレートです. [vscode-typst.webm](https://github.com/kimushun1101/typst-jp-conf-template/assets/13430937/f227b85b-0266-417b-a24a-54f28f9a71b8) | ファイル | 意味 | | -------- | ----------------------- | | main.typ | 原稿の Typst ソースコード | | refs.*  | 参考文献ファイル | | ディレクトリ | 含まれるファイルの種類 | | ------------- | --------------------------- | | figs   | 論文に使用する画像ファイル | | libs   | 体裁を整えるライブラリファイル | 雰囲気を掴みたい場合には [こちらの Typst Web Application](https://typst.app/project/w41EH6HRoEsXp95IW_y1WK) をお試しください. コンパイル済みの資料を確認したいだけでしたら [こちらの GitHub Pages](https://kimushun1101.github.io/typst-jp-conf-template/typst-jp-conf.pdf) からお読みできます. ## 使用方法 GitHub に慣れていない方は,GitHub ページの `<>Code▼` から `Download ZIP` して展開してください. 慣れている方は,`git clone` したり `use this template` したり,適宜扱ってください. ### VS Code を使用する場合 1. [VS Code](https://code.visualstudio.com/) をインストール. 1. VS Code で `File`→`Open Folder` でこのフォルダーを開く. 2. 推奨拡張機能をインストール. Extensions (`Ctrl` + `Shift` + `X`) の `Search Extensions in Marketplace` のテキストボックスに `@recommended` と入力すると表示される,以下の拡張機能をinstall をクリック. - [Typst LSP](https://marketplace.visualstudio.com/items?itemName=nvarner.typst-lsp) - [Typst Preview](https://marketplace.visualstudio.com/items?itemName=mgt19937.typst-preview) 1. Explorer (`Ctrl` + `Shift` + `E`) から `main.typ` を開いた状態で,画面右上にある Typst Preview の方の ![view-icon](https://github.com/kimushun1101/typst-jp-conf-template/assets/13430937/a44c52cb-d23a-4fdb-ac9f-dc2b47deb40a) アイコンをクリック ( `Ctrl` + `K` のあと `V`) でプレビューを表示.[トップにある動画](#typst-jp-conf-template) の操作です. 2. `Ctrl` + `S` で PDF を生成. ### 他のエディターで執筆する場合 筆者は試せていませんが,他のエディターでも同様の拡張機能はありそうです. また,Typst のインストールおよびコンパイルはコマンドラインでも行えます. お使いの OS によってインストール方法が異なるため,詳細は[別ページ](docs/native-install.md)にまとめました. ## 参考元 - (unofficial) IFAC Conference Template for Typst : https://github.com/typst/packages/tree/main/packages/preview/abiding-ifacconf/0.1.0 - charged-ieee : https://github.com/typst/packages/tree/main/packages/preview/charged-ieee/0.1.0 - IEEE style as per the 2021 guidelines, V 01.29.2021. : https://editor.citationstyles.org/styleInfo/?styleId=http%3A%2F%2Fwww.zotero.org%2Fstyles%2Fieee - GitHub Pages へのデプロイ : https://github.com/yukukotani/typst-coins-thesis ## ライセンス 参考元にならってライセンスを付与しています. Typst ファイル : MIT No Attribution CSL ファイル : Creative Commons Attribution-ShareAlike 3.0 License
https://github.com/Nrosa01/TFG-2023-2024-UCM
https://raw.githubusercontent.com/Nrosa01/TFG-2023-2024-UCM/main/Memoria%20Typst/capitulos/6.SimuladorGPU.typ
typst
#import "../utilities/gridfunc.typ": * #import "../data/gridexamples.typ": * #import "../data/data.typ": * Ejecutar una simulación de partículas en la GPU supone un desafío. Como se explicó en la @simuladoresArena, y se mencionó en la @SimuladorCPU, los simuladores de arena de por sí no son paralelizables, ya que son dependientes del orden de ejecución y cada celda puede potencialmente modificar al resto de celdas de la matriz. Sin embargo, es posible, reescribiendo las condiciones de evolución de las partículas, transformar un simulador de arena en un autómata celular. Para ello, hay que volver del concepto de partícula al de celda. Esto supone que cada celda tiene que poder conocer su próximo estado mediante reglas locales con sus vecinas, y cada celda solo se modificará a sí misma. Tomando de nuevo el ejemplo de la @simuladoresArena de simulador básico con un solo tipo de partícula, la de arena, se va a mostrar como se puede convertir este simulador en un autómata celular con un comportamiento similar. Cada celda de este autómata celular solo tiene dos estados, vacío y arena. La partícula de arena necesita tener el siguiente comportamiento: - Si la celda de abajo esta vacía, me muevo a ella. - En caso de que la celda de abajo esté ocupada por una partícula de arena, intento moverme en dirección abajo izquierda y abajo derecha si las celdas están vacías. - En caso de que no se cumpla ninguna de estas condiciones, la partícula no se mueve. Ahora, tomando cada celda como entidad aislada, se puede lograr un comportamiento similar de la siguiente forma: - Si la celda es una partícula vacía, comprueba si encima suyo hay una partícla de arena, en cuyo caso, la celda se convierte en una partícula de arena. - Si la celda es una partícula de arena, solo existen dos opciones: - La celda inmediatamente inferior es vacía, por lo tanto puede caer. La celda actual se convierte en vacía. - La celda inferior es arena. En este caso, no es posible saber en el mismo paso de la simulación si la celda inferior también puede caer, por lo que la celda no se mueve y se queda como partícula de arena. Nótese que esto provoca que se produzcan artefactos visuales entre partículas al caer, de manera similar a lo que sucedía en la simulación de Lua con multithreading cuando una partícula se movía fuera de la región en la que se estaba ejecutando. Solo que en este caso, se producen entre todas las partículas en todo momento, ya que cada celda es un hilo de ejecución separado. Se puede observar que caen en líneas horizontales con espacios entre ellas. #grid_example("Artefactos visuales", (gpu_01,gpu_03,gpu_04), vinit: 0pt) Para realizar movimientos diagonales, se llevan a cabo las mismas comprobaciones que para el movimiento de caída vertical. Sin embargo, en lugar de verificar las celdas ubicadas arriba y abajo, se realizan comprobaciones en las direcciones arriba derecha, abajo izquierda y arriba izquierda, abajo derecha respectivamente. Desde el punto de vista de desarrollo, para poder ejecutar estas instrucciones de movimiento en la GPU, es necesario programar las reglas de movimiento dentro de un compute shader. Éste recibe como input el estado de la simulación actual y devuelve como output el estado de la simulación tras realizar uno de los tres movimientos. Cada comprobación de movimiento se realiza de manera separada, es decir, se ejecuta el compute shader de movimiento hacia abajo, y el output de éste lo procesa el compute shader de movimiento diagonal. Es necesario, a su vez, separar la lógica de movimiento abajo derecha y abajo izquierda ya que no sería posible realizar el movimiento hacia ambas diagonales en un solo paso de simulación. Dado el siguiente estado de la matriz: #grid_example("Ejemplo problema movimiento diagonal", (gpu_02,), vinit: -80pt) Tanto la partícula de arriba a la izquierda como la de arriba a la derecha pueden moverse a la celda central, sin embargo, la celda central, que es la que tiene que decidir si en el siguiente paso de la simulación existe materia o no en esa posición, no puede saber si alguna de esas partículas se va a mover a esa posición, ninguna de ellas, o ambas. Esta implementación, a cambio de ser la más rápida en ejecución, como ya se verá en la @ComparacionRendimiento, no aporta flexibilidad de ampliación alguna al usuario, ya que el código de lógica de movimiento se ejecuta mediante compute shaders escritos en .GLSL, lo cual es una tarea que puede ser complicada incluso para programadores que no tengan muchos conocimientos de informática gráfica y programacion de GPUs. A su vez, otro problema que presenta esta implementación es que el añadir partículas e interacciones entre ellas requiere mucho más trabajo que sus contrapartes en CPU, ya que requiere transformar las normas de movimiento y de interacciones entre partículas a reglas locales de celdas. La dificultad que presenta ampliar este sistema ha hecho que actualmente solo tenga implementada la partícula de arena. Se utilizó Vulkano @vulkano, una librería hecha en Rust que actúa como wrapper de Vulkan @vulkan, como librería gráfica para renderizar partículas debido a la flexibilidad y rendimiento que aporta el tener control sobre el pipeline gráfico a la hora del renderizado. Se hizo uso de Bevy @bevy, motor de videojuegos hecho en Rust, para implementar mecánicas básicas como el bucle principal de juego o procesamiento de input y de Egui @egui para crear la interfaz. Se puede ver un video de esta simulación haciendo click en el siguiente #link("https://youtu.be/XyaOdjyOXFU")[#text(blue)[enlace]]
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/meta/heading-02.typ
typst
Other
// Blocks can continue the heading. = #[This is multiline. ] = This is not.
https://github.com/rabotaem-incorporated/algebra-conspect-1course
https://raw.githubusercontent.com/rabotaem-incorporated/algebra-conspect-1course/master/sections/01-number-theory/03-modulo-eq.typ
typst
Other
#import "../../utils/core.typ": * == Сравнение по модулю #def[ Пусть $a, b, m in ZZ$. Говорят, что $ a equiv_(m) b & space.quad <==> \ a scripts(equiv)_m b & space.quad <==> \ a equiv b space.third (mod m) & space.quad <==> space.quad m divides (a - b) $ ] #prop[ + $equiv_(m)$ --- рефлексивно + $equiv_(m)$ --- симметрично + $equiv_(m)$ --- транзитивно + $a equiv_(m) b$, $d divides m ==> a equiv_(d) b$ + $a equiv_(m) b$, $ k in ZZ ==> k a equiv_(k m) k b$ + $a equiv_(m) b$, $k in ZZ ==> k a equiv_(m) k b$ (ослабленная версия предыдущего свойства) + $a_1 equiv_(m) b_1$, $a_2 equiv_(m) b_2 ==> a_1 plus.minus a_2 equiv_(m) b_1 plus.minus b_2$ + $a_1 equiv_(m) b_1$, $a_2 equiv_(m) b_2 ==> a_1 a_2 equiv_(m) b_1 b_2$ ] #notice[ Сравнение по модулю --- отношение эквивалентности. ]
https://github.com/madhank93/typst-resume-template
https://raw.githubusercontent.com/madhank93/typst-resume-template/main/README.md
markdown
### Commands i) Build ```sh typst compile --font-path ./assets/fonts resume.typ "output_resume.pdf" ``` ii) Dev ```sh typst watch --font-path ./assets/fonts resume.typ "output_resume.pdf" ```
https://github.com/yonatanmgr/university-notes
https://raw.githubusercontent.com/yonatanmgr/university-notes/main/0366-%5BMath%5D/03661111-%5BLinear%20Algebra%201A%5D/src/lectures/03661111_lecture_6.typ
typst
#import "/0366-[Math]/globals/template.typ": * #import "@preview/colorful-boxes:1.2.0": * #show: project.with( title: "אלגברה לינארית 1א׳ - שיעור 6", authors: ("<NAME>",), date: "18 בינואר, 2024", ) #set enum(numbering: "(1.א)") = תתי-מרחבים וקטוריים ומושגים נוספים === תזכורת יהי $V$ מ״ו מעל השדה $F$ ותהי $U seq V$ תת-קבוצה של $V$. נאמר ש-$U$ הוא ת״מ של $V$ אם $U$ מ״ו מעל $F$ ביחס לאותן פעולות של חיבור וכפל בסקלר מ-$F$. מספיק להראות: + $U$ סגורה לחיבור. + $U$ סגורה לכפל בסקלר מ-$F$. + $0 in U$, או לחילופין, $U != emptyset$. נוכל לדרוש במקום (1) ו-(2) *סגירות לצירופים לינאריים*, כלומר: $forall u, w in U, forall alpha, beta in F: alpha dot u + beta dot w in U$. == צירופים לינאריים יהי $V$ מ״ו מעל השדה $F$, ויהיו $v_1, v_2, dots, v_n in V$ וקטורים ב-$V$. לכל $lambda_1, lambda_2, dots, lambda_n in F$, הסכום: $ sum_(k=1)^n lambda_k v_k = lambda_1 dot v_1 + lambda_2dot v_2+ dots + lambda_n dot v_n $ נקרא *צירוף לינארי (צ״ל)*. == דוגמה: מרחב הפולינומים $ F [x] = {sum_(k=0)^n a_k x^k | n in ZZ_(>=0) and a_0,a_1, dots,a_k in F } $ מרחב זה מורכב מכל הצ״ל האפשריים של המונומים ${1, x, x^2, x^3, dots}$. חיבור פולינומים מתבצע בעזרת חיבור המקדמים בהתאמה: $ sum_(k=0)^n a_k x^k + sum_(k=0)^n b_k x^k = sum_(k=0)^n (a_k+b_k) x^k $ וכן כפל בסקלר מתבצע ע״י מכפלת המקדמים בסקלר זה: $ lambda dot (sum_(k=0)^n a_k x^k) = sum_(k=0)^n (lambda dot a_k) x^k $ #outlinebox(title: "זהירות!", centering: true, color: "red")[#align(center)[ פולינום בקורס שלנו הוא יותר מהערכים שהוא מחזיר! למשל, ב-$ZZ_2$ נתבונן בפולינום $x^2+x$: $ (x^2+x)(0) = 0 and (x^2+x)(1) = 0 $ אך פולינום זה *אינו* פולינום האפס, למרות שהם מחזירים את אותם הערכים. ]] #pagebreak() נתבונן באוסף הפולינומים ממעלה $n >=$ עבור $n in ZZ_(>=0)$: $ F_n [x] = {sum_(k=0)^n a_k x^k | a_0, dots, a_n in F} $ זוהי ודאי תת-קבוצה של $F_[x]$, אך האם זהו ת״מ? $ alpha dot (sum_(k=0)^n a_k x^k)+ beta dot (sum_(k=0)^n a_k x^k) = sum_(k=0)^n overbrace((alpha a_n + beta b_k), in F) x^k in F_n [x] => "ישנה סגירות לצ״ל" $ ופולינום האפס מתקבל מהצ״ל שבו כל המקדמים אפסים $sum_(k=0)^n 0 dot x^k$. כלומר, זהו אכן ת״מ! == האם איחוד וחיתוך של ת״מ נשאר ת״מ? נסתכל על $V=RR^2 = {binom(a,b) | a, b in RR}$ ועל תתי-המרחבים $U$ (ציר ה-$x$) ו-$W$ (ציר ה-$y$). - נראה כי $U nn W = {binom(0, 0)}$ הוא ת״מ טריוויאלי. - נראה כי $U uu W$ הוא מערכת הצירים, אך לא ת״מ כי אינו סגור לחיבור. === טענה יהי $V$ מ״ו מעל $F$ ויהיו $U,W$ זוג ת״מ של $V$. אז: + החיתוך $U nn W$ הינו ת״מ של $V$ גם כן. + האיחוד $U uu W$ הוא ת״מ של $V$ אם״ם $U seq W or W seq U$. === הוכחה + יהיו $v_1, v_2 in U nn W$ ויהיו $alpha, beta in F$. נתבונן בצ״ל $alpha v_1 + beta v_2 in U$ כי $v_1, v_2 in U$ ו-$U$ סגור לצ״ל, וגם $alpha v_1 + beta v_2 in W$ הרי ש-$v_1, v_2 in W$ ו-$W$ ת״מ וסגור לצ״ל. הראנו את הסגירות לצ״ל של $U nn W$. $U$ ת״מ ולכן $0 in U$ וגם $W$ ת״מ ולכן $0 in W$, כלומר $0 in U nn W$, והראנו שהחיתוך $U nn W$ ת״מ שהרי הוא מכיל את $0$ וגם סגור לצ״ל. + - $=>$: אם $U seq W$ אז $U uu W = W$ וזהו ת״מ, וגם אם $W seq U$ אז $V uu W = U$ וזהו ת״מ. - $arrow.l.double$: נניח ש-$U uu W$ ת״מ ונניח בשלילה ש-$U subset.eq.not W$ וגם $W subset.eq.not U$. $U subset.eq.not W$ ולכן קיים $u in U$ כך ש-$u in.not W$, גם $W subset.eq.not U$ ולכן יש $w in W$ כך ש-$w in.not U$. אבל, $u, w in U uu W$ וזהו ת״מ ולכן גם $u + w in U uu W$, בה״כ נניח $u + w in W$. נקבל $u = u+w+(-w) in W$, בסתירה להנחה. #QED == סכום של תתי-מרחבים וקטוריים יהי $V$ מ״ו מעל $F$ ויהיו $U, W$ זוג ת״מ של $V$. נגדיר את הסכום $U+W = {u+w | u in U and w in W}$. כאשר $U nn W = {0}$ נאמר *שהסכום ישר* ונסמן $U plus.circle W$. === טענה יהיו $U, W$ זוג ת״מ של מ״ו $V$ מעל השדה $F$, אז $U+W$ הינו גם כן ת״מ של $V$. זהו למעשה תת-המרחב המינימלי שמכיל את $U uu W$. === הוכחה יהיו $u_1 + w_1, u_2+w_2 in U + W$. כאן $u_1, u_2 in U and w_1, w_2 in W$. יהיו $alpha, beta in F$. נביט בצ״ל: $ alpha dot (u_1+w_1) + beta dot (u_2 + w_2) = underbrace(alpha u_1 + beta u_2, in U) + underbrace(alpha w_1 + beta w_2, in W) $ $U, W$ ת״מ ולכן $0 in U$ וגם $0 in W$ וכן: $0 = underbracket(0, in U) + underbracket(0, in W) in U + W$. #QED #outlinebox(title: "הערת אזהרה!", centering: true, color: "red")[#align(center)[ בחיבור ת״מ *אין* חוק צמצום, כלומר אם $u + w_1 = u + w_2$ *לא* ניתן להסיק מכך ש-$w_1 = w_2$. ]] === טענה יהיו $U, W$ זוג ת״מ של מ״ו $V$ מעל השדה $F$. אז: הסכום $U+W$ הוא סכום ישר אם״ם כל וקטור בסכום ניתן להביע בצורה *יחידה* כסכום של וקטור מ-$U$ ווקטור מ-$W$. === הוכחה - $arrow.l.double$: נניח ש-$U nn W = {0}$. יהיו $u_1, u_2 in U$ ו-$w_1, w_2 in W$ כך ש-$u_1+w_1 = u_2+w_2 in U + W$. נסיק: $u_1 - u_2 = w_2 - w-1 in U nn W = {0}$. כלומר: $u_1-u_2 =0 and w_1-w_2 =0$ ומכך $u_1=u_2 and w_1 = w_2$ והראנו את היחידות. - $arrow.r.double$: נניח שכל וקטור ב-$U+W$ ניתן להביע בצורה יחידה. נראה כי $0 in U nn W$ ויהי $v in U nn W$. נציג: $v = underbracket(v, in U)+underbracket(0, in W) = underbracket(0, in U) + underbracket(v, in W)$ ומיחידות ההצגה נסיק $v=0$. #QED = בסיס למרחב יהי $V$ מ״ו מעל $F$ ותהי $B$ קבוצת וקטורים מ-$V$. נאמר ש-$B$ הינו *בסיס* של $V$ אם כל וקטור ב-$V$ ניתן להבעה *בצורה יחידה* כצ״ל של איברי $B$. == דוגמאות + ${0}$ תת-המרחב הטריוויאלי. כאן הבסיס הוא הקב׳ הריקה (כי צ״ל של אפס וקטורים הוא וקטור האפס שניטרלי לחיבור). + + ב-$F^n$ נגדיר את *הבסיס הסטנדרטי* כך: $ E = {e_1 = mat(1;0;0;dots.v;0), e_2 = mat(0;1;0;dots.v;0), dots, e_n = mat(0;0;0;dots.v;1)} $ נראה כי: $ mat(lambda_1;lambda_2;dots.v;lambda_n) = lambda_1 dot mat(1;0;dots.v;0) + lambda_2 dot mat(0;0;dots.v;0) + dots + lambda_n dot mat(0;0;dots.v;1) $ 2. ב-$RR^2$: $ E= {mat(1;0), mat(0;1)}, B={mat(1;1), mat(1;-1)} \ mat(x;y) = x mat(1;0)+y mat(0;1)=frac(x+y, 2) mat(1;1)+ frac(x-y,2) mat(1;-1) $ 3. ב-$F[x]$ בסיס אחד יהיה מורכב מהמונומים: ${1,x,x^2, dots}$. #pagebreak() // #colorbox()[ // ] == משפט יהי $V$ מ״ו מעל שדה $F$. אז ל-$V$ קיים בסיס $B$, ובנוסף, לכל זוג בסיסים $B_1, B_2$ של $V$ מתקיים: $abs(B_1)=abs(B_2)$. === אתגר: נסו להוכיח את המשפט ב-$RR^2$. = פרישה של מרחב יהי $V$ מ״ו מעל $F$ ותהי $A seq V$. נגדיר את *הפרישה* של $A$ להיות אוסף כל הצירופים הלינאריים של וקטורי $A$. נסמן: $ "Sp" _F (A) = { sum_(k=0)^n lambda_k v_k | n in ZZ_(>=0), lambda_1, dots, lambda_n in F, v_1, dots, v_n in A } $ == טענה יהי $V$ מ״ו מעל $F$ ותהי $A seq V$, אז $"Sp"_F (A)$ הינו ת״מ של $V$. === הוכחה צ״ל של אפס וקטורים ייתן את וקטור האפס, ולכן $0 in "Sp"_F (A)$. סגירות לצ״ל מתקבלת בקלות: $ alpha (sum_(k=0)^n lambda_k v_k) + beta (sum_(k=0)^m mu_k u_k) = sum_(k=0)^n alpha lambda_k v_k +sum_(k=0)^m beta mu_k u_k in "Sp"_F (A) $ #QED
https://github.com/frectonz/the-pg-book
https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/162.%20work.html.typ
typst
work.html What Doesn't Seem Like Work? January 2015My father is a mathematician. For most of my childhood he worked for Westinghouse, modelling nuclear reactors.He was one of those lucky people who know early on what they want to do. When you talk to him about his childhood, there's a clear watershed at about age 12, when he "got interested in maths."He grew up in the small Welsh seacoast town of Pwllheli. As we retraced his walk to school on Google Street View, he said that it had been nice growing up in the country."Didn't it get boring when you got to be about 15?" I asked."No," he said, "by then I was interested in maths."In another conversation he told me that what he really liked was solving problems. To me the exercises at the end of each chapter in a math textbook represent work, or at best a way to reinforce what you learned in that chapter. To him the problems were the reward. The text of each chapter was just some advice about solving them. He said that as soon as he got a new textbook he'd immediately work out all the problems — to the slight annoyance of his teacher, since the class was supposed to work through the book gradually.Few people know so early or so certainly what they want to work on. But talking to my father reminded me of a heuristic the rest of us can use. If something that seems like work to other people doesn't seem like work to you, that's something you're well suited for. For example, a lot of programmers I know, including me, actually like debugging. It's not something people tend to volunteer; one likes it the way one likes popping zits. But you may have to like debugging to like programming, considering the degree to which programming consists of it.The stranger your tastes seem to other people, the stronger evidence they probably are of what you should do. When I was in college I used to write papers for my friends. It was quite interesting to write a paper for a class I wasn't taking. Plus they were always so relieved.It seemed curious that the same task could be painful to one person and pleasant to another, but I didn't realize at the time what this imbalance implied, because I wasn't looking for it. I didn't realize how hard it can be to decide what you should work on, and that you sometimes have to figure it out from subtle clues, like a detective solving a case in a mystery novel. So I bet it would help a lot of people to ask themselves about this explicitly. What seems like work to other people that doesn't seem like work to you? Thanks to <NAME>, <NAME>, <NAME>, <NAME>, and my father for reading drafts of this.<NAME>: All About ProgrammingFrench Translation
https://github.com/silverling/resume
https://raw.githubusercontent.com/silverling/resume/main/template.typ
typst
#let serif = ("Palatino Linotype", "Noto Serif CJK SC") #let sans = ("Libertinus Sans", "Noto Sans CJK SC") #let mono = ("Consolas") #let rem = 12pt #let infomation( wechat: none, email: none, phone: none, github: none, avatar: none, ) = { let _title = heading[个人信息] let _wechat = text( size: rem, )[微信:#text(font: mono)[#wechat]] let _email = text( size: rem, )[邮箱:#text(font: mono)[#email]] let _phone = text( size: rem, )[电话:#text(font: mono)[#phone]] let _github = text( size: rem, )[#text(font: sans)[Github]:#text(font: mono)[#github]] let _grid = grid( columns: (1fr, auto), row-gutter: 0.8em, _wechat, _email, _phone, _github, ) let _stack = stack( dir: ttb, spacing: 1em, _title, _grid, ) let _section = grid( columns: (75%, 1fr), column-gutter: 2em, pad(top: 1em, bottom: 1em, _stack), place(top + right, dy: -1em, image(avatar)), ) _section } #let experience(body, project: none, tag: none) = { rect(width: 100%, fill: rgb("#b1f2eb"))[*#project* #h(1fr) #tag] pad(x: .5em)[#body] } #let resume( name-zh: none, name-en: none, wechat: none, email: none, phone: none, github: none, avatar: none, doc ) = { // == meta == set page( paper: "a4", margin: (left: 15mm, right: 15mm, top: 10mm, bottom: 10mm), ) set text(lang: "zh", font: serif, size: rem) set par(leading: 1em) show heading: it => { set text(size: 1.5 * rem, weight: "semibold") stack( spacing: 0.7em, it, line(length: 100%), ) } // == layout == align( bottom, heading( stack( dir: ltr, spacing: 1em, text(size: 2 * rem, weight: "bold")[#name-zh], text(size: 1.5 * rem, weight: "bold")[#name-en] ) ) ) infomation( wechat: [#wechat], email: [#email], phone: [#phone], github: [#github], avatar: avatar, ) doc }
https://github.com/florianhartung/studienarbeit
https://raw.githubusercontent.com/florianhartung/studienarbeit/main/work/main.typ
typst
#import "dhbw_template/lib.typ": dhbw_template #show: dhbw_template.with( title: [Exploring WebAssembly for versatile plugin systems through the example of a text editor], author: "Hartung, Florian", course: "TINF22IT1", submissiondate: datetime(year: 2025, month: 04, day: 15), workperiod_from: datetime(year: 2024, month: 10, day: 15), workperiod_until: datetime(year: 2024, month: 04, day: 15), matr_num: 6622800, supervisor: "<NAME>, Prof. Dr.", abstract: include "abstract.typ", ) = Introduction = Fundamentals == WebAssembly == Plugin systems == Rust = Plugin system requirements = Related work // research and projects = WebAssembly for plugin systems == Overview == Choosing a plugin API // native/wat/wasi == Safety == Performance == Summary = Implementing a plugin system for a text editor == Requirements == Design == Implementation == Example plugin development // preferable in different languages to demonstrate interoperability == Verification and validation = Discussion = Conclusion
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/visualize/gradient-math_03.typ
typst
Apache License 2.0
#import "/contrib/templates/std-tests/preset.typ": * #show: test-page // Test on matrix #show math.equation: set text(fill: gradient.linear(..color.map.rainbow)) #show math.equation: box $ A = mat( 1, 2, 3; 4, 5, 6; 7, 8, 9 ) $
https://github.com/Isaac-Fate/booxtyp
https://raw.githubusercontent.com/Isaac-Fate/booxtyp/master/README.md
markdown
Apache License 2.0
# BooxTyp A Typst template for books. It is inspired by a LaTeX template [ElegantBook](https://github.com/ElegantLaTeX/ElegantBook). ## Example Document See [example.pdf](example/example.pdf) for an example PDF document. Its typ source is in [example.typ](example/example.typ). ## License This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.
https://github.com/ClazyChen/Table-Tennis-Rankings
https://raw.githubusercontent.com/ClazyChen/Table-Tennis-Rankings/main/history_CN/2019/WS-07.typ
typst
#set text(font: ("Courier New", "NSimSun")) #figure( caption: "Women's Singles (1 - 32)", table( columns: 4, [排名], [运动员], [国家/地区], [积分], [1], [陈梦], [CHN], [3433], [2], [刘诗雯], [CHN], [3361], [3], [朱雨玲], [MAC], [3352], [4], [孙颖莎], [CHN], [3306], [5], [王曼昱], [CHN], [3294], [6], [丁宁], [CHN], [3255], [7], [木子], [CHN], [3115], [8], [伊藤美诚], [JPN], [3100], [9], [平野美宇], [JPN], [3092], [10], [王艺迪], [CHN], [3088], [11], [#text(gray, "文佳")], [CHN], [3073], [12], [陈幸同], [CHN], [3072], [13], [顾玉婷], [CHN], [3070], [14], [何卓佳], [CHN], [3061], [15], [武杨], [CHN], [3057], [16], [韩莹], [GER], [3035], [17], [冯亚兰], [CHN], [3034], [18], [长崎美柚], [JPN], [3010], [19], [早田希娜], [JPN], [3009], [20], [石川佳纯], [JPN], [3007], [21], [#text(gray, "刘高阳")], [CHN], [2992], [22], [#text(gray, "胡丽梅")], [CHN], [2972], [23], [加藤美优], [JPN], [2962], [24], [杜凯琹], [HKG], [2959], [25], [金宋依], [PRK], [2953], [26], [傅玉], [POR], [2952], [27], [佐藤瞳], [JPN], [2937], [28], [冯天薇], [SGP], [2935], [29], [陈可], [CHN], [2928], [30], [郑怡静], [TPE], [2912], [31], [芝田沙季], [JPN], [2888], [32], [张瑞], [CHN], [2888], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Women's Singles (33 - 64)", table( columns: 4, [排名], [运动员], [国家/地区], [积分], [33], [徐孝元], [KOR], [2885], [34], [孙铭阳], [CHN], [2881], [35], [木原美悠], [JPN], [2873], [36], [安藤南], [JPN], [2863], [37], [CHA Hyo Sim], [PRK], [2860], [38], [李倩], [POL], [2855], [39], [张蔷], [CHN], [2852], [40], [GU Ruochen], [CHN], [2849], [41], [车晓曦], [CHN], [2846], [42], [桥本帆乃香], [JPN], [2845], [43], [伯纳黛特 斯佐科斯], [ROU], [2842], [44], [于梦雨], [SGP], [2839], [45], [石洵瑶], [CHN], [2831], [46], [杨晓欣], [MON], [2822], [47], [倪夏莲], [LUX], [2817], [48], [LIU Xi], [CHN], [2815], [49], [刘斐], [CHN], [2812], [50], [SO<NAME>], [HKG], [2807], [51], [田志希], [KOR], [2806], [52], [侯美玲], [TUR], [2804], [53], [梁夏银], [KOR], [2802], [54], [陈思羽], [TPE], [2797], [55], [森樱], [JPN], [2796], [56], [KIM Nam Hae], [PRK], [2795], [57], [李皓晴], [HKG], [2787], [58], [佩特丽莎 索尔佳], [GER], [2773], [59], [PESOTSKA Margaryta], [UKR], [2773], [60], [单晓娜], [GER], [2756], [61], [李佳燚], [CHN], [2753], [62], [LIU Hsing-Yin], [TPE], [2749], [63], [金河英], [KOR], [2741], [64], [EKHOLM Matilda], [SWE], [2739], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Women's Singles (65 - 96)", table( columns: 4, [排名], [运动员], [国家/地区], [积分], [65], [李洁], [NED], [2738], [66], [李佼], [NED], [2738], [67], [BILENKO Tetyana], [UKR], [2733], [68], [钱天一], [CHN], [2732], [69], [崔孝珠], [KOR], [2731], [70], [索菲亚 波尔卡诺娃], [AUT], [2729], [71], [刘佳], [AUT], [2725], [72], [阿德里安娜 迪亚兹], [PUR], [2720], [73], [CHENG Hsien-Tzu], [TPE], [2716], [74], [大藤沙月], [JPN], [2709], [75], [范思琦], [CHN], [2706], [76], [SAWETTABUT Suthasini], [THA], [2702], [77], [张墨], [CAN], [2699], [78], [妮娜 米特兰姆], [GER], [2697], [79], [李芬], [SWE], [2695], [80], [LIU Xin], [CHN], [2695], [81], [布里特 伊尔兰德], [NED], [2695], [82], [曾尖], [SGP], [2695], [83], [#text(gray, "MATSUZAWA Marina")], [JPN], [2680], [84], [浜本由惟], [JPN], [2678], [85], [#text(gray, "LI Jiayuan")], [CHN], [2677], [86], [GRZYBOWSKA-FRANC Katarzyna], [POL], [2673], [87], [申裕斌], [KOR], [2671], [88], [<NAME>], [HUN], [2665], [89], [李时温], [KOR], [2662], [90], [MAEDA Miyu], [JPN], [2661], [91], [YOO Eunchong], [KOR], [2659], [92], [HUANG Yingqi], [CHN], [2656], [93], [MIKHAILOVA Polina], [RUS], [2652], [94], [李恩惠], [KOR], [2651], [95], [MATELOVA Hana], [CZE], [2651], [96], [SHIOMI Maki], [JPN], [2650], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Women's Singles (97 - 128)", table( columns: 4, [排名], [运动员], [国家/地区], [积分], [97], [#text(gray, "<NAME>")], [JPN], [2650], [98], [LANG Kristin], [GER], [2646], [99], [伊丽莎白 萨玛拉], [ROU], [2636], [100], [<NAME>], [SGP], [2634], [101], [张安], [USA], [2631], [102], [SUN Jiayi], [CRO], [2624], [103], [POTA Georgina], [HUN], [2623], [104], [KIM Youjin], [KOR], [2623], [105], [森田美咲], [JPN], [2619], [106], [琳达 伯格斯特罗姆], [SWE], [2619], [107], [玛妮卡 巴特拉], [IND], [2618], [108], [邵杰妮], [POR], [2613], [109], [<NAME>], [KOR], [2611], [110], [WU Yue], [USA], [2610], [111], [小盐遥菜], [JPN], [2605], [112], [WINTER Sabine], [GER], [2603], [113], [#text(gray, "PARK Joohyun")], [KOR], [2600], [114], [<NAME> Daniela], [ROU], [2596], [115], [SOMA Yumeno], [JPN], [2596], [116], [#text(gray, "KATO Kyoka")], [JPN], [2594], [117], [BALAZOVA Barbora], [SVK], [2587], [118], [NARUMOTO Ayami], [JPN], [2585], [119], [HUANG Yi-Hua], [TPE], [2577], [120], [维多利亚 帕芙洛维奇], [BLR], [2572], [121], [LI Xiang], [ITA], [2570], [122], [郭雨涵], [CHN], [2568], [123], [<NAME>], [POL], [2568], [124], [<NAME>], [AUT], [2568], [125], [#text(gray, "SO Eka")], [JPN], [2565], [126], [VOROBEVA Olga], [RUS], [2564], [127], [#text(gray, "CHO<NAME>")], [PRK], [2564], [128], [<NAME>], [TPE], [2562], ) )
https://github.com/gRox167/typst-assignment-template
https://raw.githubusercontent.com/gRox167/typst-assignment-template/main/assignment_example.typ
typst
#import "template.typ": * #let title = "Assignment #4" #let author = "<NAME>" #let course_id = "CS101" #let instructor = "<NAME>" #let semester = "Spring 2023" #let due_time = "April 3 at 23:59" #set enum(numbering: "a)") #show: assignment_class.with(title, author, course_id, instructor, semester, due_time) #prob[ // + $A=mat(1,-1;-1,1;1,1)$ 1. when $min(norm(bold(x))_2)$, $bold(x) = bold(x^*)$ is the solution to the problem, which is $x^*=vec(1/sqrt(3),1/sqrt(3),1/sqrt(3))$ 2. We have a matrix $bold(A) = mat(1,1;1,1;1,0)$, the projection operator is $ bold(P) = bold(A)(bold(A)^T A)^(-1)bold(A)^T = mat(1/2,1/2,0;1/2,1/2,0;0,0,1), $ hence, $ bold(x^*) = bold(P) bold(v) = vec(1/2,1/2,1). $ 3. We have a matrix $bold(A) = mat(1,-1;-1,1;2,2)$, the projection operator is $ bold(P) = bold(A)(bold(A)^T A)^(-1)bold(A)^T = mat(1/2,-1/2,0;-1/2,1/2,0;0,0,1), $ hence, $ bold(x^*) = bold(P) bold(v) = vec(1/2,-1/2,0). $ ] #prob[ // + $ op("prox")_g (bold(y)) = arg min_(bold(x in RR ^n)) {1/2 norm(bold(x)-bold(y))^2 + g(bold(x))}. $ 1. we know that: $ prox_phi (z) = argmin_(x in RR) {1/2 norm(x-z)^2 + phi.alt(x-c)}. $ let $x prime =x-c$ $ op("prox")_phi (z) = argmin_(x in RR) {1/2 norm(x prime-(z-c))^2 + phi.alt(x'+c-c)}+c = op("prox")_phi.alt (z-c)+c. $ 2. if we want to $ f(x) = 1/2 norm(x-z)^2 + phi.alt(x)$ to be minimized, we need to find the $x$ that makes the derivative of the function equal to zero. we know $ diff f(x) = cases(x-z + lambda "when " x>0, [x-z - lambda,x-z + lambda] "when" x=0, x-z - lambda "when" x<0) $. Hence, let $ diff f(x) = 0 $, we have $ prox_phi.alt(z) = x^* = cases(z-lambda "when " z>lambda, [z-lambda,z+lambda] "when" z in [-lambda,lambda], z + lambda "when" z < -lambda) . $ 3. if $phi(x) = lambda abs(x-c)$, where $c in RR$ and $lambda>0$. Use the result from part a. $ prox_phi(z) = prox_phi.alt(z-c)+c = cases(z-lambda "when " z>lambda + c, [z-lambda,z+lambda] "when" z in [-lambda+c,lambda+c], z + lambda "when" z < -lambda+c) $ ] #prob[ 1. If we take the derivative of $1/2 norm(bold(x)-bold(x)^(t-1))^2 + gamma g(bold(x))$, we have $ bold(x^t) = prox_(gamma g)(bold(x)^(t-1)) = bold(x)^(t-1) - gamma nabla g(bold(x^t)) $ 2. By the convexity of $g$, we know that $g(bold(x)^(t)) +nabla g(bold(x^(t)))^T (bold(x)^(t-1)-bold(x^t))<= g(bold(x^(t-1)))$. Hence, we have $ g(bold(x)^(t)) <= g(bold(x^(t-1))) - nabla g(bold(x^(t)))^T (bold(x)^(t-1)-bold(x^t)) = g(bold(x^(t-1))) - gamma nabla norm(g(bold(x^(t))))^2_2 $ 3. because $bold(x^t) = bold(x)^(t-1) - gamma nabla g(bold(x^t))$ which is a gradient descent method, so $ -oo<g(bold(x)^t)<=g(bold(x)^(t-1)) $ and we have $ g(bold(x)^(t)) <= g(bold(x^(t-1))) - gamma nabla norm(g(bold(x^(t))))^2_2 $ hence $ 0<=gamma nabla norm(g(bold(x^(t))))^2_2<=0 $ if $ t arrow +oo $ ] #prob[ 1. because $ diff f(bold(x)) = {bold(v) in RR^n : f(bold(y))>= f(bold(x))+ bold(v)^T (bold(y)-bold(x)),forall bold(y) in RR^n} $ if $g(bold(x)) = theta f(bold(x))$, $ diff g(bold(x)) = {bold(v) in RR^n : g(bold(y))>= g(bold(x))+ bold(v)^T (bold(y)-bold(x)),forall bold(y) in RR^n} $ $ diff g(bold(x))={bold(v) in RR^n : theta f(bold(y))>= theta f(bold(x))+ bold(v)^T (bold(y)-bold(x)),forall bold(y) in RR^n} $ $ diff g(bold(x))={bold(v) in RR^n : f(bold(y))>= f(bold(x))+ bold(v)^T/theta (bold(y)-bold(x)),forall bold(y) in RR^n} $ $ diff g(bold(x))=theta {bold(v) in RR^n : f(bold(y))>= f(bold(x))+ bold(v)^T (bold(y)-bold(x)),forall bold(y) in RR^n} = theta diff f(bold(x)) $ 2. $ diff h(bold(x)) = {bold(v) in RR^n : f(bold(y))+g(bold(y))>= f(bold(x))+g(bold(x))+ bold(v)^T (bold(y)-bold(x)),forall bold(y) in RR^n} $ all of the elements that satisfy $ f(bold(y))>= f(bold(x))+ bold(v)^T (bold(y)-bold(x)),forall bold(y) in RR^n $ and $ g(bold(y))>= g(bold(x))+ bold(v)^T (bold(y)-bold(x)),forall bold(y) in RR^n $ are in the set $ diff h(bold(x)) $ hence $ diff f(bold(x)) + diff g(bold(x)) subset.eq diff h(bold(x)) $ 3. we know that $ diff norm(x)_1 = cases(1 "when " x>0, [-1,1] "when" x=0, -1 "when" x<0) $. hence $op("sgn")(x) in diff norm(x)_1$. ] #prob[ 2. Not differentiable at $bold(x)=bold(0)$, and $h$ is convex. 3. $ nabla [1/2 norm(bold(x)-bold(y))_2^2 + gamma lambda norm(x)_1 ] = cases(x-y + gamma lambda "when " x>0, [x-y - gamma lambda,x-y +gamma lambda] "when" x=0, x-y - gamma lambda "when" x<0) $. let it be $0$, we have $ prox_(gamma g(y)) = x^* = cases(y-gamma lambda "when " y>lambda , [y-gamma lambda,y+gamma lambda] "when" y in [-gamma lambda,gamma lambda], y + gamma lambda "when" y < -gamma lambda) . $ ```matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% load the variables of the optimization problem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% load('dataset.mat'); [p, n] = size(A); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% set up the function and its gradient %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% evaluate_f = @(x) (1/n)*sum(log(1+exp(-b.*(A'*x)))); evaluate_gradf = @(x) (1/n)*A*(-b.*exp(-b.*(A'*x))./(1+exp(-b.*(A'*x)))); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% parameters of the gradient method %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% xInit = zeros(p, 1); % zero initialization stepSize = 1; % step-size of the gradient method maxIter = 1000; % maximum number of iterations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% optimize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % initialize x = xInit; % keep track of cost function values objVals = zeros(maxIter, 1); % iterate for iter = 1:maxIter % update xNext = x - stepSize*evaluate_gradf(x); % evaluate the objective funcNext = evaluate_f(xNext); % store the objective and the classification error objVals(iter) = funcNext; fprintf('[%d/%d] [step: %.1e] [objective: %.1e]\n',... iter, maxIter, stepSize, objVals(iter)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % begin visualize data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % plot the evolution figure(1); set(gcf, 'Color', 'w'); semilogy(1:iter, objVals(1:iter), 'b-',... iter, objVals(iter), 'b*', 'LineWidth', 2); grid on; axis tight; xlabel('iteration'); ylabel('objective'); title(sprintf('GM (f = %.2e)', objVals(iter))); xlim([1 maxIter]); set(gca, 'FontSize', 16); drawnow; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % end visualize data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % update w x = xNext; end ``` ]
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/block-07.typ
typst
Other
// Content blocks also create a scope. #[#let x = 1] // Error: 2-3 unknown variable: x #x
https://github.com/IllustratedMan-code/nixconfig-wsl
https://raw.githubusercontent.com/IllustratedMan-code/nixconfig-wsl/main/assignments-typst/main.typ
typst
#import "@preview/titleize:0.1.0": titlecase #let author(name, affiliation: none, email: none) = (name: name, affiliation: affiliation, email: email) #let csvtable(csvdata) = { let data = csvdata.slice(1) table( columns: csvdata.first().len(), table.header(..csvdata.first()), ..csvdata.slice(1).flatten(), if csvdata.first().first() == "" { table.vline(x: 1) } else { table.vline(x: 1, stroke: none) }, ) } #let conf( title: none, subtitle: none, date: none, authors: (author([<NAME>], email: "<EMAIL>"),), titlepage: true, doc, ) = { if title != none { title = titlecase(title) } if subtitle != none { subtitle = titlecase(subtitle) } if date == none { date = datetime.today().display("[month repr:long] [day padding:none], [year]") } let style-number(number) = text(gray)[#number] show figure.where(kind: "code"): it => { it.supplement = [Code] } show raw.where(block: true): it => { let lang = none if it.lang != none { lang = [#upper(it.lang.first())#it.lang.slice(1)] } let codebox = block( outset: 0pt, stroke: black, radius: if lang != none { ( top-left: 5pt, top-right: 0pt, bottom-right: 5pt, bottom-left: 5pt, ) } else { 5pt }, inset: (x: 5pt, y: 5pt), grid( columns: 2, align: (right, left), gutter: 0.5em, ..it.lines.map(line => (style-number(line.number), line)).flatten() ), ) let langbox = box( stroke: black, inset: 3pt, outset: 0pt, radius: ( top-left: 5pt, top-right: 5pt, bottom-right: 0pt, bottom-left: 0pt, ), [ #set text(8pt) #lang ], ) set align(center) grid( columns: 1, align: (right), if lang != none { grid.header(langbox) }, codebox, ) } set page( paper: "us-letter", header: context { if counter(page).get().first() > int(titlepage) and title != none [ #title #h(1fr) #date #line(length: 100%) ] }, footer: [ #line(length: 100%) #authors.map(author => [#author.name]).join(",") #h(1fr) #counter(page).display() ], ) // quotes set quote(block: true, quotes: true, attribution: authors.first().name) show quote: quote => { set align(center) block( stroke: none, width: 80%, inset: 5pt, fill: rgb("#ffebcd"), radius: 5pt, { set align(left) quote }, ) } // tables set table(stroke: (x, y) => if y == 0 { (bottom: black) }) // // //figures show figure.caption: it => pad( left: 1cm, right: 2cm, align(left, par(hanging-indent: 1cm, justify: true, it)), ) let r = rect(height: 2pt, fill: black, width: 100%) // //heading show heading.where(level: 1): it => block( align( center, grid( columns: (1fr, auto, 1fr), align: horizon, gutter: 5pt, r, [#it], r, ), ), breakable: false, ) show heading.where(level: 2): it => block( align( left, grid( columns: (auto, 1fr), align: horizon, gutter: 5pt, [#it], rect(height: 1pt, fill: black, width: 100%), ), ), breakable: false, ) show heading.where(level: 3): it => underline(it) { set align(center) if titlepage and title != none { [ #text(17pt, weight: "bold", title) \ #if subtitle != none [ #text(15pt, weight: "semibold", subtitle) \ ] #text(12pt, weight: "bold", date) ] let count = authors.len() let ncols = calc.min(count, 3) for i in range(calc.ceil(count / ncols)) { let end = calc.min((i + 1) * 3, count) let is-last = count == end let slice = authors.slice(i * ncols, end) grid( columns: (1fr,) * ncols, row-gutter: 2pt, ..slice.map(author => [ #author.name \ #if author.affiliation != none { [#author.affiliation \ ] } #if author.email != none { link("mailto:" + author.email) } ]), ) if not is-last { v(16pt, weak: true) } } v(40pt, weak: true) } } doc }
https://github.com/dashuai009/dashuai009.github.io
https://raw.githubusercontent.com/dashuai009/dashuai009.github.io/main/src/content/blog/024.typ
typst
#let date = datetime( year: 2022, month: 3, day: 14, ) #metadata(( title: "陪审团人选", subtitle: [DP], author: "dashuai009", abstract: "", description: "poj上一道DP题。", pubDate: date.display(), ))<frontmatter> #import "../__template/style.typ": conf #show: conf == Description <description> In Frobnia, a far-away country, the verdicts in court trials are determined by a jury consisting of members of the general public. Every time a trial is set to begin, a jury has to be selected, which is done as follows. First, several people are drawn randomly from the public. For each person in this pool, defence and prosecution assign a grade from 0 to 20 indicating their preference for this person. 0 means total dislike, 20 on the other hand means that this person is considered ideally suited for the jury. Based on the grades of the two parties, the judge selects the jury. In order to ensure a fair trial, the tendencies of the jury to favour either defence or prosecution should be as balanced as possible. The jury therefore has to be chosen in a way that is satisfactory to both parties. We will now make this more precise: given a pool of n potential jurors and two values di (the defence’s value) and pi (the prosecution’s value) for each potential juror i, you are to select a jury of m persons. If J is a subset of {1,…, n} with m elements, then D(J ) = sum(dk) k belong to J and P(J) = sum(pk) k belong to J are the total values of this jury for defence and prosecution. For an optimal jury J , the value |D(J) - P(J)| must be minimal. If there are several jurys with minimal |D(J) - P(J)|, one which maximizes D(J) + P(J) should be selected since the jury should be as ideal as possible for both parties. You are to write a program that implements this jury selection process and chooses an optimal jury given a set of candidates. == Input <input> The input file contains several jury selection rounds. Each round starts with a line containing two integers n and m. n is the number of candidates and m the number of jury members. These values will satisfy 1\<=n\<=200, 1\<=m\<=20 and of course m\<=n.~The following n lines contain the two integers pi and di for i = 1,…,n.~A blank line separates each round from the next. The file ends with a round that has n = m = 0. == Output <output> For each round output a line containing the number of the jury selection round ('Jury \#1', 'Jury \#2', etc.). On the next line print the values D(J ) and P (J ) of your jury as shown below and on another line print the numbers of the m chosen candidates in ascending order. Output a blank before each individual candidate number. Output an empty line after each test case. === Sample Input <sample-input> #quote[ 4 2 1 2 2 3 4 1 6 2 0 0 ] === Sample Output #quote[ Jury \#1 ] Best jury has value 6 for prosecution and value 4 for defence: 2 3 == Hint <hint> If your solution is based on an inefficient algorithm, it may not execute in the allotted time. == Source <source> Southwestern European Regional Contest 1996 == 中文: <中文> 描述 在遥远的国家佛罗布尼亚,嫌犯是否有罪,须由陪审团决定。陪审团是由法官从公众中挑选的。先随机挑选n个人作为陪审团的候选人,然后再从这n个人中选m人组成陪审团。选m人的办法是: 控方和辩方会根据对候选人的喜欢程度,给所有候选人打分,分值从0到20。为了公平起见,法官选出陪审团的原则是:选出的m个人,必须满足辩方总分和控方总分的差的绝对值最小。如果有多种选择方案的辩方总分和控方总分的之差的绝对值相同,那么选辩控双方总分之和最大的方案即可。 输入 输入包含多组数据。每组数据的第一行是两个整数n和m,n是候选人数目,m是陪审团人数。注意,$1 < = n < = 200 , 1 < = m < = 20 , m < = n$。接下来的n行,每行表示一个候选人的信息,它包含2个整数,先后是控方和辩方对该候选人的打分。候选人按出现的先后从1开始编号。两组有效数据之间以空行分隔。最后一组数据$n = m = 0$ 输出 对每组数据,先输出一行,表示答案所属的组号,如 'Jury \#1', 'Jury \#2', 等。接下来的一行要象例子那样输出陪审团的控方总分和辩方总分。再下来一行要以升序输出陪审团里每个成员的编号,两个成员编号之间用空格分隔。每组输出数据须以一个空行结束。 样例输入 #quote[ 4 2 1 2 2 3 4 1 6 2 0 0 ] 样例输出 #quote[ Jury \#1 ] Best jury has value 6 for prosecution and value 4 for defence: 2 3 为叙述问题方便,现将任一选择方案中,辩方总分和控方总分之差简称为“#strong[辩控差];”,辩方总分和控方总分之和称为“#strong[辩控和];”。第i个候选人的辩方总分和控方总分之差记为$V (i)$,辩方总分和控方总分之和记为$S (i)$。现用$f (j , k)$表示,取j个候选人,使其辩控差为k的所有方案中,辩控和最大的那个方案(该方案称为“方案$f (j , k)$”)的辩控和。并且,我们还规定,如果没法选j个人,使其辩控差为k,那么$f (j , k)$的值就为-1,也称方案$f (j , k)$不可行。本题是要求选出m个人,那么,如果对k的所有可能的取值,求出了所有的$f (m , k) (- 20 times m lt.eq k lt.eq 20 times m)$,那么陪审团方案自然就很容易找到了。 问题的关键是建立递推关系。需要从哪些已知条件出发,才能求出$f (j , k)$呢?显然,方案$f (j , k)$是由某个可行的方案$f (j - 1 , x) (- 20 times m lt.eq x lt.eq 20 times m)$演化而来的。可行方案$f (j - 1 , x)$能演化成方案$f (j , k)$的必要条件是:存在某个候选人i,i在方案$f (j - 1 , x)$中没有被选上,且$x + V (i) = k$。在所有满足该必要条件的$f (j - 1 , x)$中,选出$f (j - 1 , x) + S (i)$的值最大的那个,那么方案$f (j - 1 , x)$再加上候选人i,就演变成了方案$f (j , k)$。这中间需要将一个方案都选了哪些人都记录下来。不妨将方案$f (j , k)$中最后选的那个候选人的编号,记在二维数组的元素$p a t h [j] [k]$中。那么方案$f (j , k)$的倒数第二个人选的编号,就是$p a t h [j - 1] \[ k - V [p a t h [j] [k]]$。假定最后算出了解方案的辩控差是k,那么从$p a t h [m] [k]$出发,就能顺藤摸瓜一步步求出所有被选中的候选人。初始条件,只能确定$f (0 , 0) = 0$。由此出发,一步步自底向上递推,就能求出所有的可行方案$f (m , k) (- 20 times m lt.eq k lt.eq 20 times m)$。实际解题的时候,会用一个二维数组f来存放$f (j , k)$的值。而且,由于题目中辩控差的值k可以为负数,而程序中数租下标不能为负数,所以,在程序中不妨将辩控差的值都加上400,以免下标为负数导致出错,即题目描述中,如果辩控差为0,则在程序中辩控差为400。 ```cpp #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string.h> usingnamespace std; int f[30][1000]; //f[j,k]表示:取j个候选人,使其辩控差为k的方案中 //辩控和最大的那个方案(该方案称为“方案f(j,k)”)的控辩和 int Path[30][1000]; //Path数组用来记录选了哪些人 //方案f(j,k)中最后选的那个候选人的编号,记在Path[j][k]中 int P[300];//控方打分 int D[300]; //辩方打分 int Answer[30];//存放最终方案的人选 int cmp(constvoid*a,constvoid*b) { return*(int*)a-*(int*)b; } int main() { int i,j,k; int t1,t2; int n,m; int nMinP_D;//辩控双方总分一样时的辩控差 int iCase;//测试数据编号 iCase=0; while(scanf("%d %d",&n,&m)) { if(n==0&&m==0)break; iCase++; for(i=1;i<=n;i++) scanf("%d %d",&P[i],&D[i]); memset(f,-1,sizeof(f)); memset(Path,0,sizeof(Path)); nMinP_D=m*20;//题目中的辩控差为0,对应于程序中的辩控差为m*20 f[0][nMinP_D]=0; for(j=0;j<m;j++)//每次循环选出第j个人,共要选出m人 { for(k=0;k<=nMinP_D*2;k++)//可能的辩控差为[0,nMinP_D*2] if(f[j][k]>=0)//方案f[j,k]可行 { for(i=1;i<=n;i++) if(f[j][k]+P[i]+D[i]>f[j+1][k+P[i]-D[i]]) { t1=j;t2=k; while(t1>0&&Path[t1][t2]!=i)//验证i是否在前面出现过 { t2-=P[Path[t1][t2]]-D[Path[t1][t2]]; t1--; } if(t1==0) { f[j+1][k+P[i]-D[i]]=f[j][k]+P[i]+D[i]; Path[j+1][k+P[i]-D[i]]=i; } } } } i=nMinP_D; j=0; while(f[m][i+j]<0&&f[m][i-j]<0) j++; if(f[m][i+j]>f[m][i-j]) k=i+j; else k=i-j; printf("Jury #%d\n",iCase); printf("Best jury has value %d for prosecution and value %d for defence:\n",(k-nMinP_D+f[m][k])/2,(f[m][k]-k+nMinP_D)/2); for(i=1;i<=m;i++) { Answer[i]=Path[m-i+1][k]; k-=P[Answer[i]]-D[Answer[i]]; } qsort(Answer+1,m,sizeof(int),cmp); for(i=1;i<=m;i++) printf(" %d",Answer[i]); printf("\n\n"); } return 0; } ```
https://github.com/mgoulao/arkheion
https://raw.githubusercontent.com/mgoulao/arkheion/main/README.md
markdown
# arkheion A Typst template based on popular LateX template used in arXiv and bio-arXiv. Inspired by [arxiv-style](https://github.com/kourgeorge/arxiv-style) ![Example](example.png) ## Usage **Import** ``` #import "@preview/arkheion:0.1.0": arkheion, arkheion-appendices ``` **Main body** ``` #show: arkheion.with( title: "ArXiv Typst Template", authors: ( (name: "<NAME>", email: "<EMAIL>", affiliation: "Company", orcid: "0000-0000-0000-0000"), (name: "<NAME>", email: "<EMAIL>", affiliation: "Company"), ), // Insert your abstract after the colon, wrapped in brackets. // Example: `abstract: [This is my abstract...]` abstract: lorem(55), keywords: ("First keyword", "Second keyword", "etc."), date: "May 16, 2023", ) ``` **Appendix** ``` #show: arkheion-appendices = == Appendix section #lorem(100) ``` ## License The MIT License (MIT) Copyright (c) 2023 <NAME> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
https://github.com/PraneethJain/IQIC
https://raw.githubusercontent.com/PraneethJain/IQIC/main/Assignment-1/2022101093.typ
typst
MIT License
#align(center, text(17pt)[*Introduction to Quantum Information and Communication*]) #align(center, text(16pt)[Theory Assignment-1]) #align(center, text(13pt)[<NAME>, 2022101093]) #let ket(x) = $lr(|#x angle.r)$ #let bra(x) = $lr(angle.l #x |)$ #let braket(x, y) = $lr(angle.l #x|#y angle.r)$ #let tensor = $times.circle$ #let expected(x) = $angle.l #x angle.r$ = Question 1 *To Prove*: Any $n+1$ vectors belonging to an $n$ dimensional vector space must be linearly dependent *Proof*: Let $V$ be an $n$ dimensional vector space Assume $A = {v_1, v_2, v_3, dots, v_(n+1)}$ is a set of linearly independent vectors where $v_i in V$ Let $B = A \\ {v_(n+1)} = {v_1, v_2, v_3, dots, v_n}$. Since $B subset A$, $B$ is also a set of linearly independent vectors. Now, since $V$ is $n$ dimensional and $|B|= n$, $"span"(B) = V$ by the definition of $n$ dimensional vector space. Therefore, every vector $v in V$ can be expressed as a linear combination of vectors in $B$ $therefore v_(n+1) = a_1 v_1 + a_2 v_2 + a_3 v_3 + dots + a_n v_n$, where $a_i in FF ("field over which" V "is defined")$ $therefore$ $V$ is not linearly dependent. This is a contradiction Any set $A$ of $n+1$ vectors belonging to an $n$ dimensional vector space must be linearly dependent. = Question 2 *Given*: $A = mat(1, 2; 2, -2)$ *To Find*: square root of matrix $A$ *Solution*: Note that $A^dagger = A$. Thus, by the spectral theorem, $A$ can be decomposed into an orthonormal eigenbasis. Now, we find this eigenbasis. $ |A - lambda I| = 0 $ $ |mat(1 - lambda, 2; 2, -2 - lambda)| = 0 $ $ lambda_1 = 2, lambda_2 = -3 $ Let their corresponding normalized eigenvectors be $ket(2)$ and $ket(-3)$ $ A ket(2) = 2 ket(2) "and" A ket(-3) = 2 ket(-3) $ On solving, we get $ ket(2) = 1/sqrt(5) mat(2; 1) "and" ket(-3) = 1/sqrt(5) mat(1; -2) $ Now, by the spectral theorem, we have $ A = sum_i lambda_i ket(lambda_i) bra(lambda_i) $ $ A = 2 ket(2)bra(2) - 3 ket(-3) bra(-3) $ We know that $ f(A) = sum_i f(lambda_i) ket(lambda_i) bra(lambda_i) $ So $ sqrt(A) = sqrt(2)ket(2)bra(2) + sqrt(-3)ket(-3)bra(-3) $ $ sqrt(A) = sqrt(2)ket(2)bra(2) + sqrt(-3)ket(-3)bra(-3) $ $ sqrt(A) = 1/5(sqrt(2)mat(2; 1)mat(2, 1) + sqrt(-3)mat(1; -2)mat(1, -2)) $ $ sqrt(A) = 1/5(sqrt(2) mat(4, 2; 2, 1) + sqrt(-3) mat(1, -2; -2, 4)) $ $ sqrt(A) = 1/5 mat(4sqrt(2) + i sqrt(3), 2sqrt(2) - 2i sqrt(3); 2 sqrt(2) - 2 i sqrt(3), sqrt(2) + 4 i sqrt(3)) $ = Question 3 *Given*: $A$ is an $n times n $ matrix and $B$ is an $m times m$ matrix *To Prove*: $tr(A tensor B) = tr(A) times tr(B)$ *Proof*: $ A tensor B = mat(A_(1, 1)B, A_(1, 2) B, dots, A_(1, n) B; A_(2, 1) B, A_(2, 2) B, dots, A_(2, n) B; dots.v, dots.v, dots.down, dots.v; A_(n, 1)B, A_(n, 2)B, dots, A_(n, n) B) $ where each $A_(i, j) B$ is an $m times m$ matrix expanded. $ tr(A tensor B) = sum_(i=1)^n tr(A_(i, i) B) $ $ tr(A tensor B) = sum_(i=1)^n A_(i, i) tr(B) $ $ tr(A tensor B) = tr(B) times sum_(i=1)^n A_(i, i) $ $ tr(A tensor B) = tr(A) times tr(B) $ = Question 4 *Given*: $ket(psi) = cos(theta/2) ket(0) + e^(i phi) sin(theta/2) ket(1)$ *To Prove*: states are diametrically opposite on Bloch sphere $<=>$ states are orthogonal *Proof*: Let state $ ket(psi) = cos(theta/2) ket(0) + e^(i phi) sin(theta/2) ket(1) $ Now, its diametrically opposite state is given by adding $pi$ to $theta$ $ ket(psi^') = cos((theta + pi)/2) ket(0) + e^(i phi) sin((theta + pi)/2) ket(1) $ $ ket(psi^') = cos(pi/2 + theta/2) ket(0) + e^(i phi) sin(pi/2 + theta/2) ket(1) $ $ ket(psi^') = -sin(theta/2) ket(0) + e^(i phi) cos(theta/2) ket(1) $ Now, consider $ braket(psi, psi^') = mat(cos(theta/2), e^(-i phi) sin(theta/2)) mat(-sin(theta/2); e^(i phi) cos(theta/2)) $ $ braket(psi, psi^') = -cos(theta/2) sin(theta/2) + sin(theta/2) cos(theta/2) $ $ braket(psi, psi^') = 0 $ Since the inner product of any two diametrically opposite states is $0$, we can conclude that diametrically opposite states on the Bloch sphere are orthogonal *states are diametrically opposite on Bloch sphere $=>$ states are orthogonal* Now, assume two orthogonal states $ ket(psi_1) = cos(theta_1/2) ket(0) + e^(i phi_1) sin(theta_1/2) ket(1) "and" ket(psi_2) = cos(theta_2/2) ket(0) + e^(i phi_2) sin(theta_2/2) ket(1) $ $ braket(psi_1, psi_2) = 0 $ $ mat(cos(theta_1/2), e^(- i phi_1) sin(theta_1/2)) mat(cos(theta_2/2); e^(i phi_2)sin(theta_2/2)) = 0 $ $ cos(theta_1/2) cos(theta_2/2) + e^i(phi_2 - phi_1) sin(theta_1/2) sin(theta_2/2) = 0 $ $ cos(theta_1/2) cos(theta_2/2) + (cos(phi_2-phi_1) + i sin (phi_2 - phi_1)) sin(theta_1/2) sin(theta_2/2) = 0 $ Since the imaginary part is $0$ on RHS, we have $sin(phi_2 - phi_1) = 0 => phi_2 = phi_1$ $ cos(theta_1/2) cos(theta_2/2) + cos(0) sin(theta_1/2) sin(theta_2/2) = 0 $ $ cos(theta_1/2) cos(theta_2/2) + sin(theta_1/2) sin(theta_2/2) = 0 $ $ cos((theta_1 - theta_2)/2) = 0 $ $ (theta_1 - theta_2)/2 = pi/2 $ $ theta_1 = pi + theta_2 $ *states are orthogonal $=>$ states are diametrically opposite on Bloch sphere* Since we have proven both sides, we can assert *states are diametrically opposite on Bloch sphere $<=>$ states are orthogonal* = Question 5 *Given*: $ket(psi) = sum_(i=1)^n alpha_i ket(u_i)$ for some basis set ${ket(u_i)}_(i=1)^n$ and probability amplitudes $alpha_i in CC$ *To Prove*: $ket(psi)$ collapses to $ket(u_k)$ after measurement in the basis ${ket(u_i)}_(i=1)^n$ with probability $|alpha_k|^2$ *Proof*: Born rule states that the probability of a density operator $rho$ collapsing to state $ket(u_k)bra(u_k)$ is $ P = tr(ket(u_k)bra(u_k) rho) $ For the vector $psi$, we have state $rho = ket(psi)bra(psi)$ Now, we find the probability of $rho$ collapsing to $ket(u_k) bra(u_k)$ $ P = tr(ket(u_k) bra(u_k) ket(psi) bra(psi)) $ On using the cyclicity of trace $ P = tr(braket(psi, u_k) braket(u_k, psi)) $ Since the matrix inside trace is $1 times 1$ $ P = braket(psi, u_k) braket(u_k, psi) $ $ P = overline(braket(u_k, psi)) braket(u_k, psi) $ $ P = |braket(u_k, psi)|^2 $ $ P = |bra(u_k) sum_(i=1)^n alpha_i ket(u_i)|^2 $ $ P = | sum_(i=1)^n alpha_i bra(u_k) ket(u_i)|^2 $ $ P = | sum_(i=1)^n alpha_i braket(u_k, u_i)|^2 $ Since $braket(u_i, u_j) = delta_(i j)$ $ P = | sum_(i=1)^n alpha_i delta_(k i)|^2 $ $ P = |alpha_k|^2 $ $therefore$ $ket(psi)$ collapses to $ket(u_k)$ after measurement in the basis ${ket(u_i)}_(i=1)^n$ with probability $|alpha_k|^2$ = Question 6 == (a) $ ket(psi) = 1/sqrt(2) (ket(0) + i ket(1)) $ $ rho = ket(psi) bra(psi) $ $ rho = 1/2 mat(1; i)mat(1, -i) $ $ rho = 1/2 mat(1, -i; i, 1) $ Now, we find the probability of the state collapsing to $ket(1)$ in both formalisms === State Vector Formalism $ Pr["state collapsing to" ket(1)] = |braket(1, psi)|^2 $ $ P = |1/sqrt(2) mat(0, 1) mat(1; i)|^2 $ $ P = 1/2|i|^2 $ $ P = 1/2 $ === Density Matrix Formalism $ Pr["state collapsing to" ket(1)bra(1)] = tr(ket(1) bra(1) rho) $ $ P = tr(1/2 mat(0; 1) mat(0, 1) mat(1, -i; i, 1)) $ $ P = 1/2 tr(mat(0, 0; 0, 1) mat(1, -i; i, 1)) $ $ P = 1/2 tr(mat(0, 0; i, 1)) $ $ P = 1/2 $ In both the formalisms, we get the required probability to be $1/2$ == (b) === State Vector Formalism $ Pr["state collapsing to" ket(+i)] = |braket(+i, psi)|^2 $ $ P = |1/2 mat(1, -i) mat(1; i)|^2 $ $ P = |1/2 * 2|^2 $ $ P = 1 $ === Density Matrix Formalism $ Pr["state collapsing to" ket(+i)bra(+i)] = tr(ket(+i) bra(+1) rho) $ $ P = tr(1/4 mat(1; i) mat(1, -i) mat(1, -i; i, 1)) $ $ P = 1/4 tr(mat(1, -i; i, 1) mat(1, -i; i, 1)) $ $ P = 1/4 tr(mat(2, -2i; 2i, 2)) $ $ P = 1 $ $therefore$ the probability of getting $ket(+psi)$ when measuring in the basis ${ket(+psi), ket(-psi)}$ is 1 = Question 7 $ ket(Psi-) = 1/sqrt(2) (ket(0) tensor ket(1) - ket(1) tensor ket(0)) = 1/sqrt(2) mat(0; 1; -1; 0) $ $ BB = {ket(0) tensor ket(0), ket(0) tensor ket(1), ket(1) tensor ket(0), ket(1) tensor ket(1)} $ == (a) For a pure state to be separable, it must be a product state. Let $ket(Psi-) = mat(a; b) tensor mat(c; d)$ $ 1/sqrt(2) mat(0; 1; -1; 0) = mat(a c; a d; b c; b d) $ $ a c = 0 => a = 0 or c = 0 $ $ b d = 0 => b = 0 or d = 0 $ If any one of these are zero, then $a d != 1 and b c != -1$. Thus, no such states exist whose tensor product is $ket(Psi-)$ Thus, $ket(Psi-)$ is entangled. == (b) $ Pr["state collapsing to" ket(ket(1) tensor ket(0))] = |braket(ket(1) tensor ket(0), Psi-)|^2 $ $ P = |1/sqrt(2) mat(0, 0, 1, 0) mat(0; 1; -1; 0)|^2 $ $ P = 1/2 |-1|^2 $ $ P = 1/2 $ == (c) $ Pr["state collapsing to" ket(ket(0) tensor ket(0))] = |braket(ket(0) tensor ket(0), Psi-)|^2 $ $ P = |1/sqrt(2) mat(1, 0, 0, 0) mat(0; 1; -1; 0)|^2 $ $ P = 1/2 |0|^2 $ $ P = 0 $ == (d) $Z$ is the Pauli Z matrix $ Z = mat(1, 0; 0, -1) $ $ O = Z tensor Z $ $ O = mat(1, 0; 0, -1) tensor mat(1, 0; 0, -1) $ $ O = mat(1, 0, 0, 0; 0, -1, 0, 0; 0, 0, -1, 0; 0, 0, 0, 1) $ $ expected(O) = bra(Psi-) O ket(Psi-) $ $ expected(O) = 1/2 mat(0, 1, -1, 0) mat(1, 0, 0, 0; 0, -1, 0, 0; 0, 0, -1, 0; 0, 0, 0, 1) mat(0; 1; -1; 0) $ $ expected(O) = 1/2 mat(0, 1, -1, 0) mat(0; -1; 1; 0) $ $ expected(O) = 1/2 (-2) $ $ expected(O) = -1 $ The expected value of operator $O = Z tensor Z$ for the state $ket(Psi-)$ is $-1$
https://github.com/Robotechnic/iridis
https://raw.githubusercontent.com/Robotechnic/iridis/master/lib.typ
typst
MIT License
#import "internals.typ" #let iridis-palette = internals.iridis-palette #let iridis-show( opening-parenthesis: ("(","[","{"), closing-parenthesis: (")","]","}"), palette: internals.iridis-palette, body ) = { let counter = state("parenthesis", 0) show raw : internals.colorize-code(counter, opening-parenthesis, closing-parenthesis, palette) show math.equation : internals.colorize-math body }
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/visualize/gradient-official_00.typ
typst
Apache License 2.0
#set text(fill: gradient.linear(red, blue), font: "Open Sans") #let rainbow(content) = { set text(fill: gradient.linear(..color.map.rainbow)) box(content) } This is a gradient on text, but with a #rainbow[twist]!
https://github.com/fadimanai/lab4
https://raw.githubusercontent.com/fadimanai/lab4/main/Lab-4.typ
typst
#import "Class.typ": * #show: ieee.with( title: [#text(smallcaps("Lab #4: ROS2 using RCLPY in Julia"))], /* abstract: [ #lorem(10). ], */ authors: ( ( name: "<NAME>", department: [Senior-lecturer, Dept. of EE], organization: [ISET Bizerte --- Tunisia], profile: "a-mhamdi", ), ( name: "<NAME>", department: [Dept. of EE], organization: [ISET Bizerte --- Tunisia], profile: "fadimanai", ), ( name: "<NAME>", department: [Dept. of EE], organization: [ISET Bizerte --- Tunisia], profile: "MahmoudiEI2", ), ) // index-terms: (""), // bibliography-file: "Biblio.bib", ) You are required to carry out this lab using the REPL as in @fig:repl. #figure( image("Images/REPL.png", width: 100%, fit: "contain"), caption: "Julia REPL" ) <fig:repl> in this lab they are two part in the first part (“Application”) we gonna use also julia REPL to write down ROS2s codes as the figure (1) and in the second part (“clarafication”) we gonna explain every commandes and her function We begin first of all by sourcing our ROS2 installation as follows: ```zsh source /opt/ros/humble/setup.zsh ``` Secondly, we're going to open up a Julia terminal and write down the codes below. Alternatively, we can open it from our folder "infodev/codes/ros2". #solution[Always start by sourcing ROS2 installation in any newly opened terminal.] Open a _tmux_ session and write the instructions provided at your Julia REPL. #let publisher=read("../Codes/ros2/publisher.jl") #let subscriber=read("../Codes/ros2/subscriber.jl") #raw(publisher, lang: "julia") The second program is the subscriber code. After writing down both programs, we need to execute each of them in a newly opened terminal. Then the subscriber will listen to the message broadcasted by the publisher #raw(subscriber, lang: "julia") The second program is the subscriber code. Once we've written down both programs, we'll need to execute each of them in a newly opened terminal. Afterward, the subscriber will listen to the message broadcasted by the publisher ```zsh source /opt/ros/humble/setup.zsh rqt_graph ``` #figure( image("Images/rqt_graph.png", width: 100%), caption: "rqt_graph", ) <fig:rqt_graph> After linking the publisher and the subscriber, the publisher will broadcast this message one hundred times to the node linked with the subscriber: csharp Copy code [Info [TALKER] Hello, ROS2 from Julia!(1…100)] Then, the subscriber will respond in the node by: css Copy code [Info [LISTENER] I heard Hello, ROS2 from Julia!(1…100)] @fig:pub-sub depicts the publication and reception of the message _"Hello, ROS2 from Julia!"_ in a terminal. The left part of the terminal showcases the message being published, while the right part demonstrates how the message is being received and heard. #figure( image("Images/pub-sub.png", width: 100%), caption: "Minimal publisher/subscriber in ROS2", ) <fig:pub-sub> @fig:topic-list shows the current active topics, along their corresponding interfaces. /* ```zsh source /opt/ros/humble/setup.zsh ros2 topic list -t ``` */ #figure( image("Images/topic-list.png", width: 100%), caption: "List of topics", ) <fig:topic-list> //#test[Some test] First Program: Publisher Code ```julia # Using PyCall to interface with Python using PyCall # Importing the rclpy module from ROS2 Python rclpy = pyimport("rclpy") # Importing the std_msgs.msg module from ROS 2 str = pyimport("std_msgs.msg") # Initializing ROS2 runtime rclpy.init() # Creating a node named "my_publisher" node = rclpy.create_node("my_publisher") # Executing a single iteration of the ROS 2 event loop within a given timeout period rclpy.spin_once(node, timeout_sec=1) # Creating a publisher within the ROS 2 node pub = node.create_publisher(str.String, "infodev", 10) # Publishing messages to the topic for i in 1:100 msg = str.String(data="Hello, ROS2 from Julia!($(string(i)))") pub.publish(msg) txt = "[TALKER] " * msg.data @info txt sleep(1) end # Shutting down ROS2 runtime and destroying the node rclpy.shutdown() node.destroy_node() ``` Second Program: Subscriber Code ```julia # Importing the rclpy module rclpy = pyimport("rclpy") # Importing the std_msgs.msg module str = pyimport("std_msgs.msg") # Creating a node named "my_subscriber" node = rclpy.create_node("my_subscriber") # Defining a callback function to handle received messages function callback(msg) txt = "[LISTENER] I heard: " * msg.data @info txt end # Creating a subscriber within the ROS 2 node sub = node.create_subscription(str.String, "infodev", callback, 10) # Continuously spinning the ROS 2 node while rclpy.ok() rclpy.spin_once(node) end ``` These programs are written in Julia and utilize PyCall to interface with Python modules. The publisher code initializes the ROS2 runtime, creates a publisher node, and publishes messages to a specified topic. The subscriber code creates a subscriber node, defines a callback function to handle received messages, and continuously processes messages by spinning the node.
https://github.com/chendaohan/bevy_tutorials_typ
https://raw.githubusercontent.com/chendaohan/bevy_tutorials_typ/main/04_systems/systems.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. 系统 系统是 Bevy 的功能模块。它们使用函数(```Rust fn```)和闭包(```Rust FnMut```)实现。这就是你实现所有游戏逻辑的方式。系统只能接受特殊参数类型,以指定你需要访问的数据。 特殊参数类型包括: - 访问资源使用 ```Rust Res<T> / ResMut<T>``` - 访问实体/组件使用 ```Rust Query<T, F>``` - 创建/销毁实体、组件、资源使用 ```Rust Commands``` - 发送/接收事件使用 ```Rust EventWriter / EventReader``` - 获取对 ECS World 的完全直接访问使用 ```Rust &mut World``` 你的函数最多可以有 16 个参数,如果需要更多,可以用元组嵌套,元组最多可以包含 16 个成员,但可以无限嵌套。 ```Rust fn complex_system( (a, mut b): ( Res<ResourceA>, ResMut<ResourceB> ), (q0, q1, q2): ( Query<(/*...*/)>, Query<(/*...*/)>, Query<(/*...*/)>, ), ) { //... } ``` = 2. 运行时 为了让你的系统由 Bevy 运行,你需要通过 App 构建器进行配置,系统也可以用元组嵌套,元组最多包含 16 个成员,但可以无限嵌套。 ```Rust App::new() .add_plugins(DefaultPlugins) // 设置资源 .add_systems(Startup, setup) // 移动玩家 .add_systems(Update, move_player) // 系统嵌套 .add_systems(Update, ( system_1, system_2, ( system_3, system_4, ( system_5, system_6 ) ) )) .run() ``` 编写一个新系统而忘记添加到 App 中是一个常见的错误。如果你发现有系统没有运行,请确保你已经添加了系统。 随着你的项目变得复杂,你可能希望利用 Bevy 提供的一些强大的工具来管理你的系统,例如:显示排序、运行条件、系统集、状态。在 “02. 行为” 的视频中,我简略的讲解了这些内容,你有个印象就行,之后这些内容都有详细的视频讲解。 = 3. 系统类型 能够作为系统的类型: ```Rust // 实现了 Fn / FnMut / FnOnce Trait 的函数,fn() 是类型 fn function() { info!("function"); } let name = String::from("fn_closure"); // 实现了 Fn / FnMut / FnOnce Trait 的闭包 let fn_closure = move || info!("{name}"); let mut name = String::from("fn_mut"); // 实现了 FnMut / FnOnce Trait 的闭包 let fn_mut_closure = move || { name.push_str("_closure"); info!("{name}"); }; ``` = 4. 一次性系统 有时候你不想让 Bevy 为你运行系统。在这种情况下,你应该使用一次性系统。这里只要有个印象就行,以后有视频会详细讲解。 ```Rust fn register_and_run_system(mut commands: Commands) { let system_id = commands.register_one_shot_system(one_shot_system); commands.run_system(system_id); } fn one_shot_system() { info!("one shot system"); } ```
https://github.com/francescoo22/kt-uniqueness-system
https://raw.githubusercontent.com/francescoo22/kt-uniqueness-system/main/src/CFG-based-system.typ
typst
#import "./proof-tree.typ": * #import "./vars.typ": * #import "@preview/commute:0.2.0": node, arr, commutative-diagram = CFG Based System Basic rules for Uniqueness and Borrowing won't change here, but adapted to fit the CFG representation of Kotlin. The key gap between the CFG version and the type rules is at the function call. Type checking at function calls need adjustment so that it can be done in control flow order. The support for nested function call is alse missing is previous typing rules. == Formalization #grid( columns: (auto, auto), column-gutter: 2em, row-gutter: 1em, [*CFG nodes not covered in Grammar*],[*Context*], frame-box( $ af &::= unique | shared \ beta &::= dot | borrowed \ p &::= x | p.f \ "TA" &::= "$"i := p, "$i for implicit registers" \ "F" &::= f("$"1: af beta, ..., "$"n: af beta): af \ "Join" &::= j \ $ ), frame-box( $ alpha &::= unique | shared | top \ beta &::= dot | borrowed \ Delta &::= dot | p : alpha beta, Delta \ l &:== dot | (p | alpha beta , l) \ Gamma &::= dot | i : l, Gamma $ ) ) Rules for CFA is defined on control flow graph, where edges are associated with contexts, and nodes for expressions or statements. We follow the original lattice for control flow analysis. #figure(image(width: 25%, "./img/lattice.svg"), caption: [Lattice in Control Flow Analysis])<CFA-lattice> In Kotlin CFG, $"$"i = "eval" e$, is a common pattern that appears everywhere. In #link("https://kotlinlang.org/spec/control--and-data-flow-analysis.html#control-flow-graph")[Kotlin specification], the left hand side of such an assignment is an implicit register. The best property of the implicit register is that it should be assigned only once, unless it appears in two disjoint branches across the whole CFG, thus there is no need for us to track its scope, or care about update. We distinguish this case with assignment statement and call this implicit assignment. The implicit registers does not take the ownership of the value, but just store an aliasing information. We introduce an extra context $Gamma$ for CFA to track aliasing happening at implicit assignment. Notice that $Gamma$ is a list of aliasing information or uniqueness level, as we might have multiple aliasing possibilities from different branches of CFG. Rule for CFA are as follows on different nodes in CFG that does not appear in the grammar. #display-rules(row-size: 1, prooftree( axiom($Gamma'= i: (p, dot), Gamma$), rule(label: "implicit assign path", $Gamma, Delta tack.r "$"i := p tack.l Gamma', Delta$), ), prooftree( axiom($Gamma'= i:, Gamma(j), Gamma$), rule(label: "implicit assign implicit", $Gamma, Delta tack.r "$"i := "$"j tack.l Gamma', Delta$), ), prooftree( axiom($Gamma'= i:, (alpha beta, dot), Gamma$), rule(label: "implicit assign function call", $Gamma, Delta tack.r "$"i := f(...) alpha beta tack.l Gamma', Delta$), ), prooftree( axiom($forall i, j: exists p_i in Gamma("$"i) p_j in Gamma("$"j), p_i subset.sq p_j => (a_i^m = a_j^m = shared)$), axiom($Gamma' Delta' = "normalize'" Gamma Delta$), axiom($Lub Gamma'("$"i).alpha beta <= alpha_i beta_i$), rule(n: 3, label: "Function call", $Gamma, Delta tack.r f("$"1: alpha_1 beta_1, ..., "$"n: alpha_n beta_n) tack.l Gamma', Delta'$), ), prooftree( axiom($Delta' = "unify "Delta_1, Delta_2$), axiom($Gamma' = lub' Gamma_1, Gamma_2$), axiom($Gamma'' = "$result": Gamma'("$2"), Gamma'$), rule(n:3, label: "join", $(Gamma_1, Delta_1) | (Gamma_2, Delta_2) tack.r "$result" = "$2" tack.l Gamma'', Delta'$), ) ) === Unification #align(left)[#commutative-diagram( node-padding: (50pt, 50pt), node((0, 0), $I$), node((1, 0), $L$), node((1, 1), $R$), node((2, 1), $"$result=$2"$), node((3, 1), $O$), arr($I$, $L$, $Gamma_0, Delta_0$), arr($I$, $R$, $Gamma_0, Delta_0$), arr($L$, (2,1), $Gamma_1, Delta_1$), arr($R$, (2,1), $Gamma_2, Delta_2$), arr((2,1), $O$, $Gamma'', Delta'$), )] Unification for full $Gamma$ don't need to care about scope too much, as each implicit register is assigned only once. $lub' Gamma_1 Gamma_2$ does pointwise $lub$, if both $Gamma_1("$i"), Gamma_2("$i")$ are uniqueness level, otherwise, it concatenates the two lists $Gamma_1("$i"), Gamma_2("$i")$ but *keep* $x: alpha_x beta_x$ if it appears in only one of $Delta_1$ or $Delta_2$. === Normalization with $Gamma$ and $Delta$ #display-rules( prooftree( axiom($Delta' = "normalize"(p_1: alpha_1 beta_1, ..., p_n: alpha_n beta_n)$), rule(label: "N-finish", $Gamma, Delta tack.r "normalize"'(p_1: alpha_1 beta_1, ..., p_n: alpha_n beta_n) tack.r Gamma Delta'$) ), prooftree( axiom($Delta' = Lub_(k in Gamma("$"i.p)) "normalize"'(p_1: alpha_1 beta_1, ..., k: alpha_1 beta_1, ..., "$"n: alpha_n beta_n)$), rule(label: "N-rec", $Gamma, Delta tack.r "normalize'"(p_1: alpha_1 beta_1, ... "$"i: alpha_i beta_i, ... "$"n: alpha_n beta_n tack.r Gamma, Delta'$), ), ) == Examples for nested function calls CFG for function call is represented first eval the arguments sequentially and then call the function. Consider the following example: ```kt fun l(x: b shared) shared fun h(x: b shared) shared fun g(x: b shared) shared fun f(x: b shared, y: shared, z: shared, w: shared) shared fun use_f (x: unique) { f(x, g(h(x)), l(x), x) } ``` #commutative-diagram( node-padding: (50pt, 40pt), node((0, 0), $I$), node((1, 0), $"$1:=x"$), node((2, 0), $"$2:=x"$), node((3, 0), $"$3:=h($2)"$), node((4, 0), $"$4:=g($3)"$), node((5, 0), $"$5:=l($1)"$), node((6, 0), $"$6:=x"$), node((7, 0), $"$result:=f($1, $4, $5, $6)"$), node((8, 0), $O$), arr($I$, (1, 0), ${}_Gamma, {x:unique}_Delta$), arr((1,0), (2, 0), ${"$1":x}_Gamma, {x:unique}_Delta$), arr((2,0), (3, 0), ${"$2":x, "$1":x}_Gamma, {x:unique}_Delta$), arr((3,0), (4, 0), ${"$3":shared, "$2":x, "$1":x}_Gamma, {x:unique}_Delta$), arr((4,0), (5, 0), ${"$4":shared, "$3":shared, "$2":x, "$1":x}_Gamma, {x:unique}_Delta$), arr((5,0), (6, 0), ${"$5":shared, "$4":shared, "$3":shared, "$2":x, "$1":x}_Gamma, {x:unique}_Delta$), arr((6,0), (7, 0), ${"$6":x, "$5":shared, "$4":shared, "$3":shared, "$2":x, "$1":x}_Gamma, {x:unique}_Delta$), arr((7,0), (8, 0), ${"$result":shared, "$6":x, "$5":shared, "$4":shared, "$3":shared, "$2":x, "$1":x}_Gamma\ {x:shared}_Delta$), ) == Examples with multiple branches ```kt fun f(x: unique): shared fun use_f(x: unique, y: unique, z: shared) { f(if (x) y else z) } ``` #align(center)[#commutative-diagram( node-padding: (50pt, 50pt), node((0, 1), $I$), node((1, 1), $"$1:=x"$), node((2, 1), "assume $1"), node((1, 3), $""$), node((2, 3), "assume !$1"), node((3, 1), $"$2:=y"$), node((3, 3), $"$2:=z"$), node((4, 1), $"$3:=$2"$), node((4, 3), $""$), node((5, 1), $"$result:=f($3)"$), node((6, 1), $O$), arr(label-pos:right, $I$, (1, 1), ${}_Gamma\ {x:unique, y:unique, z:shared}_Delta$), arr(label-pos:right, (1,1), (2, 1), ${"$1":x}_Gamma\ {x:unique, y:unique, z:shared}_Delta$), arr(label-pos:right, (2,1), (3, 1), ${"$1":x}_Gamma\ {x:unique, y:unique, z:shared}_Delta$), arr(label-pos:right, (3,1), (4, 1), ${"$2":y, "$1":x}_Gamma\ {x:unique, y:unique, z:shared}_Delta$), arr((1,1), (1, 3), ""), arr((1,3), (2, 3), ${"$1":x}_Gamma\ {x:unique, y:unique, z:shared}_Delta$), arr((2,3), (3, 3), ${"$1":x}_Gamma\ {x:unique, y:unique, z:shared}_Delta$), arr((3,3), (4, 3), ${"$2":z, "$1":x}_Gamma\ {x:unique, y:unique, z:shared}_Delta$), arr((4,3), (4, 1), $$), arr((4,1), (5, 1), ${"$3":[x, z], "$2":[x,z], "$1":x}_Gamma\ {x:unique, y:unique, z:shared}_Delta$), arr((5,1), (6, 1), $"Error: $3 is " unique "or" shared ", while expected to be " unique$), )]
https://github.com/unb3rechenbar/TypstPackages
https://raw.githubusercontent.com/unb3rechenbar/TypstPackages/main/README.md
markdown
# Introduction This repository contains code to design typst documents the way I did using LaTeX. Since Typst has a lot of potential, I decided to translate some of my LaTeX definitions to Typst. This repository is a work in progress and will be updated as I continue to work on it. # Table of Contents 1. [Installation](#installation) 2. [Usage](#usage) 3. [Examples](#examples) # Installation To install the package, clone the repository to your local Typst installation. The path usually follows `{data-dir}/typst/packages/{namespace}/{name}/{version}`, where `{data-dir}` is given depending on your operating system. See - `$XDG_DATA_HOME` or `~/.local/share` on Linux - `~/Library/Application Support` on macOS - `%APPDATA%` on Windows This specific repository is at the level of `packages` in the above path and therefore contains _namespaces_ with their respective _names_ and _versions_. For more detail see the official Typst documentation for [local packages](https://github.com/typst/packages?tab=readme-ov-file#local-packages). # Usage The packages usage is straightforward, using Typst package management system. Just type ``` #import "@environments/boxdef:0.1.0": * ``` to use the package `boxdef` in version `0.1.0` from the namespace `environments`. The `*` is a wildcard to import all definitions from the package. # Examples A quick example for the definition environment in `boxdef` could be: ``` #import "@environments/boxdef:0.1.0": * #set heading(numbering: "1.") #definitionsbox( "Neue Definition", [ Das hier ist eine Definition, welche die vordefinierte Box nutzt, *OHNE* jemals speziell in diesem Dokment definiert worden zu sein. ] ) ```
https://github.com/Jarivanbakel/typst-action
https://raw.githubusercontent.com/Jarivanbakel/typst-action/main/README.md
markdown
MIT License
# typst-action [![Test Github Action](https://github.com/Jarivanbakel/typst-action/actions/workflows/test.yml/badge.svg)](https://github.com/Jarivanbakel/typst-action/actions/workflows/test.yml) A cross-OS GitHub Action to compile Typst documents ## Inputs - `input_files` The Typst file(s) to be compiled. This input is required. You can also pass multiple files as a multi-line string to compile multiple documents. For example: ```yaml - uses: Jarivanbakel/typst-action@v3 with: input_files: | file1.typ file2.typ ``` - `working_directory` The working directory for this action. ## Example ```yaml name: Build Typst document on: [push] jobs: build_typst: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - uses: Jarivanbakel/typst-action@v3 with: input_files: file1.typ - name: Upload PDF file uses: actions/upload-artifact@v3 with: name: PDF path: main.pdf ``` ## License MIT
https://github.com/donRumata03/aim-report
https://raw.githubusercontent.com/donRumata03/aim-report/master/lib/generic-utils.typ
typst
#let blockquote = it => rect(stroke: (left: 2.5pt + gray.lighten(50%)), inset: (left: 1em), fill: gray.lighten(93%), { set text(size: 0.92em) it }) #let lnk(dest, body) = link(dest, emph(underline(text(body, fill: color.mix(rgb("#0000FF"), rgb("#600000").darken(30%)))))) // How to use nested set rules?
https://github.com/Dav1com/resume
https://raw.githubusercontent.com/Dav1com/resume/main/modules/education.typ
typst
Apache License 2.0
#import "../brilliant-CV/template.typ": * #cvSection("Education") #cvEntry( title: [Engineering in Computer Science], society: [Faculty of Physical and Mathematical Sciences, University of Chile], date: [Mar 2020 - Present], location: [Santiago, Chile], logo: "../img/uchile.svg", description: list() )
https://github.com/zjutjh/zjut-report-typst
https://raw.githubusercontent.com/zjutjh/zjut-report-typst/main/README.md
markdown
## ZJUT-Report-Typst 浙江工业大学的报告模板 > **注意** > 本仓库**并非官方模板** ### 文件说明 - `template/template.typ` 模板入口 - `example.typ` 样例 - [example.pdf](./example.pdf) 编译出的 `pdf` 文件 ## 如何使用 ### Linux/Mac ```bash sh -c "$(wget https://raw.githubusercontent.com/zjutjh/zjut-report-typst/main/get-template.sh -O -)" ``` ### 手动 Clone 本仓库后手动导入 ### 关于 Package 参考 https://github.com/typst/packages#local-packages Template 不应该是一个 Package, 而关于 Template 的基础建设正在进行中, 请参考 https://github.com/typst/typst/issues/2432 因此如果有需求将本模板作为一个 package,请按照自己的系统自行将 `template` 目录中的内容放置到你的系统的对应位置 例如我是 Linux 系统,因此这个目录应该在: `~/.local/share/typst/packages/local/zjut-report-typst/0.1.0/template.typ` 导入时应该是: ```typ #import "@local/zjut-report-typst:0.1.0": * ``` > 需要注意的是这是一个暂时性的解决方案,之后理论上会依赖于 typst cli ## 关于 Typst Typst 是一个新的基于 Markup 的排版引擎,类似于 $\LaTeX$ 由于 Typst 还处于开发阶段,本模板可能随时出现问题 可以参考 Typst 的官方文档: https://typst.app/docs ## 参考 - [zjut-report-tex](https://github.com/zjutjh/zjut-report-tex) - [HUST-typst-template](https://github.com/werifu/HUST-typst-template) - [i-figured](https://github.com/typst/packages/tree/main/packages/preview/i-figured/0.1.0)
https://github.com/rsmith20/typst
https://raw.githubusercontent.com/rsmith20/typst/main/math-facts.typ
typst
#import "@preview/suiji:0.3.0" #let rng = suiji.gen-rng(35835935) #let col_size = 11 #let max = 30 #let integers = suiji.integers(rng, low: 2, high: max, size: 400).at(1) = Math Worksheet // #set align(left) #set text(font: "New Computer Modern Mono") #let problem(x, y, sign) = { // These could be sorted and it is probably more standard to do so. But learning to think both ways, 23x9 and 9x23 can be useful. rect(width: 80%, height: 80%, [#align(right)[ #x \ #math.underline(sign + str(" ") + str(y)) \ #str(" ") ]] ) } #let mult(x, y) = { problem(x, y, "x") } #let rand_mult(index) = { mult(integers.at(index), integers.at(index + 1)) } #let col_generator(problem_generator, index_function, col_size) = { let n = 0 while n < col_size { problem_generator(index_function(n)) n += 1 } } // I attempted to use this to avoid having multiple col_generators below, but it wasn't actually producing multiple results. // #let worksheet_generator(problem_generator, index_function, col_size) = { // let n = 0 // while n < col_size { // let current_index = index_function(n) // col_generator(problem_generator, x => current_index + x, col_size) // n += 1 // } // } #grid( columns: range(1, col_size).map(x => 10%), rows: range(1, col_size).map(x => 8%), col_generator(x => rand_mult(x), x => x, col_size), col_generator(x => rand_mult(x), x => col_size + x, col_size), col_generator(x => rand_mult(x), x => col_size * 2 + x, col_size), col_generator(x => rand_mult(x), x => col_size * 3 + x, col_size), col_generator(x => rand_mult(x), x => col_size * 4 + x, col_size), col_generator(x => rand_mult(x), x => col_size * 5 + x, col_size), col_generator(x => rand_mult(x), x => col_size * 6 + x, col_size), col_generator(x => rand_mult(x), x => col_size * 7 + x, col_size), col_generator(x => rand_mult(x), x => col_size * 8 + x, col_size), )
https://github.com/Myriad-Dreamin/tinymist
https://raw.githubusercontent.com/Myriad-Dreamin/tinymist/main/crates/tinymist-query/src/fixtures/type_describe/ever_call.typ
typst
Apache License 2.0
#let tmpl(content) = { content } #(tmpl(1)) #(tmpl(2)) #(tmpl(3)) #(/* position after */ tmpl)
https://github.com/TypstApp-team/typst
https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/compiler/show-bare.typ
typst
Apache License 2.0
// Test bare show without selector. --- #set page(height: 130pt) #set text(0.7em) #align(center)[ #text(1.3em)[*Essay on typography*] \ <NAME> ] #show: columns.with(2) Great typography is at the essence of great storytelling. It is the medium that transports meaning from parchment to reader, the wave that sparks a flame in booklovers and the great fulfiller of human need. --- // Test bare show in content block. A #[_B #show: c => [*#c*]; C_] D --- // Test style precedence. #set text(fill: eastern, size: 1.5em) #show: text.with(fill: forest) Forest --- #show: [Shown] Ignored --- // Error: 4-19 show is only allowed directly in code and content blocks #((show: body => 2) * body) --- // Error: 6 expected colon #show it => {} --- // Error: 6 expected colon #show it
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/grotesk-cv/0.1.0/lib.typ
typst
Apache License 2.0
#import "metadata.typ": * #import "@preview/fontawesome:0.2.1": * #let text-font = "<NAME>" #let text-size = 9pt #let header-name = [#first-name #last-name] #let title = [#sub-title] #let text-colors = ( light-gray: rgb("#ededef"), medium-gray: rgb("#78787e"), dark-gray: rgb("#3c3c42"), ) #let accent-color = rgb("#d4d2cc") #let import-section(file) = { include { "content/" + file + ".typ" } } #let layout(doc) = { set text( fill: text-colors.dark-gray, font: text-font, size: text-size, ) set align(left) set page( fill: rgb("F4F1EB"), paper: "a4", margin: ( left: 1.2cm, right: 1.2cm, top: 1.6cm, bottom: 1.2cm, ), ) doc } #let section-title-style(str) = { text( size: 12pt, weight: "bold", fill: text-colors.dark-gray, str, ) } #let name-block() = { text( fill: text-colors.dark-gray, size: 30pt, weight: "extrabold", header-name, ) } #let title-block() = { text( size: 15pt, style: "italic", fill: text-colors.dark-gray, title, ) } #let info-block-style(icon, txt) = { text( size: 10pt, fill: text-colors.medium-gray, weight: "medium", fa-icon(icon) + h(5pt) + txt, ) } #let info-block() = { table( columns: 1fr, inset: -1pt, stroke: none, row-gutter: 3mm, [#info-block-style("location-dot", info.address) #h(2pt) #info-block-style( "phone", info.telephone, ) #h(2pt) #info-block-style("envelope", info.email) #h(2pt) #info-block-style( "linkedin", info.linkedin, ) #h(2pt) #info-block-style("github", info.github)], ) } #let header-table() = { table( columns: 1fr, inset: 0pt, stroke: none, row-gutter: 4mm, [#name-block()], [#title-block()], [#info-block()], ) } #let make-header-photo(profile-photo) = { if profile-photo != false { box( clip: true, radius: 50%, image(profile-image), ) } else { box( clip: true, stroke: 5pt + yellow, radius: 50%, fill: yellow, ) } } #let cv-header(left-comp, right-comp, cols, align) = { table( columns: cols, inset: 0pt, stroke: none, column-gutter: 10pt, align: horizon, { left-comp }, { right-comp } ) } #let create-header( use-photo: false, ) = { cv-header( header-table(), make-header-photo(use-photo), (74%, 20%), left, ) } #let cv-section(title) = { section-title-style(title) h(4pt) } #let date-style(date) = ( table.cell( align: right, text( size: 9pt, weight: "bold", style: "italic", date, ), ) ) #let degree-style(degree) = ( text( size: 10pt, weight: "bold", degree, ) ) #let institution-style(institution) = ( table.cell( text( size: 9pt, style: "italic", weight: "medium", institution, ), ) ) #let location-style(location) = ( table.cell( text( style: "italic", weight: "medium", location, ), ) ) #let tag-style(str) = { align( right, text( weight: "regular", str, ), ) } #let tag-list-style(tags) = { for tag in tags { box( inset: (x: 0.4em), outset: (y: 0.3em), fill: accent-color, radius: 3pt, tag-style(tag), ) h(5pt) } } #let profile-entry(str) = { text( size: text-size, weight: "medium", str, ) } #let reference-entry( name: "Name", title: "Title", company: "Company", telephone: "Telephone", email: "Email", ) = { table( columns: (3fr, 2fr), inset: 0pt, stroke: none, row-gutter: 3mm, [#degree-style(name)], [#date-style(company)], table.cell(colspan: 2)[#institution-style(telephone), #location-style(email)], ) v(2pt) } #let education-entry( degree: "Degree", date: "Date", institution: "Institution", location: "Location", description: "", highlights: (), ) = { table( columns: (3fr, 1fr), inset: 0pt, stroke: none, row-gutter: 3mm, [#degree-style(degree)], [#date-style(date)], [#institution-style(institution), #location-style(location)], ) v(2pt) } #let experience-entry( title: "Title", date: "Date", company: "Company", location: "Location", ) = { table( columns: (1fr, 1fr), inset: 0pt, stroke: none, row-gutter: 3mm, [#degree-style(title)] , [#date-style(date)], table.cell(colspan: 2)[#institution-style(company), #location-style(location)], ) v(5pt) } #let skill-style(skill) = { text( weight: "bold", skill, ) } #let skill-tag(skill) = { box( inset: (x: 0.3em), outset: (y: 0.2em), fill: accent-color, radius: 3pt, skill-style(skill), ) } #let skill-entry( skills: (), ) = { table( columns: 1fr, inset: 0pt, stroke: none, row-gutter: 2mm, column-gutter: 3mm, align: center, for sk in skills { [#skill-tag(sk) #h(4pt)] }, ) } #let language-entry( language: "Language", proficiency: "Proficiency", ) = { table( columns: (1fr, 1fr), inset: 0pt, stroke: none, row-gutter: 3mm, align: left, table.cell( text( weight: "bold", language, ), ), table.cell( align: right, text( weight: "medium", proficiency, ), ) ) } #let recipient-style(str) = { text( style: "italic", str, ) } #let recipient-entry( name: "Name", title: "Title", company: "Company", address: "Address", city: "City", ) = { table( columns: 1fr, inset: 0pt, stroke: none, row-gutter: 3mm, align: left, recipient-style(name), recipient-style(title), recipient-style(company), recipient-style(address), ) } #let get-header-by-language(english-string, spanish-string) = { if language == "en" { english-string } else if language == "es" { spanish-string } } #let is-spanish() = { if language == "es" { true } else { false } } #let is-english() = { if language == "en" { true } else { false } }
https://github.com/tairahikaru/old-typst-japanese
https://raw.githubusercontent.com/tairahikaru/old-typst-japanese/main/scsnowman.typ
typst
Other
// scsnowman.typ // https://github.com/tairahikaru/old-typst-japanese // This file is based on scsnowman.sty (https://github.com/aminophen/scsnowman) // Copyright notice of scsnowman.sty is as follows: // > The BSD 2-Clause License // > Copyright (c) 2015-2023 <NAME> // This file is distributed under The BSD 2-Clause License. // // Require Typst 0.2.0 (23/04/11) #let scsnowman-init = ( scale: 1, body: false, // ! eyes: true, mouth: true, nose: false, sweat: false, arms: false, hat: false, muffler: false, buttons: false, snow: false, note: false, broom: false, ///shape: "normal", mouthshape: "smile", mikan: false, leaf: false, adjustbaseline: false, ) #let scsnowman-state = state("scsnowman", scsnowman-init) #let scsnowman( scale: none, body: none, eyes: none, mouth: none, nose: none, sweat: none, arms: none, hat: none, muffler: none, buttons: none, snow: none, note: none, broom: none, ///shape: none, mouthshape: none, mikan: none, leaf: none, adjustbaseline: none, ) = {locate(loc => { let setdefault(key, value) = { if value == none { return scsnowman-state.at(loc).at(key) } else if value == true { let v = scsnowman-state.at(loc).at(key) if v != false { return v } else { return true } } else { return value } } let scale = setdefault("scale", scale) let body = setdefault("body", body) let eyes = setdefault("eyes", eyes) let mouth = setdefault("mouth", mouth) let nose = setdefault("nose", nose) let sweat = setdefault("sweat", sweat) let arms = setdefault("arms", arms) let hat = setdefault("hat", hat) let muffler = setdefault("muffler", muffler) let buttons = setdefault("buttons", buttons) let snow = setdefault("snow", snow) let note = setdefault("note", note) let broom = setdefault("broom", broom) let mouthshape = setdefault("mouthshape", mouthshape) let mikan = setdefault("mikan", mikan) let leaf = setdefault("leaf", leaf) let adjustbaseline = setdefault("adjustbaseline", adjustbaseline) let H = scale * 1em let stroke = 0.01 * H box(width: H, height: H, place(dy: if adjustbaseline {0.08*H} else {0*H}, { set place(left+top) // body place({ path( closed: true, stroke: if body == false { stroke + black } else { auto }, fill: if body == false { none } else if body == true { black } else { body }, ((0.5*H,0.28*H), (0pt,0pt), (0.14*H,0.00*H)), ((0.76*H,0.45*H), (0*H, -0.1*H), (0.00*H,0.04*H)), ((0.67*H,0.56*H), (0.07*H, -0.03*H), (0.12*H,0.03*H)), ((0.84*H,0.75*H), (0*H, -0.07*H), (0.00*H,0.12*H)), ((0.68*H,0.92*H), (0.07*H,0*H), (0pt,0pt)), ((0.32*H,0.92*H), (0pt,0pt), (-0.07*H,0.00*H)), ((0.16*H,0.75*H), (0*H,0.12*H), (0.00*H,-0.07*H)), ((0.33*H,0.56*H), (-0.12*H, 0.03*H), (-0.05*H,-0.03*H)), ((0.24*H,0.45*H), (0*H, 0.04*H), (0.00*H,-0.10*H)), ((0.5*H,0.28*H), (-0.14*H, 0*H), (0pt,0pt)) ) }) let color(color) = { if color == true { if body == false { return black } else { return white } } else { return color } } // mouth if mouth != false { if mouthshape == "smile" { place({ path( stroke: stroke + color(mouth), ((0.40*H,0.52*H), (0pt,0pt), (0.05*H,0.03*H)), ((0.60*H,0.52*H), (-0.05*H,0.03*H), (0pt,0pt)), ) }) } else if mouthshape == "tight" { place({ path( stroke: stroke + color(mouth), (0.40*H,0.53*H), (0.60*H,0.53*H), ) }) } else if mouthshape == "frown" { place({ path( stroke: stroke + color(mouth), ((0.40*H,0.54*H), (0pt,0pt), (0.05*H,-0.03*H)), ((0.60*H,0.54*H), (-0.05*H,-0.03*H), (0pt,0pt)), ) }) } else { panic("Unknown mouthshape: ", mouthshape) } } // eyes if eyes != false { place({ place(dx: 0.38*H, dy: 0.41*H, ellipse(width: 0.04*H, height: 0.06*H, fill: color(eyes))) place(dx: 0.58*H, dy: 0.41*H, ellipse(width: 0.04*H, height: 0.06*H, fill: color(eyes))) }) } // sweat if sweat != false { place({ path( closed: true, stroke: stroke + color(sweat), ((0.70*H,0.44*H), (0pt,0pt), (-0.06*H,0.10*H)), ((0.70*H,0.44*H), (0.05*H,0.10*H), (0pt,0pt)), // repeat ((0.70*H,0.44*H), (0pt,0pt), (-0.06*H,0.10*H)), ((0.70*H,0.44*H), (0.05*H,0.10*H), (0pt,0pt)), ) }) } // nose if nose != false { place({ path( fill: color(nose), stroke: if body == false { auto } else { stroke + white }, closed: true, ((0.49*H,0.50*H), (0*H,0*H), (0.03*H,-0.01*H)), ((0.48*H,0.46*H), (0.03*H, 0*H), (-0.02*H,0.00*H)), ((0.40*H,0.48*H), (0*H,0*H), (-0.01*H,0.01*H)), ((0.49*H,0.50*H), (-0.03*H,0*H), (0*H,0*H)), // repeat ((0.49*H,0.50*H), (0*H,0*H), (0.03*H,-0.01*H)), ((0.48*H,0.46*H), (0.03*H, 0*H), (-0.02*H,0.00*H)), ((0.40*H,0.48*H), (0*H,0*H), (-0.01*H,0.01*H)), ((0.49*H,0.50*H), (-0.03*H,0*H), (0*H,0*H)), ) }) } let color(color) = { if color == true { if body == false { return black } else if body == true { return black } else { return body } } else { return color } } // hat if hat != false { place({ path( closed: true, fill: color(hat), (0.58*H,0.10*H), (0.77*H,0.19*H), ((0.74*H,0.39*H), (0pt,0pt), (-0.08*H,0.01*H)), ((0.46*H,0.28*H), (0.04*H, 0.06*H), (0pt,0pt)), (0.58*H,0.10*H), ) }) } // mikan if mikan != false { place({ place(dx: 0.35*H, dy: 0.08*H, ellipse(width: 0.30*H, height: 0.24*H, fill: color(mikan))) }) // leaf if leaf != false { place({ path( closed: true, fill: color(leaf), ((0.5*H,0.07*H), (0*H,0*H), (0.08*H,-0.02*H)), ((0.65*H,0.12*H), (-0.07*H,-0.07*H), (-0.15*H,0.01*H)), ((0.5*H,0.07*H), (0*H,0.06*H), (0*H,0*H)), ) }) } } // muffler if muffler != false { place({ path( closed: true, fill: color(muffler), stroke: if body == false { auto } else { stroke + white }, ((0.27*H,0.52*H), (0*H,0*H), (0.15*H,0.10*H)), ((0.73*H,0.52*H), (-0.15*H,0.1*H), (0.02*H,0.02*H)), ((0.77*H,0.59*H), (-0.01*H,-0.03*H), (0.00*H,0.02*H)), ((0.73*H,0.64*H), (0.02*H,-0.01*H), (0.01*H,0.03*H)), ((0.76*H,0.74*H), (-0.02*H,-0.05*H), (-0.01*H,0.01*H)), ((0.66*H,0.77*H), (0.06*H,-0.01*H), (0.00*H,-0.04*H)), ((0.63*H,0.66*H), (0.02*H,0.04*H), (-0.21*H,0.04*H)), ((0.24*H,0.59*H), (0.08*H,0.06*H), (0.01*H,-0.04*H)), ((0.27*H,0.52*H), (-0.01*H,0.01*H), (0*H,0*H)), // repeat ((0.27*H,0.52*H), (0*H,0*H), (0.15*H,0.10*H)), ((0.73*H,0.52*H), (-0.15*H,0.1*H), (0.02*H,0.02*H)), ((0.77*H,0.59*H), (-0.01*H,-0.03*H), (0.00*H,0.02*H)), ((0.73*H,0.64*H), (0.02*H,-0.01*H), (0.01*H,0.03*H)), ((0.76*H,0.74*H), (-0.02*H,-0.05*H), (-0.01*H,0.01*H)), ((0.66*H,0.77*H), (0.06*H,-0.01*H), (0.00*H,-0.04*H)), ((0.63*H,0.66*H), (0.02*H,0.04*H), (-0.21*H,0.04*H)), ((0.24*H,0.59*H), (0.08*H,0.06*H), (0.01*H,-0.04*H)), ((0.27*H,0.52*H), (-0.01*H,0.01*H), (0*H,0*H)), ) }) } // buttons if buttons != false { place({ place(dx: 0.47*H, dy: 0.81*H - if muffler != false { 0*H } else { 0.01*H }, circle(radius: 0.03*H, fill: color(buttons), stroke: if body == false { auto } else { stroke + white }) ) place(dx: 0.47*H, dy: 0.71*H - if muffler != false { 0*H } else { 0.01*H }, circle(radius: 0.03*H, fill: color(buttons), stroke: if body == false { auto } else { stroke + white }) ) }) } // broom if broom != false { place({ place(path(stroke: 0.0344444*H + color(broom), (0.03*H, 0.94*H), (0.12*H, 0.5*H) )) place(path(stroke: 0.01291665*H + color(broom), (0.11*H, 0.5*H), (0.06*H, 0.25*H) )) place(path(stroke: 0.01291665*H + color(broom), (0.12*H,0.50*H), (0.12*H,0.28*H) )) place(path(stroke: 0.01291665*H + color(broom), (0.12*H,0.50*H), (0.18*H,0.24*H) )) place(path(stroke: 0.01291665*H + color(broom), (0.12*H,0.50*H), (0.21*H,0.30*H) )) place(path(stroke: 0.01291665*H + color(broom), (0.13*H,0.50*H), (0.27*H,0.26*H) )) }) } // arms if arms != false { place({ place(path( // right closed: true, fill: color(arms), stroke: color(arms) + stroke, ((0.20*H,0.69*H), (0*H,0*H), (-0.01*H,-0.02*H)), ((0.13*H,0.58*H), (0.01*H,0.01*H), (-0.01*H,-0.01*H)), ((0.07*H,0.56*H), (0.03*H,0.01*H), (-0.03*H,-0.02*H)), ((0.08*H,0.54*H), (-0.02*H,0*H), (0.01*H,0.00*H)), ((0.12*H,0.56*H), (-0.01*H,0*H), (0.02*H,-0.02*H)), ((0.15*H,0.51*H), (-0.01*H,0.02*H), (0.01*H,-0.02*H)), ((0.16*H,0.52*H), (0*H,-0.01*H), (0.00*H,0.02*H)), ((0.15*H,0.57*H), (-0.01*H,-0.01*H), (0.01*H,0.01*H)), ((0.22*H,0.67*H), (-0.01*H,-0.02*H), (0.01*H,0.02*H)), ((0.20*H,0.69*H), (0.01*H,0.01*H), (0*H,0*H)), // repeat ((0.20*H,0.69*H), (0*H,0*H), (-0.01*H,-0.02*H)), ((0.13*H,0.58*H), (0.01*H,0.01*H), (-0.01*H,-0.01*H)), ((0.07*H,0.56*H), (0.03*H,0.01*H), (-0.03*H,-0.02*H)), ((0.08*H,0.54*H), (-0.02*H,0*H), (0.01*H,0.00*H)), ((0.12*H,0.56*H), (-0.01*H,0*H), (0.02*H,-0.02*H)), ((0.15*H,0.51*H), (-0.01*H,0.02*H), (0.01*H,-0.02*H)), ((0.16*H,0.52*H), (0*H,-0.01*H), (0.00*H,0.02*H)), ((0.15*H,0.57*H), (-0.01*H,-0.01*H), (0.01*H,0.01*H)), ((0.22*H,0.67*H), (-0.01*H,-0.02*H), (0.01*H,0.02*H)), ((0.20*H,0.69*H), (0.01*H,0.01*H), (0*H,0*H)), )) place(path( // left closed: true, fill: color(arms), stroke: color(arms) + stroke, ((0.80*H,0.69*H), (0*H,0*H), (0.01*H,-0.02*H)), ((0.87*H,0.58*H), (-0.01*H,0.01*H), (0.01*H,-0.01*H)), ((0.93*H,0.56*H), (-0.03*H,0.01*H), (0.03*H,-0.02*H)), ((0.92*H,0.54*H), (0.02*H,0*H), (-0.01*H,0.00*H)), ((0.88*H,0.56*H), (0.01*H,0*H), (-0.02*H,-0.02*H)), ((0.85*H,0.51*H), (0.01*H,0.02*H), (-0.01*H,-0.02*H)), ((0.84*H,0.52*H), (0*H,-0.01*H), (0.00*H,0.02*H)), ((0.85*H,0.57*H), (0.01*H,-0.01*H), (-0.01*H,0.01*H)), ((0.78*H,0.67*H), (0.01*H,-0.02*H), (-0.01*H,0.02*H)), ((0.80*H,0.69*H), (-0.01*H,0.01*H), (0*H,0*H)), // repeat ((0.80*H,0.69*H), (0*H,0*H), (0.01*H,-0.02*H)), ((0.87*H,0.58*H), (-0.01*H,0.01*H), (0.01*H,-0.01*H)), ((0.93*H,0.56*H), (-0.03*H,0.01*H), (0.03*H,-0.02*H)), ((0.92*H,0.54*H), (0.02*H,0*H), (-0.01*H,0.00*H)), ((0.88*H,0.56*H), (0.01*H,0*H), (-0.02*H,-0.02*H)), ((0.85*H,0.51*H), (0.01*H,0.02*H), (-0.01*H,-0.02*H)), ((0.84*H,0.52*H), (0*H,-0.01*H), (0.00*H,0.02*H)), ((0.85*H,0.57*H), (0.01*H,-0.01*H), (-0.01*H,0.01*H)), ((0.78*H,0.67*H), (0.01*H,-0.02*H), (-0.01*H,0.02*H)), ((0.80*H,0.69*H), (-0.01*H,0.01*H), (0*H,0*H)), )) }) } // snow if snow != false { place({ set circle(stroke: stroke + color(snow)) if body == false set circle(fill: color(snow)) if body != false if broom != false { place(dx:0.09*H, dy:0.15*H, circle(radius: 0.04*H)) } else { place(dx:0.03*H, dy:0.68*H, circle(radius: 0.04*H)) place(dx:0.09*H, dy:0.41*H, circle(radius: 0.04*H)) if note == false { place(dx:0.04*H, dy:0.28*H, circle(radius: 0.04*H)) place(dx:0.19*H, dy:0.22*H, circle(radius: 0.04*H)) } } place(dx:0.38*H, dy:0.07*H, circle(radius: 0.04*H)) place(dx:0.70*H, dy:0.07*H, circle(radius: 0.04*H)) place(dx:0.84*H, dy:0.23*H, circle(radius: 0.04*H)) place(dx:0.88*H, dy:0.43*H, circle(radius: 0.04*H)) place(dx:0.90*H, dy:0.73*H, circle(radius: 0.04*H)) }) } // note if note != false { place({ place(path( // musical note closed: true, fill: color(note), ((0.119*H,0.211*H), (0.000*H,-0.000*H), (-0.005*H,0.001*H)), ((0.115*H,0.219*H), (-0.001*H,-0.007*H), (0.007*H,0.041*H)), ((0.125*H,0.272*H), (-0.001*H,-0.004*H), (0.002*H,0.011*H)), ((0.118*H,0.283*H), (0.009*H,-0.000*H), (-0.013*H,-0.000*H)), ((0.096*H,0.302*H), (0.000*H,-0.011*H), (0.000*H,0.007*H)), ((0.106*H,0.317*H), (-0.006*H,-0.003*H), (0.010*H,0.004*H)), ((0.134*H,0.302*H), (-0.003*H,0.011*H), (0.001*H,-0.002*H)), ((0.132*H,0.280*H), (0.002*H,0.010*H), (-0.006*H,-0.032*H)), ((0.124*H,0.232*H), (0.001*H,0.004*H), (0.000*H,-0.005*H)), ((0.132*H,0.227*H), (-0.008*H,-0.000*H), (0.009*H,-0.001*H)), ((0.148*H,0.236*H), (-0.003*H,-0.007*H), (0.002*H,0.004*H)), ((0.155*H,0.239*H), (-0.001*H,0.003*H), (0.001*H,-0.000*H)), ((0.153*H,0.229*H), (0.002*H,0.005*H), (-0.002*H,-0.009*H)), ((0.139*H,0.211*H), (0.007*H,0.004*H), (-0.003*H,-0.002*H)), ((0.119*H,0.211*H), (0.007*H,-0.002*H), (-0.005*H,0.001*H)), )) place(path( // wavy line closed: true, fill: color(note), ((0.235*H,0.230*H), (0.000*H,-0.000*H), (-0.001*H,0.001*H)), ((0.231*H,0.239*H), (0.001*H,-0.004*H), (-0.003*H,0.011*H)), ((0.210*H,0.240*H), (0.013*H,0.011*H), (-0.007*H,-0.006*H)), ((0.195*H,0.234*H), (0.006*H,-0.000*H), (-0.009*H,-0.000*H)), ((0.174*H,0.250*H), (0.005*H,-0.011*H), (-0.004*H,0.008*H)), ((0.172*H,0.265*H), (-0.003*H,-0.003*H), (0.004*H,0.003*H)), ((0.183*H,0.259*H), (-0.004*H,0.007*H), (0.004*H,-0.009*H)), ((0.194*H,0.245*H), (-0.003*H,-0.000*H), (0.002*H,-0.000*H)), ((0.203*H,0.251*H), (-0.003*H,-0.003*H), (0.007*H,0.006*H)), ((0.225*H,0.262*H), (-0.005*H,-0.000*H), (0.006*H,-0.000*H)), ((0.241*H,0.251*H), (-0.004*H,0.007*H), (0.004*H,-0.008*H)), ((0.242*H,0.230*H), (0.004*H,0.004*H), (-0.003*H,-0.002*H)), ((0.235*H,0.230*H), (0.003*H,-0.002*H), (-0.003*H,0.005*H)), )) }) } })) })} #let scsnowmandefault(..args) = { // always global for (key,value) in args.named() { scsnowman-state.update(s => { if not key in s.keys() { panic("Unknown key: ", key) } s.insert(key, value) s }) } } #let makeitemsnowman(body) = { let func1 = eval( "(func, " + scsnowman-init.keys().join(",") + ")=>{" + "func.with(" + scsnowman-init.keys().map( e => { e + ":" + e }).join(",") + ")}" ) let values = scsnowman-init.values() let func2(func, array) = { if array == () { return func() } else { let value = array.remove(0) return func2(func.with(value), array) } } let scsnowman-list = func2(func1.with(scsnowman), values) let scsnowman-list = scsnowman-list.with( hat: black, eyes: black, mouth: black, ) set list(marker: ( scsnowman-list(muffler: rgb(100%,0%,0%)), scsnowman-list(muffler: rgb(0%,0%,100%)), scsnowman-list(muffler: rgb(0%,100%,0%)), scsnowman-list(muffler: cmyk(0%,0%,100%,0%)), )) body } // makeqedsnowman is not available #let scsnowmannumeral(num, ..args) = { let func1 = eval( "(func, " + args.named().keys().join(",") + ")=>{" + "func.with(" + args.named().keys().map( e => { e + ":" + e }).join(",") + ")}" ) let values = args.named().values() let func2(func, array) = { if array == () { return func() } else { let value = array.remove(0) return func2(func.with(value), array) } } let func = func2(func1.with(scsnowman), values) str(num).split("8").join(func()) }
https://github.com/giZoes/justsit-thesis-typst-template
https://raw.githubusercontent.com/giZoes/justsit-thesis-typst-template/main/resources/utils/datetime-display.typ
typst
MIT License
#import "@preview/a2c-nums:0.0.1": int-to-cn-num, int-to-cn-ancient-num, int-to-cn-simple-num, num-to-cn-currency // 显示中文日期 #let datetime-display(date) = { date.display("[year] 年 [month] 月 [day] 日") } // 显示英文日期 #let datetime-en-display(date) = { date.display("[month repr:short] [day], [year]") } // 显示汉字日期 #let datetime-cn-display(date) = { int-to-cn-simple-num(date.year()) text[年] int-to-cn-simple-num(date.month()) text[月] }