Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize all functions for 2D arrays #5

Merged
merged 4 commits into from
Nov 23, 2022
Merged

Conversation

tilleyd
Copy link
Owner

@tilleyd tilleyd commented Nov 23, 2022

This change allows functions to be evaluated with different parameters simultaneously. As an example, if you have an array of shape (10, 50) containing 10 samples, previously you would have to evaluate them as

for i in range(10):
    y[i] = f1(x[i])

but can now be done simply with y = f1(x).

The functions have also been reimplemented using numpy array operations to allow a significant speedup for 2D inputs. For interest's sake, benchmark results measured with arrays of size (30, 100) (i.e. 30 samples of 100 dimensions) are listed below.

Function Old Time (ms) New Time (ms)
f1 1.4786 0.1097
f2 1.5524 0.1416
f3 1.8885 0.1353
f4 2.3877 0.1332
f5 2.3929 0.1261
f6 3.4209 0.1387
f7 3.7662 0.1435
f8 5.1008 0.1446
f9 5.4039 0.1465
f10 5.9024 0.1706
f11 5.7707 0.1838
f12 5.8063 0.2113
f13 5.7787 0.2223
f14 5.7659 0.2334
f15 5.6938 0.2403
f16 5.9140 0.2566
f17 6.4317 0.2809
f18 6.3171 0.2862
f19 6.7248 0.3025
f20 7.0393 0.3232
f21 7.3497 0.3329
f22 7.9632 0.3555
f23 8.7486 0.3813
f24 9.0502 0.3957
f25 9.5073 0.4114
f26 10.6782 0.4404
f27 11.7890 0.4701
f28 12.5931 0.4901
f29 13.3116 0.5293
f30 13.8205 0.5616

@tilleyd tilleyd merged commit baf0ba3 into master Nov 23, 2022
@tilleyd tilleyd deleted the feature/nd-optimization branch November 23, 2022 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant