mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-01-11 13:38:24 +00:00
Merge branch 'main' of https://github.com/janishutz/eth-summaries
This commit is contained in:
Binary file not shown.
@@ -1,2 +1,60 @@
|
|||||||
\newsectionNoPB
|
\newsectionNoPB
|
||||||
\subsection{Line integrals}
|
\subsection{Line integrals}
|
||||||
|
\shortdef Let $I = [a, b]$ be a closed and bounded interval in $\R$. $f : I \rightarrow \R$ with $f(t) = (f_1(t), \ldots, f_n(t))$ continuous (also $f_i$ cont.).
|
||||||
|
\mrmvspace
|
||||||
|
\begin{enumerate}[noitemsep, label=(\arabic*)]
|
||||||
|
\item Then $\displaystyle \int_{a}^{b} f(t) \dx t = \left( \int_{a}^{b} f_1(t), \ldots, \int_{a}^{b} f_n(t) \right)$
|
||||||
|
\item \bi{Parametrized Curve} in $\R^n$ is a continuous map $\gamma: I \rightarrow \R^n$, piecewise in $C^1$, i.e. for $k \geq 1$, we have partition $a = t_0 < t_1 < \ldots < t_k = b$,
|
||||||
|
such that if $f$ is restricted to interval $]t_{j - 1}, t_j$, restriction is $C^1$. $\gamma$ is a \textit{path} between $\gamma(a)$ and $\gamma(b)$
|
||||||
|
\item \bi{Line integral} $X \subseteq \R^n$ is the image of $\gamma$ as above and $f : X \rightarrow \R^n$ cont.\\
|
||||||
|
Integral $\displaystyle\int_{a}^{b} f(\gamma(t)) \cdot \gamma'(t) \dx t \in \R$
|
||||||
|
is line integral of $f$ along $\gamma$, denoted $\displaystyle\int_{\gamma} f(s) \dx s$ or $\displaystyle\int_{\gamma} f(s) \dx \vec{s}$ or $\displaystyle\int_{\gamma} \omega$,\\
|
||||||
|
with $\omega = f_1(x) \dx x_1 + \ldots f_n(x) \dx x_n$
|
||||||
|
\end{enumerate}
|
||||||
|
|
||||||
|
\rmvspace
|
||||||
|
We usually call $f : X \rightarrow \R^n$ a \bi{vector field}, which maps each point $x \in X$ to a vector in $\R^n$, displayed as originating from $x$
|
||||||
|
|
||||||
|
\setLabelNumber{all}{4}
|
||||||
|
\compactdef{Oriented reparametrization} of $\gamma$ is parametrized curve $\sigma : [c, d] \rightarrow \R^n$ s.t $\sigma = \gamma \circ \varphi$, with $\varphi : [c, d] \rightarrow I$ cont. map,
|
||||||
|
differentiable on $]a, b[$ and for which $\varphi(a) = c$ and $\varphi(b) = d$.
|
||||||
|
Conversely, $\gamma = \sigma \circ \varphi^{-1}$
|
||||||
|
|
||||||
|
\rmvspace
|
||||||
|
\shortproposition For $f : X \rightarrow \R^n$ with $X$ containing the image of of $\gamma$ and equivalently $\sigma$,
|
||||||
|
we have $\displaystyle\int_{\gamma} f(s) \cdot \dx \vec{s} = \int_{\sigma} f(s) \cdot \dx \vec{s}$
|
||||||
|
|
||||||
|
\mrmvspace
|
||||||
|
\setLabelNumber{all}{8}
|
||||||
|
\compactdef{Conservative Vector Field} If for any $x_1, x_2 \in X$ the line integral $\displaystyle\int_{\gamma} f(s) \dx \vec{s}$ is independent choice of $\gamma$ in $X$
|
||||||
|
|
||||||
|
\mrmvspace
|
||||||
|
\shortremark $f$ conservative iff $\int_{\gamma} f(s) \dx \vec{s} = 0$ for a \textit{closed} ($\gamma(a) = \gamma(b)$) parametrized curve\\
|
||||||
|
%
|
||||||
|
\shorttheorem Let $X$ be open set, $f$ conservative vector field. Then $\exists C^1$ function $g$ s.t. $f = \nabla g$.
|
||||||
|
If any two points of $X$ can be joined by a parametrized curve, then $g$ is unique up to a constant: if $\nabla g_1 = f$, then $g - g_1$ is constant on $X$
|
||||||
|
|
||||||
|
\shortremark Two points $x, y \in X$ can be joined by parametrized curve $\gamma$ if $\gamma(a) = x$ and $\gamma(b) = y$. In that case, $X$ is called \bi{path-connected}.
|
||||||
|
It is true when $X$ is \textit{convex} (e.g. when $X$ is a disc or a product of intervals).
|
||||||
|
If $f$ is a vector field on $X$, then $g$ is called a \bi{potential} for $f$ and it is not unique, since we can add a constant to $g$ without changing the gradient.\\
|
||||||
|
%
|
||||||
|
\stepLabelNumber{all}
|
||||||
|
\shortproposition For a vectorfield to be conservative, a \textit{necessary condition} is that $\displaystyle\frac{\partial f_i}{\partial x_j} = \frac{\partial f_j}{x_i}$
|
||||||
|
for any $1 \leq i \neq j \leq n \in \N$\\
|
||||||
|
%
|
||||||
|
\stepLabelNumber{all}
|
||||||
|
\compactdef{Start Shaped Set} $X \subseteq \R^n$ is star shaped if $\exists x_0 \in X$ s.t. $\forall x \in X$, the line segment from $x$ to $x_0$ is contained in $X$,
|
||||||
|
and we also say that $X$ is \textit{star shaped around} $x_0$\\
|
||||||
|
%
|
||||||
|
\stepLabelNumber{all}
|
||||||
|
\shorttheorem Let $X$ start shaped and open, $f$ a $C^1$ vector field fulfilling Proposition \ref{all:4-1-13}. Then $f$ is conservative.
|
||||||
|
|
||||||
|
\drmvspace
|
||||||
|
\setLabelNumber{all}{20}
|
||||||
|
\shortdef Let $X \subseteq \R^3$ open and $f$ a $C^1$ vector field. Then the \bi{curl} of $f$ is the conservative vector field
|
||||||
|
$\text{curl}(f) = \begin{bmatrix}
|
||||||
|
\partial_y f_3 - \partial_z f_2 \\
|
||||||
|
\partial_z f_1 - \partial_x f_3 \\
|
||||||
|
\partial_x f_2 - \partial_y f_1
|
||||||
|
\end{bmatrix}$
|
||||||
|
\ddrmvspace
|
||||||
|
|||||||
@@ -1,2 +1,48 @@
|
|||||||
\newsectionNoPB
|
\newsectionNoPB
|
||||||
\subsection{Riemann integral in Vector Space}
|
\subsection{Riemann integral in Vector Space}
|
||||||
|
The integral of a continuous function $f: X \rightarrow \R$ with $X \subseteq \R^n$ bounded and closed, is denoted $\int_X f(x) \dx x$ with properties:
|
||||||
|
\rmvspace
|
||||||
|
\begin{enumerate}[label=(\arabic*), noitemsep]
|
||||||
|
\item \bi{(Compatibility)} If $n = 1$ and $X = [a, b]$, integral is the indefinite integral as per Analysis I
|
||||||
|
\item \bi{(Linearity)} If $f$, $g$ are continuous on $X$ and $a, b \in \R$, then $\displaystyle \int_X (a f(x) + b g(x)) \dx x = a \int_X f(x) \dx x + b \int_X g(x) \dx x$
|
||||||
|
\item \bi{(Positivity)} If $f \leq g$, then so is the integral and if $f \geq 0$, so is the integral and if $Y \subseteq X$, then int. over $Y$ is $\leq$ over $X$
|
||||||
|
\item \bi{(Upper bound \& Triangle Inequality)} $\displaystyle \left| \int_{X} f(x) \dx x \right| \leq \int_{X} |f(x)|\dx x$ and
|
||||||
|
$\displaystyle \left| \int_{X} (f(x) + g(x)) \dx x \right| \leq \int_{X} |f(x)| \dx x \int_X |g(x)|$
|
||||||
|
\item \bi{(Volume)} The integral of $f$ is the volume of $\{ (x, y) \in X \times \R : 0 \leq y \leq f(x) \} \subseteq \R^{n + 1}$.
|
||||||
|
If $X$ is a bounded rectangle, e.g. $X = [a_1, b_1] \times \ldots \times [a_n, b_n] \subseteq \R^n$ and $f = 1$, then $\int_{X} \dx x = (b_n - a_n) \dots (b_1 - a_1)$.
|
||||||
|
We write $\text{Vol}(X)$ or $\text{Vol}_n(X)$
|
||||||
|
\item \bi{(Multiple integral)} \textit{(Fubini)} If $n_1, n_2 \in \Z$ s.t. $n = n_1 + n_2$,
|
||||||
|
then for $x_1 \in \R^{n_1}$, let $Y_{x_1} = \{ x_2 \in \R^{n_2} : (x_1, x_2) \in X \} \subseteq \R^{n_2}$.
|
||||||
|
Let $X_1$ be the set of $x_1 \in \R^n$ such that $Y_{x_1}$ is not empty. Then $X_1$ and $Y_{x_1}$ are compact.\\
|
||||||
|
If $\displaystyle g(x_1) = \int_{Y_{x_1}} f(x_1, x_2) \dx x_2$ is continuous on $X_1$, then
|
||||||
|
\dnrmvspace
|
||||||
|
\begin{align*}
|
||||||
|
\int_{X} f(x_1, x_2) \dx x = \int_{X_1} g(x_1) \dx x = \int_{X_1} g(x_1) \dx x_1 = \int_{X_1} \left( \int_{Y_{x_1}} f(x_1, x_2) \dx x_2 \right) \dx x_1
|
||||||
|
\end{align*}
|
||||||
|
|
||||||
|
\rmvspace
|
||||||
|
Exchanging the role of $x_1$ and $x_2$ we have (with $Z_{x_2} = \{ x_1 : (x_1, x_2) \in X \}$) if integral over $x_1$ is continuous.
|
||||||
|
\rmvspace
|
||||||
|
\begin{align*}
|
||||||
|
\int_{X} f(x_1, x_2) \dx x = \int_{X_2} \left( \int_{Z_{x_2}} f(x_1, x_2) \dx x_1 \right) \dx x_2
|
||||||
|
\end{align*}
|
||||||
|
\drmvspace
|
||||||
|
\item \bi{(Domain additivity)} If $X_1$ and $X_2$ are compact and $f$ continuous on $X = X_1 \cup X_2$, then (for $Y = X_1 \cap X_2$)
|
||||||
|
\rmvspace
|
||||||
|
\begin{align*}
|
||||||
|
\int_X f(x) \dx x + \int_Y f(x) \dx x = \int_{X_1} f(x) \dx x + \int_{X_2} f(x) \dx x
|
||||||
|
\end{align*}
|
||||||
|
|
||||||
|
\rmvspace
|
||||||
|
In particular, if $Y$ empty (or size is ``negligible''), then $\int_{X} f(x) \dx x = \int_{X_1} f(x) \dx x + \int_{X_2} f(x) \dx x$
|
||||||
|
\end{enumerate}
|
||||||
|
\setLabelNumber{all}{3}
|
||||||
|
\shortdef For $m \leq n \in \N$, a \bi{parametrized $m$-set} in $\R^n$ is a continuous map $f: [a_1, b_1] \times \ldots \times [a_m, b_m] \rightarrow \R^n$,
|
||||||
|
which is $C^1$ on $]a_1, b_1[ \times \ldots \times ]a_m, b_m[$.
|
||||||
|
$B \subseteq \R^n$ is \bi{negligible} if $\exists k \geq 0 \in \Z$ and parametrized $m_i$-sets $f_i: X_i \rightarrow \R^n$ with $1 \leq i \leq k$ and $m_i < n$ s.t.
|
||||||
|
$X \subseteq f_1(x_1) \cup \ldots \cup f_k(X_k)$. A parametrized $1$-set in $\R^n$ is a parametrized curve.
|
||||||
|
\shortex Any $\R \times \{ 0 \} \subseteq \R^2$ is negligible in $\R^2$, or more generally,
|
||||||
|
if $H \subseteq \R^n$ is an affine subspsace of dimension $m < n$, then any subset of $\R^n$ that is contained in $H$ is negligible.
|
||||||
|
Image of par. curve $\gamma: [a, b] \rightarrow \R^n$ is negligible, since $\gamma$ is a $1$-set in $\R^n$
|
||||||
|
|
||||||
|
\shortproposition $X$ compact set, negligible. Then for any cont. function on $X$, $\displaystyle\int_{X} f(x) \dx x = 0$
|
||||||
|
|||||||
@@ -1,2 +1,11 @@
|
|||||||
\newsectionNoPB
|
\newsectionNoPB
|
||||||
\subsection{Improper integrals}
|
\subsection{Improper integrals}
|
||||||
|
As in the one-dimensional case, we are looking at integrals that are undefined at the edge of the interval and thus, we apply a limit to them,
|
||||||
|
thus approaching said edge of the interval.
|
||||||
|
|
||||||
|
For example, in the two-dimensional case, disc $D_R = [-R, R]^2$ with radius $R$
|
||||||
|
\rmvspace
|
||||||
|
\begin{align*}
|
||||||
|
\limit{R}{\infty} \int_{D_R} f(d, y) \dx x \dx y
|
||||||
|
\end{align*}
|
||||||
|
\ddrmvspace
|
||||||
|
|||||||
@@ -1,2 +1,9 @@
|
|||||||
\newsectionNoPB
|
\newsectionNoPB
|
||||||
\subsection{Change of Variable Formula}
|
\subsection{Change of Variable Formula}
|
||||||
|
\compacttheorem{Change of variable formula} $\overline{X}, \overline{Y} \subseteq \R^n$ compact, $\varphi : \overline{X} \rightarrow \overline{Y}$ continuous.
|
||||||
|
For the open sets $X, Y$, negligible sets $B, C$ and restriction of $\varphi : X \rightarrow Y$ to open set $X$ is a $C^1$ bijection,
|
||||||
|
we can write $\overline{X} = X \cup B$ and $\overline{Y} = Y \cup C$.
|
||||||
|
The Jacobian $J_\varphi(x)$ is invertible at all $x \in X$.
|
||||||
|
For any cont. func. $f$ on $\overline{Y}$ we have $\displaystyle \int_{\overline{X}} f(\varphi(x)) |\det(J_\varphi(x))| \dx x = \int_{\overline{Y}} f(y) \dx y$
|
||||||
|
% TODO: Add notes from TA's notes for how to apply it
|
||||||
|
\rmvspace
|
||||||
|
|||||||
@@ -1,2 +1,22 @@
|
|||||||
\newsectionNoPB
|
\newsectionNoPB
|
||||||
\subsection{The Green Formula}
|
\subsection{The Green Formula}
|
||||||
|
\compactdef{Simple parametrized curve} $\gamma : [a, b] \rightarrow \R^2$ is a closed parametrized curve s.t.
|
||||||
|
$\gamma(t) \neq \gamma(s)$ (if $s \neq t$ and $\{ s, t \} = \{ a, b \}$), s.t. $\gamma'(t) \neq 0$ for $a < t < b$.
|
||||||
|
If $\gamma$ only piecewise in $C^1$ in $]a, b[$, then only apply when $\gamma'(t)$ exists.
|
||||||
|
|
||||||
|
\stepLabelNumber{all}
|
||||||
|
\compacttheorem{Green's Formula} $X \subseteq \R^2$ compact set with boundary $\partial X = \gamma_1 \cup \ldots \cup y_k$
|
||||||
|
with $\gamma_i = (\gamma_{i, 1}, \gamma_{i, 2}) : [a_i, b_i] \rightarrow \R^2$ a simple closed parametrized curve, with property that $X$ lies ``to the left'' of tangent vector $\gamma_i'(t)$ based at $\gamma_i(t)$.
|
||||||
|
$f = (f_1, f_2)$ is a vector field of class $C^1$ on open set containing $X$. Then:
|
||||||
|
\drmvspace
|
||||||
|
\begin{align*}
|
||||||
|
\int_{X} \left( \frac{\partial f_2}{\partial x} - \frac{\partial f_1}{\partial_y} \right) \dx x \dx y = \sum_{i = 1}^{k} \int_{\gamma_i} f \cdot \dx \vec{s}
|
||||||
|
\end{align*}
|
||||||
|
|
||||||
|
\stepLabelNumber{all}\dhrmvspace
|
||||||
|
\inlinecorollary $X \subseteq \R^2$ compact with boundary $\partial X$ as before.
|
||||||
|
$\gamma_i$ as above, then
|
||||||
|
\drmvspace
|
||||||
|
\begin{align*}
|
||||||
|
\text{Vol}(X) = \sum_{i = 1}^{k} \int_{\gamma_i} x \dx \vec{s} = \sum_{i = 1}^{k} \int_{a_i}^{b_i} \gamma_{i, 1}(t) \gamma_{i, 2}'(t) \dx t
|
||||||
|
\end{align*}
|
||||||
|
|||||||
Binary file not shown.
276
semester3/spca/code-examples/.clang-format
Normal file
276
semester3/spca/code-examples/.clang-format
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
# ─────────────────────────────────────────────────────────────────────
|
||||||
|
# ╭─────────────────────────────────────────────────╮
|
||||||
|
# │ clang-format config │
|
||||||
|
# ╰─────────────────────────────────────────────────╯
|
||||||
|
# ─────────────────────────────────────────────────────────────────────
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: BlockIndent
|
||||||
|
AlignArrayOfStructures: Left
|
||||||
|
AlignConsecutiveAssignments:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: true
|
||||||
|
AlignConsecutiveBitFields:
|
||||||
|
Enabled: true
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveDeclarations:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveMacros:
|
||||||
|
Enabled: true
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveShortCaseStatements:
|
||||||
|
Enabled: true
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCaseArrows: false
|
||||||
|
AlignCaseColons: false
|
||||||
|
AlignConsecutiveTableGenBreakingDAGArgColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveTableGenCondOperatorColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveTableGenDefinitionColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowBreakBeforeNoexceptSpecifier: Never
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseExpressionOnASingleLine: true
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortCompoundRequirementOnASingleLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakAdjacentStringLiterals: true
|
||||||
|
BreakAfterAttributes: Always
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakAfterReturnType: None
|
||||||
|
BreakArrays: true
|
||||||
|
BreakBeforeBinaryOperators: All
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeConceptDeclarations: Always
|
||||||
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakFunctionDefinitionParameters: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
BreakTemplateDeclarations: MultiLine
|
||||||
|
ColumnLimit: 100
|
||||||
|
CommentPragmas: "^ IWYU pragma:"
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: true
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: Always
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: ^"(llvm|llvm-c|clang|clang-c)/
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: ^(<|"(gtest|gmock|isl|json)/)
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: .*
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IncludeIsMainRegex: (Test)?$
|
||||||
|
IncludeIsMainSourceRegex: ""
|
||||||
|
IndentAccessModifiers: true
|
||||||
|
IndentCaseBlocks: true
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: BeforeHash
|
||||||
|
IndentRequiresClause: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
InsertBraces: false
|
||||||
|
InsertNewlineAtEOF: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
IntegerLiteralSeparator:
|
||||||
|
Binary: 0
|
||||||
|
BinaryMinDigits: 0
|
||||||
|
Decimal: 0
|
||||||
|
DecimalMinDigits: 0
|
||||||
|
Hex: 0
|
||||||
|
HexMinDigits: 0
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLines:
|
||||||
|
AtEndOfFile: false
|
||||||
|
AtStartOfBlock: true
|
||||||
|
AtStartOfFile: true
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
LineEnding: DeriveLF
|
||||||
|
MacroBlockBegin: ""
|
||||||
|
MacroBlockEnd: ""
|
||||||
|
MainIncludeChar: Quote
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PPIndentWidth: -1
|
||||||
|
PackConstructorInitializers: BinPack
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakScopeResolution: 500
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Right
|
||||||
|
QualifierAlignment: Left
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: true
|
||||||
|
RemoveBracesLLVM: true
|
||||||
|
RemoveParentheses: MultipleParentheses
|
||||||
|
RemoveSemicolon: false
|
||||||
|
RequiresClausePosition: OwnLine
|
||||||
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Always
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SkipMacroDefinitionBody: false
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: LexicographicNumeric
|
||||||
|
SpaceAfterCStyleCast: true
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: true
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeJsonColon: false
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: true
|
||||||
|
AfterForeachMacros: true
|
||||||
|
AfterFunctionDeclarationName: true
|
||||||
|
AfterFunctionDefinitionName: true
|
||||||
|
AfterIfMacros: true
|
||||||
|
AfterOverloadedOperator: false
|
||||||
|
AfterPlacementOperator: true
|
||||||
|
AfterRequiresInClause: false
|
||||||
|
AfterRequiresInExpression: false
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParens: Custom
|
||||||
|
SpacesInParensOptions:
|
||||||
|
ExceptDoubleParentheses: false
|
||||||
|
InConditionalStatements: true
|
||||||
|
InCStyleCasts: false
|
||||||
|
InEmptyParentheses: false
|
||||||
|
Other: true
|
||||||
|
SpacesInSquareBrackets: true
|
||||||
|
Standard: Latest
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 4
|
||||||
|
TableGenBreakInsideDAGArg: DontBreak
|
||||||
|
UseTab: Never
|
||||||
|
VerilogBreakBetweenInstancePorts: true
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- STRINGIZE
|
||||||
16
semester3/spca/code-examples/00_c/00_intro.c
Normal file
16
semester3/spca/code-examples/00_c/00_intro.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// This is a line comment
|
||||||
|
/* this is a block comment */
|
||||||
|
#include "01_func.h" // Relative import
|
||||||
|
|
||||||
|
int i = 0; // This allocates an integer on the stack
|
||||||
|
|
||||||
|
int main( int argc, char *argv[] ) {
|
||||||
|
// This is the function body of a function (here the main function)
|
||||||
|
// which serves as the entrypoint to the program in C and has arguments
|
||||||
|
printf( "Argc: %d\n", argc ); // Number of arguments passed, always >= 1
|
||||||
|
// (first argument is the executable name)
|
||||||
|
for ( int i = 0; i < argc; i++ ) // For loop just like any other sane programming language
|
||||||
|
printf( "Arg %d: %s\n", i, argv[ i ] ); // Outputs the i-th argument from CLI
|
||||||
|
|
||||||
|
get_user_input_int( "Select a number" ); // Function calls as in any other language
|
||||||
|
}
|
||||||
37
semester3/spca/code-examples/00_c/01_func.c
Normal file
37
semester3/spca/code-examples/00_c/01_func.c
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#include "01_func.h"
|
||||||
|
|
||||||
|
int get_user_input_int( char prompt[] ) {
|
||||||
|
int input_data;
|
||||||
|
printf( "%s", prompt ); // Always wrap strings like this for printf
|
||||||
|
scanf( "%d", &input_data ); // Get user input from CLI
|
||||||
|
|
||||||
|
// If statements just like any other language
|
||||||
|
if ( input_data )
|
||||||
|
printf( "Not 0" );
|
||||||
|
else
|
||||||
|
printf( "Input is zero" );
|
||||||
|
|
||||||
|
switch ( input_data ) {
|
||||||
|
case 5:
|
||||||
|
printf( "You win!" );
|
||||||
|
break; // Doesn't fall through
|
||||||
|
case 6:
|
||||||
|
printf( "You were close" ); // Falls through
|
||||||
|
default:
|
||||||
|
printf( "No win" ); // Case for any not covered input
|
||||||
|
}
|
||||||
|
|
||||||
|
int input_data_copy = input_data;
|
||||||
|
|
||||||
|
while ( input_data > 1 ) {
|
||||||
|
input_data -= 1;
|
||||||
|
printf( "Hello World\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
input_data -= 1;
|
||||||
|
printf( "Bye World\n" );
|
||||||
|
} while ( input_data_copy > 1 );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
4
semester3/spca/code-examples/00_c/01_func.h
Normal file
4
semester3/spca/code-examples/00_c/01_func.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#include <stdio.h> // Import from system path
|
||||||
|
// (like library imports in other languages)
|
||||||
|
|
||||||
|
int get_user_input_int( char prompt[] );
|
||||||
0
semester3/spca/code-examples/00_c/02_pointers.c
Normal file
0
semester3/spca/code-examples/00_c/02_pointers.c
Normal file
0
semester3/spca/code-examples/00_c/02_pointers.h
Normal file
0
semester3/spca/code-examples/00_c/02_pointers.h
Normal file
15
semester3/spca/parts/00_c/00_intro.tex
Normal file
15
semester3/spca/parts/00_c/00_intro.tex
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
\begin{scriptsize}
|
||||||
|
\textit{I can clearly C why you'd want to use C. Already sorry in advance for all the bad C jokes that are going to be part of this section}
|
||||||
|
\end{scriptsize}
|
||||||
|
|
||||||
|
\texttt{C} is a compiled, low-level programming language, lacking many features modern high-level programming languages offer, like Object Oriented programming,
|
||||||
|
true Functional Programming (like Haskell implements), Garbage Collection, complex abstract datatypes and vectors, just to name a few.
|
||||||
|
(It is possible to replicate these using Preprocessor macros, more on this later).
|
||||||
|
|
||||||
|
On the other hand, it offers low-level hardware access, the ability to directly integrate assembly code into the \texttt{.c} files,
|
||||||
|
as well as bit level data manipulation and extensive memory management options, again just to name a few.
|
||||||
|
|
||||||
|
This of course leads to \texttt{C} performing excellently and there are many programming languages whose compiler doesn't directly produce machine code or assembly,
|
||||||
|
but instead optimized \texttt{C} code that is then compiled into machine code using a \texttt{C} compiler.
|
||||||
|
This has a number of benefits, most notably that \texttt{C} compilers can produce very efficient assembly,
|
||||||
|
as lots of effort is put into the \texttt{C} compilers by the hardware manufacturers.
|
||||||
13
semester3/spca/parts/00_c/01_syntax.tex
Normal file
13
semester3/spca/parts/00_c/01_syntax.tex
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
\subsection{The Syntax}
|
||||||
|
\texttt{C} uses a very similar syntax as many other programming languages, like \texttt{Java}, \texttt{JavaScript} and many more\dots
|
||||||
|
to be precise, it is \textit{them} that use the \texttt{C} syntax, not the other way around. So:
|
||||||
|
\inputcodewithfilename{c}{code-examples/00_c/}{00_intro.c}
|
||||||
|
|
||||||
|
In \texttt{C} we are referring to the implementation of a function as a \bi{(function) definition} (correspondingly, \textit{variable definition}, if the variable is initialized)
|
||||||
|
and to the definition of the function signature (or variables, without initializing them) as the \bi{(function) declaration} (or, correspondingly, \textit{variable declaration}).
|
||||||
|
|
||||||
|
\texttt{C} code is usuallt split into the source files, ending in \texttt{.c} (where the local functions and variables are declared, as well as all function definitions)
|
||||||
|
and the header files, ending in \texttt{.h}, where the external declarations are defined. Usually, no definition of functions are in the \texttt{.h} files
|
||||||
|
\inputcodewithfilename{c}{code-examples/00_c/}{01_func.h}
|
||||||
|
|
||||||
|
\inputcodewithfilename{c}{code-examples/00_c/}{01_func.c}
|
||||||
0
semester3/spca/parts/01_asm/00_intro.tex
Normal file
0
semester3/spca/parts/01_asm/00_intro.tex
Normal file
0
semester3/spca/parts/02_hw/00_intro.tex
Normal file
0
semester3/spca/parts/02_hw/00_intro.tex
Normal file
@@ -1,10 +0,0 @@
|
|||||||
\newsection
|
|
||||||
\section{Introduction to C}
|
|
||||||
I can clearly C why you'd want to use C. Already sorry in advance for all the bad C jokes that are going to be part of this section
|
|
||||||
|
|
||||||
\texttt{C} is a compiled, low-level programming language, lacking many features modern high-level programming languages offer, like Object Oriented programming, true Functional Programming, Garbage Collection, complex abstract datatypes and vectors, just to name a few. (It is possible to replicate these, more on this later).
|
|
||||||
|
|
||||||
On the other hand, it offers the ability to directly integrate assembly code into the \texttt{.c} files, as well as bit level data manipulation and extensive memory management options, again just to name a few.
|
|
||||||
|
|
||||||
This of course leads to \texttt{C} performing excellently and there are many programming languages who's compiler doesn't directly produce machine code or assembly, but instead optimized \texttt{C} code that is then compiled into machine code using a \texttt{C} compiler.
|
|
||||||
This has a number of benefits, most notably that \texttt{C} compilers can produce very efficient assembly, as lots of effort is put into the \texttt{C} compilers by the hardware manufacturers.
|
|
||||||
Binary file not shown.
@@ -1,11 +1,12 @@
|
|||||||
\documentclass{article}
|
\documentclass{article}
|
||||||
|
|
||||||
\newcommand{\dir}{~/projects/latex}
|
\input{~/projects/latex/dist/full.tex}
|
||||||
\input{\dir/include.tex}
|
|
||||||
\load{recommended}
|
|
||||||
|
|
||||||
\setup{Systems Programming and Computer Architecture}
|
\setup{Systems Programming and Computer Architecture}
|
||||||
|
|
||||||
|
\usepackage{lmodern}
|
||||||
|
\setFontType{sans}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\startDocument
|
\startDocument
|
||||||
\usetcolorboxes
|
\usetcolorboxes
|
||||||
@@ -54,7 +55,21 @@
|
|||||||
% │ Content │
|
% │ Content │
|
||||||
% ╰────────────────────────────────────────────────╯
|
% ╰────────────────────────────────────────────────╯
|
||||||
% ── Intro to C ──────────────────────────────────────────────────────
|
% ── Intro to C ──────────────────────────────────────────────────────
|
||||||
\input{parts/intro-to-c/start.tex}
|
\newsection
|
||||||
|
\section{The C Programming Language}
|
||||||
|
\input{parts/00_c/00_intro.tex}
|
||||||
|
\input{parts/00_c/01_syntax.tex}
|
||||||
|
|
||||||
|
|
||||||
|
% ── Intro to x86 asm ────────────────────────────────────────────────
|
||||||
|
\newsection
|
||||||
|
\section{x86 Assembly}
|
||||||
|
\input{parts/01_asm/00_intro.tex}
|
||||||
|
|
||||||
|
|
||||||
|
% ── Hardware recap ──────────────────────────────────────────────────
|
||||||
|
\newsection
|
||||||
|
\section{Hardware}
|
||||||
|
\input{parts/02_hw/00_intro.tex}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|||||||
Reference in New Issue
Block a user