動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04.4 LTS desktop amd64
TensorFlow v1.7.0
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0
MATLAB R2017b (Home Edition)
ADDA v.1.3b6
gnustep-gui-runtime v0.24.0-3.1
PyMieScatt v1.7.0
線分の交差判定を使う処理を実装している。
- sympy実装: geometry > star shape(星形)の内部をdipoleでfillする > findDipolesInisideStarShape_180429 v0.1 > sympy使用 > 3分かかる (MESH_RESOL=20)
- shapely実装: geometry > star shape(星形)の内部をdipoleでfillする > findDipolesInisideStarShape_180429 v0.2 > shapely使用 > 1秒で完了 (MESH_RESOL=50)
sympyで3分かかった処理はshapelyで1秒未満だった。
intersection処理速度が違うのだろうか。
速度比較
sympy
test_speed_symp_180429.ipynb
from sympy import *
def test_func():
sg1,sg2 = Segment( Point(0,0), Point(1,1)),Segment( Point(0,1), Point(1,0))
ls = intersection(sg1,sg2)
print(ls)
ls = intersection(sg1,sg2)[0]
print(ls,ls.x,ls.y)
sg1,sg2 = Segment( Point(0,0), Point(0.3,0.3)), Segment( Point(0,1), Point(1,0))
ls = intersection(sg1,sg2)
print(ls)
%timeit test_func
run
12.7 ns ± 0.021 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
shapely
test_speed_symp_180429.ipynb
from shapely.geometry import LineString
def test_func():
sg1 = LineString([(0, 0), (1, 1)])
sg2 = LineString([(0, 1), (1, 0)])
ls = sg1.intersection(sg2)
print(ls)
sg1 = LineString([(0, 0), (0.3, 0.3)])
sg2 = LineString([(0, 1), (1, 0)])
ls = sg1.intersection(sg2)
print(ls)
%timeit test_func
run
12.8 ns ± 0.112 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
考察
両者の処理速度に大きな違いは見られなかった。
sympy使用時に3分でshapely使用時に1秒の違いが生じる理由については未消化。