├── .github └── workflows │ └── ExportPluto.yaml ├── .gitignore ├── 6_MultipleDispatchAmbiguity.jpg ├── README.md ├── homeworks ├── HW3.jl ├── hw0-2024.jl └── hw1-2024.jl ├── homeworks_old ├── hw1a.jl ├── hw1b.jl ├── hw2.jl ├── hw3.jl ├── hw4.jl ├── hw5-gpu.jl ├── hw5.jl ├── hw6.jl └── images │ ├── atmosphere.png │ └── lineland.png ├── homeworks_old2 ├── fall2024_hw1.jl ├── hw0.jl ├── hw1.jl ├── hw10.jl ├── hw2.jl ├── hw3.jl ├── hw4.jl ├── hw5.jl ├── hw6.jl ├── hw7.jl ├── hw8.jl └── hw9.jl ├── netlify.toml ├── notebooks ├── .ipynb_checkpoints │ └── 3_Julia is fast-checkpoint.ipynb ├── 0_julia_tutorial.jl ├── 1. solar_panel_avalanche.jl ├── 13_ferari_lecture1.pdf ├── 14_energy_balance.jl ├── 18c06odedemo.jl ├── 1_abstraction.jl ├── 1_hyperbolic_corgi.jl ├── 1_images.jl ├── 20220422_philip.jpg ├── 20220422_philip.png ├── 3_Julia is fast.ipynb ├── 4. AutoDiff.ipynb ├── 6_MultDisAmbiguity.jl ├── 7_ptypes.jl ├── Lecture16a.jl ├── Lecture16b.jl ├── Lecture2a.jl ├── circular.jl ├── fast_inv_sqrt.jl ├── fourier_quantum.jl ├── geometric_sequence ├── geometric_sequence.jl ├── jacobi.jl └── reduced_phil.png ├── notebooks_old ├── 10_climate_science.jl ├── 2_finite_differences.jl ├── 2_matrix_jacobians.jl ├── 2layerocean.png ├── 3_linear_transformations.jl ├── 3_symmetric_eigenvalue_derivatives.jl ├── 4_computational_geometry.jl ├── 8_greenhouse_effect.jl ├── 9_climate_sensitivity.jl ├── 9_raf2.jl ├── Broadening.pdf ├── Broadening.svg ├── Emission_TS.png ├── GHGmodel.png ├── LeakyGreenhouse.png ├── RightPicture_TC.png ├── WaterVapor.pdf ├── WaterVapor.svg ├── WrongPicture_TC.png ├── cpu_for_class.jl ├── floop_nbody.jl ├── gdalle │ ├── challenge.jl │ ├── good_practices.jl │ ├── graphs.jl │ ├── linear_programming.jl │ └── performance.jl └── juliahub_in_class_110122.jl ├── pluto-slider-server-environment ├── Manifest.toml ├── PlutoDeployment.toml └── Project.toml └── slides_old ├── ClimateMARGO.pdf ├── ad_handwritten.pdf └── mesh_generation.pdf /.github/workflows/ExportPluto.yaml: -------------------------------------------------------------------------------- 1 | name: Export Pluto notebooks 2 | on: 3 | push: 4 | paths-ignore: 5 | - "README.md" 6 | - "homeworks_old" 7 | - "homeworks_old2" 8 | - "notebooks" 9 | branches: 10 | - Fall24 11 | - main 12 | - master 13 | workflow_dispatch: 14 | 15 | # When two jobs run in parallel, cancel the older ones, to make sure that the website is generated from the most recent commit. 16 | concurrency: 17 | group: pluto-export 18 | cancel-in-progress: true 19 | 20 | # This action needs permission to write the exported HTML file to the gh-pages branch. 21 | permissions: 22 | contents: write 23 | # (all other permission fields default to "none") 24 | 25 | jobs: 26 | build-and-deploy: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - name: Checkout this repository 30 | uses: actions/checkout@v3 31 | 32 | - name: Install Julia 33 | uses: julia-actions/setup-julia@v1 34 | with: 35 | version: "1.10" 36 | 37 | - name: Cache Julia artifacts & such 38 | uses: julia-actions/cache@v1 39 | with: 40 | cache-registries: "true" 41 | 42 | # We set up a folder that Pluto can use to cache exported notebooks. If the notebook file did not change, then Pluto can take the exported file from cache instead of running the notebook. 43 | - name: Set up notebook state cache 44 | uses: actions/cache@v3 45 | with: 46 | path: pluto_state_cache 47 | key: ${{ runner.os }}-pluto_state_cache-v2-${{ hashFiles('**/Project.toml', '**/Manifest.toml', '.github/workflows/*' ) }}-${{ hashFiles('**/*jl') }} 48 | restore-keys: | 49 | ${{ runner.os }}-pluto_state_cache-v2-${{ hashFiles('**/Project.toml', '**/Manifest.toml', '.github/workflows/*' ) }} 50 | 51 | 52 | - name: Run & export Pluto notebooks 53 | run: | 54 | julia -e 'using Pkg 55 | Pkg.activate("pluto-slider-server-environment") 56 | Pkg.instantiate() 57 | 58 | import PlutoSliderServer 59 | 60 | PlutoSliderServer.github_action("."; Export_cache_dir="pluto_state_cache")' 61 | 62 | 63 | - name: Deploy to gh-pages 64 | uses: JamesIves/github-pages-deploy-action@releases/v4 65 | with: 66 | token: ${{ secrets.GITHUB_TOKEN }} 67 | branch: gh-pages 68 | folder: . 69 | single-commit: true 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /6_MultipleDispatchAmbiguity.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/6_MultipleDispatchAmbiguity.jpg -------------------------------------------------------------------------------- /homeworks_old/hw1b.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.11 3 | 4 | #> [frontmatter] 5 | #> title = "HW1b - Matrix calculus" 6 | #> date = "2022-09-16" 7 | 8 | using Markdown 9 | using InteractiveUtils 10 | 11 | # ╔═╡ f6cdf6d4-35cd-11ed-1c5c-db3e4aec3adb 12 | md""" 13 | Homework 1b of the MIT Course [_Julia: solving real-world problems with computation_](https://github.com/mitmath/JuliaComputation) 14 | 15 | Release date: Friday, Sep 16, 2022 (version 1) 16 | 17 | **Due date: Thursday, Sep 22, 2022 (11:59pm EST)** 18 | 19 | Submission by: Jazzy Doe (jazz@mit.edu) 20 | """ 21 | 22 | # ╔═╡ 6cc8e719-fb27-478c-a362-a51e65c152a9 23 | student = (name = "Jazzy Doe", kerberos_id = "jazz") 24 | 25 | # ╔═╡ d411f114-76e5-45b3-b257-8936227c45bc 26 | md""" 27 | # Matrix calculus 28 | """ 29 | 30 | # ╔═╡ 14ac9e7e-206e-4472-af05-b3d1ccf0010f 31 | md""" 32 | For each function $f(x)$, work out the linear transformation $f'(x)$ such that $df = f'(x) dx$. 33 | Check your answers numerically using Julia by computing $f(x+e)-f(x)$ for some random $x$ and (small) $e$, and comparing with $f'(x)e$. 34 | We use lowercase $x$ for vectors and uppercase $X$ for matrices. 35 | """ 36 | 37 | # ╔═╡ 5aed70bc-d518-4c0a-b650-cd6ff60f2db0 38 | md""" 39 | !!! warning "Instructions" 40 | Please write the mathematical part of each answer inside a Markdown cell, and the experimental part inside one or several code cells. 41 | """ 42 | 43 | # ╔═╡ 12e51959-e16d-424d-a663-e316adb78e0e 44 | md""" 45 | !!! info "Tips" 46 | To write math in a Markdown cell, just surround it with dollars and use basic LaTeX syntax, like this: 47 | 48 | $\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$ 49 | """ 50 | 51 | # ╔═╡ 245f4f38-9aed-4d7b-b1e1-4294ac6c477f 52 | md""" 53 | ## Question 1 54 | 55 | $f \colon x \in \mathbb{R}^n \longmapsto (x^\top x)^2$. Hint: use the chain rule $df(g)=f'(g)dg$ 56 | """ 57 | 58 | # ╔═╡ f07be691-99c3-47ce-b963-c7452338f0fa 59 | md""" 60 | Your answer (with justification) goes here 61 | """ 62 | 63 | # ╔═╡ cd1d0fbe-5760-4100-ad49-7b94e368df3d 64 | # Your code goes here 65 | 66 | # ╔═╡ a36c286b-d6d6-4f9f-ad86-b4046a77663d 67 | md""" 68 | ## Question 2 69 | 70 | $f \colon x \in \mathbb{R}^n \longmapsto \log.(x)$, meaning the elementwise application of the $\log$ function to each entry of the vector $x$, whose result is another vector of $\mathbb{R}^n$. 71 | """ 72 | 73 | # ╔═╡ 86a96dbb-c018-45b2-b6dd-35bd47051f7f 74 | md""" 75 | Your answer (with justification) goes here 76 | """ 77 | 78 | # ╔═╡ ed3beb6f-42ac-4787-b4f1-78169e53678b 79 | # Your code goes here 80 | 81 | # ╔═╡ 4fcc5b25-0df2-4125-9e5a-9357e56f8e13 82 | # and here 83 | 84 | # ╔═╡ 9be9d847-36ce-4461-aa85-5da3e82cc1ec 85 | # and maybe here too 86 | 87 | # ╔═╡ 87c518d1-632d-4b27-9b4d-69bc2300b569 88 | md""" 89 | ## Question 3 90 | 91 | $f \colon X \in \mathbb{R}^{n \times m} \longmapsto \theta^\top X$, where $\theta \in R^n$ is a vector 92 | """ 93 | 94 | # ╔═╡ a2e57067-52c6-4a5c-95fd-ae655418fa48 95 | md""" 96 | Your answer (with justification) goes here 97 | """ 98 | 99 | # ╔═╡ 1ef4387c-59f0-443d-8d8c-26aa8d1c1e0f 100 | # Your code goes here 101 | 102 | # ╔═╡ 39d7205b-4de0-4e60-9def-39c3cdc09f52 103 | md""" 104 | ## Question 4 105 | 106 | $f \colon X \in \mathbb{R}^{n \times n} \longmapsto X^{-2}$, where $X$ is non-singular. Hint: use the chain rule and remember $d(X^{-1}) = -X^{-1} (dX) X^{-1}$ and $d(X^2)=X (dX) + (dX) X.$ 107 | """ 108 | 109 | # ╔═╡ fa193ad5-e527-4d48-8c39-e428252c1ccd 110 | md""" 111 | Your answer (with justification) goes here 112 | """ 113 | 114 | # ╔═╡ 3e80bec0-b8dc-406e-bc6b-b1a7d1df5f60 115 | # Your code goes here 116 | 117 | # ╔═╡ 00000000-0000-0000-0000-000000000001 118 | PLUTO_PROJECT_TOML_CONTENTS = """ 119 | [deps] 120 | """ 121 | 122 | # ╔═╡ 00000000-0000-0000-0000-000000000002 123 | PLUTO_MANIFEST_TOML_CONTENTS = """ 124 | # This file is machine-generated - editing it directly is not advised 125 | 126 | julia_version = "1.8.1" 127 | manifest_format = "2.0" 128 | project_hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709" 129 | 130 | [deps] 131 | """ 132 | 133 | # ╔═╡ Cell order: 134 | # ╟─f6cdf6d4-35cd-11ed-1c5c-db3e4aec3adb 135 | # ╠═6cc8e719-fb27-478c-a362-a51e65c152a9 136 | # ╟─d411f114-76e5-45b3-b257-8936227c45bc 137 | # ╟─14ac9e7e-206e-4472-af05-b3d1ccf0010f 138 | # ╟─5aed70bc-d518-4c0a-b650-cd6ff60f2db0 139 | # ╠═12e51959-e16d-424d-a663-e316adb78e0e 140 | # ╟─245f4f38-9aed-4d7b-b1e1-4294ac6c477f 141 | # ╠═f07be691-99c3-47ce-b963-c7452338f0fa 142 | # ╠═cd1d0fbe-5760-4100-ad49-7b94e368df3d 143 | # ╟─a36c286b-d6d6-4f9f-ad86-b4046a77663d 144 | # ╠═86a96dbb-c018-45b2-b6dd-35bd47051f7f 145 | # ╠═ed3beb6f-42ac-4787-b4f1-78169e53678b 146 | # ╠═4fcc5b25-0df2-4125-9e5a-9357e56f8e13 147 | # ╠═9be9d847-36ce-4461-aa85-5da3e82cc1ec 148 | # ╟─87c518d1-632d-4b27-9b4d-69bc2300b569 149 | # ╠═a2e57067-52c6-4a5c-95fd-ae655418fa48 150 | # ╠═1ef4387c-59f0-443d-8d8c-26aa8d1c1e0f 151 | # ╟─39d7205b-4de0-4e60-9def-39c3cdc09f52 152 | # ╠═fa193ad5-e527-4d48-8c39-e428252c1ccd 153 | # ╠═3e80bec0-b8dc-406e-bc6b-b1a7d1df5f60 154 | # ╟─00000000-0000-0000-0000-000000000001 155 | # ╟─00000000-0000-0000-0000-000000000002 156 | -------------------------------------------------------------------------------- /homeworks_old/hw5-gpu.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.8 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 956634aa-547b-11ed-2e14-1ff1f6d562d8 8 | begin 9 | using BenchmarkTools 10 | using Statistics 11 | 12 | BenchmarkTools.DEFAULT_PARAMETERS.seconds = 15.0 13 | end; 14 | 15 | # ╔═╡ 5950d5f0-e1f2-472b-ac4c-361c208bb9a7 16 | using CUDA 17 | 18 | # ╔═╡ d89ee739-b144-48a3-9e53-423d8351f75f 19 | md""" 20 | # GPU Demo Notebook 21 | In this short demo we are going to look at a simple example of running Julia code on the GPU and seeing what kind of performance boost we can get versus running on a CPU. The example will be the most fundamental GPU task: matrix multiplication. 22 | 23 | The point of this demo is to make sure you are able to run GPU code successfully as well as to show you a first compelling example of why GPUs are important for HPC (high performance computing). 24 | """ 25 | 26 | # ╔═╡ 801929aa-64be-4053-b3fa-8b00b9e4aa95 27 | N = 3000 28 | 29 | # ╔═╡ 96fe138c-3e80-4cb5-b1d3-62dba08f2257 30 | A = rand(N, N) 31 | 32 | # ╔═╡ d1828384-d821-4a2a-b19c-5e2bb7a88c43 33 | @benchmark $A * $A 34 | 35 | # ╔═╡ b1c5ce5a-d682-42d5-9bb5-cf07fb8313be 36 | md""" 37 | ## CUDA.jl 38 | CUDA.jl is the Julia package that lets you write Julia code that can run on CUDA-compatible (i.e. Nvidia) GPUs. To move your data `A` from CPU memory to GPU memory, all you have to do is run `A_gpu = CuArray(A)`. Then you can proceed as usual but computations involving only `A_gpu` will be run on the GPU instead of the CPU. 39 | """ 40 | 41 | # ╔═╡ 31ea1880-46c4-4a44-b3f8-d595d4040654 42 | A_gpu = CuArray(A) # the first time you run this cell will take a minute to run 43 | # while CUDA.jl compiles 44 | 45 | # ╔═╡ 924713fa-068f-4112-8e50-9f5c78b0644d 46 | # We need to use CUDA.@sync to account for the GPU time in the benchmark. 47 | @benchmark CUDA.@sync $A_gpu * $A_gpu 48 | 49 | # ╔═╡ ec53920a-625b-446c-ae95-f2f5a78c81dc 50 | md""" 51 | ## Accuracy 52 | Recall that computers generally store non-integer numbers in a [floating-point representation](https://en.wikipedia.org/wiki/Floating-point_arithmetic). You might be familiar with the fact that unlike addition over the reals, addition over floating point numbers is _not_ [associative](https://en.wikipedia.org/wiki/Associative_property). Consider the following example. 53 | """ 54 | 55 | # ╔═╡ c7afca91-ee61-4a66-9baf-4a11916a70e3 56 | let 57 | # using @show because if we just return `a` from the cell 58 | # Pluto would truncate to make it look nice 59 | @show a = (0.1 + 0.2) + 0.3 60 | @show b = 0.1 + (0.2 + 0.3) 61 | @show a - b # with real numbers this would be 0, but not with floats 62 | end 63 | 64 | # ╔═╡ b8cfabde-d51d-45ee-8a56-3282cfbfdfbd 65 | md""" 66 | Running matrix multiplication on the GPU will calculate many things in parallel and then add them up (this is why it is so much faster than the CPU). This different order of floating point operations means that the results could be slightly different due to the lack of associativity. Let's see what the difference is. 67 | """ 68 | 69 | # ╔═╡ ce9136e4-06c0-4caf-8e46-09653f40c7e4 70 | # the gpu_result.value is on the GPU, so we use Array(_) to move it back to the CPU 71 | # since you can't mix GPU memory and CPU memory in your calculation 72 | mean(abs.(A * A - Array(A_gpu * A_gpu))) 73 | 74 | # ╔═╡ 00000000-0000-0000-0000-000000000001 75 | PLUTO_PROJECT_TOML_CONTENTS = """ 76 | [deps] 77 | BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 78 | CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" 79 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 80 | 81 | [compat] 82 | BenchmarkTools = "~1.3.1" 83 | CUDA = "~3.12.0" 84 | """ 85 | 86 | # ╔═╡ 00000000-0000-0000-0000-000000000002 87 | PLUTO_MANIFEST_TOML_CONTENTS = """ 88 | # This file is machine-generated - editing it directly is not advised 89 | 90 | julia_version = "1.7.2" 91 | manifest_format = "2.0" 92 | 93 | [[deps.AbstractFFTs]] 94 | deps = ["ChainRulesCore", "LinearAlgebra"] 95 | git-tree-sha1 = "69f7020bd72f069c219b5e8c236c1fa90d2cb409" 96 | uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" 97 | version = "1.2.1" 98 | 99 | [[deps.Adapt]] 100 | deps = ["LinearAlgebra"] 101 | git-tree-sha1 = "195c5505521008abea5aee4f96930717958eac6f" 102 | uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" 103 | version = "3.4.0" 104 | 105 | [[deps.ArgTools]] 106 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 107 | 108 | [[deps.Artifacts]] 109 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 110 | 111 | [[deps.BFloat16s]] 112 | deps = ["LinearAlgebra", "Printf", "Random", "Test"] 113 | git-tree-sha1 = "a598ecb0d717092b5539dbbe890c98bac842b072" 114 | uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b" 115 | version = "0.2.0" 116 | 117 | [[deps.Base64]] 118 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 119 | 120 | [[deps.BenchmarkTools]] 121 | deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"] 122 | git-tree-sha1 = "4c10eee4af024676200bc7752e536f858c6b8f93" 123 | uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 124 | version = "1.3.1" 125 | 126 | [[deps.CEnum]] 127 | git-tree-sha1 = "eb4cb44a499229b3b8426dcfb5dd85333951ff90" 128 | uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" 129 | version = "0.4.2" 130 | 131 | [[deps.CUDA]] 132 | deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CompilerSupportLibraries_jll", "ExprTools", "GPUArrays", "GPUCompiler", "LLVM", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "SpecialFunctions", "TimerOutputs"] 133 | git-tree-sha1 = "49549e2c28ffb9cc77b3689dc10e46e6271e9452" 134 | uuid = "052768ef-5323-5732-b1bb-66c8b64840ba" 135 | version = "3.12.0" 136 | 137 | [[deps.ChainRulesCore]] 138 | deps = ["Compat", "LinearAlgebra", "SparseArrays"] 139 | git-tree-sha1 = "8a494fe0c4ae21047f28eb48ac968f0b8a6fcaa7" 140 | uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" 141 | version = "1.15.4" 142 | 143 | [[deps.ChangesOfVariables]] 144 | deps = ["ChainRulesCore", "LinearAlgebra", "Test"] 145 | git-tree-sha1 = "38f7a08f19d8810338d4f5085211c7dfa5d5bdd8" 146 | uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" 147 | version = "0.1.4" 148 | 149 | [[deps.Compat]] 150 | deps = ["Dates", "LinearAlgebra", "UUIDs"] 151 | git-tree-sha1 = "5856d3031cdb1f3b2b6340dfdc66b6d9a149a374" 152 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 153 | version = "4.2.0" 154 | 155 | [[deps.CompilerSupportLibraries_jll]] 156 | deps = ["Artifacts", "Libdl"] 157 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 158 | 159 | [[deps.Dates]] 160 | deps = ["Printf"] 161 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 162 | 163 | [[deps.DocStringExtensions]] 164 | deps = ["LibGit2"] 165 | git-tree-sha1 = "5158c2b41018c5f7eb1470d558127ac274eca0c9" 166 | uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 167 | version = "0.9.1" 168 | 169 | [[deps.Downloads]] 170 | deps = ["ArgTools", "LibCURL", "NetworkOptions"] 171 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 172 | 173 | [[deps.ExprTools]] 174 | git-tree-sha1 = "56559bbef6ca5ea0c0818fa5c90320398a6fbf8d" 175 | uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" 176 | version = "0.1.8" 177 | 178 | [[deps.GPUArrays]] 179 | deps = ["Adapt", "GPUArraysCore", "LLVM", "LinearAlgebra", "Printf", "Random", "Reexport", "Serialization", "Statistics"] 180 | git-tree-sha1 = "45d7deaf05cbb44116ba785d147c518ab46352d7" 181 | uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" 182 | version = "8.5.0" 183 | 184 | [[deps.GPUArraysCore]] 185 | deps = ["Adapt"] 186 | git-tree-sha1 = "6872f5ec8fd1a38880f027a26739d42dcda6691f" 187 | uuid = "46192b85-c4d5-4398-a991-12ede77f4527" 188 | version = "0.1.2" 189 | 190 | [[deps.GPUCompiler]] 191 | deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "TimerOutputs", "UUIDs"] 192 | git-tree-sha1 = "122d7bcc92abf94cf1a86281ad7a4d0e838ab9e0" 193 | uuid = "61eb1bfa-7361-4325-ad38-22787b887f55" 194 | version = "0.16.3" 195 | 196 | [[deps.InteractiveUtils]] 197 | deps = ["Markdown"] 198 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 199 | 200 | [[deps.InverseFunctions]] 201 | deps = ["Test"] 202 | git-tree-sha1 = "b3364212fb5d870f724876ffcd34dd8ec6d98918" 203 | uuid = "3587e190-3f89-42d0-90ee-14403ec27112" 204 | version = "0.1.7" 205 | 206 | [[deps.IrrationalConstants]] 207 | git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151" 208 | uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" 209 | version = "0.1.1" 210 | 211 | [[deps.JLLWrappers]] 212 | deps = ["Preferences"] 213 | git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" 214 | uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" 215 | version = "1.4.1" 216 | 217 | [[deps.JSON]] 218 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 219 | git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e" 220 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 221 | version = "0.21.3" 222 | 223 | [[deps.LLVM]] 224 | deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"] 225 | git-tree-sha1 = "e7e9184b0bf0158ac4e4aa9daf00041b5909bf1a" 226 | uuid = "929cbde3-209d-540e-8aea-75f648917ca0" 227 | version = "4.14.0" 228 | 229 | [[deps.LLVMExtra_jll]] 230 | deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg", "TOML"] 231 | git-tree-sha1 = "771bfe376249626d3ca12bcd58ba243d3f961576" 232 | uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab" 233 | version = "0.0.16+0" 234 | 235 | [[deps.LazyArtifacts]] 236 | deps = ["Artifacts", "Pkg"] 237 | uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" 238 | 239 | [[deps.LibCURL]] 240 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 241 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 242 | 243 | [[deps.LibCURL_jll]] 244 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 245 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 246 | 247 | [[deps.LibGit2]] 248 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 249 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 250 | 251 | [[deps.LibSSH2_jll]] 252 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 253 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 254 | 255 | [[deps.Libdl]] 256 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 257 | 258 | [[deps.LinearAlgebra]] 259 | deps = ["Libdl", "libblastrampoline_jll"] 260 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 261 | 262 | [[deps.LogExpFunctions]] 263 | deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"] 264 | git-tree-sha1 = "94d9c52ca447e23eac0c0f074effbcd38830deb5" 265 | uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" 266 | version = "0.3.18" 267 | 268 | [[deps.Logging]] 269 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 270 | 271 | [[deps.Markdown]] 272 | deps = ["Base64"] 273 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 274 | 275 | [[deps.MbedTLS_jll]] 276 | deps = ["Artifacts", "Libdl"] 277 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 278 | 279 | [[deps.Mmap]] 280 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 281 | 282 | [[deps.MozillaCACerts_jll]] 283 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 284 | 285 | [[deps.NetworkOptions]] 286 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 287 | 288 | [[deps.OpenBLAS_jll]] 289 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 290 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 291 | 292 | [[deps.OpenLibm_jll]] 293 | deps = ["Artifacts", "Libdl"] 294 | uuid = "05823500-19ac-5b8b-9628-191a04bc5112" 295 | 296 | [[deps.OpenSpecFun_jll]] 297 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] 298 | git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" 299 | uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" 300 | version = "0.5.5+0" 301 | 302 | [[deps.Parsers]] 303 | deps = ["Dates"] 304 | git-tree-sha1 = "3d5bf43e3e8b412656404ed9466f1dcbf7c50269" 305 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 306 | version = "2.4.0" 307 | 308 | [[deps.Pkg]] 309 | deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 310 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 311 | 312 | [[deps.Preferences]] 313 | deps = ["TOML"] 314 | git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" 315 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 316 | version = "1.3.0" 317 | 318 | [[deps.Printf]] 319 | deps = ["Unicode"] 320 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 321 | 322 | [[deps.Profile]] 323 | deps = ["Printf"] 324 | uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" 325 | 326 | [[deps.REPL]] 327 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 328 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 329 | 330 | [[deps.Random]] 331 | deps = ["SHA", "Serialization"] 332 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 333 | 334 | [[deps.Random123]] 335 | deps = ["Random", "RandomNumbers"] 336 | git-tree-sha1 = "7a1a306b72cfa60634f03a911405f4e64d1b718b" 337 | uuid = "74087812-796a-5b5d-8853-05524746bad3" 338 | version = "1.6.0" 339 | 340 | [[deps.RandomNumbers]] 341 | deps = ["Random", "Requires"] 342 | git-tree-sha1 = "043da614cc7e95c703498a491e2c21f58a2b8111" 343 | uuid = "e6cf234a-135c-5ec9-84dd-332b85af5143" 344 | version = "1.5.3" 345 | 346 | [[deps.Reexport]] 347 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 348 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 349 | version = "1.2.2" 350 | 351 | [[deps.Requires]] 352 | deps = ["UUIDs"] 353 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7" 354 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 355 | version = "1.3.0" 356 | 357 | [[deps.SHA]] 358 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 359 | 360 | [[deps.Serialization]] 361 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 362 | 363 | [[deps.Sockets]] 364 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 365 | 366 | [[deps.SparseArrays]] 367 | deps = ["LinearAlgebra", "Random"] 368 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 369 | 370 | [[deps.SpecialFunctions]] 371 | deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] 372 | git-tree-sha1 = "d75bda01f8c31ebb72df80a46c88b25d1c79c56d" 373 | uuid = "276daf66-3868-5448-9aa4-cd146d93841b" 374 | version = "2.1.7" 375 | 376 | [[deps.Statistics]] 377 | deps = ["LinearAlgebra", "SparseArrays"] 378 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 379 | 380 | [[deps.TOML]] 381 | deps = ["Dates"] 382 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 383 | 384 | [[deps.Tar]] 385 | deps = ["ArgTools", "SHA"] 386 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 387 | 388 | [[deps.Test]] 389 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 390 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 391 | 392 | [[deps.TimerOutputs]] 393 | deps = ["ExprTools", "Printf"] 394 | git-tree-sha1 = "9dfcb767e17b0849d6aaf85997c98a5aea292513" 395 | uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" 396 | version = "0.5.21" 397 | 398 | [[deps.UUIDs]] 399 | deps = ["Random", "SHA"] 400 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 401 | 402 | [[deps.Unicode]] 403 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 404 | 405 | [[deps.Zlib_jll]] 406 | deps = ["Libdl"] 407 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 408 | 409 | [[deps.libblastrampoline_jll]] 410 | deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] 411 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 412 | 413 | [[deps.nghttp2_jll]] 414 | deps = ["Artifacts", "Libdl"] 415 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 416 | 417 | [[deps.p7zip_jll]] 418 | deps = ["Artifacts", "Libdl"] 419 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 420 | """ 421 | 422 | # ╔═╡ Cell order: 423 | # ╠═956634aa-547b-11ed-2e14-1ff1f6d562d8 424 | # ╟─d89ee739-b144-48a3-9e53-423d8351f75f 425 | # ╠═801929aa-64be-4053-b3fa-8b00b9e4aa95 426 | # ╠═96fe138c-3e80-4cb5-b1d3-62dba08f2257 427 | # ╠═d1828384-d821-4a2a-b19c-5e2bb7a88c43 428 | # ╟─b1c5ce5a-d682-42d5-9bb5-cf07fb8313be 429 | # ╠═5950d5f0-e1f2-472b-ac4c-361c208bb9a7 430 | # ╠═31ea1880-46c4-4a44-b3f8-d595d4040654 431 | # ╠═924713fa-068f-4112-8e50-9f5c78b0644d 432 | # ╟─ec53920a-625b-446c-ae95-f2f5a78c81dc 433 | # ╠═c7afca91-ee61-4a66-9baf-4a11916a70e3 434 | # ╟─b8cfabde-d51d-45ee-8a56-3282cfbfdfbd 435 | # ╠═ce9136e4-06c0-4caf-8e46-09653f40c7e4 436 | # ╟─00000000-0000-0000-0000-000000000001 437 | # ╟─00000000-0000-0000-0000-000000000002 438 | -------------------------------------------------------------------------------- /homeworks_old/images/atmosphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/homeworks_old/images/atmosphere.png -------------------------------------------------------------------------------- /homeworks_old/images/lineland.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/homeworks_old/images/lineland.png -------------------------------------------------------------------------------- /homeworks_old2/hw10.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.31 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 9ea8ed00-7484-11ee-0824-0b5807b13a8f 8 | md""" 9 | Homework 10 of the MIT Course [_Julia: solving real-world problems with computation_](https://github.com/mitmath/JuliaComputation) 10 | 11 | Release date: Thursday, Nov 28th, 2023 (version 1) 12 | 13 | **Due date: Thursday, Dec 5th, 2023 at 11:59pm EST** 14 | 15 | **Instructions: Submit a url to your github repository to Canvas.** 16 | """ 17 | 18 | # ╔═╡ 16086277-f9a9-4866-80d6-181d1d18519a 19 | md""" 20 | # Google Hashcode Optimization Challenge: Repository Submission 21 | 22 | ### Overview 23 | This final project report is your opportunity to showcase the culmination of your skills and knowledge gained throughout the course. You've already made it quite a ways, completing various parts through hw6 and hw8. Your repository will now be graded based on the following attributes, each carrying a specific weight towards your final score. 24 | 25 | ### Grading Attributes and Tasks 26 | 27 | #### 1. Documentation (3/10 Points) 28 | **Task**: Create a comprehensive documentation page and a clear README for your Julia package. 29 | 30 | The documentation website will serve as a report. It should contain the following pages: 31 | 32 | - A tutorial aimed at users of your code 33 | - A list of all the docstrings 34 | - A mathematical description of your algorithms 35 | - A critical discussion of their implementation and performance 36 | - Ensure your documentation covers all aspects of using your package. 37 | - The README should provide a quick start guide, installation instructions, and examples. 38 | 39 | Note, this takes a particularly heavy weight in the project. This is because you will not be submissing a report. The repository is the report for itself! For documenation guidance, please see [Julia Reach Dev Docs](https://juliareach.github.io/JuliaReachDevDocs/latest/guidelines/) 40 | 41 | #### 2. Types for Storing Problem Instances and Solutions (2/10 Points) 42 | **Task**: Develop and document custom types for storing problem instances and solutions. 43 | - Focus on the efficiency and appropriateness of the types for the given problem. 44 | - Document how these types are used within the package. 45 | 46 | Most of these points will be awarded by demonstrating the value of the custom type. Put yourself in the shoes of someone else who might be using the package, would they understand how to use your custom type? 47 | 48 | #### 3. Functions for Checking the Feasibility of a Solution (1/10 Points) 49 | **Task**: Document the functions you have developed for checking the feasibility of solutions. 50 | - Emphasize the quality of documentation, explaining how these functions integrate into the overall package. 51 | 52 | We'd like to understand how you check your solution (likely using HashCode2014). Demonstrate how this check should interact with your custom types. You don't have to overcomplicate this part. It may also be something good to include in the README. 53 | 54 | #### 4. Algorithms for Generating a Good Solution (1/10 Points) 55 | **Task**: Implement algorithms that generate effective solutions and beat Guillaume's baseline. 56 | - Document the algorithm design and its efficiency in terms of both distance and computation time. 57 | - Specific targets: Beat Guillaume's baseline in both 54000s and 18000s scenarios (0.25 points for beating each time and distance per scenario). 58 | 59 | #### 5. Finding an Upper Bound on the Best Objective Value (1/10 Points) 60 | **Task**: Develop a method to find an upper bound on the best objective value that beats or matches Guillaume's baseline. 61 | - Document your approach and how it integrates with the overall problem-solving strategy. 62 | 63 | #### 6. Competition Points (1/10 Points) 64 | **Task**: Achieve the best performance in one of the following categories: fastest solution, longest distance, or lowest bound with a correct proof. In each of these cases, it has to match or exceed Guillaume's baseline in the other attributes (i.e. a fast solution that doesn't at least match Guillaume's baseline doesn't get awarded the point). 65 | 66 | These are the hardest points to get, so don't fret too much! 90% is still an A 67 | 68 | #### 7. Unit Tests and CI/CD (1/10 Points) 69 | **Task**: Expand the existing CI/CD setup with at least one more relevant unit test (so at least two tests that have specific purpose). 70 | - Document the purpose and implementation of the new test. 71 | """ 72 | 73 | # ╔═╡ 75aab5f9-458f-452d-bd22-41e5ca5b5b97 74 | md""" 75 | # Algorithm Suggestions for Performance Improvement in Distance Calculation 76 | 77 | The use of one of these algorithms is not required. But try looking into them and think if they could be applied to the problem. This package can be a wonderful addition to your github profile, and the use of these algorithms can be quite shiny in job or internship applications... 78 | 79 | 1. **Max Flow Algorithms** 80 | - *Ford-Fulkerson Algorithm*: A method for finding the maximum flow in a flow network. 81 | - Resource: [Ford-Fulkerson Algorithm](https://www.geeksforgeeks.org/ford-fulkerson-algorithm-for-maximum-flow-problem/) 82 | 83 | 2. **Graph Traversal Algorithms** 84 | - *Dijkstra’s Algorithm*: Used for finding the shortest paths between nodes in a graph. 85 | - Resource: [Dijkstra’s Algorithm](https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/) 86 | 87 | 3. **Greedy Algorithms** 88 | - *Nearest Neighbor Algorithm*: A heuristic used in routing problems like the Traveling Salesman Problem. 89 | - Resource: [Nearest Neighbor Algorithm](https://blog.devgenius.io/traveling-salesman-problem-nearest-neighbor-algorithm-solution-e78399d0ab0c) 90 | 91 | 4. **Dynamic Programming** 92 | - *Bellman-Ford Algorithm*: Computes shortest paths in a weighted graph, useful for negative weight edges. 93 | - Resource: [Bellman-Ford Algorithm](https://www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/) 94 | 95 | 5. **Metaheuristic Algorithms** 96 | - *Genetic Algorithms*: Simulates natural selection, useful for complex optimization problems. 97 | - Resource: [Genetic Algorithms](https://www.geeksforgeeks.org/genetic-algorithms/) 98 | 99 | 6. **Integer Linear Programming (ILP)** 100 | - *Branch and Bound*: A method for solving integer linear programming problems. 101 | - Resource: [Branch and Bound Method](https://www.geeksforgeeks.org/introduction-to-branch-and-bound-data-structures-and-algorithms-tutorial/) 102 | 103 | """ 104 | 105 | # ╔═╡ Cell order: 106 | # ╟─9ea8ed00-7484-11ee-0824-0b5807b13a8f 107 | # ╟─16086277-f9a9-4866-80d6-181d1d18519a 108 | # ╟─75aab5f9-458f-452d-bd22-41e5ca5b5b97 109 | -------------------------------------------------------------------------------- /homeworks_old2/hw6.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.27 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 25c1f001-8e4b-41aa-926e-9ff1550eae35 8 | begin 9 | using PlutoTeachingTools 10 | end 11 | 12 | # ╔═╡ 9ea8ed00-7484-11ee-0824-0b5807b13a8f 13 | md""" 14 | Homework 6 of the MIT Course [_Julia: solving real-world problems with computation_](https://github.com/mitmath/JuliaComputation) 15 | 16 | Release date: Thursday, Oct 27, 2023 (version 1) 17 | 18 | **Due date: Thursday, Nov 2, 2023 at 11:59pm EST** 19 | 20 | **Instructions: Submit a pdf to canvas by selecting Pluto export to PDF.** 21 | 22 | Submission by: Jazzy Doe (jazz@mit.edu) 23 | """ 24 | 25 | # ╔═╡ 48b82457-95d0-4ccc-bec0-8d40e01760f3 26 | student = (name = "Jazzy Doe", kerberos_id = "jazz") 27 | 28 | # ╔═╡ 16086277-f9a9-4866-80d6-181d1d18519a 29 | md""" 30 | This homework is to follow up on your progress for Guillaume's challenge problem **(https://gdalle.github.io/IntroJulia/challenge.html)**. 31 | This counts as equal weight to other homeworks, which equates to 25% of the challenge. These are the easy points, but to help you get started on the project. 32 | """ 33 | 34 | # ╔═╡ 08165c83-3772-49e7-96c9-ee133708b6a8 35 | md""" 36 | !!! danger "Task 1" 37 | Form a group of 2 students (message on piazza if you're looking for someone, or if you'd like to form a group of 3) 38 | """ 39 | 40 | # ╔═╡ 14a6f7d8-1be4-4a8b-95f1-64330fef13b8 41 | md""" 42 | > 43 | """ 44 | 45 | # ╔═╡ e430eb66-1a00-4d7d-990c-7dbbde96cc8a 46 | 47 | 48 | # ╔═╡ 09ba7470-55f6-437c-910f-48f43eb3ff6a 49 | md""" 50 | !!! danger "Task 2" 51 | Create a Julia Package as a Github Repository (can be empty, 1 per team) 52 | """ 53 | 54 | # ╔═╡ ec973d54-d65c-415a-8ffd-46f10182cfca 55 | 56 | md""" 57 | For guidance, reference Tuesday's lecture Oct 17th: 58 | > 59 | """ 60 | 61 | 62 | # ╔═╡ 2ba3f41a-07c0-4b42-91e1-ebb35e9eeefd 63 | 64 | 65 | # ╔═╡ 2e56a5c5-e90d-4840-bce9-1213fcf8c24e 66 | md""" 67 | !!! danger "Task 3" 68 | Benchmark the random walk example given and record performance 69 | """ 70 | 71 | # ╔═╡ 61df1e85-3b98-497a-8e12-906cb3c0de44 72 | 73 | 74 | # ╔═╡ a969e83b-cdd1-42b4-afa5-b8bc51c32cbc 75 | md""" 76 | !!! danger "Task 3" 77 | Come up with at least a slight improvement, improving either Total Distance or CPU time. Record your time in the groups spreadsheet. 78 | """ 79 | 80 | # ╔═╡ 51d27564-c911-4c4f-8f20-9023273bcf60 81 | hint(md" 82 | You could consider one of the following approaches: 83 | - Adjusting the random walk to avoid previously explored paths 84 | - Directed random walk (cars have different probabilities of North/South/East/West route choices) 85 | - ect 86 | ") 87 | 88 | # ╔═╡ 6d68647b-10ed-447b-8ffd-7e807144fdbf 89 | 90 | 91 | # ╔═╡ 00000000-0000-0000-0000-000000000001 92 | PLUTO_PROJECT_TOML_CONTENTS = """ 93 | [deps] 94 | PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" 95 | 96 | [compat] 97 | PlutoTeachingTools = "~0.2.13" 98 | """ 99 | 100 | # ╔═╡ 00000000-0000-0000-0000-000000000002 101 | PLUTO_MANIFEST_TOML_CONTENTS = """ 102 | # This file is machine-generated - editing it directly is not advised 103 | 104 | julia_version = "1.8.5" 105 | manifest_format = "2.0" 106 | project_hash = "7a42974596e9e12c27f0417f760c666a50853d11" 107 | 108 | [[deps.AbstractPlutoDingetjes]] 109 | deps = ["Pkg"] 110 | git-tree-sha1 = "91bd53c39b9cbfb5ef4b015e8b582d344532bd0a" 111 | uuid = "6e696c72-6542-2067-7265-42206c756150" 112 | version = "1.2.0" 113 | 114 | [[deps.ArgTools]] 115 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 116 | version = "1.1.1" 117 | 118 | [[deps.Artifacts]] 119 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 120 | 121 | [[deps.Base64]] 122 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 123 | 124 | [[deps.CodeTracking]] 125 | deps = ["InteractiveUtils", "UUIDs"] 126 | git-tree-sha1 = "c0216e792f518b39b22212127d4a84dc31e4e386" 127 | uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" 128 | version = "1.3.5" 129 | 130 | [[deps.ColorTypes]] 131 | deps = ["FixedPointNumbers", "Random"] 132 | git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4" 133 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 134 | version = "0.11.4" 135 | 136 | [[deps.CompilerSupportLibraries_jll]] 137 | deps = ["Artifacts", "Libdl"] 138 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 139 | version = "1.0.1+0" 140 | 141 | [[deps.Dates]] 142 | deps = ["Printf"] 143 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 144 | 145 | [[deps.Distributed]] 146 | deps = ["Random", "Serialization", "Sockets"] 147 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 148 | 149 | [[deps.Downloads]] 150 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 151 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 152 | version = "1.6.0" 153 | 154 | [[deps.FileWatching]] 155 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 156 | 157 | [[deps.FixedPointNumbers]] 158 | deps = ["Statistics"] 159 | git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" 160 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 161 | version = "0.8.4" 162 | 163 | [[deps.Formatting]] 164 | deps = ["Printf"] 165 | git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8" 166 | uuid = "59287772-0a20-5a39-b81b-1366585eb4c0" 167 | version = "0.4.2" 168 | 169 | [[deps.Hyperscript]] 170 | deps = ["Test"] 171 | git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9" 172 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" 173 | version = "0.0.4" 174 | 175 | [[deps.HypertextLiteral]] 176 | deps = ["Tricks"] 177 | git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9" 178 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 179 | version = "0.9.4" 180 | 181 | [[deps.IOCapture]] 182 | deps = ["Logging", "Random"] 183 | git-tree-sha1 = "d75853a0bdbfb1ac815478bacd89cd27b550ace6" 184 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 185 | version = "0.2.3" 186 | 187 | [[deps.InteractiveUtils]] 188 | deps = ["Markdown"] 189 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 190 | 191 | [[deps.JSON]] 192 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 193 | git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" 194 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 195 | version = "0.21.4" 196 | 197 | [[deps.JuliaInterpreter]] 198 | deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] 199 | git-tree-sha1 = "0592b1810613d1c95eeebcd22dc11fba186c2a57" 200 | uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" 201 | version = "0.9.26" 202 | 203 | [[deps.LaTeXStrings]] 204 | git-tree-sha1 = "f2355693d6778a178ade15952b7ac47a4ff97996" 205 | uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" 206 | version = "1.3.0" 207 | 208 | [[deps.Latexify]] 209 | deps = ["Formatting", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Printf", "Requires"] 210 | git-tree-sha1 = "f428ae552340899a935973270b8d98e5a31c49fe" 211 | uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" 212 | version = "0.16.1" 213 | 214 | [[deps.LibCURL]] 215 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 216 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 217 | version = "0.6.3" 218 | 219 | [[deps.LibCURL_jll]] 220 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 221 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 222 | version = "7.84.0+0" 223 | 224 | [[deps.LibGit2]] 225 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 226 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 227 | 228 | [[deps.LibSSH2_jll]] 229 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 230 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 231 | version = "1.10.2+0" 232 | 233 | [[deps.Libdl]] 234 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 235 | 236 | [[deps.LinearAlgebra]] 237 | deps = ["Libdl", "libblastrampoline_jll"] 238 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 239 | 240 | [[deps.Logging]] 241 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 242 | 243 | [[deps.LoweredCodeUtils]] 244 | deps = ["JuliaInterpreter"] 245 | git-tree-sha1 = "60168780555f3e663c536500aa790b6368adc02a" 246 | uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" 247 | version = "2.3.0" 248 | 249 | [[deps.MIMEs]] 250 | git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" 251 | uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" 252 | version = "0.1.4" 253 | 254 | [[deps.MacroTools]] 255 | deps = ["Markdown", "Random"] 256 | git-tree-sha1 = "9ee1618cbf5240e6d4e0371d6f24065083f60c48" 257 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" 258 | version = "0.5.11" 259 | 260 | [[deps.Markdown]] 261 | deps = ["Base64"] 262 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 263 | 264 | [[deps.MbedTLS_jll]] 265 | deps = ["Artifacts", "Libdl"] 266 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 267 | version = "2.28.0+0" 268 | 269 | [[deps.Mmap]] 270 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 271 | 272 | [[deps.MozillaCACerts_jll]] 273 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 274 | version = "2022.2.1" 275 | 276 | [[deps.NetworkOptions]] 277 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 278 | version = "1.2.0" 279 | 280 | [[deps.OpenBLAS_jll]] 281 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 282 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 283 | version = "0.3.20+0" 284 | 285 | [[deps.OrderedCollections]] 286 | git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3" 287 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 288 | version = "1.6.2" 289 | 290 | [[deps.Parsers]] 291 | deps = ["Dates", "PrecompileTools", "UUIDs"] 292 | git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" 293 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 294 | version = "2.7.2" 295 | 296 | [[deps.Pkg]] 297 | deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 298 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 299 | version = "1.8.0" 300 | 301 | [[deps.PlutoHooks]] 302 | deps = ["InteractiveUtils", "Markdown", "UUIDs"] 303 | git-tree-sha1 = "072cdf20c9b0507fdd977d7d246d90030609674b" 304 | uuid = "0ff47ea0-7a50-410d-8455-4348d5de0774" 305 | version = "0.0.5" 306 | 307 | [[deps.PlutoLinks]] 308 | deps = ["FileWatching", "InteractiveUtils", "Markdown", "PlutoHooks", "Revise", "UUIDs"] 309 | git-tree-sha1 = "8f5fa7056e6dcfb23ac5211de38e6c03f6367794" 310 | uuid = "0ff47ea0-7a50-410d-8455-4348d5de0420" 311 | version = "0.1.6" 312 | 313 | [[deps.PlutoTeachingTools]] 314 | deps = ["Downloads", "HypertextLiteral", "LaTeXStrings", "Latexify", "Markdown", "PlutoLinks", "PlutoUI", "Random"] 315 | git-tree-sha1 = "542de5acb35585afcf202a6d3361b430bc1c3fbd" 316 | uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" 317 | version = "0.2.13" 318 | 319 | [[deps.PlutoUI]] 320 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] 321 | git-tree-sha1 = "e47cd150dbe0443c3a3651bc5b9cbd5576ab75b7" 322 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 323 | version = "0.7.52" 324 | 325 | [[deps.PrecompileTools]] 326 | deps = ["Preferences"] 327 | git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" 328 | uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" 329 | version = "1.2.0" 330 | 331 | [[deps.Preferences]] 332 | deps = ["TOML"] 333 | git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" 334 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 335 | version = "1.4.1" 336 | 337 | [[deps.Printf]] 338 | deps = ["Unicode"] 339 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 340 | 341 | [[deps.REPL]] 342 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 343 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 344 | 345 | [[deps.Random]] 346 | deps = ["SHA", "Serialization"] 347 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 348 | 349 | [[deps.Reexport]] 350 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 351 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 352 | version = "1.2.2" 353 | 354 | [[deps.Requires]] 355 | deps = ["UUIDs"] 356 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7" 357 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 358 | version = "1.3.0" 359 | 360 | [[deps.Revise]] 361 | deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "Requires", "UUIDs", "Unicode"] 362 | git-tree-sha1 = "ba168f8fc36bf83c8d0573d464b7aab0f8a81623" 363 | uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" 364 | version = "3.5.7" 365 | 366 | [[deps.SHA]] 367 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 368 | version = "0.7.0" 369 | 370 | [[deps.Serialization]] 371 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 372 | 373 | [[deps.Sockets]] 374 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 375 | 376 | [[deps.SparseArrays]] 377 | deps = ["LinearAlgebra", "Random"] 378 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 379 | 380 | [[deps.Statistics]] 381 | deps = ["LinearAlgebra", "SparseArrays"] 382 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 383 | 384 | [[deps.TOML]] 385 | deps = ["Dates"] 386 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 387 | version = "1.0.0" 388 | 389 | [[deps.Tar]] 390 | deps = ["ArgTools", "SHA"] 391 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 392 | version = "1.10.1" 393 | 394 | [[deps.Test]] 395 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 396 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 397 | 398 | [[deps.Tricks]] 399 | git-tree-sha1 = "eae1bb484cd63b36999ee58be2de6c178105112f" 400 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" 401 | version = "0.1.8" 402 | 403 | [[deps.URIs]] 404 | git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b" 405 | uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" 406 | version = "1.5.1" 407 | 408 | [[deps.UUIDs]] 409 | deps = ["Random", "SHA"] 410 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 411 | 412 | [[deps.Unicode]] 413 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 414 | 415 | [[deps.Zlib_jll]] 416 | deps = ["Libdl"] 417 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 418 | version = "1.2.12+3" 419 | 420 | [[deps.libblastrampoline_jll]] 421 | deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] 422 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 423 | version = "5.1.1+0" 424 | 425 | [[deps.nghttp2_jll]] 426 | deps = ["Artifacts", "Libdl"] 427 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 428 | version = "1.48.0+0" 429 | 430 | [[deps.p7zip_jll]] 431 | deps = ["Artifacts", "Libdl"] 432 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 433 | version = "17.4.0+0" 434 | """ 435 | 436 | # ╔═╡ Cell order: 437 | # ╟─9ea8ed00-7484-11ee-0824-0b5807b13a8f 438 | # ╠═48b82457-95d0-4ccc-bec0-8d40e01760f3 439 | # ╟─16086277-f9a9-4866-80d6-181d1d18519a 440 | # ╠═25c1f001-8e4b-41aa-926e-9ff1550eae35 441 | # ╟─08165c83-3772-49e7-96c9-ee133708b6a8 442 | # ╟─14a6f7d8-1be4-4a8b-95f1-64330fef13b8 443 | # ╠═e430eb66-1a00-4d7d-990c-7dbbde96cc8a 444 | # ╟─09ba7470-55f6-437c-910f-48f43eb3ff6a 445 | # ╟─ec973d54-d65c-415a-8ffd-46f10182cfca 446 | # ╠═2ba3f41a-07c0-4b42-91e1-ebb35e9eeefd 447 | # ╟─2e56a5c5-e90d-4840-bce9-1213fcf8c24e 448 | # ╠═61df1e85-3b98-497a-8e12-906cb3c0de44 449 | # ╟─a969e83b-cdd1-42b4-afa5-b8bc51c32cbc 450 | # ╟─51d27564-c911-4c4f-8f20-9023273bcf60 451 | # ╠═6d68647b-10ed-447b-8ffd-7e807144fdbf 452 | # ╟─00000000-0000-0000-0000-000000000001 453 | # ╟─00000000-0000-0000-0000-000000000002 454 | -------------------------------------------------------------------------------- /homeworks_old2/hw8.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.31 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 25c1f001-8e4b-41aa-926e-9ff1550eae35 8 | begin 9 | using PlutoTeachingTools 10 | end 11 | 12 | # ╔═╡ 9ea8ed00-7484-11ee-0824-0b5807b13a8f 13 | md""" 14 | Homework 8 of the MIT Course [_Julia: solving real-world problems with computation_](https://github.com/mitmath/JuliaComputation) 15 | 16 | Release date: Thursday, Nov 9th, 2023 (version 1) 17 | 18 | **Due date: Thursday, Nov 17th, 2023 at 11:59pm EST** 19 | 20 | **Instructions: Submit a pdf to canvas by selecting Pluto export to PDF.** 21 | 22 | Submission by: Jazzy Doe (jazz@mit.edu) 23 | """ 24 | 25 | # ╔═╡ 48b82457-95d0-4ccc-bec0-8d40e01760f3 26 | student = (name = "Jazzy Doe", kerberos_id = "jazz") 27 | 28 | # ╔═╡ 16086277-f9a9-4866-80d6-181d1d18519a 29 | md""" 30 | **Project Second Check-In** 31 | This homework is to follow up on your progress for Guillaume's challenge problem **(https://gdalle.github.io/IntroJulia/challenge.html)**. 32 | This counts as equal weight to other homeworks, which equates to 25% of the challenge. 33 | 34 | As you progress in developing your Julia package for the semester project, it's essential to build upon a foundation of good practices that not only facilitate code functionality but also ensure maintainability, efficiency, and collaboration. This check-in is designed to reinforce the critical components required for a robust Julia package: 35 | 36 | **Types for Storing Problem Instances and Solutions**: Custom types are the backbone of your package, allowing you to define structures that represent complex data and operations in an intuitive and efficient way. 37 | 38 | **Functions for Checking the Feasibility and Computing Objective Values**: Functions that operate on your custom types should not only perform the necessary computations but also validate the feasibility of solutions within the context of the problem. 39 | 40 | **Algorithms for Generating Good Solutions and Finding Upper Bounds**: Good solutions are born from algorithms that efficiently navigate the problem space, guided by bounds that benchmark the solution quality. 41 | 42 | **Thorough Unit Tests**: These are your first line of defense against bugs, ensuring each part of your code behaves as expected, even as you make changes and add new features. 43 | 44 | **Detailed Documentation**: Well-documented code is as valuable as well-written code, providing clarity on the usage and purpose of your package's components. 45 | 46 | **Continuous Integration**: A CI system automates the testing of your codebase, ensuring that changes do not break existing functionality, and helps maintain code quality throughout the development process. 47 | 48 | The following sections of this assignment will delve into each of these areas, helping you to strengthen your package by applying these principles. The sections are interrelated, and while they can be addressed sequentially, you may find it beneficial to read through the entire assignment first to understand how each part complements the others. This way, you can plan your approach, decide on the order of tasks, and ensure that your work is cohesive and strategically aligned with the project's objectives. 49 | 50 | As you embark on this check-in, remember that the goal is to deepen your understanding of these principles and to directly apply them to your project, illustrating your mastery of both Julia and the best practices in software development. 51 | """ 52 | 53 | # ╔═╡ 3d6772be-2ad6-4f9b-94a6-2cd75252d9cd 54 | md""" 55 | # 1. Effectiveness of a Custom Type Design 56 | """ 57 | 58 | # ╔═╡ 6a501c3e-0bae-428d-b8cd-2b430afbb6b5 59 | md""" 60 | **Introduction**: In Julia, the design of custom types is not only about storing data but also about aligning with the language's multiple dispatch system to write more efficient and clearer code. This approach can significantly optimize the execution time, especially in computational tasks such as optimization problems, by ensuring that operations are specialized for the types of data they operate on. 61 | """ 62 | 63 | # ╔═╡ d32ee0f3-4009-41ff-8bd3-04d8e92bfa8b 64 | md""" 65 | The routing problem involves managing complex data structures that represent the city's layout and the various routes within it. For example, an effectively designed custom type, which we might call RouteGrid, could encapsulate the nuances of this layout, such as distances between points, connectivity, and traffic patterns. By creating a type tailored to these specific needs, algorithms can more directly address the problem's constraints, such as minimizing travel distance or time, potentially leading to more efficient and effective routing solutions. **The custom type can also facilitate the implementation of methods that manipulate this data**, taking advantage of Julia's multiple dispatch to provide optimized performance for operations like route addition, deletion, or adjustment. 66 | """ 67 | 68 | # ╔═╡ 08165c83-3772-49e7-96c9-ee133708b6a8 69 | md""" 70 | !!! danger "Task 1" 71 | Create a custom type, such as RouteGrid type that encapsulates the city's grid layout and the routes, and provide documentation on it's use. 72 | - The type should include fields that represent the necessary components of the grid, such as intersections, streets, and delivery endpoints. 73 | - Include methods for common operations that will be performed on the grid, such as adding a route or checking for an intersection. 74 | If you are further along in the project, you are also welcome to create a different custom type, not relating to the manipulation of the city's grid layout and routes. This problem will be graded on the usefulness of the custom type and its supporting documentation. 75 | """ 76 | 77 | # ╔═╡ e430eb66-1a00-4d7d-990c-7dbbde96cc8a 78 | md""" 79 | Link to Documentation: https://www... 80 | Link to Type in Repository Code: https://www... 81 | """ 82 | 83 | # ╔═╡ 99b8ff51-5b21-45d9-bca8-1d21ff37f23b 84 | md""" 85 | # 2. Solution Feasibility: Understanding the Bounds of the Problem 86 | """ 87 | 88 | # ╔═╡ c5e62fd0-a827-4efe-8da8-dcc77b7a5d3d 89 | md""" 90 | **Introduction**: Estimating an upper bound for optimization problems is crucial for evaluating algorithmic performance and understanding the scope of potential solutions. A well-calculated upper bound can guide decision-making and heuristic development. """ 91 | 92 | # ╔═╡ fd90f0f3-a4a3-445b-9b84-b12cae29dbcc 93 | md""" 94 | Calculating an improved upper bound on the optimal route distance is directly applicable to assessing the efficiency of the routing algorithms used in the project. By establishing a more realistic upper bound that accounts for the actual distribution of delivery points and the city's street layout, you can better evaluate your routing solutions against this benchmark. This encourages the development of algorithms that do not just seek any solution but strive for the optimality within the bounds of the problem's constraints. It can guide the algorithm refinement process, helping to prioritize which aspects of the algorithm need improvement to approach or surpass the theoretical upper bound. 95 | """ 96 | 97 | # ╔═╡ 09ba7470-55f6-437c-910f-48f43eb3ff6a 98 | md""" 99 | !!! danger "Task 2.1" 100 | Propose and document an algorithm for calculating an improved upper bound for the objective value. 101 | - Ideally, your algorithm should leverage the structure of the city grid and the distribution of delivery points. (And not just the total distance of roads in city, the first obvious upper bound) 102 | - Justify your algorithm's approach and its potential impact on solution quality. 103 | """ 104 | 105 | # ╔═╡ 2ba3f41a-07c0-4b42-91e1-ebb35e9eeefd 106 | md""" 107 | Link to algorithm documentation: https://www... 108 | """ 109 | 110 | # ╔═╡ 01aea163-dc8f-4dd8-b669-c84bc879f41d 111 | md""" 112 | !!! danger "Task 2.2" 113 | Calculate the bounds based on your algorithm 114 | """ 115 | 116 | # ╔═╡ 50fdc883-4956-4311-8fec-dda5060c7b48 117 | md""" 118 | 54000 Sec Bound (m): ? 119 | 120 | 18000 Sec bound (m): ? 121 | 122 | Also put these bounds in the spreadsheet 123 | """ 124 | 125 | # ╔═╡ 11aeaeb7-4106-4a02-a822-6d2ce24d38cc 126 | md""" 127 | # 3. Unit Testing: Your First Unit Test 128 | """ 129 | 130 | # ╔═╡ 67f8ba14-7f27-467b-a3e2-aac03bc3d5f3 131 | md""" 132 | **Introduction**: Unit testing is a software testing method by which individual units of source code—sets of one or more program functions—are tested to determine whether they are fit for use. It ensures that code changes don't break existing functionality, leading to more stable software builds. A comprehensive guide on unit testing in Julia can be found in Julia's documentation on testing 133 | """ 134 | 135 | # ╔═╡ 79af0d11-9b79-4a20-8376-4257c5b4d097 136 | md""" 137 | For your routing solution, unit tests will validate each function's behavior, ensuring the code is not only correct but also resilient to changes over time. 138 | """ 139 | 140 | # ╔═╡ 2e56a5c5-e90d-4840-bce9-1213fcf8c24e 141 | md""" 142 | !!! danger "Task 3" 143 | Write and integrate any form of a unit test for your package. 144 | - It should benchmark either the code efficiency or correctness 145 | - The unit test case in your code should be passing at the time of submission (which could obviously change by the time we're grading) 146 | """ 147 | 148 | # ╔═╡ 61df1e85-3b98-497a-8e12-906cb3c0de44 149 | md""" 150 | Test case code: https://www... 151 | """ 152 | 153 | # ╔═╡ 6f417269-dca9-4db3-ae0e-d60dfd261e01 154 | md""" 155 | # 4. Continous Integration Setup 156 | """ 157 | 158 | # ╔═╡ b84c91fc-c06c-447c-aae1-64b2f0378158 159 | md""" 160 | **Introduction**: Continuous Integration (CI) practices are fundamental in modern software development, ensuring that code changes are automatically tested, which helps in identifying issues early on. It also enforces discipline in testing and can reduce integration problems, allowing for faster iterative development. A detailed explanation of CI benefits can be found in Martin Fowler's article on Continuous Integration. 161 | """ 162 | 163 | # ╔═╡ eade570d-c7f6-4aee-be86-0010cc32ea92 164 | md""" 165 | The setup of a Continuous Integration (CI) system is a step towards professional software engineering practices. For the routing challenge, CI ensures that any changes to the codebase do not inadvertently break the solution. As you develop their algorithms and make improvements to their code, CI automatically verifies that the code compiles, all tests pass, and, in some configurations, that the code adheres to style guidelines. This instant feedback loop is crucial, especially in a collaborative project where multiple people might be working on different parts of the code. It encourages an iterative approach to development, where you can make small, frequent changes while maintaining the integrity of the overall solution. 166 | """ 167 | 168 | # ╔═╡ 65a19c8e-3cad-41b6-b56e-0dc31168b103 169 | md""" 170 | !!! danger "Task 4" 171 | Set up a CI workflow with GitHub Actions or another CI service of your choice. 172 | - The workflow should trigger a build and run your test suite on every push to the repository. 173 | """ 174 | 175 | # ╔═╡ 88e42108-ee9f-445d-a29d-607ce3056e45 176 | md""" 177 | Link to github page (showing CI icon): https://www... 178 | """ 179 | 180 | # ╔═╡ 00000000-0000-0000-0000-000000000001 181 | PLUTO_PROJECT_TOML_CONTENTS = """ 182 | [deps] 183 | PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" 184 | 185 | [compat] 186 | PlutoTeachingTools = "~0.2.13" 187 | """ 188 | 189 | # ╔═╡ 00000000-0000-0000-0000-000000000002 190 | PLUTO_MANIFEST_TOML_CONTENTS = """ 191 | # This file is machine-generated - editing it directly is not advised 192 | 193 | julia_version = "1.8.5" 194 | manifest_format = "2.0" 195 | project_hash = "7a42974596e9e12c27f0417f760c666a50853d11" 196 | 197 | [[deps.AbstractPlutoDingetjes]] 198 | deps = ["Pkg"] 199 | git-tree-sha1 = "91bd53c39b9cbfb5ef4b015e8b582d344532bd0a" 200 | uuid = "6e696c72-6542-2067-7265-42206c756150" 201 | version = "1.2.0" 202 | 203 | [[deps.ArgTools]] 204 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 205 | version = "1.1.1" 206 | 207 | [[deps.Artifacts]] 208 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 209 | 210 | [[deps.Base64]] 211 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 212 | 213 | [[deps.CodeTracking]] 214 | deps = ["InteractiveUtils", "UUIDs"] 215 | git-tree-sha1 = "c0216e792f518b39b22212127d4a84dc31e4e386" 216 | uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" 217 | version = "1.3.5" 218 | 219 | [[deps.ColorTypes]] 220 | deps = ["FixedPointNumbers", "Random"] 221 | git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4" 222 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 223 | version = "0.11.4" 224 | 225 | [[deps.CompilerSupportLibraries_jll]] 226 | deps = ["Artifacts", "Libdl"] 227 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 228 | version = "1.0.1+0" 229 | 230 | [[deps.Dates]] 231 | deps = ["Printf"] 232 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 233 | 234 | [[deps.Distributed]] 235 | deps = ["Random", "Serialization", "Sockets"] 236 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 237 | 238 | [[deps.Downloads]] 239 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 240 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 241 | version = "1.6.0" 242 | 243 | [[deps.FileWatching]] 244 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 245 | 246 | [[deps.FixedPointNumbers]] 247 | deps = ["Statistics"] 248 | git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" 249 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 250 | version = "0.8.4" 251 | 252 | [[deps.Formatting]] 253 | deps = ["Printf"] 254 | git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8" 255 | uuid = "59287772-0a20-5a39-b81b-1366585eb4c0" 256 | version = "0.4.2" 257 | 258 | [[deps.Hyperscript]] 259 | deps = ["Test"] 260 | git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9" 261 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" 262 | version = "0.0.4" 263 | 264 | [[deps.HypertextLiteral]] 265 | deps = ["Tricks"] 266 | git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9" 267 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 268 | version = "0.9.4" 269 | 270 | [[deps.IOCapture]] 271 | deps = ["Logging", "Random"] 272 | git-tree-sha1 = "d75853a0bdbfb1ac815478bacd89cd27b550ace6" 273 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 274 | version = "0.2.3" 275 | 276 | [[deps.InteractiveUtils]] 277 | deps = ["Markdown"] 278 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 279 | 280 | [[deps.JSON]] 281 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 282 | git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" 283 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 284 | version = "0.21.4" 285 | 286 | [[deps.JuliaInterpreter]] 287 | deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] 288 | git-tree-sha1 = "0592b1810613d1c95eeebcd22dc11fba186c2a57" 289 | uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" 290 | version = "0.9.26" 291 | 292 | [[deps.LaTeXStrings]] 293 | git-tree-sha1 = "f2355693d6778a178ade15952b7ac47a4ff97996" 294 | uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" 295 | version = "1.3.0" 296 | 297 | [[deps.Latexify]] 298 | deps = ["Formatting", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Printf", "Requires"] 299 | git-tree-sha1 = "f428ae552340899a935973270b8d98e5a31c49fe" 300 | uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" 301 | version = "0.16.1" 302 | 303 | [[deps.LibCURL]] 304 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 305 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 306 | version = "0.6.3" 307 | 308 | [[deps.LibCURL_jll]] 309 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 310 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 311 | version = "7.84.0+0" 312 | 313 | [[deps.LibGit2]] 314 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 315 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 316 | 317 | [[deps.LibSSH2_jll]] 318 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 319 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 320 | version = "1.10.2+0" 321 | 322 | [[deps.Libdl]] 323 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 324 | 325 | [[deps.LinearAlgebra]] 326 | deps = ["Libdl", "libblastrampoline_jll"] 327 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 328 | 329 | [[deps.Logging]] 330 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 331 | 332 | [[deps.LoweredCodeUtils]] 333 | deps = ["JuliaInterpreter"] 334 | git-tree-sha1 = "60168780555f3e663c536500aa790b6368adc02a" 335 | uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" 336 | version = "2.3.0" 337 | 338 | [[deps.MIMEs]] 339 | git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" 340 | uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" 341 | version = "0.1.4" 342 | 343 | [[deps.MacroTools]] 344 | deps = ["Markdown", "Random"] 345 | git-tree-sha1 = "9ee1618cbf5240e6d4e0371d6f24065083f60c48" 346 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" 347 | version = "0.5.11" 348 | 349 | [[deps.Markdown]] 350 | deps = ["Base64"] 351 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 352 | 353 | [[deps.MbedTLS_jll]] 354 | deps = ["Artifacts", "Libdl"] 355 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 356 | version = "2.28.0+0" 357 | 358 | [[deps.Mmap]] 359 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 360 | 361 | [[deps.MozillaCACerts_jll]] 362 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 363 | version = "2022.2.1" 364 | 365 | [[deps.NetworkOptions]] 366 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 367 | version = "1.2.0" 368 | 369 | [[deps.OpenBLAS_jll]] 370 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 371 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 372 | version = "0.3.20+0" 373 | 374 | [[deps.OrderedCollections]] 375 | git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3" 376 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 377 | version = "1.6.2" 378 | 379 | [[deps.Parsers]] 380 | deps = ["Dates", "PrecompileTools", "UUIDs"] 381 | git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" 382 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 383 | version = "2.7.2" 384 | 385 | [[deps.Pkg]] 386 | deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 387 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 388 | version = "1.8.0" 389 | 390 | [[deps.PlutoHooks]] 391 | deps = ["InteractiveUtils", "Markdown", "UUIDs"] 392 | git-tree-sha1 = "072cdf20c9b0507fdd977d7d246d90030609674b" 393 | uuid = "0ff47ea0-7a50-410d-8455-4348d5de0774" 394 | version = "0.0.5" 395 | 396 | [[deps.PlutoLinks]] 397 | deps = ["FileWatching", "InteractiveUtils", "Markdown", "PlutoHooks", "Revise", "UUIDs"] 398 | git-tree-sha1 = "8f5fa7056e6dcfb23ac5211de38e6c03f6367794" 399 | uuid = "0ff47ea0-7a50-410d-8455-4348d5de0420" 400 | version = "0.1.6" 401 | 402 | [[deps.PlutoTeachingTools]] 403 | deps = ["Downloads", "HypertextLiteral", "LaTeXStrings", "Latexify", "Markdown", "PlutoLinks", "PlutoUI", "Random"] 404 | git-tree-sha1 = "542de5acb35585afcf202a6d3361b430bc1c3fbd" 405 | uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" 406 | version = "0.2.13" 407 | 408 | [[deps.PlutoUI]] 409 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] 410 | git-tree-sha1 = "e47cd150dbe0443c3a3651bc5b9cbd5576ab75b7" 411 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 412 | version = "0.7.52" 413 | 414 | [[deps.PrecompileTools]] 415 | deps = ["Preferences"] 416 | git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" 417 | uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" 418 | version = "1.2.0" 419 | 420 | [[deps.Preferences]] 421 | deps = ["TOML"] 422 | git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" 423 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 424 | version = "1.4.1" 425 | 426 | [[deps.Printf]] 427 | deps = ["Unicode"] 428 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 429 | 430 | [[deps.REPL]] 431 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 432 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 433 | 434 | [[deps.Random]] 435 | deps = ["SHA", "Serialization"] 436 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 437 | 438 | [[deps.Reexport]] 439 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 440 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 441 | version = "1.2.2" 442 | 443 | [[deps.Requires]] 444 | deps = ["UUIDs"] 445 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7" 446 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 447 | version = "1.3.0" 448 | 449 | [[deps.Revise]] 450 | deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "Requires", "UUIDs", "Unicode"] 451 | git-tree-sha1 = "ba168f8fc36bf83c8d0573d464b7aab0f8a81623" 452 | uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" 453 | version = "3.5.7" 454 | 455 | [[deps.SHA]] 456 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 457 | version = "0.7.0" 458 | 459 | [[deps.Serialization]] 460 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 461 | 462 | [[deps.Sockets]] 463 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 464 | 465 | [[deps.SparseArrays]] 466 | deps = ["LinearAlgebra", "Random"] 467 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 468 | 469 | [[deps.Statistics]] 470 | deps = ["LinearAlgebra", "SparseArrays"] 471 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 472 | 473 | [[deps.TOML]] 474 | deps = ["Dates"] 475 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 476 | version = "1.0.0" 477 | 478 | [[deps.Tar]] 479 | deps = ["ArgTools", "SHA"] 480 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 481 | version = "1.10.1" 482 | 483 | [[deps.Test]] 484 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 485 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 486 | 487 | [[deps.Tricks]] 488 | git-tree-sha1 = "eae1bb484cd63b36999ee58be2de6c178105112f" 489 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" 490 | version = "0.1.8" 491 | 492 | [[deps.URIs]] 493 | git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b" 494 | uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" 495 | version = "1.5.1" 496 | 497 | [[deps.UUIDs]] 498 | deps = ["Random", "SHA"] 499 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 500 | 501 | [[deps.Unicode]] 502 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 503 | 504 | [[deps.Zlib_jll]] 505 | deps = ["Libdl"] 506 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 507 | version = "1.2.12+3" 508 | 509 | [[deps.libblastrampoline_jll]] 510 | deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] 511 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 512 | version = "5.1.1+0" 513 | 514 | [[deps.nghttp2_jll]] 515 | deps = ["Artifacts", "Libdl"] 516 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 517 | version = "1.48.0+0" 518 | 519 | [[deps.p7zip_jll]] 520 | deps = ["Artifacts", "Libdl"] 521 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 522 | version = "17.4.0+0" 523 | """ 524 | 525 | # ╔═╡ Cell order: 526 | # ╠═9ea8ed00-7484-11ee-0824-0b5807b13a8f 527 | # ╠═48b82457-95d0-4ccc-bec0-8d40e01760f3 528 | # ╟─16086277-f9a9-4866-80d6-181d1d18519a 529 | # ╟─25c1f001-8e4b-41aa-926e-9ff1550eae35 530 | # ╟─3d6772be-2ad6-4f9b-94a6-2cd75252d9cd 531 | # ╟─6a501c3e-0bae-428d-b8cd-2b430afbb6b5 532 | # ╟─d32ee0f3-4009-41ff-8bd3-04d8e92bfa8b 533 | # ╟─08165c83-3772-49e7-96c9-ee133708b6a8 534 | # ╠═e430eb66-1a00-4d7d-990c-7dbbde96cc8a 535 | # ╟─99b8ff51-5b21-45d9-bca8-1d21ff37f23b 536 | # ╟─c5e62fd0-a827-4efe-8da8-dcc77b7a5d3d 537 | # ╟─fd90f0f3-a4a3-445b-9b84-b12cae29dbcc 538 | # ╟─09ba7470-55f6-437c-910f-48f43eb3ff6a 539 | # ╠═2ba3f41a-07c0-4b42-91e1-ebb35e9eeefd 540 | # ╟─01aea163-dc8f-4dd8-b669-c84bc879f41d 541 | # ╠═50fdc883-4956-4311-8fec-dda5060c7b48 542 | # ╟─11aeaeb7-4106-4a02-a822-6d2ce24d38cc 543 | # ╟─67f8ba14-7f27-467b-a3e2-aac03bc3d5f3 544 | # ╟─79af0d11-9b79-4a20-8376-4257c5b4d097 545 | # ╟─2e56a5c5-e90d-4840-bce9-1213fcf8c24e 546 | # ╠═61df1e85-3b98-497a-8e12-906cb3c0de44 547 | # ╟─6f417269-dca9-4db3-ae0e-d60dfd261e01 548 | # ╟─b84c91fc-c06c-447c-aae1-64b2f0378158 549 | # ╟─eade570d-c7f6-4aee-be86-0010cc32ea92 550 | # ╟─65a19c8e-3cad-41b6-b56e-0dc31168b103 551 | # ╠═88e42108-ee9f-445d-a29d-607ce3056e45 552 | # ╟─00000000-0000-0000-0000-000000000001 553 | # ╟─00000000-0000-0000-0000-000000000002 554 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [[headers]] 2 | for = "/*" 3 | [headers.values] 4 | Access-Control-Allow-Origin = "*" 5 | -------------------------------------------------------------------------------- /notebooks/13_ferari_lecture1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks/13_ferari_lecture1.pdf -------------------------------------------------------------------------------- /notebooks/20220422_philip.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks/20220422_philip.jpg -------------------------------------------------------------------------------- /notebooks/20220422_philip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks/20220422_philip.png -------------------------------------------------------------------------------- /notebooks/4. AutoDiff.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Autodiff:
Calculus from another angle \n", 8 | "(and the special role played by Julia's multiple dispatch and compiler technology)\n", 9 | "\n", 10 | "(Alan Edelman, 2017)\n", 11 | "\n", 12 | "\n", 13 | " The first time I heard about automatic differentiation, it was easy for me to imagine what it was. I was wrong. In my head, I thought it was straightforward symbolic differentiation applied to code. I kind of imagined it was like executing Mathematica or Maple, or even just automatically doing what I learned to do in my calculus class. \n", 14 | " \n", 15 | " .... and anyway if it was not that, then it must be finite differences, like one learns in a numerical computing class.\n", 16 | " \n", 17 | "\n", 18 | "\n" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": {}, 24 | "source": [ 25 | "## Babylonian sqrt\n", 26 | "\n", 27 | "I would like to use a simple example, computation of sqrt(x), where for me how autodiff works came as both a mathematical surprise, and a computing wonder. The example is the Babylonian algorithm, known to man for millenia, to compute sqrt(x): \n", 28 | "\n", 29 | "\n", 30 | " > Repeat $ t \\leftarrow (t+x/t) / 2 $ until $t$ converges to $\\sqrt{x}$.\n", 31 | " \n", 32 | " Each iteration has one add and two divides. For illustration purposes, 10 iterations suffice." 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "metadata": {}, 39 | "outputs": [], 40 | "source": [ 41 | "function Babylonian(x; N = 10) \n", 42 | " t = (1+x)/2\n", 43 | " for i = 2:N; t=(t + x/t)/2 end \n", 44 | " t\n", 45 | "end " 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "Check that it works:" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "α = π\n", 62 | "Babylonian(α), √α " 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": null, 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "x=2; Babylonian(x),√x # Type \\sqrt+ to get the symbol" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "metadata": {}, 78 | "outputs": [], 79 | "source": [ 80 | "using Plots\n", 81 | "plotly()\n", 82 | "#gr()\n", 83 | "#pyplot()" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": null, 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [ 92 | "i = 0:.01:49\n", 93 | "\n", 94 | "plot([x->Babylonian(x,N=i) for i=1:5],i,label=[\"Iteration $j\" for i=1:1,j=1:5])\n", 95 | "\n", 96 | "plot!(sqrt,i,c=\"black\",label=\"sqrt\",\n", 97 | " title = \"Those Babylonians really knew how to √\")" 98 | ] 99 | }, 100 | { 101 | "cell_type": "markdown", 102 | "metadata": {}, 103 | "source": [ 104 | "## ...and now the derivative, almost by magic" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": null, 110 | "metadata": {}, 111 | "outputs": [], 112 | "source": [ 113 | "struct D <: Number # D is a function-derivative pair\n", 114 | " f::Tuple{Float64,Float64}\n", 115 | "end" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": null, 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [ 124 | "D((1.2,3.14))" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": null, 130 | "metadata": {}, 131 | "outputs": [], 132 | "source": [ 133 | "D(x,y) = D((x,y)) # teaching point, overload D to take in either a tupe, or two arguments" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": null, 139 | "metadata": {}, 140 | "outputs": [], 141 | "source": [ 142 | "D(1.2,3.14)" 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": null, 148 | "metadata": {}, 149 | "outputs": [], 150 | "source": [ 151 | "D(1,2) / D(3,4)" 152 | ] 153 | }, 154 | { 155 | "cell_type": "markdown", 156 | "metadata": {}, 157 | "source": [ 158 | "Sum Rule: (x+y)' = x' + y'
\n", 159 | "Quotient Rule: (x/y)' = (yx'-xy') / y^2" 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": null, 165 | "metadata": {}, 166 | "outputs": [], 167 | "source": [ 168 | "import Base: +, /, convert, promote_rule\n", 169 | "+(x::D, y::D) = D(x.f .+ y.f)\n", 170 | "/(x::D, y::D) = D((x.f[1]/y.f[1], (y.f[1]*x.f[2] - x.f[1]*y.f[2])/y.f[1]^2))\n", 171 | "convert(::Type{D}, x::Real) = D((x,zero(x)))\n", 172 | "promote_rule(::Type{D}, ::Type{<:Number}) = D" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": null, 178 | "metadata": {}, 179 | "outputs": [], 180 | "source": [ 181 | "D(2,3) / D(3,4)" 182 | ] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "execution_count": null, 187 | "metadata": {}, 188 | "outputs": [], 189 | "source": [ 190 | "x=49; Babylonian(D(x,1)), (√x,.5/√x)" 191 | ] 192 | }, 193 | { 194 | "cell_type": "code", 195 | "execution_count": null, 196 | "metadata": {}, 197 | "outputs": [], 198 | "source": [ 199 | "x=π; Babylonian(D((x,1))), (√x,.5/√x)" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": null, 205 | "metadata": {}, 206 | "outputs": [], 207 | "source": [ 208 | "Babylonian( D(100,1) )" 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": null, 214 | "metadata": {}, 215 | "outputs": [], 216 | "source": [ 217 | "i = .2:.01:49\n", 218 | "plot([x->Babylonian(D((x,1.0)),N=i).f[2] for i=1:5],i)\n", 219 | "plot!(x->.5/√x,i,c=\"black\",label=\"d(sqrt(x))/dx\",\n", 220 | " title = \" Babylonians Differentiated\")" 221 | ] 222 | }, 223 | { 224 | "cell_type": "markdown", 225 | "metadata": {}, 226 | "source": [ 227 | "## It just works!\n", 228 | "\n", 229 | "How does it work? We will explain in a moment. Right now marvel that it does. Note we did not\n", 230 | "import any autodiff package. Everything is just basic vanilla Julia." 231 | ] 232 | }, 233 | { 234 | "cell_type": "markdown", 235 | "metadata": {}, 236 | "source": [ 237 | "## The assembler\n", 238 | "\n", 239 | "Most folks don't read assembler, but one can see that it is short." 240 | ] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "execution_count": null, 245 | "metadata": {}, 246 | "outputs": [], 247 | "source": [ 248 | "# @inline function Babylonian(x; N = 10) \n", 249 | "# t = (1+x)/2\n", 250 | "# for i = 2:N; t=(t + x/t)/2 end \n", 251 | "# t\n", 252 | "# end \n", 253 | "@code_native(Babylonian(D((2,1))))" 254 | ] 255 | }, 256 | { 257 | "cell_type": "markdown", 258 | "metadata": {}, 259 | "source": [ 260 | "## Symbolically\n", 261 | "\n", 262 | "We haven't yet explained how it works, but it may be of some value to understand that the below is mathematically\n", 263 | "equivalent, though not what the computation is doing.\n", 264 | "\n", 265 | "Notice in the below that Babylonian works on SymPy symbols." 266 | ] 267 | }, 268 | { 269 | "cell_type": "code", 270 | "execution_count": null, 271 | "metadata": {}, 272 | "outputs": [], 273 | "source": [ 274 | "#Pkg.add(\"SymPy\")\n", 275 | "using SymPy " 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": null, 281 | "metadata": {}, 282 | "outputs": [], 283 | "source": [ 284 | "x = symbols(\"x\")\n", 285 | "display(\"Iterations as a function of x\")\n", 286 | "for k = 1:5\n", 287 | " display( simplify(Babylonian(x,N=k)))\n", 288 | "end\n", 289 | "\n", 290 | "display(\"Derivatives as a function of x\")\n", 291 | "for k = 1:5\n", 292 | " display(simplify(diff(simplify(Babylonian(x,N=k)),x)))\n", 293 | "end" 294 | ] 295 | }, 296 | { 297 | "cell_type": "markdown", 298 | "metadata": {}, 299 | "source": [ 300 | "## How autodiff is getting the answer\n", 301 | "Let us by hand take the \"derivative\" of the Babylonian iteration with respect to x. Specifically t′=dt/dx" 302 | ] 303 | }, 304 | { 305 | "cell_type": "code", 306 | "execution_count": null, 307 | "metadata": {}, 308 | "outputs": [], 309 | "source": [ 310 | "function dBabylonian(x; N = 10) \n", 311 | " t = (1+x)/2\n", 312 | " t′ = 1/2\n", 313 | " for i = 1:N; \n", 314 | " t = (t+x/t)/2; \n", 315 | " t′= (t′+(t-x*t′)/t^2)/2; \n", 316 | " end \n", 317 | " t′\n", 318 | "\n", 319 | "end " 320 | ] 321 | }, 322 | { 323 | "cell_type": "code", 324 | "execution_count": null, 325 | "metadata": {}, 326 | "outputs": [], 327 | "source": [ 328 | "x = π; dBabylonian(x), .5/√x" 329 | ] 330 | }, 331 | { 332 | "cell_type": "markdown", 333 | "metadata": {}, 334 | "source": [ 335 | "What just happened? Answer: We created an iteration by hand for t′ given our iteration for t. Then we ran the iteration alongside the iteration for t." 336 | ] 337 | }, 338 | { 339 | "cell_type": "code", 340 | "execution_count": null, 341 | "metadata": {}, 342 | "outputs": [], 343 | "source": [ 344 | "Babylonian(D((x,1)))\n" 345 | ] 346 | }, 347 | { 348 | "cell_type": "markdown", 349 | "metadata": {}, 350 | "source": [ 351 | "How did this work? It created the same derivative iteration, using very general rules that are set once and need not be written by hand." 352 | ] 353 | }, 354 | { 355 | "cell_type": "markdown", 356 | "metadata": {}, 357 | "source": [ 358 | "Important:: The derivative is substituted before the JIT compiler, and thus efficient compiled code is executed." 359 | ] 360 | }, 361 | { 362 | "cell_type": "markdown", 363 | "metadata": {}, 364 | "source": [ 365 | "## Dual Number Notation\n", 366 | "\n", 367 | "Instead of D(a,b) we can write a + b ϵ, where ϵ satisfies ϵ^2=0. (Some people like to recall imaginary numbers where an i is introduced with i^2=-1.) \n", 368 | "\n", 369 | "Others like to think of how engineers just drop the O(ϵ^2) terms.\n", 370 | "\n", 371 | "The four rules are\n", 372 | "\n", 373 | "$ (a+b\\epsilon) \\pm (c+d\\epsilon) = (a \\pm c) + (b \\pm d)\\epsilon$\n", 374 | "\n", 375 | "$ (a+b\\epsilon) * (c+d\\epsilon) = (ac) + (bc+ad)\\epsilon$\n", 376 | "\n", 377 | "$ (a+b\\epsilon) / (c+d\\epsilon) = (a/c) + (bc-ad)/c^2 \\epsilon $\n" 378 | ] 379 | }, 380 | { 381 | "cell_type": "code", 382 | "execution_count": null, 383 | "metadata": {}, 384 | "outputs": [], 385 | "source": [ 386 | "@syms a b c d ϵ" 387 | ] 388 | }, 389 | { 390 | "cell_type": "code", 391 | "execution_count": null, 392 | "metadata": {}, 393 | "outputs": [], 394 | "source": [ 395 | "series((a+b*ϵ)/(c+d*ϵ),ϵ,0,2)" 396 | ] 397 | }, 398 | { 399 | "cell_type": "code", 400 | "execution_count": null, 401 | "metadata": {}, 402 | "outputs": [], 403 | "source": [ 404 | "Base.show(io::IO,x::D) = print(io,x.f[1],\" + \",x.f[2],\" ϵ\")" 405 | ] 406 | }, 407 | { 408 | "cell_type": "code", 409 | "execution_count": null, 410 | "metadata": {}, 411 | "outputs": [], 412 | "source": [ 413 | "D(4,5)" 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "execution_count": null, 419 | "metadata": {}, 420 | "outputs": [], 421 | "source": [ 422 | "# Add the last two rules\n", 423 | "import Base: -,*\n", 424 | "-(x::D, y:: D) = D(x.f .- y.f)\n", 425 | "*(x::D, y::D) = D((x.f[1]*y.f[1], (x.f[2]*y.f[1] + x.f[1]*y.f[2])))" 426 | ] 427 | }, 428 | { 429 | "cell_type": "code", 430 | "execution_count": null, 431 | "metadata": {}, 432 | "outputs": [], 433 | "source": [ 434 | "D((1,0))" 435 | ] 436 | }, 437 | { 438 | "cell_type": "code", 439 | "execution_count": null, 440 | "metadata": {}, 441 | "outputs": [], 442 | "source": [ 443 | "D((2,1)) ^2" 444 | ] 445 | }, 446 | { 447 | "cell_type": "code", 448 | "execution_count": null, 449 | "metadata": {}, 450 | "outputs": [], 451 | "source": [ 452 | "ϵ = D((0,1))\n" 453 | ] 454 | }, 455 | { 456 | "cell_type": "code", 457 | "execution_count": null, 458 | "metadata": {}, 459 | "outputs": [], 460 | "source": [ 461 | "ϵ * ϵ " 462 | ] 463 | }, 464 | { 465 | "cell_type": "code", 466 | "execution_count": null, 467 | "metadata": {}, 468 | "outputs": [], 469 | "source": [ 470 | "ϵ^2\n" 471 | ] 472 | }, 473 | { 474 | "cell_type": "code", 475 | "execution_count": null, 476 | "metadata": {}, 477 | "outputs": [], 478 | "source": [ 479 | "1/(1+ϵ) \n", 480 | "# Exact power series: 1-ϵ+ϵ²-ϵ³-..." 481 | ] 482 | }, 483 | { 484 | "cell_type": "code", 485 | "execution_count": null, 486 | "metadata": {}, 487 | "outputs": [], 488 | "source": [ 489 | "(1+ϵ)^5 ## Note this just works (we didn't train powers)!!" 490 | ] 491 | }, 492 | { 493 | "cell_type": "code", 494 | "execution_count": null, 495 | "metadata": {}, 496 | "outputs": [], 497 | "source": [ 498 | "(1+ϵ)^(-1)" 499 | ] 500 | }, 501 | { 502 | "cell_type": "markdown", 503 | "metadata": {}, 504 | "source": [ 505 | "## Generalization to arbitrary roots" 506 | ] 507 | }, 508 | { 509 | "cell_type": "code", 510 | "execution_count": null, 511 | "metadata": {}, 512 | "outputs": [], 513 | "source": [ 514 | "function nthroot(x, n=2; t=1, N = 10) \n", 515 | " for i = 1:N; t += (x/t^(n-1)-t)/n; end \n", 516 | " t\n", 517 | "end " 518 | ] 519 | }, 520 | { 521 | "cell_type": "code", 522 | "execution_count": null, 523 | "metadata": {}, 524 | "outputs": [], 525 | "source": [ 526 | "nthroot(2,3), ∛2 # take a cube root" 527 | ] 528 | }, 529 | { 530 | "cell_type": "code", 531 | "execution_count": null, 532 | "metadata": {}, 533 | "outputs": [], 534 | "source": [ 535 | "nthroot(2+ϵ,3)" 536 | ] 537 | }, 538 | { 539 | "cell_type": "code", 540 | "execution_count": null, 541 | "metadata": {}, 542 | "outputs": [], 543 | "source": [ 544 | "nthroot(7,12), 7^(1/12)" 545 | ] 546 | }, 547 | { 548 | "cell_type": "code", 549 | "execution_count": null, 550 | "metadata": {}, 551 | "outputs": [], 552 | "source": [ 553 | "x = 2.0\n", 554 | "nthroot( x+ϵ,3), ∛x, 1/x^(2/3)/3" 555 | ] 556 | }, 557 | { 558 | "cell_type": "markdown", 559 | "metadata": {}, 560 | "source": [ 561 | "## Forward Diff\n", 562 | "Now that you understand it, you can use the official package" 563 | ] 564 | }, 565 | { 566 | "cell_type": "code", 567 | "execution_count": null, 568 | "metadata": {}, 569 | "outputs": [], 570 | "source": [ 571 | "using Pkg\n", 572 | "Pkg.add(\"ForwardDiff\")" 573 | ] 574 | }, 575 | { 576 | "cell_type": "code", 577 | "execution_count": null, 578 | "metadata": {}, 579 | "outputs": [], 580 | "source": [ 581 | "using ForwardDiff" 582 | ] 583 | }, 584 | { 585 | "cell_type": "code", 586 | "execution_count": null, 587 | "metadata": {}, 588 | "outputs": [], 589 | "source": [ 590 | "ForwardDiff.derivative(sqrt, 2)" 591 | ] 592 | }, 593 | { 594 | "cell_type": "code", 595 | "execution_count": null, 596 | "metadata": {}, 597 | "outputs": [], 598 | "source": [ 599 | "ForwardDiff.derivative(Babylonian, 2)" 600 | ] 601 | }, 602 | { 603 | "cell_type": "code", 604 | "execution_count": null, 605 | "metadata": {}, 606 | "outputs": [], 607 | "source": [ 608 | "@which ForwardDiff.derivative(sqrt, 2)" 609 | ] 610 | }, 611 | { 612 | "cell_type": "code", 613 | "execution_count": null, 614 | "metadata": {}, 615 | "outputs": [], 616 | "source": [] 617 | } 618 | ], 619 | "metadata": { 620 | "kernelspec": { 621 | "display_name": "Julia 1.9.3", 622 | "language": "julia", 623 | "name": "julia-1.9" 624 | }, 625 | "language_info": { 626 | "file_extension": ".jl", 627 | "mimetype": "application/julia", 628 | "name": "julia", 629 | "version": "1.9.3" 630 | } 631 | }, 632 | "nbformat": 4, 633 | "nbformat_minor": 2 634 | } 635 | -------------------------------------------------------------------------------- /notebooks/6_MultDisAmbiguity.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.46 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ b861f824-ae14-4a19-bdfa-cde601b1b21c 8 | using PlutoUI 9 | 10 | 11 | # ╔═╡ 208180e6-9686-4105-985d-fa9232ff8a7e 12 | md""" 13 | # Multiple Dispatch Ambiguity 14 | """ 15 | 16 | # ╔═╡ 80d58188-e689-4677-9d08-4958828771c0 17 | md""" 18 | ![Venn Diagram](https://github.com/mitmath/JuliaComputation/blob/Fall24/6_MultipleDispatchAmbiguity.jpg?raw=true) 19 | """ 20 | 21 | # ╔═╡ f01c27c9-e246-4a11-a856-5e1103b541db 22 | f(a::Real, b::Integer) = "(ℝ , ℤ)" 23 | 24 | # ╔═╡ 83a1215f-93fe-4844-8cd8-2243cd4f2925 25 | f(a::Integer, b:: Real) = "(ℤ , ℝ)" 26 | 27 | # ╔═╡ e5d21d57-856e-4c15-87fc-82471afceb35 28 | f(a::Real, b:: Real) = "(ℝ , ℝ)" 29 | 30 | # ╔═╡ 7d98b956-7445-4ec1-8fff-db27ff7ab3dd 31 | f(1.0,1.0) 32 | 33 | # ╔═╡ a9fcb40a-549d-445d-892e-3e0c8e33237f 34 | f(1.0,1) 35 | 36 | # ╔═╡ f45c6ce8-6f93-4c5f-8f7e-198a5203a039 37 | f(1,1.0) 38 | 39 | # ╔═╡ 4a8c885f-2c02-4cb6-968b-96a0d0f6ec9d 40 | md"Ambiguous:" 41 | 42 | # ╔═╡ acdc9c3f-d302-4bc4-b920-f227f3004f38 43 | f(1,1) 44 | 45 | # ╔═╡ 00000000-0000-0000-0000-000000000001 46 | PLUTO_PROJECT_TOML_CONTENTS = """ 47 | [deps] 48 | PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 49 | 50 | [compat] 51 | PlutoUI = "~0.7.60" 52 | """ 53 | 54 | # ╔═╡ 00000000-0000-0000-0000-000000000002 55 | PLUTO_MANIFEST_TOML_CONTENTS = """ 56 | # This file is machine-generated - editing it directly is not advised 57 | 58 | julia_version = "1.10.4" 59 | manifest_format = "2.0" 60 | project_hash = "c1674f662899f5bfc062df83020732df21a649e9" 61 | 62 | [[deps.AbstractPlutoDingetjes]] 63 | deps = ["Pkg"] 64 | git-tree-sha1 = "6e1d2a35f2f90a4bc7c2ed98079b2ba09c35b83a" 65 | uuid = "6e696c72-6542-2067-7265-42206c756150" 66 | version = "1.3.2" 67 | 68 | [[deps.ArgTools]] 69 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 70 | version = "1.1.1" 71 | 72 | [[deps.Artifacts]] 73 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 74 | 75 | [[deps.Base64]] 76 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 77 | 78 | [[deps.ColorTypes]] 79 | deps = ["FixedPointNumbers", "Random"] 80 | git-tree-sha1 = "b10d0b65641d57b8b4d5e234446582de5047050d" 81 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 82 | version = "0.11.5" 83 | 84 | [[deps.CompilerSupportLibraries_jll]] 85 | deps = ["Artifacts", "Libdl"] 86 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 87 | version = "1.1.1+0" 88 | 89 | [[deps.Dates]] 90 | deps = ["Printf"] 91 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 92 | 93 | [[deps.Downloads]] 94 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 95 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 96 | version = "1.6.0" 97 | 98 | [[deps.FileWatching]] 99 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 100 | 101 | [[deps.FixedPointNumbers]] 102 | deps = ["Statistics"] 103 | git-tree-sha1 = "05882d6995ae5c12bb5f36dd2ed3f61c98cbb172" 104 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 105 | version = "0.8.5" 106 | 107 | [[deps.Hyperscript]] 108 | deps = ["Test"] 109 | git-tree-sha1 = "179267cfa5e712760cd43dcae385d7ea90cc25a4" 110 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" 111 | version = "0.0.5" 112 | 113 | [[deps.HypertextLiteral]] 114 | deps = ["Tricks"] 115 | git-tree-sha1 = "7134810b1afce04bbc1045ca1985fbe81ce17653" 116 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 117 | version = "0.9.5" 118 | 119 | [[deps.IOCapture]] 120 | deps = ["Logging", "Random"] 121 | git-tree-sha1 = "b6d6bfdd7ce25b0f9b2f6b3dd56b2673a66c8770" 122 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 123 | version = "0.2.5" 124 | 125 | [[deps.InteractiveUtils]] 126 | deps = ["Markdown"] 127 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 128 | 129 | [[deps.JSON]] 130 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 131 | git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" 132 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 133 | version = "0.21.4" 134 | 135 | [[deps.LibCURL]] 136 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 137 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 138 | version = "0.6.4" 139 | 140 | [[deps.LibCURL_jll]] 141 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 142 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 143 | version = "8.4.0+0" 144 | 145 | [[deps.LibGit2]] 146 | deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] 147 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 148 | 149 | [[deps.LibGit2_jll]] 150 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] 151 | uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" 152 | version = "1.6.4+0" 153 | 154 | [[deps.LibSSH2_jll]] 155 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 156 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 157 | version = "1.11.0+1" 158 | 159 | [[deps.Libdl]] 160 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 161 | 162 | [[deps.LinearAlgebra]] 163 | deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] 164 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 165 | 166 | [[deps.Logging]] 167 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 168 | 169 | [[deps.MIMEs]] 170 | git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" 171 | uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" 172 | version = "0.1.4" 173 | 174 | [[deps.Markdown]] 175 | deps = ["Base64"] 176 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 177 | 178 | [[deps.MbedTLS_jll]] 179 | deps = ["Artifacts", "Libdl"] 180 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 181 | version = "2.28.2+1" 182 | 183 | [[deps.Mmap]] 184 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 185 | 186 | [[deps.MozillaCACerts_jll]] 187 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 188 | version = "2023.1.10" 189 | 190 | [[deps.NetworkOptions]] 191 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 192 | version = "1.2.0" 193 | 194 | [[deps.OpenBLAS_jll]] 195 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 196 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 197 | version = "0.3.23+4" 198 | 199 | [[deps.Parsers]] 200 | deps = ["Dates", "PrecompileTools", "UUIDs"] 201 | git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821" 202 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 203 | version = "2.8.1" 204 | 205 | [[deps.Pkg]] 206 | deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 207 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 208 | version = "1.10.0" 209 | 210 | [[deps.PlutoUI]] 211 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] 212 | git-tree-sha1 = "eba4810d5e6a01f612b948c9fa94f905b49087b0" 213 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 214 | version = "0.7.60" 215 | 216 | [[deps.PrecompileTools]] 217 | deps = ["Preferences"] 218 | git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f" 219 | uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" 220 | version = "1.2.1" 221 | 222 | [[deps.Preferences]] 223 | deps = ["TOML"] 224 | git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" 225 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 226 | version = "1.4.3" 227 | 228 | [[deps.Printf]] 229 | deps = ["Unicode"] 230 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 231 | 232 | [[deps.REPL]] 233 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 234 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 235 | 236 | [[deps.Random]] 237 | deps = ["SHA"] 238 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 239 | 240 | [[deps.Reexport]] 241 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 242 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 243 | version = "1.2.2" 244 | 245 | [[deps.SHA]] 246 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 247 | version = "0.7.0" 248 | 249 | [[deps.Serialization]] 250 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 251 | 252 | [[deps.Sockets]] 253 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 254 | 255 | [[deps.SparseArrays]] 256 | deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] 257 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 258 | version = "1.10.0" 259 | 260 | [[deps.Statistics]] 261 | deps = ["LinearAlgebra", "SparseArrays"] 262 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 263 | version = "1.10.0" 264 | 265 | [[deps.SuiteSparse_jll]] 266 | deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] 267 | uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" 268 | version = "7.2.1+1" 269 | 270 | [[deps.TOML]] 271 | deps = ["Dates"] 272 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 273 | version = "1.0.3" 274 | 275 | [[deps.Tar]] 276 | deps = ["ArgTools", "SHA"] 277 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 278 | version = "1.10.0" 279 | 280 | [[deps.Test]] 281 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 282 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 283 | 284 | [[deps.Tricks]] 285 | git-tree-sha1 = "7822b97e99a1672bfb1b49b668a6d46d58d8cbcb" 286 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" 287 | version = "0.1.9" 288 | 289 | [[deps.URIs]] 290 | git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b" 291 | uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" 292 | version = "1.5.1" 293 | 294 | [[deps.UUIDs]] 295 | deps = ["Random", "SHA"] 296 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 297 | 298 | [[deps.Unicode]] 299 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 300 | 301 | [[deps.Zlib_jll]] 302 | deps = ["Libdl"] 303 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 304 | version = "1.2.13+1" 305 | 306 | [[deps.libblastrampoline_jll]] 307 | deps = ["Artifacts", "Libdl"] 308 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 309 | version = "5.8.0+1" 310 | 311 | [[deps.nghttp2_jll]] 312 | deps = ["Artifacts", "Libdl"] 313 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 314 | version = "1.52.0+1" 315 | 316 | [[deps.p7zip_jll]] 317 | deps = ["Artifacts", "Libdl"] 318 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 319 | version = "17.4.0+2" 320 | """ 321 | 322 | # ╔═╡ Cell order: 323 | # ╟─208180e6-9686-4105-985d-fa9232ff8a7e 324 | # ╟─80d58188-e689-4677-9d08-4958828771c0 325 | # ╠═f01c27c9-e246-4a11-a856-5e1103b541db 326 | # ╠═83a1215f-93fe-4844-8cd8-2243cd4f2925 327 | # ╠═e5d21d57-856e-4c15-87fc-82471afceb35 328 | # ╠═7d98b956-7445-4ec1-8fff-db27ff7ab3dd 329 | # ╠═a9fcb40a-549d-445d-892e-3e0c8e33237f 330 | # ╠═f45c6ce8-6f93-4c5f-8f7e-198a5203a039 331 | # ╟─4a8c885f-2c02-4cb6-968b-96a0d0f6ec9d 332 | # ╠═acdc9c3f-d302-4bc4-b920-f227f3004f38 333 | # ╟─b861f824-ae14-4a19-bdfa-cde601b1b21c 334 | # ╟─00000000-0000-0000-0000-000000000001 335 | # ╟─00000000-0000-0000-0000-000000000002 336 | -------------------------------------------------------------------------------- /notebooks/7_ptypes.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.46 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ e248ec9e-7b3c-11ef-3434-b1e6fc44ac3b 8 | using PlutoUI 9 | 10 | # ╔═╡ cb79cfad-9b8c-4017-ba7c-9cebcebc84f7 11 | TableOfContents(title="📚 Table of Contents", indent=true, depth=4, aside=true) 12 | 13 | # ╔═╡ 144c7859-9880-4d8a-af4a-3f0d4e77bc46 14 | md""" 15 | # 1. Views (Performance) 16 | """ 17 | 18 | # ╔═╡ 2b0b302c-f474-4964-b88b-e182057cd5db 19 | M = rand([2,3,5,7,9],3,3) 20 | 21 | # ╔═╡ 9d6f60eb-7af4-4986-8946-e5a08868fda4 22 | A = view(M, 2:3, 1:2) 23 | 24 | # ╔═╡ 53ffeb7e-3e60-4c2f-b34a-984a7a7fb2df 25 | md""" 26 | # 2. Create a type, what methods are created? 27 | """ 28 | 29 | # ╔═╡ fe8b88e1-05fb-4387-8b04-c329ff4c46f3 30 | struct C25 31 | value::Float64 32 | end 33 | 34 | # ╔═╡ 484b9cd9-2820-471b-85d3-75f23bbd9b61 35 | C25(1.0) 36 | 37 | # ╔═╡ 61dbdaaa-cc20-4bc9-a80c-5f4b9be1536a 38 | md""" 39 | Note that this **constructor** (a function with the same name as the type that creates objects of that type) was **automatically generated** when we defined the type. We can ask Julia which of these so-called default constructors are provided: 40 | """ 41 | 42 | # ╔═╡ 042e554c-59f7-4107-b958-76adcfcb8800 43 | display(methods(C25)) 44 | 45 | # ╔═╡ 4f9f2a79-98e3-4244-81c0-6ad089c1ec57 46 | C25(true) 47 | 48 | # ╔═╡ 64fc97fa-897a-4b03-81ad-e5121c3ccf00 49 | C25("Philip") 50 | 51 | # ╔═╡ 6d46a963-d316-4b95-82a0-a8c8a3f3a050 52 | convert(Float64, true) 53 | 54 | # ╔═╡ 8f6f438d-a2b7-4eb0-b527-cf75e7741418 55 | C25("3.1") 56 | 57 | # ╔═╡ ce9fcfb2-9ab0-445f-beea-907c83a5b88b 58 | convert(Float64, "3.1") 59 | 60 | # ╔═╡ 9c1240da-86e8-4b27-9a49-ec56c632b725 61 | parse(Float64,"3.1") 62 | 63 | # ╔═╡ d27918d5-363a-49c7-a358-5265d35244ab 64 | md""" 65 | # 3. convert and Type{T} type selectors 66 | """ 67 | 68 | # ╔═╡ 06df76cc-8c6f-4997-b7f0-8bd475f2fa7d 69 | md""" 70 | You can define your own convert 71 | """ 72 | 73 | 74 | # ╔═╡ 406b2aab-a2ea-4540-9f2a-06f2513095b5 75 | # Base.convert(::Type{Float64}, s::String) = parse(Float64, s) 76 | 77 | # ╔═╡ 77349ae4-6c57-40d5-91b1-db353c7f2ddb 78 | md""" 79 | ::Type{Float64} 80 | means that the second argument s is a string and the first argument is not a Float64 but is itself a type. See doc on [ Type{T} type selectors] (https://docs.julialang.org/en/v1/manual/types/#man-typet-type). 81 | """ 82 | 83 | # ╔═╡ f176edcc-de5e-4cd0-b6dd-428ce3ca302c 84 | begin 85 | h1(::String, s::String) = s 86 | h2(T::Type{String}, s::String) = T 87 | h3(T::Type{Number}, s::String) = T 88 | end 89 | 90 | # ╔═╡ 0d8857b7-747a-4415-b505-aaa3c9110027 91 | h1("abc","def") 92 | 93 | # ╔═╡ 5eed423a-c0fb-449c-a3cc-6ed4f4e7ae7f 94 | h2(String,"def") 95 | 96 | # ╔═╡ fdc2102a-b25a-431e-ba9e-827898b0a421 97 | h3(Number,"def") 98 | 99 | # ╔═╡ c8c00b27-1467-4119-b9c5-3a4050adb047 100 | isa(3.0, Float64) 101 | 102 | # ╔═╡ 29f0fa70-715e-450b-8f24-b83d00399240 103 | isa(Float64,Type{Float64}) 104 | 105 | # ╔═╡ 67a7ac4f-89cb-4fb1-99b5-23c7efae24e8 106 | Type{Float64} <: DataType 107 | 108 | # ╔═╡ f22b8320-1751-4920-995e-3dd762f1d884 109 | md""" 110 | # 4. getfield 111 | """ 112 | 113 | # ╔═╡ 3049e587-c25b-4926-8aa1-cf3781a1e642 114 | fieldnames( C25 ) 115 | 116 | # ╔═╡ 55d8bbc7-5d0e-495a-b371-34cffb9d4884 117 | C25(3).value 118 | 119 | # ╔═╡ a35181c6-5040-4cbb-9cb0-643c2a5b8593 120 | getfield(C25(3),:value) 121 | 122 | # ╔═╡ 13237b9e-edc6-4288-a51f-146b3e3d5252 123 | getfield(C25(3),1) 124 | 125 | # ╔═╡ f1e944fe-e8ee-47ca-bdb8-ffff8c245cdd 126 | md""" 127 | # 5. constructors with conditions 128 | """ 129 | 130 | # ╔═╡ 1a57c6a7-105e-4bed-acd4-0c4250d410f9 131 | md""" 132 | In this example, we also illustrate [short circuit evaluation](https://docs.julialang.org/en/v1/manual/control-flow/#Short-Circuit-Evaluation) 133 | 134 | Here we have used so-called "short-circuit" evaluation: && can be thought of as an if...then, while || is unless... (i.e. if not ... then). 135 | """ 136 | 137 | # ╔═╡ ac317618-c293-41cf-a5de-a123b1674e7f 138 | struct C25v2 139 | value::Float64 140 | 141 | function C25v2(x) 142 | 143 | x < 0 && throw(ArgumentError("Negative value not allowed.")) 144 | 145 | new(x) 146 | end 147 | end 148 | 149 | # ╔═╡ 31fd9ece-a5c2-4072-b1ef-3d33268dc678 150 | C25v2(-1) 151 | 152 | # ╔═╡ a7d8ce7b-50db-4503-972f-0b0e17e340ee 153 | md""" 154 | # 6. What if we don't want to nail down the type? 155 | """ 156 | 157 | # ╔═╡ 9f20ba44-658a-42d3-8baa-e25b4a4d86b0 158 | md""" 159 | sometimes it's okay to do this, but one can do better 160 | """ 161 | 162 | # ╔═╡ a78c8fbf-5555-4f10-9491-5f2af68c632e 163 | struct C25v3 164 | v 165 | end 166 | 167 | # ╔═╡ 93f6dacc-ebc8-4d0b-ab5f-10c9ec395a2d 168 | md""" 169 | # 7. Parametric Types 170 | """ 171 | 172 | # ╔═╡ b6b34a07-ffb1-4f62-8b71-3f6fb56f11fa 173 | struct C25v4{T} 174 | v::T 175 | end 176 | 177 | # ╔═╡ dab97bb1-aec9-4ff7-8e20-24725be751c5 178 | C25v4(3) 179 | 180 | # ╔═╡ 0720bbc9-c47a-4dcf-b43d-27c06354cdc2 181 | C25v4(2.54) 182 | 183 | # ╔═╡ b2d48852-3ec7-4e5c-8363-b7325ae895fe 184 | C25v4( rand(3,3)) 185 | 186 | # ╔═╡ 3e09c429-4daf-4bc0-92fa-97ef43dbaf68 187 | C25v4( C25v4(7)) 188 | 189 | # ╔═╡ e4bb130f-9e98-4afe-85e8-38f7483b62db 190 | md""" 191 | # 8. Adding Conditions to types 192 | """ 193 | 194 | # ╔═╡ 0d789338-f2b9-4765-a7e9-d33ee416f560 195 | struct C25v5{ T<:Real } 196 | v::T 197 | end 198 | 199 | # ╔═╡ af52a273-c1bc-46af-a0a3-ff826b324cd6 200 | C25v5(3) 201 | 202 | # ╔═╡ e65b158d-7c54-4b9c-895b-cdaaadde20ee 203 | C25v5("hello") 204 | 205 | # ╔═╡ 00000000-0000-0000-0000-000000000001 206 | PLUTO_PROJECT_TOML_CONTENTS = """ 207 | [deps] 208 | PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 209 | 210 | [compat] 211 | PlutoUI = "~0.7.60" 212 | """ 213 | 214 | # ╔═╡ 00000000-0000-0000-0000-000000000002 215 | PLUTO_MANIFEST_TOML_CONTENTS = """ 216 | # This file is machine-generated - editing it directly is not advised 217 | 218 | julia_version = "1.10.4" 219 | manifest_format = "2.0" 220 | project_hash = "c1674f662899f5bfc062df83020732df21a649e9" 221 | 222 | [[deps.AbstractPlutoDingetjes]] 223 | deps = ["Pkg"] 224 | git-tree-sha1 = "6e1d2a35f2f90a4bc7c2ed98079b2ba09c35b83a" 225 | uuid = "6e696c72-6542-2067-7265-42206c756150" 226 | version = "1.3.2" 227 | 228 | [[deps.ArgTools]] 229 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 230 | version = "1.1.1" 231 | 232 | [[deps.Artifacts]] 233 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 234 | 235 | [[deps.Base64]] 236 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 237 | 238 | [[deps.ColorTypes]] 239 | deps = ["FixedPointNumbers", "Random"] 240 | git-tree-sha1 = "b10d0b65641d57b8b4d5e234446582de5047050d" 241 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 242 | version = "0.11.5" 243 | 244 | [[deps.CompilerSupportLibraries_jll]] 245 | deps = ["Artifacts", "Libdl"] 246 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 247 | version = "1.1.1+0" 248 | 249 | [[deps.Dates]] 250 | deps = ["Printf"] 251 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 252 | 253 | [[deps.Downloads]] 254 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 255 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 256 | version = "1.6.0" 257 | 258 | [[deps.FileWatching]] 259 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 260 | 261 | [[deps.FixedPointNumbers]] 262 | deps = ["Statistics"] 263 | git-tree-sha1 = "05882d6995ae5c12bb5f36dd2ed3f61c98cbb172" 264 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 265 | version = "0.8.5" 266 | 267 | [[deps.Hyperscript]] 268 | deps = ["Test"] 269 | git-tree-sha1 = "179267cfa5e712760cd43dcae385d7ea90cc25a4" 270 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" 271 | version = "0.0.5" 272 | 273 | [[deps.HypertextLiteral]] 274 | deps = ["Tricks"] 275 | git-tree-sha1 = "7134810b1afce04bbc1045ca1985fbe81ce17653" 276 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 277 | version = "0.9.5" 278 | 279 | [[deps.IOCapture]] 280 | deps = ["Logging", "Random"] 281 | git-tree-sha1 = "b6d6bfdd7ce25b0f9b2f6b3dd56b2673a66c8770" 282 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 283 | version = "0.2.5" 284 | 285 | [[deps.InteractiveUtils]] 286 | deps = ["Markdown"] 287 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 288 | 289 | [[deps.JSON]] 290 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 291 | git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" 292 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 293 | version = "0.21.4" 294 | 295 | [[deps.LibCURL]] 296 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 297 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 298 | version = "0.6.4" 299 | 300 | [[deps.LibCURL_jll]] 301 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 302 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 303 | version = "8.4.0+0" 304 | 305 | [[deps.LibGit2]] 306 | deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] 307 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 308 | 309 | [[deps.LibGit2_jll]] 310 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] 311 | uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" 312 | version = "1.6.4+0" 313 | 314 | [[deps.LibSSH2_jll]] 315 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 316 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 317 | version = "1.11.0+1" 318 | 319 | [[deps.Libdl]] 320 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 321 | 322 | [[deps.LinearAlgebra]] 323 | deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] 324 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 325 | 326 | [[deps.Logging]] 327 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 328 | 329 | [[deps.MIMEs]] 330 | git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" 331 | uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" 332 | version = "0.1.4" 333 | 334 | [[deps.Markdown]] 335 | deps = ["Base64"] 336 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 337 | 338 | [[deps.MbedTLS_jll]] 339 | deps = ["Artifacts", "Libdl"] 340 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 341 | version = "2.28.2+1" 342 | 343 | [[deps.Mmap]] 344 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 345 | 346 | [[deps.MozillaCACerts_jll]] 347 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 348 | version = "2023.1.10" 349 | 350 | [[deps.NetworkOptions]] 351 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 352 | version = "1.2.0" 353 | 354 | [[deps.OpenBLAS_jll]] 355 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 356 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 357 | version = "0.3.23+4" 358 | 359 | [[deps.Parsers]] 360 | deps = ["Dates", "PrecompileTools", "UUIDs"] 361 | git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821" 362 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 363 | version = "2.8.1" 364 | 365 | [[deps.Pkg]] 366 | deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 367 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 368 | version = "1.10.0" 369 | 370 | [[deps.PlutoUI]] 371 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] 372 | git-tree-sha1 = "eba4810d5e6a01f612b948c9fa94f905b49087b0" 373 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 374 | version = "0.7.60" 375 | 376 | [[deps.PrecompileTools]] 377 | deps = ["Preferences"] 378 | git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f" 379 | uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" 380 | version = "1.2.1" 381 | 382 | [[deps.Preferences]] 383 | deps = ["TOML"] 384 | git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" 385 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 386 | version = "1.4.3" 387 | 388 | [[deps.Printf]] 389 | deps = ["Unicode"] 390 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 391 | 392 | [[deps.REPL]] 393 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 394 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 395 | 396 | [[deps.Random]] 397 | deps = ["SHA"] 398 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 399 | 400 | [[deps.Reexport]] 401 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 402 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 403 | version = "1.2.2" 404 | 405 | [[deps.SHA]] 406 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 407 | version = "0.7.0" 408 | 409 | [[deps.Serialization]] 410 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 411 | 412 | [[deps.Sockets]] 413 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 414 | 415 | [[deps.SparseArrays]] 416 | deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] 417 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 418 | version = "1.10.0" 419 | 420 | [[deps.Statistics]] 421 | deps = ["LinearAlgebra", "SparseArrays"] 422 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 423 | version = "1.10.0" 424 | 425 | [[deps.SuiteSparse_jll]] 426 | deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] 427 | uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" 428 | version = "7.2.1+1" 429 | 430 | [[deps.TOML]] 431 | deps = ["Dates"] 432 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 433 | version = "1.0.3" 434 | 435 | [[deps.Tar]] 436 | deps = ["ArgTools", "SHA"] 437 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 438 | version = "1.10.0" 439 | 440 | [[deps.Test]] 441 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 442 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 443 | 444 | [[deps.Tricks]] 445 | git-tree-sha1 = "7822b97e99a1672bfb1b49b668a6d46d58d8cbcb" 446 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" 447 | version = "0.1.9" 448 | 449 | [[deps.URIs]] 450 | git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b" 451 | uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" 452 | version = "1.5.1" 453 | 454 | [[deps.UUIDs]] 455 | deps = ["Random", "SHA"] 456 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 457 | 458 | [[deps.Unicode]] 459 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 460 | 461 | [[deps.Zlib_jll]] 462 | deps = ["Libdl"] 463 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 464 | version = "1.2.13+1" 465 | 466 | [[deps.libblastrampoline_jll]] 467 | deps = ["Artifacts", "Libdl"] 468 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 469 | version = "5.8.0+1" 470 | 471 | [[deps.nghttp2_jll]] 472 | deps = ["Artifacts", "Libdl"] 473 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 474 | version = "1.52.0+1" 475 | 476 | [[deps.p7zip_jll]] 477 | deps = ["Artifacts", "Libdl"] 478 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 479 | version = "17.4.0+2" 480 | """ 481 | 482 | # ╔═╡ Cell order: 483 | # ╠═e248ec9e-7b3c-11ef-3434-b1e6fc44ac3b 484 | # ╠═cb79cfad-9b8c-4017-ba7c-9cebcebc84f7 485 | # ╠═144c7859-9880-4d8a-af4a-3f0d4e77bc46 486 | # ╠═2b0b302c-f474-4964-b88b-e182057cd5db 487 | # ╠═9d6f60eb-7af4-4986-8946-e5a08868fda4 488 | # ╟─53ffeb7e-3e60-4c2f-b34a-984a7a7fb2df 489 | # ╠═fe8b88e1-05fb-4387-8b04-c329ff4c46f3 490 | # ╠═484b9cd9-2820-471b-85d3-75f23bbd9b61 491 | # ╟─61dbdaaa-cc20-4bc9-a80c-5f4b9be1536a 492 | # ╠═042e554c-59f7-4107-b958-76adcfcb8800 493 | # ╠═4f9f2a79-98e3-4244-81c0-6ad089c1ec57 494 | # ╠═64fc97fa-897a-4b03-81ad-e5121c3ccf00 495 | # ╠═6d46a963-d316-4b95-82a0-a8c8a3f3a050 496 | # ╠═8f6f438d-a2b7-4eb0-b527-cf75e7741418 497 | # ╠═ce9fcfb2-9ab0-445f-beea-907c83a5b88b 498 | # ╠═9c1240da-86e8-4b27-9a49-ec56c632b725 499 | # ╟─d27918d5-363a-49c7-a358-5265d35244ab 500 | # ╟─06df76cc-8c6f-4997-b7f0-8bd475f2fa7d 501 | # ╠═406b2aab-a2ea-4540-9f2a-06f2513095b5 502 | # ╟─77349ae4-6c57-40d5-91b1-db353c7f2ddb 503 | # ╠═f176edcc-de5e-4cd0-b6dd-428ce3ca302c 504 | # ╠═0d8857b7-747a-4415-b505-aaa3c9110027 505 | # ╠═5eed423a-c0fb-449c-a3cc-6ed4f4e7ae7f 506 | # ╠═fdc2102a-b25a-431e-ba9e-827898b0a421 507 | # ╠═c8c00b27-1467-4119-b9c5-3a4050adb047 508 | # ╠═29f0fa70-715e-450b-8f24-b83d00399240 509 | # ╠═67a7ac4f-89cb-4fb1-99b5-23c7efae24e8 510 | # ╟─f22b8320-1751-4920-995e-3dd762f1d884 511 | # ╠═3049e587-c25b-4926-8aa1-cf3781a1e642 512 | # ╠═55d8bbc7-5d0e-495a-b371-34cffb9d4884 513 | # ╠═a35181c6-5040-4cbb-9cb0-643c2a5b8593 514 | # ╠═13237b9e-edc6-4288-a51f-146b3e3d5252 515 | # ╠═f1e944fe-e8ee-47ca-bdb8-ffff8c245cdd 516 | # ╟─1a57c6a7-105e-4bed-acd4-0c4250d410f9 517 | # ╠═ac317618-c293-41cf-a5de-a123b1674e7f 518 | # ╠═31fd9ece-a5c2-4072-b1ef-3d33268dc678 519 | # ╟─a7d8ce7b-50db-4503-972f-0b0e17e340ee 520 | # ╟─9f20ba44-658a-42d3-8baa-e25b4a4d86b0 521 | # ╠═a78c8fbf-5555-4f10-9491-5f2af68c632e 522 | # ╟─93f6dacc-ebc8-4d0b-ab5f-10c9ec395a2d 523 | # ╠═b6b34a07-ffb1-4f62-8b71-3f6fb56f11fa 524 | # ╠═dab97bb1-aec9-4ff7-8e20-24725be751c5 525 | # ╠═0720bbc9-c47a-4dcf-b43d-27c06354cdc2 526 | # ╠═b2d48852-3ec7-4e5c-8363-b7325ae895fe 527 | # ╠═3e09c429-4daf-4bc0-92fa-97ef43dbaf68 528 | # ╟─e4bb130f-9e98-4afe-85e8-38f7483b62db 529 | # ╠═0d789338-f2b9-4765-a7e9-d33ee416f560 530 | # ╠═af52a273-c1bc-46af-a0a3-ff826b324cd6 531 | # ╠═e65b158d-7c54-4b9c-895b-cdaaadde20ee 532 | # ╟─00000000-0000-0000-0000-000000000001 533 | # ╟─00000000-0000-0000-0000-000000000002 534 | -------------------------------------------------------------------------------- /notebooks/geometric_sequence: -------------------------------------------------------------------------------- 1 | a,r,n refers implicitly to \rightarrow a,ar,ar^2,\ldots,ar^{n-1}$$ -------------------------------------------------------------------------------- /notebooks/geometric_sequence.jl: -------------------------------------------------------------------------------- 1 | # g(a,r,n) = geometric_sequence 2 | # refers implicitly to → a,ar,ar²,…, arⁿ⁻¹ 3 | 4 | # state(i,t) = iteration number and current term (i.e. t = arⁱ) 5 | # start = state(0,i) 6 | # next = (i,t) → (i+1, r*t) 7 | # done when i=n 8 | 9 | struct geometric_sequence 10 | a :: Float64 # start 11 | r :: Float64 # ratio 12 | n :: Int # number of terms 13 | end 14 | 15 | struct geometric_sequence_state 16 | i :: Int # iteration number 17 | t :: Float64 # current term 18 | end 19 | 20 | iterate(g::geometric_sequence) = geometric_sequence_state(0,g.a) # start 21 | 22 | # next should return term and state 23 | function iterate(g::geometric_sequence, s::geometric_sequence_state) 24 | s.t, geometric_sequence_state(s.i+1, g.r * s.t ) 25 | end -------------------------------------------------------------------------------- /notebooks/reduced_phil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks/reduced_phil.png -------------------------------------------------------------------------------- /notebooks_old/2_finite_differences.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.11 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 1e8197f6-3355-11ed-3e7c-e5184ff0442c 8 | using PlutoUI, LinearAlgebra 9 | 10 | # ╔═╡ 9835214d-cc0d-45cc-8894-2487b943566a 11 | TableOfContents(title="📚 Table of Contents", indent=true, depth=4, aside=true) 12 | 13 | # ╔═╡ d5a3aa08-9f8a-4cb6-8407-7942faf08f4c 14 | md""" 15 | The purpose of this notebook is to help understand the concept of gradients 16 | through finite differences, but not to suggest that this is a modern method to compute gradients. (Though finite differences can still serve nicely as a way of checking) 17 | """ 18 | 19 | # ╔═╡ 9a65a337-77e5-45c5-a11f-dd3b95a1407c 20 | md"# Simple Neural Network" 21 | 22 | # ╔═╡ 964c7bcb-98df-4955-8751-d1815fcf1ca5 23 | x₃(W₁,W₂,b₁,b₂,x₀,h::Function) = W₂ * h.(W₁*x₀ .+ b₁) .+ b₂ 24 | 25 | # ╔═╡ a8e7902b-2ad4-4599-9d81-3f28e0c6c5dc 26 | loss(x₃,y) = norm(x₃ .- y) 27 | 28 | # ╔═╡ c87a3ffa-774c-401f-8845-93c502363b14 29 | NN(x₀,y,W₁,W₂,b₁,b₂,h) = loss(x₃(W₁,W₂,b₁,b₂,x₀,h) , y ) 30 | 31 | # ╔═╡ 91477641-d4c7-48c9-ada9-b7576558ae86 32 | sizes = 3, 5, 7 33 | 34 | # ╔═╡ 87d01d74-ab2f-4634-a2c1-b11a8b674de3 35 | begin 36 | x₀ = rand( sizes[1]) 37 | W₁ = rand( sizes[2], sizes[1]) 38 | W₂ = rand( sizes[3], sizes[2]) 39 | b₁ = rand( sizes[2]) 40 | b₂ = rand( sizes[3]) 41 | h = sin 42 | y = rand( sizes[3] ) 43 | end 44 | 45 | # ╔═╡ 2d0d42b4-0a43-4aa3-a089-4343f2864abf 46 | NN(x₀,y,W₁,W₂,b₁,b₂,h) 47 | 48 | # ╔═╡ d5ab569c-f498-41db-b85c-1829bd046399 49 | begin 50 | md"""## Old Fashioned Gradient Computation 51 | (We don't want to do this anymore) 52 | """ 53 | end 54 | 55 | # ╔═╡ 006de347-5f29-4b5a-baac-a13df0848943 56 | begin # Create storage for the gradient 57 | ∇W₁ = zeros( size(W₁)) 58 | ∇W₂ = zeros( size(W₂)) 59 | ∇b₁ = zeros( size(b₁)) 60 | ∇b₂ = zeros( size(b₂)) 61 | end 62 | 63 | # ╔═╡ 221bb602-77f5-4ecf-95c4-3f9fba654eff 64 | function compute∇(W₁,W₂,b₁,b₂,x₀,h,y ) 65 | ϵ = .001 66 | # W₁ gradient 67 | for i=1:size(W₁,1), j=1:size(W₁,2) 68 | dW₁ = zeros( size(W₁)) 69 | dW₁[i,j] = ϵ 70 | ∇W₁[i,j] = (NN(x₀,y, W₁.+dW₁ ,W₂,b₁,b₂,h) - NN(x₀,y, W₁, W₂,b₁,b₂,h))/ϵ 71 | end 72 | # W₂ gradient 73 | for i=1:size(W₂,1), j=1:size(W₂,2) 74 | dW₂ = zeros( size(W₂)) 75 | dW₂[i,j] = ϵ 76 | ∇W₂[i,j] = (NN(x₀,y, W₁ ,W₂.+dW₂,b₁,b₂,h) - NN(x₀,y, W₁, W₂,b₁,b₂,h))/ϵ 77 | end 78 | # b₁ gradient 79 | for i=1:size(b₁,1) 80 | db₁ = zeros( size(b₁)) 81 | db₁[i] = ϵ 82 | ∇b₁[i] = (NN(x₀,y, W₁ ,W₂,b₁.+db₁,b₂,h) - NN(x₀,y, W₁, W₂,b₁,b₂,h))/ϵ 83 | end 84 | # b₂ gradient 85 | for i=1:size(b₁,1) 86 | db₂ = zeros( size(b₂)) 87 | db₂[i] = ϵ 88 | ∇b₂[i] = (NN(x₀,y, W₁ ,W₂,b₁,b₂.+db₂,h) - NN(x₀,y, W₁, W₂,b₁,b₂,h))/ϵ 89 | end 90 | return ∇W₁,∇W₂,∇b₁,∇b₂ 91 | end 92 | 93 | # ╔═╡ 0acbaeed-3f9c-4a35-b178-8a443a5882e9 94 | compute∇(W₁,W₂,b₁,b₂,x₀,h,y ) 95 | 96 | # ╔═╡ 13750938-b1b7-4914-867b-a77895389a10 97 | md""" 98 | ## What about dx₃/d(W₁,W₂,b₁,b₂) ??? 99 | (When the output function is not a scalar we call this a Jacobian) 100 | (Sometimes when it's too klunky to put in the form of a matrix, it is called a linearization but also Jacobian can be used) 101 | """ 102 | 103 | # ╔═╡ 586b13fa-d7b7-4d2e-b27d-46f744ebeccb 104 | md""" 105 | ## For starters think about the matrix Square Function A→A² 106 | """ 107 | 108 | # ╔═╡ 00000000-0000-0000-0000-000000000001 109 | PLUTO_PROJECT_TOML_CONTENTS = """ 110 | [deps] 111 | LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 112 | PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 113 | 114 | [compat] 115 | PlutoUI = "~0.7.40" 116 | """ 117 | 118 | # ╔═╡ 00000000-0000-0000-0000-000000000002 119 | PLUTO_MANIFEST_TOML_CONTENTS = """ 120 | # This file is machine-generated - editing it directly is not advised 121 | 122 | julia_version = "1.8.0-rc4" 123 | manifest_format = "2.0" 124 | project_hash = "3731524a0be8981c0b3969f8e7511b0d5e2849dc" 125 | 126 | [[deps.AbstractPlutoDingetjes]] 127 | deps = ["Pkg"] 128 | git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481" 129 | uuid = "6e696c72-6542-2067-7265-42206c756150" 130 | version = "1.1.4" 131 | 132 | [[deps.ArgTools]] 133 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 134 | version = "1.1.1" 135 | 136 | [[deps.Artifacts]] 137 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 138 | 139 | [[deps.Base64]] 140 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 141 | 142 | [[deps.ColorTypes]] 143 | deps = ["FixedPointNumbers", "Random"] 144 | git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4" 145 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 146 | version = "0.11.4" 147 | 148 | [[deps.CompilerSupportLibraries_jll]] 149 | deps = ["Artifacts", "Libdl"] 150 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 151 | version = "0.5.2+0" 152 | 153 | [[deps.Dates]] 154 | deps = ["Printf"] 155 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 156 | 157 | [[deps.Downloads]] 158 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 159 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 160 | version = "1.6.0" 161 | 162 | [[deps.FileWatching]] 163 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 164 | 165 | [[deps.FixedPointNumbers]] 166 | deps = ["Statistics"] 167 | git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" 168 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 169 | version = "0.8.4" 170 | 171 | [[deps.Hyperscript]] 172 | deps = ["Test"] 173 | git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9" 174 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" 175 | version = "0.0.4" 176 | 177 | [[deps.HypertextLiteral]] 178 | deps = ["Tricks"] 179 | git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9" 180 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 181 | version = "0.9.4" 182 | 183 | [[deps.IOCapture]] 184 | deps = ["Logging", "Random"] 185 | git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a" 186 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 187 | version = "0.2.2" 188 | 189 | [[deps.InteractiveUtils]] 190 | deps = ["Markdown"] 191 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 192 | 193 | [[deps.JSON]] 194 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 195 | git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e" 196 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 197 | version = "0.21.3" 198 | 199 | [[deps.LibCURL]] 200 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 201 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 202 | version = "0.6.3" 203 | 204 | [[deps.LibCURL_jll]] 205 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 206 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 207 | version = "7.84.0+0" 208 | 209 | [[deps.LibGit2]] 210 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 211 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 212 | 213 | [[deps.LibSSH2_jll]] 214 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 215 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 216 | version = "1.10.2+0" 217 | 218 | [[deps.Libdl]] 219 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 220 | 221 | [[deps.LinearAlgebra]] 222 | deps = ["Libdl", "libblastrampoline_jll"] 223 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 224 | 225 | [[deps.Logging]] 226 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 227 | 228 | [[deps.Markdown]] 229 | deps = ["Base64"] 230 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 231 | 232 | [[deps.MbedTLS_jll]] 233 | deps = ["Artifacts", "Libdl"] 234 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 235 | version = "2.28.0+0" 236 | 237 | [[deps.Mmap]] 238 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 239 | 240 | [[deps.MozillaCACerts_jll]] 241 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 242 | version = "2022.2.1" 243 | 244 | [[deps.NetworkOptions]] 245 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 246 | version = "1.2.0" 247 | 248 | [[deps.OpenBLAS_jll]] 249 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 250 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 251 | version = "0.3.20+0" 252 | 253 | [[deps.Parsers]] 254 | deps = ["Dates"] 255 | git-tree-sha1 = "3d5bf43e3e8b412656404ed9466f1dcbf7c50269" 256 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 257 | version = "2.4.0" 258 | 259 | [[deps.Pkg]] 260 | deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 261 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 262 | version = "1.8.0" 263 | 264 | [[deps.PlutoUI]] 265 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "UUIDs"] 266 | git-tree-sha1 = "a602d7b0babfca89005da04d89223b867b55319f" 267 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 268 | version = "0.7.40" 269 | 270 | [[deps.Printf]] 271 | deps = ["Unicode"] 272 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 273 | 274 | [[deps.REPL]] 275 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 276 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 277 | 278 | [[deps.Random]] 279 | deps = ["SHA", "Serialization"] 280 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 281 | 282 | [[deps.Reexport]] 283 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 284 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 285 | version = "1.2.2" 286 | 287 | [[deps.SHA]] 288 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 289 | version = "0.7.0" 290 | 291 | [[deps.Serialization]] 292 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 293 | 294 | [[deps.Sockets]] 295 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 296 | 297 | [[deps.SparseArrays]] 298 | deps = ["LinearAlgebra", "Random"] 299 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 300 | 301 | [[deps.Statistics]] 302 | deps = ["LinearAlgebra", "SparseArrays"] 303 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 304 | 305 | [[deps.TOML]] 306 | deps = ["Dates"] 307 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 308 | version = "1.0.0" 309 | 310 | [[deps.Tar]] 311 | deps = ["ArgTools", "SHA"] 312 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 313 | version = "1.10.0" 314 | 315 | [[deps.Test]] 316 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 317 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 318 | 319 | [[deps.Tricks]] 320 | git-tree-sha1 = "6bac775f2d42a611cdfcd1fb217ee719630c4175" 321 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" 322 | version = "0.1.6" 323 | 324 | [[deps.UUIDs]] 325 | deps = ["Random", "SHA"] 326 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 327 | 328 | [[deps.Unicode]] 329 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 330 | 331 | [[deps.Zlib_jll]] 332 | deps = ["Libdl"] 333 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 334 | version = "1.2.12+3" 335 | 336 | [[deps.libblastrampoline_jll]] 337 | deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] 338 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 339 | version = "5.1.1+0" 340 | 341 | [[deps.nghttp2_jll]] 342 | deps = ["Artifacts", "Libdl"] 343 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 344 | version = "1.48.0+0" 345 | 346 | [[deps.p7zip_jll]] 347 | deps = ["Artifacts", "Libdl"] 348 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 349 | version = "17.4.0+0" 350 | """ 351 | 352 | # ╔═╡ Cell order: 353 | # ╠═1e8197f6-3355-11ed-3e7c-e5184ff0442c 354 | # ╠═9835214d-cc0d-45cc-8894-2487b943566a 355 | # ╟─d5a3aa08-9f8a-4cb6-8407-7942faf08f4c 356 | # ╠═9a65a337-77e5-45c5-a11f-dd3b95a1407c 357 | # ╠═964c7bcb-98df-4955-8751-d1815fcf1ca5 358 | # ╠═a8e7902b-2ad4-4599-9d81-3f28e0c6c5dc 359 | # ╠═c87a3ffa-774c-401f-8845-93c502363b14 360 | # ╠═91477641-d4c7-48c9-ada9-b7576558ae86 361 | # ╠═87d01d74-ab2f-4634-a2c1-b11a8b674de3 362 | # ╠═2d0d42b4-0a43-4aa3-a089-4343f2864abf 363 | # ╟─d5ab569c-f498-41db-b85c-1829bd046399 364 | # ╠═006de347-5f29-4b5a-baac-a13df0848943 365 | # ╠═221bb602-77f5-4ecf-95c4-3f9fba654eff 366 | # ╠═0acbaeed-3f9c-4a35-b178-8a443a5882e9 367 | # ╟─13750938-b1b7-4914-867b-a77895389a10 368 | # ╟─586b13fa-d7b7-4d2e-b27d-46f744ebeccb 369 | # ╟─00000000-0000-0000-0000-000000000001 370 | # ╟─00000000-0000-0000-0000-000000000002 371 | -------------------------------------------------------------------------------- /notebooks_old/2layerocean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks_old/2layerocean.png -------------------------------------------------------------------------------- /notebooks_old/3_linear_transformations.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.11 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 095fe061-b141-4329-a598-89987e69ddb9 8 | 9 | 10 | # ╔═╡ 41f2ea0a-34ea-11ed-0bad-b90a0169251a 11 | T(c::Number) = x -> c * x 12 | 13 | # ╔═╡ 8054ab1a-e6ef-41db-951d-faa101364986 14 | T(w::Vector) = x::Vector -> w'x # could write w ⋅ x "cdot" with linalg 15 | 16 | # ╔═╡ 3267a067-0613-42fc-9304-d4370c01fff9 17 | T(A::Matrix) = x::Vector -> A*x 18 | 19 | # ╔═╡ 2837c741-ca74-436e-9065-6b86f4e3fd9b 20 | T(10)(1) 21 | 22 | # ╔═╡ bfbe6a47-61d9-436c-8c42-323ff7966c3b 23 | T(10)([1,2,3,4]) 24 | 25 | # ╔═╡ 3a501d1b-4a19-40c4-925d-0e20bd892904 26 | T(10)([1 2;3 4]) 27 | 28 | # ╔═╡ b25fe8e8-dff6-4c38-9e23-e3b7ff00f42b 29 | T([1,2,3,4])([5,6,7,8]) 30 | 31 | # ╔═╡ dde18f54-b212-4792-bf08-83b6c82b1ed6 32 | 33 | 34 | # ╔═╡ 00000000-0000-0000-0000-000000000001 35 | PLUTO_PROJECT_TOML_CONTENTS = """ 36 | [deps] 37 | """ 38 | 39 | # ╔═╡ 00000000-0000-0000-0000-000000000002 40 | PLUTO_MANIFEST_TOML_CONTENTS = """ 41 | # This file is machine-generated - editing it directly is not advised 42 | 43 | julia_version = "1.8.0-rc4" 44 | manifest_format = "2.0" 45 | project_hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709" 46 | 47 | [deps] 48 | """ 49 | 50 | # ╔═╡ Cell order: 51 | # ╠═095fe061-b141-4329-a598-89987e69ddb9 52 | # ╠═41f2ea0a-34ea-11ed-0bad-b90a0169251a 53 | # ╠═2837c741-ca74-436e-9065-6b86f4e3fd9b 54 | # ╠═bfbe6a47-61d9-436c-8c42-323ff7966c3b 55 | # ╠═3a501d1b-4a19-40c4-925d-0e20bd892904 56 | # ╠═8054ab1a-e6ef-41db-951d-faa101364986 57 | # ╠═b25fe8e8-dff6-4c38-9e23-e3b7ff00f42b 58 | # ╠═3267a067-0613-42fc-9304-d4370c01fff9 59 | # ╠═dde18f54-b212-4792-bf08-83b6c82b1ed6 60 | # ╟─00000000-0000-0000-0000-000000000001 61 | # ╟─00000000-0000-0000-0000-000000000002 62 | -------------------------------------------------------------------------------- /notebooks_old/3_symmetric_eigenvalue_derivatives.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.11 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 7f7e5188-7c86-11ec-34ca-3347d6c19595 8 | using LinearAlgebra, PlutoUI 9 | 10 | # ╔═╡ c6386d30-fc92-4d12-922c-3fe14d59ad68 11 | TableOfContents(title="Symmetric Eigenvalue Derivatives", indent=true, depth=4, aside=true) 12 | 13 | # ╔═╡ fd24a55b-d4d4-4bfe-a485-552c69c2c7f7 14 | md""" 15 | ## Warmup:Differentiating on the unit sphere in n dimensions 16 | 17 | Geometrically, we all know that velocity vectors (equivalently tangents) on the sphere are orthogonal to radii. Our differentials say this algebraically: 18 | 19 | """ 20 | 21 | # ╔═╡ 71ca8eac-0864-4beb-9f1a-b12ef4e6cf7b 22 | begin 23 | x = randn(5) 24 | dx= .000001 * randn(5) 25 | 26 | q = normalize(x) # make x a unit vector x/norm(x) 27 | dq = normalize(x+dx)-q # make (x+dx) a unit vector and subtract from q 28 | 29 | q'dq 30 | end 31 | 32 | # ╔═╡ 63df3a83-cd11-4d48-a24a-28d97deea00f 33 | md""" 34 | Since ``x^Tx=1``, we have that $(br) 35 | ``2x^Tdx=d(1)=0``, which says that at the point ``x`` on the sphere (a radius, if you will), ``dx``, 36 | the linearization of the constraint of moving along the sphere satisfies ``dx \perp x`` 37 | (dot product is 0). 38 | 39 | This is our first example where we have seen the infinitesimal perturbation ``dx`` being constrained. 40 | """ 41 | 42 | # ╔═╡ 38f7d4de-1072-4127-bbce-4e80da9273a8 43 | md""" 44 | ## Special case: a circle 45 | Let us consider simply the circle in the plane. 46 | 47 | ``x = (\cos \theta, \sin \theta)`` $(br) 48 | ``x^T dx = (\cos \theta, \sin \theta) \cdot (-\sin \theta, \cos \theta) d\theta= 0`` 49 | 50 | We can think of ``x`` as "extrinsic" coordinates, in that it is a vector in ``R^2.`` 51 | On the other hand ``\theta`` is an "intrinsic" coordinate, every point on the circle is specified by one ``\theta``. 52 | """ 53 | 54 | # ╔═╡ 44471684-8f86-43b3-8d79-660a48912dc0 55 | 56 | 57 | # ╔═╡ 5c83619a-3983-4c0a-ac2a-3f88fa6366c5 58 | md""" 59 | Suppose ``A`` is symmetric. We then know that if we allow general ``dx`` then 60 | $(br) ``d(\frac{1}{2}x^TAx)= (Ax)^Tdx `` and we would conclude ``Ax`` is the gradient. 61 | $(br) Now we wish to restrict to the sphere. $(br) 62 | 63 | ### On the sphere 64 | 65 | You may remember that ``I-xx^T`` is a *Projection Matrix* ( meaning that its equal to its square and it is symmetric). Geometrically the matrix removes components in the ``x`` direction. $(br) In particular if ``x^Tdx=0``, ``(I-xx^T)dx=dx``. 66 | 67 | It follows that if ``x^Tdx=0`` then ``x^TA(dx) = x^TA(I-xx^T)dx = ((I-xx^T)Ax)^T dx`` 68 | so that $(I-xx^T)Ax$ is the gradient of ``\frac{1}{2}x^TAx`` on the sphere. 69 | 70 | ### What did we just do? 71 | 72 | To get the gradient we needed two things: 73 | * A linearization of the function that is correct on tangents and 74 | * A direction that is tangent (satisfies the linearized constraint) 75 | 76 | ### Gradient of a general scalar function on the sphere: 77 | 78 | ``df= g(x)^T dx = ((I-xx^T)g(x))^Tdx`` 79 | 80 | Project the unconstrained gradient to the sphere to get the constrained gradient. It is the direction of maximal increase on the sphere. 81 | 82 | 83 | """ 84 | 85 | # ╔═╡ ac64ea62-e6f5-4b0b-8a21-4a0d84c9ed7b 86 | md""" 87 | # Differentiating nxn orthogonal matrices (the orthogonal group) 88 | """ 89 | 90 | # ╔═╡ 6f687dd6-78fb-4e5f-9bf8-e41f4a7665f4 91 | begin 92 | A = randn(5,5) 93 | dA = .00001 * randn(5,5) 94 | Q = qr(A).Q 95 | dQ = qr(A+dA).Q - Q 96 | (Q'dQ)/.00001 97 | end 98 | 99 | # ╔═╡ c9ccb3f3-70c6-4f99-92f4-a8529705b237 100 | md""" 101 | Do you see the structure? 102 | 103 | Q^TdQ is anti-symmetric (sometimes called skew-symmetric). 104 | 105 | (If ``M=-M^T``, we say that ``M`` is anti-symmetric. Note all anti-symmetric 106 | have 0 diagonally) 107 | 108 | Proof: The constraint of being orthogonal is ``Q^TQ=I`` 109 | so differentiating, ``Q^TdQ + dQ^TQ=0`` which is the same as 110 | saying `` (Q^TdQ) + (Q^TdQ)^T = 0``, but this is the equation 111 | for being antisymmetric. 112 | """ 113 | 114 | # ╔═╡ dd659a37-3235-4f56-921a-b348e233ce73 115 | md""" 116 | ## What is the dimension of the "surface" of orthogonal matrices in the ``n^2`` dimensional , n by n matrix space? 117 | 118 | For example when n=2 we have rotations (and reflections). Rotations have the form 119 | $(br) 120 | ``Q = \begin{pmatrix} \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \end{pmatrix} `` 121 | 122 | When n=2 we have one parameter. 123 | 124 | When n=3, airplane pilots know about "roll, pitch, and yaw" and these are three parameters. 125 | 126 | For general ``n`` the answer is ``n(n-1)/2.`` 127 | 128 | A few ways to see that: 129 | 130 | * n^2 free parameters, orthogonality ``Q^TQ=I`` imposes n(n+1)/2 constraints leaving 131 | ``n(n-1)/2`` free parameters. 132 | 133 | * When we do QR, the R "eats" up n(n+1)/2 parameters leaving n(n-1)/2 for Q. 134 | 135 | * Think about the symmetric eigenvalue problem: S = QΛQᵀ. 136 | S has n(n+1)/2 and Λ has n, leaving n(n-1)/2 for Q. 137 | 138 | * Think about the singular value decomposition. A = UΣVᵀ 139 | A has n^2, and Σ has n, leaving n(n-1) to be split evenly for the 140 | orthogonal matrices U and V. 141 | 142 | """ 143 | 144 | # ╔═╡ acaccf1f-cc17-47d8-ad6d-49108f067e17 145 | md""" 146 | ## Differentiating the Symmetric Eigendecomposition 147 | """ 148 | 149 | # ╔═╡ 1023e972-bd69-45ae-974a-1a093a57ece4 150 | md""" 151 | `` S = Q \Lambda Q^T`` is the eigendecomposition of a symmetric ``S`` with ``\Lambda`` diagonal containing eigenvalues, and ``Q`` orthogonal with columns as eigenvectors. 152 | $(br) 153 | 154 | ``dS = dQ \Lambda Q^T + Q d\Lambda Q^T + Q Λ dQ^T`` which may be written 155 | ``Q^T dS Q = Q^T dQ \Lambda - \Lambda Q^T dQ + d\Lambda`` 156 | 157 | $(br) 158 | 159 | Exercise: Check that the left and right side of the above are both symmetric. 160 | """ 161 | 162 | # ╔═╡ 7f566eab-a296-4666-8b5b-e94cf2debf68 163 | let 164 | A = randn(5,5) 165 | dA = .00001 * randn(5,5) 166 | S = A+A' # symmetrize A 167 | dS = dA + dA' # symmetrize dA 168 | Λ,Q = eigen(Symmetric(S)) 169 | Λ₁,Q₁ = eigen(Symmetric(S+dS)) 170 | dQ = Q₁-Q 171 | dΛ = Λ₁-Λ 172 | 173 | 174 | [Q'*dS*Q ; diagm(dΛ) + Q'dQ*diagm(Λ)-diagm(Λ)*Q'dQ] 175 | 176 | 177 | 178 | 179 | end 180 | 181 | # ╔═╡ 049e54a1-ee97-4fda-a9c6-2865ffe938a2 182 | md""" 183 | Maybe easier if one looks at the diagonal entries on their own: $(br) 184 | 185 | ``(Q^T dS Q)_{ii} = q_i^T dS q_i,`` where ``q_i`` is the ith eigenvector. $(br) 186 | Hence ``q_i^T dS q_i = d\lambda_i.`` 187 | 188 | Sometimes we think of a curve of matrices ``S(t)`` depending on a parameter such as time. If we ask for ``\frac{d\lambda_i}{dt}`` we have that it equals ``q_i^T \frac{dS(t)}{dt} q_i``. 189 | 190 | How do we get the gradient ``\nabla \lambda_i`` of one eigenvalue ``\lambda_i``? 191 | 192 | trace(``(q_i q_i^T)^T dS``) ``= d\lambda_i``, thus we instantly see 193 | that ``\nabla \lambda_i = q_i q_i^T`` 194 | """ 195 | 196 | # ╔═╡ 769d7ff6-bae1-423e-890b-69e0a0a9a79b 197 | md""" 198 | What about the eigenvectors? Those come from the off-diagonal elements: 199 | $(br) 200 | ``(Q^T dS Q)_{ij} = (Q^T \frac{dQ}{dt})_{ij}(\lambda_j-\lambda_i),`` if ``(i\ne j)``, 201 | so we can form the elements of `` Q^T \frac{dQ}{dt}`` (remember the diagonal is 0), 202 | and left multiply by ``Q`` to obtain ``\frac{dQ}{dt}.`` 203 | """ 204 | 205 | # ╔═╡ c9c7011a-8eca-4169-b890-97d6bb4a8244 206 | md""" 207 | It is interesting to get the second derivative of eigenvalues when moving along a line in symmetric matrix space. For simplicity we'll start at a diagonal matrix ``\Lambda``. 208 | 209 | Let ``S(t)= \Lambda + t E``. 210 | 211 | Differentiating ``\frac{d\Lambda}{dt} = diag( Q^T \frac{dS}{dt} Q)`` we get 212 | ``\frac{d^2\Lambda}{dt^2} = diag( Q^T \frac{d^2S}{dt^2} Q) + 2 diag(Q^T \frac{dS}{dt} \frac{dQ}{dt}).`` 213 | """ 214 | 215 | # ╔═╡ c3ae2756-5a33-4ec1-8323-262d65f018c6 216 | md""" 217 | Evaluating at ``Q=I`` and recognizing that the first term is $0$ since we are on a line, we have $(br) 218 | 219 | ``\frac{d^2\Lambda}{dt^2} = 2 diag( E \frac{dQ}{dt} )`` 220 | 221 | or 222 | 223 | ``\frac{d^2\lambda_i}{dt^2} = 2 \sum_{k \ne i} E_{ik}^2/(\lambda_i-\lambda_k).`` 224 | """ 225 | 226 | # ╔═╡ 81be4b3e-b7b8-4814-8239-11f949561868 227 | md""" 228 | We can write this as a Taylor series. 229 | 230 | ``\lambda_i(\epsilon) = \lambda_i + \epsilon E_{ii} + \epsilon^2 \sum_{k \ne i} E_{ik}^2/(\lambda_i-\lambda_k) + \ldots `` 231 | """ 232 | 233 | # ╔═╡ 00000000-0000-0000-0000-000000000001 234 | PLUTO_PROJECT_TOML_CONTENTS = """ 235 | [deps] 236 | LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 237 | PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 238 | 239 | [compat] 240 | PlutoUI = "~0.7.30" 241 | """ 242 | 243 | # ╔═╡ 00000000-0000-0000-0000-000000000002 244 | PLUTO_MANIFEST_TOML_CONTENTS = """ 245 | # This file is machine-generated - editing it directly is not advised 246 | 247 | [[AbstractPlutoDingetjes]] 248 | deps = ["Pkg"] 249 | git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481" 250 | uuid = "6e696c72-6542-2067-7265-42206c756150" 251 | version = "1.1.4" 252 | 253 | [[ArgTools]] 254 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 255 | version = "1.1.1" 256 | 257 | [[Artifacts]] 258 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 259 | 260 | [[Base64]] 261 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 262 | 263 | [[ColorTypes]] 264 | deps = ["FixedPointNumbers", "Random"] 265 | git-tree-sha1 = "024fe24d83e4a5bf5fc80501a314ce0d1aa35597" 266 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 267 | version = "0.11.0" 268 | 269 | [[CompilerSupportLibraries_jll]] 270 | deps = ["Artifacts", "Libdl"] 271 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 272 | version = "0.5.2+0" 273 | 274 | [[Dates]] 275 | deps = ["Printf"] 276 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 277 | 278 | [[Downloads]] 279 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 280 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 281 | version = "1.6.0" 282 | 283 | [[FileWatching]] 284 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 285 | 286 | [[FixedPointNumbers]] 287 | deps = ["Statistics"] 288 | git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" 289 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 290 | version = "0.8.4" 291 | 292 | [[Hyperscript]] 293 | deps = ["Test"] 294 | git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9" 295 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" 296 | version = "0.0.4" 297 | 298 | [[HypertextLiteral]] 299 | git-tree-sha1 = "2b078b5a615c6c0396c77810d92ee8c6f470d238" 300 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 301 | version = "0.9.3" 302 | 303 | [[IOCapture]] 304 | deps = ["Logging", "Random"] 305 | git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a" 306 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 307 | version = "0.2.2" 308 | 309 | [[InteractiveUtils]] 310 | deps = ["Markdown"] 311 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 312 | 313 | [[JSON]] 314 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 315 | git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37" 316 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 317 | version = "0.21.2" 318 | 319 | [[LibCURL]] 320 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 321 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 322 | version = "0.6.3" 323 | 324 | [[LibCURL_jll]] 325 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 326 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 327 | version = "7.84.0+0" 328 | 329 | [[LibGit2]] 330 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 331 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 332 | 333 | [[LibSSH2_jll]] 334 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 335 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 336 | version = "1.10.2+0" 337 | 338 | [[Libdl]] 339 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 340 | 341 | [[LinearAlgebra]] 342 | deps = ["Libdl", "libblastrampoline_jll"] 343 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 344 | 345 | [[Logging]] 346 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 347 | 348 | [[Markdown]] 349 | deps = ["Base64"] 350 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 351 | 352 | [[MbedTLS_jll]] 353 | deps = ["Artifacts", "Libdl"] 354 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 355 | version = "2.28.0+0" 356 | 357 | [[Mmap]] 358 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 359 | 360 | [[MozillaCACerts_jll]] 361 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 362 | version = "2022.2.1" 363 | 364 | [[NetworkOptions]] 365 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 366 | version = "1.2.0" 367 | 368 | [[OpenBLAS_jll]] 369 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 370 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 371 | version = "0.3.20+0" 372 | 373 | [[Parsers]] 374 | deps = ["Dates"] 375 | git-tree-sha1 = "92f91ba9e5941fc781fecf5494ac1da87bdac775" 376 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 377 | version = "2.2.0" 378 | 379 | [[Pkg]] 380 | deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 381 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 382 | version = "1.8.0" 383 | 384 | [[PlutoUI]] 385 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "UUIDs"] 386 | git-tree-sha1 = "5c0eb9099596090bb3215260ceca687b888a1575" 387 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 388 | version = "0.7.30" 389 | 390 | [[Printf]] 391 | deps = ["Unicode"] 392 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 393 | 394 | [[REPL]] 395 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 396 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 397 | 398 | [[Random]] 399 | deps = ["SHA", "Serialization"] 400 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 401 | 402 | [[Reexport]] 403 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 404 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 405 | version = "1.2.2" 406 | 407 | [[SHA]] 408 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 409 | version = "0.7.0" 410 | 411 | [[Serialization]] 412 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 413 | 414 | [[Sockets]] 415 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 416 | 417 | [[SparseArrays]] 418 | deps = ["LinearAlgebra", "Random"] 419 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 420 | 421 | [[Statistics]] 422 | deps = ["LinearAlgebra", "SparseArrays"] 423 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 424 | 425 | [[TOML]] 426 | deps = ["Dates"] 427 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 428 | version = "1.0.0" 429 | 430 | [[Tar]] 431 | deps = ["ArgTools", "SHA"] 432 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 433 | version = "1.10.0" 434 | 435 | [[Test]] 436 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 437 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 438 | 439 | [[UUIDs]] 440 | deps = ["Random", "SHA"] 441 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 442 | 443 | [[Unicode]] 444 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 445 | 446 | [[Zlib_jll]] 447 | deps = ["Libdl"] 448 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 449 | version = "1.2.12+3" 450 | 451 | [[libblastrampoline_jll]] 452 | deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] 453 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 454 | version = "5.1.1+0" 455 | 456 | [[nghttp2_jll]] 457 | deps = ["Artifacts", "Libdl"] 458 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 459 | version = "1.48.0+0" 460 | 461 | [[p7zip_jll]] 462 | deps = ["Artifacts", "Libdl"] 463 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 464 | version = "17.4.0+0" 465 | """ 466 | 467 | # ╔═╡ Cell order: 468 | # ╠═7f7e5188-7c86-11ec-34ca-3347d6c19595 469 | # ╠═c6386d30-fc92-4d12-922c-3fe14d59ad68 470 | # ╟─fd24a55b-d4d4-4bfe-a485-552c69c2c7f7 471 | # ╠═71ca8eac-0864-4beb-9f1a-b12ef4e6cf7b 472 | # ╟─63df3a83-cd11-4d48-a24a-28d97deea00f 473 | # ╟─38f7d4de-1072-4127-bbce-4e80da9273a8 474 | # ╠═44471684-8f86-43b3-8d79-660a48912dc0 475 | # ╟─5c83619a-3983-4c0a-ac2a-3f88fa6366c5 476 | # ╟─ac64ea62-e6f5-4b0b-8a21-4a0d84c9ed7b 477 | # ╠═6f687dd6-78fb-4e5f-9bf8-e41f4a7665f4 478 | # ╟─c9ccb3f3-70c6-4f99-92f4-a8529705b237 479 | # ╟─dd659a37-3235-4f56-921a-b348e233ce73 480 | # ╟─acaccf1f-cc17-47d8-ad6d-49108f067e17 481 | # ╟─1023e972-bd69-45ae-974a-1a093a57ece4 482 | # ╠═7f566eab-a296-4666-8b5b-e94cf2debf68 483 | # ╟─049e54a1-ee97-4fda-a9c6-2865ffe938a2 484 | # ╟─769d7ff6-bae1-423e-890b-69e0a0a9a79b 485 | # ╟─c9c7011a-8eca-4169-b890-97d6bb4a8244 486 | # ╟─c3ae2756-5a33-4ec1-8323-262d65f018c6 487 | # ╟─81be4b3e-b7b8-4814-8239-11f949561868 488 | # ╟─00000000-0000-0000-0000-000000000001 489 | # ╟─00000000-0000-0000-0000-000000000002 490 | -------------------------------------------------------------------------------- /notebooks_old/Broadening.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks_old/Broadening.pdf -------------------------------------------------------------------------------- /notebooks_old/Emission_TS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks_old/Emission_TS.png -------------------------------------------------------------------------------- /notebooks_old/GHGmodel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks_old/GHGmodel.png -------------------------------------------------------------------------------- /notebooks_old/LeakyGreenhouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks_old/LeakyGreenhouse.png -------------------------------------------------------------------------------- /notebooks_old/RightPicture_TC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks_old/RightPicture_TC.png -------------------------------------------------------------------------------- /notebooks_old/WaterVapor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks_old/WaterVapor.pdf -------------------------------------------------------------------------------- /notebooks_old/WrongPicture_TC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/notebooks_old/WrongPicture_TC.png -------------------------------------------------------------------------------- /notebooks_old/cpu_for_class.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.14 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 19f74853-2f50-4e89-b8c2-a238f12fbf65 8 | using PlutoUI 9 | 10 | # ╔═╡ 9f23d5e7-5cc3-4ba3-8fae-7c4786d65347 11 | using KernelAbstractions 12 | 13 | # ╔═╡ 569dadd3-c97c-4311-b9c7-1f6df16e4e58 14 | # Making an object callable 15 | 16 | # ╔═╡ 270d7deb-fb38-4dc6-a991-9696aeca5f0b 17 | (A::Array)(i,j) = A[i,j] * 10 18 | 19 | # ╔═╡ 293c977a-97f6-43a6-afaf-b9a1595139c9 20 | [1 2 3;4 5 6] 21 | 22 | # ╔═╡ 7dfefc08-6e10-431b-b393-93403b399e85 23 | [1 2 3;4 5 6][2,2] 24 | 25 | # ╔═╡ 60ed4508-8aaf-4d59-a9b2-859d2318cb83 26 | [1 2 3;4 5 6](2,2) 27 | 28 | # ╔═╡ 086a74b8-d61a-4c93-a3c2-68dfccded570 29 | md""" 30 | Make sin callable 31 | """ 32 | 33 | # ╔═╡ b38218ff-b59a-4fcd-97f9-d5bc09bd3382 34 | md""" 35 | Wrap functions in a kernel so we can get control over it 36 | """ 37 | 38 | # ╔═╡ 087a1ecc-59d1-11ed-1edc-c9d2f1082687 39 | begin 40 | 41 | struct VectorizeMe{F} 42 | func::F 43 | end 44 | 45 | # Make any f callable on a vector 46 | (f::VectorizeMe)(A::Array) = f.func.(A) 47 | 48 | 49 | 50 | end 51 | 52 | # ╔═╡ 955492bf-5e9d-4c3c-92fb-a8f437324b3c 53 | VectorizeMe(x->x^2)([1,2,3]) 54 | 55 | 56 | # ╔═╡ 26c44e57-6fa2-44f0-92f1-b2923e630c9b 57 | typeof(VectorizeMe(x->x^2)) 58 | 59 | # ╔═╡ 1aba26a0-1add-4c1a-bfc2-0c84efac31c3 60 | md""" 61 | Suppose I want this behavior for all functions: 62 | f(i,v) = f(v[i]) 63 | """ 64 | 65 | # ╔═╡ a65f191d-f6a4-46af-9a89-6c7e3aa16455 66 | begin 67 | 68 | struct Kernel1{F} 69 | func::F 70 | end 71 | 72 | # Make any f take on both an index 73 | (f::Kernel1)(i,A::Vector) = f.func(A[i]) 74 | 75 | 76 | 77 | end 78 | 79 | # ╔═╡ 97c1cde2-7a68-4152-a826-f8de8eab1b25 80 | atan.([1,2,3],6) 81 | 82 | # ╔═╡ 81e236e5-79f2-4bb0-9700-7f54b04c02e4 83 | Kernel1(atan)(3,[1,2,3],6) 84 | 85 | # ╔═╡ 84ee162b-4f3a-4cc8-b7b2-0f54f1942d3b 86 | begin 87 | 88 | struct Kernel2{F} 89 | func::F 90 | end 91 | 92 | # Make any f take on both an index 93 | (f::Kernel2)(i,A::Vector,args...) = f.func(A[i],args...) 94 | 95 | 96 | end 97 | 98 | # ╔═╡ a51db5e5-271d-4128-ad72-9c386d10fba0 99 | Kernel2(atan)(3,[1,2,3],6) 100 | 101 | # ╔═╡ 04ad73b2-dd1d-46ea-b2cf-23f68233c716 102 | begin 103 | 104 | struct Kernel3{F} 105 | func::F 106 | end 107 | 108 | # Make any f take on both an index 109 | (f::Kernel3)(A::Vector,args...) = [ f.func(A[i],args...) for i=1:length(A) ] 110 | 111 | 112 | end 113 | 114 | # ╔═╡ 72c0348e-f807-4495-836b-33b4364674ac 115 | Kernel3(atan)([1,2,3],6) 116 | 117 | # ╔═╡ 0eb8df71-abb9-4802-8631-61877bb592cf 118 | md""" 119 | now in place 120 | """ 121 | 122 | # ╔═╡ 573a73ac-8403-4876-88f4-fb2619148178 123 | function sin(A,i) 124 | A[i]=i 125 | A 126 | end 127 | 128 | # ╔═╡ f1b0a547-fca0-44ad-a6ac-c43a2f719562 129 | (s::typeof(sin))(x::Vector) = sin.(x) 130 | 131 | # ╔═╡ 3730edfa-4c3c-43db-a5f4-9808a37e587d 132 | sin([1,2,3]) 133 | 134 | # ╔═╡ 740a224d-6fef-4c49-8d2c-da1dc1d41725 135 | VectorizeMe(sin)(rand(3)) 136 | 137 | # ╔═╡ 8a449e8a-2132-47e6-ab0f-69bd39de9dd6 138 | typeof(VectorizeMe(sin)) 139 | 140 | # ╔═╡ b49f4ba9-bf80-4f84-8a14-de5beefc65e4 141 | Kernel1(sin)(3,[1,2,3]), sin(3) 142 | 143 | # ╔═╡ 80a9d6f9-9401-4a21-b980-d0fc8028d52f 144 | sin([5,6,7],2) 145 | 146 | # ╔═╡ b06403f7-dcca-4bee-8eae-ce94671b6294 147 | function atan!(i,A,args...) 148 | A[i] = atan(A[i],args...) 149 | end 150 | 151 | # ╔═╡ 9497351d-1a4f-4eb2-a1b7-7153bfbbdadb 152 | begin 153 | 154 | struct Kernel4{F} 155 | func!::F 156 | end 157 | 158 | # Make any f take on both an index 159 | function (f::Kernel4)(A::Vector,args...) 160 | for i=1:length(A) 161 | f.func!(i,A,args...) 162 | end 163 | end 164 | 165 | 166 | end 167 | 168 | # ╔═╡ 4f391154-4333-45f2-908f-3bf6c839e410 169 | begin 170 | v = [1.0,2,3] 171 | Kernel4(atan!)(v,6) 172 | end 173 | 174 | # ╔═╡ a095a1a3-f758-4ac2-a37e-81177b299388 175 | v 176 | 177 | # ╔═╡ def1145d-c455-49a6-9f3d-73794c41c3c7 178 | atan.([1,2,3],6) 179 | 180 | # ╔═╡ 4070b1b7-fd74-4f26-b01b-2922daed406a 181 | begin 182 | n = 5 183 | #positions = rand(n) 184 | end 185 | 186 | # ╔═╡ 972f3f82-560d-469d-9215-069ef4167562 187 | function myproblem1(x) 188 | y = zero(x) 189 | n = length(x) 190 | for i=1:n ,j=1:n 191 | if j≠i 192 | y[i] += 1. /abs(x[i]-x[j]) 193 | end 194 | end 195 | y 196 | end 197 | 198 | # ╔═╡ d8c47d59-a5ce-4c6b-943f-6e73d522b209 199 | function myproblem2(x) 200 | y = zero(x) 201 | n = length(x) 202 | for i=1:n 203 | y[i] = sum( 1/abs(x[i]-x[j]) for j=1:n if j≠i) 204 | end 205 | 206 | y 207 | end 208 | 209 | # ╔═╡ 8286beee-54b6-471d-b27a-ce24dc6a8438 210 | myproblem1([1.0,2,3]) 211 | 212 | # ╔═╡ 80dea46a-ceeb-4b15-8a6e-95232598cb53 213 | myproblem2([1.0,2,3]) 214 | 215 | # ╔═╡ 975346eb-34cd-4457-8cbe-d4150aa039f6 216 | function myproblem3(x) 217 | 218 | A = 1 ./ abs.(x .- x') 219 | A = ( x-> isinf(x) ? 0 : x).(A) 220 | sum(A, dims=1) 221 | end 222 | 223 | # ╔═╡ 65e04649-f79c-4421-97fc-bae6832705a2 224 | myproblem3([1.0,2,3]) 225 | 226 | # ╔═╡ c3a361ae-3714-409e-ab0e-eb19bba53ab2 227 | isinf(3.5) 228 | 229 | # ╔═╡ 9c06aad4-7b94-41dd-baf0-9d8a0bfe0591 230 | force_law(x,y) = 1/abs(x-y) 231 | 232 | # ╔═╡ d33e625a-9c05-4180-9009-4e014d0fd2ec 233 | num_cores = Threads.nthreads() 234 | 235 | # ╔═╡ a9161a66-a19c-4a4d-a5e8-0ba120051ad7 236 | begin 237 | positions = rand(n) 238 | forces = similar(positions) 239 | end 240 | 241 | # ╔═╡ e3736993-b7df-48ea-ac8c-2fec24f78537 242 | @kernel function myproblem!(forces, positions, force_law) 243 | tid = @index(Global, Linear) 244 | forces[tid] = 0.0 245 | 246 | for j = 1:length(positions) 247 | if j != tid 248 | forces[tid] += force_law(positions[tid], positions[j] ) end 249 | end 250 | 251 | end 252 | 253 | # ╔═╡ 349b3418-e9b7-4044-9523-f1cbc9404987 254 | kernel! = myproblem!(CPU(),num_cores) 255 | 256 | # ╔═╡ 07eee79f-f827-4e26-9fa8-5721dece1503 257 | kernel!(forces, positions, force_law, ndrange=n) 258 | 259 | # ╔═╡ 861f0dd3-3bb0-429a-8150-1ef7e3eaab04 260 | forces 261 | 262 | # ╔═╡ 18312733-02c4-44ce-a487-15799ee480e2 263 | myproblem1(positions) 264 | 265 | # ╔═╡ c1276493-ebff-4600-a5d4-728a903cd1ee 266 | myproblem2(positions) 267 | 268 | # ╔═╡ 00000000-0000-0000-0000-000000000001 269 | PLUTO_PROJECT_TOML_CONTENTS = """ 270 | [deps] 271 | KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" 272 | PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 273 | 274 | [compat] 275 | KernelAbstractions = "~0.8.4" 276 | PlutoUI = "~0.7.48" 277 | """ 278 | 279 | # ╔═╡ 00000000-0000-0000-0000-000000000002 280 | PLUTO_MANIFEST_TOML_CONTENTS = """ 281 | # This file is machine-generated - editing it directly is not advised 282 | 283 | julia_version = "1.8.0-rc4" 284 | manifest_format = "2.0" 285 | project_hash = "ffb6dfa41b7d6ca0e64373f4cd9305ae5eacd441" 286 | 287 | [[deps.AbstractPlutoDingetjes]] 288 | deps = ["Pkg"] 289 | git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481" 290 | uuid = "6e696c72-6542-2067-7265-42206c756150" 291 | version = "1.1.4" 292 | 293 | [[deps.Adapt]] 294 | deps = ["LinearAlgebra"] 295 | git-tree-sha1 = "195c5505521008abea5aee4f96930717958eac6f" 296 | uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" 297 | version = "3.4.0" 298 | 299 | [[deps.ArgTools]] 300 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 301 | version = "1.1.1" 302 | 303 | [[deps.Artifacts]] 304 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 305 | 306 | [[deps.Atomix]] 307 | deps = ["UnsafeAtomics"] 308 | git-tree-sha1 = "c06a868224ecba914baa6942988e2f2aade419be" 309 | uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" 310 | version = "0.1.0" 311 | 312 | [[deps.Base64]] 313 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 314 | 315 | [[deps.CEnum]] 316 | git-tree-sha1 = "eb4cb44a499229b3b8426dcfb5dd85333951ff90" 317 | uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" 318 | version = "0.4.2" 319 | 320 | [[deps.ColorTypes]] 321 | deps = ["FixedPointNumbers", "Random"] 322 | git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4" 323 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 324 | version = "0.11.4" 325 | 326 | [[deps.CompilerSupportLibraries_jll]] 327 | deps = ["Artifacts", "Libdl"] 328 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 329 | version = "0.5.2+0" 330 | 331 | [[deps.Dates]] 332 | deps = ["Printf"] 333 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 334 | 335 | [[deps.Downloads]] 336 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 337 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 338 | version = "1.6.0" 339 | 340 | [[deps.FileWatching]] 341 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 342 | 343 | [[deps.FixedPointNumbers]] 344 | deps = ["Statistics"] 345 | git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" 346 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 347 | version = "0.8.4" 348 | 349 | [[deps.Hyperscript]] 350 | deps = ["Test"] 351 | git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9" 352 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" 353 | version = "0.0.4" 354 | 355 | [[deps.HypertextLiteral]] 356 | deps = ["Tricks"] 357 | git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9" 358 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 359 | version = "0.9.4" 360 | 361 | [[deps.IOCapture]] 362 | deps = ["Logging", "Random"] 363 | git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a" 364 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 365 | version = "0.2.2" 366 | 367 | [[deps.InteractiveUtils]] 368 | deps = ["Markdown"] 369 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 370 | 371 | [[deps.JLLWrappers]] 372 | deps = ["Preferences"] 373 | git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" 374 | uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" 375 | version = "1.4.1" 376 | 377 | [[deps.JSON]] 378 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 379 | git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e" 380 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 381 | version = "0.21.3" 382 | 383 | [[deps.KernelAbstractions]] 384 | deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"] 385 | git-tree-sha1 = "eed4743b01ca88d23be3663bac121374940b475b" 386 | uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c" 387 | version = "0.8.4" 388 | 389 | [[deps.LLVM]] 390 | deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"] 391 | git-tree-sha1 = "e7e9184b0bf0158ac4e4aa9daf00041b5909bf1a" 392 | uuid = "929cbde3-209d-540e-8aea-75f648917ca0" 393 | version = "4.14.0" 394 | 395 | [[deps.LLVMExtra_jll]] 396 | deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg", "TOML"] 397 | git-tree-sha1 = "771bfe376249626d3ca12bcd58ba243d3f961576" 398 | uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab" 399 | version = "0.0.16+0" 400 | 401 | [[deps.LazyArtifacts]] 402 | deps = ["Artifacts", "Pkg"] 403 | uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" 404 | 405 | [[deps.LibCURL]] 406 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 407 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 408 | version = "0.6.3" 409 | 410 | [[deps.LibCURL_jll]] 411 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 412 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 413 | version = "7.84.0+0" 414 | 415 | [[deps.LibGit2]] 416 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 417 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 418 | 419 | [[deps.LibSSH2_jll]] 420 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 421 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 422 | version = "1.10.2+0" 423 | 424 | [[deps.Libdl]] 425 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 426 | 427 | [[deps.LinearAlgebra]] 428 | deps = ["Libdl", "libblastrampoline_jll"] 429 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 430 | 431 | [[deps.Logging]] 432 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 433 | 434 | [[deps.MIMEs]] 435 | git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" 436 | uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" 437 | version = "0.1.4" 438 | 439 | [[deps.MacroTools]] 440 | deps = ["Markdown", "Random"] 441 | git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2" 442 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" 443 | version = "0.5.10" 444 | 445 | [[deps.Markdown]] 446 | deps = ["Base64"] 447 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 448 | 449 | [[deps.MbedTLS_jll]] 450 | deps = ["Artifacts", "Libdl"] 451 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 452 | version = "2.28.0+0" 453 | 454 | [[deps.Mmap]] 455 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 456 | 457 | [[deps.MozillaCACerts_jll]] 458 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 459 | version = "2022.2.1" 460 | 461 | [[deps.NetworkOptions]] 462 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 463 | version = "1.2.0" 464 | 465 | [[deps.OpenBLAS_jll]] 466 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 467 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 468 | version = "0.3.20+0" 469 | 470 | [[deps.Parsers]] 471 | deps = ["Dates"] 472 | git-tree-sha1 = "6c01a9b494f6d2a9fc180a08b182fcb06f0958a0" 473 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 474 | version = "2.4.2" 475 | 476 | [[deps.Pkg]] 477 | deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 478 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 479 | version = "1.8.0" 480 | 481 | [[deps.PlutoUI]] 482 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] 483 | git-tree-sha1 = "efc140104e6d0ae3e7e30d56c98c4a927154d684" 484 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 485 | version = "0.7.48" 486 | 487 | [[deps.Preferences]] 488 | deps = ["TOML"] 489 | git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" 490 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 491 | version = "1.3.0" 492 | 493 | [[deps.Printf]] 494 | deps = ["Unicode"] 495 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 496 | 497 | [[deps.REPL]] 498 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 499 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 500 | 501 | [[deps.Random]] 502 | deps = ["SHA", "Serialization"] 503 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 504 | 505 | [[deps.Reexport]] 506 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 507 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 508 | version = "1.2.2" 509 | 510 | [[deps.SHA]] 511 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 512 | version = "0.7.0" 513 | 514 | [[deps.Serialization]] 515 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 516 | 517 | [[deps.Sockets]] 518 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 519 | 520 | [[deps.SparseArrays]] 521 | deps = ["LinearAlgebra", "Random"] 522 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 523 | 524 | [[deps.StaticArrays]] 525 | deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"] 526 | git-tree-sha1 = "f86b3a049e5d05227b10e15dbb315c5b90f14988" 527 | uuid = "90137ffa-7385-5640-81b9-e52037218182" 528 | version = "1.5.9" 529 | 530 | [[deps.StaticArraysCore]] 531 | git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a" 532 | uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" 533 | version = "1.4.0" 534 | 535 | [[deps.Statistics]] 536 | deps = ["LinearAlgebra", "SparseArrays"] 537 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 538 | 539 | [[deps.TOML]] 540 | deps = ["Dates"] 541 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 542 | version = "1.0.0" 543 | 544 | [[deps.Tar]] 545 | deps = ["ArgTools", "SHA"] 546 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 547 | version = "1.10.0" 548 | 549 | [[deps.Test]] 550 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 551 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 552 | 553 | [[deps.Tricks]] 554 | git-tree-sha1 = "6bac775f2d42a611cdfcd1fb217ee719630c4175" 555 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" 556 | version = "0.1.6" 557 | 558 | [[deps.URIs]] 559 | git-tree-sha1 = "e59ecc5a41b000fa94423a578d29290c7266fc10" 560 | uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" 561 | version = "1.4.0" 562 | 563 | [[deps.UUIDs]] 564 | deps = ["Random", "SHA"] 565 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 566 | 567 | [[deps.Unicode]] 568 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 569 | 570 | [[deps.UnsafeAtomics]] 571 | git-tree-sha1 = "6331ac3440856ea1988316b46045303bef658278" 572 | uuid = "013be700-e6cd-48c3-b4a1-df204f14c38f" 573 | version = "0.2.1" 574 | 575 | [[deps.UnsafeAtomicsLLVM]] 576 | deps = ["LLVM", "UnsafeAtomics"] 577 | git-tree-sha1 = "33af9d2031d0dc09e2be9a0d4beefec4466def8e" 578 | uuid = "d80eeb9a-aca5-4d75-85e5-170c8b632249" 579 | version = "0.1.0" 580 | 581 | [[deps.Zlib_jll]] 582 | deps = ["Libdl"] 583 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 584 | version = "1.2.12+3" 585 | 586 | [[deps.libblastrampoline_jll]] 587 | deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] 588 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 589 | version = "5.1.1+0" 590 | 591 | [[deps.nghttp2_jll]] 592 | deps = ["Artifacts", "Libdl"] 593 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 594 | version = "1.48.0+0" 595 | 596 | [[deps.p7zip_jll]] 597 | deps = ["Artifacts", "Libdl"] 598 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 599 | version = "17.4.0+0" 600 | """ 601 | 602 | # ╔═╡ Cell order: 603 | # ╠═19f74853-2f50-4e89-b8c2-a238f12fbf65 604 | # ╠═569dadd3-c97c-4311-b9c7-1f6df16e4e58 605 | # ╠═270d7deb-fb38-4dc6-a991-9696aeca5f0b 606 | # ╠═293c977a-97f6-43a6-afaf-b9a1595139c9 607 | # ╠═7dfefc08-6e10-431b-b393-93403b399e85 608 | # ╠═60ed4508-8aaf-4d59-a9b2-859d2318cb83 609 | # ╠═086a74b8-d61a-4c93-a3c2-68dfccded570 610 | # ╠═f1b0a547-fca0-44ad-a6ac-c43a2f719562 611 | # ╠═3730edfa-4c3c-43db-a5f4-9808a37e587d 612 | # ╠═b38218ff-b59a-4fcd-97f9-d5bc09bd3382 613 | # ╠═087a1ecc-59d1-11ed-1edc-c9d2f1082687 614 | # ╠═740a224d-6fef-4c49-8d2c-da1dc1d41725 615 | # ╠═955492bf-5e9d-4c3c-92fb-a8f437324b3c 616 | # ╠═8a449e8a-2132-47e6-ab0f-69bd39de9dd6 617 | # ╠═26c44e57-6fa2-44f0-92f1-b2923e630c9b 618 | # ╠═1aba26a0-1add-4c1a-bfc2-0c84efac31c3 619 | # ╠═a65f191d-f6a4-46af-9a89-6c7e3aa16455 620 | # ╠═b49f4ba9-bf80-4f84-8a14-de5beefc65e4 621 | # ╠═97c1cde2-7a68-4152-a826-f8de8eab1b25 622 | # ╠═81e236e5-79f2-4bb0-9700-7f54b04c02e4 623 | # ╠═84ee162b-4f3a-4cc8-b7b2-0f54f1942d3b 624 | # ╠═a51db5e5-271d-4128-ad72-9c386d10fba0 625 | # ╠═04ad73b2-dd1d-46ea-b2cf-23f68233c716 626 | # ╠═72c0348e-f807-4495-836b-33b4364674ac 627 | # ╠═0eb8df71-abb9-4802-8631-61877bb592cf 628 | # ╠═573a73ac-8403-4876-88f4-fb2619148178 629 | # ╠═80a9d6f9-9401-4a21-b980-d0fc8028d52f 630 | # ╠═b06403f7-dcca-4bee-8eae-ce94671b6294 631 | # ╠═9497351d-1a4f-4eb2-a1b7-7153bfbbdadb 632 | # ╠═4f391154-4333-45f2-908f-3bf6c839e410 633 | # ╠═a095a1a3-f758-4ac2-a37e-81177b299388 634 | # ╠═def1145d-c455-49a6-9f3d-73794c41c3c7 635 | # ╠═4070b1b7-fd74-4f26-b01b-2922daed406a 636 | # ╠═972f3f82-560d-469d-9215-069ef4167562 637 | # ╠═d8c47d59-a5ce-4c6b-943f-6e73d522b209 638 | # ╠═8286beee-54b6-471d-b27a-ce24dc6a8438 639 | # ╠═80dea46a-ceeb-4b15-8a6e-95232598cb53 640 | # ╠═975346eb-34cd-4457-8cbe-d4150aa039f6 641 | # ╠═65e04649-f79c-4421-97fc-bae6832705a2 642 | # ╠═c3a361ae-3714-409e-ab0e-eb19bba53ab2 643 | # ╠═9f23d5e7-5cc3-4ba3-8fae-7c4786d65347 644 | # ╠═9c06aad4-7b94-41dd-baf0-9d8a0bfe0591 645 | # ╠═d33e625a-9c05-4180-9009-4e014d0fd2ec 646 | # ╠═a9161a66-a19c-4a4d-a5e8-0ba120051ad7 647 | # ╠═e3736993-b7df-48ea-ac8c-2fec24f78537 648 | # ╠═349b3418-e9b7-4044-9523-f1cbc9404987 649 | # ╠═07eee79f-f827-4e26-9fa8-5721dece1503 650 | # ╠═861f0dd3-3bb0-429a-8150-1ef7e3eaab04 651 | # ╠═18312733-02c4-44ce-a487-15799ee480e2 652 | # ╠═c1276493-ebff-4600-a5d4-728a903cd1ee 653 | # ╟─00000000-0000-0000-0000-000000000001 654 | # ╟─00000000-0000-0000-0000-000000000002 655 | -------------------------------------------------------------------------------- /notebooks_old/floop_nbody.jl: -------------------------------------------------------------------------------- 1 | using CUDA 2 | using FLoops 3 | using FoldsCUDA 4 | using StaticArrays 5 | 6 | function nbody(n, num_steps, dt; ArrayType=Array, box_size=1, dims=2) 7 | accelerations = ArrayType([SVector(Tuple(zeros(dims))) for i = 1:n]) 8 | positions = ArrayType([SVector(Tuple(rand(dims) * box_size .- 0.5 * box_size)) for i = 1:n]) 9 | masses = ArrayType(ones(n)) 10 | last_positions = copy(positions) 11 | 12 | trajectories = zeros(eltype(positions), num_steps, 2) # always "CPU" array 13 | 14 | for t in 1:num_steps 15 | # Equivalent: 16 | # @floop for i in 1:n 17 | # pᵢ = positions[i] 18 | # mᵢ = masses[i] 19 | # ... 20 | # end 21 | 22 | @floop for (i, pᵢ, mᵢ) in zip(1:n, positions, masses) 23 | a = zero(accelerations[i]) 24 | for (j, pⱼ, mⱼ) in zip(1:n, positions, masses) 25 | if j != i 26 | r² = sum((pᵢ .- pⱼ) .^ 2) 27 | 𝟙 = (pᵢ .- pⱼ) ./ sqrt(r²) 28 | G = 9.81 29 | a += (G * mᵢ * mⱼ / r²) * 𝟙 30 | end 31 | end 32 | accelerations[i] = a 33 | end 34 | 35 | # verlet 36 | positions .= positions * 2 .- last_positions .+ accelerations * dt * dt 37 | 38 | last_positions .= positions 39 | 40 | # "Download" first two position data 41 | @views copy!(trajectories[t, :], positions[1:2]) 42 | end 43 | 44 | return trajectories 45 | end 46 | 47 | # nbody(10, 20, 0.1) 48 | positions = nbody(100, 10000, 0.1; ArrayType = CuArray) 49 | 50 | using Plots 51 | plot( 52 | map(p -> p.x, positions), 53 | map(p -> p.y, positions), 54 | ) 55 | -------------------------------------------------------------------------------- /notebooks_old/gdalle/challenge.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.14 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 35580339-744e-422a-b474-47dda002390a 8 | begin 9 | using PlutoTeachingTools 10 | using PlutoUI 11 | end 12 | 13 | # ╔═╡ fcc41a80-b44a-4eb8-ade6-13f075c5b72f 14 | TableOfContents() 15 | 16 | # ╔═╡ 51d9bad9-aebd-40bb-8682-688a57c876db 17 | html"" 18 | 19 | # ╔═╡ 633fc28a-6138-11ed-2bf2-9fc45fc9a926 20 | md""" 21 | # Optimization challenge 22 | """ 23 | 24 | # ╔═╡ 6fdbc050-ed89-48af-9b21-43aeb5bc103a 25 | md""" 26 | # 1. Overview 27 | """ 28 | 29 | # ╔═╡ bf76e4a9-8319-4aca-91fc-93d31952906f 30 | md""" 31 | ## Street view routing 32 | """ 33 | 34 | # ╔═╡ 5b096f1a-b5b7-4db0-855a-de39ddb5ef4c 35 | md""" 36 | The problem we chose for you is taken from [Google Hash Code](https://codingcompetitions.withgoogle.com/hashcode), an annual team programming competition. 37 | Its 2014 final round was about the routing of [Google Street View](https://www.google.com/streetview/) cars through Paris. 38 | In a nutshell, the goal is to define itineraries that capture as much image data as possible within a limited time frame. 39 | See the official [task description](https://storage.googleapis.com/coding-competitions.appspot.com/HC/2014/hashcode2014_final_task.pdf) and the [data file](https://storage.googleapis.com/coding-competitions.appspot.com/HC/2014/paris_54000.txt). 40 | """ 41 | 42 | # ╔═╡ e103f446-d3f9-432d-9fb6-dd0f67ee716b 43 | md""" 44 | We wrote a small package called [HashCode2014.jl](https://github.com/gdalle/HashCode2014.jl) to help you get started. 45 | It is not available on the general registry, so to install it, you need to use the URL: 46 | ```julia 47 | pkg> add https://github.com/gdalle/HashCode2014.jl 48 | ``` 49 | In addition to basic utilities, it includes a parser for text files, a very simple random walk algorithm, and a visualization function based on [folium](https://python-visualization.github.io/folium/). 50 | Check out the [documentation](https://gdalle.github.io/HashCode2014.jl/dev/) for more details. 51 | """ 52 | 53 | # ╔═╡ ed66c4e6-17e8-4706-9cf4-56f4bc1d7b6c 54 | md""" 55 | ## Problem statement 56 | """ 57 | 58 | # ╔═╡ 9a15943f-5dad-4043-b540-546d0fc2f025 59 | md""" 60 | Your task is to solve Hash Code 2014 by developing a Julia package. 61 | This package should contain (at least) the following elements: 62 | - New structs for storing problem instances and solutions (the ones from HashCode2014.jl are very dumb) 63 | - Functions that check the feasibility and value of a solution 64 | - One or more functions that compute a good solution 65 | - One or more functions that compute an upper bound on the value of an optimal solution 66 | - Unit tests that verify feasibility of your solutions and coherence of the bounds 67 | - A documentation made with [Documenter.jl](https://github.com/gdalle/HashCode2014.jl) 68 | """ 69 | 70 | # ╔═╡ 5aea0b2d-c3da-4496-9a9f-2fbc31fecf19 71 | md""" 72 | The documentation will serve as a report. 73 | It should not only contain function docstrings, but also present a mathematical description of your algorithms and a discussion of their performance, both in terms of solution quality and speed. 74 | 75 | In this project, a major focus should be code efficiency. 76 | Make use of all the tools that you have discovered in the class. 77 | Don't be afraid to discuss the questions that you faced, and the answers that you found. 78 | """ 79 | 80 | # ╔═╡ 3eff3936-4713-43a8-b4c5-ac0245086fab 81 | md""" 82 | ## Deliverable 83 | """ 84 | 85 | # ╔═╡ a7cd1bb9-44b3-44ce-bf2e-e3575ae73efe 86 | md""" 87 | Your deliverable for the challenge must be a _public_ GitHub repository containing your Julia package and its documentation. 88 | We ask you to make it public because open source development produces code that is accessible, auditable and reusable by everyone. 89 | In addition, GitHub offers many more services for public repositories than for private ones, and they're usually free of charge (one example being unlimited CI). 90 | Finally, this will allow instructors to check in on your work regularly and give you advice if you need it. 91 | """ 92 | 93 | # ╔═╡ 3cc76524-62e7-4476-9a62-02ad93915172 94 | md""" 95 | ## Tools 96 | """ 97 | 98 | # ╔═╡ 49ce7a51-815b-4d96-b217-e0bf65472828 99 | md""" 100 | As long as you write your code in Julia, you can use any package from the ecosystem. 101 | We also allow the use of mathematical programming solvers, for instance through JuMP.jl, even when these solvers are not written in Julia. 102 | 103 | In terms of hardware, you should run your code on your personal laptop, and not on an MIT cluster or on JuliaHub. 104 | Multithreading is allowed, but GPU computing probably won't be necessary. 105 | As is often the case in combinatorial optimization, the biggest differences come from clever algorithms and implementations, not from having a bigger computer. 106 | 107 | As a rule of thumb, your entire code should never take more than one hour to run on your laptop, ideally less. 108 | """ 109 | 110 | # ╔═╡ b268179b-a2ea-481d-be0d-e1aed35d6a6c 111 | md""" 112 | # 2. Rules and advice 113 | """ 114 | 115 | # ╔═╡ cd6d305e-f5fb-46f7-abbc-3b175f42a325 116 | md""" 117 | ## Teams 118 | """ 119 | 120 | # ╔═╡ 1e0f6c1a-694c-4802-91b2-45c67baa0305 121 | md""" 122 | This challenge can be tackled individually, or in teams of up to 3 students. 123 | If you struggle to find teammates, you can check out this [Piazza post](https://piazza.com/class/l6xyasad2hl2z7/post/120). 124 | """ 125 | 126 | # ╔═╡ 648389db-8498-4848-b4aa-d3703facc2a7 127 | md""" 128 | ## Leaderboard 129 | """ 130 | 131 | # ╔═╡ 0f2d2902-a4d9-4a25-96ac-685e6a1da5dd 132 | md""" 133 | To make this challenge more fun, we encourage teams to compete against each other. 134 | We thus created a [Google Sheets](https://docs.google.com/spreadsheets/d/1aiFdtYymErgXhLLqcXC50fYtiBA16Gzb8NaxFVOqxPo/edit?usp=sharing) where you can enter your team information and your current best performance. 135 | The computation time column is mostly intended for orders of magnitude: since you all have different hardware, precise comparison is impossible. 136 | 137 | To verify solution values, we will set up another Canvas submission that you can keep updated with your best solution sofar. 138 | The challenge instructions provide very clear guidelines to export this solution as a text file, and HashCode2014.jl has a function to do just that. 139 | """ 140 | 141 | # ╔═╡ cdb75786-4fc0-491f-bbd7-fdf59d36b668 142 | md""" 143 | ## Ethics 144 | """ 145 | 146 | # ╔═╡ 6802a897-1be1-4d93-a432-b783ca648830 147 | md""" 148 | Since each team is expected to work in a public repository, plagiarism is technically possible, but we will not tolerate it. 149 | If you draw inspiration from the work of others, we demand that you: 150 | 1. cite the source explicitly to separate their contributions 151 | 2. make their method better / faster in the process, and explain how you did it 152 | """ 153 | 154 | # ╔═╡ d3175bdd-74dd-4c83-8540-a32323580d67 155 | md""" 156 | ## Grading 157 | """ 158 | 159 | # ╔═╡ d011f5a4-3d5d-4bba-af45-de15efac5f98 160 | md""" 161 | The grading rubric is not defined yet, but the following items will be taken into account: 162 | - Code quality 163 | - Clarity of the documentation 164 | - Cleverness of the algorithms 165 | - Efficiency considerations 166 | - Actual performance and leaderboard ranking (for a small part) 167 | """ 168 | 169 | # ╔═╡ a71422ea-f656-4338-a943-3ecf3e8ecf61 170 | md""" 171 | ## Deadlines 172 | """ 173 | 174 | # ╔═╡ 22701912-d47b-4baf-a97c-57d8d4a763be 175 | md""" 176 | | Date | Objective | Assignment | Consequences | 177 | | --- | --- | --- | --- | 178 | | Thursday 11/17 | Package initialized | Submit your team and repository URL | | 179 | | Tuesday 11/22 | Package operational | Submit your first solution file | We will review your repository to give advice | 180 | | Friday 12/09 | Package and documentation complete | Submit your final solution file | We will download and evaluate your repository | 181 | 182 | All dates are to be understood as 11:59 PM 183 | """ 184 | 185 | # ╔═╡ 4ad8e4c2-080d-496f-8b54-8a55ebd23923 186 | md""" 187 | ## Troubleshooting 188 | """ 189 | 190 | # ╔═╡ cf53067e-dfe4-42a3-b433-27ca7b3dbec8 191 | md""" 192 | We recommend you initialize your package with [PkgTemplates.jl](https://github.com/JuliaCI/PkgTemplates.jl), as discussed in the tutorial on good coding practices. 193 | Before pushing, try running the tests and building the documentation locally. 194 | 195 | **Ignoring files** 196 | 197 | PkgTemplates.jl generates a file called `.gitignore`, which tells Git to avoid tracking certain files. 198 | You will need to insert a line in this file containing `.CondaPkg`. When you add HashCode2014.jl as a dependency, some Python packages will be stored there, but you don't need to push them to GitHub. 199 | 200 | **Testing** 201 | 202 | You should copy the basic `runtests.jl` structure we suggested in the course on good programming practices. 203 | While doing so, you might find that 204 | 205 | - You need to set up additional test-specific dependencies (see the documentation for Pkg.jl to learn how) 206 | - [Aqua.jl](https://github.com/JuliaTesting/Aqua.jl) is very picky on certain aspects. Read its documentation to understand why and how you can get the tests to pass. 207 | """ 208 | 209 | # ╔═╡ 00000000-0000-0000-0000-000000000001 210 | PLUTO_PROJECT_TOML_CONTENTS = """ 211 | [deps] 212 | PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" 213 | PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 214 | 215 | [compat] 216 | PlutoTeachingTools = "~0.2.5" 217 | PlutoUI = "~0.7.48" 218 | """ 219 | 220 | # ╔═╡ 00000000-0000-0000-0000-000000000002 221 | PLUTO_MANIFEST_TOML_CONTENTS = """ 222 | # This file is machine-generated - editing it directly is not advised 223 | 224 | julia_version = "1.8.2" 225 | manifest_format = "2.0" 226 | project_hash = "a084e953ecc8d9d6d85465607b1a1d49f1e47fec" 227 | 228 | [[deps.AbstractPlutoDingetjes]] 229 | deps = ["Pkg"] 230 | git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481" 231 | uuid = "6e696c72-6542-2067-7265-42206c756150" 232 | version = "1.1.4" 233 | 234 | [[deps.ArgTools]] 235 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 236 | version = "1.1.1" 237 | 238 | [[deps.Artifacts]] 239 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 240 | 241 | [[deps.Base64]] 242 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 243 | 244 | [[deps.CodeTracking]] 245 | deps = ["InteractiveUtils", "UUIDs"] 246 | git-tree-sha1 = "cc4bd91eba9cdbbb4df4746124c22c0832a460d6" 247 | uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" 248 | version = "1.1.1" 249 | 250 | [[deps.ColorTypes]] 251 | deps = ["FixedPointNumbers", "Random"] 252 | git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4" 253 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 254 | version = "0.11.4" 255 | 256 | [[deps.CompilerSupportLibraries_jll]] 257 | deps = ["Artifacts", "Libdl"] 258 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 259 | version = "0.5.2+0" 260 | 261 | [[deps.Dates]] 262 | deps = ["Printf"] 263 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 264 | 265 | [[deps.Distributed]] 266 | deps = ["Random", "Serialization", "Sockets"] 267 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 268 | 269 | [[deps.Downloads]] 270 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 271 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 272 | version = "1.6.0" 273 | 274 | [[deps.FileWatching]] 275 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 276 | 277 | [[deps.FixedPointNumbers]] 278 | deps = ["Statistics"] 279 | git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" 280 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 281 | version = "0.8.4" 282 | 283 | [[deps.Formatting]] 284 | deps = ["Printf"] 285 | git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8" 286 | uuid = "59287772-0a20-5a39-b81b-1366585eb4c0" 287 | version = "0.4.2" 288 | 289 | [[deps.Hyperscript]] 290 | deps = ["Test"] 291 | git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9" 292 | uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" 293 | version = "0.0.4" 294 | 295 | [[deps.HypertextLiteral]] 296 | deps = ["Tricks"] 297 | git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9" 298 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 299 | version = "0.9.4" 300 | 301 | [[deps.IOCapture]] 302 | deps = ["Logging", "Random"] 303 | git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a" 304 | uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" 305 | version = "0.2.2" 306 | 307 | [[deps.InteractiveUtils]] 308 | deps = ["Markdown"] 309 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 310 | 311 | [[deps.JSON]] 312 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 313 | git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e" 314 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 315 | version = "0.21.3" 316 | 317 | [[deps.JuliaInterpreter]] 318 | deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] 319 | git-tree-sha1 = "0f960b1404abb0b244c1ece579a0ec78d056a5d1" 320 | uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" 321 | version = "0.9.15" 322 | 323 | [[deps.LaTeXStrings]] 324 | git-tree-sha1 = "f2355693d6778a178ade15952b7ac47a4ff97996" 325 | uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" 326 | version = "1.3.0" 327 | 328 | [[deps.Latexify]] 329 | deps = ["Formatting", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Printf", "Requires"] 330 | git-tree-sha1 = "ab9aa169d2160129beb241cb2750ca499b4e90e9" 331 | uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" 332 | version = "0.15.17" 333 | 334 | [[deps.LibCURL]] 335 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 336 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 337 | version = "0.6.3" 338 | 339 | [[deps.LibCURL_jll]] 340 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 341 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 342 | version = "7.84.0+0" 343 | 344 | [[deps.LibGit2]] 345 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 346 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 347 | 348 | [[deps.LibSSH2_jll]] 349 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 350 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 351 | version = "1.10.2+0" 352 | 353 | [[deps.Libdl]] 354 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 355 | 356 | [[deps.LinearAlgebra]] 357 | deps = ["Libdl", "libblastrampoline_jll"] 358 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 359 | 360 | [[deps.Logging]] 361 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 362 | 363 | [[deps.LoweredCodeUtils]] 364 | deps = ["JuliaInterpreter"] 365 | git-tree-sha1 = "dedbebe234e06e1ddad435f5c6f4b85cd8ce55f7" 366 | uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" 367 | version = "2.2.2" 368 | 369 | [[deps.MIMEs]] 370 | git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" 371 | uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" 372 | version = "0.1.4" 373 | 374 | [[deps.MacroTools]] 375 | deps = ["Markdown", "Random"] 376 | git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2" 377 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" 378 | version = "0.5.10" 379 | 380 | [[deps.Markdown]] 381 | deps = ["Base64"] 382 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 383 | 384 | [[deps.MbedTLS_jll]] 385 | deps = ["Artifacts", "Libdl"] 386 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 387 | version = "2.28.0+0" 388 | 389 | [[deps.Mmap]] 390 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 391 | 392 | [[deps.MozillaCACerts_jll]] 393 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 394 | version = "2022.2.1" 395 | 396 | [[deps.NetworkOptions]] 397 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 398 | version = "1.2.0" 399 | 400 | [[deps.OpenBLAS_jll]] 401 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 402 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 403 | version = "0.3.20+0" 404 | 405 | [[deps.OrderedCollections]] 406 | git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c" 407 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 408 | version = "1.4.1" 409 | 410 | [[deps.Parsers]] 411 | deps = ["Dates", "SnoopPrecompile"] 412 | git-tree-sha1 = "cceb0257b662528ecdf0b4b4302eb00e767b38e7" 413 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 414 | version = "2.5.0" 415 | 416 | [[deps.Pkg]] 417 | deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 418 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 419 | version = "1.8.0" 420 | 421 | [[deps.PlutoHooks]] 422 | deps = ["InteractiveUtils", "Markdown", "UUIDs"] 423 | git-tree-sha1 = "072cdf20c9b0507fdd977d7d246d90030609674b" 424 | uuid = "0ff47ea0-7a50-410d-8455-4348d5de0774" 425 | version = "0.0.5" 426 | 427 | [[deps.PlutoLinks]] 428 | deps = ["FileWatching", "InteractiveUtils", "Markdown", "PlutoHooks", "Revise", "UUIDs"] 429 | git-tree-sha1 = "0e8bcc235ec8367a8e9648d48325ff00e4b0a545" 430 | uuid = "0ff47ea0-7a50-410d-8455-4348d5de0420" 431 | version = "0.1.5" 432 | 433 | [[deps.PlutoTeachingTools]] 434 | deps = ["Downloads", "HypertextLiteral", "LaTeXStrings", "Latexify", "Markdown", "PlutoLinks", "PlutoUI", "Random"] 435 | git-tree-sha1 = "ea3e4ac2e49e3438815f8946fa7673b658e35bdb" 436 | uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" 437 | version = "0.2.5" 438 | 439 | [[deps.PlutoUI]] 440 | deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] 441 | git-tree-sha1 = "efc140104e6d0ae3e7e30d56c98c4a927154d684" 442 | uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" 443 | version = "0.7.48" 444 | 445 | [[deps.Printf]] 446 | deps = ["Unicode"] 447 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 448 | 449 | [[deps.REPL]] 450 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 451 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 452 | 453 | [[deps.Random]] 454 | deps = ["SHA", "Serialization"] 455 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 456 | 457 | [[deps.Reexport]] 458 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 459 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 460 | version = "1.2.2" 461 | 462 | [[deps.Requires]] 463 | deps = ["UUIDs"] 464 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7" 465 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 466 | version = "1.3.0" 467 | 468 | [[deps.Revise]] 469 | deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "Requires", "UUIDs", "Unicode"] 470 | git-tree-sha1 = "dad726963ecea2d8a81e26286f625aee09a91b7c" 471 | uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" 472 | version = "3.4.0" 473 | 474 | [[deps.SHA]] 475 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 476 | version = "0.7.0" 477 | 478 | [[deps.Serialization]] 479 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 480 | 481 | [[deps.SnoopPrecompile]] 482 | git-tree-sha1 = "f604441450a3c0569830946e5b33b78c928e1a85" 483 | uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" 484 | version = "1.0.1" 485 | 486 | [[deps.Sockets]] 487 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 488 | 489 | [[deps.SparseArrays]] 490 | deps = ["LinearAlgebra", "Random"] 491 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 492 | 493 | [[deps.Statistics]] 494 | deps = ["LinearAlgebra", "SparseArrays"] 495 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 496 | 497 | [[deps.TOML]] 498 | deps = ["Dates"] 499 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 500 | version = "1.0.0" 501 | 502 | [[deps.Tar]] 503 | deps = ["ArgTools", "SHA"] 504 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 505 | version = "1.10.1" 506 | 507 | [[deps.Test]] 508 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 509 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 510 | 511 | [[deps.Tricks]] 512 | git-tree-sha1 = "6bac775f2d42a611cdfcd1fb217ee719630c4175" 513 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" 514 | version = "0.1.6" 515 | 516 | [[deps.URIs]] 517 | git-tree-sha1 = "e59ecc5a41b000fa94423a578d29290c7266fc10" 518 | uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" 519 | version = "1.4.0" 520 | 521 | [[deps.UUIDs]] 522 | deps = ["Random", "SHA"] 523 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 524 | 525 | [[deps.Unicode]] 526 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 527 | 528 | [[deps.Zlib_jll]] 529 | deps = ["Libdl"] 530 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 531 | version = "1.2.12+3" 532 | 533 | [[deps.libblastrampoline_jll]] 534 | deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] 535 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 536 | version = "5.1.1+0" 537 | 538 | [[deps.nghttp2_jll]] 539 | deps = ["Artifacts", "Libdl"] 540 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 541 | version = "1.48.0+0" 542 | 543 | [[deps.p7zip_jll]] 544 | deps = ["Artifacts", "Libdl"] 545 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 546 | version = "17.4.0+0" 547 | """ 548 | 549 | # ╔═╡ Cell order: 550 | # ╠═35580339-744e-422a-b474-47dda002390a 551 | # ╠═fcc41a80-b44a-4eb8-ade6-13f075c5b72f 552 | # ╟─51d9bad9-aebd-40bb-8682-688a57c876db 553 | # ╟─633fc28a-6138-11ed-2bf2-9fc45fc9a926 554 | # ╟─6fdbc050-ed89-48af-9b21-43aeb5bc103a 555 | # ╟─bf76e4a9-8319-4aca-91fc-93d31952906f 556 | # ╟─5b096f1a-b5b7-4db0-855a-de39ddb5ef4c 557 | # ╟─e103f446-d3f9-432d-9fb6-dd0f67ee716b 558 | # ╟─ed66c4e6-17e8-4706-9cf4-56f4bc1d7b6c 559 | # ╟─9a15943f-5dad-4043-b540-546d0fc2f025 560 | # ╟─5aea0b2d-c3da-4496-9a9f-2fbc31fecf19 561 | # ╟─3eff3936-4713-43a8-b4c5-ac0245086fab 562 | # ╟─a7cd1bb9-44b3-44ce-bf2e-e3575ae73efe 563 | # ╟─3cc76524-62e7-4476-9a62-02ad93915172 564 | # ╟─49ce7a51-815b-4d96-b217-e0bf65472828 565 | # ╟─b268179b-a2ea-481d-be0d-e1aed35d6a6c 566 | # ╟─cd6d305e-f5fb-46f7-abbc-3b175f42a325 567 | # ╟─1e0f6c1a-694c-4802-91b2-45c67baa0305 568 | # ╟─648389db-8498-4848-b4aa-d3703facc2a7 569 | # ╟─0f2d2902-a4d9-4a25-96ac-685e6a1da5dd 570 | # ╟─cdb75786-4fc0-491f-bbd7-fdf59d36b668 571 | # ╟─6802a897-1be1-4d93-a432-b783ca648830 572 | # ╟─d3175bdd-74dd-4c83-8540-a32323580d67 573 | # ╟─d011f5a4-3d5d-4bba-af45-de15efac5f98 574 | # ╟─a71422ea-f656-4338-a943-3ecf3e8ecf61 575 | # ╟─22701912-d47b-4baf-a97c-57d8d4a763be 576 | # ╟─4ad8e4c2-080d-496f-8b54-8a55ebd23923 577 | # ╟─cf53067e-dfe4-42a3-b433-27ca7b3dbec8 578 | # ╟─00000000-0000-0000-0000-000000000001 579 | # ╟─00000000-0000-0000-0000-000000000002 580 | -------------------------------------------------------------------------------- /notebooks_old/juliahub_in_class_110122.jl: -------------------------------------------------------------------------------- 1 | ### A Pluto.jl notebook ### 2 | # v0.19.8 3 | 4 | using Markdown 5 | using InteractiveUtils 6 | 7 | # ╔═╡ 9260ed2e-5a0c-11ed-3cd6-0ff639b38f1c 8 | using CUDA, KernelAbstractions, CUDAKernels, BenchmarkTools 9 | 10 | # ╔═╡ 6ed42e7e-3bbb-4fc9-95fb-509b08d2d53d 11 | force_law(x,y) = 1/abs(x-y) 12 | 13 | # ╔═╡ 76fbcfe3-7962-4f99-b70d-9bcc3bed07e4 14 | @kernel function myproblem!(forces, positions, force_law) 15 | tid = @index(Global, Linear) 16 | forces[tid] = 0.0 17 | 18 | for j = 1:length(positions) 19 | if j != tid 20 | forces[tid] += force_law(positions[tid], positions[j] ) end 21 | end 22 | 23 | end 24 | 25 | # ╔═╡ 78754f69-56d8-4cce-b500-704656530711 26 | kernel! = myproblem!(CUDADevice(),256) 27 | 28 | # ╔═╡ 700d5233-fee9-415c-b757-322d014a4a23 29 | # @time myproblem1(Array(positions)) 30 | 31 | # ╔═╡ b1d4465d-7d65-411d-ba33-632bb1eb2ace 32 | n = 8_000_000 33 | 34 | # ╔═╡ 6aa011fa-bb3b-4057-bb26-2b898465b359 35 | begin 36 | positions = rand(n) 37 | forces = similar(positions) 38 | end 39 | 40 | # ╔═╡ 2dc55a8e-0837-4f35-8191-e70a54e7ca7e 41 | positionsGPU = CuArray(positions) 42 | 43 | # ╔═╡ 6b390849-1959-445b-bc7f-c5352db0890a 44 | forcesGPU = CuArray(forces) 45 | 46 | # ╔═╡ 19c602c1-9800-4d74-9c56-deab17e54df7 47 | begin 48 | @time wait(kernel!(forcesGPU, positionsGPU, force_law, ndrange=n)) 49 | forcesGPU 50 | end 51 | 52 | # ╔═╡ 4559bcc6-a8a8-4bd7-a464-5b430258ce43 53 | (n * 4*8)/2^30 54 | 55 | # ╔═╡ 661d35c0-4d0c-4748-917a-6d599c821de0 56 | function myproblem1(x) 57 | y = zero(x) 58 | n = length(x) 59 | for i=1:n ,j=1:n 60 | if j≠i 61 | y[i] += 1. /abs(x[i]-x[j]) 62 | end 63 | end 64 | y 65 | end 66 | 67 | # ╔═╡ 00000000-0000-0000-0000-000000000001 68 | PLUTO_PROJECT_TOML_CONTENTS = """ 69 | [deps] 70 | BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 71 | CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" 72 | CUDAKernels = "72cfdca4-0801-4ab0-bf6a-d52aa10adc57" 73 | KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" 74 | 75 | [compat] 76 | BenchmarkTools = "~1.3.1" 77 | CUDA = "~3.12.0" 78 | CUDAKernels = "~0.4.3" 79 | KernelAbstractions = "~0.8.3" 80 | """ 81 | 82 | # ╔═╡ 00000000-0000-0000-0000-000000000002 83 | PLUTO_MANIFEST_TOML_CONTENTS = """ 84 | # This file is machine-generated - editing it directly is not advised 85 | 86 | julia_version = "1.7.2" 87 | manifest_format = "2.0" 88 | 89 | [[deps.AbstractFFTs]] 90 | deps = ["ChainRulesCore", "LinearAlgebra"] 91 | git-tree-sha1 = "69f7020bd72f069c219b5e8c236c1fa90d2cb409" 92 | uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" 93 | version = "1.2.1" 94 | 95 | [[deps.Adapt]] 96 | deps = ["LinearAlgebra"] 97 | git-tree-sha1 = "195c5505521008abea5aee4f96930717958eac6f" 98 | uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" 99 | version = "3.4.0" 100 | 101 | [[deps.ArgTools]] 102 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 103 | 104 | [[deps.Artifacts]] 105 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 106 | 107 | [[deps.Atomix]] 108 | deps = ["UnsafeAtomics"] 109 | git-tree-sha1 = "c06a868224ecba914baa6942988e2f2aade419be" 110 | uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" 111 | version = "0.1.0" 112 | 113 | [[deps.BFloat16s]] 114 | deps = ["LinearAlgebra", "Printf", "Random", "Test"] 115 | git-tree-sha1 = "a598ecb0d717092b5539dbbe890c98bac842b072" 116 | uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b" 117 | version = "0.2.0" 118 | 119 | [[deps.Base64]] 120 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 121 | 122 | [[deps.BenchmarkTools]] 123 | deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"] 124 | git-tree-sha1 = "4c10eee4af024676200bc7752e536f858c6b8f93" 125 | uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 126 | version = "1.3.1" 127 | 128 | [[deps.CEnum]] 129 | git-tree-sha1 = "eb4cb44a499229b3b8426dcfb5dd85333951ff90" 130 | uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" 131 | version = "0.4.2" 132 | 133 | [[deps.CUDA]] 134 | deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CompilerSupportLibraries_jll", "ExprTools", "GPUArrays", "GPUCompiler", "LLVM", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "SpecialFunctions", "TimerOutputs"] 135 | git-tree-sha1 = "49549e2c28ffb9cc77b3689dc10e46e6271e9452" 136 | uuid = "052768ef-5323-5732-b1bb-66c8b64840ba" 137 | version = "3.12.0" 138 | 139 | [[deps.CUDAKernels]] 140 | deps = ["Adapt", "CUDA", "KernelAbstractions", "StaticArrays", "UnsafeAtomicsLLVM"] 141 | git-tree-sha1 = "bbab4d1a4001ec322c384dfff0889cec4118da93" 142 | uuid = "72cfdca4-0801-4ab0-bf6a-d52aa10adc57" 143 | version = "0.4.3" 144 | 145 | [[deps.ChainRulesCore]] 146 | deps = ["Compat", "LinearAlgebra", "SparseArrays"] 147 | git-tree-sha1 = "8a494fe0c4ae21047f28eb48ac968f0b8a6fcaa7" 148 | uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" 149 | version = "1.15.4" 150 | 151 | [[deps.ChangesOfVariables]] 152 | deps = ["ChainRulesCore", "LinearAlgebra", "Test"] 153 | git-tree-sha1 = "38f7a08f19d8810338d4f5085211c7dfa5d5bdd8" 154 | uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" 155 | version = "0.1.4" 156 | 157 | [[deps.Compat]] 158 | deps = ["Dates", "LinearAlgebra", "UUIDs"] 159 | git-tree-sha1 = "5856d3031cdb1f3b2b6340dfdc66b6d9a149a374" 160 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 161 | version = "4.2.0" 162 | 163 | [[deps.CompilerSupportLibraries_jll]] 164 | deps = ["Artifacts", "Libdl"] 165 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 166 | 167 | [[deps.Dates]] 168 | deps = ["Printf"] 169 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 170 | 171 | [[deps.DocStringExtensions]] 172 | deps = ["LibGit2"] 173 | git-tree-sha1 = "5158c2b41018c5f7eb1470d558127ac274eca0c9" 174 | uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 175 | version = "0.9.1" 176 | 177 | [[deps.Downloads]] 178 | deps = ["ArgTools", "LibCURL", "NetworkOptions"] 179 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 180 | 181 | [[deps.ExprTools]] 182 | git-tree-sha1 = "56559bbef6ca5ea0c0818fa5c90320398a6fbf8d" 183 | uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" 184 | version = "0.1.8" 185 | 186 | [[deps.GPUArrays]] 187 | deps = ["Adapt", "GPUArraysCore", "LLVM", "LinearAlgebra", "Printf", "Random", "Reexport", "Serialization", "Statistics"] 188 | git-tree-sha1 = "45d7deaf05cbb44116ba785d147c518ab46352d7" 189 | uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" 190 | version = "8.5.0" 191 | 192 | [[deps.GPUArraysCore]] 193 | deps = ["Adapt"] 194 | git-tree-sha1 = "6872f5ec8fd1a38880f027a26739d42dcda6691f" 195 | uuid = "46192b85-c4d5-4398-a991-12ede77f4527" 196 | version = "0.1.2" 197 | 198 | [[deps.GPUCompiler]] 199 | deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "TimerOutputs", "UUIDs"] 200 | git-tree-sha1 = "122d7bcc92abf94cf1a86281ad7a4d0e838ab9e0" 201 | uuid = "61eb1bfa-7361-4325-ad38-22787b887f55" 202 | version = "0.16.3" 203 | 204 | [[deps.InteractiveUtils]] 205 | deps = ["Markdown"] 206 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 207 | 208 | [[deps.InverseFunctions]] 209 | deps = ["Test"] 210 | git-tree-sha1 = "b3364212fb5d870f724876ffcd34dd8ec6d98918" 211 | uuid = "3587e190-3f89-42d0-90ee-14403ec27112" 212 | version = "0.1.7" 213 | 214 | [[deps.IrrationalConstants]] 215 | git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151" 216 | uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" 217 | version = "0.1.1" 218 | 219 | [[deps.JLLWrappers]] 220 | deps = ["Preferences"] 221 | git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" 222 | uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" 223 | version = "1.4.1" 224 | 225 | [[deps.JSON]] 226 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 227 | git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e" 228 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 229 | version = "0.21.3" 230 | 231 | [[deps.KernelAbstractions]] 232 | deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"] 233 | git-tree-sha1 = "02838ecfc5f925ac408ffe6b359ac59ef8865272" 234 | uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c" 235 | version = "0.8.3" 236 | 237 | [[deps.LLVM]] 238 | deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"] 239 | git-tree-sha1 = "e7e9184b0bf0158ac4e4aa9daf00041b5909bf1a" 240 | uuid = "929cbde3-209d-540e-8aea-75f648917ca0" 241 | version = "4.14.0" 242 | 243 | [[deps.LLVMExtra_jll]] 244 | deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg", "TOML"] 245 | git-tree-sha1 = "771bfe376249626d3ca12bcd58ba243d3f961576" 246 | uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab" 247 | version = "0.0.16+0" 248 | 249 | [[deps.LazyArtifacts]] 250 | deps = ["Artifacts", "Pkg"] 251 | uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" 252 | 253 | [[deps.LibCURL]] 254 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 255 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 256 | 257 | [[deps.LibCURL_jll]] 258 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 259 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 260 | 261 | [[deps.LibGit2]] 262 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 263 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 264 | 265 | [[deps.LibSSH2_jll]] 266 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 267 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 268 | 269 | [[deps.Libdl]] 270 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 271 | 272 | [[deps.LinearAlgebra]] 273 | deps = ["Libdl", "libblastrampoline_jll"] 274 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 275 | 276 | [[deps.LogExpFunctions]] 277 | deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"] 278 | git-tree-sha1 = "94d9c52ca447e23eac0c0f074effbcd38830deb5" 279 | uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" 280 | version = "0.3.18" 281 | 282 | [[deps.Logging]] 283 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 284 | 285 | [[deps.MacroTools]] 286 | deps = ["Markdown", "Random"] 287 | git-tree-sha1 = "3d3e902b31198a27340d0bf00d6ac452866021cf" 288 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" 289 | version = "0.5.9" 290 | 291 | [[deps.Markdown]] 292 | deps = ["Base64"] 293 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 294 | 295 | [[deps.MbedTLS_jll]] 296 | deps = ["Artifacts", "Libdl"] 297 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 298 | 299 | [[deps.Mmap]] 300 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 301 | 302 | [[deps.MozillaCACerts_jll]] 303 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 304 | 305 | [[deps.NetworkOptions]] 306 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 307 | 308 | [[deps.OpenBLAS_jll]] 309 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 310 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 311 | 312 | [[deps.OpenLibm_jll]] 313 | deps = ["Artifacts", "Libdl"] 314 | uuid = "05823500-19ac-5b8b-9628-191a04bc5112" 315 | 316 | [[deps.OpenSpecFun_jll]] 317 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] 318 | git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" 319 | uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" 320 | version = "0.5.5+0" 321 | 322 | [[deps.Parsers]] 323 | deps = ["Dates"] 324 | git-tree-sha1 = "3d5bf43e3e8b412656404ed9466f1dcbf7c50269" 325 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 326 | version = "2.4.0" 327 | 328 | [[deps.Pkg]] 329 | deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 330 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 331 | 332 | [[deps.Preferences]] 333 | deps = ["TOML"] 334 | git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" 335 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 336 | version = "1.3.0" 337 | 338 | [[deps.Printf]] 339 | deps = ["Unicode"] 340 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 341 | 342 | [[deps.Profile]] 343 | deps = ["Printf"] 344 | uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" 345 | 346 | [[deps.REPL]] 347 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 348 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 349 | 350 | [[deps.Random]] 351 | deps = ["SHA", "Serialization"] 352 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 353 | 354 | [[deps.Random123]] 355 | deps = ["Random", "RandomNumbers"] 356 | git-tree-sha1 = "7a1a306b72cfa60634f03a911405f4e64d1b718b" 357 | uuid = "74087812-796a-5b5d-8853-05524746bad3" 358 | version = "1.6.0" 359 | 360 | [[deps.RandomNumbers]] 361 | deps = ["Random", "Requires"] 362 | git-tree-sha1 = "043da614cc7e95c703498a491e2c21f58a2b8111" 363 | uuid = "e6cf234a-135c-5ec9-84dd-332b85af5143" 364 | version = "1.5.3" 365 | 366 | [[deps.Reexport]] 367 | git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" 368 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 369 | version = "1.2.2" 370 | 371 | [[deps.Requires]] 372 | deps = ["UUIDs"] 373 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7" 374 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 375 | version = "1.3.0" 376 | 377 | [[deps.SHA]] 378 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 379 | 380 | [[deps.Serialization]] 381 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 382 | 383 | [[deps.Sockets]] 384 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 385 | 386 | [[deps.SparseArrays]] 387 | deps = ["LinearAlgebra", "Random"] 388 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 389 | 390 | [[deps.SpecialFunctions]] 391 | deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] 392 | git-tree-sha1 = "d75bda01f8c31ebb72df80a46c88b25d1c79c56d" 393 | uuid = "276daf66-3868-5448-9aa4-cd146d93841b" 394 | version = "2.1.7" 395 | 396 | [[deps.StaticArrays]] 397 | deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"] 398 | git-tree-sha1 = "dfec37b90740e3b9aa5dc2613892a3fc155c3b42" 399 | uuid = "90137ffa-7385-5640-81b9-e52037218182" 400 | version = "1.5.6" 401 | 402 | [[deps.StaticArraysCore]] 403 | git-tree-sha1 = "ec2bd695e905a3c755b33026954b119ea17f2d22" 404 | uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" 405 | version = "1.3.0" 406 | 407 | [[deps.Statistics]] 408 | deps = ["LinearAlgebra", "SparseArrays"] 409 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 410 | 411 | [[deps.TOML]] 412 | deps = ["Dates"] 413 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 414 | 415 | [[deps.Tar]] 416 | deps = ["ArgTools", "SHA"] 417 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 418 | 419 | [[deps.Test]] 420 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 421 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 422 | 423 | [[deps.TimerOutputs]] 424 | deps = ["ExprTools", "Printf"] 425 | git-tree-sha1 = "9dfcb767e17b0849d6aaf85997c98a5aea292513" 426 | uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" 427 | version = "0.5.21" 428 | 429 | [[deps.UUIDs]] 430 | deps = ["Random", "SHA"] 431 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 432 | 433 | [[deps.Unicode]] 434 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 435 | 436 | [[deps.UnsafeAtomics]] 437 | git-tree-sha1 = "6331ac3440856ea1988316b46045303bef658278" 438 | uuid = "013be700-e6cd-48c3-b4a1-df204f14c38f" 439 | version = "0.2.1" 440 | 441 | [[deps.UnsafeAtomicsLLVM]] 442 | deps = ["LLVM", "UnsafeAtomics"] 443 | git-tree-sha1 = "33af9d2031d0dc09e2be9a0d4beefec4466def8e" 444 | uuid = "d80eeb9a-aca5-4d75-85e5-170c8b632249" 445 | version = "0.1.0" 446 | 447 | [[deps.Zlib_jll]] 448 | deps = ["Libdl"] 449 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 450 | 451 | [[deps.libblastrampoline_jll]] 452 | deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] 453 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 454 | 455 | [[deps.nghttp2_jll]] 456 | deps = ["Artifacts", "Libdl"] 457 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 458 | 459 | [[deps.p7zip_jll]] 460 | deps = ["Artifacts", "Libdl"] 461 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 462 | """ 463 | 464 | # ╔═╡ Cell order: 465 | # ╠═9260ed2e-5a0c-11ed-3cd6-0ff639b38f1c 466 | # ╠═6ed42e7e-3bbb-4fc9-95fb-509b08d2d53d 467 | # ╠═76fbcfe3-7962-4f99-b70d-9bcc3bed07e4 468 | # ╠═6aa011fa-bb3b-4057-bb26-2b898465b359 469 | # ╠═2dc55a8e-0837-4f35-8191-e70a54e7ca7e 470 | # ╠═6b390849-1959-445b-bc7f-c5352db0890a 471 | # ╠═78754f69-56d8-4cce-b500-704656530711 472 | # ╠═19c602c1-9800-4d74-9c56-deab17e54df7 473 | # ╠═700d5233-fee9-415c-b757-322d014a4a23 474 | # ╠═b1d4465d-7d65-411d-ba33-632bb1eb2ace 475 | # ╠═4559bcc6-a8a8-4bd7-a464-5b430258ce43 476 | # ╠═661d35c0-4d0c-4748-917a-6d599c821de0 477 | # ╟─00000000-0000-0000-0000-000000000001 478 | # ╟─00000000-0000-0000-0000-000000000002 479 | -------------------------------------------------------------------------------- /pluto-slider-server-environment/Manifest.toml: -------------------------------------------------------------------------------- 1 | # This file is machine-generated - editing it directly is not advised 2 | 3 | julia_version = "1.9.3" 4 | manifest_format = "2.0" 5 | project_hash = "13a51ad2b377d764861ea553e631182e0e81a599" 6 | 7 | [[deps.AbstractPlutoDingetjes]] 8 | deps = ["Pkg"] 9 | git-tree-sha1 = "91bd53c39b9cbfb5ef4b015e8b582d344532bd0a" 10 | uuid = "6e696c72-6542-2067-7265-42206c756150" 11 | version = "1.2.0" 12 | 13 | [[deps.AbstractTrees]] 14 | git-tree-sha1 = "faa260e4cb5aba097a73fab382dd4b5819d8ec8c" 15 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" 16 | version = "0.4.4" 17 | 18 | [[deps.ArgTools]] 19 | uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" 20 | version = "1.1.1" 21 | 22 | [[deps.Artifacts]] 23 | uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" 24 | 25 | [[deps.Base64]] 26 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 27 | 28 | [[deps.BetterFileWatching]] 29 | deps = ["Deno_jll", "JSON"] 30 | git-tree-sha1 = "0d7ee0a1acad90d544fa87cc3d6f463e99abb77a" 31 | uuid = "c9fd44ac-77b5-486c-9482-9798bd063cc6" 32 | version = "0.1.5" 33 | 34 | [[deps.BitFlags]] 35 | git-tree-sha1 = "43b1a4a8f797c1cddadf60499a8a077d4af2cd2d" 36 | uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" 37 | version = "0.1.7" 38 | 39 | [[deps.CodecZlib]] 40 | deps = ["TranscodingStreams", "Zlib_jll"] 41 | git-tree-sha1 = "02aa26a4cf76381be7f66e020a3eddeb27b0a092" 42 | uuid = "944b1d66-785c-5afd-91f1-9de20f533193" 43 | version = "0.7.2" 44 | 45 | [[deps.CompilerSupportLibraries_jll]] 46 | deps = ["Artifacts", "Libdl"] 47 | uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" 48 | version = "1.0.5+0" 49 | 50 | [[deps.ConcurrentUtilities]] 51 | deps = ["Serialization", "Sockets"] 52 | git-tree-sha1 = "5372dbbf8f0bdb8c700db5367132925c0771ef7e" 53 | uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb" 54 | version = "2.2.1" 55 | 56 | [[deps.Configurations]] 57 | deps = ["ExproniconLite", "OrderedCollections", "TOML"] 58 | git-tree-sha1 = "434f446dbf89d08350e83bf57c0fc86f5d3ffd4e" 59 | uuid = "5218b696-f38b-4ac9-8b61-a12ec717816d" 60 | version = "0.17.5" 61 | 62 | [[deps.DataAPI]] 63 | git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c" 64 | uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" 65 | version = "1.15.0" 66 | 67 | [[deps.DataValueInterfaces]] 68 | git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" 69 | uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464" 70 | version = "1.0.0" 71 | 72 | [[deps.Dates]] 73 | deps = ["Printf"] 74 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 75 | 76 | [[deps.Deno_jll]] 77 | deps = ["Artifacts", "JLLWrappers", "Libdl"] 78 | git-tree-sha1 = "cd6756e833c377e0ce9cd63fb97689a255f12323" 79 | uuid = "04572ae6-984a-583e-9378-9577a1c2574d" 80 | version = "1.33.4+0" 81 | 82 | [[deps.Distributed]] 83 | deps = ["Random", "Serialization", "Sockets"] 84 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 85 | 86 | [[deps.Downloads]] 87 | deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] 88 | uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 89 | version = "1.6.0" 90 | 91 | [[deps.ExceptionUnwrapping]] 92 | deps = ["Test"] 93 | git-tree-sha1 = "e90caa41f5a86296e014e148ee061bd6c3edec96" 94 | uuid = "460bff9d-24e4-43bc-9d9f-a8973cb893f4" 95 | version = "0.1.9" 96 | 97 | [[deps.Expat_jll]] 98 | deps = ["Artifacts", "JLLWrappers", "Libdl"] 99 | git-tree-sha1 = "4558ab818dcceaab612d1bb8c19cee87eda2b83c" 100 | uuid = "2e619515-83b5-522b-bb60-26c02a35a201" 101 | version = "2.5.0+0" 102 | 103 | [[deps.ExproniconLite]] 104 | deps = ["Pkg", "TOML"] 105 | git-tree-sha1 = "d80b5d5990071086edf5de9018c6c69c83937004" 106 | uuid = "55351af7-c7e9-48d6-89ff-24e801d99491" 107 | version = "0.10.3" 108 | 109 | [[deps.FileWatching]] 110 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 111 | 112 | [[deps.FromFile]] 113 | deps = ["Downloads", "Requires"] 114 | git-tree-sha1 = "5df4ca248bed8c35164d6a7ae006073bbf8289ff" 115 | uuid = "ff7dd447-1dcb-4ce3-b8ac-22a812192de7" 116 | version = "0.1.5" 117 | 118 | [[deps.FuzzyCompletions]] 119 | deps = ["REPL"] 120 | git-tree-sha1 = "001bd0eefc8c532660676725bed56b696321dfd2" 121 | uuid = "fb4132e2-a121-4a70-b8a1-d5b831dcdcc2" 122 | version = "0.5.2" 123 | 124 | [[deps.Git]] 125 | deps = ["Git_jll"] 126 | git-tree-sha1 = "51764e6c2e84c37055e846c516e9015b4a291c7d" 127 | uuid = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2" 128 | version = "1.3.0" 129 | 130 | [[deps.GitHubActions]] 131 | deps = ["JSON", "Logging"] 132 | git-tree-sha1 = "f544c863d90c82854ac2d3003808de0e4cba4186" 133 | uuid = "6b79fd1a-b13a-48ab-b6b0-aaee1fee41df" 134 | version = "0.1.6" 135 | 136 | [[deps.Git_jll]] 137 | deps = ["Artifacts", "Expat_jll", "JLLWrappers", "LibCURL_jll", "Libdl", "Libiconv_jll", "OpenSSL_jll", "PCRE2_jll", "Zlib_jll"] 138 | git-tree-sha1 = "d8be4aab0f4e043cc40984e9097417307cce4c03" 139 | uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb" 140 | version = "2.36.1+2" 141 | 142 | [[deps.Glob]] 143 | git-tree-sha1 = "97285bbd5230dd766e9ef6749b80fc617126d496" 144 | uuid = "c27321d9-0574-5035-807b-f59d2c89b15c" 145 | version = "1.3.1" 146 | 147 | [[deps.HTTP]] 148 | deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] 149 | git-tree-sha1 = "cb56ccdd481c0dd7f975ad2b3b62d9eda088f7e2" 150 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 151 | version = "1.9.14" 152 | 153 | [[deps.HypertextLiteral]] 154 | deps = ["Tricks"] 155 | git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9" 156 | uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" 157 | version = "0.9.4" 158 | 159 | [[deps.InteractiveUtils]] 160 | deps = ["Markdown"] 161 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 162 | 163 | [[deps.IteratorInterfaceExtensions]] 164 | git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" 165 | uuid = "82899510-4779-5014-852e-03e436cf321d" 166 | version = "1.0.0" 167 | 168 | [[deps.JLLWrappers]] 169 | deps = ["Artifacts", "Preferences"] 170 | git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca" 171 | uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" 172 | version = "1.5.0" 173 | 174 | [[deps.JSON]] 175 | deps = ["Dates", "Mmap", "Parsers", "Unicode"] 176 | git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" 177 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 178 | version = "0.21.4" 179 | 180 | [[deps.LazilyInitializedFields]] 181 | git-tree-sha1 = "410fe4739a4b092f2ffe36fcb0dcc3ab12648ce1" 182 | uuid = "0e77f7df-68c5-4e49-93ce-4cd80f5598bf" 183 | version = "1.2.1" 184 | 185 | [[deps.LeftChildRightSiblingTrees]] 186 | deps = ["AbstractTrees"] 187 | git-tree-sha1 = "fb6803dafae4a5d62ea5cab204b1e657d9737e7f" 188 | uuid = "1d6d02ad-be62-4b6b-8a6d-2f90e265016e" 189 | version = "0.2.0" 190 | 191 | [[deps.LibCURL]] 192 | deps = ["LibCURL_jll", "MozillaCACerts_jll"] 193 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 194 | version = "0.6.3" 195 | 196 | [[deps.LibCURL_jll]] 197 | deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] 198 | uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" 199 | version = "7.84.0+0" 200 | 201 | [[deps.LibGit2]] 202 | deps = ["Base64", "NetworkOptions", "Printf", "SHA"] 203 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 204 | 205 | [[deps.LibSSH2_jll]] 206 | deps = ["Artifacts", "Libdl", "MbedTLS_jll"] 207 | uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" 208 | version = "1.10.2+0" 209 | 210 | [[deps.Libdl]] 211 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 212 | 213 | [[deps.Libiconv_jll]] 214 | deps = ["Artifacts", "JLLWrappers", "Libdl"] 215 | git-tree-sha1 = "f9557a255370125b405568f9767d6d195822a175" 216 | uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" 217 | version = "1.17.0+0" 218 | 219 | [[deps.LinearAlgebra]] 220 | deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] 221 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 222 | 223 | [[deps.Logging]] 224 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 225 | 226 | [[deps.LoggingExtras]] 227 | deps = ["Dates", "Logging"] 228 | git-tree-sha1 = "0d097476b6c381ab7906460ef1ef1638fbce1d91" 229 | uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" 230 | version = "1.0.2" 231 | 232 | [[deps.MIMEs]] 233 | git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" 234 | uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" 235 | version = "0.1.4" 236 | 237 | [[deps.Markdown]] 238 | deps = ["Base64"] 239 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 240 | 241 | [[deps.MbedTLS]] 242 | deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "Random", "Sockets"] 243 | git-tree-sha1 = "03a9b9718f5682ecb107ac9f7308991db4ce395b" 244 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 245 | version = "1.1.7" 246 | 247 | [[deps.MbedTLS_jll]] 248 | deps = ["Artifacts", "Libdl"] 249 | uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" 250 | version = "2.28.2+0" 251 | 252 | [[deps.Mmap]] 253 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 254 | 255 | [[deps.MozillaCACerts_jll]] 256 | uuid = "14a3606d-f60d-562e-9121-12d972cd8159" 257 | version = "2022.10.11" 258 | 259 | [[deps.MsgPack]] 260 | deps = ["Serialization"] 261 | git-tree-sha1 = "fc8c15ca848b902015bd4a745d350f02cf791c2a" 262 | uuid = "99f44e22-a591-53d1-9472-aa23ef4bd671" 263 | version = "1.2.0" 264 | 265 | [[deps.NetworkOptions]] 266 | uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" 267 | version = "1.2.0" 268 | 269 | [[deps.OpenBLAS_jll]] 270 | deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] 271 | uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" 272 | version = "0.3.21+4" 273 | 274 | [[deps.OpenSSL]] 275 | deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] 276 | git-tree-sha1 = "51901a49222b09e3743c65b8847687ae5fc78eb2" 277 | uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c" 278 | version = "1.4.1" 279 | 280 | [[deps.OpenSSL_jll]] 281 | deps = ["Artifacts", "JLLWrappers", "Libdl"] 282 | git-tree-sha1 = "bbb5c2115d63c2f1451cb70e5ef75e8fe4707019" 283 | uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" 284 | version = "1.1.22+0" 285 | 286 | [[deps.OrderedCollections]] 287 | git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3" 288 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 289 | version = "1.6.2" 290 | 291 | [[deps.PCRE2_jll]] 292 | deps = ["Artifacts", "Libdl"] 293 | uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15" 294 | version = "10.42.0+0" 295 | 296 | [[deps.Parsers]] 297 | deps = ["Dates", "PrecompileTools", "UUIDs"] 298 | git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" 299 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 300 | version = "2.7.2" 301 | 302 | [[deps.Pkg]] 303 | deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] 304 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 305 | version = "1.9.2" 306 | 307 | [[deps.Pluto]] 308 | deps = ["Base64", "Configurations", "Dates", "Distributed", "FileWatching", "FuzzyCompletions", "HTTP", "HypertextLiteral", "InteractiveUtils", "Logging", "LoggingExtras", "MIMEs", "Markdown", "MsgPack", "Pkg", "PrecompileSignatures", "PrecompileTools", "REPL", "RegistryInstances", "RelocatableFolders", "Sockets", "TOML", "Tables", "URIs", "UUIDs"] 309 | git-tree-sha1 = "06fec2244568a4641e3352d20d0a0a608df6fa92" 310 | uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781" 311 | version = "0.19.27" 312 | 313 | [[deps.PlutoSliderServer]] 314 | deps = ["AbstractPlutoDingetjes", "Base64", "BetterFileWatching", "Configurations", "Distributed", "FromFile", "Git", "GitHubActions", "Glob", "HTTP", "JSON", "Logging", "Pkg", "Pluto", "SHA", "Sockets", "TOML", "TerminalLoggers", "UUIDs"] 315 | git-tree-sha1 = "0965f4a7feb3f1814bcf67b379ceaa67cdb3beda" 316 | uuid = "2fc8631c-6f24-4c5b-bca7-cbb509c42db4" 317 | version = "0.3.26" 318 | 319 | [[deps.PrecompileSignatures]] 320 | git-tree-sha1 = "18ef344185f25ee9d51d80e179f8dad33dc48eb1" 321 | uuid = "91cefc8d-f054-46dc-8f8c-26e11d7c5411" 322 | version = "3.0.3" 323 | 324 | [[deps.PrecompileTools]] 325 | deps = ["Preferences"] 326 | git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" 327 | uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" 328 | version = "1.2.0" 329 | 330 | [[deps.Preferences]] 331 | deps = ["TOML"] 332 | git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1" 333 | uuid = "21216c6a-2e73-6563-6e65-726566657250" 334 | version = "1.4.0" 335 | 336 | [[deps.Printf]] 337 | deps = ["Unicode"] 338 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 339 | 340 | [[deps.ProgressLogging]] 341 | deps = ["Logging", "SHA", "UUIDs"] 342 | git-tree-sha1 = "80d919dee55b9c50e8d9e2da5eeafff3fe58b539" 343 | uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c" 344 | version = "0.1.4" 345 | 346 | [[deps.REPL]] 347 | deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] 348 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 349 | 350 | [[deps.Random]] 351 | deps = ["SHA", "Serialization"] 352 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 353 | 354 | [[deps.RegistryInstances]] 355 | deps = ["LazilyInitializedFields", "Pkg", "TOML", "Tar"] 356 | git-tree-sha1 = "ffd19052caf598b8653b99404058fce14828be51" 357 | uuid = "2792f1a3-b283-48e8-9a74-f99dce5104f3" 358 | version = "0.1.0" 359 | 360 | [[deps.RelocatableFolders]] 361 | deps = ["SHA", "Scratch"] 362 | git-tree-sha1 = "90bc7a7c96410424509e4263e277e43250c05691" 363 | uuid = "05181044-ff0b-4ac5-8273-598c1e38db00" 364 | version = "1.0.0" 365 | 366 | [[deps.Requires]] 367 | deps = ["UUIDs"] 368 | git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7" 369 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 370 | version = "1.3.0" 371 | 372 | [[deps.SHA]] 373 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 374 | version = "0.7.0" 375 | 376 | [[deps.Scratch]] 377 | deps = ["Dates"] 378 | git-tree-sha1 = "30449ee12237627992a99d5e30ae63e4d78cd24a" 379 | uuid = "6c6a2e73-6563-6170-7368-637461726353" 380 | version = "1.2.0" 381 | 382 | [[deps.Serialization]] 383 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 384 | 385 | [[deps.SimpleBufferStream]] 386 | git-tree-sha1 = "874e8867b33a00e784c8a7e4b60afe9e037b74e1" 387 | uuid = "777ac1f9-54b0-4bf8-805c-2214025038e7" 388 | version = "1.1.0" 389 | 390 | [[deps.Sockets]] 391 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 392 | 393 | [[deps.TOML]] 394 | deps = ["Dates"] 395 | uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" 396 | version = "1.0.3" 397 | 398 | [[deps.TableTraits]] 399 | deps = ["IteratorInterfaceExtensions"] 400 | git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39" 401 | uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" 402 | version = "1.0.1" 403 | 404 | [[deps.Tables]] 405 | deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"] 406 | git-tree-sha1 = "1544b926975372da01227b382066ab70e574a3ec" 407 | uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" 408 | version = "1.10.1" 409 | 410 | [[deps.Tar]] 411 | deps = ["ArgTools", "SHA"] 412 | uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" 413 | version = "1.10.0" 414 | 415 | [[deps.TerminalLoggers]] 416 | deps = ["LeftChildRightSiblingTrees", "Logging", "Markdown", "Printf", "ProgressLogging", "UUIDs"] 417 | git-tree-sha1 = "f133fab380933d042f6796eda4e130272ba520ca" 418 | uuid = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" 419 | version = "0.1.7" 420 | 421 | [[deps.Test]] 422 | deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] 423 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 424 | 425 | [[deps.TranscodingStreams]] 426 | deps = ["Random", "Test"] 427 | git-tree-sha1 = "9a6ae7ed916312b41236fcef7e0af564ef934769" 428 | uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" 429 | version = "0.9.13" 430 | 431 | [[deps.Tricks]] 432 | git-tree-sha1 = "aadb748be58b492045b4f56166b5188aa63ce549" 433 | uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" 434 | version = "0.1.7" 435 | 436 | [[deps.URIs]] 437 | git-tree-sha1 = "b7a5e99f24892b6824a954199a45e9ffcc1c70f0" 438 | uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" 439 | version = "1.5.0" 440 | 441 | [[deps.UUIDs]] 442 | deps = ["Random", "SHA"] 443 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 444 | 445 | [[deps.Unicode]] 446 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 447 | 448 | [[deps.Zlib_jll]] 449 | deps = ["Libdl"] 450 | uuid = "83775a58-1f1d-513f-b197-d71354ab007a" 451 | version = "1.2.13+0" 452 | 453 | [[deps.libblastrampoline_jll]] 454 | deps = ["Artifacts", "Libdl"] 455 | uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" 456 | version = "5.8.0+0" 457 | 458 | [[deps.nghttp2_jll]] 459 | deps = ["Artifacts", "Libdl"] 460 | uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" 461 | version = "1.48.0+0" 462 | 463 | [[deps.p7zip_jll]] 464 | deps = ["Artifacts", "Libdl"] 465 | uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" 466 | version = "17.4.0+0" 467 | -------------------------------------------------------------------------------- /pluto-slider-server-environment/PlutoDeployment.toml: -------------------------------------------------------------------------------- 1 | [Export] 2 | baked_notebookfile = false 3 | baked_state = false 4 | # slider_server_url="https://computationalthinking-sliderserver-c25.plutojl.org" 5 | exclude = [ 6 | "notebooks_old/*", 7 | "homeworks_old/*", 8 | ] 9 | 10 | [SliderServer] 11 | port = 80 12 | host = "0.0.0.0" 13 | exclude = [ 14 | "notebooks_old/*", 15 | "homeworks_old/*", 16 | # don't run the interactive sliderserver for homeworks 17 | "*/hw*.jl", 18 | ] 19 | -------------------------------------------------------------------------------- /pluto-slider-server-environment/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781" 3 | PlutoSliderServer = "2fc8631c-6f24-4c5b-bca7-cbb509c42db4" 4 | -------------------------------------------------------------------------------- /slides_old/ClimateMARGO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/slides_old/ClimateMARGO.pdf -------------------------------------------------------------------------------- /slides_old/ad_handwritten.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/slides_old/ad_handwritten.pdf -------------------------------------------------------------------------------- /slides_old/mesh_generation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmath/JuliaComputation/734119b67936e255f8d21dc8154d50a969cc31a0/slides_old/mesh_generation.pdf --------------------------------------------------------------------------------