Skip to content

Commit

Permalink
Python environment
Browse files Browse the repository at this point in the history
Include instruction on how to use python environment.

Update analys b.
  • Loading branch information
mnerv committed Mar 19, 2024
1 parent d8fbe40 commit 40d4819
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 29 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ dist-ssr
node_modules
public/*.tar.gz
public/pdf
test.png

# Environments
.venv

# Editor directories and files
!.vscode/extensions.json
Expand Down Expand Up @@ -57,4 +61,3 @@ yarn-error.log*
# Xcode
*.xcworkspace
*.xcodeproj

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ Start latex docker image.
docker run -it --rm -v "$(pwd):/home/porter/app" --hostname latex --name maths latex
```

## Python Environment

Use python environment for generating graph and experiments. Requires `venv`.

```sh
python3 -m venv .venv
```

Activate it by using the script inside the .venv `directory`.

```sh
.venv/Script/activate.sh
```

Install packages from the `requirements.txt`

```sh
pip install -r ./requirements.txt
```

## Resources

- Inner product space - <https://en.wikipedia.org/wiki/Inner_product_space>
Expand Down
9 changes: 7 additions & 2 deletions analys_b/20231027/4b-kurvlängd.tex
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@
\int_0^2 \sqrt{x'(t)^2 + y'(t)^2} dt &= \int_0^2 \sqrt{\left(e^t - e^{-t}\right)^2 + 2^2} dt \\
\int_0^2 \sqrt{e^{2t} + e^{-2t} + 2} dt &= \left[\begin{aligned}
u &= e^{2t} + e^{-2t} + 2\\
\frac{du}{dt} &= 2e^{2t} - 2e^{-2t} \Leftrightarrow \frac{du}{2} = e^{2t} - e^{-2t}dt
\end{aligned}\right]
\frac{du}{dt} &= 2e^{2t} - 2e^{-2t} \Leftrightarrow du = 2e^{2t} - 2e^{-2t}dt\\
a &= e^(2 \cdot 0) + e^{-2 \cdot 0} + 2 = 4\\
b &= e^{2 \cdot 2} + e^{-2 \cdot 2} + 2 = e^4 + e^{-4} + 2
\end{aligned}\right]\\
&= \int_a^b \sqrt{u} du = \left[\frac{2}{3}u^{\frac{3}{2}}\right]_a^b\\
&= \frac{2}{3}\left[u^{\frac{3}{2}}\right]_2^{e^4 + e^{-4}} \\
&= \frac{2}{3}\left(\left(e^4 + e^{-4}\right)^{\frac{3}{2}} - \left(2\right)^{\frac{3}{2}}\right)
\end{align}

\end{document}
Expand Down
23 changes: 12 additions & 11 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ abs_pdf_dir=""
file_deps=""

help() {
printf "usage: $arg0 [options] <file.tex>\n"
printf "\n"
printf "options:\n"
printf " -h, --help Show this menu.\n"
printf " --dry-run Dry run the commands.\n"
printf " --build-dir=<directory> Specify build directory.\n"
printf " --skip-bibtex Skip generating bibtex.\n"
printf " --no-cache This action skips the cache check.\n"
# printf " --no-spin Disable spin status for compile steps.\n"
printf " --clean Clean before build. This will remove\n"
printf " output pdf and the build intermediate steps.\n"
cat << EOF
usage: $arg0 [options] <file.tex>
options:
-h, --help Show this menu.
--dry-run Dry run the commands.
--build-dir=<directory> Specify build directory.
--skip-bibtex Skip generating bibtex.
--no-cache This action skips the cache check.
--clean Clean before build. This will remove
output pdf and the build intermediate steps.
EOF
}

parse_args() {
Expand Down
32 changes: 17 additions & 15 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ is_production=false
is_skip_load_cache=false

help() {
printf "usage: $arg0 [options]\n"
printf "\n"
printf "options:\n"
printf " -h, --help Show this menu.\n"
printf " --dry-run Dry run the commands.\n"
printf " --clean Clean the output directories build and pdfs\n"
printf " before compiling.\n"
printf " --parallel Use parallel to run the compile scripts.\n"
printf " --production Create pdf in distribution directory.\n"
printf " --build-dir Specify build directory,\n"
printf " example: --build-dir=\"build\". Default: build.\n"
printf " --dist-dir Specify dist directory,\n"
printf " example: --dist-dir=\"dist\". Default: dist.\n"
printf " --cache-uri Set cache uri to download.\n"
printf " --skip-load-cache Skip loading cache.\n"
cat << EOF
usage: $arg0 [options]
options:
-h, --help Show this menu.
--dry-run Dry run the commands.
--clean Clean the output directories build and pdfs
before compiling.
--parallel Use parallel to run the compile scripts.
--production Create pdf in distribution directory.
--build-dir Specify build directory,
example: --build-dir=\"build\". Default: build.
--dist-dir Specify dist directory,
example: --dist-dir=\"dist\". Default: dist.
--cache-uri Set cache uri to download.
--skip-load-cache Skip loading cache.
EOF
}

generate_file_index() {
Expand Down
71 changes: 71 additions & 0 deletions misc/doit.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % Fix weird character
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{gensymb}
\usepackage{spalign}
\usepackage{xfrac}
\usepackage{parskip}
\usepackage{float} % figure[H]
\usepackage[style=ieee,backend=biber]{biblatex}
\usepackage[breaklinks=true,bookmarks=true,hidelinks]{hyperref}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest,compat/show suggested version=false}

\geometry{
a4paper,
hmargin=2.54cm,
tmargin=1.27cm,
bmargin=1.27cm,
includeheadfoot
}
\setcounter{secnumdepth}{0} % Disable section numbering

\begin{document}
\section{Dator- och internetteknik}

\subsection{Computer Architectures}

\subsubsection{General Architecture}

Memory

ALU

Control Unit

Registers

Intterupts

Cache Memory

Pipelining

CISC/RISC

Bus

\subsubsection{Different Type of Systems}

Von-Neumann Model

General Purpose System

Parallel Processing

Flynn's Classification of Computers

\subsubsection{Instructions}

Single Instruction and Single Data Stream

Single Instruction and Multiple Data Stream

Multiple Instruction and Single Data Stream

\end{document}

26 changes: 26 additions & 0 deletions misc/pdm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# %% Imports
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import signal
from matplotlib.ticker import EngFormatter

# %% Analytics
# Data for plotting
fs = 10.0
Ts = 1/fs
f = 5.0
t = np.arange(0.0, 2.0, Ts)
s = 1 + np.sin(2 * np.pi * f * t * Ts )

fig, ax = plt.subplots()
ax.plot(t, s)
# ax.stem(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)', title='Sinewave')
ax.grid(linewidth=1, color='lightgray', alpha=0.5)
ax.grid(which='minor', linestyle=':', linewidth=1, color='lightgray', alpha=0.25)

# plt.savefig("test.png", dpi=512)
plt.show()

# %%
15 changes: 15 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
contourpy==1.2.0
cycler==0.12.1
fonttools==4.50.0
kiwisolver==1.4.5
matplotlib==3.8.3
numpy==1.26.4
packaging==24.0
pandas==2.2.1
pillow==10.2.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
scipy==1.12.0
six==1.16.0
tzdata==2024.1

0 comments on commit 40d4819

Please sign in to comment.