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

Enhancements to expt #651

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jpellegrini
Copy link
Contributor

  • Don't use Scheme arithmentic where not needed in exponentiation by squaring (the exponent is known to be a fixnum).
  • Fast path for exponent=2 (much much faster).
  • Change name exact_exponent_expt -> fixnum_exponent_expt
  • Move the bignum check to my_expt, so the exponent is always a fixnum when calling fixnum_exponent_expt.
  • Since the exponent is always a fixnum in fixnum_exponent_expt, compare with MAKE_INT(0) instead of using zerop.

Results:

  • for some integer exponents, expt is faster
  • specifically, for exponent = 2, it is more than twice as fast

* Don't use Scheme arithmentic where not needed in exponentiation by
  squaring (the exponent is known to be a fixnum).
* Fast path for exponent=2 (much much faster).
* Change name `exact_exponent_expt` -> `fixnum_exponent_expt`
* Move the bignum check to `my_expt`, so the exponent is always a fixnum
  when calling `fixnum_exponent_expt`.
* Since the exponent is always a fixnum in `fixnum_exponent_expt`, compare
  with `MAKE_INT(0)` instead of using `zerop`.

Results:
* for some integer exponents, `expt` is faster
* specifically, for exponent = 2, it is more than twice as fast
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.

None yet

1 participant