mirror of
https://gitlab.rlp.net/mobitar/julia_course.git
synced 2024-11-16 13:28:10 +00:00
Done tasks day 4
This commit is contained in:
parent
aaa6f6e324
commit
91b415dd8b
1 changed files with 59 additions and 1 deletions
|
@ -5,6 +5,61 @@ using Markdown
|
|||
using InteractiveUtils
|
||||
|
||||
# ╔═╡ 95f0a7c8-b065-11ec-0bd4-a9be6aca0c47
|
||||
md"""
|
||||
# Workflow outside notebooks
|
||||
Create a project directory somewhere in your file system. Now, `cd` into this project directory and create a project environment. Add some packages to this environment.
|
||||
|
||||
Now, create two Julia files in this directory:
|
||||
- `main.jl`
|
||||
- `sub.jl`
|
||||
|
||||
Write a function in the `sub.jl` file. Include this code in the `main.jl` file using the following inside `main.jl`:
|
||||
|
||||
include("sub.jl")
|
||||
|
||||
Now, define a new function in `main.jl` that uses the function from `sub.jl`. Use `Measurements.jl` for some error calculation in one of these functions.
|
||||
|
||||
Run Julia with the `--project=.` argument.
|
||||
|
||||
Include only the `main.jl` file. Now run the function defined in `main.jl`.
|
||||
"""
|
||||
|
||||
# ╔═╡ c2bbace2-3585-4a40-b54f-d466dd735716
|
||||
md"""
|
||||
# Startup
|
||||
Create the file `~/.julia/config/startup.jl`. Add the following lines into this file:
|
||||
|
||||
```julia
|
||||
using OhMyREPL
|
||||
using Revise
|
||||
```
|
||||
|
||||
Make sure that the two packages are in your global environment.
|
||||
|
||||
Now launch Julia and test the syntax highlighting provided by `OhMyREPL`.
|
||||
"""
|
||||
|
||||
# ╔═╡ 53bbb6c2-b264-4892-8e18-af8a1a5d5c2d
|
||||
md"""
|
||||
# Multithreading
|
||||
Open the tasks notebook of the first course day. Copy your function for the task about the squaring difference.
|
||||
|
||||
Now, calculate all squaring differences for $i \in [1, N]$ with $N = 1000$ and store the results in a vector.
|
||||
|
||||
Do this calculation without and with multithreading. What is the difference?
|
||||
|
||||
Can you optimize more? Do some benchmarking!
|
||||
|
||||
Plot the "squaring difference" of `i` against `i`.
|
||||
|
||||
Hints:
|
||||
- You might need to use `BigInt`!
|
||||
- Verify that `Threads.nthreads()` returns a number bigger than one.
|
||||
- You have to import needed packages.
|
||||
"""
|
||||
|
||||
# ╔═╡ 98112d63-c9df-4f4d-b961-ad26c76dd118
|
||||
# Your code starts here
|
||||
|
||||
|
||||
# ╔═╡ 00000000-0000-0000-0000-000000000001
|
||||
|
@ -23,6 +78,9 @@ manifest_format = "2.0"
|
|||
"""
|
||||
|
||||
# ╔═╡ Cell order:
|
||||
# ╠═95f0a7c8-b065-11ec-0bd4-a9be6aca0c47
|
||||
# ╟─95f0a7c8-b065-11ec-0bd4-a9be6aca0c47
|
||||
# ╟─c2bbace2-3585-4a40-b54f-d466dd735716
|
||||
# ╟─53bbb6c2-b264-4892-8e18-af8a1a5d5c2d
|
||||
# ╠═98112d63-c9df-4f4d-b961-ad26c76dd118
|
||||
# ╟─00000000-0000-0000-0000-000000000001
|
||||
# ╟─00000000-0000-0000-0000-000000000002
|
||||
|
|
Loading…
Reference in a new issue