├── .gitignore
├── README.md
├── autodiff
├── README.md
├── coolad.jl
└── coolad.pdf
├── copilot
└── README.md
├── error-float
├── error_estimate.ipynb
└── figs
│ ├── complex_rule.png
│ ├── conditional_number.png
│ └── flIEEE.png
├── franklin
└── README.md
├── helpdesk
├── README.md
└── README.org
├── julia-packages
├── .gitignore
├── Manifest.toml
├── Project.toml
├── README.md
├── cuda.jl
├── makie.jl
└── optim.jl
├── julia
├── 1.julia-setup.md
├── 2.first-package.md
├── 3.basic-grammar.md
└── linear-algebra.md
├── mpi
├── .gitignore
├── LocalPreferences.toml
├── Manifest.toml
├── Project.toml
├── README.md
├── julia-helloworld-lsf.job
├── julia-helloworld-slurm.slurm
└── mpi.jl
├── prompt
└── prompt.pdf
└── simulated-annealing
├── README.md
├── example.txt
├── notebook.jl
├── notebook.pdf
└── programs
├── example.txt
├── fsa.f90
├── problem.f90
├── sa.py
└── testsa.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.so
3 | *.mod
4 | .vscode
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CodingClub Materials
2 | The coding club material is usually in the form of `.pdf`, `.md` or notebooks.
3 |
4 | ## Table of contents
5 | 1. [20221105-The Julia programming language - Jinguo Liu](julia)
6 | 2. [20221112-Create a static website with Franklin.jl - Jinguo Liu](franklin)
7 | 3. [20230218-An introduction to Zulip - Yusheng Zhao]()
8 | 4. [20230225-Automatic differentiation - Jinguo Liu](autodiff)
9 | 5. [20230303-Adapt latex template to personal use - Tong Yuan]()
10 | 6. [20230318-The Evolution of NLP: From Language Modeling to ChatGPT's Success with Prompt - Yijie Xu](prompt)
11 | 7. [20230325-Essential Julia packages - Jinguo Liu](julia-packages)
12 | 8. [20230401-Help Desk: Linux and Git - Yusheng Zhao](helpdesk)
13 | 9. [20230408-Simulated annealing for solving the spin-glass problem - Jinguo Liu](simulated-annealing)
14 | 11. [20230408-Message Passing Interfaces (MPI) - Jinguo Liu](mpi)
15 | 12. [20230527-Error in Floating Point System - Xuanzhao Gao](error-float)
16 |
17 |
18 | ## To join our coding club
19 | If you haven't joined the [HKUST-GZ Zulip workspace](http://zulip.hkust-gz.edu.cn/), please check the following invitation link to join our Zulip workspace and subscribe `#coding-club` stream.
20 | https://zulip.hkust-gz.edu.cn/join/uqe4q76jbpowflb42ydaav5b/
21 |
22 | If you are already a member of the [HKUST-GZ Zulip workspace](http://zulip.hkust-gz.edu.cn/), you may subscript the updates directly by navigating to the `#coding-club` stream.
23 |
--------------------------------------------------------------------------------
/autodiff/README.md:
--------------------------------------------------------------------------------
1 | # Cool examples about automatic differentiation
2 |
3 | 1. install Julia from here https://julialang.org/downloads/
4 | 2. open a julia REPL and install related packages
5 | ```julia
6 | julia>] add Pluto Optim NiLang Zygote PlutoUI Compose Viznet Plots ChainRules StochasticOptimizers TupleTools TropicalNumbers ForwardDiff
7 | ```
8 | 3. open the `coolad.jl` by
9 | ```julia
10 | julia> using Pluto
11 |
12 | julia> Pluto.run(1234)
13 | ```
14 | Then open this file by typing the path to `coolad.jl` in input field.
15 |
16 | If you have any problem opening it, please file an issue: https://github.com/Happy-Diode/LunchTalks/issues/new
17 |
--------------------------------------------------------------------------------
/autodiff/coolad.jl:
--------------------------------------------------------------------------------
1 | ### A Pluto.jl notebook ###
2 | # v0.12.21
3 |
4 | using Markdown
5 | using InteractiveUtils
6 |
7 | # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
8 | macro bind(def, element)
9 | quote
10 | local el = $(esc(element))
11 | global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
12 | el
13 | end
14 | end
15 |
16 | # ╔═╡ b9a9214e-8830-11eb-1751-9d9161202c76
17 | using PlutoUI, Viznet, Compose, Plots
18 |
19 | # ╔═╡ bd3a4ece-8b09-11eb-2fcb-0710286e9892
20 | using ForwardDiff: Dual
21 |
22 | # ╔═╡ 0f22e7d6-88c5-11eb-0600-ff9b80f2113e
23 | using NiLang, Random
24 |
25 | # ╔═╡ 95b2f940-8a4c-11eb-1813-7b28745b5050
26 | using Optim
27 |
28 | # ╔═╡ 2b36cfd2-8d77-11eb-0b32-afc6294b5f50
29 | using Statistics: mean
30 |
31 | # ╔═╡ 5dfb2158-8c4a-11eb-33e6-f96facaf76fa
32 | using ChainRules
33 |
34 | # ╔═╡ f5e3b3de-8b61-11eb-2875-7594a13c1897
35 | using LinearAlgebra
36 |
37 | # ╔═╡ 270fef44-8c49-11eb-01af-43bd6e72da09
38 | using Zygote
39 |
40 | # ╔═╡ c239e57a-8b62-11eb-1f10-87cda664a87c
41 | using StochasticOptimizers
42 |
43 | # ╔═╡ b01b19b6-8bc8-11eb-1a02-bf79f074bad3
44 | begin
45 | using TupleTools, TropicalNumbers
46 | using NiLang.AD: GVar
47 |
48 | @i function bond_tensor(res::Matrix{T}) where T
49 | x ← zero(T)
50 | SWAP(res[2, 2], x)
51 | x → one(T)
52 | end
53 |
54 | @i function vertex_tensor(res::Array{T}, n::Int, val::T) where T
55 | for i=2:length(res)-1
56 | x ← zero(T)
57 | SWAP(res[i], x)
58 | x → one(T)
59 | end
60 | x ← one(T)
61 | res[1] *= x
62 | res[end] *= val
63 | end
64 |
65 | @i @inline function :(*=)(+)(z::Tropical, x::Tropical, y::Tropical)
66 | if x.n > y.n
67 | z.n += x.n
68 | else
69 | z.n += y.n
70 | end
71 | end
72 |
73 | @i @inline function (:*=(identity))(x::Tropical, y::Tropical)
74 | x.n += y.n
75 | end
76 |
77 | @i @inline function (:*=(*))(out!::Tropical, x::Tropical, y::Tropical)
78 | out!.n += x.n + y.n
79 | end
80 |
81 | """
82 | i_einsum!(ixs, xs, iy, y::AbstractArray{T})
83 |
84 | A naive reversible implementation of `i_einsum` function for tropical numbers.
85 | * `ixs`: input tensor indices,
86 | * `xs`: input tensors,
87 | * `iy`: output tensor indices,
88 | * `y`: accumulated tensor, notice it is initialized to 0 as output!
89 |
90 | # NOTE: this function is general purposed and slow!
91 | """
92 | @i function i_einsum!(ixs, xs, iy, y::AbstractArray{T}) where {T<:Tropical}
93 | @routine begin
94 | # outer legs and inner legs
95 | outer_indices ← unique(iy)
96 | inner_indices ← setdiff(TupleTools.vcat(ixs...), outer_indices)
97 |
98 | # find size for each leg
99 | all_indices ← TupleTools.vcat(ixs..., iy)
100 | all_sizes ← TupleTools.vcat(size.(xs)..., size(y))
101 | outer_sizes ← [map(i->all_sizes[i], indexin(outer_indices, [all_indices...]))...]
102 | inner_sizes ← [map(i->all_sizes[i], indexin(inner_indices, [all_indices...]))...]
103 |
104 | # cartesian indices for outer and inner legs
105 | outer_ci ← CartesianIndices((outer_sizes...,))
106 | inner_ci ← CartesianIndices((inner_sizes...,))
107 |
108 | # for indexing tensors (leg binding)
109 | indices ← (outer_indices..., inner_indices...)
110 | locs_xs ← map(ix->map(i->findfirst(isequal(i), indices), ix), ixs)
111 | locs_y ← map(i->findfirst(isequal(i), outer_indices), iy)
112 | end
113 | i_loop!(locs_xs, xs, locs_y, y, outer_ci, inner_ci)
114 | ~@routine
115 | end
116 |
117 | """take an index subset from `ind`"""
118 | index_map(ind::CartesianIndex, locs::Tuple) = CartesianIndex(TupleTools.getindices(Tuple(ind), locs))
119 |
120 | """
121 | loop and accumulate products to y, the GPU version, the CPU version.
122 | """
123 | @i function i_loop!(locs_xs::NTuple{N,Any}, xs::NTuple{N, AbstractArray}, locs_y, y::AbstractArray{T}, outer_ci::CartesianIndices, inner_ci::CartesianIndices) where {N, T<:Tropical}
124 | @invcheckoff @inbounds for i in outer_ci
125 | @routine begin
126 | el ← zero(T)
127 | ind_y ← outer_ci[i]
128 | iy ← index_map(ind_y, locs_y)
129 | branch_keeper ← zeros(Bool, size(inner_ci)...)
130 | pl ← ones(T, size(inner_ci)...)
131 | for ind_x in inner_ci
132 | pli ← one(T)
133 | ind_xy ← CartesianIndex(TupleTools.vcat(ind_y.I, ind_x.I))
134 | for I=1:N
135 | pli *= xs[I][index_map(ind_xy, locs_xs[I])]
136 | end
137 | if (el.n < pli.n, branch_keeper[ind_x])
138 | FLIP(branch_keeper[ind_x])
139 | SWAP(el, pli)
140 | end
141 | SWAP(pl[ind_x], pli)
142 | pli → one(T)
143 | end
144 | end
145 | @inbounds y[iy] *= el
146 | ~@routine
147 | end
148 | end
149 |
150 | # patches
151 | Base.zero(x::Tropical{GVar{T,GT}}) where {T,GT} =zero(Tropical{GVar{T,GT}})
152 | Base.zero(::Type{Tropical{GVar{T,T}}}) where T = Tropical(GVar(zero(Tropical{T}).n, zero(T)))
153 |
154 | NiLang.AD.GVar(x::Tropical{T}) where T = Tropical(GVar{T,T}(x.n, zero(T)))
155 |
156 | function NiLangCore.deanc(x::T, v::T) where T<:Tropical
157 | x === v || NiLangCore.deanc(content(x), content(v))
158 | end
159 | end
160 |
161 | # ╔═╡ d8669492-8c98-11eb-1cf5-374da9bd4556
162 | html""
163 |
164 | # ╔═╡ f0b4563a-8b0b-11eb-3085-458f5d9f88b8
165 | md"""
166 | ```math
167 | \newcommand{\comment}[1]{{\bf \color{blue}{\text{◂~ #1}}}}
168 | ```
169 | """
170 |
171 | # ╔═╡ ce5af22a-8830-11eb-13c8-49c680526bd9
172 | md"# Cool automatic differentiation applications
173 |
174 | -- Jinguo Liu"
175 |
176 | # ╔═╡ 22768818-8a95-11eb-1cfe-69534f8b0314
177 | md"""
178 | * What is automatic differentiation (AD)?
179 | * A true history of AD
180 | * Forward mode AD
181 | * Reverse mode AD
182 | * primitves on tensors (including tensorflow, pytorch et al.)
183 | * primitves on elementary instructions (usually source code transformation based)
184 | * defined on a reversible program
185 | * Some applications in **scientific computing**
186 | * solving the graph embedding problem
187 | * inverse engineering a hamiltonian
188 | * obtaining maximum independent set (MIS) configurations
189 | * towards differentiating `expmv` ``\comment{will be used in our emulator}``
190 | """
191 |
192 | # ╔═╡ 68be48da-8a93-11eb-226b-7b1f2be99cb6
193 | md"""
194 | ## The true history of automatic differentiation
195 | """
196 |
197 | # ╔═╡ da08c542-8a93-11eb-3375-d79ccd2de122
198 | md"""
199 | * 1964 ~ Robert Edwin Wengert, A simple automatic derivative evaluation program. ``\comment{first forward mode AD}``
200 | * 1970 ~ Seppo Linnainmaa, Taylor expansion of the accumulated rounding error. ``\comment{first backward mode AD}``
201 | * 1986 ~ Rumelhart, D. E., Hinton, G. E., and Williams, R. J., Learning representations by back-propagating errors.
202 | * 1992 ~ Andreas Griewank, Achieving logarithmic growth of temporal and spatial complexity in reverse automatic differentiation. ``\comment{foundation of source code transformation based AD.}``
203 | * 2000s ~ The boom of tensor based AD frameworks for machine learning.
204 | * 2018 ~ People re-invented AD as differential programming ([wiki](https://en.wikipedia.org/wiki/Differentiable_programming) and this [quora answer](https://www.quora.com/What-is-Differentiable-Programming).)
205 | 
206 | * 2020 ~ Me, Differentiate everything with a reversible embeded domain-specific language ``\comment{AD based on reversible programming}``.
207 | """
208 |
209 | # ╔═╡ 0c80347a-8aff-11eb-0862-1d551e3af00b
210 | md"## Forward mode automatic differentiation"
211 |
212 | # ╔═╡ f55f9cba-8afe-11eb-3bf9-e3e5ecbf3a56
213 | md"""
214 | Forward mode AD attaches a infitesimal number $\epsilon$ to a variable, when applying a function $f$, it does the following transformation
215 | ```math
216 | \begin{align}
217 | f(x+g \epsilon) = f(x) + f'(x) g\epsilon + \mathcal{O}(\epsilon^2)
218 | \end{align}
219 | ```
220 |
221 | The higher order infinitesimal is ignored.
222 |
223 | **In the program**, we can define a *dual number* with two fields, just like a complex number
224 | ```
225 | f((x, g)) = (f(x), f'(x)*g)
226 | ```
227 | """
228 |
229 | # ╔═╡ 662c94c4-8b0a-11eb-39a2-9f37e689fbd3
230 | res = sin(Dual(π/4, 2.0))
231 |
232 | # ╔═╡ 9e24dd6c-8b0a-11eb-020a-a1d7bf2e87bf
233 | res === Dual(sin(π/4), cos(π/4)*2.0)
234 |
235 | # ╔═╡ fc682956-8b00-11eb-3102-952881130049
236 | md"
237 | We can apply this transformation consecutively, it reflects the chain rule.
238 | ```math
239 | \begin{align}
240 | \frac{\partial \vec y_{i+1}}{\partial x} &= \boxed{\frac{\partial \vec y_{i+1}}{\partial \vec y_i}}\frac{\partial \vec y_i}{\partial x}\\
241 | &\text{local Jacobian}
242 | \end{align}
243 | ```
244 | "
245 |
246 | # ╔═╡ 167cbe40-8bf5-11eb-077b-bdd217c9bd78
247 | let
248 | lb = textstyle(:math, fontsize(8), width=0.5, height=0.5)
249 | tb = textstyle(:default, fontsize(10), Compose.font("monospace"))
250 | tb_big = textstyle(:default, fontsize(3.5), fill("white"), Compose.font("monospace"))
251 | nb = nodestyle(:circle, fill("white"), Compose.stroke("black"); r=0.08)
252 | tri = nodestyle(:triangle, Compose.stroke("transparent"), fill("black"); r=0.02)
253 | eb = bondstyle(:default, linewidth(0.5mm))
254 | ebr = bondstyle(:default, Compose.stroke("red"), linewidth(0.5mm))
255 | ebd = bondstyle(:default, linewidth(0.5mm), dashed=true)
256 | eba = bondstyle(:default, linewidth(0.5mm), Compose.arrow(), Compose.stroke("red"), Compose.fill("red"))
257 |
258 | function arrow(x, y)
259 | mid = (x .+ y) ./ 2
260 | t = nodestyle(:triangle, fill("red"), θ=π/2-atan((y .- x)...)-1π/6)
261 | ebr >> (x, y)
262 | t >> mid
263 | end
264 |
265 | Compose.set_default_graphic_size(15cm, 5cm)
266 | x = (0.1, 0.5)
267 | fi0 = (0.35, 0.5)
268 | fi1 = (0.7, 0.5)
269 | fi2 = (1.0, 0.5)
270 | img = canvas() do
271 | nb >> fi0
272 | nb >> fi1
273 | lb >> (fi0 .- (0.05, 0.1), "f_{i-1}")
274 | lb >> (fi1 .- (0.02, 0.1), "f_{i}")
275 | lb >> (x, "x")
276 | lb >> ((fi1 .+ fi0) ./ 2 .- (0.02, 0.0), raw"\vec{y}_{i}")
277 | lb >> ((fi1 .+ fi2) ./ 2 .- (0.05, 0.0), raw"\vec{y}_{i+1}")
278 | lb >> ((fi1 .+ fi2) ./ 2 .- (0.05, 0.0), "\\vec{y}_{i+1}")
279 | lb >> (x .- (0.00, 0.25), raw"\color{red}{1}")
280 | lb >> ((fi1 .+ fi0) ./ 2 .- (0.05, 0.45), raw"\color{red}{\frac{\partial \vec{y}_{i}}{\partial x}}")
281 | lb >> ((fi1 .+ fi2) ./ 2 .- (0.08, 0.45), raw"\color{red}{\frac{\partial \vec{y}_{i+1}}{\partial x}}")
282 | ebd >> (x, fi0)
283 | eb >> (fi0, fi1)
284 | eb >> (fi1, fi2)
285 | #arrow((fi1 .+ fi0) ./ 2 .+ (0.08, -0.3), (fi1 .+ fi2) ./ 2 .+ (-0.08, -0.3))
286 | arrow((fi1 .+ fi0) ./ 2 .+ (0.08, -0.3), (fi1 .+ fi2) ./ 2 .+ (-0.08, -0.3))
287 | end
288 | img
289 | end
290 |
291 | # ╔═╡ d29a56a4-8d86-11eb-1749-0972a594a0e4
292 | let
293 | x = Dual(π/4, 1.0)
294 | for i=1:10
295 | x = sin(x)
296 | end
297 | x
298 | end
299 |
300 | # ╔═╡ 0ba6245c-8bf5-11eb-1005-1b72ffae3412
301 | md"""
302 | **Example:** Computing two gradients $\frac{\partial z\sin x}{\partial x}$ and $\frac{\partial \sin^2x}{\partial x}$ at one sweep
303 | """
304 |
305 | # ╔═╡ aa316d52-8b00-11eb-1e7e-43e6f504977f
306 | let
307 | lb = textstyle(:math, fontsize(8), width=1.0, height=0.5)
308 | tb = textstyle(:default, fontsize(3.5), Compose.font("monospace"))
309 | tb_big = textstyle(:default, fontsize(4.5), fill("white"), Compose.font("monospace"))
310 | nb = nodestyle(:circle, fill("black"), Compose.stroke("transparent"); r=0.05)
311 | tri = nodestyle(:triangle, Compose.stroke("transparent"), fill("black"); r=0.02)
312 | eb = bondstyle(:default, linewidth(0.5mm))
313 |
314 | x_x = (0.1, 0.25)
315 | x_y = (0.9, 0.5)
316 | x_y2 = (0.9, 0.25)
317 | x_z = (0.3, 0.5)
318 | x_sin = (0.3, 0.25)
319 | x_mul = (0.5, 0.5)
320 | x_square = (0.5, 0.25)
321 |
322 | function arrow(x, y)
323 | mid = (x .+ y) ./ 2
324 | t = nodestyle(:triangle, θ=π/2-atan((y .- x)...)-1π/6)
325 | eb >> (x, y)
326 | t >> mid
327 | end
328 |
329 | img = canvas() do
330 | nb >> x_sin
331 | nb >> x_mul
332 | nb >> x_square
333 | tb_big >> (x_sin, "sin")
334 | tb_big >> (x_mul .+ (0, 0.01), "*")
335 | tb_big >> (x_square, "^2")
336 | arrow(x_sin, x_mul)
337 | arrow(x_x, x_sin)
338 | arrow(x_mul, x_y)
339 | arrow(x_square, x_y2)
340 | arrow(x_z, x_mul)
341 | arrow(x_sin, x_square)
342 | tb >> ((x_x .+ x_sin) ./ 2 .- (0.02, 0.04), "x+ϵˣ")
343 | tb >> ((x_sin .+ x_mul) ./ 2 .- (0.08, 0.04), "sin(x)+cos(x)*ϵˣ")
344 | tb >> ((x_y .+ x_mul) ./ 2 .- (-0.04, 0.055), "z*sin(x)\n+z*cos(x)*ϵˣ")
345 | tb >> ((x_y2 .+ x_square) ./ 2 .- (-0.04, 0.055), "sin(x)^2\n+2*sin(x)*cos(x)*ϵˣ")
346 | tb >> ((x_z .+ x_mul) ./ 2 .- (0.05, 0.02), "z")
347 | end
348 |
349 | Compose.set_default_graphic_size(100mm, 100mm/2)
350 | Compose.compose(context(0, -0.15, 1, 2), img)
351 | end
352 |
353 | # ╔═╡ 8a55b3e4-8d67-11eb-203e-0b49c8e3e4aa
354 | md"so the gradients are $z\cos x$ and $2\sin x\cos x$"
355 |
356 | # ╔═╡ f0468078-8b0c-11eb-1bdb-9f6f9496dcf2
357 | md"""
358 | **What if we want to compute gradients for multiple inputs?**
359 |
360 | The computing time grows **linearly** as the number of variables that we want to differentiate. But does not grow significantly with the number of outputs.
361 | """
362 |
363 | # ╔═╡ 6335bc36-8b15-11eb-3731-5b76661d10fa
364 | md"""
365 | ## Reverse mode automatic differentiation
366 |
367 | """
368 |
369 | # ╔═╡ 2f60bb2c-8b2e-11eb-04f9-b79f81439af3
370 | md"On the other side, the back-propagation can differentiate **many inputs** with respect to a **single output** efficiently"
371 |
372 | # ╔═╡ 61be9354-8b25-11eb-3205-db9b03a18f18
373 | md"""
374 | ```math
375 | \begin{align}
376 | \frac{\partial \mathcal{L}}{\partial \vec y_i} = \frac{\partial \mathcal{L}}{\partial \vec y_{i+1}}&\boxed{\frac{\partial \vec y_{i+1}}{\partial \vec y_i}}\\
377 | &\text{local jacobian?}
378 | \end{align}
379 | ```
380 | """
381 |
382 | # ╔═╡ 30f3b718-8bfc-11eb-02cc-777ebc108429
383 | let
384 | lb = textstyle(:math, fontsize(8), width=0.5, height=0.5)
385 | tb = textstyle(:default, fontsize(10), Compose.font("monospace"))
386 | tb_big = textstyle(:default, fontsize(3.5), fill("white"), Compose.font("monospace"))
387 | nb = nodestyle(:circle, fill("white"), Compose.stroke("black"); r=0.08)
388 | tri = nodestyle(:triangle, Compose.stroke("transparent"), fill("black"); r=0.02)
389 | eb = bondstyle(:default, linewidth(0.5mm))
390 | ebr = bondstyle(:default, Compose.stroke("red"), linewidth(0.5mm))
391 | ebd = bondstyle(:default, linewidth(0.5mm), dashed=true)
392 | eba = bondstyle(:default, linewidth(0.5mm), Compose.arrow(), Compose.stroke("red"), Compose.fill("red"))
393 |
394 | function arrow(x, y)
395 | mid = (x .+ y) ./ 2
396 | t = nodestyle(:triangle, fill("red"), θ=π/2-atan((y .- x)...)-1π/6)
397 | ebr >> (x, y)
398 | t >> mid
399 | end
400 |
401 | Compose.set_default_graphic_size(15cm, 5cm)
402 | x = (0.1, 0.5)
403 | fi0 = (0.35, 0.5)
404 | fi1 = (0.7, 0.5)
405 | fi2 = (0.9, 0.5)
406 | img = canvas() do
407 | nb >> fi0
408 | nb >> fi1
409 | lb >> (fi0 .- (0.02, 0.1), "f_{i}")
410 | lb >> (fi1 .- (0.05, 0.1), "f_{i+1}")
411 | lb >> (fi2 .- (0.05, 0.0), raw"\mathcal{L}")
412 | lb >> ((fi0 .+ x) ./ 2 .- (0.05, 0.0), raw"\vec{y}_{i}")
413 | lb >> ((fi0 .+ fi1) ./ 2 .- (0.05, 0.0), raw"\vec{y}_{i+1}")
414 | lb >> ((fi0 .+ fi1) ./ 2 .- (0.05, 0.0), "\\vec{y}_{i+1}")
415 | lb >> (fi2 .- (0.05, 0.25), raw"\color{red}{1}")
416 | lb >> ((fi0 .+ x) ./ 2 .- (0.08, 0.45), raw"\color{red}{\frac{\partial \vec{y}_{i}}{\partial x}}")
417 | lb >> ((fi0 .+ fi1) ./ 2 .- (0.08, 0.45), raw"\color{red}{\frac{\partial \vec{y}_{i+1}}{\partial x}}")
418 | ebd >> (fi1, fi2)
419 | eb >> (fi0, fi1)
420 | eb >> (x, fi0)
421 | #arrow((fi1 .+ fi0) ./ 2 .+ (0.08, -0.3), (fi1 .+ fi2) ./ 2 .+ (-0.08, -0.3))
422 | arrow( (fi0 .+ fi1) ./ 2 .+ (-0.08, -0.3), (fi0 .+ x) ./ 2 .+ (0.05, -0.3),)
423 | end
424 | img
425 | end
426 |
427 | # ╔═╡ f67d1d28-8d6c-11eb-2e47-09e0aece0967
428 | md"### How to visite local Jacobians in the reversed order? "
429 |
430 | # ╔═╡ 0ebb6588-8b52-11eb-21c0-4fd9e70a77e7
431 | md"
432 | **Design Decision**
433 |
434 | 1. Compute forward pass and caching inetermediate results into a global stack $\Sigma$ (packages except NiLang),
435 | 2. reversible programming."
436 |
437 | # ╔═╡ 085145dc-8c10-11eb-12dc-3be1d68fe85c
438 | md"""
439 | **Example:** Computing the gradient $\frac{\partial z\sin x}{\partial x}$ and $\frac{\partial z\sin x}{\partial z}$ by back propagating cached local information.
440 | """
441 |
442 | # ╔═╡ 80caf3ba-8b1f-11eb-3030-5378078e2df9
443 | let
444 | lb = textstyle(:math, fontsize(10), width=1.0, height=0.5)
445 | tb = textstyle(:default, fontsize(3.5), Compose.font("monospace"))
446 | tbc = textstyle(:default, fontsize(3.5), fill("red"), Compose.font("monospace"))
447 | tb_big = textstyle(:default, fontsize(4), fill("white"), Compose.font("monospace"))
448 | nb = nodestyle(:circle, fill("black"), Compose.stroke("transparent"); r=0.05)
449 | tri = nodestyle(:triangle, Compose.stroke("transparent"), fill("black"); r=0.02)
450 | eb = bondstyle(:default, linewidth(0.5mm))
451 |
452 | x_x = (0.1, 0.2)
453 | x_y = (0.9, 0.5)
454 | x_z = (0.1, 0.7)
455 | x_sin = (0.3, 0.3)
456 | x_mul = (0.5, 0.5)
457 |
458 | function arrow(x, y)
459 | mid = (x .+ y) ./ 2
460 | t = nodestyle(:triangle, θ=π/2-atan((y .- x)...)-1π/6)
461 | eb >> (x, y)
462 | t >> mid
463 | end
464 | img1 = canvas() do
465 | nb >> x_sin
466 | nb >> x_mul
467 | tb_big >> (x_sin, "sin")
468 | tb_big >> (x_mul .+ (0, 0.01), "*")
469 | arrow(x_sin, x_mul)
470 | arrow(x_x, x_sin)
471 | arrow(x_mul, x_y)
472 | arrow(x_z, x_mul)
473 | tb >> ((x_x .+ x_sin) ./ 2 .- (0.0, 0.1), "x \n push(Σ,x)")
474 | tb >> ((x_sin .+ x_mul) ./ 2 .- (-0.15, 0.04), "s = sin(x) \n push(Σ,s)")
475 | tb >> ((x_y .+ x_mul) ./ 2 .- (-0.05, 0.04), "y = z*sin(x)")
476 | tb >> ((x_z .+ x_mul) ./ 2 .- (0.05, 0.07), "z\n push(Σ,z)")
477 | end
478 | img2 = canvas() do
479 | nb >> x_sin
480 | nb >> x_mul
481 | tb_big >> (x_sin, "sin")
482 | tb_big >> (x_mul .+ (0, 0.01), "*")
483 | arrow(x_mul, x_sin)
484 | arrow(x_sin, x_x)
485 | arrow(x_y, x_mul)
486 | arrow(x_mul, x_z)
487 | tb >> ((x_x .+ x_sin) ./ 2 .- (0.0, 0.1), "x = pop(Σ)\nx̄ = cos(x)*s̄")
488 | tb >> ((x_sin .+ x_mul) ./ 2 .- (-0.12, 0.04), "z = pop(Σ)\ns̄ = z*ȳ")
489 | tb >> ((x_y .+ x_mul) ./ 2 .- (-0.05, 0.06), "y\nȳ=1")
490 | tb >> ((x_z .+ x_mul) ./ 2 .- (0.05, 0.07), "s = pop(Σ)\nz̄ = s*ȳ")
491 | end
492 |
493 | Compose.set_default_graphic_size(150mm, 75mm/1.4)
494 | Compose.compose(context(),
495 | (context(0, -0.1, 0.5, 1.4), img1),
496 | (context(0.5, -0.1, 0.5, 1.4), img2)
497 | )
498 | end
499 |
500 |
501 |
502 | # ╔═╡ 8bed03b2-8c1b-11eb-1043-23ff31b46991
503 | md"Here, we use $\overline y$ for $\frac{\partial \mathcal{L}}{\partial y}$, which is also called the adjoint."
504 |
505 | # ╔═╡ 0790392e-8d04-11eb-3585-d17e29d379d9
506 | md"### Primitives on different scales"
507 |
508 | # ╔═╡ 330ccb76-8d04-11eb-3bfd-434a93465975
509 | md"We call the leaf nodes defining AD rules \"**primitives**\""
510 |
511 | # ╔═╡ dfb179fe-8cae-11eb-24b6-3bdfa57a0d45
512 | md"
513 | **Design Decision**
514 |
515 | * A: If we define primitives on **arrays**, we need tons of manually defined backward rules. (Jax, Pytorch, Zygote.jl, ReverseDiff.jl et al.)
516 | * B: If we define primitives on **scalar instructions**, we will have worse tensor performance. (Tapenade, Adept, NiLang et al.)
517 |
518 | *Note*: Here, implementing AD on scalars means specifically the **optimal checkpointing** approach, rather than a package like Jax, Zygote and ReverseDiff that having scalar support.
519 | "
520 |
521 | # ╔═╡ f2c75336-8cab-11eb-09ce-e99acb20aee8
522 | let
523 | w, h = 0.22, 0.1
524 | lb = Compose.compose(context(), polygon([(-w, -h), (-w, h), (w, h), (w, -h)]), Compose.stroke("transparent"))
525 | lb2 = Compose.compose(context(), polygon([(-w, -h), (-w, h), (w, h), (w, -h)]), Compose.stroke("transparent"), fill("red"))
526 | tb = Compose.compose(context(), Compose.text(0.0, 0.0, ""), fontsize(3), Compose.font("monospace"))
527 | tb_big = textstyle(:default, fontsize(3), fill("white"), Compose.font("monospace"))
528 | eb = bondstyle(:default, linewidth(0.5mm))
529 | ar = bondstyle(:default, linewidth(0.3mm), Compose.arrow())
530 | xprog = (0.25, 0.15)
531 | xtensors = (0.25, 0.5)
532 | t1 = (0.5, 0.15)
533 | t2 = (0.5, 0.5)
534 | t3 = (0.5, 0.85)
535 | xscalars2 = (0.25, 0.85)
536 |
537 | function box(loc, text; color="black")
538 | (color=="black" ? lb : lb2) >> loc
539 | tb_big >> (loc, text)
540 | end
541 | Compose.set_default_graphic_size(10cm, 5cm)
542 | canvas() do
543 | box(xprog, "Program")
544 | ar >> (xprog, xtensors .+ (0, -h-0.03))
545 | #ar >> (xprog, xscalars .+ (-w/2, -h-0.03))
546 | ar >> (xtensors, xscalars2 .+ (0, -h-0.05))
547 | box(xtensors, "Functions on arrays")
548 | #box(xscalars, "Functions on Scalars")
549 | box(xscalars2, "Finite instructions"; color="red")
550 | tb >> (t1, "Neural networks")
551 | tb >> (t2, "matrix multiplication")
552 | tb >> (t3, "+, -, *")
553 | end
554 | end
555 |
556 | # ╔═╡ d1760114-8b52-11eb-3241-252292bf96ac
557 | html"""
558 |
559 |
560 | |
561 | on tensors |
562 | on finite instructions |
563 |
564 |
565 | meaning |
566 | defining backward rules manully for functions on tensors |
567 | defining backward rules on a limited set of basic scalar operations, and generate gradient code using source code transformation |
568 |
569 |
570 | pros and cons |
571 |
572 |
573 | - Good tensor performance
574 | - Mature machine learning ecosystem
575 | - Need to define backward rules manually
576 |
577 | |
578 |
579 |
580 | - Reasonalbe scalar performance
581 | - hard to utilize GPU kernels (except NiLang.jl) and BLAS
582 |
583 | |
584 |
585 | |
586 |
587 |
588 | packages |
589 | Jax PyTorch |
590 | Tapenade
591 | Adept
592 | NiLang.jl
593 | |
594 |
595 |
596 | """
597 |
598 | # ╔═╡ 8cab36f8-8c1a-11eb-009a-3d6dbdb83d85
599 | md"""
600 | ## The AD ecosystem in Julia
601 |
602 | Please check JuliaDiff: [https://juliadiff.org/](https://juliadiff.org/)
603 |
604 | A short list:
605 | * Forward mode AD: ForwardDiff.jl
606 | * Reverse mode AD (tensor): ReverseDiff.jl/Zygote.jl
607 | * Reverse mode AD (scalar): NiLang.jl
608 |
609 | Warnings
610 | * The main authors of `Tracker`, `ReverseDiff` and `Zygote` are not maintaining them anymore.
611 | """
612 | #=
613 | | | Rules | Favors Tensor? | Type |
614 | | ---- | ---- | --- | --- |
615 | | Zygote | C | ✓ | R |
616 | | ReverseDiff | D | ✓ | R |
617 | | Nabla | D→C | ✓ | R |
618 | | Tracker | D | ✓ | R |
619 | | Yota | C | ✓ | R |
620 | | NiLang | - | × | R |
621 | | Enzyme | - | × | R |
622 | | ForwardDiff | - | × | F |
623 | | Diffractor | ? | ? | ? |
624 |
625 | * R: reverse mode
626 | * F: forward mode
627 | * C: ChainRules
628 | * D: DiffRules
629 | """
630 | =#
631 |
632 | # ╔═╡ 01e46500-8ced-11eb-04b7-a1e05a81b1b2
633 | md"# Quick summary
634 | 1. The history of AD is longer than many people have thought. People are most familar with *reverse mode AD with primitives implemented on tensors* that brings the boom of machine learning. There are also AD frameworks that can differentiate a general program directly, which does not require users defining AD rules manually.
635 | 2. **Forward mode AD** propagate gradients forward, it has a computational overhead propotional to the number of input parameters.
636 | 2. **Backward mode AD** propagate gradients backward, it has a computational overhead propotional to the number of output parameters.
637 | * primitives on **tensors** v.s. **scalars**
638 | * reverse the program tape by **caching/checkpointing** v.s. **reversible programming**
639 | 4. Julia has one of the most active AD community!
640 |
641 | #### Forward v.s. Backward
642 | when is forward mode AD more useful?
643 |
644 | * It is often combined with backward mode AD for obtaining Hessians (forward over backward).
645 | * Having <20 input parameters.
646 |
647 | when is backward mode AD more useful?
648 | * In most variational optimizations, especially when we are training a neural network with ~ 100M parameters.
649 | "
650 |
651 | # ╔═╡ eb0cba98-8a54-11eb-132f-6320f3893da9
652 | md"## 1. Embedding a peterson Graph"
653 |
654 | # ╔═╡ 43c6b8ec-8a79-11eb-2ff1-cb8fd958b693
655 | md"""
656 | One day, A postdoc of Anders Sandvik Jun Takahashi went to me, said "Hey, Jinguo, can you help me figure out what is the minimum embedding dimension of a Peterson graph?"
657 |
658 | A Peterson graph is a famous 3-regular graph with very high symmetry. It is well know to graph theory people. It looks like
659 | """
660 |
661 | # ╔═╡ 99839afc-8a83-11eb-3f38-1bef2960f969
662 | md"It has 10 vertices, 15 edges, while these vertices are all equivalent to each other. By embedding a graph into a k-dimensional space, it requires
663 | 1. assigning a k-dimensional vector to each node as the Euclidean coordinate,
664 | 2. the distance between each pair of connected nodes are the same, meanwhile, the distance between each pair of disconnected nodes are same too.
665 | 3. the distance between disconnected vertices are larger than connect vertices"
666 |
667 | # ╔═╡ a8a92160-88c5-11eb-0a7e-cbec45b627f0
668 | # connected vertex-pairs in a petersen graph
669 | const L1 = [(1, 6), (2, 7), (3, 8), (4, 9), (5, 10),
670 | (1, 2), (2, 3), (3, 4), (4, 5), (1, 5), (6, 8),
671 | (8, 10), (7, 10), (7, 9), (6, 9)];
672 |
673 | # ╔═╡ b1016e9c-88c5-11eb-12a5-41a914a794d3
674 | # disconnected vertex-pairs in a petersen graph
675 | const L2 = [(1, 3), (1, 4), (1, 7), (1, 8), (1, 9),
676 | (1, 10), (2, 4), (2, 5), (2, 6), (2, 8), (2, 9),
677 | (2, 10), (3, 5), (3, 6), (3, 7), (3, 9), (3, 10),
678 | (4, 6), (4, 7), (4, 8), (4, 10), (5, 6), (5, 7),
679 | (5, 8), (5, 9), (6, 7), (6, 10), (7, 8), (8, 9),
680 | (9, 10)];
681 |
682 | # ╔═╡ 385638ea-8a81-11eb-166b-a9caf2b2792f
683 | let
684 | L1 = [(1, 6), (2, 7), (3, 8), (4, 9), (5, 10),
685 | (1, 2), (2, 3), (3, 4), (4, 5), (1, 5), (6, 8),
686 | (8, 10), (7, 10), (7, 9), (6, 9)]
687 | x1 = (0.0, -0.45)
688 | x2 = (0.0, -0.25)
689 | nodes = [
690 | [Viznet.rot(x1..., 2π/5*i) .+ 0.5 for i=0:4]...,
691 | [Viznet.rot(x2..., 2π/5*i) .+ 0.5 for i=0:4]...
692 | ]
693 | Compose.set_default_graphic_size(8cm, 8cm)
694 | nb = nodestyle(:circle, fill("white"), Compose.stroke("black"))
695 | eb = bondstyle(:default)
696 | eb2 = bondstyle(:default, Compose.stroke("#DDDDDD"))
697 | canvas() do
698 | for n in nodes
699 | nb >> n
700 | end
701 | for (i,j) in L1
702 | eb >> (nodes[i], nodes[j])
703 | end
704 | for (i,j) in L2
705 | eb2 >> (nodes[i], nodes[j])
706 | end
707 | end
708 | end
709 |
710 | # ╔═╡ 38a9382e-8b58-11eb-3e0b-656260c672cd
711 | md"For dimension $k\in 1,2,\dots,10$, we assign a coordinate to each vertex. Then we define the loss as
712 | ```math
713 | \begin{align}
714 | \begin{split}
715 | D_1 &= \{d_{(i,j)} | (i,j) \in L_1\}\\
716 | D_2 &= \{d_{(i,j)} | (i,j) \in L_2\}\\
717 | \mathcal{L} &= {\rm var}(D_1) + {\rm var}(D_2) \\
718 | &+\exp({\rm relu}({\rm mean}(D_1)- {\rm mean}(D_2) + 0.1)) - 1 \comment{if $d_2$ < $d_1$, punish}
719 | \end{split}
720 | \end{align}
721 | ```
722 |
723 | "
724 |
725 | # ╔═╡ 1d503598-8d7c-11eb-1cf4-cf0755194043
726 | md"""
727 | `relu` is defined as `x > 0 ? x : 0`
728 | """
729 |
730 | # ╔═╡ bf5702ae-88c5-11eb-2bb2-d7d5cf4eccdf
731 | @i function sqdistance(dist!, x1::AbstractVector{T}, x2::AbstractVector) where T
732 | for i=1:length(x1)
733 | @routine begin
734 | diff ← zero(T)
735 | diff += x1[i] - x2[i]
736 | end
737 | dist! += diff ^ 2
738 | ~@routine
739 | end
740 | end
741 |
742 | # ╔═╡ 9a474d6a-885f-11eb-2db5-2145c0b9183f
743 | """The loss of graph embedding problem."""
744 | @i function embedding_loss(out!::T, x) where T
745 | @routine @invcheckoff begin
746 | @zeros T v1 varsum1 varsum2 s1 s2 m1 v2 m2 diff
747 | d1 ← zeros(T, length(L1))
748 | d2 ← zeros(T, length(L2))
749 | # 1. compute distances
750 | for i=1:length(L1)
751 | sqdistance(d1[i], x[:,L1[i][1]],x[:,L1[i][2]])
752 | end
753 | for i=1:length(L2)
754 | sqdistance(d2[i], x[:,L2[i][1]],x[:,L2[i][2]])
755 | end
756 | # 2. compute variances
757 | NiLang.i_var_mean_sum(v1, varsum1, m1, s1, d1)
758 | NiLang.i_var_mean_sum(v2, varsum2, m2, s2, d2)
759 | m1 -= m2 - 0.1
760 | end
761 | out! += v1 + v2
762 | if m1 > 0
763 | # to ensure mean(v2) > mean(v1)
764 | # if mean(v1)+0.1 - mean(v2) > 0, punish it.
765 | out! += exp(m1)
766 | out! -= 1
767 | end
768 | ~@routine
769 | end
770 |
771 | # ╔═╡ 5ef95fa8-8a50-11eb-35e7-9354bf50b0e7
772 | md"Seed = $(@bind seed Slider(1:10000))"
773 |
774 | # ╔═╡ 8f2d529c-8a50-11eb-1910-29b61b1b8f82
775 | md"dimension $(@bind dimension NumberField(1:10; default=5))"
776 |
777 | # ╔═╡ 9b86ac04-8a4c-11eb-278e-5777f3552f25
778 | x_minimizer, x_minimum = let
779 | Random.seed!(seed)
780 | x = randn(dimension,10)
781 | # `NiLang.AD.gradient` to obtain the gradients
782 | res = Optim.optimize(x->embedding_loss(0.0, x)[1], x->NiLang.AD.gradient(embedding_loss, (0.0, x); iloss=1)[2], x, LBFGS(), Optim.Options(f_abstol=1e-12, f_reltol=1e-12, g_abstol=1e-12, g_reltol=1e-12), inplace=false)
783 | res.minimizer, res.minimum
784 | end;
785 |
786 | # ╔═╡ c697cf2c-8d76-11eb-1817-132326c4a92e
787 | x_minimum
788 |
789 | # ╔═╡ 8cae97aa-8d76-11eb-1740-0752e4297de2
790 | d1s = [norm(x_minimizer[:,a] .- x_minimizer[:,b]) for (a, b) in L1]
791 |
792 | # ╔═╡ 01e6cbb4-8d77-11eb-2519-23c89d5de971
793 | d2s = [norm(x_minimizer[:,a] .- x_minimizer[:,b]) for (a, b) in L2]
794 |
795 | # ╔═╡ 071bc508-8d77-11eb-01e6-950e171e6b45
796 | mean(d2s)/mean(d1s)
797 |
798 | # ╔═╡ 77562ce2-8a79-11eb-389a-a35e42e65171
799 | md"""
800 | His work of finding the SO(5) symmetric tensor order representation is later published as
801 |
802 | "Valence-bond solids, vestigial order, and emergent SO(5) symmetry in a two-dimensional quantum magnet." (Phys. Rev. Research 2, 033459, Jun Takahashi, Anders W. Sandvik)
803 | """
804 |
805 | # ╔═╡ 0f5cc712-8a84-11eb-0f31-91b30ad895af
806 | md"## 2. Inverse engineering a Hamiltonian"
807 |
808 | # ╔═╡ be1a31d8-8a91-11eb-2ead-fb4b7de74afc
809 | md"""
810 | This problem is from "Notes on Adjoint Methods for 18.335", Steven G. Johnson
811 |
812 | Consider a 1D Shrodinger equation
813 | ```math
814 | \left[-\frac{d^2}{dx^2} + V(x)\right]\Psi(x) = E\Psi(x), x \in [-1,1]
815 | ```
816 |
817 | """
818 |
819 | # ╔═╡ 25bc662a-8c14-11eb-0689-45ac05c280aa
820 | md"We can solve its gound state numerically by discretizing the space and diagonalize the Hamiltonian matrix. The Hamiltonian matrix is
821 |
822 | ```math
823 | A = \frac{1}{Δx^2}\left(
824 | \begin{matrix}
825 | 2 & -1 & 0 & \ldots & 0 & -1\\
826 | -1 & 2 & -1 & 0 & \ldots & \\
827 | 0 & -1 & 2 & -1 & 0 & \ldots \\
828 | \vdots & & & \ddots & & \\
829 | & & & -1 & 2 & -1\\
830 | -1 & 0 & \ldots & 0 & -1 & 2
831 | \end{matrix}
832 | \right) + {\rm diag}(V)
833 | ```
834 | "
835 |
836 | # ╔═╡ 3aa7ea18-8c15-11eb-010e-9d6a9e7dd952
837 | md"where the matrix size is equal the descretized lattice size"
838 |
839 | # ╔═╡ 4eda1c4c-8b5f-11eb-2485-6b34cdef4ef8
840 | dx = 0.02;
841 |
842 | # ╔═╡ 40ec8444-8b5f-11eb-0de5-97ed546aa4a1
843 | xgrid = -1.0:dx:1.0;
844 |
845 | # ╔═╡ cf8235b6-8b5d-11eb-2997-41da626b503f
846 | @i function hamiltonian!(a, x, V::AbstractVector{T}) where T
847 | @routine begin
848 | @zeros T dx2 invdx2
849 | n ← length(x)
850 | dx2 += (@const Float64(x.step))^2
851 | invdx2 += 1/dx2
852 | end
853 | @safe @assert size(a) == (n, n)
854 | for i=1:n
855 | a[i, i] += 2 * invdx2
856 | a[i, i] += V[i]
857 | a[i, mod1(i+1, n)] -= invdx2
858 | a[mod1(i+1, n), i] -= invdx2
859 | end
860 | ~@routine
861 | end
862 |
863 | # ╔═╡ 82c60414-8c4a-11eb-27c2-e9294ecbebba
864 | hamiltonian(x, V) = hamiltonian!(zeros(length(x), length(x)), x, V)[1]
865 |
866 | # ╔═╡ 3dcc9014-8c4b-11eb-0a15-a5e9e495c7b7
867 | hamiltonian(xgrid, randn(length(xgrid)))
868 |
869 | # ╔═╡ eb77b59a-8c9b-11eb-2683-c150952cf85b
870 | md"Because we are going to use Zygote (with rules set defined in ChainRules)"
871 |
872 | # ╔═╡ 63d9c6ce-8c4a-11eb-384d-a1fa4fe5ccd6
873 | function ChainRules.rrule(::typeof(hamiltonian), x, V)
874 | y = hamiltonian(x, V)
875 | function hamiltonian_pullback(Δy)
876 | gV = NiLang.AD.grad((~hamiltonian!)(GVar.(y, Δy), x, GVar.(V))[3])
877 | return (ChainRules.NO_FIELDS, ChainRules.DoesNotExist(), gV)
878 | end
879 | return y, hamiltonian_pullback
880 | end
881 |
882 | # ╔═╡ 8e9f00ca-8c15-11eb-3079-a147fd2b0149
883 | md"We want the ground state be a house."
884 |
885 | # ╔═╡ 20e1c2ae-8b5f-11eb-334c-d74f310f9cc5
886 | ψ0 = [abs(xi)<0.5 ? 1 - abs(xi) : 0 for xi in xgrid]; normalize!(ψ0);
887 |
888 | # ╔═╡ 88757052-8b5f-11eb-189c-5b74c7c9acde
889 | plot(xgrid, ψ0)
890 |
891 | # ╔═╡ 5b357e9e-8c15-11eb-1ce8-6b91fac05cc0
892 | md"So we define a loss function
893 | ```math
894 | \begin{align}
895 | E, \psi &= {\rm eigensolve}(A)\\
896 | \mathcal{L} &= \sum_i |(|(\psi_0)_i| - |(\psi_G)_i|)|
897 | \end{align}
898 | ```
899 | "
900 |
901 | # ╔═╡ bd15d5ca-8c18-11eb-33a8-7306b70c02e0
902 | md"where $\psi_G$ is state vector in $\psi$ that corresponds to the minimum energy."
903 |
904 | # ╔═╡ 2a7a0da4-8b63-11eb-2d1c-9b852a39dacf
905 | function solve_wave(x, V)
906 | a = hamiltonian(x, V)
907 | ψ = LinearAlgebra.eigen(LinearAlgebra.Hermitian(a)).vectors[:,1]
908 | end
909 |
910 | # ╔═╡ a0918e24-8b61-11eb-3f39-69bd8ce0c618
911 | function loss(x, V, ψ0)
912 | ψ = solve_wave(x, V)
913 | sum(map(abs, map(abs, ψ) - map(abs, ψ0))) * dx
914 | end
915 |
916 | # ╔═╡ eaa8f57e-8b61-11eb-28b7-bf487a201b80
917 | loss(xgrid, randn(length(xgrid)), ψ0)
918 |
919 | # ╔═╡ 4543b0b2-8b64-11eb-0984-71f0a8027e6b
920 | solve_wave(xgrid, randn(length(xgrid))) |> norm
921 |
922 | # ╔═╡ c21f7c16-8b66-11eb-1502-8362d656896a
923 | loss(xgrid, randn(length(xgrid)), ψ0)
924 |
925 | # ╔═╡ 4b667f7a-8b60-11eb-1773-6904f0858ad7
926 | Zygote.gradient(v->loss(xgrid, v, ψ0), randn(length(xgrid)))
927 |
928 | # ╔═╡ a0a78f52-8b62-11eb-2e7a-4d3f975461ce
929 | @bind clock Clock(0.1)
930 |
931 | # ╔═╡ e64c8508-8b62-11eb-191c-45ec2ae6cd8c
932 | it = adam(v->loss(xgrid, v, ψ0), x->Zygote.gradient(v->loss(xgrid, v, ψ0), x)[1], randn(length(xgrid)); η=1.0);
933 |
934 | # ╔═╡ a910ae42-8b62-11eb-0474-7f81c709a77c
935 | let
936 | clock
937 | state = step!(it)
938 | v = minimizer(state)
939 | ψ = solve_wave(xgrid, v)
940 | @show loss(xgrid, v, ψ0)
941 | plot(xgrid, abs.(ψ); label="ψ")
942 | plot!(xgrid, abs.(ψ0); label="ψ0")
943 | plot!(xgrid, normalize(v); label="V")
944 | end |> PlutoUI.as_svg
945 |
946 | # ╔═╡ a1e7dd02-8bc8-11eb-29e0-91df4126872a
947 | md"""## 3. Obtaining MIS configurations"""
948 |
949 | # ╔═╡ 7919105e-8ce4-11eb-3f31-ff0fc17ca375
950 | md"We are able to get the weighted maximum independent set (MIS) size of the following graph
951 |
952 | ```math
953 | S = \max_{\vec s}\left(\sum_i w_i s_i-\infty \sum_{ij\in E} s_i s_j\right), s_i \in \{0,1\}
954 | ```
955 | where $s_i$ and $w_i$ are the configuration (in MIS: 1, not in MIS: 0) and weight of node $i$.
956 | "
957 |
958 | # ╔═╡ 1e954d20-8ce7-11eb-078e-0baaaa7132d4
959 | md"Question: how to get the configuration with MIS?"
960 |
961 | # ╔═╡ ee3c1284-8d7d-11eb-3f4c-59ceabbd180c
962 | md"The optimal configuration is a gradient!"
963 |
964 | # ╔═╡ 32fdc4e0-8ce7-11eb-3acd-ed90c6e2e780
965 | md"""
966 | ```math
967 | \frac{\partial S}{\partial w_i} = \begin{cases}
968 | 1 & s_i \in \vec s_{\rm max}\\
969 | 0 & otherwise
970 | \end{cases}
971 | ```
972 | """
973 |
974 | # ╔═╡ 083f13f0-8cea-11eb-0b3a-a96ab05aece9
975 | md"The actual problem is harder, if we fix the boundary configurations `a, b, c, d`, what is the optimal configurations for interior?"
976 |
977 | # ╔═╡ f96dc3b4-8bcf-11eb-15ec-232d15b3e075
978 | function vizconfig(nodes, edges, config=zeros(Int, length(nodes)))
979 | Compose.set_default_graphic_size(12cm, 12cm)
980 | tb = textstyle(:default, fill("white"))
981 | nb = nodestyle(:default)
982 | nb2 = nodestyle(:default, fill("red"))
983 | eb = bondstyle(:default)
984 | canvas() do
985 | for (i, (t, p)) in enumerate(nodes)
986 | (config[i]==1 ? nb2 : nb) >> p
987 | tb >> (p, t)
988 | end
989 | for (i,j) in edges
990 | eb >> (nodes[i].second, nodes[j].second)
991 | end
992 | end
993 | end;
994 |
995 | # ╔═╡ beee2d1e-8bcf-11eb-295c-a3b45bfc3aa8
996 | nodes_simple = let
997 | a = 0.12
998 | ymid = xmid = 0.5
999 | X = 0.33
1000 | Y = 0.17
1001 | D = 0.15
1002 | y = [ymid-Y, ymid-Y+D, ymid-a/2, ymid+a/2, ymid+Y-D, ymid+Y]
1003 | x = [xmid-X, xmid-X+D, xmid-1.5a, xmid-a/2, xmid+a/2, xmid+1.5a, xmid+X-D, xmid+X]
1004 | xmin, xmax, ymin, ymax = x[1], x[end], y[1], y[end]
1005 | ["a"=>(xmid, y[1]), "b"=>(xmin, ymid), "c"=>(xmid, ymax), "d"=>(xmax, ymid),
1006 | "i"=>(x[3], y[3]), "j"=>(x[4], y[3]),
1007 | "k"=>(x[5], y[3]), "l"=>(x[6], y[3]), "m"=>(x[3], y[4]),
1008 | "n"=>(x[4], y[4]), "o"=>(x[5], y[4]), "p"=>(x[6], y[4])]
1009 | end;
1010 |
1011 | # ╔═╡ 13bc3822-8bd0-11eb-1caa-1d49b3b74272
1012 | function find_edges(nodes, distance)
1013 | edges = Tuple{Int,Int}[]
1014 | for (i, p) in enumerate(nodes)
1015 | for (j,p2) in enumerate(nodes)
1016 | if i tget(i), 1, x[i])
1050 | end
1051 | for j=length(x)+1:length(x)+28
1052 | bond_tensor(xs |> tget(j))
1053 | end
1054 | end
1055 | # contract tropical tensors
1056 | i_einsum!(ixs, xs, iy, out)
1057 | # store the entry with specific boundary configuration to `optsize`
1058 | optsize += out[config...].n
1059 | ~@routine
1060 | end
1061 |
1062 | # ╔═╡ 546c8fb4-8bd2-11eb-30e4-5de043658636
1063 | compute_mis(0, ones(Tropical{Int},2,2,2,2), Tropical.(ones(Int,12)), [1,1,2,2])
1064 |
1065 | # ╔═╡ c1aa24ce-8cea-11eb-3dd1-bd817acf2d8b
1066 | md"
1067 | We want to differentiate the weights (3rd argument) with respect to the loss (1st argument).
1068 | "
1069 |
1070 | # ╔═╡ d34fc06e-8ce8-11eb-0604-7139a6e1fbc3
1071 | md" $(@bind ca CheckBox()) a $(@bind cb CheckBox()) b $(@bind cc CheckBox()) c $(@bind cd CheckBox()) d "
1072 |
1073 | # ╔═╡ 85978e48-8bd9-11eb-340d-1f60d233522a
1074 | configs = NiLang.AD.gradient(compute_mis, (0, ones(Tropical{Int64},2,2,2,2), Tropical.(ones(Int,12)), 1 .+ [ca,cb,cc,cd]); iloss=1)[3];
1075 |
1076 | # ╔═╡ 0a3f57c2-8be2-11eb-11f9-d1c6d78f0af0
1077 | vizconfig(nodes_simple, edges_simple, content.(configs))
1078 |
1079 | # ╔═╡ 4180d4ee-8cec-11eb-139d-f9a0b79dcf3f
1080 | md"Here is a quick reference of the function definitions of Tropical algebra and Tropical einsum.
1081 |
1082 | Note: For regular tensors, we can use existing backward rules defined in `ChainRules`.
1083 | "
1084 |
1085 | # ╔═╡ 57e182e2-8bd4-11eb-2c36-835b43413c1c
1086 | vertex_tensor(ones(TropicalF64,2), 1, Tropical(1.0))[1]
1087 |
1088 | # ╔═╡ 2dad711e-8cec-11eb-1b78-a79d8201a019
1089 | bond_tensor(ones(TropicalF64,2, 2))
1090 |
1091 | # ╔═╡ abb3b8c0-8a94-11eb-35b9-fbfd31f19501
1092 | md"""
1093 | ## 4. Towards differentiating `expmv`
1094 | """
1095 |
1096 | # ╔═╡ 4bd1668e-8cb5-11eb-2ea7-f5398916dd60
1097 | let
1098 | F = 1.7
1099 | W, w, h = 0.47, 0.22, 0.1/F
1100 | lb = Compose.compose(context(), polygon([(-w, -h), (-w, h), (w, h), (w, -h)]), Compose.stroke("transparent"))
1101 | lb2 = Compose.compose(context(), polygon([(-W, -h), (-W, h), (W, h), (W, -h)]), Compose.stroke("transparent"), fill("red"))
1102 | lb3 = Compose.compose(context(), polygon([(-w/2, -h), (-w/2, h), (w/2, h), (w/2, -h)]), Compose.stroke("transparent"), fill("black"))
1103 | lb4 = Compose.compose(context(), polygon([(-w, -h), (-w, h), (w, h), (w, -h)]), Compose.stroke("transparent"), fill("green"))
1104 | tb = textstyle(:default, fontsize(3.5), Compose.font("monospace"))
1105 | tb_big = textstyle(:default, fontsize(3), fill("white"), Compose.font("monospace"))
1106 | eb = bondstyle(:default, linewidth(0.5mm))
1107 | ar = bondstyle(:default, linewidth(0.3mm), Compose.arrow())
1108 | xprog = (0.5, 0.15/F)
1109 | xtensors = (0.25, 0.5/F)
1110 | xscalars = (0.75, 0.5/F)
1111 | xscalars2 = (0.25, 0.85/F)
1112 | xscalars3 = (0.25, 1.2/F)
1113 | xscalars4 = (0.5, 1.55/F)
1114 | xpade = (0.6, 0.85/F)
1115 |
1116 | function box(loc, text; color="black")
1117 | (color=="black" ? lb : (color=="red" ? lb2 : lb4)) >> loc
1118 | tb_big >> (loc, text)
1119 | end
1120 | Compose.set_default_graphic_size(10cm, F*5cm)
1121 | img = canvas() do
1122 | box(xprog, "expmv")
1123 | ar >> (xprog, xtensors .+ (w/2, -h-0.03/F))
1124 | ar >> (xprog, xscalars .+ (-w/2, -h-0.03/F))
1125 | ar >> (xtensors, xscalars2 .+ (0, -h-0.05/F))
1126 | ar >> (xscalars2, xscalars3 .+ (0, -h-0.05/F))
1127 | ar >> (xscalars3, xscalars3 .+ (0, 0.2/F))
1128 | ar >> (xscalars, xscalars3 .+ (0.5, 0.2/F))
1129 | ar >> (xtensors, xpade .+ (-w/2, -h-0.02/F))
1130 | box(xtensors, "expm (small dense)")
1131 | lb3 >> xpade
1132 | tb_big >> (xpade, "Pade")
1133 | box(xscalars, "Sparse mv (Lanczos)")
1134 | box(xscalars2, "Linear solver")
1135 | box(xscalars3, "QR decomp."; color="green")
1136 | box(xscalars4, "+, -, *, /"; color="red")
1137 | end
1138 | end
1139 |
1140 | # ╔═╡ 5482dd8a-8cba-11eb-182e-6d7fed2543f5
1141 | md"""
1142 | ### Resouces
1143 | * [Differentiating sparse operations](https://nextjournal.com/giggle/how-to-write-a-program-differentiably)
1144 | * [How to compute expm](http://eprints.ma.man.ac.uk/634/1/covered/MIMS_ep2006_394.pdf)
1145 | """
1146 |
1147 | # ╔═╡ b1b8ccb4-8ce5-11eb-36c7-f5be8f8d1115
1148 | md"## More interesting AD examples
1149 |
1150 | * **Gate based quantum simulation**, Yao.jl: Extensible, Efficient Framework for Quantum Algorithm Design, Xiu-Zhe Luo, Jin-Guo Liu, Pan Zhang, Lei Wang [arxiv: 1912.10877](https://arxiv.org/abs/1912.10877)
1151 | * **Reverse time migration**, Reverse time migration with optimal checkpointing, William W. Symes [DOI](https://doi.org/10.1190/1.2742686)
1152 | * **Gaussian mixture models, Bundle adjustment and hand tracking**, A benchmark of selected algorithmic differentiation tools on some problems in computer vision and machine learning, Filip Srajer,Zuzana Kukelova &Andrew Fitzgibbon [DOI](https://doi.org/10.1080/10556788.2018.1435651)
1153 |
1154 | ### Videos
1155 |
1156 | * [Transformations & AutoDiff | MIT Computational Thinking Spring 2021 | Lecture 3](https://www.youtube.com/watch?v=AAREeuaKCic&ab_channel=TheJuliaProgrammingLanguage) ``\comment{AD in image processing}``
1157 | "
1158 |
1159 | # ╔═╡ f8a2feee-8d63-11eb-0e4a-874a49df59ed
1160 | md"""
1161 | ## Quick Summary
1162 |
1163 | * Every program is differentiable
1164 | * For packages implementing AD rules on tensors, they have problems handling effective codes.
1165 | """
1166 |
1167 | # ╔═╡ Cell order:
1168 | # ╠═b9a9214e-8830-11eb-1751-9d9161202c76
1169 | # ╟─d8669492-8c98-11eb-1cf5-374da9bd4556
1170 | # ╟─f0b4563a-8b0b-11eb-3085-458f5d9f88b8
1171 | # ╟─ce5af22a-8830-11eb-13c8-49c680526bd9
1172 | # ╟─22768818-8a95-11eb-1cfe-69534f8b0314
1173 | # ╟─68be48da-8a93-11eb-226b-7b1f2be99cb6
1174 | # ╟─da08c542-8a93-11eb-3375-d79ccd2de122
1175 | # ╟─0c80347a-8aff-11eb-0862-1d551e3af00b
1176 | # ╟─f55f9cba-8afe-11eb-3bf9-e3e5ecbf3a56
1177 | # ╠═bd3a4ece-8b09-11eb-2fcb-0710286e9892
1178 | # ╠═662c94c4-8b0a-11eb-39a2-9f37e689fbd3
1179 | # ╠═9e24dd6c-8b0a-11eb-020a-a1d7bf2e87bf
1180 | # ╟─fc682956-8b00-11eb-3102-952881130049
1181 | # ╟─167cbe40-8bf5-11eb-077b-bdd217c9bd78
1182 | # ╠═d29a56a4-8d86-11eb-1749-0972a594a0e4
1183 | # ╟─0ba6245c-8bf5-11eb-1005-1b72ffae3412
1184 | # ╟─aa316d52-8b00-11eb-1e7e-43e6f504977f
1185 | # ╟─8a55b3e4-8d67-11eb-203e-0b49c8e3e4aa
1186 | # ╟─f0468078-8b0c-11eb-1bdb-9f6f9496dcf2
1187 | # ╟─6335bc36-8b15-11eb-3731-5b76661d10fa
1188 | # ╟─2f60bb2c-8b2e-11eb-04f9-b79f81439af3
1189 | # ╟─61be9354-8b25-11eb-3205-db9b03a18f18
1190 | # ╟─30f3b718-8bfc-11eb-02cc-777ebc108429
1191 | # ╟─f67d1d28-8d6c-11eb-2e47-09e0aece0967
1192 | # ╟─0ebb6588-8b52-11eb-21c0-4fd9e70a77e7
1193 | # ╟─085145dc-8c10-11eb-12dc-3be1d68fe85c
1194 | # ╟─80caf3ba-8b1f-11eb-3030-5378078e2df9
1195 | # ╟─8bed03b2-8c1b-11eb-1043-23ff31b46991
1196 | # ╟─0790392e-8d04-11eb-3585-d17e29d379d9
1197 | # ╟─330ccb76-8d04-11eb-3bfd-434a93465975
1198 | # ╟─dfb179fe-8cae-11eb-24b6-3bdfa57a0d45
1199 | # ╟─f2c75336-8cab-11eb-09ce-e99acb20aee8
1200 | # ╟─d1760114-8b52-11eb-3241-252292bf96ac
1201 | # ╟─8cab36f8-8c1a-11eb-009a-3d6dbdb83d85
1202 | # ╟─01e46500-8ced-11eb-04b7-a1e05a81b1b2
1203 | # ╟─eb0cba98-8a54-11eb-132f-6320f3893da9
1204 | # ╟─43c6b8ec-8a79-11eb-2ff1-cb8fd958b693
1205 | # ╟─385638ea-8a81-11eb-166b-a9caf2b2792f
1206 | # ╟─99839afc-8a83-11eb-3f38-1bef2960f969
1207 | # ╠═0f22e7d6-88c5-11eb-0600-ff9b80f2113e
1208 | # ╠═a8a92160-88c5-11eb-0a7e-cbec45b627f0
1209 | # ╠═b1016e9c-88c5-11eb-12a5-41a914a794d3
1210 | # ╟─38a9382e-8b58-11eb-3e0b-656260c672cd
1211 | # ╟─1d503598-8d7c-11eb-1cf4-cf0755194043
1212 | # ╠═9a474d6a-885f-11eb-2db5-2145c0b9183f
1213 | # ╠═bf5702ae-88c5-11eb-2bb2-d7d5cf4eccdf
1214 | # ╠═95b2f940-8a4c-11eb-1813-7b28745b5050
1215 | # ╟─5ef95fa8-8a50-11eb-35e7-9354bf50b0e7
1216 | # ╟─8f2d529c-8a50-11eb-1910-29b61b1b8f82
1217 | # ╠═9b86ac04-8a4c-11eb-278e-5777f3552f25
1218 | # ╠═c697cf2c-8d76-11eb-1817-132326c4a92e
1219 | # ╠═8cae97aa-8d76-11eb-1740-0752e4297de2
1220 | # ╠═01e6cbb4-8d77-11eb-2519-23c89d5de971
1221 | # ╠═2b36cfd2-8d77-11eb-0b32-afc6294b5f50
1222 | # ╠═071bc508-8d77-11eb-01e6-950e171e6b45
1223 | # ╟─77562ce2-8a79-11eb-389a-a35e42e65171
1224 | # ╟─0f5cc712-8a84-11eb-0f31-91b30ad895af
1225 | # ╟─be1a31d8-8a91-11eb-2ead-fb4b7de74afc
1226 | # ╟─25bc662a-8c14-11eb-0689-45ac05c280aa
1227 | # ╟─3aa7ea18-8c15-11eb-010e-9d6a9e7dd952
1228 | # ╠═4eda1c4c-8b5f-11eb-2485-6b34cdef4ef8
1229 | # ╠═40ec8444-8b5f-11eb-0de5-97ed546aa4a1
1230 | # ╠═cf8235b6-8b5d-11eb-2997-41da626b503f
1231 | # ╠═82c60414-8c4a-11eb-27c2-e9294ecbebba
1232 | # ╠═3dcc9014-8c4b-11eb-0a15-a5e9e495c7b7
1233 | # ╟─eb77b59a-8c9b-11eb-2683-c150952cf85b
1234 | # ╠═5dfb2158-8c4a-11eb-33e6-f96facaf76fa
1235 | # ╠═63d9c6ce-8c4a-11eb-384d-a1fa4fe5ccd6
1236 | # ╟─8e9f00ca-8c15-11eb-3079-a147fd2b0149
1237 | # ╠═20e1c2ae-8b5f-11eb-334c-d74f310f9cc5
1238 | # ╠═88757052-8b5f-11eb-189c-5b74c7c9acde
1239 | # ╟─5b357e9e-8c15-11eb-1ce8-6b91fac05cc0
1240 | # ╟─bd15d5ca-8c18-11eb-33a8-7306b70c02e0
1241 | # ╠═2a7a0da4-8b63-11eb-2d1c-9b852a39dacf
1242 | # ╠═a0918e24-8b61-11eb-3f39-69bd8ce0c618
1243 | # ╠═f5e3b3de-8b61-11eb-2875-7594a13c1897
1244 | # ╠═eaa8f57e-8b61-11eb-28b7-bf487a201b80
1245 | # ╠═4543b0b2-8b64-11eb-0984-71f0a8027e6b
1246 | # ╠═c21f7c16-8b66-11eb-1502-8362d656896a
1247 | # ╠═270fef44-8c49-11eb-01af-43bd6e72da09
1248 | # ╠═4b667f7a-8b60-11eb-1773-6904f0858ad7
1249 | # ╟─a0a78f52-8b62-11eb-2e7a-4d3f975461ce
1250 | # ╠═c239e57a-8b62-11eb-1f10-87cda664a87c
1251 | # ╠═e64c8508-8b62-11eb-191c-45ec2ae6cd8c
1252 | # ╠═a910ae42-8b62-11eb-0474-7f81c709a77c
1253 | # ╟─a1e7dd02-8bc8-11eb-29e0-91df4126872a
1254 | # ╟─7919105e-8ce4-11eb-3f31-ff0fc17ca375
1255 | # ╟─1e954d20-8ce7-11eb-078e-0baaaa7132d4
1256 | # ╟─ee3c1284-8d7d-11eb-3f4c-59ceabbd180c
1257 | # ╟─32fdc4e0-8ce7-11eb-3acd-ed90c6e2e780
1258 | # ╟─8d25f9e0-8bcc-11eb-1df4-33556074d6ff
1259 | # ╟─083f13f0-8cea-11eb-0b3a-a96ab05aece9
1260 | # ╟─f96dc3b4-8bcf-11eb-15ec-232d15b3e075
1261 | # ╠═beee2d1e-8bcf-11eb-295c-a3b45bfc3aa8
1262 | # ╠═13bc3822-8bd0-11eb-1caa-1d49b3b74272
1263 | # ╠═06f15870-8bd0-11eb-3b4c-db7d9e3e7adf
1264 | # ╠═dec89520-8bcf-11eb-3ab4-97cc22ca2368
1265 | # ╠═546c8fb4-8bd2-11eb-30e4-5de043658636
1266 | # ╟─c1aa24ce-8cea-11eb-3dd1-bd817acf2d8b
1267 | # ╟─d34fc06e-8ce8-11eb-0604-7139a6e1fbc3
1268 | # ╠═85978e48-8bd9-11eb-340d-1f60d233522a
1269 | # ╠═0a3f57c2-8be2-11eb-11f9-d1c6d78f0af0
1270 | # ╟─4180d4ee-8cec-11eb-139d-f9a0b79dcf3f
1271 | # ╠═b01b19b6-8bc8-11eb-1a02-bf79f074bad3
1272 | # ╠═57e182e2-8bd4-11eb-2c36-835b43413c1c
1273 | # ╠═2dad711e-8cec-11eb-1b78-a79d8201a019
1274 | # ╟─abb3b8c0-8a94-11eb-35b9-fbfd31f19501
1275 | # ╟─4bd1668e-8cb5-11eb-2ea7-f5398916dd60
1276 | # ╟─5482dd8a-8cba-11eb-182e-6d7fed2543f5
1277 | # ╟─b1b8ccb4-8ce5-11eb-36c7-f5be8f8d1115
1278 | # ╟─f8a2feee-8d63-11eb-0e4a-874a49df59ed
1279 |
--------------------------------------------------------------------------------
/autodiff/coolad.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingThrust/CodingClub/d6acc0c44858c5a2c0f6d0b81beaa2e85144a91c/autodiff/coolad.pdf
--------------------------------------------------------------------------------
/copilot/README.md:
--------------------------------------------------------------------------------
1 | # How to setup Copilot for lecturing
2 | The recommended workflow contains the following three building blocks
3 | 1. Markdown: A file format for writing plain text documents that can be converted to HTML for preview. Or equivalently, you could use latex to write your lecture notes.
4 | 2. Editor: Visual Studio Code (VS Code), a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. We use it to write and preview markdown files.
5 | 3. Github Copilot: An extension of VSCode that helps you write code. Here we use it to generate lecture notes.
6 |
7 |
8 | ## Step 1: Link to Github Copilot
9 | To use Github Copilot, you need to have a Github account first. Github is a code hosting platform for version control and collaboration, which can host your markdown files and provide preview. You should go to [Github website](https://github.com/) and sign up an account.
10 | ## Step 2: Get Visual Studio Code
11 | 1. Go to [VS Code website](https://code.visualstudio.com/) and download the latest version.
12 | 2. Install & open VS Code.
13 | 3. Add the following VS Code extensions. To add an VS Code extension, please click the `Extensions` button in the left side bar, search for the extension name and click the `Install` button.
14 | - [Markdown Preview Enhanced](https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced)
15 | - [Markdown All in One](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one)
16 | 5. Open a new file and save it as `test.md`. Then, click the `Open Preview to the Side` button in the top right corner of the VS Code window. The left side is the editor and the right side is the preview. You can edit the file on the left side and the preview will be updated automatically.
17 | 6. Now, you can start writing your own markdown file. You can learn markdown from [here](https://www.markdownguide.org/basic-syntax/). The GitHub website also renders math equations in Markdown. For example, the following code
18 | ~~~
19 | ```math
20 | \frac{1}{2}
21 | ```
22 | ~~~
23 | will be rendered as
24 | ```math
25 | \frac{1}{2}
26 | ```
27 | I think is better than latex because the preview is dynamically rendered.
28 |
29 | 7. Install the following VS Code extension
30 | - [Github Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot). It requires you to connect with your Github account, and you can use it for free for 30 days. After 30 days, you can still use it for free but you need to join the waitlist. You can also use it for free if you are a student. You can apply for a student account [here](https://education.github.com/pack). Please check this [YouTube video](https://youtu.be/HDG4PQK7DK8?si=sOR7PqNcGAnrV4Tm) for more details
31 | 8. You might need to activate the Github Copilot extension by clicking the `Activate` button in the bottom right corner of the VS Code window to make it work. Then you can type some text in the editor and press `Tab` to generate lecture notes.
32 | ## Step 3: Using Github to sync your files (optional)
33 | If you want to sync your files across different devices, you can use Github. Github is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. You can use Github to host your markdown files and provide preview.
34 |
35 | This tutorial does not cover how to use Github. You can learn it from the [YouTube video](https://www.youtube.com/watch?v=RGOj5yH7evk) or the [official guide](https://guides.github.com/activities/hello-world/).
--------------------------------------------------------------------------------
/error-float/error_estimate.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "metadata": {},
7 | "source": [
8 | "# Error in Floating Point System\n",
9 | "\n",
10 | "Let's start from a simple example"
11 | ]
12 | },
13 | {
14 | "cell_type": "code",
15 | "execution_count": 1,
16 | "metadata": {},
17 | "outputs": [
18 | {
19 | "name": "stdout",
20 | "output_type": "stream",
21 | "text": [
22 | "a64 + b64 = 0.21000000000000002\n",
23 | "a32 + b32 = 0.21000001f0\n"
24 | ]
25 | }
26 | ],
27 | "source": [
28 | "a64 = 0.01\n",
29 | "b64 = 0.2\n",
30 | "@show a64 + b64;\n",
31 | "a32 = Float32(0.01)\n",
32 | "b32 = Float32(0.2)\n",
33 | "@show a32 + b32;"
34 | ]
35 | },
36 | {
37 | "attachments": {},
38 | "cell_type": "markdown",
39 | "metadata": {},
40 | "source": [
41 | "## IEEE 754: Standard of Floating Point Number\n",
42 | "\n",
43 | "The IEEE 754 standard is a binary floating-point arithmetic standard used to represent and process real numbers in computers and other digital devices. The standard defines two floating-point formats: single-precision and double-precision, which use 32 bits and 64 bits respectively to represent a floating-point number. These formats use scientific notation to represent real numbers, with three parts: sign, exponent, and mantissa.\n",
44 | "\n",
45 | "The IEEE 754 standard also defines arithmetic operations such as addition, subtraction, multiplication, and division, as well as rounding rules for performing arithmetic operations on these floating-point numbers. These rules ensure the precision and reproducibility of floating-point arithmetic operations performed in computers.\n",
46 | "\n",
47 | "A floating point number can be give as\n",
48 | "$$\n",
49 | "a = ±m \\cdot \\beta^e, m = (0.d_1 d_2 ... d_t)_\\beta, 0 ≤ d_i< \\beta\\;,\n",
50 | "$$\n",
51 | "so that the rounding error will be $\\frac{1}{2} \\beta^{1-t}$ and the chopping error will be $\\beta^{1-t}$.\n",
52 | "\n",
53 | "By IEEE 754, in single precision a floating-point number $a$ is stored as the sign $s$ (one bit), the exponent $e$ (8 bits), and the mantissa $m$ (23 bits).\n",
54 | "In double precision 11 of the 64 bits are used for the exponent, and 52 bits are used for the mantissa.\n",
55 | "So that the rounding error of Float32 and Float64 are about $5.94 \\cdot 10^{-8}$ and $1.11 \\cdot 10^{-16}$.\n",
56 | "\n",
57 | "The IEEE standard also includes two extended precision formats that offer extra precision and exponent range. The standard only specifies a lower bound on how many extra bits it provides. 33 Most modern processors use 80-bit registers for processing real numbers and store results as 64-bit numbers according to the IEEE double precision standard. Extended formats simplify tasks such as computing elementary functions accurately in single or double precision. Extended precision formats are used also by hand calculators. These will often display 10 decimal digits but use 13 digits internally—“the calculator knows more than it shows.”\n",
58 | "\n",
59 | "\n",
60 | "### Guard digits\n",
61 | "\n",
62 | "The guard digit is an extra digit used in floating-point arithmetic to improve the accuracy of computations. It is a bit that is added to the least significant bit of the mantissa of a floating-point number, and it represents an additional bit of precision that is used during arithmetic operations.\n",
63 | "\n",
64 | "The guard digit is used to prevent rounding errors that may occur during arithmetic operations, especially when intermediate results are very close to the boundary between two representable floating-point numbers. By adding an extra bit of precision, the guard digit helps to ensure that the final result is as accurate as possible.\n",
65 | "\n",
66 | "For example, consider the addition of two floating-point numbers that have a very small difference between their values. Without a guard digit, the result of the addition may need to be rounded, which could introduce a small error. With a guard digit, the addition can be performed with greater precision, reducing the likelihood of rounding errors and improving the accuracy of the final result.\n",
67 | "\n",
68 | ""
69 | ]
70 | },
71 | {
72 | "attachments": {},
73 | "cell_type": "markdown",
74 | "metadata": {},
75 | "source": [
76 | "## Error Propragration\n",
77 | "\n",
78 | "### Operations in Floating Point Number System\n",
79 | "\n",
80 | "Define the basic floating-point operations are given as\n",
81 | "$$\n",
82 | "fl(x + y),~fl(x-y),~fl(x\\times y)~\\text{and}~fl(x / y)\n",
83 | "$$\n",
84 | "and the standard model holds because of the existence of the guard digits:\n",
85 | "$$\n",
86 | "fl(x ~\\text{op} ~y) = (x ~\\text{op} ~y) (1 + \\delta),~|\\delta| \\leq u \\;.\n",
87 | "$$\n",
88 | "In computers support a *fused multiply-add* operation and have only one rounding error\n",
89 | "$$\n",
90 | "fl(a\\times x + y) = (a \\times x + y) (1 + \\delta),~|\\delta| \\leq u \\;,\n",
91 | "$$\n",
92 | "so it is not only about speed but also accuracy.\n",
93 | "\n",
94 | "The rule for the complex number is a litte bit different, given by\n",
95 | "\n",
96 | "\n",
97 | "\n",
98 | "where $\\gamma_n = \\frac{nu}{1 - nu}$."
99 | ]
100 | },
101 | {
102 | "attachments": {},
103 | "cell_type": "markdown",
104 | "metadata": {},
105 | "source": [
106 | "Here we can have a check on another example"
107 | ]
108 | },
109 | {
110 | "cell_type": "code",
111 | "execution_count": 9,
112 | "metadata": {},
113 | "outputs": [
114 | {
115 | "name": "stdout",
116 | "output_type": "stream",
117 | "text": [
118 | "error natural = 0.00010874912467651043\n",
119 | "error opposite = 3.0252606197933574e-8\n"
120 | ]
121 | }
122 | ],
123 | "source": [
124 | "sum_natural = sum(Float32(Float32(1)/Float32(i)^Float32(2)) for i= 1:10000)\n",
125 | "sum_opposite = sum(Float32(Float32(1)/Float32(10001 - i)^Float32(2)) for i= 1:10000)\n",
126 | "sum_exact = sum(1.0/(i^2) for i in 1:10000)\n",
127 | "println(\"error natural = \", abs(sum_exact - sum_natural))\n",
128 | "println(\"error opposite = \", abs(sum_exact - sum_opposite))"
129 | ]
130 | },
131 | {
132 | "attachments": {},
133 | "cell_type": "markdown",
134 | "metadata": {},
135 | "source": [
136 | "This clearly shows the error of the $fl(x~\\text{op}~y)$ depends on value of $x~\\text{op}~y$, changing the summation order may change a lot.\n",
137 | "\n",
138 | "The compensated summation method can be used in such cases."
139 | ]
140 | },
141 | {
142 | "cell_type": "code",
143 | "execution_count": 10,
144 | "metadata": {},
145 | "outputs": [
146 | {
147 | "data": {
148 | "text/plain": [
149 | "compensated_summation (generic function with 1 method)"
150 | ]
151 | },
152 | "metadata": {},
153 | "output_type": "display_data"
154 | }
155 | ],
156 | "source": [
157 | "function compensated_summation(x::Vector{T}) where T\n",
158 | " s = x[1]\n",
159 | " c = zero(T)\n",
160 | " for i in 2:length(x)\n",
161 | " y = c + x[i]\n",
162 | " t = s + y\n",
163 | " c = (s - t) + y\n",
164 | " s = t\n",
165 | " end\n",
166 | " return s\n",
167 | "end"
168 | ]
169 | },
170 | {
171 | "cell_type": "code",
172 | "execution_count": 11,
173 | "metadata": {},
174 | "outputs": [
175 | {
176 | "name": "stdout",
177 | "output_type": "stream",
178 | "text": [
179 | "error special = 3.0252606197933574e-8\n"
180 | ]
181 | }
182 | ],
183 | "source": [
184 | "error_special = abs(compensated_summation([Float32(1 / i^2) for i in 1:10000]) - sum_exact)\n",
185 | "println(\"error special = \", error_special)"
186 | ]
187 | },
188 | {
189 | "attachments": {},
190 | "cell_type": "markdown",
191 | "metadata": {},
192 | "source": [
193 | "### Error Propragation\n",
194 | "\n",
195 | "The very basic rule of error propragation can be given as \n",
196 | "$$\n",
197 | "|\\Delta f| \\leq \\sum_i |\\frac{\\partial f}{\\partial x_i} \\Delta x_i|\\;.\n",
198 | "$$\n",
199 | "\n",
200 | "We can also define conditional number as\n",
201 | "$$\n",
202 | "\\kappa(f;x) = \\frac{||J(x)||~||x||}{||f(x)||}\\;.\n",
203 | "$$"
204 | ]
205 | },
206 | {
207 | "attachments": {},
208 | "cell_type": "markdown",
209 | "metadata": {},
210 | "source": [
211 | ""
212 | ]
213 | },
214 | {
215 | "attachments": {},
216 | "cell_type": "markdown",
217 | "metadata": {},
218 | "source": []
219 | }
220 | ],
221 | "metadata": {
222 | "kernelspec": {
223 | "display_name": "Julia 1.9.0",
224 | "language": "julia",
225 | "name": "julia-1.9"
226 | },
227 | "language_info": {
228 | "file_extension": ".jl",
229 | "mimetype": "application/julia",
230 | "name": "julia",
231 | "version": "1.9.0"
232 | },
233 | "orig_nbformat": 4
234 | },
235 | "nbformat": 4,
236 | "nbformat_minor": 2
237 | }
238 |
--------------------------------------------------------------------------------
/error-float/figs/complex_rule.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingThrust/CodingClub/d6acc0c44858c5a2c0f6d0b81beaa2e85144a91c/error-float/figs/complex_rule.png
--------------------------------------------------------------------------------
/error-float/figs/conditional_number.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingThrust/CodingClub/d6acc0c44858c5a2c0f6d0b81beaa2e85144a91c/error-float/figs/conditional_number.png
--------------------------------------------------------------------------------
/error-float/figs/flIEEE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingThrust/CodingClub/d6acc0c44858c5a2c0f6d0b81beaa2e85144a91c/error-float/figs/flIEEE.png
--------------------------------------------------------------------------------
/franklin/README.md:
--------------------------------------------------------------------------------
1 | # How to write your own blog with Franklin
2 |
3 | The workflow is detailed in this web-page:
4 | https://franklinjl.org/workflow/
--------------------------------------------------------------------------------
/helpdesk/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Purpose
4 |
5 | - Setup environments
6 | - Help find solution to your coding problems
7 | - …
8 |
9 |
10 | # Git
11 |
12 |
13 | ## Basics
14 |
15 |
16 | ### Before Starting: Configuring git
17 |
18 | - Configs
19 | 1. Global use `/.gitconfig`
20 | 2. Repo specific use `.git/config`
21 | 3. Repo specific config file will overwrite the global one
22 | - How to view your current config
23 | `$ git config --list --show-origin`
24 | - Config editor
25 | `$ git config --global core.editor emacs`
26 |
27 |
28 | ### Git-Basics-Undoing-Things:
29 |
30 | - Introduction to undoing changes in Git
31 | - Three basic ways to undo changes in Git:
32 | - `git reset`
33 | - `git revert`
34 | - `git checkout`
35 | - `git commit --ammend` is your pal for fixing a commit not pushed
36 | - `git reset HEAD ` – Unstage a staged file
37 | - `git checkout -- ` – Discard changes in a file since the last commit
38 | - `git revert HEAD` – Create a new commit that undoes the changes made in the
39 | previous commit
40 | - `git push --force origin ` – Force push changes to a remote branch
41 | that has already been pushed with unwanted changes.
42 |
43 | - [Reference](https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things#_undoing)
44 |
45 |
46 | ### What is remote?
47 |
48 | Remote on Git refers to a repository that is located on a server or another
49 | computer, rather than the user’s local machine. It’s a version of the repository
50 | that is used by teams to collaborate on a project. Remote repositories can be
51 | accessed and manipulated through Git commands, allowing users to push changes or
52 | fetch changes made by others. Remote repositories can be hosted on Git hosting
53 | services like GitHub, GitLab, or Bitbucket, or set up on a personal server.
54 | Multiple users can access and modify the same remote repository, making it easy
55 | for teams to work on a project together.
56 |
57 |
58 | ### What is branch?
59 |
60 | A branch in Git is a lightweight pointer to a specific commit. It allows
61 | developers to work on new features or make changes to the codebase without
62 | affecting the main codebase. Branches are created and can be switched between
63 | easily, and changes made in one branch do not affect other branches.
64 |
65 | To create a new branch in Git, you can use the command `git branch
66 | `. This creates a new branch but does not switch to it, so you will
67 | be working in the same branch until you use the command `git checkout
68 | ` to switch to the new branch. Alternatively, you can use the
69 | command `git checkout -b ` to create and switch to the new branch
70 | at the same time.
71 |
72 | To end a branch, you can use the command `git branch -d `. This
73 | deletes the specified branch, but only if it has been fully merged into the main
74 | branch. If you want to delete a branch whether it has been fully merged or not,
75 | you can use the command `git branch -D `. It’s important to note
76 | that once a branch has been deleted, you cannot restore its commit history.
77 |
78 |
79 | ## Resources
80 |
81 | - [Visualization of Commands](https://dev.to/lydiahallie/cs-visualized-useful-git-commands-37p1)
82 | -
83 | -
84 | - [Missing semester video](https://missing.csail.mit.edu/2020/version-control/)
85 | -
86 |
87 |
88 | # Julia Package Management
89 |
90 | - This section is really well presented by Prof Liu at [here](https://github.com/exAClior/CodingClub/blob/main/julia-packages/README.md) and [here](https://github.com/exAClior/CodingClub/blob/main/julia/2.first-package.md).
91 | - Ask me anything and let’s do a quick demo.
92 |
93 |
94 | # Shell Tools
95 |
96 |
97 | ## Shells
98 |
99 | Shell, zsh and bash are all command-line interface (CLI) interpreters used in
100 | Unix-like operating systems.
101 |
102 | - Shell is the simplest and most basic interpreter. Its primary function is to
103 | provide a command-line interface to the system. It can execute scripts, launch
104 | programs, manage files and directories, and perform basic system
105 | administrative tasks.
106 |
107 | - Bash (Bourne-Again SHell) is the default shell on most Linux distributions. It
108 | is backward-compatible with the original Bourne shell and includes many
109 | additional features, such as command-line editing, job control, and shell
110 | scripting capabilities. Bash is widely used as it is both easy to use and has
111 | a large user community, resulting in a plethora of available resources
112 | (tutorials, scripts, etc.) online.
113 |
114 | - Zsh (Z shell) is an extended version of the shell, with a more powerful
115 | command-line editing and completion system. It includes features like spelling
116 | correction and tab-completion, and it also supports plugins and themes. Zsh is
117 | commonly used by power users who require more productivity and efficiency from
118 | their command-line interface.
119 |
120 |
121 | ## Path Variable
122 |
123 | On Linux, the PATH variable is an environment variable that contains a list of
124 | directories that the shell searches for executable files. When a user enters a
125 | command in the shell, the shell looks for the executable file in each directory
126 | listed in the PATH variable, in the order they are listed. The PATH variable can
127 | be modified to add or remove directories, and it can also be set on a per-user
128 | or system-wide basis. The PATH variable is important because it allows users to
129 | easily run programs without having to specify the full path to the executable
130 | file each time.
131 |
132 |
133 | ## File Permission
134 |
135 | In Linux, file permissions determine who can access, edit, and execute files and
136 | directories. Each file and directory has three permission settings: owner,
137 | group, and other. The owner is the user who created the file or directory, the
138 | group is a set of users with specific permissions, and other is anyone else who
139 | has permission to access the file or directory. Each permission setting can have
140 | three levels of access: read, write, and execute. Read permission allows the
141 | user to view the contents of the file or directory, write permission allows the
142 | user to edit or delete the file or directory, and execute permission allows the
143 | user to run the file or access the directory. File and directory permissions can
144 | be changed using the chmod command in Linux.
145 |
146 |
147 | ## Common Shell Commands
148 |
149 | 1. `cd` - Change directory
150 | 2. `ls` - List directory contents
151 | 3. `mv` - Move or rename files or directories
152 | 4. `cp` - Copy files or directories
153 | 5. `rm` - Remove files or directories
154 | 6. `mkdir` - Create directories
155 | 7. `rmdir` - Remove empty directories
156 | 8. `touch` - Create an empty file or update the modification timestamp of a file
157 | 9. `cat` - Display the content of a file
158 | 10. `grep` - Search for a pattern in files
159 | 11. `ps` - Display information about running processes
160 | 12. `kill` - Terminate a process
161 | 13. `echo` - Print a message to the console
162 | 14. `chmod` - Change permissions of files or directories
163 | 15. `history` - Display a list of recently used commands
164 | 16. `ssh` - Connect to a remote server through ssh protocol
165 | 17. `scp` - Copy files between local and remote machines over ssh protocol
166 | 18. `tar` - Create or extract archive files
167 | 19. `df` - Display information about disk usage
168 | 20. `wget` - Download files from the internet.
169 |
170 |
171 | ## Tools
172 |
173 | 1. `ripgrep` (rg): A fast text search tool that recursively searches a directory
174 | hierarchy for a regex pattern.
175 | 2. `Tmux`: A terminal multiplexer that allows you to divide your terminal into
176 | multiple panes and windows.
177 | 3. `Ncdu`: A disk usage analyzer that helps you visualize which files and
178 | directories are consuming the most space on your filesystem.
179 | 4. `tldr`: A simplified and community-driven version of man pages that provides
180 | practical examples of command line usage.
181 | 5. `Bat`: A cat replacement that provides syntax highlighting, line numbering, and
182 | Git integration.
183 | 6. `Exa`: A modern replacement for ls that supports additional features like file
184 | icons, Git status, and color themes.
185 | 7. `Bandwhich`: A bandwidth usage analyzer that helps you see which processes are
186 | using the most network bandwidth.
187 | 8. `fd`: A more user-friendly alternative to find that allows you to search for
188 | files and directories using a streamlined syntax.
189 | 9. `htop`: An interactive process viewer that provides detailed information about
190 | system resource usage and allows you to manage processes.
191 | 10. `Tmuxp`: A command line tool that allows you to easily manage and share your
192 | Tmux configurations.
193 | 11. `direnv`: direnv is a shell extension that allows users to manage environment
194 | variables for different directories. It is designed to alleviate the
195 | inconvenience of constantly setting and unsetting environmental variables
196 | within different development environments.
197 |
198 |
199 | ## Resources
200 |
201 | - [Shell Script Learning](https://www.shellscript.sh/)
202 | - [The Art of Command Line](https://github.com/jlevy/the-art-of-command-line/blob/master/README.md)
203 |
204 |
205 | # Editors
206 |
207 | - Vim
208 | - Emacs
209 | - VSCode
210 |
211 |
--------------------------------------------------------------------------------
/helpdesk/README.org:
--------------------------------------------------------------------------------
1 | #+TITLE: Coding Help Desk
2 | #+AUTHOR: Yusheng Zhao (+ ChatGPT)
3 | #+OPTIONS: toc:nil
4 | * Purpose
5 | - Setup environments
6 | - Help find solution to your coding problems
7 | - ...
8 |
9 | * Git
10 | ** Basics
11 | *** Before Starting: Configuring git
12 | - Configs
13 | 1) Global use ~/.gitconfig~
14 | 2) Repo specific use ~.git/config~
15 | 3) Repo specific config file will overwrite the global one
16 | - How to view your current config
17 | ~$ git config --list --show-origin~
18 | - Config editor
19 | ~$ git config --global core.editor emacs~
20 |
21 | *** Git-Basics-Undoing-Things:
22 | - Introduction to undoing changes in Git
23 | - Three basic ways to undo changes in Git:
24 | - ~git reset~
25 | - ~git revert~
26 | - ~git checkout~
27 | - ~git commit --ammend~ is your pal for fixing a commit not pushed
28 | - ~git reset HEAD ~ – Unstage a staged file
29 | - ~git checkout -- ~ – Discard changes in a file since the last commit
30 | - ~git revert HEAD~ – Create a new commit that undoes the changes made in the
31 | previous commit
32 | - ~git push --force origin ~ – Force push changes to a remote branch
33 | that has already been pushed with unwanted changes.
34 |
35 | - [[https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things#_undoing][Reference]]
36 | *** What is remote?
37 | Remote on Git refers to a repository that is located on a server or another
38 | computer, rather than the user's local machine. It's a version of the repository
39 | that is used by teams to collaborate on a project. Remote repositories can be
40 | accessed and manipulated through Git commands, allowing users to push changes or
41 | fetch changes made by others. Remote repositories can be hosted on Git hosting
42 | services like GitHub, GitLab, or Bitbucket, or set up on a personal server.
43 | Multiple users can access and modify the same remote repository, making it easy
44 | for teams to work on a project together.
45 |
46 | *** What is branch?
47 | A branch in Git is a lightweight pointer to a specific commit. It allows
48 | developers to work on new features or make changes to the codebase without
49 | affecting the main codebase. Branches are created and can be switched between
50 | easily, and changes made in one branch do not affect other branches.
51 |
52 | To create a new branch in Git, you can use the command ~git branch
53 | ~. This creates a new branch but does not switch to it, so you will
54 | be working in the same branch until you use the command ~git checkout
55 | ~ to switch to the new branch. Alternatively, you can use the
56 | command ~git checkout -b ~ to create and switch to the new branch
57 | at the same time.
58 |
59 | To end a branch, you can use the command ~git branch -d ~. This
60 | deletes the specified branch, but only if it has been fully merged into the main
61 | branch. If you want to delete a branch whether it has been fully merged or not,
62 | you can use the command ~git branch -D ~. It's important to note
63 | that once a branch has been deleted, you cannot restore its commit history.
64 |
65 | ** Resources
66 | - [[https://dev.to/lydiahallie/cs-visualized-useful-git-commands-37p1][Visualization of Commands]]
67 | - [[https://ohshitgit.com/]]
68 | - [[https://learngitbranching.js.org/?locale=zh_CN]]
69 | - [[https://missing.csail.mit.edu/2020/version-control/][Missing semester video]]
70 | - [[https://git-scm.com/book/en/v2]]
71 |
72 | * Julia Package Management
73 | - This section is really well presented by Prof Liu at [[https://github.com/exAClior/CodingClub/blob/main/julia-packages/README.md][here]] and [[https://github.com/exAClior/CodingClub/blob/main/julia/2.first-package.md][here]].
74 | - Ask me anything and let's do a quick demo.
75 |
76 | * Shell Tools
77 | ** Shells
78 | Shell, zsh and bash are all command-line interface (CLI) interpreters used in
79 | Unix-like operating systems.
80 |
81 | - Shell is the simplest and most basic interpreter. Its primary function is to
82 | provide a command-line interface to the system. It can execute scripts, launch
83 | programs, manage files and directories, and perform basic system
84 | administrative tasks.
85 |
86 | - Bash (Bourne-Again SHell) is the default shell on most Linux distributions. It
87 | is backward-compatible with the original Bourne shell and includes many
88 | additional features, such as command-line editing, job control, and shell
89 | scripting capabilities. Bash is widely used as it is both easy to use and has
90 | a large user community, resulting in a plethora of available resources
91 | (tutorials, scripts, etc.) online.
92 |
93 | - Zsh (Z shell) is an extended version of the shell, with a more powerful
94 | command-line editing and completion system. It includes features like spelling
95 | correction and tab-completion, and it also supports plugins and themes. Zsh is
96 | commonly used by power users who require more productivity and efficiency from
97 | their command-line interface.
98 |
99 | ** Path Variable
100 | On Linux, the PATH variable is an environment variable that contains a list of
101 | directories that the shell searches for executable files. When a user enters a
102 | command in the shell, the shell looks for the executable file in each directory
103 | listed in the PATH variable, in the order they are listed. The PATH variable can
104 | be modified to add or remove directories, and it can also be set on a per-user
105 | or system-wide basis. The PATH variable is important because it allows users to
106 | easily run programs without having to specify the full path to the executable
107 | file each time.
108 |
109 | ** File Permission
110 | In Linux, file permissions determine who can access, edit, and execute files and
111 | directories. Each file and directory has three permission settings: owner,
112 | group, and other. The owner is the user who created the file or directory, the
113 | group is a set of users with specific permissions, and other is anyone else who
114 | has permission to access the file or directory. Each permission setting can have
115 | three levels of access: read, write, and execute. Read permission allows the
116 | user to view the contents of the file or directory, write permission allows the
117 | user to edit or delete the file or directory, and execute permission allows the
118 | user to run the file or access the directory. File and directory permissions can
119 | be changed using the chmod command in Linux.
120 |
121 | ** Common Shell Commands
122 | 1. ~cd~ - Change directory
123 | 2. ~ls~ - List directory contents
124 | 3. ~mv~ - Move or rename files or directories
125 | 4. ~cp~ - Copy files or directories
126 | 5. ~rm~ - Remove files or directories
127 | 6. ~mkdir~ - Create directories
128 | 7. ~rmdir~ - Remove empty directories
129 | 8. ~touch~ - Create an empty file or update the modification timestamp of a file
130 | 9. ~cat~ - Display the content of a file
131 | 10. ~grep~ - Search for a pattern in files
132 | 11. ~ps~ - Display information about running processes
133 | 12. ~kill~ - Terminate a process
134 | 13. ~echo~ - Print a message to the console
135 | 14. ~chmod~ - Change permissions of files or directories
136 | 15. ~history~ - Display a list of recently used commands
137 | 16. ~ssh~ - Connect to a remote server through ssh protocol
138 | 17. ~scp~ - Copy files between local and remote machines over ssh protocol
139 | 18. ~tar~ - Create or extract archive files
140 | 19. ~df~ - Display information about disk usage
141 | 20. ~wget~ - Download files from the internet.
142 |
143 | ** Tools
144 | 1. ~ripgrep~ (rg): A fast text search tool that recursively searches a directory
145 | hierarchy for a regex pattern.
146 | 2. ~Tmux~: A terminal multiplexer that allows you to divide your terminal into
147 | multiple panes and windows.
148 | 3. ~Ncdu~: A disk usage analyzer that helps you visualize which files and
149 | directories are consuming the most space on your filesystem.
150 | 4. ~tldr~: A simplified and community-driven version of man pages that provides
151 | practical examples of command line usage.
152 | 5. ~Bat~: A cat replacement that provides syntax highlighting, line numbering, and
153 | Git integration.
154 | 6. ~Exa~: A modern replacement for ls that supports additional features like file
155 | icons, Git status, and color themes.
156 | 7. ~Bandwhich~: A bandwidth usage analyzer that helps you see which processes are
157 | using the most network bandwidth.
158 | 8. ~fd~: A more user-friendly alternative to find that allows you to search for
159 | files and directories using a streamlined syntax.
160 | 9. ~htop~: An interactive process viewer that provides detailed information about
161 | system resource usage and allows you to manage processes.
162 | 10. ~Tmuxp~: A command line tool that allows you to easily manage and share your
163 | Tmux configurations.
164 | 11. ~direnv~: direnv is a shell extension that allows users to manage environment
165 | variables for different directories. It is designed to alleviate the
166 | inconvenience of constantly setting and unsetting environmental variables
167 | within different development environments.
168 |
169 | ** Resources
170 | - [[https://www.shellscript.sh/][Shell Script Learning]]
171 | - [[https://github.com/jlevy/the-art-of-command-line/blob/master/README.md][The Art of Command Line]]
172 |
173 | * Editors
174 | - Vim
175 | - Emacs
176 | - VSCode
177 |
--------------------------------------------------------------------------------
/julia-packages/.gitignore:
--------------------------------------------------------------------------------
1 | _test.dat
--------------------------------------------------------------------------------
/julia-packages/Manifest.toml:
--------------------------------------------------------------------------------
1 | # This file is machine-generated - editing it directly is not advised
2 |
3 | julia_version = "1.9.0-rc1"
4 | manifest_format = "2.0"
5 | project_hash = "c5949bca6853aa4235adab4bfc66c533b58e57a1"
6 |
7 | [[deps.AbstractFFTs]]
8 | deps = ["LinearAlgebra"]
9 | git-tree-sha1 = "16b6dbc4cf7caee4e1e75c49485ec67b667098a0"
10 | uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
11 | version = "1.3.1"
12 | weakdeps = ["ChainRulesCore"]
13 |
14 | [deps.AbstractFFTs.extensions]
15 | AbstractFFTsChainRulesCoreExt = "ChainRulesCore"
16 |
17 | [[deps.AbstractTrees]]
18 | git-tree-sha1 = "faa260e4cb5aba097a73fab382dd4b5819d8ec8c"
19 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
20 | version = "0.4.4"
21 |
22 | [[deps.Adapt]]
23 | deps = ["LinearAlgebra", "Requires"]
24 | git-tree-sha1 = "cc37d689f599e8df4f464b2fa3870ff7db7492ef"
25 | uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
26 | version = "3.6.1"
27 | weakdeps = ["StaticArrays"]
28 |
29 | [deps.Adapt.extensions]
30 | AdaptStaticArraysExt = "StaticArrays"
31 |
32 | [[deps.Animations]]
33 | deps = ["Colors"]
34 | git-tree-sha1 = "e81c509d2c8e49592413bfb0bb3b08150056c79d"
35 | uuid = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
36 | version = "0.4.1"
37 |
38 | [[deps.ArgTools]]
39 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
40 | version = "1.1.1"
41 |
42 | [[deps.Artifacts]]
43 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
44 |
45 | [[deps.Atomix]]
46 | deps = ["UnsafeAtomics"]
47 | git-tree-sha1 = "c06a868224ecba914baa6942988e2f2aade419be"
48 | uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
49 | version = "0.1.0"
50 |
51 | [[deps.Automa]]
52 | deps = ["Printf", "ScanByte", "TranscodingStreams"]
53 | git-tree-sha1 = "d50976f217489ce799e366d9561d56a98a30d7fe"
54 | uuid = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b"
55 | version = "0.8.2"
56 |
57 | [[deps.AxisAlgorithms]]
58 | deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"]
59 | git-tree-sha1 = "66771c8d21c8ff5e3a93379480a2307ac36863f7"
60 | uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950"
61 | version = "1.0.1"
62 |
63 | [[deps.AxisArrays]]
64 | deps = ["Dates", "IntervalSets", "IterTools", "RangeArrays"]
65 | git-tree-sha1 = "1dd4d9f5beebac0c03446918741b1a03dc5e5788"
66 | uuid = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
67 | version = "0.4.6"
68 |
69 | [[deps.BFloat16s]]
70 | deps = ["LinearAlgebra", "Printf", "Random", "Test"]
71 | git-tree-sha1 = "dbf84058d0a8cbbadee18d25cf606934b22d7c66"
72 | uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b"
73 | version = "0.4.2"
74 |
75 | [[deps.Base64]]
76 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
77 |
78 | [[deps.Bzip2_jll]]
79 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
80 | git-tree-sha1 = "19a35467a82e236ff51bc17a3a44b69ef35185a2"
81 | uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
82 | version = "1.0.8+0"
83 |
84 | [[deps.CEnum]]
85 | git-tree-sha1 = "eb4cb44a499229b3b8426dcfb5dd85333951ff90"
86 | uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
87 | version = "0.4.2"
88 |
89 | [[deps.CRC32c]]
90 | uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
91 |
92 | [[deps.CUDA]]
93 | deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CUDA_Driver_jll", "CUDA_Runtime_Discovery", "CUDA_Runtime_jll", "CompilerSupportLibraries_jll", "ExprTools", "GPUArrays", "GPUCompiler", "KernelAbstractions", "LLVM", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "Preferences", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "SpecialFunctions", "UnsafeAtomicsLLVM"]
94 | git-tree-sha1 = "2dbdec5c010bed6c6b1e0e5fd213bfe47925abc3"
95 | uuid = "052768ef-5323-5732-b1bb-66c8b64840ba"
96 | version = "4.1.0"
97 |
98 | [[deps.CUDA_Driver_jll]]
99 | deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"]
100 | git-tree-sha1 = "a1efe2bfb96c10906dede10f1580aca0ae6d092f"
101 | uuid = "4ee394cb-3365-5eb0-8335-949819d2adfc"
102 | version = "0.4.0+2"
103 |
104 | [[deps.CUDA_Runtime_Discovery]]
105 | deps = ["Libdl"]
106 | git-tree-sha1 = "58dd8ec29f54f08c04b052d2c2fa6760b4f4b3a4"
107 | uuid = "1af6417a-86b4-443c-805f-a4643ffb695f"
108 | version = "0.1.1"
109 |
110 | [[deps.CUDA_Runtime_jll]]
111 | deps = ["Artifacts", "CUDA_Driver_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
112 | git-tree-sha1 = "96e06a24c89a9945c57278fd09fb717f71476d87"
113 | uuid = "76a88914-d11a-5bdc-97e0-2f5a05c973a2"
114 | version = "0.4.0+2"
115 |
116 | [[deps.Cairo_jll]]
117 | deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
118 | git-tree-sha1 = "4b859a208b2397a7a623a03449e4636bdb17bcf2"
119 | uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a"
120 | version = "1.16.1+1"
121 |
122 | [[deps.Calculus]]
123 | deps = ["LinearAlgebra"]
124 | git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad"
125 | uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
126 | version = "0.5.1"
127 |
128 | [[deps.ChainRulesCore]]
129 | deps = ["Compat", "LinearAlgebra", "SparseArrays"]
130 | git-tree-sha1 = "c6d890a52d2c4d55d326439580c3b8d0875a77d9"
131 | uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
132 | version = "1.15.7"
133 |
134 | [[deps.ColorBrewer]]
135 | deps = ["Colors", "JSON", "Test"]
136 | git-tree-sha1 = "61c5334f33d91e570e1d0c3eb5465835242582c4"
137 | uuid = "a2cac450-b92f-5266-8821-25eda20663c8"
138 | version = "0.4.0"
139 |
140 | [[deps.ColorSchemes]]
141 | deps = ["ColorTypes", "ColorVectorSpace", "Colors", "FixedPointNumbers", "Random", "SnoopPrecompile"]
142 | git-tree-sha1 = "aa3edc8f8dea6cbfa176ee12f7c2fc82f0608ed3"
143 | uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
144 | version = "3.20.0"
145 |
146 | [[deps.ColorTypes]]
147 | deps = ["FixedPointNumbers", "Random"]
148 | git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4"
149 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
150 | version = "0.11.4"
151 |
152 | [[deps.ColorVectorSpace]]
153 | deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "SpecialFunctions", "Statistics", "TensorCore"]
154 | git-tree-sha1 = "600cc5508d66b78aae350f7accdb58763ac18589"
155 | uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4"
156 | version = "0.9.10"
157 |
158 | [[deps.Colors]]
159 | deps = ["ColorTypes", "FixedPointNumbers", "Reexport"]
160 | git-tree-sha1 = "fc08e5930ee9a4e03f84bfb5211cb54e7769758a"
161 | uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
162 | version = "0.12.10"
163 |
164 | [[deps.Compat]]
165 | deps = ["UUIDs"]
166 | git-tree-sha1 = "7a60c856b9fa189eb34f5f8a6f6b5529b7942957"
167 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
168 | version = "4.6.1"
169 | weakdeps = ["Dates", "LinearAlgebra"]
170 |
171 | [deps.Compat.extensions]
172 | CompatLinearAlgebraExt = "LinearAlgebra"
173 |
174 | [[deps.CompilerSupportLibraries_jll]]
175 | deps = ["Artifacts", "Libdl"]
176 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
177 | version = "1.0.2+0"
178 |
179 | [[deps.ConstructionBase]]
180 | deps = ["LinearAlgebra"]
181 | git-tree-sha1 = "89a9db8d28102b094992472d333674bd1a83ce2a"
182 | uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
183 | version = "1.5.1"
184 | weakdeps = ["IntervalSets", "StaticArrays"]
185 |
186 | [deps.ConstructionBase.extensions]
187 | IntervalSetsExt = "IntervalSets"
188 | StaticArraysExt = "StaticArrays"
189 |
190 | [[deps.Contour]]
191 | git-tree-sha1 = "d05d9e7b7aedff4e5b51a029dced05cfb6125781"
192 | uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
193 | version = "0.6.2"
194 |
195 | [[deps.DataAPI]]
196 | git-tree-sha1 = "e8119c1a33d267e16108be441a287a6981ba1630"
197 | uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
198 | version = "1.14.0"
199 |
200 | [[deps.DataStructures]]
201 | deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
202 | git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0"
203 | uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
204 | version = "0.18.13"
205 |
206 | [[deps.DataValueInterfaces]]
207 | git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
208 | uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
209 | version = "1.0.0"
210 |
211 | [[deps.Dates]]
212 | deps = ["Printf"]
213 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
214 |
215 | [[deps.DelimitedFiles]]
216 | deps = ["Mmap"]
217 | git-tree-sha1 = "9e2f36d3c96a820c678f2f1f1782582fcf685bae"
218 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
219 | version = "1.9.1"
220 |
221 | [[deps.Distributed]]
222 | deps = ["Random", "Serialization", "Sockets"]
223 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
224 |
225 | [[deps.Distributions]]
226 | deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns", "Test"]
227 | git-tree-sha1 = "da9e1a9058f8d3eec3a8c9fe4faacfb89180066b"
228 | uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
229 | version = "0.25.86"
230 |
231 | [deps.Distributions.extensions]
232 | DistributionsChainRulesCoreExt = "ChainRulesCore"
233 | DistributionsDensityInterfaceExt = "DensityInterface"
234 |
235 | [deps.Distributions.weakdeps]
236 | ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
237 | DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d"
238 |
239 | [[deps.DocStringExtensions]]
240 | deps = ["LibGit2"]
241 | git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d"
242 | uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
243 | version = "0.9.3"
244 |
245 | [[deps.Downloads]]
246 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
247 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
248 | version = "1.6.0"
249 |
250 | [[deps.DualNumbers]]
251 | deps = ["Calculus", "NaNMath", "SpecialFunctions"]
252 | git-tree-sha1 = "5837a837389fccf076445fce071c8ddaea35a566"
253 | uuid = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"
254 | version = "0.6.8"
255 |
256 | [[deps.EarCut_jll]]
257 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
258 | git-tree-sha1 = "e3290f2d49e661fbd94046d7e3726ffcb2d41053"
259 | uuid = "5ae413db-bbd1-5e63-b57d-d24a61df00f5"
260 | version = "2.2.4+0"
261 |
262 | [[deps.Expat_jll]]
263 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
264 | git-tree-sha1 = "bad72f730e9e91c08d9427d5e8db95478a3c323d"
265 | uuid = "2e619515-83b5-522b-bb60-26c02a35a201"
266 | version = "2.4.8+0"
267 |
268 | [[deps.ExprTools]]
269 | git-tree-sha1 = "c1d06d129da9f55715c6c212866f5b1bddc5fa00"
270 | uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
271 | version = "0.1.9"
272 |
273 | [[deps.Extents]]
274 | git-tree-sha1 = "5e1e4c53fa39afe63a7d356e30452249365fba99"
275 | uuid = "411431e0-e8b7-467b-b5e0-f676ba4f2910"
276 | version = "0.1.1"
277 |
278 | [[deps.FFMPEG]]
279 | deps = ["FFMPEG_jll"]
280 | git-tree-sha1 = "b57e3acbe22f8484b4b5ff66a7499717fe1a9cc8"
281 | uuid = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
282 | version = "0.4.1"
283 |
284 | [[deps.FFMPEG_jll]]
285 | deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "PCRE2_jll", "Pkg", "Zlib_jll", "libaom_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"]
286 | git-tree-sha1 = "74faea50c1d007c85837327f6775bea60b5492dd"
287 | uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
288 | version = "4.4.2+2"
289 |
290 | [[deps.FFTW]]
291 | deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"]
292 | git-tree-sha1 = "f9818144ce7c8c41edf5c4c179c684d92aa4d9fe"
293 | uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
294 | version = "1.6.0"
295 |
296 | [[deps.FFTW_jll]]
297 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
298 | git-tree-sha1 = "c6033cc3892d0ef5bb9cd29b7f2f0331ea5184ea"
299 | uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a"
300 | version = "3.3.10+0"
301 |
302 | [[deps.FileIO]]
303 | deps = ["Pkg", "Requires", "UUIDs"]
304 | git-tree-sha1 = "7be5f99f7d15578798f338f5433b6c432ea8037b"
305 | uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
306 | version = "1.16.0"
307 |
308 | [[deps.FileWatching]]
309 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
310 |
311 | [[deps.FillArrays]]
312 | deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"]
313 | git-tree-sha1 = "0ba171480d51567ba337e5eea4e68a8231b7a2c3"
314 | uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
315 | version = "0.13.10"
316 |
317 | [[deps.FixedPointNumbers]]
318 | deps = ["Statistics"]
319 | git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
320 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
321 | version = "0.8.4"
322 |
323 | [[deps.Fontconfig_jll]]
324 | deps = ["Artifacts", "Bzip2_jll", "Expat_jll", "FreeType2_jll", "JLLWrappers", "Libdl", "Libuuid_jll", "Pkg", "Zlib_jll"]
325 | git-tree-sha1 = "21efd19106a55620a188615da6d3d06cd7f6ee03"
326 | uuid = "a3f928ae-7b40-5064-980b-68af3947d34b"
327 | version = "2.13.93+0"
328 |
329 | [[deps.Formatting]]
330 | deps = ["Printf"]
331 | git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8"
332 | uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
333 | version = "0.4.2"
334 |
335 | [[deps.FreeType]]
336 | deps = ["CEnum", "FreeType2_jll"]
337 | git-tree-sha1 = "cabd77ab6a6fdff49bfd24af2ebe76e6e018a2b4"
338 | uuid = "b38be410-82b0-50bf-ab77-7b57e271db43"
339 | version = "4.0.0"
340 |
341 | [[deps.FreeType2_jll]]
342 | deps = ["Artifacts", "Bzip2_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
343 | git-tree-sha1 = "87eb71354d8ec1a96d4a7636bd57a7347dde3ef9"
344 | uuid = "d7e528f0-a631-5988-bf34-fe36492bcfd7"
345 | version = "2.10.4+0"
346 |
347 | [[deps.FreeTypeAbstraction]]
348 | deps = ["ColorVectorSpace", "Colors", "FreeType", "GeometryBasics"]
349 | git-tree-sha1 = "38a92e40157100e796690421e34a11c107205c86"
350 | uuid = "663a7486-cb36-511b-a19d-713bb74d65c9"
351 | version = "0.10.0"
352 |
353 | [[deps.FriBidi_jll]]
354 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
355 | git-tree-sha1 = "aa31987c2ba8704e23c6c8ba8a4f769d5d7e4f91"
356 | uuid = "559328eb-81f9-559d-9380-de523a88c83c"
357 | version = "1.0.10+0"
358 |
359 | [[deps.Future]]
360 | deps = ["Random"]
361 | uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
362 |
363 | [[deps.GLFW]]
364 | deps = ["GLFW_jll"]
365 | git-tree-sha1 = "35dbc482f0967d8dceaa7ce007d16f9064072166"
366 | uuid = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98"
367 | version = "3.4.1"
368 |
369 | [[deps.GLFW_jll]]
370 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Libglvnd_jll", "Pkg", "Xorg_libXcursor_jll", "Xorg_libXi_jll", "Xorg_libXinerama_jll", "Xorg_libXrandr_jll"]
371 | git-tree-sha1 = "d972031d28c8c8d9d7b41a536ad7bb0c2579caca"
372 | uuid = "0656b61e-2033-5cc2-a64a-77c0f6c09b89"
373 | version = "3.3.8+0"
374 |
375 | [[deps.GLMakie]]
376 | deps = ["ColorTypes", "Colors", "FileIO", "FixedPointNumbers", "FreeTypeAbstraction", "GLFW", "GeometryBasics", "LinearAlgebra", "Makie", "Markdown", "MeshIO", "ModernGL", "Observables", "Printf", "ShaderAbstractions", "SnoopPrecompile", "StaticArrays"]
377 | git-tree-sha1 = "38b855bf489c9d785ac9777230c0a14d4e69e11f"
378 | uuid = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
379 | version = "0.8.3"
380 |
381 | [[deps.GPUArrays]]
382 | deps = ["Adapt", "GPUArraysCore", "LLVM", "LinearAlgebra", "Printf", "Random", "Reexport", "Serialization", "Statistics"]
383 | git-tree-sha1 = "7a2e790b1e2e6f648cfb25c4500c5de1f7b375ef"
384 | uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
385 | version = "8.6.5"
386 |
387 | [[deps.GPUArraysCore]]
388 | deps = ["Adapt"]
389 | git-tree-sha1 = "1cd7f0af1aa58abc02ea1d872953a97359cb87fa"
390 | uuid = "46192b85-c4d5-4398-a991-12ede77f4527"
391 | version = "0.1.4"
392 |
393 | [[deps.GPUCompiler]]
394 | deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "TimerOutputs", "UUIDs"]
395 | git-tree-sha1 = "fd6431121f31fed05a5386ac88b9bb3f97fdfa69"
396 | uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
397 | version = "0.18.0"
398 |
399 | [[deps.GeoInterface]]
400 | deps = ["Extents"]
401 | git-tree-sha1 = "e07a1b98ed72e3cdd02c6ceaab94b8a606faca40"
402 | uuid = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
403 | version = "1.2.1"
404 |
405 | [[deps.GeometryBasics]]
406 | deps = ["EarCut_jll", "GeoInterface", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
407 | git-tree-sha1 = "303202358e38d2b01ba46844b92e48a3c238fd9e"
408 | uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
409 | version = "0.4.6"
410 |
411 | [[deps.Gettext_jll]]
412 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"]
413 | git-tree-sha1 = "9b02998aba7bf074d14de89f9d37ca24a1a0b046"
414 | uuid = "78b55507-aeef-58d4-861c-77aaff3498b1"
415 | version = "0.21.0+0"
416 |
417 | [[deps.Glib_jll]]
418 | deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Pkg", "Zlib_jll"]
419 | git-tree-sha1 = "d3b3624125c1474292d0d8ed0f65554ac37ddb23"
420 | uuid = "7746bdde-850d-59dc-9ae8-88ece973131d"
421 | version = "2.74.0+2"
422 |
423 | [[deps.Graphics]]
424 | deps = ["Colors", "LinearAlgebra", "NaNMath"]
425 | git-tree-sha1 = "d61890399bc535850c4bf08e4e0d3a7ad0f21cbd"
426 | uuid = "a2bd30eb-e257-5431-a919-1863eab51364"
427 | version = "1.1.2"
428 |
429 | [[deps.Graphite2_jll]]
430 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
431 | git-tree-sha1 = "344bf40dcab1073aca04aa0df4fb092f920e4011"
432 | uuid = "3b182d85-2403-5c21-9c21-1e1f0cc25472"
433 | version = "1.3.14+0"
434 |
435 | [[deps.GridLayoutBase]]
436 | deps = ["GeometryBasics", "InteractiveUtils", "Observables"]
437 | git-tree-sha1 = "678d136003ed5bceaab05cf64519e3f956ffa4ba"
438 | uuid = "3955a311-db13-416c-9275-1d80ed98e5e9"
439 | version = "0.9.1"
440 |
441 | [[deps.Grisu]]
442 | git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2"
443 | uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
444 | version = "1.0.2"
445 |
446 | [[deps.HarfBuzz_jll]]
447 | deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"]
448 | git-tree-sha1 = "129acf094d168394e80ee1dc4bc06ec835e510a3"
449 | uuid = "2e76f6c2-a576-52d4-95c1-20adfe4de566"
450 | version = "2.8.1+1"
451 |
452 | [[deps.HypergeometricFunctions]]
453 | deps = ["DualNumbers", "LinearAlgebra", "OpenLibm_jll", "SpecialFunctions", "Test"]
454 | git-tree-sha1 = "709d864e3ed6e3545230601f94e11ebc65994641"
455 | uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
456 | version = "0.3.11"
457 |
458 | [[deps.ImageAxes]]
459 | deps = ["AxisArrays", "ImageBase", "ImageCore", "Reexport", "SimpleTraits"]
460 | git-tree-sha1 = "c54b581a83008dc7f292e205f4c409ab5caa0f04"
461 | uuid = "2803e5a7-5153-5ecf-9a86-9b4c37f5f5ac"
462 | version = "0.6.10"
463 |
464 | [[deps.ImageBase]]
465 | deps = ["ImageCore", "Reexport"]
466 | git-tree-sha1 = "b51bb8cae22c66d0f6357e3bcb6363145ef20835"
467 | uuid = "c817782e-172a-44cc-b673-b171935fbb9e"
468 | version = "0.1.5"
469 |
470 | [[deps.ImageCore]]
471 | deps = ["AbstractFFTs", "ColorVectorSpace", "Colors", "FixedPointNumbers", "Graphics", "MappedArrays", "MosaicViews", "OffsetArrays", "PaddedViews", "Reexport"]
472 | git-tree-sha1 = "acf614720ef026d38400b3817614c45882d75500"
473 | uuid = "a09fc81d-aa75-5fe9-8630-4744c3626534"
474 | version = "0.9.4"
475 |
476 | [[deps.ImageIO]]
477 | deps = ["FileIO", "IndirectArrays", "JpegTurbo", "LazyModules", "Netpbm", "OpenEXR", "PNGFiles", "QOI", "Sixel", "TiffImages", "UUIDs"]
478 | git-tree-sha1 = "342f789fd041a55166764c351da1710db97ce0e0"
479 | uuid = "82e4d734-157c-48bb-816b-45c225c6df19"
480 | version = "0.6.6"
481 |
482 | [[deps.ImageMetadata]]
483 | deps = ["AxisArrays", "ImageAxes", "ImageBase", "ImageCore"]
484 | git-tree-sha1 = "36cbaebed194b292590cba2593da27b34763804a"
485 | uuid = "bc367c6b-8a6b-528e-b4bd-a4b897500b49"
486 | version = "0.9.8"
487 |
488 | [[deps.Imath_jll]]
489 | deps = ["Artifacts", "JLLWrappers", "Libdl"]
490 | git-tree-sha1 = "3d09a9f60edf77f8a4d99f9e015e8fbf9989605d"
491 | uuid = "905a6f67-0a94-5f89-b386-d35d92009cd1"
492 | version = "3.1.7+0"
493 |
494 | [[deps.IndirectArrays]]
495 | git-tree-sha1 = "012e604e1c7458645cb8b436f8fba789a51b257f"
496 | uuid = "9b13fd28-a010-5f03-acff-a1bbcff69959"
497 | version = "1.0.0"
498 |
499 | [[deps.Inflate]]
500 | git-tree-sha1 = "5cd07aab533df5170988219191dfad0519391428"
501 | uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
502 | version = "0.1.3"
503 |
504 | [[deps.IntelOpenMP_jll]]
505 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
506 | git-tree-sha1 = "d979e54b71da82f3a65b62553da4fc3d18c9004c"
507 | uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0"
508 | version = "2018.0.3+2"
509 |
510 | [[deps.InteractiveUtils]]
511 | deps = ["Markdown"]
512 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
513 |
514 | [[deps.Interpolations]]
515 | deps = ["Adapt", "AxisAlgorithms", "ChainRulesCore", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "Requires", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"]
516 | git-tree-sha1 = "721ec2cf720536ad005cb38f50dbba7b02419a15"
517 | uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
518 | version = "0.14.7"
519 |
520 | [[deps.IntervalSets]]
521 | deps = ["Dates", "Random", "Statistics"]
522 | git-tree-sha1 = "16c0cc91853084cb5f58a78bd209513900206ce6"
523 | uuid = "8197267c-284f-5f27-9208-e0e47529a953"
524 | version = "0.7.4"
525 |
526 | [[deps.IrrationalConstants]]
527 | git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2"
528 | uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
529 | version = "0.2.2"
530 |
531 | [[deps.Isoband]]
532 | deps = ["isoband_jll"]
533 | git-tree-sha1 = "f9b6d97355599074dc867318950adaa6f9946137"
534 | uuid = "f1662d9f-8043-43de-a69a-05efc1cc6ff4"
535 | version = "0.1.1"
536 |
537 | [[deps.IterTools]]
538 | git-tree-sha1 = "fa6287a4469f5e048d763df38279ee729fbd44e5"
539 | uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
540 | version = "1.4.0"
541 |
542 | [[deps.IteratorInterfaceExtensions]]
543 | git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
544 | uuid = "82899510-4779-5014-852e-03e436cf321d"
545 | version = "1.0.0"
546 |
547 | [[deps.JLLWrappers]]
548 | deps = ["Preferences"]
549 | git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1"
550 | uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
551 | version = "1.4.1"
552 |
553 | [[deps.JSON]]
554 | deps = ["Dates", "Mmap", "Parsers", "Unicode"]
555 | git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e"
556 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
557 | version = "0.21.3"
558 |
559 | [[deps.JpegTurbo]]
560 | deps = ["CEnum", "FileIO", "ImageCore", "JpegTurbo_jll", "TOML"]
561 | git-tree-sha1 = "106b6aa272f294ba47e96bd3acbabdc0407b5c60"
562 | uuid = "b835a17e-a41a-41e7-81f0-2f016b05efe0"
563 | version = "0.1.2"
564 |
565 | [[deps.JpegTurbo_jll]]
566 | deps = ["Artifacts", "JLLWrappers", "Libdl"]
567 | git-tree-sha1 = "6f2675ef130a300a112286de91973805fcc5ffbc"
568 | uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8"
569 | version = "2.1.91+0"
570 |
571 | [[deps.KernelAbstractions]]
572 | deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "SnoopPrecompile", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"]
573 | git-tree-sha1 = "17d0bb94eef881b09c57967be12cca70fefb3304"
574 | uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
575 | version = "0.9.0"
576 |
577 | [[deps.KernelDensity]]
578 | deps = ["Distributions", "DocStringExtensions", "FFTW", "Interpolations", "StatsBase"]
579 | git-tree-sha1 = "9816b296736292a80b9a3200eb7fbb57aaa3917a"
580 | uuid = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
581 | version = "0.6.5"
582 |
583 | [[deps.LAME_jll]]
584 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
585 | git-tree-sha1 = "f6250b16881adf048549549fba48b1161acdac8c"
586 | uuid = "c1c5ebd0-6772-5130-a774-d5fcae4a789d"
587 | version = "3.100.1+0"
588 |
589 | [[deps.LLVM]]
590 | deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"]
591 | git-tree-sha1 = "f044a2796a9e18e0531b9b3072b0019a61f264bc"
592 | uuid = "929cbde3-209d-540e-8aea-75f648917ca0"
593 | version = "4.17.1"
594 |
595 | [[deps.LLVMExtra_jll]]
596 | deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
597 | git-tree-sha1 = "070e4b5b65827f82c16ae0916376cb47377aa1b5"
598 | uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
599 | version = "0.0.18+0"
600 |
601 | [[deps.LZO_jll]]
602 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
603 | git-tree-sha1 = "e5b909bcf985c5e2605737d2ce278ed791b89be6"
604 | uuid = "dd4b983a-f0e5-5f8d-a1b7-129d4a5fb1ac"
605 | version = "2.10.1+0"
606 |
607 | [[deps.LaTeXStrings]]
608 | git-tree-sha1 = "f2355693d6778a178ade15952b7ac47a4ff97996"
609 | uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
610 | version = "1.3.0"
611 |
612 | [[deps.LazyArtifacts]]
613 | deps = ["Artifacts", "Pkg"]
614 | uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
615 |
616 | [[deps.LazyModules]]
617 | git-tree-sha1 = "a560dd966b386ac9ae60bdd3a3d3a326062d3c3e"
618 | uuid = "8cdb02fc-e678-4876-92c5-9defec4f444e"
619 | version = "0.3.1"
620 |
621 | [[deps.LibCURL]]
622 | deps = ["LibCURL_jll", "MozillaCACerts_jll"]
623 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
624 | version = "0.6.3"
625 |
626 | [[deps.LibCURL_jll]]
627 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
628 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
629 | version = "7.84.0+0"
630 |
631 | [[deps.LibGit2]]
632 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
633 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
634 |
635 | [[deps.LibSSH2_jll]]
636 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
637 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
638 | version = "1.10.2+0"
639 |
640 | [[deps.Libdl]]
641 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
642 |
643 | [[deps.Libffi_jll]]
644 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
645 | git-tree-sha1 = "0b4a5d71f3e5200a7dff793393e09dfc2d874290"
646 | uuid = "e9f186c6-92d2-5b65-8a66-fee21dc1b490"
647 | version = "3.2.2+1"
648 |
649 | [[deps.Libgcrypt_jll]]
650 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgpg_error_jll", "Pkg"]
651 | git-tree-sha1 = "64613c82a59c120435c067c2b809fc61cf5166ae"
652 | uuid = "d4300ac3-e22c-5743-9152-c294e39db1e4"
653 | version = "1.8.7+0"
654 |
655 | [[deps.Libglvnd_jll]]
656 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll", "Xorg_libXext_jll"]
657 | git-tree-sha1 = "6f73d1dd803986947b2c750138528a999a6c7733"
658 | uuid = "7e76a0d4-f3c7-5321-8279-8d96eeed0f29"
659 | version = "1.6.0+0"
660 |
661 | [[deps.Libgpg_error_jll]]
662 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
663 | git-tree-sha1 = "c333716e46366857753e273ce6a69ee0945a6db9"
664 | uuid = "7add5ba3-2f88-524e-9cd5-f83b8a55f7b8"
665 | version = "1.42.0+0"
666 |
667 | [[deps.Libiconv_jll]]
668 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
669 | git-tree-sha1 = "c7cb1f5d892775ba13767a87c7ada0b980ea0a71"
670 | uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
671 | version = "1.16.1+2"
672 |
673 | [[deps.Libmount_jll]]
674 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
675 | git-tree-sha1 = "9c30530bf0effd46e15e0fdcf2b8636e78cbbd73"
676 | uuid = "4b2f31a3-9ecc-558c-b454-b3730dcb73e9"
677 | version = "2.35.0+0"
678 |
679 | [[deps.Libuuid_jll]]
680 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
681 | git-tree-sha1 = "7f3efec06033682db852f8b3bc3c1d2b0a0ab066"
682 | uuid = "38a345b3-de98-5d2b-a5d3-14cd9215e700"
683 | version = "2.36.0+0"
684 |
685 | [[deps.LinearAlgebra]]
686 | deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
687 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
688 |
689 | [[deps.LogExpFunctions]]
690 | deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
691 | git-tree-sha1 = "0a1b7c2863e44523180fdb3146534e265a91870b"
692 | uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
693 | version = "0.3.23"
694 |
695 | [deps.LogExpFunctions.extensions]
696 | LogExpFunctionsChainRulesCoreExt = "ChainRulesCore"
697 | LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables"
698 | LogExpFunctionsInverseFunctionsExt = "InverseFunctions"
699 |
700 | [deps.LogExpFunctions.weakdeps]
701 | ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
702 | ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
703 | InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
704 |
705 | [[deps.Logging]]
706 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
707 |
708 | [[deps.MKL_jll]]
709 | deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"]
710 | git-tree-sha1 = "2ce8695e1e699b68702c03402672a69f54b8aca9"
711 | uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
712 | version = "2022.2.0+0"
713 |
714 | [[deps.MacroTools]]
715 | deps = ["Markdown", "Random"]
716 | git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2"
717 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
718 | version = "0.5.10"
719 |
720 | [[deps.Makie]]
721 | deps = ["Animations", "Base64", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "Contour", "Distributions", "DocStringExtensions", "Downloads", "FFMPEG", "FileIO", "FixedPointNumbers", "Formatting", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageIO", "InteractiveUtils", "IntervalSets", "Isoband", "KernelDensity", "LaTeXStrings", "LinearAlgebra", "MakieCore", "Markdown", "Match", "MathTeXEngine", "MiniQhull", "Observables", "OffsetArrays", "Packing", "PlotUtils", "PolygonOps", "Printf", "Random", "RelocatableFolders", "Setfield", "Showoff", "SignedDistanceFields", "SnoopPrecompile", "SparseArrays", "StableHashTraits", "Statistics", "StatsBase", "StatsFuns", "StructArrays", "TriplotBase", "UnicodeFun"]
722 | git-tree-sha1 = "e7b6e3eebbadcdfd9f40ad99be84044968a562ee"
723 | uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
724 | version = "0.19.3"
725 |
726 | [[deps.MakieCore]]
727 | deps = ["Observables"]
728 | git-tree-sha1 = "9926529455a331ed73c19ff06d16906737a876ed"
729 | uuid = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
730 | version = "0.6.3"
731 |
732 | [[deps.MappedArrays]]
733 | git-tree-sha1 = "e8b359ef06ec72e8c030463fe02efe5527ee5142"
734 | uuid = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
735 | version = "0.4.1"
736 |
737 | [[deps.Markdown]]
738 | deps = ["Base64"]
739 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
740 |
741 | [[deps.Match]]
742 | git-tree-sha1 = "1d9bc5c1a6e7ee24effb93f175c9342f9154d97f"
743 | uuid = "7eb4fadd-790c-5f42-8a69-bfa0b872bfbf"
744 | version = "1.2.0"
745 |
746 | [[deps.MathTeXEngine]]
747 | deps = ["AbstractTrees", "Automa", "DataStructures", "FreeTypeAbstraction", "GeometryBasics", "LaTeXStrings", "REPL", "RelocatableFolders", "Test", "UnicodeFun"]
748 | git-tree-sha1 = "f04120d9adf4f49be242db0b905bea0be32198d1"
749 | uuid = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53"
750 | version = "0.5.4"
751 |
752 | [[deps.MbedTLS_jll]]
753 | deps = ["Artifacts", "Libdl"]
754 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
755 | version = "2.28.2+0"
756 |
757 | [[deps.MeshIO]]
758 | deps = ["ColorTypes", "FileIO", "GeometryBasics", "Printf"]
759 | git-tree-sha1 = "8be09d84a2d597c7c0c34d7d604c039c9763e48c"
760 | uuid = "7269a6da-0436-5bbc-96c2-40638cbb6118"
761 | version = "0.4.10"
762 |
763 | [[deps.MiniQhull]]
764 | deps = ["QhullMiniWrapper_jll"]
765 | git-tree-sha1 = "9dc837d180ee49eeb7c8b77bb1c860452634b0d1"
766 | uuid = "978d7f02-9e05-4691-894f-ae31a51d76ca"
767 | version = "0.4.0"
768 |
769 | [[deps.Missings]]
770 | deps = ["DataAPI"]
771 | git-tree-sha1 = "f66bdc5de519e8f8ae43bdc598782d35a25b1272"
772 | uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
773 | version = "1.1.0"
774 |
775 | [[deps.Mmap]]
776 | uuid = "a63ad114-7e13-5084-954f-fe012c677804"
777 |
778 | [[deps.ModernGL]]
779 | deps = ["Libdl"]
780 | git-tree-sha1 = "b76ea40b5c0f45790ae09492712dd326208c28b2"
781 | uuid = "66fc600b-dfda-50eb-8b99-91cfa97b1301"
782 | version = "1.1.7"
783 |
784 | [[deps.MosaicViews]]
785 | deps = ["MappedArrays", "OffsetArrays", "PaddedViews", "StackViews"]
786 | git-tree-sha1 = "7b86a5d4d70a9f5cdf2dacb3cbe6d251d1a61dbe"
787 | uuid = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389"
788 | version = "0.3.4"
789 |
790 | [[deps.MozillaCACerts_jll]]
791 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
792 | version = "2022.10.11"
793 |
794 | [[deps.NaNMath]]
795 | deps = ["OpenLibm_jll"]
796 | git-tree-sha1 = "0877504529a3e5c3343c6f8b4c0381e57e4387e4"
797 | uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
798 | version = "1.0.2"
799 |
800 | [[deps.Netpbm]]
801 | deps = ["FileIO", "ImageCore", "ImageMetadata"]
802 | git-tree-sha1 = "5ae7ca23e13855b3aba94550f26146c01d259267"
803 | uuid = "f09324ee-3d7c-5217-9330-fc30815ba969"
804 | version = "1.1.0"
805 |
806 | [[deps.NetworkOptions]]
807 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
808 | version = "1.2.0"
809 |
810 | [[deps.Observables]]
811 | git-tree-sha1 = "6862738f9796b3edc1c09d0890afce4eca9e7e93"
812 | uuid = "510215fc-4207-5dde-b226-833fc4488ee2"
813 | version = "0.5.4"
814 |
815 | [[deps.OffsetArrays]]
816 | deps = ["Adapt"]
817 | git-tree-sha1 = "82d7c9e310fe55aa54996e6f7f94674e2a38fcb4"
818 | uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
819 | version = "1.12.9"
820 |
821 | [[deps.Ogg_jll]]
822 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
823 | git-tree-sha1 = "887579a3eb005446d514ab7aeac5d1d027658b8f"
824 | uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051"
825 | version = "1.3.5+1"
826 |
827 | [[deps.OpenBLAS_jll]]
828 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
829 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
830 | version = "0.3.21+4"
831 |
832 | [[deps.OpenEXR]]
833 | deps = ["Colors", "FileIO", "OpenEXR_jll"]
834 | git-tree-sha1 = "327f53360fdb54df7ecd01e96ef1983536d1e633"
835 | uuid = "52e1d378-f018-4a11-a4be-720524705ac7"
836 | version = "0.3.2"
837 |
838 | [[deps.OpenEXR_jll]]
839 | deps = ["Artifacts", "Imath_jll", "JLLWrappers", "Libdl", "Zlib_jll"]
840 | git-tree-sha1 = "a4ca623df1ae99d09bc9868b008262d0c0ac1e4f"
841 | uuid = "18a262bb-aa17-5467-a713-aee519bc75cb"
842 | version = "3.1.4+0"
843 |
844 | [[deps.OpenLibm_jll]]
845 | deps = ["Artifacts", "Libdl"]
846 | uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
847 | version = "0.8.1+0"
848 |
849 | [[deps.OpenSSL_jll]]
850 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
851 | git-tree-sha1 = "9ff31d101d987eb9d66bd8b176ac7c277beccd09"
852 | uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
853 | version = "1.1.20+0"
854 |
855 | [[deps.OpenSpecFun_jll]]
856 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
857 | git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
858 | uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
859 | version = "0.5.5+0"
860 |
861 | [[deps.Opus_jll]]
862 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
863 | git-tree-sha1 = "51a08fb14ec28da2ec7a927c4337e4332c2a4720"
864 | uuid = "91d4177d-7536-5919-b921-800302f37372"
865 | version = "1.3.2+0"
866 |
867 | [[deps.OrderedCollections]]
868 | git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
869 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
870 | version = "1.4.1"
871 |
872 | [[deps.PCRE2_jll]]
873 | deps = ["Artifacts", "Libdl"]
874 | uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15"
875 | version = "10.42.0+0"
876 |
877 | [[deps.PDMats]]
878 | deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
879 | git-tree-sha1 = "67eae2738d63117a196f497d7db789821bce61d1"
880 | uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
881 | version = "0.11.17"
882 |
883 | [[deps.PNGFiles]]
884 | deps = ["Base64", "CEnum", "ImageCore", "IndirectArrays", "OffsetArrays", "libpng_jll"]
885 | git-tree-sha1 = "f809158b27eba0c18c269cf2a2be6ed751d3e81d"
886 | uuid = "f57f5aa1-a3ce-4bc8-8ab9-96f992907883"
887 | version = "0.3.17"
888 |
889 | [[deps.Packing]]
890 | deps = ["GeometryBasics"]
891 | git-tree-sha1 = "ec3edfe723df33528e085e632414499f26650501"
892 | uuid = "19eb6ba3-879d-56ad-ad62-d5c202156566"
893 | version = "0.5.0"
894 |
895 | [[deps.PaddedViews]]
896 | deps = ["OffsetArrays"]
897 | git-tree-sha1 = "03a7a85b76381a3d04c7a1656039197e70eda03d"
898 | uuid = "5432bcbf-9aad-5242-b902-cca2824c8663"
899 | version = "0.5.11"
900 |
901 | [[deps.Parsers]]
902 | deps = ["Dates", "SnoopPrecompile"]
903 | git-tree-sha1 = "478ac6c952fddd4399e71d4779797c538d0ff2bf"
904 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
905 | version = "2.5.8"
906 |
907 | [[deps.Pixman_jll]]
908 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
909 | git-tree-sha1 = "b4f5d02549a10e20780a24fce72bea96b6329e29"
910 | uuid = "30392449-352a-5448-841d-b1acce4e97dc"
911 | version = "0.40.1+0"
912 |
913 | [[deps.Pkg]]
914 | deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
915 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
916 | version = "1.9.0"
917 |
918 | [[deps.PkgVersion]]
919 | deps = ["Pkg"]
920 | git-tree-sha1 = "f6cf8e7944e50901594838951729a1861e668cb8"
921 | uuid = "eebad327-c553-4316-9ea0-9fa01ccd7688"
922 | version = "0.3.2"
923 |
924 | [[deps.PlotUtils]]
925 | deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "SnoopPrecompile", "Statistics"]
926 | git-tree-sha1 = "c95373e73290cf50a8a22c3375e4625ded5c5280"
927 | uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
928 | version = "1.3.4"
929 |
930 | [[deps.PolygonOps]]
931 | git-tree-sha1 = "77b3d3605fc1cd0b42d95eba87dfcd2bf67d5ff6"
932 | uuid = "647866c9-e3ac-4575-94e7-e3d426903924"
933 | version = "0.1.2"
934 |
935 | [[deps.Preferences]]
936 | deps = ["TOML"]
937 | git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d"
938 | uuid = "21216c6a-2e73-6563-6e65-726566657250"
939 | version = "1.3.0"
940 |
941 | [[deps.Printf]]
942 | deps = ["Unicode"]
943 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
944 |
945 | [[deps.ProgressMeter]]
946 | deps = ["Distributed", "Printf"]
947 | git-tree-sha1 = "d7a7aef8f8f2d537104f170139553b14dfe39fe9"
948 | uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
949 | version = "1.7.2"
950 |
951 | [[deps.QOI]]
952 | deps = ["ColorTypes", "FileIO", "FixedPointNumbers"]
953 | git-tree-sha1 = "18e8f4d1426e965c7b532ddd260599e1510d26ce"
954 | uuid = "4b34888f-f399-49d4-9bb3-47ed5cae4e65"
955 | version = "1.0.0"
956 |
957 | [[deps.QhullMiniWrapper_jll]]
958 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Qhull_jll"]
959 | git-tree-sha1 = "607cf73c03f8a9f83b36db0b86a3a9c14179621f"
960 | uuid = "460c41e3-6112-5d7f-b78c-b6823adb3f2d"
961 | version = "1.0.0+1"
962 |
963 | [[deps.Qhull_jll]]
964 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
965 | git-tree-sha1 = "238dd7e2cc577281976b9681702174850f8d4cbc"
966 | uuid = "784f63db-0788-585a-bace-daefebcd302b"
967 | version = "8.0.1001+0"
968 |
969 | [[deps.QuadGK]]
970 | deps = ["DataStructures", "LinearAlgebra"]
971 | git-tree-sha1 = "6ec7ac8412e83d57e313393220879ede1740f9ee"
972 | uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
973 | version = "2.8.2"
974 |
975 | [[deps.REPL]]
976 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
977 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
978 |
979 | [[deps.Random]]
980 | deps = ["SHA", "Serialization"]
981 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
982 |
983 | [[deps.Random123]]
984 | deps = ["Random", "RandomNumbers"]
985 | git-tree-sha1 = "7a1a306b72cfa60634f03a911405f4e64d1b718b"
986 | uuid = "74087812-796a-5b5d-8853-05524746bad3"
987 | version = "1.6.0"
988 |
989 | [[deps.RandomNumbers]]
990 | deps = ["Random", "Requires"]
991 | git-tree-sha1 = "043da614cc7e95c703498a491e2c21f58a2b8111"
992 | uuid = "e6cf234a-135c-5ec9-84dd-332b85af5143"
993 | version = "1.5.3"
994 |
995 | [[deps.RangeArrays]]
996 | git-tree-sha1 = "b9039e93773ddcfc828f12aadf7115b4b4d225f5"
997 | uuid = "b3c3ace0-ae52-54e7-9d0b-2c1406fd6b9d"
998 | version = "0.3.2"
999 |
1000 | [[deps.Ratios]]
1001 | deps = ["Requires"]
1002 | git-tree-sha1 = "dc84268fe0e3335a62e315a3a7cf2afa7178a734"
1003 | uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
1004 | version = "0.4.3"
1005 |
1006 | [[deps.Reexport]]
1007 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
1008 | uuid = "189a3867-3050-52da-a836-e630ba90ab69"
1009 | version = "1.2.2"
1010 |
1011 | [[deps.RelocatableFolders]]
1012 | deps = ["SHA", "Scratch"]
1013 | git-tree-sha1 = "90bc7a7c96410424509e4263e277e43250c05691"
1014 | uuid = "05181044-ff0b-4ac5-8273-598c1e38db00"
1015 | version = "1.0.0"
1016 |
1017 | [[deps.Requires]]
1018 | deps = ["UUIDs"]
1019 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
1020 | uuid = "ae029012-a4dd-5104-9daa-d747884805df"
1021 | version = "1.3.0"
1022 |
1023 | [[deps.Rmath]]
1024 | deps = ["Random", "Rmath_jll"]
1025 | git-tree-sha1 = "f65dcb5fa46aee0cf9ed6274ccbd597adc49aa7b"
1026 | uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
1027 | version = "0.7.1"
1028 |
1029 | [[deps.Rmath_jll]]
1030 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1031 | git-tree-sha1 = "6ed52fdd3382cf21947b15e8870ac0ddbff736da"
1032 | uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
1033 | version = "0.4.0+0"
1034 |
1035 | [[deps.SHA]]
1036 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
1037 | version = "0.7.0"
1038 |
1039 | [[deps.SIMD]]
1040 | deps = ["SnoopPrecompile"]
1041 | git-tree-sha1 = "8b20084a97b004588125caebf418d8cab9e393d1"
1042 | uuid = "fdea26ae-647d-5447-a871-4b548cad5224"
1043 | version = "3.4.4"
1044 |
1045 | [[deps.ScanByte]]
1046 | deps = ["Libdl", "SIMD"]
1047 | git-tree-sha1 = "2436b15f376005e8790e318329560dcc67188e84"
1048 | uuid = "7b38b023-a4d7-4c5e-8d43-3f3097f304eb"
1049 | version = "0.3.3"
1050 |
1051 | [[deps.Scratch]]
1052 | deps = ["Dates"]
1053 | git-tree-sha1 = "30449ee12237627992a99d5e30ae63e4d78cd24a"
1054 | uuid = "6c6a2e73-6563-6170-7368-637461726353"
1055 | version = "1.2.0"
1056 |
1057 | [[deps.Serialization]]
1058 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1059 |
1060 | [[deps.Setfield]]
1061 | deps = ["ConstructionBase", "Future", "MacroTools", "StaticArraysCore"]
1062 | git-tree-sha1 = "e2cc6d8c88613c05e1defb55170bf5ff211fbeac"
1063 | uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46"
1064 | version = "1.1.1"
1065 |
1066 | [[deps.ShaderAbstractions]]
1067 | deps = ["ColorTypes", "FixedPointNumbers", "GeometryBasics", "LinearAlgebra", "Observables", "StaticArrays", "StructArrays", "Tables"]
1068 | git-tree-sha1 = "0d15c3e7b2003f4451714f08ffec2b77badc2dc4"
1069 | uuid = "65257c39-d410-5151-9873-9b3e5be5013e"
1070 | version = "0.3.0"
1071 |
1072 | [[deps.SharedArrays]]
1073 | deps = ["Distributed", "Mmap", "Random", "Serialization"]
1074 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
1075 |
1076 | [[deps.Showoff]]
1077 | deps = ["Dates", "Grisu"]
1078 | git-tree-sha1 = "91eddf657aca81df9ae6ceb20b959ae5653ad1de"
1079 | uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
1080 | version = "1.0.3"
1081 |
1082 | [[deps.SignedDistanceFields]]
1083 | deps = ["Random", "Statistics", "Test"]
1084 | git-tree-sha1 = "d263a08ec505853a5ff1c1ebde2070419e3f28e9"
1085 | uuid = "73760f76-fbc4-59ce-8f25-708e95d2df96"
1086 | version = "0.4.0"
1087 |
1088 | [[deps.SimpleTraits]]
1089 | deps = ["InteractiveUtils", "MacroTools"]
1090 | git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231"
1091 | uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
1092 | version = "0.9.4"
1093 |
1094 | [[deps.Sixel]]
1095 | deps = ["Dates", "FileIO", "ImageCore", "IndirectArrays", "OffsetArrays", "REPL", "libsixel_jll"]
1096 | git-tree-sha1 = "8fb59825be681d451c246a795117f317ecbcaa28"
1097 | uuid = "45858cf5-a6b0-47a3-bbea-62219f50df47"
1098 | version = "0.1.2"
1099 |
1100 | [[deps.SnoopPrecompile]]
1101 | deps = ["Preferences"]
1102 | git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c"
1103 | uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c"
1104 | version = "1.0.3"
1105 |
1106 | [[deps.Sockets]]
1107 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
1108 |
1109 | [[deps.SortingAlgorithms]]
1110 | deps = ["DataStructures"]
1111 | git-tree-sha1 = "a4ada03f999bd01b3a25dcaa30b2d929fe537e00"
1112 | uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
1113 | version = "1.1.0"
1114 |
1115 | [[deps.SparseArrays]]
1116 | deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
1117 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1118 |
1119 | [[deps.SpecialFunctions]]
1120 | deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
1121 | git-tree-sha1 = "ef28127915f4229c971eb43f3fc075dd3fe91880"
1122 | uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
1123 | version = "2.2.0"
1124 | weakdeps = ["ChainRulesCore"]
1125 |
1126 | [deps.SpecialFunctions.extensions]
1127 | SpecialFunctionsChainRulesCoreExt = "ChainRulesCore"
1128 |
1129 | [[deps.StableHashTraits]]
1130 | deps = ["CRC32c", "Compat", "Dates", "SHA", "Tables", "TupleTools", "UUIDs"]
1131 | git-tree-sha1 = "0b8b801b8f03a329a4e86b44c5e8a7d7f4fe10a3"
1132 | uuid = "c5dd0088-6c3f-4803-b00e-f31a60c170fa"
1133 | version = "0.3.1"
1134 |
1135 | [[deps.StackViews]]
1136 | deps = ["OffsetArrays"]
1137 | git-tree-sha1 = "46e589465204cd0c08b4bd97385e4fa79a0c770c"
1138 | uuid = "cae243ae-269e-4f55-b966-ac2d0dc13c15"
1139 | version = "0.1.1"
1140 |
1141 | [[deps.StaticArrays]]
1142 | deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"]
1143 | git-tree-sha1 = "b8d897fe7fa688e93aef573711cb207c08c9e11e"
1144 | uuid = "90137ffa-7385-5640-81b9-e52037218182"
1145 | version = "1.5.19"
1146 |
1147 | [[deps.StaticArraysCore]]
1148 | git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a"
1149 | uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
1150 | version = "1.4.0"
1151 |
1152 | [[deps.Statistics]]
1153 | deps = ["LinearAlgebra", "SparseArrays"]
1154 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1155 | version = "1.9.0"
1156 |
1157 | [[deps.StatsAPI]]
1158 | deps = ["LinearAlgebra"]
1159 | git-tree-sha1 = "f9af7f195fb13589dd2e2d57fdb401717d2eb1f6"
1160 | uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
1161 | version = "1.5.0"
1162 |
1163 | [[deps.StatsBase]]
1164 | deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
1165 | git-tree-sha1 = "d1bf48bfcc554a3761a133fe3a9bb01488e06916"
1166 | uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1167 | version = "0.33.21"
1168 |
1169 | [[deps.StatsFuns]]
1170 | deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
1171 | git-tree-sha1 = "f625d686d5a88bcd2b15cd81f18f98186fdc0c9a"
1172 | uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
1173 | version = "1.3.0"
1174 |
1175 | [deps.StatsFuns.extensions]
1176 | StatsFunsChainRulesCoreExt = "ChainRulesCore"
1177 | StatsFunsInverseFunctionsExt = "InverseFunctions"
1178 |
1179 | [deps.StatsFuns.weakdeps]
1180 | ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
1181 | InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
1182 |
1183 | [[deps.StructArrays]]
1184 | deps = ["Adapt", "DataAPI", "GPUArraysCore", "StaticArraysCore", "Tables"]
1185 | git-tree-sha1 = "521a0e828e98bb69042fec1809c1b5a680eb7389"
1186 | uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
1187 | version = "0.6.15"
1188 |
1189 | [[deps.SuiteSparse]]
1190 | deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]
1191 | uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
1192 |
1193 | [[deps.SuiteSparse_jll]]
1194 | deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"]
1195 | uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
1196 | version = "5.10.1+6"
1197 |
1198 | [[deps.TOML]]
1199 | deps = ["Dates"]
1200 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
1201 | version = "1.0.3"
1202 |
1203 | [[deps.TableTraits]]
1204 | deps = ["IteratorInterfaceExtensions"]
1205 | git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
1206 | uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
1207 | version = "1.0.1"
1208 |
1209 | [[deps.Tables]]
1210 | deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"]
1211 | git-tree-sha1 = "1544b926975372da01227b382066ab70e574a3ec"
1212 | uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
1213 | version = "1.10.1"
1214 |
1215 | [[deps.Tar]]
1216 | deps = ["ArgTools", "SHA"]
1217 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
1218 | version = "1.10.0"
1219 |
1220 | [[deps.TensorCore]]
1221 | deps = ["LinearAlgebra"]
1222 | git-tree-sha1 = "1feb45f88d133a655e001435632f019a9a1bcdb6"
1223 | uuid = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50"
1224 | version = "0.1.1"
1225 |
1226 | [[deps.Test]]
1227 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
1228 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1229 |
1230 | [[deps.TiffImages]]
1231 | deps = ["ColorTypes", "DataStructures", "DocStringExtensions", "FileIO", "FixedPointNumbers", "IndirectArrays", "Inflate", "Mmap", "OffsetArrays", "PkgVersion", "ProgressMeter", "UUIDs"]
1232 | git-tree-sha1 = "7e6b0e3e571be0b4dd4d2a9a3a83b65c04351ccc"
1233 | uuid = "731e570b-9d59-4bfa-96dc-6df516fadf69"
1234 | version = "0.6.3"
1235 |
1236 | [[deps.TimerOutputs]]
1237 | deps = ["ExprTools", "Printf"]
1238 | git-tree-sha1 = "f2fd3f288dfc6f507b0c3a2eb3bac009251e548b"
1239 | uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
1240 | version = "0.5.22"
1241 |
1242 | [[deps.TranscodingStreams]]
1243 | deps = ["Random", "Test"]
1244 | git-tree-sha1 = "94f38103c984f89cf77c402f2a68dbd870f8165f"
1245 | uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
1246 | version = "0.9.11"
1247 |
1248 | [[deps.TriplotBase]]
1249 | git-tree-sha1 = "4d4ed7f294cda19382ff7de4c137d24d16adc89b"
1250 | uuid = "981d1d27-644d-49a2-9326-4793e63143c3"
1251 | version = "0.1.0"
1252 |
1253 | [[deps.TupleTools]]
1254 | git-tree-sha1 = "3c712976c47707ff893cf6ba4354aa14db1d8938"
1255 | uuid = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
1256 | version = "1.3.0"
1257 |
1258 | [[deps.UUIDs]]
1259 | deps = ["Random", "SHA"]
1260 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1261 |
1262 | [[deps.Unicode]]
1263 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
1264 |
1265 | [[deps.UnicodeFun]]
1266 | deps = ["REPL"]
1267 | git-tree-sha1 = "53915e50200959667e78a92a418594b428dffddf"
1268 | uuid = "1cfade01-22cf-5700-b092-accc4b62d6e1"
1269 | version = "0.4.1"
1270 |
1271 | [[deps.UnsafeAtomics]]
1272 | git-tree-sha1 = "6331ac3440856ea1988316b46045303bef658278"
1273 | uuid = "013be700-e6cd-48c3-b4a1-df204f14c38f"
1274 | version = "0.2.1"
1275 |
1276 | [[deps.UnsafeAtomicsLLVM]]
1277 | deps = ["LLVM", "UnsafeAtomics"]
1278 | git-tree-sha1 = "33af9d2031d0dc09e2be9a0d4beefec4466def8e"
1279 | uuid = "d80eeb9a-aca5-4d75-85e5-170c8b632249"
1280 | version = "0.1.0"
1281 |
1282 | [[deps.WoodburyMatrices]]
1283 | deps = ["LinearAlgebra", "SparseArrays"]
1284 | git-tree-sha1 = "de67fa59e33ad156a590055375a30b23c40299d3"
1285 | uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
1286 | version = "0.5.5"
1287 |
1288 | [[deps.XML2_jll]]
1289 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"]
1290 | git-tree-sha1 = "93c41695bc1c08c46c5899f4fe06d6ead504bb73"
1291 | uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a"
1292 | version = "2.10.3+0"
1293 |
1294 | [[deps.XSLT_jll]]
1295 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "Pkg", "XML2_jll", "Zlib_jll"]
1296 | git-tree-sha1 = "91844873c4085240b95e795f692c4cec4d805f8a"
1297 | uuid = "aed1982a-8fda-507f-9586-7b0439959a61"
1298 | version = "1.1.34+0"
1299 |
1300 | [[deps.Xorg_libX11_jll]]
1301 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libxcb_jll", "Xorg_xtrans_jll"]
1302 | git-tree-sha1 = "5be649d550f3f4b95308bf0183b82e2582876527"
1303 | uuid = "4f6342f7-b3d2-589e-9d20-edeb45f2b2bc"
1304 | version = "1.6.9+4"
1305 |
1306 | [[deps.Xorg_libXau_jll]]
1307 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1308 | git-tree-sha1 = "4e490d5c960c314f33885790ed410ff3a94ce67e"
1309 | uuid = "0c0b7dd1-d40b-584c-a123-a41640f87eec"
1310 | version = "1.0.9+4"
1311 |
1312 | [[deps.Xorg_libXcursor_jll]]
1313 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libXfixes_jll", "Xorg_libXrender_jll"]
1314 | git-tree-sha1 = "12e0eb3bc634fa2080c1c37fccf56f7c22989afd"
1315 | uuid = "935fb764-8cf2-53bf-bb30-45bb1f8bf724"
1316 | version = "1.2.0+4"
1317 |
1318 | [[deps.Xorg_libXdmcp_jll]]
1319 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1320 | git-tree-sha1 = "4fe47bd2247248125c428978740e18a681372dd4"
1321 | uuid = "a3789734-cfe1-5b06-b2d0-1dd0d9d62d05"
1322 | version = "1.1.3+4"
1323 |
1324 | [[deps.Xorg_libXext_jll]]
1325 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll"]
1326 | git-tree-sha1 = "b7c0aa8c376b31e4852b360222848637f481f8c3"
1327 | uuid = "1082639a-0dae-5f34-9b06-72781eeb8cb3"
1328 | version = "1.3.4+4"
1329 |
1330 | [[deps.Xorg_libXfixes_jll]]
1331 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll"]
1332 | git-tree-sha1 = "0e0dc7431e7a0587559f9294aeec269471c991a4"
1333 | uuid = "d091e8ba-531a-589c-9de9-94069b037ed8"
1334 | version = "5.0.3+4"
1335 |
1336 | [[deps.Xorg_libXi_jll]]
1337 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libXext_jll", "Xorg_libXfixes_jll"]
1338 | git-tree-sha1 = "89b52bc2160aadc84d707093930ef0bffa641246"
1339 | uuid = "a51aa0fd-4e3c-5386-b890-e753decda492"
1340 | version = "1.7.10+4"
1341 |
1342 | [[deps.Xorg_libXinerama_jll]]
1343 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libXext_jll"]
1344 | git-tree-sha1 = "26be8b1c342929259317d8b9f7b53bf2bb73b123"
1345 | uuid = "d1454406-59df-5ea1-beac-c340f2130bc3"
1346 | version = "1.1.4+4"
1347 |
1348 | [[deps.Xorg_libXrandr_jll]]
1349 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll"]
1350 | git-tree-sha1 = "34cea83cb726fb58f325887bf0612c6b3fb17631"
1351 | uuid = "ec84b674-ba8e-5d96-8ba1-2a689ba10484"
1352 | version = "1.5.2+4"
1353 |
1354 | [[deps.Xorg_libXrender_jll]]
1355 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll"]
1356 | git-tree-sha1 = "19560f30fd49f4d4efbe7002a1037f8c43d43b96"
1357 | uuid = "ea2f1a96-1ddc-540d-b46f-429655e07cfa"
1358 | version = "0.9.10+4"
1359 |
1360 | [[deps.Xorg_libpthread_stubs_jll]]
1361 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1362 | git-tree-sha1 = "6783737e45d3c59a4a4c4091f5f88cdcf0908cbb"
1363 | uuid = "14d82f49-176c-5ed1-bb49-ad3f5cbd8c74"
1364 | version = "0.1.0+3"
1365 |
1366 | [[deps.Xorg_libxcb_jll]]
1367 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "XSLT_jll", "Xorg_libXau_jll", "Xorg_libXdmcp_jll", "Xorg_libpthread_stubs_jll"]
1368 | git-tree-sha1 = "daf17f441228e7a3833846cd048892861cff16d6"
1369 | uuid = "c7cfdc94-dc32-55de-ac96-5a1b8d977c5b"
1370 | version = "1.13.0+3"
1371 |
1372 | [[deps.Xorg_xtrans_jll]]
1373 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1374 | git-tree-sha1 = "79c31e7844f6ecf779705fbc12146eb190b7d845"
1375 | uuid = "c5fb5394-a638-5e4d-96e5-b29de1b5cf10"
1376 | version = "1.4.0+3"
1377 |
1378 | [[deps.Zlib_jll]]
1379 | deps = ["Libdl"]
1380 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
1381 | version = "1.2.13+0"
1382 |
1383 | [[deps.isoband_jll]]
1384 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1385 | git-tree-sha1 = "51b5eeb3f98367157a7a12a1fb0aa5328946c03c"
1386 | uuid = "9a68df92-36a6-505f-a73e-abb412b6bfb4"
1387 | version = "0.2.3+0"
1388 |
1389 | [[deps.libaom_jll]]
1390 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1391 | git-tree-sha1 = "3a2ea60308f0996d26f1e5354e10c24e9ef905d4"
1392 | uuid = "a4ae2306-e953-59d6-aa16-d00cac43593b"
1393 | version = "3.4.0+0"
1394 |
1395 | [[deps.libass_jll]]
1396 | deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
1397 | git-tree-sha1 = "5982a94fcba20f02f42ace44b9894ee2b140fe47"
1398 | uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0"
1399 | version = "0.15.1+0"
1400 |
1401 | [[deps.libblastrampoline_jll]]
1402 | deps = ["Artifacts", "Libdl"]
1403 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
1404 | version = "5.4.0+0"
1405 |
1406 | [[deps.libfdk_aac_jll]]
1407 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1408 | git-tree-sha1 = "daacc84a041563f965be61859a36e17c4e4fcd55"
1409 | uuid = "f638f0a6-7fb0-5443-88ba-1cc74229b280"
1410 | version = "2.0.2+0"
1411 |
1412 | [[deps.libpng_jll]]
1413 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
1414 | git-tree-sha1 = "94d180a6d2b5e55e447e2d27a29ed04fe79eb30c"
1415 | uuid = "b53b4c65-9356-5827-b1ea-8c7a1a84506f"
1416 | version = "1.6.38+0"
1417 |
1418 | [[deps.libsixel_jll]]
1419 | deps = ["Artifacts", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Pkg", "libpng_jll"]
1420 | git-tree-sha1 = "d4f63314c8aa1e48cd22aa0c17ed76cd1ae48c3c"
1421 | uuid = "075b6546-f08a-558a-be8f-8157d0f608a5"
1422 | version = "1.10.3+0"
1423 |
1424 | [[deps.libvorbis_jll]]
1425 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"]
1426 | git-tree-sha1 = "b910cb81ef3fe6e78bf6acee440bda86fd6ae00c"
1427 | uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a"
1428 | version = "1.3.7+1"
1429 |
1430 | [[deps.nghttp2_jll]]
1431 | deps = ["Artifacts", "Libdl"]
1432 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
1433 | version = "1.48.0+0"
1434 |
1435 | [[deps.p7zip_jll]]
1436 | deps = ["Artifacts", "Libdl"]
1437 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
1438 | version = "17.4.0+0"
1439 |
1440 | [[deps.x264_jll]]
1441 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1442 | git-tree-sha1 = "4fea590b89e6ec504593146bf8b988b2c00922b2"
1443 | uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a"
1444 | version = "2021.5.5+0"
1445 |
1446 | [[deps.x265_jll]]
1447 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1448 | git-tree-sha1 = "ee567a171cce03570d77ad3a43e90218e38937a9"
1449 | uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76"
1450 | version = "3.5.0+0"
1451 |
--------------------------------------------------------------------------------
/julia-packages/Project.toml:
--------------------------------------------------------------------------------
1 | [deps]
2 | CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
3 | DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
4 | GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
5 | LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
6 | Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
7 |
--------------------------------------------------------------------------------
/julia-packages/README.md:
--------------------------------------------------------------------------------
1 | # Essential Julia packages
2 | You may find trending Julia packages here: https://juliahub.com/ui/Packages
3 |
4 | ## Development
5 | 1. [PkgTemplates](https://github.com/JuliaCI/PkgTemplates.jl) `package development`, `continuous integration`
6 |
7 | Create new Julia packages, the easy way.
8 |
9 | ```julia
10 | julia> using PkgTemplates
11 |
12 | julia> tpl = Template(; user="GiggleLiu", plugins=[
13 | GitHubActions(; extra_versions=["nightly"]),
14 | Git(),
15 | Codecov(),
16 | Documenter{GitHubActions}(),
17 | ])
18 |
19 | julia> tpl("PkgName")
20 | ```
21 |
22 | 2. [Revise](https://github.com/timholy/Revise.jl) `package development`, `reload`
23 |
24 | `Revise.jl` allows you to modify code and use the changes without restarting Julia. With Revise, you can be in the middle of a session and then update packages, switch git branches, and/or edit the source code in the editor of your choice; any changes will typically be incorporated into the very next command you issue from the REPL. This can save you the overhead of restarting Julia, loading packages, and waiting for code to JIT-compile.
25 |
26 | ## High performance computing
27 | 1. [CUDA](https://github.com/JuliaGPU/CUDA.jl) `CUDA`, `kernels`
28 |
29 | The CUDA.jl package is the main programming interface for working with NVIDIA CUDA GPUs using Julia. It features a user-friendly array abstraction, a compiler for writing CUDA kernels in Julia, and wrappers for various CUDA libraries.
30 |
31 | Example: [cuda.jl](cuda.jl)
32 |
33 | 2. [LoopVectorization](https://github.com/JuliaSIMD/LoopVectorization.jl) `AVX`, `SIMD`, `CPU`, `speed`
34 |
35 | Macro(s) for vectorizing loops.
36 |
37 | 3. [StaticArrays](https://github.com/JuliaArrays/StaticArrays.jl) `small arrays`, `static`
38 |
39 | StaticArrays provides a framework for implementing statically sized arrays in Julia, using the abstract type StaticArray{Size,T,N} <: AbstractArray{T,N}. Subtypes of StaticArray will provide fast implementations of common array and linear algebra operations. Note that here "statically sized" means that the size can be determined from the type, and "static" does not necessarily imply immutable.
40 |
41 | ## Optimization
42 | 1. [Optim.jl](https://github.com/JuliaNLSolvers/Optim.jl) `optimize`, `LBFGS`, `Nelder-Mead`
43 |
44 | Univariate and multivariate optimization in Julia.
45 |
46 | Example: [optim.jl](optim.jl)
47 |
48 | 2. [JuMP](https://github.com/jump-dev/JuMP.jl) `mathematical optimization`, `fast`
49 |
50 | JuMP is a domain-specific modeling language for mathematical optimization embedded in Julia. You can find out more about us by visiting jump.dev.
51 |
52 | 3. [ForwradDiff](https://github.com/JuliaDiff/ForwardDiff.jl) and [Enzyme](https://github.com/EnzymeAD/Enzyme.jl) `autodiff`, `llvm`, `NIPS best paper`, `forward`, `reverse`
53 |
54 | Enzyme is a plugin that performs automatic differentiation (AD) of statically analyzable LLVM. It is highly-efficient and its ability perform AD on optimized code allows Enzyme to meet or exceed the performance of state-of-the-art AD tools.
55 |
56 |
57 | ## Linear Algebra
58 | 1. [ITensors](https://github.com/ITensor/ITensors.jl), [TensorOperations](https://github.com/Jutho/TensorOperations.jl) and [OMEinsum](https://github.com/under-Peter/OMEinsum.jl) `tensor`, `contraction`, `physics`
59 |
60 | * ITensor is a library for rapidly creating correct and efficient tensor network algorithms.
61 | * TensorOperations provides fast tensor operations using a convenient Einstein index notation.
62 | * This is a repository for the Google Summer of Code project on Differentiable Tensor Networks. It implements one function that both computer scientists and physicists love, the Einstein summation. It features large scale tensor network contraction.
63 |
64 | 2. [KrylovKit](https://github.com/Jutho/KrylovKit.jl) `sparse matrix`, `linear operator`, `eigen value problem`, `iterative solver`, `krylov space`
65 |
66 | A Julia package collecting a number of Krylov-based algorithms for linear problems, singular value and eigenvalue problems and the application of functions of linear maps or operators to vectors.
67 |
68 | 3. [ExponentialUtilities](https://github.com/SciML/ExponentialUtilities.jl) `expmv`, `krylov space`
69 |
70 | ExponentialUtilities is a package of utility functions for matrix functions of exponential type, including functionality for the matrix exponential and phi-functions. These methods are more numerically stable, generic (thus support a wider range of number types), and faster than the matrix exponentiation tools in Julia's Base. The tools are used by the exponential integrators in OrdinaryDiffEq. The package has no external dependencies, so it can also be used independently.
71 |
72 | ## Plotting
73 |
74 | 1. [Makie](https://github.com/MakieOrg/Makie.jl) `plot`, `gpu`
75 |
76 | Example: [makie.jl](cuda.jl)
77 |
78 |
79 | 2. [Luxor](https://github.com/JuliaGraphics/Luxor.jl)
80 |
81 | Luxor is a Julia package for drawing simple 2D vector graphics. Think of it as a high-level easier to use interface to Cairo.jl, with shorter names, fewer underscores, default contexts, and simplified functions. In Luxor, the emphasis is on simplicity and ease of use.
82 |
83 | 3. [UnicodePlots](https://github.com/JuliaPlots/UnicodePlots.jl)
84 | Advanced Unicode plotting library designed for use in Julia's REPL.
85 |
86 | ## Scientific Computing
87 | 1. [DifferetialEquations](https://github.com/SciML/DifferentialEquations.jl) `ODE`, `PDE`, `fast`
88 |
89 | This is a suite for numerically solving differential equations written in Julia and available for use in Julia, Python, and R. The purpose of this package is to supply efficient Julia implementations of solvers for various differential equations. Equations within the realm of this package include:
90 |
91 | * Discrete equations (function maps, discrete stochastic (Gillespie/Markov) simulations)
92 | * Ordinary differential equations (ODEs)
93 | * Split and Partitioned ODEs (Symplectic integrators, IMEX Methods)
94 | * Stochastic ordinary differential equations (SODEs or SDEs)
95 | * Stochastic differential-algebraic equations (SDAEs)
96 | * Random differential equations (RODEs or RDEs)
97 | * Differential algebraic equations (DAEs)
98 | * Delay differential equations (DDEs)
99 | * Neutral, retarded, and algebraic delay differential equations (NDDEs, RDDEs, and DDAEs)
100 | * Stochastic delay differential equations (SDDEs)
101 | * Experimental support for stochastic neutral, retarded, and algebraic delay differential equations (SNDDEs, SRDDEs, and SDDAEs)
102 | * Mixed discrete and continuous equations (Hybrid Equations, Jump Diffusions)
103 | * (Stochastic) partial differential equations ((S)PDEs) (with both finite difference and finite element methods)
104 |
105 | 2. [Yao](https://github.com/QuantumBFS/Yao.jl) `quantum`, `differentiable`, `fast`, `gpu`
106 |
107 | Yao is an open source framework that aims to empower quantum information research with software tools. It is designed with following in mind:
108 | * quantum algorithm design;
109 | * quantum software 2.0;
110 | * quantum computation education.
111 |
112 |
113 | ## FileIO
114 |
115 | 1. DelimitedFiles
116 |
117 | ```julia
118 | julia> using DelimitedFiles
119 |
120 | julia> x = randn(100, 100);julia> writedlm(x);
121 |
122 | julia> writedlm("_test.dat", x);
123 |
124 | julia> y = readdlm("_test.dat");
125 |
126 | julia> x ≈ y
127 | true
128 | ```
129 |
130 | 2. [JLD2](https://github.com/JuliaIO/JLD2.jl)
131 |
132 | JLD2 saves and loads Julia data structures in a format comprising a subset of HDF5, without any dependency on the HDF5 C library. JLD2 is able to read most HDF5 files created by other HDF5 implementations supporting HDF5 File Format Specification Version 3.0 (i.e. libhdf5 1.10 or later) and similarly those should be able to read the files that JLD2 produces. JLD2 provides read-only support for files created with the JLD package.
--------------------------------------------------------------------------------
/julia-packages/cuda.jl:
--------------------------------------------------------------------------------
1 | using CUDA, CUDA.GPUArrays
2 |
3 | function my_permutedims!(dest::AbstractGPUArray, src::AbstractGPUArray,
4 | perm::NTuple{N}) where N
5 | Base.checkdims_perm(dest, src, perm)
6 |
7 | # get the new strides of destination tensor
8 | dest_strides = ntuple(k->k==1 ? 1 : prod(i->size(dest, i), 1:k-1), N)
9 | dest_strides_perm = ntuple(i->dest_strides[findfirst(==(i), perm)], N)
10 |
11 | function permutedims_kernel(ctx, dest, src, dest_strides_perm)
12 | # find the cartesian index in source tensor
13 | LI = @linearidx src
14 | I = @inbounds CartesianIndices(src)[LI]
15 |
16 | # the corresponding linear index in the destination tensor
17 | dest_index = map_index(I.I, dest_strides_perm)
18 | @inbounds dest[dest_index] = src[LI]
19 | return
20 | end
21 | gpu_call(permutedims_kernel, dest, src, dest_strides_perm)
22 | return dest
23 | end
24 |
25 | # get linear index from cartesian indices and strides.
26 | @inline @generated function map_index(I::NTuple{N}, dest_strides::NTuple{N,T}) where {N,T}
27 | Expr(:call, :+, one(T), [:(@inbounds (I[$i]-1) * dest_strides[$i]) for i in 1:N]...)
28 | end
29 |
30 | using Test
31 | @testset "permutedims" begin
32 | a = randn(10, 10, 4, 6, 20)
33 | b = randn(20, 4, 6, 10, 10)
34 | c1 = my_permutedims!(CuArray(a), CuArray(b), (5, 4, 2, 3, 1))
35 | c2 = permutedims!(a, b, (5, 4, 2, 3, 1))
36 | @test c1 isa CuArray
37 | @test Array(c1) ≈ c2
38 | end
--------------------------------------------------------------------------------
/julia-packages/makie.jl:
--------------------------------------------------------------------------------
1 | using GLMakie, GLMakie.FileIO
2 | using LinearAlgebra: norm
3 | using DelimitedFiles
4 |
5 | f = Figure(resolution = (1400, 1000))
6 | a = readdlm(assetpath("airportlocations.csv")) # reduce this number if your GPU is not powerful enough
7 | n_points = 10_000_000
8 | a_rep = repeat(a, n_points ÷ size(a, 1), 1) .+ randn.()
9 | scatter(f[1, 1], a_rep, color = (:black, 0.01), markersize = 1.0,
10 | strokewidth = 0, axis = (title = "Airports (100 Million points)",
11 | limits = (-200, 200, -70, 80)))
12 |
13 | r = LinRange(-5, 5, 100)
14 | volume = [sin(x) + sin(y) + 0.1z^2 for x = r, y = r, z = r]
15 | ax, c = contour(f[2, 1][1, 1], volume, levels = 8, colormap = :viridis,
16 | axis = (type = Axis3, viewmode = :stretch, title = "3D contour"))
17 | Colorbar(f[2, 1][1, 2], c, label = "intensity")
18 |
19 | function mandelbrot(x, y)
20 | z = c = x + y*im
21 | for i in 1:30.0
22 | abs(z) > 2 && return i
23 | z = z^2 + c
24 | end
25 | 0
26 | end
27 | ax2, hm = heatmap(f[1:2, 2][1, 2], -2:0.005:1, -1.1:0.005:1.1, mandelbrot,
28 | colormap = Reverse(:deep), axis = (title = "Mandelbrot set",))
29 | hidedecorations!(ax2)
30 | Colorbar(f[1:2, 2][1, 1], hm, flipaxis = false,
31 | label = "Iterations", height = 300)
32 | Axis3(f[1:2, 2][2, 1:2], aspect = :data, title = "Brain mesh")
33 | brain = load(assetpath("brain.stl"))
34 | color = [-norm(x[1] .- Point(-40, 10, 45)) for x in brain for i in 1:3]
35 | mesh!(brain, color = color, colormap = :thermal)
36 | Label(f[0, :], "Makie.jl Example Figure")
37 | save("paper_example.png", f)
--------------------------------------------------------------------------------
/julia-packages/optim.jl:
--------------------------------------------------------------------------------
1 | using Optim, ForwardDiff
2 |
3 | f(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
4 | x0 = [0.0, 0.0]
5 |
6 | # gradient free optimizers
7 | optimize(f, x0, NelderMead())
8 |
9 | # gradient based optimizers
10 | function g(x)
11 | return ForwardDiff.gradient(f, x)
12 | end
13 | optimize(f, g, x0, LBFGS(); inplace = false)
--------------------------------------------------------------------------------
/julia/1.julia-setup.md:
--------------------------------------------------------------------------------
1 | ## Setup Julia development environment in mainland China
2 |
3 | ### Step 1: Installing Julia
4 | For Linux/Mac users, please open a terminal and type the following command to install [Julia](https://julialang.org/) with [juliaup](https://github.com/JuliaLang/juliaup). `Juliaup` is a tool to manage Julia versions and installations. It allows you to install multiple versions of Julia and switch between them easily.
5 |
6 | ```Bash
7 | curl -fsSL https://install.julialang.org | sh # Linux and macOS
8 | ```
9 |
10 | For Windows users, please open execute the following command in a `cmd`,
11 | ```PowerShell
12 | winget install julia -s msstore # Windows
13 | ```
14 | You can also install Juliaup directly from [Windows Store](https://www.microsoft.com/store/apps/9NJNWW8PVKMN).
15 |
16 |
17 | #### For users suffering from the slow download speed
18 |
19 | You may need to specify another server for installing Juliaup. To do so, execute the following command in your terminal before running the script above.
20 |
21 | **Linux and macOS**
22 | ```bash
23 | export JULIAUP_SERVER=https://mirror.nju.edu.cn/julia-releases/ # Linux & macOS
24 | ```
25 | **Windows**
26 | ```PowerShell
27 | $env:JULIAUP_SERVER="https://mirror.nju.edu.cn/julia-releases/" # Windows
28 | ```
29 | An alternative approach is downloading the corresponding Julia binary from the [Nanjing university mirror website](https://mirror.nju.edu.cn/julia-releases/).
30 | After installing the binary, please set the Julia binary path properly if you want to start a Julia REPL from a terminal, check this [manual page](https://julialang.org/downloads/platform/) to learn more.
31 |
32 |
33 | #### Installing Julia
34 | To verify that Julia is installed, run the following command in your terminal.
35 | ```bash
36 | julia
37 | ```
38 | - It should start a Julia REPL(Read-Eval-Print-Loop) session like this
39 | 
40 | - If you wish to install a specific version of Julia, please refer to the [documentation](https://github.com/JuliaLang/juliaup).
41 |
42 | ### Step 2: Package Management
43 | - `Julia` has a mature eco-system for scientific computing.
44 | - `Pkg` is the built-in package manager for Julia.
45 | - To enter the package manager, press `]` in the REPL.
46 | 
47 | - The environment is indicated by the `(@v1.9)`.
48 | - To add a package, type `add `.
49 | - To exit the package manager press `backspace` key
50 | - [Read More](https://pkgdocs.julialang.org/v1/managing-packages/)
51 |
52 | ### Step 3. Configure the startup file and add `Revise`
53 | First create a new file `~/.julia/config/startup.jl` by executing the following commands
54 |
55 | `mkdir -r ~/.julia/config`
56 | `touch ~/.julia/config/startup.jl`
57 |
58 | You could open the file with your favourite editor and add the following content
59 | ```julia
60 | ENV["JULIA_PKG_SERVER"] = "http://cn-southeast.pkg.juliacn.com/"
61 | try
62 | using Revise
63 | catch e
64 | @warn "fail to load Revise."
65 | end
66 | ```
67 |
68 | The contents in the startup file is executed immediately after you open a new Julia session.
69 |
70 | Then you need to install [Revise](https://github.com/timholy/Revise.jl), which is an Julia package that can greatly improve the using experience of Julia. To install `Revise`, open Julia REPL and type
71 | ```julia
72 | julia> using Pkg; Pkg.add("Revise")
73 | ```
74 |
75 | If you don't know about `startup.jl` and where to find it, [here](https://docs.julialang.org/en/v1/manual/command-line-interface/#Startup-file) is a good place for further information. Windows users can find their Julia config file in `JULIA_INSTALL_FOLDER\etc\julia\startup.jl`
76 |
77 | #### More Packages
78 | - You may find more Julia packages [here](https://juliahub.com/).
79 |
80 |
81 | As a final step, please verify your Julia configuration by openning a Julia REPL and type
82 | ```julia
83 | julia> versioninfo()
84 | Julia Version 1.9.2
85 | Commit e4ee485e909 (2023-07-05 09:39 UTC)
86 | Platform Info:
87 | OS: macOS (arm64-apple-darwin22.4.0)
88 | CPU: 10 × Apple M2 Pro
89 | WORD_SIZE: 64
90 | LIBM: libopenlibm
91 | LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
92 | Threads: 1 on 6 virtual cores
93 | Environment:
94 | JULIA_NUM_THREADS = 1
95 | JULIA_PROJECT = @.
96 | JULIA_PKG_SERVER = http://cn-southeast.pkg.juliacn.com/
97 | ```
98 |
99 | #### Step 3. Download an editor: VSCode
100 |
101 | Install VSCode by downloading the correct binary for your platform from [here](https://code.visualstudio.com/download).
102 | Open VSCode and open the `Extensions` tab on the left side-bar of the window, search `Julia` and install the most popular extension.
103 | [read more...](https://github.com/julia-vscode/julia-vscode)
104 | 
105 |
106 | You are ready to go, cheers!
107 |
108 | ### A quick introduction to the Julia REPL
109 |
110 | A Julia REPL has four modes,
111 |
112 | 1. Julian mode is the default mode that can interpret your Julia code.
113 |
114 | 2. Shell mode is the mode that you can run shell commands. Press `;` in the Julian mode and type
115 | ```julia
116 | shell> date
117 | Sun Nov 6 10:50:21 PM CST 2022
118 | ```
119 | To return to the Julian mode, type the Backspace key.
120 |
121 | 3. Package mode is the mode that you can manage packages. Press `]` in the Julian mode and type
122 | ```julia
123 | (@v1.8) pkg> st
124 | Status `~/.julia/environments/v1.8/Project.toml`
125 | [295af30f] Revise v3.4.0
126 | ```
127 | To return to the Julian mode, type the Backspace key.
128 |
129 | 4. Help mode is the mode that you can access the docstrings of functions. Press `?` in the Julian mode and type
130 | ```julia
131 | help> sum
132 | ... docstring for sum ...
133 | ```
134 | To return to the Julian mode, type the Backspace key.
135 |
136 | [read more...](https://docs.julialang.org/en/v1/stdlib/REPL/)
137 |
--------------------------------------------------------------------------------
/julia/2.first-package.md:
--------------------------------------------------------------------------------
1 | # Packages and projects
2 |
3 | Julia packages are scattered on Github, e.g. the package `Yao` is in a Github repo [Yao.jl](https://github.com/QuantumBFS/Yao.jl).
4 | To locate these packages, Julia uses the a special Github repository as the registry of packages.
5 | The default one is called `General` registry.
6 |
7 | ```julia
8 | (@v1.8) pkg> registry status
9 | Registry Status
10 | [23338594] General (https://github.com/JuliaRegistries/General.git)
11 | ```
12 |
13 | Each package has a special file called `Project.toml` in the top level folder, which includes the dependency information.
14 | When you install a package, Julia resolves this dependency tree and install the dependencies and generate the `Manifest.toml` file.
15 |
16 | [read more...]()
17 |
18 | ## Create and release your first package
19 |
20 | ### 1. Create a package using `PkgTemplates`
21 | It is recommended to start a new Julia project as a Julia package so that the dependency can be resolved properly.
22 | It is very simple to create a new Julia package with [PkgTemplates](https://github.com/JuliaCI/PkgTemplates.jl).
23 | A minimum example is as follows.
24 |
25 | ```julia
26 | pkg> add PkgTemplates
27 |
28 | julia> using PkgTemplates
29 |
30 | julia> tpl = Template(; user="MyGithubUserOrOrg", plugins=[
31 | GitHubActions(; extra_versions=["nightly"]),
32 | Git(),
33 | Codecov(),
34 | Documenter{GitHubActions}(),
35 | ])
36 |
37 | julia> tpl("Demo")
38 | ```
39 |
40 | A fresh new project will be generate in folder `~/.julia/dev/Demo` (or `%HOME%/.julia/dev/Demo` for Windows users). The file structure of this project is
41 | ```zsh
42 | (base) ➜ Demo git:(main) tree .
43 | .
44 | ├── docs
45 | │ ├── make.jl # The make file for the documents
46 | │ ├── Manifest.toml # The resolved dependency for the `docs` environment
47 | │ ├── Project.toml # The dependency specification for the `docs` environment
48 | │ └── src
49 | │ └── index.md # The document home page
50 | ├── .github
51 | │ └── workflows # Files in this folder specify jobs run by Github Action automatically.
52 | │ ├── CI.yml # Run tests and calculate the test coverage
53 | │ ├── CompatHelper.yml # Help your package dependency up to date by creating a pull request.
54 | │ └── TagBot.yml # Auto-tag a version after registering a new version in a Julia registry.
55 | ├── .gitignore # Ignored files will not be considered a part of the `git` repo.
56 | ├── LICENSE # MIT license by default
57 | ├── Manifest.toml # The resolved dependency
58 | ├── Project.toml # The package name, UUID and dependencies
59 | ├── README.md # README in markdown format
60 | ├── src # The folder for Julia source code
61 | │ └── Demo.jl # The main file for the `Demo` module
62 | └── test # The folder for Julia test code
63 | └── runtests.jl # The main file for testing.
64 | ```
65 | References
66 |
67 | * [Github Action](https://docs.github.com/en/actions)
68 |
69 | Some extra steps are required,
70 |
71 | * Setup the Github pages,
72 | * Connect your repo with [CodeCov](https://about.codecov.io/) correctly.
73 |
74 | ### 2. Create a Github repo
75 | The github repo name should be the same as your Julia package name.
76 | In our example, it is `Demo.jl`. Push your local files to the remote.
77 |
78 | ### 3. Develop and manage your package dependency
79 |
80 | ### 4. Release your package
81 | You can offically release this package to make it accessible to the public by registering your package in Julia's [General registry](https://github.com/JuliaRegistries/General).
82 | You may find an instruction about how to register a package in the github repo [Registrator.jl](https://github.com/JuliaRegistries/Registrator.jl).
83 | After a 3 days review procedure, your package will be installable in the Pkg mode.
84 |
85 | ### How to contribute to a package
86 |
87 | Fork a package,
88 |
89 | ```julia
90 | pkg> dev
91 | ```
92 |
93 |
94 | Explain package management.
95 | Local and global environment
96 |
97 | Remove access.
98 |
99 | How to create a package, specify project.toml
100 |
--------------------------------------------------------------------------------
/julia/3.basic-grammar.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingThrust/CodingClub/d6acc0c44858c5a2c0f6d0b81beaa2e85144a91c/julia/3.basic-grammar.md
--------------------------------------------------------------------------------
/julia/linear-algebra.md:
--------------------------------------------------------------------------------
1 | # Linear Algebra
2 |
3 | ## Setup BLAS backend and multi-threading
4 | ```julia
5 | julia> using LinearAlgebra
6 |
7 | julia> BLAS.get_config()
8 | LinearAlgebra.BLAS.LBTConfig
9 | Libraries:
10 | └ [ILP64] libopenblas64_.so
11 |
12 | julia> BLAS.get_num_threads()
13 | 4
14 | ```
15 |
16 | If you want to switch to MKL, please type
17 | ```julia
18 | julia> using Pkg; Pkg.add("MKL")
19 |
20 | julia> using LinearAlgebra, MKL
21 |
22 | julia> BLAS.get_config()
23 | LinearAlgebra.BLAS.LBTConfig
24 | Libraries:
25 | └ [ILP64] libmkl_rt.1.dylib
26 | ```
27 |
28 | [read more...](https://github.com/JuliaLinearAlgebra/MKL.jl)
29 |
30 | Input unicode characters
31 | https://docs.julialang.org/en/v1/manual/unicode-input/
32 |
--------------------------------------------------------------------------------
/mpi/.gitignore:
--------------------------------------------------------------------------------
1 | *.err
2 | *.out
3 |
--------------------------------------------------------------------------------
/mpi/LocalPreferences.toml:
--------------------------------------------------------------------------------
1 | [MPIPreferences]
2 | _format = "1.0"
3 | abi = "OpenMPI"
4 | binary = "system"
5 | libmpi = "libmpi"
6 | mpiexec = "mpiexec"
7 |
--------------------------------------------------------------------------------
/mpi/Manifest.toml:
--------------------------------------------------------------------------------
1 | # This file is machine-generated - editing it directly is not advised
2 |
3 | julia_version = "1.9.0"
4 | manifest_format = "2.0"
5 | project_hash = "74a6e625983937d7da55b3762da71de816c3ebfa"
6 |
7 | [[deps.ArgTools]]
8 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
9 | version = "1.1.1"
10 |
11 | [[deps.Artifacts]]
12 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
13 |
14 | [[deps.Base64]]
15 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
16 |
17 | [[deps.CompilerSupportLibraries_jll]]
18 | deps = ["Artifacts", "Libdl"]
19 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
20 | version = "1.0.2+0"
21 |
22 | [[deps.Dates]]
23 | deps = ["Printf"]
24 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
25 |
26 | [[deps.Distributed]]
27 | deps = ["Random", "Serialization", "Sockets"]
28 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
29 |
30 | [[deps.DocStringExtensions]]
31 | deps = ["LibGit2"]
32 | git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d"
33 | uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
34 | version = "0.9.3"
35 |
36 | [[deps.Downloads]]
37 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
38 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
39 | version = "1.6.0"
40 |
41 | [[deps.FileWatching]]
42 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
43 |
44 | [[deps.InteractiveUtils]]
45 | deps = ["Markdown"]
46 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
47 |
48 | [[deps.JLLWrappers]]
49 | deps = ["Preferences"]
50 | git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1"
51 | uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
52 | version = "1.4.1"
53 |
54 | [[deps.LazyArtifacts]]
55 | deps = ["Artifacts", "Pkg"]
56 | uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
57 |
58 | [[deps.LibCURL]]
59 | deps = ["LibCURL_jll", "MozillaCACerts_jll"]
60 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
61 | version = "0.6.3"
62 |
63 | [[deps.LibCURL_jll]]
64 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
65 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
66 | version = "7.84.0+0"
67 |
68 | [[deps.LibGit2]]
69 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
70 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
71 |
72 | [[deps.LibSSH2_jll]]
73 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
74 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
75 | version = "1.10.2+0"
76 |
77 | [[deps.Libdl]]
78 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
79 |
80 | [[deps.Logging]]
81 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
82 |
83 | [[deps.MPI]]
84 | deps = ["Distributed", "DocStringExtensions", "Libdl", "MPICH_jll", "MPIPreferences", "MPItrampoline_jll", "MicrosoftMPI_jll", "OpenMPI_jll", "PrecompileTools", "Requires", "Serialization", "Sockets"]
85 | git-tree-sha1 = "cef80bd5aad97224a3937596066c21a37dca3990"
86 | uuid = "da04e1cc-30fd-572f-bb4f-1f8673147195"
87 | version = "0.20.9"
88 |
89 | [deps.MPI.extensions]
90 | AMDGPUExt = "AMDGPU"
91 | CUDAExt = "CUDA"
92 |
93 | [deps.MPI.weakdeps]
94 | AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
95 | CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
96 |
97 | [[deps.MPICH_jll]]
98 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"]
99 | git-tree-sha1 = "d790fbd913f85e8865c55bf4725aff197c5155c8"
100 | uuid = "7cb0a576-ebde-5e09-9194-50597f1243b4"
101 | version = "4.1.1+1"
102 |
103 | [[deps.MPIPreferences]]
104 | deps = ["Libdl", "Preferences"]
105 | git-tree-sha1 = "71f937129731a29eabe6969db2c90368a4408933"
106 | uuid = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
107 | version = "0.1.7"
108 |
109 | [[deps.MPItrampoline_jll]]
110 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"]
111 | git-tree-sha1 = "b3dcf8e1c610a10458df3c62038c8cc3a4d6291d"
112 | uuid = "f1f71cc9-e9ae-5b93-9b94-4fe0e1ad3748"
113 | version = "5.3.0+0"
114 |
115 | [[deps.Markdown]]
116 | deps = ["Base64"]
117 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
118 |
119 | [[deps.MbedTLS_jll]]
120 | deps = ["Artifacts", "Libdl"]
121 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
122 | version = "2.28.2+0"
123 |
124 | [[deps.MicrosoftMPI_jll]]
125 | deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
126 | git-tree-sha1 = "a8027af3d1743b3bfae34e54872359fdebb31422"
127 | uuid = "9237b28f-5490-5468-be7b-bb81f5f5e6cf"
128 | version = "10.1.3+4"
129 |
130 | [[deps.MozillaCACerts_jll]]
131 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
132 | version = "2022.10.11"
133 |
134 | [[deps.NetworkOptions]]
135 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
136 | version = "1.2.0"
137 |
138 | [[deps.OpenMPI_jll]]
139 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"]
140 | git-tree-sha1 = "f3080f4212a8ba2ceb10a34b938601b862094314"
141 | uuid = "fe0851c0-eecd-5654-98d4-656369965a5c"
142 | version = "4.1.5+0"
143 |
144 | [[deps.Pkg]]
145 | deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
146 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
147 | version = "1.9.0"
148 |
149 | [[deps.PrecompileTools]]
150 | deps = ["Preferences"]
151 | git-tree-sha1 = "259e206946c293698122f63e2b513a7c99a244e8"
152 | uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
153 | version = "1.1.1"
154 |
155 | [[deps.Preferences]]
156 | deps = ["TOML"]
157 | git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1"
158 | uuid = "21216c6a-2e73-6563-6e65-726566657250"
159 | version = "1.4.0"
160 |
161 | [[deps.Printf]]
162 | deps = ["Unicode"]
163 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
164 |
165 | [[deps.REPL]]
166 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
167 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
168 |
169 | [[deps.Random]]
170 | deps = ["SHA", "Serialization"]
171 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
172 |
173 | [[deps.Requires]]
174 | deps = ["UUIDs"]
175 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
176 | uuid = "ae029012-a4dd-5104-9daa-d747884805df"
177 | version = "1.3.0"
178 |
179 | [[deps.SHA]]
180 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
181 | version = "0.7.0"
182 |
183 | [[deps.Serialization]]
184 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
185 |
186 | [[deps.Sockets]]
187 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
188 |
189 | [[deps.TOML]]
190 | deps = ["Dates"]
191 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
192 | version = "1.0.3"
193 |
194 | [[deps.Tar]]
195 | deps = ["ArgTools", "SHA"]
196 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
197 | version = "1.10.0"
198 |
199 | [[deps.UUIDs]]
200 | deps = ["Random", "SHA"]
201 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
202 |
203 | [[deps.Unicode]]
204 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
205 |
206 | [[deps.Zlib_jll]]
207 | deps = ["Libdl"]
208 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
209 | version = "1.2.13+0"
210 |
211 | [[deps.nghttp2_jll]]
212 | deps = ["Artifacts", "Libdl"]
213 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
214 | version = "1.48.0+0"
215 |
216 | [[deps.p7zip_jll]]
217 | deps = ["Artifacts", "Libdl"]
218 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
219 | version = "17.4.0+0"
220 |
--------------------------------------------------------------------------------
/mpi/Project.toml:
--------------------------------------------------------------------------------
1 | [deps]
2 | MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
3 | MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
4 |
--------------------------------------------------------------------------------
/mpi/README.md:
--------------------------------------------------------------------------------
1 | # Message Passing Interface (MPI)
2 | ## Mindset
3 | Multi-Universe model: all processors run exactly the same program without sharing memories. Without communication, they will end up with returning the same result.
4 | Then, we introduce a web-based oracle object `MPI.COMM_WORLD`. When a processor queries that object with the `Get_rank()` function, that object returns a number that corresponds to the processor ID.
5 | ## Watch YouTube Video
6 | * [MPI Basic](https://youtu.be/c0C9mQaxsD4)
7 | * [MPI Advancd](https://youtu.be/q9OfXis50Rg)
8 | ## List of packages
9 | 1. Python: [mpi4py](https://mpi4py.readthedocs.io/en/stable/)
10 | 2. Julia: [MPI.jl](https://juliaparallel.org/MPI.jl/dev/)
11 | 3. Backends: [MPICH](https://www.mpich.org/), [OpenMPI](https://www.open-mpi.org/), Intel MPI et al.
12 |
13 | ## Coding example: Distributed hello-world with MPI.jl
14 | We are working in the Julia project folder, using the project's [local environment](https://pkgdocs.julialang.org/v1/environments/)
15 |
16 | 1. Add `MPI.jl` to your project dependencies.
17 | ```julia
18 | julia> using Pkg; Pkg.activate("."); Pkg.add("MPI")
19 | ```
20 |
21 | 2. Configure the MPI backend ([doc](https://juliaparallel.org/MPI.jl/dev/configuration/))
22 | ```julia
23 | julia> using Pkg; Pkg.add("MPIPreferences");
24 |
25 | julia> using MPIPreferences; MPIPreferences.use_system_binary()
26 | ```
27 | You will see a [LocalPreferences.toml](LocalPreferences.toml) in your working folder.
28 |
29 | 3. You need to build the MPI package again for the new MPI backend.
30 | ```bash
31 | julia --project -e 'using Pkg; Pkg.build("MPI")'
32 | ```
33 |
34 | 4. You may test the program with
35 | ```bash
36 | mpiexec -n 3 julia --project mpi.jl
37 | ```
38 |
39 | ## Another example
40 | Go through this example: https://juliaparallel.org/MPI.jl/dev/examples/06-scatterv/
41 |
42 | ## Using school cluster.
43 | 1. Please check the tested [LSF script](julia-helloworld-lsf.job). This script can be executed on a cluster with
44 | ```bash
45 | bsub < julia-helloworld-lsf.job
46 | ```
47 |
48 | 2. The [slurm script](julia-helloworld-slurm.slurm) is not tested. It can be executed on a cluster with
49 | ```bash
50 | sbatch < julia-helloworld-slurm.slurm
51 | ```
52 |
--------------------------------------------------------------------------------
/mpi/julia-helloworld-lsf.job:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ############## SLURM SETUP ###############
4 | #BSUB -W 10:00
5 | #BSUB -n 4
6 | #BSUB -R "span[ptile=2]"
7 | #BSUB -e $PWD/%J.err
8 | #BSUB -o $PWD/%J.out
9 |
10 | ############## MODULE LOADING ###############
11 | # Clear the environment from any previously loaded modules
12 | # module purge > /dev/null 2>&1
13 | # Show available modules with module avail
14 | module load openmpi
15 |
16 | ############## RUN ######################
17 | /usr/mpi/gcc/openmpi-4.1.2a1/bin/mpirun $HOME/.local/bin/julia --project=$PWD mpi.jl
18 |
--------------------------------------------------------------------------------
/mpi/julia-helloworld-slurm.slurm:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ############## SLURM SETUP ###############
4 | #SBATCH --job-name=mpi_job
5 | #SBATCH --ntasks=128
6 | # less than 10 hours
7 | #SBATCH --time=10:00:00
8 | #SBATCH --output=log.%j
9 |
10 | ############## MODULE LOADING ###############
11 | # Clear the environment from any previously loaded modules
12 | # module purge > /dev/null 2>&1
13 | # Show available modules with module avail
14 | module load mpi/openmpi-4.1.5
15 |
16 | ############## RUN ######################
17 | export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
18 | mpirun $HOME/.juliaup/bin/julia --project=$PWD mpi.jl
19 |
--------------------------------------------------------------------------------
/mpi/mpi.jl:
--------------------------------------------------------------------------------
1 | # examples/06-scatterv.jl
2 | # This example shows how to use MPI.Scatterv! and MPI.Gatherv!
3 | # roughly based on the example from
4 | # https://stackoverflow.com/a/36082684/392585
5 | # source: https://juliaparallel.org/MPI.jl/dev/examples/06-scatterv/
6 |
7 | using MPI
8 |
9 | # initialize global variables
10 | MPI.Init()
11 |
12 | comm = MPI.COMM_WORLD
13 |
14 | # get the id for the current processor
15 | rank = MPI.Comm_rank(comm)
16 |
17 | # total number of processors
18 | comm_size = MPI.Comm_size(comm)
19 |
20 | print("Hello world, I am rank $(MPI.Comm_rank(comm)) of $(MPI.Comm_size(comm))\n")
21 |
22 | MPI.Barrier(comm)
23 |
24 | # root = 0
25 |
26 | # if rank == root
27 | # M, N = 4, 7
28 |
29 | # test = Float64[i for i = 1:M, j = 1:N]
30 | # output = similar(test)
31 |
32 | # # Julia arrays are stored in column-major order, so we need to split along the last dimension
33 | # # dimension
34 | # M_counts = [M for i = 1:comm_size]
35 | # N_counts = split_count(N, comm_size)
36 |
37 | # # store sizes in 2 * comm_size Array
38 | # sizes = vcat(M_counts', N_counts')
39 | # size_ubuf = UBuffer(sizes, 2)
40 |
41 | # # store number of values to send to each rank in comm_size length Vector
42 | # counts = vec(prod(sizes, dims=1))
43 |
44 | # test_vbuf = VBuffer(test, counts) # VBuffer for scatter
45 | # output_vbuf = VBuffer(output, counts) # VBuffer for gather
46 | # else
47 | # # these variables can be set to `nothing` on non-root processes
48 | # size_ubuf = UBuffer(nothing)
49 | # output_vbuf = test_vbuf = VBuffer(nothing)
50 | # end
51 |
52 | # if rank == root
53 | # println("Original matrix")
54 | # println("================")
55 | # @show test sizes counts
56 | # println()
57 | # println("Each rank")
58 | # println("================")
59 | # end
60 | # MPI.Barrier(comm)
61 |
62 | # local_size = MPI.Scatter(size_ubuf, NTuple{2,Int}, root, comm)
63 | # local_test = MPI.Scatterv!(test_vbuf, zeros(Float64, local_size), root, comm)
64 |
65 | # for i = 0:comm_size-1
66 | # if rank == i
67 | # @show rank local_test
68 | # end
69 | # MPI.Barrier(comm)
70 | # end
71 |
72 | # MPI.Gatherv!(local_test, output_vbuf, root, comm)
73 |
74 | # if rank == root
75 | # println()
76 | # println("Final matrix")
77 | # println("================")
78 | # @show output
79 | # end
--------------------------------------------------------------------------------
/prompt/prompt.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingThrust/CodingClub/d6acc0c44858c5a2c0f6d0b81beaa2e85144a91c/prompt/prompt.pdf
--------------------------------------------------------------------------------
/simulated-annealing/README.md:
--------------------------------------------------------------------------------
1 | # Solving the spin-glass problem with simulated annealing
2 |
3 | ### Get started
4 |
5 | This tutorial is contained in the Pluto notebook file: [notebook.jl](notebook.jl) [[pdf](notebook.pdf)].
6 | You can open it with [Pluto](https://github.com/fonsp/Pluto.jl).
7 |
8 | ## The SSSS-Challenge
9 | [Github repo](https://github.com/QuantumBFS/SSSS)
10 |
11 | The challenge description could be found in the challenge section of the README of SSSS. Where submissions are also available.
12 |
--------------------------------------------------------------------------------
/simulated-annealing/example.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingThrust/CodingClub/d6acc0c44858c5a2c0f6d0b81beaa2e85144a91c/simulated-annealing/example.txt
--------------------------------------------------------------------------------
/simulated-annealing/notebook.jl:
--------------------------------------------------------------------------------
1 | ### A Pluto.jl notebook ###
2 | # v0.19.19
3 |
4 | using Markdown
5 | using InteractiveUtils
6 |
7 | # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
8 | macro bind(def, element)
9 | quote
10 | local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
11 | local el = $(esc(element))
12 | global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
13 | el
14 | end
15 | end
16 |
17 | # ╔═╡ 2ec32c9d-0216-48a8-848d-79f7cc84798e
18 | using DelimitedFiles, Test, BenchmarkTools, Statistics
19 |
20 | # ╔═╡ 701dfc92-4891-477b-9e15-8083f8ca5531
21 | begin
22 | using PlutoUI
23 |
24 | struct BondWrapper
25 | content
26 | end
27 |
28 | function Base.show(io::IO, mime::MIME"text/html", b::BondWrapper)
29 | print(io,
30 | """$(b.content.defines) =
""")
31 | Base.show(io, mime, b.content)
32 | end
33 |
34 | #macro xbind(args...)
35 | # esc(quote
36 | # let
37 | # bond = @bind $(args...)
38 | # $BondWrapper(bond)
39 | # end
40 | # end)
41 | #end
42 | end;
43 |
44 | # ╔═╡ 0b0e674d-688d-491d-8a51-36334ad40b1a
45 | using Random
46 |
47 | # ╔═╡ 8c702004-0534-43cb-b92c-1b494a1145b3
48 | using Profile
49 |
50 | # ╔═╡ c96ce06a-bd6a-419c-8c77-cc76ea0f8593
51 | # pip install viznet, matplotlib
52 | using PythonCall, CondaPkg
53 |
54 | # ╔═╡ 0c3000cf-46d3-4481-9d6d-61980443dd93
55 | """General Annealing Problem"""
56 | abstract type AnnealingProblem end
57 |
58 | # ╔═╡ 9ec34d03-e9e6-460c-bc8b-39b70b6b8a37
59 | """
60 | SpinAnnealingProblem{T<:Real} <: AnnealingProblem
61 |
62 | Annealing problem defined by coupling matrix of spins.
63 | """
64 | struct SpinAnnealingProblem{T<:Real} <: AnnealingProblem # immutable, with type parameter T (a subtype of Real).
65 | num_spin::Int
66 | coupling::Matrix{T}
67 | function SpinAnnealingProblem(coupling::Matrix{T}) where T
68 | size(coupling, 1) == size(coupling, 2) || throw(DimensionMismatch("input must be square matrix."))
69 | new{T}(size(coupling, 1), coupling)
70 | end
71 | end
72 |
73 | # ╔═╡ a7e70b41-9184-4127-b66f-dfc03b8b3004
74 | """
75 | load_coupling(filename::String) -> SpinAnnealingProblem
76 |
77 | Load the data file into symmtric coupling matrix.
78 | """
79 | function load_coupling(filename::String)
80 | data = readdlm(filename)
81 | is = Int.(view(data, :, 1)) .+ 1 #! @. means broadcast for the following functions, is here used correctly?
82 | js = Int.(view(data, :, 2)) .+ 1
83 | weights = data[:,3]
84 | num_spin = max(maximum(is), maximum(js))
85 | J = zeros(eltype(weights), num_spin, num_spin)
86 | @inbounds for (i, j, weight) = zip(is, js, weights)
87 | J[i,j] = weight/2
88 | J[j,i] = weight/2
89 | end
90 | SpinAnnealingProblem(J)
91 | end
92 |
93 | # ╔═╡ 35b7dcfe-717f-48b0-bd4f-4c72f880a229
94 | @testset "loading" begin
95 | sap = load_coupling("programs/example.txt")
96 | @test size(sap.coupling) == (300, 300)
97 | end
98 |
99 | # ╔═╡ 6cc6e9a2-4409-4ad1-b8d1-be0826fe9592
100 | abstract type AnnealingConfig end
101 |
102 | # ╔═╡ a2a174b8-28d0-461f-97c6-8364ccada6c4
103 | struct SpinConfig{Ts, Tf} <: AnnealingConfig
104 | config::Vector{Ts}
105 | field::Vector{Tf}
106 | end
107 |
108 | # ╔═╡ f1c1eae7-102f-4ca3-9fd2-d81529ada0a3
109 | """
110 | random_config(prblm::AnnealingProblem) -> SpinConfig
111 |
112 | Random spin configuration.
113 | """
114 | function random_config end # where to put the docstring of a multiple-dispatch function is a problem. Using `abstract function` is proper.
115 |
116 | # ╔═╡ caa805be-6c98-4b59-8404-c0db284c58e9
117 | function random_config(prblm::SpinAnnealingProblem)
118 | config = rand([-1,1], prblm.num_spin)
119 | SpinConfig(config, prblm.coupling*config)
120 | end
121 |
122 | # ╔═╡ e692876e-72eb-4a19-a0b9-367ab3e84783
123 | @testset "random config" begin
124 | sap = load_coupling("programs/example.txt")
125 | initial_config = random_config(sap)
126 | @test initial_config.config |> length == 300
127 | @test eltype(initial_config.config) == Int
128 | end
129 |
130 | # ╔═╡ 0d37406b-f16a-4b91-a138-ee59a92e2ca4
131 | md"## Main program"
132 |
133 | # ╔═╡ 6116801e-e6a8-4e75-9e04-6c07e4a17305
134 | """
135 | get_cost(config::AnnealingConfig, ap::AnnealingProblem) -> Real
136 |
137 | Get the cost of specific configuration.
138 | """
139 | get_cost(config::SpinConfig, sap::SpinAnnealingProblem) = sum(config.config'*sap.coupling*config.config)
140 |
141 | # ╔═╡ 92c83b32-668a-4adb-8531-4258d094403c
142 | """
143 | propose(config::AnnealingConfig, ap::AnnealingProblem) -> (Proposal, Real)
144 |
145 | Propose a change, as well as the energy change.
146 | """
147 | @inline function propose(config::SpinConfig, ::SpinAnnealingProblem) # ommit the name of argument, since not used.
148 | ispin = rand(1:length(config.config))
149 | @inbounds ΔE = -config.field[ispin] * config.config[ispin] * 4 # 2 for spin change, 2 for mutual energy.
150 | ispin, ΔE
151 | end
152 |
153 | # ╔═╡ 83211927-e0b7-4439-90e1-9d348328be16
154 | """
155 | flip!(config::AnnealingConfig, ispin::Proposal, ap::AnnealingProblem) -> SpinConfig
156 |
157 | Apply the change to the configuration.
158 | """
159 | @inline function flip!(config::SpinConfig, ispin::Int, sap::SpinAnnealingProblem)
160 | @inbounds config.config[ispin] = -config.config[ispin] # @inbounds can remove boundary check, and improve performance
161 | @simd for i=1:sap.num_spin
162 | @inbounds config.field[i] += 2 * config.config[ispin] * sap.coupling[i,ispin]
163 | end
164 | config
165 | end
166 |
167 | # ╔═╡ 30ea57fc-f6ce-4fdf-b880-fc83012ed49f
168 | """
169 | anneal_singlerun!(config::AnnealingConfig, prblm, tempscales::Vector{Float64}, num_update_each_temp::Int)
170 |
171 | Perform Simulated Annealing using Metropolis updates for the single run.
172 |
173 | * configuration that can be updated.
174 | * prblm: problem with `get_cost`, `flip!` and `random_config` interfaces.
175 | * tempscales: temperature scales, which should be a decreasing array.
176 | * num_update_each_temp: the number of update in each temprature scale.
177 |
178 | Returns (minimum cost, optimal configuration).
179 | """
180 | function anneal_singlerun!(config, prblm, tempscales::Vector{Float64}, num_update_each_temp::Int)
181 | cost = get_cost(config, prblm)
182 |
183 | opt_config = config
184 | opt_cost = cost
185 | for beta = 1 ./ tempscales
186 | @simd for m = 1:num_update_each_temp # single instriuction multiple data, see julia performance tips.
187 | proposal, ΔE = propose(config, prblm)
188 | if exp(-beta*ΔE) > rand() #accept
189 | flip!(config, proposal, prblm)
190 | cost += ΔE
191 | if cost < opt_cost
192 | opt_cost = cost
193 | opt_config = config
194 | end
195 | end
196 | end
197 | end
198 | opt_cost, opt_config
199 | end
200 |
201 | # ╔═╡ 01275de9-c88b-4404-94f9-8a9129b06e70
202 | """
203 | anneal(nrun::Int, prblm, tempscales::Vector{Float64}, num_update_each_temp::Int)
204 |
205 | Perform Simulated Annealing with multiple runs.
206 | """
207 | function anneal(nrun::Int, prblm, tempscales::Vector{Float64}, num_update_each_temp::Int)
208 | local opt_config, opt_cost
209 | for r = 1:nrun
210 | initial_config = random_config(prblm)
211 | cost, config = anneal_singlerun!(initial_config, prblm, tempscales, num_update_each_temp)
212 | if r == 1 || cost < opt_cost
213 | opt_cost = cost
214 | opt_config = config
215 | end
216 | end
217 | opt_cost, opt_config
218 | end
219 |
220 | # ╔═╡ dcac0777-ff00-4ccb-91bb-678680413826
221 | Random.seed!(2)
222 |
223 | # ╔═╡ 53510c2f-ed40-4dee-84c0-436cc8281076
224 | tempscales = 10 .- (1:64 .- 1) .* 0.15 |> collect
225 |
226 | # ╔═╡ a4269932-e5af-4966-a0a9-4757066048b8
227 | sap = load_coupling("programs/example.txt")
228 |
229 | # ╔═╡ 61b6649e-04cd-45ab-ab40-19283a556bd8
230 | @testset "anneal" begin
231 | opt_cost, opt_config = anneal(30, sap, tempscales, 4000)
232 | @test anneal(30, sap, tempscales, 4000)[1] == -3858
233 | anneal(30, sap, tempscales, 4000)
234 | res = median(@benchmark anneal(30, $sap, $tempscales, 4000))
235 | @test res.time/1e9 < 2
236 | @test res.allocs < 500
237 | end
238 |
239 | # ╔═╡ a883bf1a-f38c-4759-9287-7bad55d9ac37
240 | @bind run_julia_benchmark CheckBox()
241 |
242 | # ╔═╡ 0aebe7f7-3a88-4bf3-ab81-2d817f2d56b8
243 | if run_julia_benchmark @benchmark anneal(30, $sap, $tempscales, 4000) end
244 |
245 | # ╔═╡ 6a658549-c1e5-4ce2-bcce-ca08a5b0fe2c
246 | with_terminal() do
247 | Profile.clear()
248 | @profile anneal(100, sap, tempscales, 4000)
249 | Profile.print()
250 | end
251 |
252 | # ╔═╡ 8fa64302-22ac-49b1-ae0d-035660eacdac
253 | md"""
254 | ## Calling a Fortran program
255 | * https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/index.html
256 | * https://craftofcoding.wordpress.com/2017/02/26/calling-fortran-from-julia-i/
257 | * https://craftofcoding.wordpress.com/2017/03/01/calling-fortran-from-julia-ii/
258 | """
259 |
260 | # ╔═╡ 8dac622d-b115-46e5-8dd8-2150fcf53cc5
261 | cd(joinpath(@__DIR__, "programs")) do
262 | run(`gfortran -shared -fPIC problem.f90 fsa.f90 -o fsa.so` & `nm fsa.so`)
263 | end
264 |
265 | # ╔═╡ e9ffb48e-8d57-468e-b47c-466d827faa78
266 | @bind run_fortran_benchmark CheckBox()
267 |
268 | # ╔═╡ ef586d7e-adbc-44b3-b6eb-6685b3e13378
269 | # crash!
270 | # @benchmark ccall(((:test_, joinpath(@__DIR__, "fsa.so"))), Int32, ())
271 |
272 | # ╔═╡ 1acd9c9b-6a01-44ab-9cbe-9d0c94544f39
273 | md"""
274 | ## What about Python?
275 | We can use [PyCall](https://github.com/JuliaPy/PyCall.jl) to call python programs!
276 |
277 | ### **Challenge!**
278 | 1. use Python package [viznet](https://github.com/GiggleLiu/viznet) and [matplotlib](https://matplotlib.org/) for visualization
279 | 2. benchmark pure python version of simulated annealing, show the time
280 | """
281 |
282 | # ╔═╡ 92e7af60-0566-4769-b90c-e0abbb2b2f76
283 | # ╠═╡ show_logs = false
284 | CondaPkg.add("seaborn")
285 |
286 | # ╔═╡ c9d2f737-c034-4394-b18b-70e9f9ec28ea
287 | plt = pyimport("matplotlib.pyplot")
288 |
289 | # ╔═╡ 83d904d3-cdfe-499b-bfaa-c2ae643526a7
290 | let
291 | N = 400
292 | t = LinRange(0, 2π, N)
293 | r = 0.5 .+ cos.(t)
294 | x, y = r .* cos.(t), r .* sin.(t)
295 |
296 | fig, ax = plt.subplots()
297 | ax.plot(x, y, "k")
298 | ax.set(aspect=1)
299 | plt.show()
300 | end;
301 |
302 | # ╔═╡ 0a1ad6b8-f848-4147-a4aa-b4edc0caa42b
303 | pysa = try
304 | pyimport("testsa")
305 | catch e
306 | pyimport("sys").path.append(joinpath(@__DIR__, "programs")) # add current folder into path
307 | pyimport("testsa")
308 | end
309 |
310 | # ╔═╡ 01dd7234-f600-4597-b372-049e000ced1b
311 | @bind benchmark_python CheckBox()
312 |
313 | # ╔═╡ a3575bea-e521-47e1-9167-62e999728786
314 | if benchmark_python @benchmark pysa.test_codec() end
315 |
316 | # ╔═╡ 00000000-0000-0000-0000-000000000001
317 | PLUTO_PROJECT_TOML_CONTENTS = """
318 | [deps]
319 | BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
320 | CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
321 | DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
322 | PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
323 | Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
324 | PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
325 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
326 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
327 | Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
328 |
329 | [compat]
330 | BenchmarkTools = "~1.3.2"
331 | CondaPkg = "~0.2.18"
332 | PlutoUI = "~0.7.50"
333 | PythonCall = "~0.9.12"
334 | """
335 |
336 | # ╔═╡ 00000000-0000-0000-0000-000000000002
337 | PLUTO_MANIFEST_TOML_CONTENTS = """
338 | # This file is machine-generated - editing it directly is not advised
339 |
340 | julia_version = "1.9.0-rc2"
341 | manifest_format = "2.0"
342 | project_hash = "3c9743b42aefe8f050872f1389dfdc77f9f22d5f"
343 |
344 | [[deps.AbstractPlutoDingetjes]]
345 | deps = ["Pkg"]
346 | git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481"
347 | uuid = "6e696c72-6542-2067-7265-42206c756150"
348 | version = "1.1.4"
349 |
350 | [[deps.ArgTools]]
351 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
352 | version = "1.1.1"
353 |
354 | [[deps.Artifacts]]
355 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
356 |
357 | [[deps.Base64]]
358 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
359 |
360 | [[deps.BenchmarkTools]]
361 | deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"]
362 | git-tree-sha1 = "d9a9701b899b30332bbcb3e1679c41cce81fb0e8"
363 | uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
364 | version = "1.3.2"
365 |
366 | [[deps.ColorTypes]]
367 | deps = ["FixedPointNumbers", "Random"]
368 | git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4"
369 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
370 | version = "0.11.4"
371 |
372 | [[deps.CompilerSupportLibraries_jll]]
373 | deps = ["Artifacts", "Libdl"]
374 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
375 | version = "1.0.2+0"
376 |
377 | [[deps.CondaPkg]]
378 | deps = ["JSON3", "Markdown", "MicroMamba", "Pidfile", "Pkg", "TOML"]
379 | git-tree-sha1 = "741146cf2ced5859faae76a84b541aa9af1a78bb"
380 | uuid = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
381 | version = "0.2.18"
382 |
383 | [[deps.DataAPI]]
384 | git-tree-sha1 = "e8119c1a33d267e16108be441a287a6981ba1630"
385 | uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
386 | version = "1.14.0"
387 |
388 | [[deps.DataValueInterfaces]]
389 | git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
390 | uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
391 | version = "1.0.0"
392 |
393 | [[deps.Dates]]
394 | deps = ["Printf"]
395 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
396 |
397 | [[deps.DelimitedFiles]]
398 | deps = ["Mmap"]
399 | git-tree-sha1 = "9e2f36d3c96a820c678f2f1f1782582fcf685bae"
400 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
401 | version = "1.9.1"
402 |
403 | [[deps.Downloads]]
404 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
405 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
406 | version = "1.6.0"
407 |
408 | [[deps.FileWatching]]
409 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
410 |
411 | [[deps.FixedPointNumbers]]
412 | deps = ["Statistics"]
413 | git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
414 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
415 | version = "0.8.4"
416 |
417 | [[deps.Hyperscript]]
418 | deps = ["Test"]
419 | git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9"
420 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91"
421 | version = "0.0.4"
422 |
423 | [[deps.HypertextLiteral]]
424 | deps = ["Tricks"]
425 | git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9"
426 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
427 | version = "0.9.4"
428 |
429 | [[deps.IOCapture]]
430 | deps = ["Logging", "Random"]
431 | git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a"
432 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
433 | version = "0.2.2"
434 |
435 | [[deps.InteractiveUtils]]
436 | deps = ["Markdown"]
437 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
438 |
439 | [[deps.IteratorInterfaceExtensions]]
440 | git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
441 | uuid = "82899510-4779-5014-852e-03e436cf321d"
442 | version = "1.0.0"
443 |
444 | [[deps.JLLWrappers]]
445 | deps = ["Preferences"]
446 | git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1"
447 | uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
448 | version = "1.4.1"
449 |
450 | [[deps.JSON]]
451 | deps = ["Dates", "Mmap", "Parsers", "Unicode"]
452 | git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e"
453 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
454 | version = "0.21.3"
455 |
456 | [[deps.JSON3]]
457 | deps = ["Dates", "Mmap", "Parsers", "SnoopPrecompile", "StructTypes", "UUIDs"]
458 | git-tree-sha1 = "84b10656a41ef564c39d2d477d7236966d2b5683"
459 | uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
460 | version = "1.12.0"
461 |
462 | [[deps.LazyArtifacts]]
463 | deps = ["Artifacts", "Pkg"]
464 | uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
465 |
466 | [[deps.LibCURL]]
467 | deps = ["LibCURL_jll", "MozillaCACerts_jll"]
468 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
469 | version = "0.6.3"
470 |
471 | [[deps.LibCURL_jll]]
472 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
473 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
474 | version = "7.84.0+0"
475 |
476 | [[deps.LibGit2]]
477 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
478 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
479 |
480 | [[deps.LibSSH2_jll]]
481 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
482 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
483 | version = "1.10.2+0"
484 |
485 | [[deps.Libdl]]
486 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
487 |
488 | [[deps.LinearAlgebra]]
489 | deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
490 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
491 |
492 | [[deps.Logging]]
493 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
494 |
495 | [[deps.MIMEs]]
496 | git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb"
497 | uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65"
498 | version = "0.1.4"
499 |
500 | [[deps.MacroTools]]
501 | deps = ["Markdown", "Random"]
502 | git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2"
503 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
504 | version = "0.5.10"
505 |
506 | [[deps.Markdown]]
507 | deps = ["Base64"]
508 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
509 |
510 | [[deps.MbedTLS_jll]]
511 | deps = ["Artifacts", "Libdl"]
512 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
513 | version = "2.28.2+0"
514 |
515 | [[deps.MicroMamba]]
516 | deps = ["Pkg", "Scratch", "micromamba_jll"]
517 | git-tree-sha1 = "a6a4771aba1dc8942bc0f44ff9f8ee0f893ef888"
518 | uuid = "0b3b1443-0f03-428d-bdfb-f27f9c1191ea"
519 | version = "0.1.12"
520 |
521 | [[deps.Mmap]]
522 | uuid = "a63ad114-7e13-5084-954f-fe012c677804"
523 |
524 | [[deps.MozillaCACerts_jll]]
525 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
526 | version = "2022.10.11"
527 |
528 | [[deps.NetworkOptions]]
529 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
530 | version = "1.2.0"
531 |
532 | [[deps.OpenBLAS_jll]]
533 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
534 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
535 | version = "0.3.21+4"
536 |
537 | [[deps.OrderedCollections]]
538 | git-tree-sha1 = "d321bf2de576bf25ec4d3e4360faca399afca282"
539 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
540 | version = "1.6.0"
541 |
542 | [[deps.Parsers]]
543 | deps = ["Dates", "SnoopPrecompile"]
544 | git-tree-sha1 = "478ac6c952fddd4399e71d4779797c538d0ff2bf"
545 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
546 | version = "2.5.8"
547 |
548 | [[deps.Pidfile]]
549 | deps = ["FileWatching", "Test"]
550 | git-tree-sha1 = "2d8aaf8ee10df53d0dfb9b8ee44ae7c04ced2b03"
551 | uuid = "fa939f87-e72e-5be4-a000-7fc836dbe307"
552 | version = "1.3.0"
553 |
554 | [[deps.Pkg]]
555 | deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
556 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
557 | version = "1.9.0"
558 |
559 | [[deps.PlutoUI]]
560 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"]
561 | git-tree-sha1 = "5bb5129fdd62a2bbbe17c2756932259acf467386"
562 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
563 | version = "0.7.50"
564 |
565 | [[deps.Preferences]]
566 | deps = ["TOML"]
567 | git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d"
568 | uuid = "21216c6a-2e73-6563-6e65-726566657250"
569 | version = "1.3.0"
570 |
571 | [[deps.Printf]]
572 | deps = ["Unicode"]
573 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
574 |
575 | [[deps.Profile]]
576 | deps = ["Printf"]
577 | uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
578 |
579 | [[deps.PythonCall]]
580 | deps = ["CondaPkg", "Dates", "Libdl", "MacroTools", "Markdown", "Pkg", "REPL", "Requires", "Serialization", "Tables", "UnsafePointers"]
581 | git-tree-sha1 = "f27dabb05ec811675a9eefe49325a14ae7266b0b"
582 | uuid = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
583 | version = "0.9.12"
584 |
585 | [[deps.REPL]]
586 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
587 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
588 |
589 | [[deps.Random]]
590 | deps = ["SHA", "Serialization"]
591 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
592 |
593 | [[deps.Reexport]]
594 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
595 | uuid = "189a3867-3050-52da-a836-e630ba90ab69"
596 | version = "1.2.2"
597 |
598 | [[deps.Requires]]
599 | deps = ["UUIDs"]
600 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
601 | uuid = "ae029012-a4dd-5104-9daa-d747884805df"
602 | version = "1.3.0"
603 |
604 | [[deps.SHA]]
605 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
606 | version = "0.7.0"
607 |
608 | [[deps.Scratch]]
609 | deps = ["Dates"]
610 | git-tree-sha1 = "30449ee12237627992a99d5e30ae63e4d78cd24a"
611 | uuid = "6c6a2e73-6563-6170-7368-637461726353"
612 | version = "1.2.0"
613 |
614 | [[deps.Serialization]]
615 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
616 |
617 | [[deps.SnoopPrecompile]]
618 | deps = ["Preferences"]
619 | git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c"
620 | uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c"
621 | version = "1.0.3"
622 |
623 | [[deps.Sockets]]
624 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
625 |
626 | [[deps.SparseArrays]]
627 | deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
628 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
629 |
630 | [[deps.Statistics]]
631 | deps = ["LinearAlgebra", "SparseArrays"]
632 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
633 | version = "1.9.0"
634 |
635 | [[deps.StructTypes]]
636 | deps = ["Dates", "UUIDs"]
637 | git-tree-sha1 = "ca4bccb03acf9faaf4137a9abc1881ed1841aa70"
638 | uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
639 | version = "1.10.0"
640 |
641 | [[deps.SuiteSparse_jll]]
642 | deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"]
643 | uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
644 | version = "5.10.1+6"
645 |
646 | [[deps.TOML]]
647 | deps = ["Dates"]
648 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
649 | version = "1.0.3"
650 |
651 | [[deps.TableTraits]]
652 | deps = ["IteratorInterfaceExtensions"]
653 | git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
654 | uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
655 | version = "1.0.1"
656 |
657 | [[deps.Tables]]
658 | deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"]
659 | git-tree-sha1 = "1544b926975372da01227b382066ab70e574a3ec"
660 | uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
661 | version = "1.10.1"
662 |
663 | [[deps.Tar]]
664 | deps = ["ArgTools", "SHA"]
665 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
666 | version = "1.10.0"
667 |
668 | [[deps.Test]]
669 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
670 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
671 |
672 | [[deps.Tricks]]
673 | git-tree-sha1 = "aadb748be58b492045b4f56166b5188aa63ce549"
674 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775"
675 | version = "0.1.7"
676 |
677 | [[deps.URIs]]
678 | git-tree-sha1 = "074f993b0ca030848b897beff716d93aca60f06a"
679 | uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
680 | version = "1.4.2"
681 |
682 | [[deps.UUIDs]]
683 | deps = ["Random", "SHA"]
684 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
685 |
686 | [[deps.Unicode]]
687 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
688 |
689 | [[deps.UnsafePointers]]
690 | git-tree-sha1 = "c81331b3b2e60a982be57c046ec91f599ede674a"
691 | uuid = "e17b2a0c-0bdf-430a-bd0c-3a23cae4ff39"
692 | version = "1.0.0"
693 |
694 | [[deps.Zlib_jll]]
695 | deps = ["Libdl"]
696 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
697 | version = "1.2.13+0"
698 |
699 | [[deps.libblastrampoline_jll]]
700 | deps = ["Artifacts", "Libdl"]
701 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
702 | version = "5.4.0+0"
703 |
704 | [[deps.micromamba_jll]]
705 | deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl"]
706 | git-tree-sha1 = "087555b0405ed6adf526cef22b6931606b5af8ac"
707 | uuid = "f8abcde7-e9b7-5caa-b8af-a437887ae8e4"
708 | version = "1.4.1+0"
709 |
710 | [[deps.nghttp2_jll]]
711 | deps = ["Artifacts", "Libdl"]
712 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
713 | version = "1.48.0+0"
714 |
715 | [[deps.p7zip_jll]]
716 | deps = ["Artifacts", "Libdl"]
717 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
718 | version = "17.4.0+0"
719 | """
720 |
721 | # ╔═╡ Cell order:
722 | # ╠═2ec32c9d-0216-48a8-848d-79f7cc84798e
723 | # ╟─701dfc92-4891-477b-9e15-8083f8ca5531
724 | # ╠═0c3000cf-46d3-4481-9d6d-61980443dd93
725 | # ╠═9ec34d03-e9e6-460c-bc8b-39b70b6b8a37
726 | # ╠═a7e70b41-9184-4127-b66f-dfc03b8b3004
727 | # ╠═35b7dcfe-717f-48b0-bd4f-4c72f880a229
728 | # ╠═6cc6e9a2-4409-4ad1-b8d1-be0826fe9592
729 | # ╠═a2a174b8-28d0-461f-97c6-8364ccada6c4
730 | # ╠═f1c1eae7-102f-4ca3-9fd2-d81529ada0a3
731 | # ╠═caa805be-6c98-4b59-8404-c0db284c58e9
732 | # ╠═e692876e-72eb-4a19-a0b9-367ab3e84783
733 | # ╟─0d37406b-f16a-4b91-a138-ee59a92e2ca4
734 | # ╠═30ea57fc-f6ce-4fdf-b880-fc83012ed49f
735 | # ╠═01275de9-c88b-4404-94f9-8a9129b06e70
736 | # ╠═6116801e-e6a8-4e75-9e04-6c07e4a17305
737 | # ╠═92c83b32-668a-4adb-8531-4258d094403c
738 | # ╠═83211927-e0b7-4439-90e1-9d348328be16
739 | # ╠═0b0e674d-688d-491d-8a51-36334ad40b1a
740 | # ╠═dcac0777-ff00-4ccb-91bb-678680413826
741 | # ╠═53510c2f-ed40-4dee-84c0-436cc8281076
742 | # ╠═a4269932-e5af-4966-a0a9-4757066048b8
743 | # ╠═61b6649e-04cd-45ab-ab40-19283a556bd8
744 | # ╟─a883bf1a-f38c-4759-9287-7bad55d9ac37
745 | # ╠═0aebe7f7-3a88-4bf3-ab81-2d817f2d56b8
746 | # ╠═8c702004-0534-43cb-b92c-1b494a1145b3
747 | # ╠═6a658549-c1e5-4ce2-bcce-ca08a5b0fe2c
748 | # ╟─8fa64302-22ac-49b1-ae0d-035660eacdac
749 | # ╠═8dac622d-b115-46e5-8dd8-2150fcf53cc5
750 | # ╟─e9ffb48e-8d57-468e-b47c-466d827faa78
751 | # ╠═ef586d7e-adbc-44b3-b6eb-6685b3e13378
752 | # ╟─1acd9c9b-6a01-44ab-9cbe-9d0c94544f39
753 | # ╠═c96ce06a-bd6a-419c-8c77-cc76ea0f8593
754 | # ╠═92e7af60-0566-4769-b90c-e0abbb2b2f76
755 | # ╠═c9d2f737-c034-4394-b18b-70e9f9ec28ea
756 | # ╠═83d904d3-cdfe-499b-bfaa-c2ae643526a7
757 | # ╠═0a1ad6b8-f848-4147-a4aa-b4edc0caa42b
758 | # ╟─01dd7234-f600-4597-b372-049e000ced1b
759 | # ╠═a3575bea-e521-47e1-9167-62e999728786
760 | # ╟─00000000-0000-0000-0000-000000000001
761 | # ╟─00000000-0000-0000-0000-000000000002
762 |
--------------------------------------------------------------------------------
/simulated-annealing/notebook.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingThrust/CodingClub/d6acc0c44858c5a2c0f6d0b81beaa2e85144a91c/simulated-annealing/notebook.pdf
--------------------------------------------------------------------------------
/simulated-annealing/programs/fsa.f90:
--------------------------------------------------------------------------------
1 | ! initialize a random seed from the system clock at every run (fortran 95 code)
2 | subroutine init_random_seed()
3 | INTEGER :: i, n, clock
4 | INTEGER, DIMENSION(:), ALLOCATABLE :: seed
5 |
6 | CALL RANDOM_SEED(size = n)
7 | ALLOCATE(seed(n))
8 | CALL SYSTEM_CLOCK(COUNT=clock)
9 | seed = clock + 37 * (/ (i - 1, i = 1, n) /)
10 | CALL RANDOM_SEED(PUT = seed)
11 | DEALLOCATE(seed)
12 | end subroutine init_random_seed
13 |
14 | !Perform Simulated Annealing using Metropolis updates for the single run.
15 | !
16 | !Parameters:
17 | ! :ann: , the app.
18 | ! :initial_config: config,
19 | ! :tempscales: 1D array, the time scale from high temperature to low temperature.
20 | !
21 | !Return:
22 | ! (minimum cost, optimal configuration)
23 | subroutine anneal_singlerun(config,field,opt_cost,opt_config)
24 | use problem
25 | implicit none
26 | integer,intent(inout) :: config(num_spin)
27 | real,intent(inout) :: field(num_spin)
28 | integer :: it,ispin,m
29 | real :: cost,delta
30 | real :: uni01(nms),beta
31 | integer,intent(out) :: opt_config(num_spin)
32 | real,intent(out) :: opt_cost
33 |
34 | opt_config=config
35 | call get_cost(config,cost)
36 | opt_cost=cost
37 |
38 | do it=1,num_tempscales
39 | beta=1/tempscales(it)
40 | call random_number(uni01)
41 | do m=1,nms
42 | call propose(config,field,ispin,delta)
43 | if(exp(-beta*delta)>uni01(m)) then !accept
44 | call accept(ispin,config,field)
45 | cost=cost+delta
46 | if(cost, the app.
71 | :initial_state: state,
72 | :tempscales: 1D array, the time scale from high temperature to low temperature.
73 | :nms: int, the number of Monte Carlo updates in each time scale.
74 |
75 | Return:
76 | (minimum cost, optimal configuration)
77 | '''
78 | state=initial_state
79 | opt_state=copy.deepcopy(initial_state)
80 | opt_cost=cost=ann.get_cost(state)
81 | for T in tempscales:
82 | uni01=random.random(nms)
83 | beta=1./T
84 | for m in range(nms):
85 | info,dE=ann.propose(state)
86 | if exp(-beta*dE)>uni01[m]: #accept
87 | state=ann.accept((info,dE),state)
88 | cost+=dE
89 | if cost, the app.
99 | :tempscales: 1D array, the time scale from high temperature to low temperature.
100 | :nrun: int, the number of runs.
101 | :nms: int, the number of Monte Carlo updates in each time scale.
102 |
103 | Return:
104 | (minimum cost, optimal configuration)
105 | '''
106 | opt_cost=Inf
107 | for r in range(nrun):
108 | t0=time.time()
109 | initial_state=ann.get_random_state()
110 | cost,state=anneal_singlerun(ann,initial_state,tempscales,nms=nms)
111 | if cost %s'%(r,cost,t1-t0))
116 | return opt_cost,opt_state
117 |
118 | '''
119 | Flexible way to construct .
120 |
121 | e.g. sap(get_cost,propose,accept,get_random_state)
122 | '''
123 | sap=namedtuple('SAP','get_cost propose accept get_random_state')
124 |
--------------------------------------------------------------------------------
/simulated-annealing/programs/testsa.py:
--------------------------------------------------------------------------------
1 | '''
2 | Tests for nrg.
3 | '''
4 | from numpy import *
5 | from numpy.testing import dec,assert_,assert_raises,assert_almost_equal,assert_allclose
6 | from scipy.sparse import coo_matrix
7 | import pdb,sys
8 |
9 | from sa import SAP,anneal
10 |
11 | class CC(SAP):
12 | def __init__(self,J):
13 | self.J=J
14 |
15 | def get_cost(self,state):
16 | config=state[0]
17 | return (self.J*config[:,newaxis]*config).sum()
18 |
19 | def propose(self,state):
20 | config,field=state
21 | N=len(self.J)
22 | i = random.randint(N)
23 | dE=-field[i]*config[i]*4 #2 for spin change, 2 for mutual energy.
24 | return i,dE
25 |
26 | def accept(self,proposal,state):
27 | i,dE=proposal
28 | config,field=state
29 | config[i]*=-1
30 | #update field
31 | ci=config[i]
32 | field+=(2*ci)*self.J[:,i]
33 | return (config,field)
34 |
35 | def get_random_state(self):
36 | config=sign(random.random(len(self.J))-0.5)
37 | field=self.J.dot(config)
38 | return (config,field)
39 |
40 | def test_codec():
41 | #run a simple test: code challenge
42 | N=300
43 | import os
44 | dirname = os.path.dirname(__file__)
45 | data=loadtxt(os.path.join(dirname, 'example.txt'))
46 | J=coo_matrix((data[:,2],(data[:,0],data[:,1])),shape=(N,N),dtype='int32').toarray()
47 | J=(J+J.T)/2.
48 | cc=CC(J)
49 | Emin,Config=anneal(cc,tempscales=linspace(10,0.6,51),nms=4000,nrun=30)
50 | assert_(Emin==-3858 and cc.get_cost(Config)==Emin)
51 |
52 | if __name__=='__main__':
53 | test_codec()
54 |
--------------------------------------------------------------------------------