Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions labs/ex01/solution/taskB.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
" A naive solution for finding pairvise distances between poins in P and Q\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
"\n",
Expand Down Expand Up @@ -247,8 +247,8 @@
" An optimized solution using matching indices\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
"\n",
Expand Down Expand Up @@ -284,8 +284,8 @@
" An optimized solution using matching indices\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
"\n",
Expand Down Expand Up @@ -324,8 +324,8 @@
" A solution using scipy\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
"\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
Expand Down Expand Up @@ -354,8 +354,8 @@
" A solution using tensor broadcasting\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
"\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
Expand Down Expand Up @@ -472,10 +472,24 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
40 changes: 24 additions & 16 deletions labs/ex01/template/taskB.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"source": [
"Data Generation\n",
Expand All @@ -42,7 +41,6 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"source": [
"Solution\n",
Expand All @@ -60,8 +58,8 @@
" A naive solution for finding pairvise distances between poins in P and Q\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
"\n",
Expand All @@ -87,7 +85,6 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"source": [
"### Use matching indices\n",
Expand Down Expand Up @@ -127,8 +124,8 @@
" An optimized solution using matching indices\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
"\n",
Expand All @@ -154,7 +151,6 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"source": [
"### Use a library\n",
Expand All @@ -176,8 +172,8 @@
" A solution using scipy\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
"\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
Expand All @@ -190,7 +186,6 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"source": [
"### Numpy Magic"
Expand All @@ -207,8 +202,8 @@
" A solution using tensor broadcasting\n",
"\n",
" Args:\n",
" P: numpy array of shape=(p, 2)\n",
" Q: numpy array of shape=(q, 2)\n",
" P: numpy array of shape=(p, n)\n",
" Q: numpy array of shape=(q, n)\n",
"\n",
" Returns:\n",
" D: numpy array of shape=(p, q)\n",
Expand All @@ -221,7 +216,6 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"source": [
"# Compare methods"
Expand Down Expand Up @@ -272,10 +266,24 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}