-
Notifications
You must be signed in to change notification settings - Fork 161
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 FACTORIAL_INT of Factorial #1969
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1969 +/- ##
==========================================
+ Coverage 65.2% 65.52% +0.31%
==========================================
Files 930 930
Lines 275034 275887 +853
Branches 12718 12768 +50
==========================================
+ Hits 179346 180774 +1428
+ Misses 92401 92321 -80
+ Partials 3287 2792 -495
|
src/integer.c
Outdated
*/ | ||
Obj FuncFACTORIAL_INT(Obj self, Obj n) | ||
{ | ||
REQUIRE_INT_ARG("FactorialInt", "n", n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be Factorial
instead of FactorialInt
(which does not exist on GAP level)?
And why is this test made in a separate function?
Why not changing FactorialInt
above into FuncFactorial
and removing this FuncFACTORIAL_INT
and the InstallGlobalFunction(Factorial, FACTORIAL_INT);
line in the library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that should be Factorial
and not FactorialInt
.
The check is in a separate function because so far all those integer functions had a "kernel version" (i.e. FactorialInt
), and a "library version (i.e. FuncFACTORIAL_INT
) -- in other words, blind habit. But its unlikely that we will want to directly call Factorial
from the kernel, so that's overkill here, so I agree we can merge the two together.
(These remarks apply similarly to Binomial
and a few others, I'll look into tweaking those, too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why I did not remove InstallGlobalFunction(Factorial, FACTORIAL_INT);
is that then I also need to remove the Declare*
counterpart, and decide where to move the GAPDoc comment; and I'd rather keep the change as small as possible.
The performance seems significantly better than that of the function in PR #1968 for all reasonable inputs. So this PR should be preferred. |
* merge several pairs of functions * adjust some error messages * adjust the names of the arguments of 'JACOBI_INT', to match the documented argument names for 'Jacobi'
51b7e02
to
e0fa073
Compare
Updated. |
It was redundant, combinat.tst already contains good thorough tests for Binomial
This is an alternative to PR #1968. Some micro-benchmark results: