summaryrefslogtreecommitdiff
path: root/gmpxx.h
Commit message (Collapse)AuthorAgeFilesLines
* Do not use mp directly in mpz_classMarc Glisse2022-04-181-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | This is the difference between f and g in the following, where gcc generates "return 1;" for f and not for g. The aliasing is caused by the functions get_num and get_den in mpq_class. struct mpz_struct { int i; }; typedef mpz_struct mpz_t[1]; struct mpq_struct { mpz_struct num, den; }; typedef mpq_struct mpq_t[1]; struct mpz_class { mpz_t mp; }; struct mpq_class { mpq_t mp; }; int f(mpq_class*q, mpz_class*z){ q->mp->num.i = 1; z->mp->i = 2; return q->mp->num.i; } int g(mpq_class*q, mpz_class*z){ q->mp->num.i = 1; int*p=&z->mp->i; *p = 2; return q->mp->num.i; }
* Add constructor mpq_class(mpz_class&&)Marc Glisse2021-06-201-0/+6
| | | | Surprisingly, the corresponding test was already present.
* gmpxx.h: Special handling for mpq==0Marco Bodrato2018-03-031-3/+8
|
* gmpxx.h (__gmp_binary_equal): Optimised comparison mpq == integer.Marco Bodrato2018-02-281-3/+3
|
* gmpxx.h (__gmp_binary_{min,pl}us): Special case for mpq -/+ 1.Marco Bodrato2018-02-281-0/+10
|
* Use mpf_sgn to access _mp_size in gmpxx.h.Marc Glisse2017-06-021-1/+1
| | | | This helps mpf2mpfr.h without changing the generated code (at least with gcc).
* Optimize 1/q to call mpq_inv.Marc Glisse2016-10-281-2/+27
| | | | Also handle (-1)/q and 0/q. We could test for l == 1 at runtime and not just with __builtin_constant_p, it might be worth it, especially for non-gcc compilers.
* mpz_init cannot throw.Marc Glisse2016-04-071-2/+2
|
* New C++ function fibonacci.Marc Glisse2015-11-121-8/+39
|
* Reject negative operands for primorial, after Marco's suggestion.Marc Glisse2015-11-101-7/+5
|
* New C++ function primorial.Marc Glisse2015-11-081-0/+27
|
* Update copyright years on gmpxx.h.Marc Glisse2015-11-081-1/+1
|
* Mark the static member function inline.Marc Glisse2015-11-081-2/+2
|
* factorial in C++.Marc Glisse2015-11-081-0/+97
|
* Nicer failure mode for C++ binary functions.Marc Glisse2015-11-071-7/+70
| | | | | Restrict the overloads to the types that are actually supported. It would be possible to share some more generic macros with __GMP_DEFINE_BINARY_FUNCTION but I am afraid it would become completely unreadable.
* Nicer failure mode for C++ unary function.Marc Glisse2015-11-071-5/+18
| | | | Restrict the overloads to the types that are actually supported.
* Use the new mpq_cmp_z in gmpxx.h.Marc Glisse2015-10-131-51/+93
|
* Prepare for expressions like factorial(int).Marc Glisse2014-12-271-2/+20
|
* Add C++ functions gcd and lcm.Marc Glisse2014-06-171-0/+38
|
* The C++ standard was modified so common_type now decays.Marc Glisse2014-05-081-2/+2
|
* Update library files license to use LGPL3+ and GPL2+.Torbjorn Granlund2014-01-271-7/+18
|
* Canonicalise copyright headers.Torbjorn Granlund2014-01-191-3/+3
|
* Use https to link to GNU license.Torbjorn Granlund2013-12-021-1/+1
|
* Collapse copyright years.Torbjorn Granlund2013-11-281-2/+1
|
* Update some old uses of __GMPXX_CONSTANT to bring them in line with the new ↵Marc Glisse2013-02-171-26/+17
| | | | ones.
* Construct temporary mpq from double on the stack, as is already the case for ↵Marc Glisse2013-02-171-93/+28
| | | | mpz.
* gmpxx.h (mpq_class, mpf_class): Some more SI->UI optimisations.Marco Bodrato2013-02-171-18/+33
|
* #include <algorithm> for std::swap.Marc Glisse2013-02-161-0/+1
|
* Use __builtin_constant_p in mpz_class::init_* and mpz_class::assign_*.Marc Glisse2013-02-151-6/+48
| | | | | Introduce macro __GMPXX_CONSTANT_TRUE (to be removed if it makes its way into gmp.h).
* Refactor the C++ code to convert from builtin types so we have a singleMarc Glisse2013-02-151-103/+62
| | | | place to optimize.
* Reduce the number of worker functions in __gmp_binary_equal (forwardMarc Glisse2013-02-141-8/+8
| | | | instead of duplicating the code).
* Remove code duplication between __gmp_binary_greater and __gmp_binary_less.Marc Glisse2013-02-141-60/+2
|
* Specialize std::common_type for expressions with builtin types.Marc Glisse2012-07-281-0/+25
|
* Disable __builtin_constant_p for g++34.Marc Glisse2012-07-211-1/+3
|
* specializing numeric_limits is useless if the content is private...Marc Glisse2012-06-231-0/+3
| | | | I'll add some tests later to make sure I don't accidentally revert it some day.
* Unify handling of mpf with mpz/mpq. Function eval had 2 arguments for mpf:Marc Glisse2012-06-091-75/+43
| | | | p and prec, but prec was always equal to mpf_get_prec(p), so I am removing it.
* Handle mpq_class(0,1)Marc Glisse2012-05-311-1/+8
|
* explicit conversion to boolMarc Glisse2012-05-111-0/+12
|
* C++11 user-defined literalsMarc Glisse2012-03-081-2/+22
|
* Specialize std::numeric_limits for mp*_class types. It is mostly ↵Marc Glisse2012-02-291-0/+114
| | | | meaningless, but that's normal.
* Use macros like NUM, ALLOC, SIZ, etc in mpq/*.Marc Glisse2012-02-241-0/+5
| | | | | Test some mpq functions that were not used in the testsuite. Implement q=z (in gmpxx) with mpq_set_z.
* Remove a temporary in expressions like q=q*q+z*z: tmp=z*z, q=q*q, q+=tmp.Marc Glisse2012-02-181-12/+12
| | | | Note that we could do the same for q=q*q+z, but that would require checking if z is the numerator or denominator of q.
* Comment out long double function declarations. Half of them were already ↵Marc Glisse2012-02-181-3/+3
| | | | commented out, and the other half had declarations but no definitions.
* Specialize std::common_type in C++11.Marc Glisse2012-02-181-2/+24
|
* Replace e=a*b-c*d with tmp=c*d, e=a*b, e-=tmp, which uses one less temporary.Marc Glisse2012-02-161-6/+9
|
* Remove test for compilosaurus.Marc Glisse2012-02-011-13/+2
|
* Initial C++11 support.Marc Glisse2012-01-301-6/+45
|
* Replace d=a+b+c with (d=a+b)+=c when c!=d.Marc Glisse2012-01-301-8/+40
| | | | | | TODO: * same thing for the mixed mpq/mpz operations * finish the generic code I have that generalizes all these small optimizations (may not be ready for 5.1)
* Make sure we never compute -LONG_MIN.Marc Glisse2012-01-281-19/+24
|
* more mp_bitcnt_t...Marc Glisse2012-01-281-10/+11
|