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

Add kernel implementation of Binomial() #1921

Merged
merged 1 commit into from
Nov 21, 2017

Commits on Nov 17, 2017

  1. Add kernel implementation of Binomial()

    This uses the GMP functions mpz_bin_ui and mpz_bin_uiui. The following timings
    for certain central binomial coefficients illustrates the speedup:
    
    gap> n:=2^14;; a:=BINOMIAL_INT(2*n,n);; time; b:=Binomial_GAP(2*n,n);; time;
    0
    51
    
    gap> n:=2^16;; a:=BINOMIAL_INT(2*n,n);; time; b:=Binomial_GAP(2*n,n);; time;
    2
    719
    
    gap> n:=2^18;; a:=BINOMIAL_INT(2*n,n);; time; b:=Binomial_GAP(2*n,n);; time;
    8
    11470
    
    gap> n:=2^19;; a:=BINOMIAL_INT(2*n,n);; time; b:=Binomial_GAP(2*n,n);; time;
    14
    51386
    
    gap> n:=2^20;; a:=BINOMIAL_INT(2*n,n);; time; b:=Binomial_GAP(2*n,n);; time;
    33
    190444
    
    The main reason the C version is so much faster is that it can accumulate the
    result in-place, whereas GAP creates tons and tons of temporary integer
    objects which then need to be garbage collected. Of course some other tricks
    employed by GMP help, too.
    fingolfin committed Nov 17, 2017
    Configuration menu
    Copy the full SHA
    f26ded4 View commit details
    Browse the repository at this point in the history