ondrolexa / apsg

Structural geology package for Python
https://apsg.readthedocs.io
Other
102 stars 27 forks source link

New math subpackage #21

Closed 4e1e0603 closed 4 years ago

4e1e0603 commented 5 years ago

New "math" subpackage

Work in progress -- it is not intended for merging! See the current branch and notebook

Math changes

Benchmarks

I plan to write more benchmarks but it seems that pure Python beats Numpy -- it is known that for small dimensions ndarray doesn't speed up the code, quite the opposite.

from apsg import Vec3
​
v1 = Vec3([1, 2, 3])
v2 = Vec3([3, 2, 1])
​
%timeit -r 1000 -n 1000 v1.cross(v2)
53.2 µs ± 4.46 µs per loop (mean ± std. dev. of 1000 runs, 1000 loops each)

from apsg.math import Vector3
​
v1 = Vector3(1, 2, 3)
v2 = Vector3(3, 2, 1)
​
%timeit -r 1000 -n 1000 v1.cross(v2)
9.82 µs ± 1.21 µs per loop (mean ± std. dev. of 1000 runs, 1000 loops each)

Other changes