Skip to content
Snippets Groups Projects
Commit 14e94f75 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil :bicyclist:
Browse files

1st lecture slides

parent e0ec6e09
No related branches found
No related tags found
No related merge requests found
Showing
with 107 additions and 75 deletions
......@@ -8,13 +8,11 @@
</div>
<div style="top: 1em; left: 60%; position: absolute;">
<img src="slides/img/r3-training-logo.png" height="200px">
<img src="slides/img/julia.svg" height="200px">
<h1 style="margin-top:3ex; margin-bottom:3ex;">Julia for newcomers</h1>
<h1 style="margin-top:3ex; margin-bottom:3ex;">01: Absolute basics</h1>
<h4>
Miroslav Kratochvíl<br>
Laurent Heirendt<br>
R3 Team - <a href="mailto:lcsb-r3@uni.lu">lcsb-r3@uni.lu</a><br>
LCSB, DSSE<br>
</h4>
</div>
......
......@@ -3,7 +3,9 @@
- Everything is in the slides
- The slides (current version) are available at `courses.lcsb.uni.lu`
- Ask questions immediately
- Offline questions best sent by e-mail (`miroslav.kratochvil@uni.lu`)
- Offline questions best sent by e-mail
- `miroslav.kratochvil@uni.lu`
- `laurent.heirendt@uni.lu`
......@@ -24,14 +26,14 @@
# <i class="twa twa-ledger"></i> Homework
- HW 0: trivial, touch the tooling
- Solution period: 7.3. — 14.3.
- HW 1: basic programming
- Solution period: 7.3. — 21.3.
- HW 2: making your code go fast
- Solution period: 14.3. — 28.3.
- HW 3: managing types and complex things
- Solution period: 21.3. — exam
- *HW 0*: trivial, touch the tooling
- Solution period: 7.3. — *14.3*.
- *HW 1*: basic programming
- Solution period: 7.3. — *21.3*.
- *HW 2*: making your code go fast
- Solution period: 14.3. — *28.3*.
- *HW 3*: managing types and complex things
- Solution period: 21.3. — *exam*
## Guidelines
......@@ -57,5 +59,7 @@
# <i class="twa twa-woman-teacher"></i> Knowing the demographics is important!
- Our background is almost entirely technical.
- We did several scientific computing packages for Julia
- MK was previously teaching a pretty wide spectrum of other programming languages
- What do *you* currently use for programming?
- What's *your* area of interest?
......@@ -29,3 +29,16 @@
# Why Julia?
<center><img src="slides/img/whyjulia.png" width="80%"></center>
# So what is high performance?
- You can process more data with the same resources = You can generate more results
- At some point, you can't get a better algorithm.
High-performance comupting is:
- getting speedup by optimizing the constant factor in the algorithm complexity
- speedup generated by removing various overhead
- getting speedup by parallelizing parts of the algorithm
- speedup generated by adding more computers
......@@ -67,6 +67,8 @@ open("inputs.txt", "r") do io
end
```
Memory-consuming alternative: `readlines`
# Extremely useful: string interpolation
......
# Exercise: write a median function
Approaches (let's do at least 2)
- sort and pick
- quick-median (aka. lightweight sort&pick, as in quicksort)
- approximation-improving-median
- this parallelizes well
- at which point is this faster than quick-median?
- did we lose any property?
- what about median strings?
# Homework 0
Make a package from the "trivial" median algorithm.
- Use julia's `]generate`.
- Have a look at how unit tests are done
- Make sure this unittest works:
```julia
using MagicMedian
@testset "median funcitonality test" begin
@test simplemedian([1,2,3,4]) >= 2
@test simplemedian([1,2,3,4]) <= 3
@test simplemedian([2,6,8]) == 6
end
```
- Zip the package (or `.tar.gz` it or whatever) and upload it to Moodle
How to run unit tests?
- place unittest code into `test/runtests.jl` in the package file
- run `]test MagicMedian`
# Exercise: let's play a maze game
- Read a maze from a file (let's have `0`s for a corridor and `1`s for a wall)
- Draw it to console using `.` and `#`, add a border.
- Make a function that annotates the whole maze based on how many (axis-aligned) steps a person (maze inhabitant) needs to take from some point
- let's use the slow <i class="twa twa-water-wave"></i>wave<i class="twa twa-water-wave"></i> algorithm
- Use `UnicodePlots` to plot interesting stuff
- shortest path length distribution
- shortest-path-length heatmap of the maze
- "most blocking walls" (how much time to reach the father side of the wall could be gained by removing the wall?)
# Exercise: Tricky questions about the maze
What is the slowest part of the "wave" solution?
How can we make it faster?
# Homework 1
Make a *faster* version of the maze distance computation.
- any definiton of "faster solution" works; keep it terse
- recommended way:
- Use `DataStructures.jl` or any other Julia package to get a priority queue working
- Implement some simple version of Dijkstra's algorithm
- alternatively, try to optimize our naive array algorithm
- measure your speedup with `@time` on mazes of at least `128*128` tiles
- data for testing will be available (probably on Moodle)
Submission:
- wrap your code into a package `MagicMaze`
- include a function `maze_distance_map(x::Int, y::Int)::Matrix{Int}`
- write a unit test that demonstrates the result
- pack the package and upload it to Moodle
<div class=leader>
<i class="twa twa-mechanical-arm"></i>
<i class="twa twa-battery"></i>
<i class="twa twa-nut-and-bolt"></i>
<i class="twa twa-mechanical-leg"></i>
<br>
Language in depth
</div>
<div class=leader>
<i class="twa twa-volcano"></i>
<i class="twa twa-mount-fuji"></i>
<i class="twa twa-snow-capped-mountain"></i>
<i class="twa twa-mountain"></i>
<i class="twa twa-sunrise-over-mountains"></i>
<br>
Julia for scientific computing
</div>
<div class=leader>
<i class="twa twa-horse-face"></i>
<i class="twa twa-zebra"></i>
<i class="twa twa-chicken"></i>
<i class="twa twa-unicorn"></i>
<br>
Ecosystem
</div>
<div class=leader>
<i class="twa twa-rocket"></i>
<i class="twa twa-rocket"></i>
<i class="twa twa-rocket"></i>
<i class="twa twa-rocket"></i>
<br>
Parallel Julia
</div>
<div class=leader>
<i class="twa twa-locomotive"></i>
<i class="twa twa-helicopter"></i>
<i class="twa twa-police-car"></i>
<i class="twa twa-trolleybus"></i>
<br>
Data and their types
</div>
<div class=leader>
<i class="twa twa-basketball"></i><br>
<i class="twa twa-wastebasket"></i><br>
The End
</div>
What next?
......@@ -5,10 +5,5 @@
{ "filename": "1b-bootstrap.md" },
{ "filename": "1c-language.md" },
{ "filename": "1d-io.md" },
{ "filename": "2a-details.md" },
{ "filename": "3a-sci.md" },
{ "filename": "4a-scipkgs.md" },
{ "filename": "5a-para.md" },
{ "filename": "6a-types.md" },
{ "filename": "9-end.md" }
{ "filename": "1e-exercises.md" }
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment