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

Small speedup in samping from ortho and special_ortho groups #10058

Merged
merged 2 commits into from Apr 14, 2019

Conversation

JesseLivezey
Copy link
Contributor

@JesseLivezey JesseLivezey commented Apr 12, 2019

Makes 3 changes:

  • Uses dot for norm^2,
  • Reuse norm calculation, and
  • do multiplications by scalars in a different place.

This should be identical up to floating point associativity differences such as between dot(x, x) and (x*x).sum(). np.allclose is satisfied for everything I've checked although np.array_equal is not.

I timed this on my desktop using only 1 core for dim ranging from 2 to 200. Current code is typically 5-15% slower and this tends to shrink for larger dims.

ortho

special_ortho

Notebook that generated the tests is here
https://github.com/JesseLivezey/scipy-ortho-speedup/blob/master/faster_ortho_groups.ipynb

@JesseLivezey
Copy link
Contributor Author

Is it worth adding a benchmark for these?

@rgommers
Copy link
Member

It would be nice to have a benchmark, because it looks like there are none for ortho or special_ortho yet.

@rgommers rgommers added enhancement A new feature or improvement scipy.stats labels Apr 13, 2019
@JesseLivezey
Copy link
Contributor Author

@rgommers added a benchmark!

@rgommers rgommers merged commit d565b61 into scipy:master Apr 14, 2019
@rgommers
Copy link
Member

Benchmark looks good, and verified that code is equivalent. Merged, thanks @JesseLivezey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement scipy.stats
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants