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 tests for GMP code and start overhauling it #1045

Merged
merged 38 commits into from
Jan 13, 2017

Commits on Jan 11, 2017

  1. Configuration menu
    Copy the full SHA
    cf12444 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4a3f678 View commit details
    Browse the repository at this point in the history
  3. tests: make intarith.tst more systematic

    * test negative integers (small and big), too
    * systematically test all possible juxtapositions of arguments for the
      operations that are covered
    * sorted tests by which kernel function they exercise, and document the
      name of the function in a comment
    * add tests for more functions (ModInt, ProdInt, AbsInt, ...)
    * move PValuation tests to new file numtheor.tst (PValuation is not
      basic integer arithmetic, so it does not belong into intarith.tst)
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    1b8681c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    90c22ef View commit details
    Browse the repository at this point in the history
  5. gmpints: improve optimization for "x mod 2^k" for small k

    We already did this, but for fewer values of k than possible,
    and also using an inefficient integer division instead of a shift
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    a352b8a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    aa9c3b7 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    3bc3eca View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    8f504df View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    7cdf8c9 View commit details
    Browse the repository at this point in the history
  10. gmpints: rewrote PowInt, and fix 0^-LARGEINT

    This commit simplifies the code of PowInt, reducing code duplication.
    This fixes a bug where 0^-LARGEINT returned 0, instead of raising an
    error; and ensures that optimizations for certain special cases always
    take effect, even if the exponent is large.
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    4e0bc63 View commit details
    Browse the repository at this point in the history
  11. gmpints: cleanup ProdIntObj

    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    dbf44e2 View commit details
    Browse the repository at this point in the history
  12. gmpints: cleanup PowObjInt

    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    bddc188 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    b0654aa View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    c72c8da View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    b558aba View commit details
    Browse the repository at this point in the history
  16. gmpints: remove unused stuff

    * NEW_INTNEG was commented out and also trivial to reimplement
    * ProdIntObjFunc and PowObjIntFunc were declared but never used
    * SMALLEST_INTPOS was exported to the language level, but unused
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    66a5d51 View commit details
    Browse the repository at this point in the history
  17. gmpints: pedantic tweak to ModInt

    This change should be mostly irrelevant.; indeed, the C99
    standard mandates that a%b and a%(-b) are equal, and even
    on most pre-C99 compiler this holds true -- but not all.
    
    We could instead also add a configure test, and reject compilers
    violating this; in that case, we can obviously just stop checking
    the sign of k.
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    1195105 View commit details
    Browse the repository at this point in the history
  18. compiler: be defensive about possible INTEGER_UNIT_SIZE values

    In particular, if INTEGER_UNIT_SIZE ever differs from 2, 4, 8,
    produce an error.
    
    Also replace some tabs by spaces.
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    8933614 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    5bddb1c View commit details
    Browse the repository at this point in the history
  20. gmpints: simplify EqInt

    The result should also be a bit faster when comparing a small with a
    large integer, as we immediately return false, instead of first
    converting the small integer into a large one, then calling mpn_cmp.
    This relies on all integers always being normalized and reduced.
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    8539203 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    f2f82d5 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    7fe0b1a View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    1a00950 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    1b891cb View commit details
    Browse the repository at this point in the history
  25. lib: change AbsInt/SignInt methods to use ABS_RAT and SIGN_RAT

    We cannot simply use ABS_INT and SIGN_INT, as one might expect
    given the names AbsInt/SignInt, as a lot of library code (and
    likely in packages and elsewhere) is relying on the undocumented
    fact that the old AbsInt and SignInt implementations also worked
    for rationals.
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    3f994af View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    f623903 View commit details
    Browse the repository at this point in the history
  27. lib: use AbsoluteValue instead of AbsInt

    AbsoluteValue used to invoke AbsInt on non-integer rationals.
    While this works, this is undocumented
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    f92fb1f View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    862b3e1 View commit details
    Browse the repository at this point in the history
  29. lib: remove shortbanner support

    This was added 2010-11-02 as an experimental feature by Laurent.
    But it was never documented, nor hooked up to anything, or usable
    without modifying the library.
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    d761332 View commit details
    Browse the repository at this point in the history
  30. lib: fix indentation

    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    9794cf4 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    bd2fd18 View commit details
    Browse the repository at this point in the history
  32. gmpints: make SumOrDiffInt internal

    This allows us to optimize it.
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    7a7c173 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    cf8a3e9 View commit details
    Browse the repository at this point in the history
  34. gmpints: remove invalid ModInt return value treatment

    Before returning the computed result, ModInt checked whether it was
    negative, it flipped the sign. This should (a) never be necessary,
    because the preceding computations should always produce something
    non-negative, and (b) would be mathematically incorrect.
    
    Instead, we simply return the result untreated, and added an assertion
    triggering if we ever see a negative result here (only enabled if
    DEBUG_GMP is set).
    fingolfin committed Jan 11, 2017
    Configuration menu
    Copy the full SHA
    9730707 View commit details
    Browse the repository at this point in the history

Commits on Jan 12, 2017

  1. gmpints: add CHECK_INT macro for debugging

    To turn this on, #define DEBUG_GMP 1
    fingolfin committed Jan 12, 2017
    Configuration menu
    Copy the full SHA
    7e51920 View commit details
    Browse the repository at this point in the history
  2. gmpints: reduce output of IntHexString

    This fix a bug, as IntHexString could return a non-reduced integer.
    fingolfin committed Jan 12, 2017
    Configuration menu
    Copy the full SHA
    01f3bef View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1bc3d6c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    74280ef View commit details
    Browse the repository at this point in the history