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

vectorize the function point_to_line() for time speed up #2

Closed
sbrockhaus opened this issue Jul 25, 2016 · 2 comments
Closed

vectorize the function point_to_line() for time speed up #2

sbrockhaus opened this issue Jul 25, 2016 · 2 comments

Comments

@sbrockhaus
Copy link
Contributor

To speed up the computation of the idealized line by the function points_on_ideal(), I propose to vectorize the function point_to_line() such that the argument P0 expects a matrix of points and not just a single point.

A small benchmark on computation times shows that the time is reduced drastically. On my machine the mean computation time for an example with 1000 observations can be reduced from about 1400 to 100 microseconds.

As the functions points_on_ideal() and point_to_line() are both internal, it should be easy to replace point_to_line() by the vectorized version and keep everything else as is.

Attached you find such a vectorized version of point_to_line(), with some code for benchmarking (R-Code as .txt as .R files cannot be uploaded here).

Best,
Sarah

vectorize_point_to_line.txt

@sbrockhaus
Copy link
Contributor Author

see pull request #3 for proposed changes on the package

@PascalKieslich
Copy link
Owner

Thanks, Sarah, for the suggestion, your implementation, and the benchmark! Just accepted the changes you proposed.

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

No branches or pull requests

2 participants