Update solutions notebook

This commit is contained in:
Gelieza K 2023-08-14 15:14:23 +02:00
parent ebdeef8893
commit b55aef53a7
5 changed files with 86 additions and 25 deletions

View File

@ -758,7 +758,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Julia 1.9.0", "display_name": "Julia 1.9.1",
"language": "julia", "language": "julia",
"name": "julia-1.9" "name": "julia-1.9"
}, },
@ -766,7 +766,7 @@
"file_extension": ".jl", "file_extension": ".jl",
"mimetype": "application/julia", "mimetype": "application/julia",
"name": "julia", "name": "julia",
"version": "1.9.0" "version": "1.9.1"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -1589,7 +1589,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Julia 1.9.0", "display_name": "Julia 1.9.1",
"language": "julia", "language": "julia",
"name": "julia-1.9" "name": "julia-1.9"
}, },
@ -1597,7 +1597,7 @@
"file_extension": ".jl", "file_extension": ".jl",
"mimetype": "application/julia", "mimetype": "application/julia",
"name": "julia", "name": "julia",
"version": "1.9.0" "version": "1.9.1"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -1295,19 +1295,11 @@
"\n", "\n",
"We have seen the basics of distributed computing in Julia. The programming model is essentially an extension of tasks and channels to parallel computations on multiple machines. The low-level functions are `remotecall` and `RemoteChannel`, but there are other functions and macros like `pmap` and `@distributed` that simplify the implementation of parallel algorithms." "We have seen the basics of distributed computing in Julia. The programming model is essentially an extension of tasks and channels to parallel computations on multiple machines. The low-level functions are `remotecall` and `RemoteChannel`, but there are other functions and macros like `pmap` and `@distributed` that simplify the implementation of parallel algorithms."
] ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "49d094e4",
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Julia 1.9.0", "display_name": "Julia 1.9.1",
"language": "julia", "language": "julia",
"name": "julia-1.9" "name": "julia-1.9"
}, },
@ -1315,7 +1307,7 @@
"file_extension": ".jl", "file_extension": ".jl",
"mimetype": "application/julia", "mimetype": "application/julia",
"name": "julia", "name": "julia",
"version": "1.9.0" "version": "1.9.1"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -1108,14 +1108,6 @@
"println(\"Optimal speedup = \", P)\n", "println(\"Optimal speedup = \", P)\n",
"println(\"Efficiency = \", 100*(T1/TP)/P, \"%\")" "println(\"Efficiency = \", 100*(T1/TP)/P, \"%\")"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cd31d955",
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {

View File

@ -1,13 +1,90 @@
{ {
"cells": [ "cells": [
{
"cell_type": "markdown",
"id": "f48b9a60",
"metadata": {},
"source": [
"# Solutions to Notebook Exercises\n",
"\n",
"## Julia Basics: Exercise 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a06fd02a",
"metadata": {},
"outputs": [],
"source": [
"function ex1(a)\n",
" j = 1\n",
" m = a[j]\n",
" for (i,ai) in enumerate(a)\n",
" if m < ai\n",
" m = ai\n",
" j = i\n",
" end\n",
" end\n",
" (m,j)\n",
"end"
]
},
{
"cell_type": "markdown",
"id": "175b6c35",
"metadata": {},
"source": [
"## Julia Basics: Exercise 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bb289acd",
"metadata": {},
"outputs": [],
"source": [
"ex2(f,g) = x -> f(x) + g(x) "
]
},
{
"cell_type": "markdown",
"id": "86250e27",
"metadata": {},
"source": [
"## Julia Basics: Exercise 3"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "41b537ab",
"metadata": {},
"outputs": [],
"source": [
"function compute_values(n,max_iters)\n",
" x = LinRange(-1.7,0.7,n)\n",
" y = LinRange(-1.2,1.2,n)\n",
" values = zeros(Int,n,n)\n",
" for j in 1:n\n",
" for i in 1:n\n",
" values[i,j] = mandel(x[i],y[j],max_iters)\n",
" end\n",
" end\n",
" values\n",
"end\n",
"values = compute_values(1000,10)\n",
"using GLMakie\n",
"heatmap(x,y,values)"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "d6d12733", "id": "d6d12733",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Solutions to Notebook Exercises\n", "## Matrix Multiplication : Exercise 1"
"\n",
"## Matrix Multiplication : Implementation of Algorithm 3"
] ]
}, },
{ {