Files
TDT4200/exercise1/theory.typ
2025-09-04 15:46:32 +02:00

71 lines
2.2 KiB
Typst

#import "@preview/cetz:0.3.2";
#import "@preview/cetz-plot:0.1.1": plot
#import "@preview/physica:0.9.4": *
#import "@preview/plotsy-3d:0.1.0": plot-3d-parametric-surface
#import "@preview/fletcher:0.5.4" as fletcher: diagram, edge, node
#set page(paper: "a4", margin: (x: 2.6cm, y: 2.8cm), numbering: "1 : 1")
#set par(justify: true, leading: 0.52em)
#let FONT_SIZE = 18pt;
#set text(font: "FreeSerif", size: FONT_SIZE, lang: "us")
#show math.equation: set text(font: "Euler Math", size: (FONT_SIZE * 1.0), lang: "en")
#set heading(numbering: none)
#show heading.where(level: 1): it => {
rect(inset: FONT_SIZE / 2)[#it]
}
// Dracula palette
#let bg = rgb("#282a36")
#let fg = rgb("#f8f8f2")
#let sec = rgb("#44475a")
#align(center)[
#text(size: FONT_SIZE * 2, weight: "bold")[#underline[exercise 0]]
]
these are my solutions to exercise set 1 of TDT4200.
this document was created using
#link("https://typst.app/")[#text(blue.darken(5%))[typst]].
#v(42pt)
#outline(title: none)
#v(42pt)
= macros
macros define programmer-friendly syntax that is preprocessed at compile time,
thus incurring no performance penality. they constitute a fundamental part in
meta programming (see lisp). excessive use of macros may obfuscate semantics,
but can often be used to make the code clearer to read. in this case, it helps
simplify the indexing of the buffers for easier to read calculations.
= boundary conditions
the boundary condition could be changed from reflection to wrapping around. this
can be achieved by setting the left boundary to be the right-most point, and the
right boundary to be the left-most point.
= no memory
if you don't allocate memory in T1, the buffers will be unallocated and you will
get indexing errors as you try to access the buffers using the predefined
macros.
basically, you segfault.
= `float const *a` vs `float *const b`
- `float const *a` is a constant pointer to some memory address, assigned to the
constant name `a`. since `a` is constant, it cannot be reassigned.
- `float *const b` is a pointer to some constant value, assigned to the
variable `b`. since `b` points to a constant, the dereferenced value cannot be
changed.
these are not the same.