Created
April 12, 2021 04:22
-
-
Save antimon2/4f332bdaef6627fd32a6142eeebd5fec to your computer and use it in GitHub Desktop.
MeshgridTest.jl.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:30.058Z", | |
"end_time": "2021-04-12T13:21:30.851000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "versioninfo()", | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "Julia Version 1.6.0\nCommit f9720dc2eb (2021-03-24 12:55 UTC)\nPlatform Info:\n OS: Linux (x86_64-pc-linux-gnu)\n CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\n WORD_SIZE: 64\n LIBM: libopenlibm\n LLVM: libLLVM-11.0.1 (ORCJIT, skylake)\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:35.023Z", | |
"end_time": "2021-04-12T13:21:35.001000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "function meshgrid1(x, y)\n # Complex.(x', y) |> z -> (real(z), imag(z))\n reim(Complex.(x', y))\nend", | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 2, | |
"data": { | |
"text/plain": "meshgrid1 (generic function with 1 method)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:37.670Z", | |
"end_time": "2021-04-12T13:21:37.258000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "function meshgrid2(x, y)\n (\n repeat(x', outer=(length(y), 1)),\n repeat(y, outer=(1, length(x)))\n )\nend", | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 3, | |
"data": { | |
"text/plain": "meshgrid2 (generic function with 1 method)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:38.863Z", | |
"end_time": "2021-04-12T13:21:38.481000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "function meshgrid3(x, y)\n ([v for _=y, v=x], [v for v=y, _=x])\nend", | |
"execution_count": 4, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 4, | |
"data": { | |
"text/plain": "meshgrid3 (generic function with 1 method)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:46.153Z", | |
"end_time": "2021-04-12T13:21:45.747000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "x = range(-3, 3, step=0.1);\ny = range(-4, 4, step=0.1);", | |
"execution_count": 5, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:46.955Z", | |
"end_time": "2021-04-12T13:21:47.167000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "X1, Y1 = meshgrid1(x, y)", | |
"execution_count": 6, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 6, | |
"data": { | |
"text/plain": "([-3.0 -2.9 … 2.9 3.0; -3.0 -2.9 … 2.9 3.0; … ; -3.0 -2.9 … 2.9 3.0; -3.0 -2.9 … 2.9 3.0], [-4.0 -4.0 … -4.0 -4.0; -3.9 -3.9 … -3.9 -3.9; … ; 3.9 3.9 … 3.9 3.9; 4.0 4.0 … 4.0 4.0])" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:48.897Z", | |
"end_time": "2021-04-12T13:21:48.566000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "X2, Y2 = meshgrid2(x, y)", | |
"execution_count": 7, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 7, | |
"data": { | |
"text/plain": "([-3.0 -2.9 … 2.9 3.0; -3.0 -2.9 … 2.9 3.0; … ; -3.0 -2.9 … 2.9 3.0; -3.0 -2.9 … 2.9 3.0], [-4.0 -4.0 … -4.0 -4.0; -3.9 -3.9 … -3.9 -3.9; … ; 3.9 3.9 … 3.9 3.9; 4.0 4.0 … 4.0 4.0])" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:49.879Z", | |
"end_time": "2021-04-12T13:21:49.490000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "X3, Y3 = meshgrid3(x, y)", | |
"execution_count": 8, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 8, | |
"data": { | |
"text/plain": "([-3.0 -2.9 … 2.9 3.0; -3.0 -2.9 … 2.9 3.0; … ; -3.0 -2.9 … 2.9 3.0; -3.0 -2.9 … 2.9 3.0], [-4.0 -4.0 … -4.0 -4.0; -3.9 -3.9 … -3.9 -3.9; … ; 3.9 3.9 … 3.9 3.9; 4.0 4.0 … 4.0 4.0])" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:51.228Z", | |
"end_time": "2021-04-12T13:21:50.983000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "X1 == X2 == X3", | |
"execution_count": 9, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 9, | |
"data": { | |
"text/plain": "true" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:52.217Z", | |
"end_time": "2021-04-12T13:21:51.722000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "Y1 == Y2 == Y3", | |
"execution_count": 10, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 10, | |
"data": { | |
"text/plain": "true" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:53.637Z", | |
"end_time": "2021-04-12T13:21:53.141000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "using BenchmarkTools", | |
"execution_count": 11, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:21:55.392Z", | |
"end_time": "2021-04-12T13:22:01.730000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "@benchmark meshgrid1(x, y)", | |
"execution_count": 12, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 12, | |
"data": { | |
"text/plain": "BenchmarkTools.Trial: \n memory estimate: 154.77 KiB\n allocs estimate: 7\n --------------\n minimum time: 13.786 μs (0.00% GC)\n median time: 15.716 μs (0.00% GC)\n mean time: 17.745 μs (8.13% GC)\n maximum time: 626.237 μs (95.08% GC)\n --------------\n samples: 10000\n evals/sample: 1" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:22:03.603Z", | |
"end_time": "2021-04-12T13:22:08.997000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "@benchmark meshgrid2(x, y)", | |
"execution_count": 13, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 13, | |
"data": { | |
"text/plain": "BenchmarkTools.Trial: \n memory estimate: 77.44 KiB\n allocs estimate: 5\n --------------\n minimum time: 26.316 μs (0.00% GC)\n median time: 28.102 μs (0.00% GC)\n mean time: 30.176 μs (3.12% GC)\n maximum time: 748.620 μs (95.67% GC)\n --------------\n samples: 10000\n evals/sample: 1" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2021-04-12T04:22:10.491Z", | |
"end_time": "2021-04-12T13:22:15.694000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "@benchmark meshgrid3(x, y)", | |
"execution_count": 14, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 14, | |
"data": { | |
"text/plain": "BenchmarkTools.Trial: \n memory estimate: 77.44 KiB\n allocs estimate: 5\n --------------\n minimum time: 11.442 μs (0.00% GC)\n median time: 12.179 μs (0.00% GC)\n mean time: 13.185 μs (4.65% GC)\n maximum time: 531.136 μs (96.60% GC)\n --------------\n samples: 10000\n evals/sample: 1" | |
}, | |
"metadata": {} | |
} | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "julia-1.6", | |
"display_name": "Julia 1.6.0", | |
"language": "julia" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"name": "julia", | |
"mimetype": "application/julia", | |
"version": "1.6.0" | |
}, | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "MeshgridTest.jl.ipynb", | |
"public": true | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment