From 431d655e69fc4256c344c64dd0b11e075752e7c6 Mon Sep 17 00:00:00 2001 From: William Hart Date: Thu, 27 Mar 2014 15:34:35 +0000 Subject: [PATCH 1/3] Fixed a miscompilation of mpirxx.h with a C++11 compiler. --- mpirxx.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mpirxx.h b/mpirxx.h index 568aa7c6..51e2b4e4 100644 --- a/mpirxx.h +++ b/mpirxx.h @@ -40,6 +40,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include #include #include +#include /* swap */ #include #if defined( _MSC_VER ) && _MSC_VER >= 1700 @@ -1383,7 +1384,7 @@ struct __gmp_resolve_expr typedef mpf_t value_type; }; -#if defined( __GMPXX_USE_CXX11 ) || defined( MSC_CXX_11 ) +#if __GMPXX_USE_CXX11 || defined( MSC_CXX_11 ) namespace std { template struct common_type <__gmp_expr, __gmp_expr > @@ -1515,7 +1516,7 @@ public: __gmp_expr() { mpz_init(mp); } __gmp_expr(const __gmp_expr &z) { mpz_init_set(mp, z.mp); } -#if defined(__GMPXX_USE_CXX11) || defined( MSC_CXX_11 ) +#if __GMPXX_USE_CXX11 || defined( MSC_CXX_11 ) __gmp_expr(__gmp_expr &&z) { *mp = *z.mp; mpz_init(z.mp); } #endif @@ -1581,7 +1582,7 @@ public: // assignment operators __gmp_expr & operator=(const __gmp_expr &z) { mpz_set(mp, z.mp); return *this; } -#if defined(__GMPXX_USE_CXX11) || defined( MSC_CXX_11 ) +#if __GMPXX_USE_CXX11 || defined( MSC_CXX_11 ) __gmp_expr & operator=(__gmp_expr &&z) __GMPXX_NOEXCEPT { swap(z); return *this; } #endif @@ -1724,7 +1725,7 @@ public: mpz_init_set(mpq_numref(mp), mpq_numref(q.mp)); mpz_init_set(mpq_denref(mp), mpq_denref(q.mp)); } -#if defined(__GMPXX_USE_CXX11) || defined( MSC_CXX_11 ) +#if __GMPXX_USE_CXX11 || defined( MSC_CXX_11 ) __gmp_expr(__gmp_expr &&q) { *mp = *q.mp; mpq_init(q.mp); } #endif @@ -1803,7 +1804,7 @@ public: // assignment operators __gmp_expr & operator=(const __gmp_expr &q) { mpq_set(mp, q.mp); return *this; } -#if defined(__GMPXX_USE_CXX11) || defined( MSC_CXX_11 ) +#if __GMPXX_USE_CXX11 || defined( MSC_CXX_11 ) __gmp_expr & operator=(__gmp_expr &&q) __GMPXX_NOEXCEPT { swap(q); return *this; } __gmp_expr & operator=(mpz_class &&z)__GMPXX_NOEXCEPT @@ -1933,7 +1934,7 @@ public: __gmp_expr(const __gmp_expr &f) { mpf_init2(mp, f.get_prec()); mpf_set(mp, f.mp); } -#if defined(__GMPXX_USE_CXX11) || defined( MSC_CXX_11 ) +#if __GMPXX_USE_CXX11 || defined( MSC_CXX_11 ) __gmp_expr(__gmp_expr &&f) { *mp = *f.mp; mpf_init2(f.mp, get_prec()); } #endif @@ -2039,7 +2040,7 @@ public: // assignment operators __gmp_expr & operator=(const __gmp_expr &f) { mpf_set(mp, f.mp); return *this; } -#if defined(__GMPXX_USE_CXX11) || defined( MSC_CXX_11 ) +#if __GMPXX_USE_CXX11 || defined( MSC_CXX_11 ) __gmp_expr & operator=(__gmp_expr &&f) __GMPXX_NOEXCEPT { swap(f); return *this; } #endif From 0fef849a42349e1474a155ce1720b06c78bef2ac Mon Sep 17 00:00:00 2001 From: William Hart Date: Thu, 27 Mar 2014 15:45:23 +0000 Subject: [PATCH 2/3] Document mpz/mpq/mpf_class swap functions. --- doc/mpir.info | 138 ++++++++++++++++++++++++------------------------ doc/mpir.info-1 | 6 +++ doc/mpir.info-2 | 30 +++++++---- doc/mpir.texi | 6 +++ 4 files changed, 102 insertions(+), 78 deletions(-) diff --git a/doc/mpir.info b/doc/mpir.info index 56ba6413..8fb8242c 100644 --- a/doc/mpir.info +++ b/doc/mpir.info @@ -25,7 +25,7 @@ END-INFO-DIR-ENTRY  Indirect: mpir.info-1: 1044 -mpir.info-2: 299956 +mpir.info-2: 300280  Tag Table: (Indirect) @@ -105,73 +105,73 @@ Node: C++ Formatted Input215791 Node: C++ Class Interface217699 Node: C++ Interface General218697 Node: C++ Interface Integers221777 -Node: C++ Interface Rationals225163 -Node: C++ Interface Floats228809 -Node: C++ Interface Random Numbers234036 -Node: C++ Interface Limitations236144 -Node: Custom Allocation238990 -Node: Language Bindings243636 -Node: Algorithms247666 -Node: Multiplication Algorithms248371 -Node: Basecase Multiplication249583 -Node: Karatsuba Multiplication251495 -Node: Toom 3-Way Multiplication255125 -Node: Toom 4-Way Multiplication261541 -Node: FFT Multiplication262915 -Node: Other Multiplication268341 -Node: Unbalanced Multiplication271023 -Node: Division Algorithms271919 -Node: Single Limb Division272267 -Node: Basecase Division275187 -Node: Divide and Conquer Division276390 -Node: Exact Division278660 -Node: Exact Remainder281860 -Node: Small Quotient Division284153 -Node: Greatest Common Divisor Algorithms285752 -Node: Binary GCD286044 -Node: Lehmer's GCD288720 -Node: Subquadratic GCD290924 -Node: Extended GCD293378 -Node: Jacobi Symbol293937 -Node: Powering Algorithms294854 -Node: Normal Powering Algorithm295118 -Node: Modular Powering Algorithm295647 -Node: Root Extraction Algorithms296711 -Node: Square Root Algorithm297027 -Node: Nth Root Algorithm299170 -Node: Perfect Square Algorithm299956 -Node: Perfect Power Algorithm302043 -Node: Radix Conversion Algorithms302665 -Node: Binary to Radix303042 -Node: Radix to Binary306973 -Node: Other Algorithms308938 -Node: Prime Testing Algorithm309292 -Node: Factorial Algorithm310519 -Node: Binomial Coefficients Algorithm311956 -Node: Fibonacci Numbers Algorithm312851 -Node: Lucas Numbers Algorithm315327 -Node: Random Number Algorithms316049 -Node: Assembler Coding318173 -Node: Assembler Code Organisation319150 -Node: Assembler Basics320123 -Node: Assembler Carry Propagation321282 -Node: Assembler Cache Handling323120 -Node: Assembler Functional Units325288 -Node: Assembler Floating Point326909 -Node: Assembler SIMD Instructions330692 -Node: Assembler Software Pipelining331681 -Node: Assembler Loop Unrolling332749 -Node: Assembler Writing Guide334969 -Node: Internals337739 -Node: Integer Internals338253 -Node: Rational Internals340510 -Node: Float Internals341750 -Node: Raw Output Internals349078 -Node: C++ Interface Internals350273 -Node: Contributors353560 -Node: References362555 -Node: GNU Free Documentation License370302 -Node: Concept Index395472 -Node: Function Index438211 +Node: C++ Interface Rationals225271 +Node: C++ Interface Floats229025 +Node: C++ Interface Random Numbers234360 +Node: C++ Interface Limitations236468 +Node: Custom Allocation239314 +Node: Language Bindings243960 +Node: Algorithms247990 +Node: Multiplication Algorithms248695 +Node: Basecase Multiplication249907 +Node: Karatsuba Multiplication251819 +Node: Toom 3-Way Multiplication255449 +Node: Toom 4-Way Multiplication261865 +Node: FFT Multiplication263239 +Node: Other Multiplication268665 +Node: Unbalanced Multiplication271347 +Node: Division Algorithms272243 +Node: Single Limb Division272591 +Node: Basecase Division275511 +Node: Divide and Conquer Division276714 +Node: Exact Division278984 +Node: Exact Remainder282184 +Node: Small Quotient Division284477 +Node: Greatest Common Divisor Algorithms286076 +Node: Binary GCD286368 +Node: Lehmer's GCD289044 +Node: Subquadratic GCD291248 +Node: Extended GCD293702 +Node: Jacobi Symbol294261 +Node: Powering Algorithms295178 +Node: Normal Powering Algorithm295442 +Node: Modular Powering Algorithm295971 +Node: Root Extraction Algorithms297035 +Node: Square Root Algorithm297351 +Node: Nth Root Algorithm299494 +Node: Perfect Square Algorithm300280 +Node: Perfect Power Algorithm302367 +Node: Radix Conversion Algorithms302989 +Node: Binary to Radix303366 +Node: Radix to Binary307297 +Node: Other Algorithms309262 +Node: Prime Testing Algorithm309616 +Node: Factorial Algorithm310843 +Node: Binomial Coefficients Algorithm312280 +Node: Fibonacci Numbers Algorithm313175 +Node: Lucas Numbers Algorithm315651 +Node: Random Number Algorithms316373 +Node: Assembler Coding318497 +Node: Assembler Code Organisation319474 +Node: Assembler Basics320447 +Node: Assembler Carry Propagation321606 +Node: Assembler Cache Handling323444 +Node: Assembler Functional Units325612 +Node: Assembler Floating Point327233 +Node: Assembler SIMD Instructions331016 +Node: Assembler Software Pipelining332005 +Node: Assembler Loop Unrolling333073 +Node: Assembler Writing Guide335293 +Node: Internals338063 +Node: Integer Internals338577 +Node: Rational Internals340834 +Node: Float Internals342074 +Node: Raw Output Internals349402 +Node: C++ Interface Internals350597 +Node: Contributors353884 +Node: References362879 +Node: GNU Free Documentation License370626 +Node: Concept Index395796 +Node: Function Index438535  End Tag Table diff --git a/doc/mpir.info-1 b/doc/mpir.info-1 index d3259de7..31c53fff 100644 --- a/doc/mpir.info-1 +++ b/doc/mpir.info-1 @@ -5313,6 +5313,8 @@ File: mpir.info, Node: C++ Interface Integers, Next: C++ Interface Rationals, -- Function: int mpz_class::set_str (const string& STR, int BASE) -- Function: int sgn (mpz_class OP) -- Function: mpz_class sqrt (mpz_class OP) + -- Function: void mpz_class::swap (mpz_class& OP) + -- Function: void swap (mpz_class& OP1, mpz_class& OP2) These functions provide a C++ class interface to the corresponding MPIR C routines. @@ -5381,6 +5383,8 @@ called. -- Function: int mpq_class::set_str (const char *STR, int BASE) -- Function: int mpq_class::set_str (const string& STR, int BASE) -- Function: int sgn (mpq_class OP) + -- Function: void mpq_class::swap (mpq_class& OP) + -- Function: void swap (mpq_class& OP1, mpq_class& OP2) These functions provide a C++ class interface to the corresponding MPIR C routines. @@ -5503,6 +5507,8 @@ used if this doesn't suit. -- Function: int mpf_class::set_str (const string& STR, int BASE) -- Function: int sgn (mpf_class OP) -- Function: mpf_class sqrt (mpf_class OP) + -- Function: void mpf_class::swap (mpf_class& OP) + -- Function: void swap (mpf_class& OP1, mpf_class& OP2) -- Function: mpf_class trunc (mpf_class OP) These functions provide a C++ class interface to the corresponding MPIR C routines. diff --git a/doc/mpir.info-2 b/doc/mpir.info-2 index 7c9ac31c..b2dc771f 100644 --- a/doc/mpir.info-2 +++ b/doc/mpir.info-2 @@ -2909,7 +2909,7 @@ Function and Type Index * mpf_class::get_mpf_t: C++ Interface General. (line 66) * mpf_class::get_prec: C++ Interface Floats. - (line 99) + (line 101) * mpf_class::get_si: C++ Interface Floats. (line 82) * mpf_class::get_str: C++ Interface Floats. @@ -2921,11 +2921,13 @@ Function and Type Index * mpf_class::operator=: C++ Interface Floats. (line 46) * mpf_class::set_prec: C++ Interface Floats. - (line 100) + (line 102) * mpf_class::set_prec_raw: C++ Interface Floats. - (line 101) + (line 103) * mpf_class::set_str: C++ Interface Floats. (line 86) +* mpf_class::swap: C++ Interface Floats. + (line 90) * mpf_clear: Initializing Floats. (line 37) * mpf_clears: Initializing Floats. (line 41) * mpf_cmp: Float Comparison. (line 7) @@ -3073,21 +3075,23 @@ Function and Type Index * mpq_class::get_d: C++ Interface Rationals. (line 46) * mpq_class::get_den: C++ Interface Rationals. - (line 58) + (line 60) * mpq_class::get_den_mpz_t: C++ Interface Rationals. - (line 68) + (line 70) * mpq_class::get_mpq_t: C++ Interface General. (line 65) * mpq_class::get_num: C++ Interface Rationals. - (line 57) + (line 59) * mpq_class::get_num_mpz_t: C++ Interface Rationals. - (line 67) + (line 69) * mpq_class::get_str: C++ Interface Rationals. (line 47) * mpq_class::mpq_class: C++ Interface Rationals. (line 11) * mpq_class::set_str: C++ Interface Rationals. (line 48) +* mpq_class::swap: C++ Interface Rationals. + (line 51) * mpq_clear: Initializing Rationals. (line 16) * mpq_clears: Initializing Rationals. @@ -3196,6 +3200,8 @@ Function and Type Index (line 7) * mpz_class::set_str: C++ Interface Integers. (line 54) +* mpz_class::swap: C++ Interface Integers. + (line 58) * mpz_clear: Initializing Integers. (line 41) * mpz_clears: Initializing Integers. @@ -3423,7 +3429,7 @@ Function and Type Index * operator<<: C++ Formatted Output. (line 11) * operator>> <1>: C++ Interface Rationals. - (line 77) + (line 79) * operator>>: C++ Formatted Input. (line 11) * sgn <1>: C++ Interface Floats. (line 88) @@ -3435,7 +3441,13 @@ Function and Type Index (line 89) * sqrt: C++ Interface Integers. (line 57) +* swap <1>: C++ Interface Floats. + (line 91) +* swap <2>: C++ Interface Rationals. + (line 52) +* swap: C++ Interface Integers. + (line 59) * trunc: C++ Interface Floats. - (line 90) + (line 92) diff --git a/doc/mpir.texi b/doc/mpir.texi index 2cc4857c..81496428 100644 --- a/doc/mpir.texi +++ b/doc/mpir.texi @@ -6382,6 +6382,8 @@ mpz_fdiv_q (q.get_mpz_t(), a.get_mpz_t(), d.get_mpz_t()); @deftypefunx int mpz_class::set_str (const string& @var{str}, int @var{base}) @deftypefunx int sgn (mpz_class @var{op}) @deftypefunx mpz_class sqrt (mpz_class @var{op}) +@deftypefunx void mpz_class::swap (mpz_class& @var{op}) +@deftypefunx void swap (mpz_class& @var{op1}, mpz_class& @var{op2}) These functions provide a C++ class interface to the corresponding MPIR C routines. @@ -6454,6 +6456,8 @@ form, and will return results in canonical form. @deftypefunx int mpq_class::set_str (const char *@var{str}, int @var{base}) @deftypefunx int mpq_class::set_str (const string& @var{str}, int @var{base}) @deftypefunx int sgn (mpq_class @var{op}) +@deftypefunx void mpq_class::swap (mpq_class& @var{op}) +@deftypefunx void swap (mpq_class& @var{op1}, mpq_class& @var{op2}) These functions provide a C++ class interface to the corresponding MPIR C routines. @@ -6586,6 +6590,8 @@ with the builtin float types. @deftypefunx int mpf_class::set_str (const string& @var{str}, int @var{base}) @deftypefunx int sgn (mpf_class @var{op}) @deftypefunx mpf_class sqrt (mpf_class @var{op}) +@deftypefunx void mpf_class::swap (mpf_class& @var{op}) +@deftypefunx void swap (mpf_class& @var{op1}, mpf_class& @var{op2}) @deftypefunx mpf_class trunc (mpf_class @var{op}) These functions provide a C++ class interface to the corresponding MPIR C routines. From 823c649e361758b10b2c943bf28cbd2d91d5d6a2 Mon Sep 17 00:00:00 2001 From: William Hart Date: Thu, 27 Mar 2014 15:48:40 +0000 Subject: [PATCH 3/3] Added docs for operator"" for _mpz, _mpq, _mpf. --- doc/mpir.info | 138 ++++++++++++++++++++++---------------------- doc/mpir.info-1 | 13 +++++ doc/mpir.info-2 | 150 +++++++++++++++++++++++++----------------------- doc/mpir.texi | 16 ++++++ 4 files changed, 176 insertions(+), 141 deletions(-) diff --git a/doc/mpir.info b/doc/mpir.info index 8fb8242c..4d575c61 100644 --- a/doc/mpir.info +++ b/doc/mpir.info @@ -25,7 +25,7 @@ END-INFO-DIR-ENTRY  Indirect: mpir.info-1: 1044 -mpir.info-2: 300280 +mpir.info-2: 300935  Tag Table: (Indirect) @@ -105,73 +105,73 @@ Node: C++ Formatted Input215791 Node: C++ Class Interface217699 Node: C++ Interface General218697 Node: C++ Interface Integers221777 -Node: C++ Interface Rationals225271 -Node: C++ Interface Floats229025 -Node: C++ Interface Random Numbers234360 -Node: C++ Interface Limitations236468 -Node: Custom Allocation239314 -Node: Language Bindings243960 -Node: Algorithms247990 -Node: Multiplication Algorithms248695 -Node: Basecase Multiplication249907 -Node: Karatsuba Multiplication251819 -Node: Toom 3-Way Multiplication255449 -Node: Toom 4-Way Multiplication261865 -Node: FFT Multiplication263239 -Node: Other Multiplication268665 -Node: Unbalanced Multiplication271347 -Node: Division Algorithms272243 -Node: Single Limb Division272591 -Node: Basecase Division275511 -Node: Divide and Conquer Division276714 -Node: Exact Division278984 -Node: Exact Remainder282184 -Node: Small Quotient Division284477 -Node: Greatest Common Divisor Algorithms286076 -Node: Binary GCD286368 -Node: Lehmer's GCD289044 -Node: Subquadratic GCD291248 -Node: Extended GCD293702 -Node: Jacobi Symbol294261 -Node: Powering Algorithms295178 -Node: Normal Powering Algorithm295442 -Node: Modular Powering Algorithm295971 -Node: Root Extraction Algorithms297035 -Node: Square Root Algorithm297351 -Node: Nth Root Algorithm299494 -Node: Perfect Square Algorithm300280 -Node: Perfect Power Algorithm302367 -Node: Radix Conversion Algorithms302989 -Node: Binary to Radix303366 -Node: Radix to Binary307297 -Node: Other Algorithms309262 -Node: Prime Testing Algorithm309616 -Node: Factorial Algorithm310843 -Node: Binomial Coefficients Algorithm312280 -Node: Fibonacci Numbers Algorithm313175 -Node: Lucas Numbers Algorithm315651 -Node: Random Number Algorithms316373 -Node: Assembler Coding318497 -Node: Assembler Code Organisation319474 -Node: Assembler Basics320447 -Node: Assembler Carry Propagation321606 -Node: Assembler Cache Handling323444 -Node: Assembler Functional Units325612 -Node: Assembler Floating Point327233 -Node: Assembler SIMD Instructions331016 -Node: Assembler Software Pipelining332005 -Node: Assembler Loop Unrolling333073 -Node: Assembler Writing Guide335293 -Node: Internals338063 -Node: Integer Internals338577 -Node: Rational Internals340834 -Node: Float Internals342074 -Node: Raw Output Internals349402 -Node: C++ Interface Internals350597 -Node: Contributors353884 -Node: References362879 -Node: GNU Free Documentation License370626 -Node: Concept Index395796 -Node: Function Index438535 +Node: C++ Interface Rationals225459 +Node: C++ Interface Floats229486 +Node: C++ Interface Random Numbers235015 +Node: C++ Interface Limitations237123 +Node: Custom Allocation239969 +Node: Language Bindings244615 +Node: Algorithms248645 +Node: Multiplication Algorithms249350 +Node: Basecase Multiplication250562 +Node: Karatsuba Multiplication252474 +Node: Toom 3-Way Multiplication256104 +Node: Toom 4-Way Multiplication262520 +Node: FFT Multiplication263894 +Node: Other Multiplication269320 +Node: Unbalanced Multiplication272002 +Node: Division Algorithms272898 +Node: Single Limb Division273246 +Node: Basecase Division276166 +Node: Divide and Conquer Division277369 +Node: Exact Division279639 +Node: Exact Remainder282839 +Node: Small Quotient Division285132 +Node: Greatest Common Divisor Algorithms286731 +Node: Binary GCD287023 +Node: Lehmer's GCD289699 +Node: Subquadratic GCD291903 +Node: Extended GCD294357 +Node: Jacobi Symbol294916 +Node: Powering Algorithms295833 +Node: Normal Powering Algorithm296097 +Node: Modular Powering Algorithm296626 +Node: Root Extraction Algorithms297690 +Node: Square Root Algorithm298006 +Node: Nth Root Algorithm300149 +Node: Perfect Square Algorithm300935 +Node: Perfect Power Algorithm303022 +Node: Radix Conversion Algorithms303644 +Node: Binary to Radix304021 +Node: Radix to Binary307952 +Node: Other Algorithms309917 +Node: Prime Testing Algorithm310271 +Node: Factorial Algorithm311498 +Node: Binomial Coefficients Algorithm312935 +Node: Fibonacci Numbers Algorithm313830 +Node: Lucas Numbers Algorithm316306 +Node: Random Number Algorithms317028 +Node: Assembler Coding319152 +Node: Assembler Code Organisation320129 +Node: Assembler Basics321102 +Node: Assembler Carry Propagation322261 +Node: Assembler Cache Handling324099 +Node: Assembler Functional Units326267 +Node: Assembler Floating Point327888 +Node: Assembler SIMD Instructions331671 +Node: Assembler Software Pipelining332660 +Node: Assembler Loop Unrolling333728 +Node: Assembler Writing Guide335948 +Node: Internals338718 +Node: Integer Internals339232 +Node: Rational Internals341489 +Node: Float Internals342729 +Node: Raw Output Internals350057 +Node: C++ Interface Internals351252 +Node: Contributors354539 +Node: References363534 +Node: GNU Free Documentation License371281 +Node: Concept Index396451 +Node: Function Index439190  End Tag Table diff --git a/doc/mpir.info-1 b/doc/mpir.info-1 index 31c53fff..627281f8 100644 --- a/doc/mpir.info-1 +++ b/doc/mpir.info-1 @@ -5283,6 +5283,10 @@ File: mpir.info, Node: C++ Interface Integers, Next: C++ Interface Rationals, If the string is not a valid integer, an `std::invalid_argument' exception is thrown. The same applies to `operator='. + -- Function: mpz_class operator"" _mpz (const char *STR) + With C++11 compilers, integers can be constructed with the syntax + `123_mpz' which is equivalent to `mpz_class("123")'. + -- Function: mpz_class operator/ (mpz_class A, mpz_class D) -- Function: mpz_class operator% (mpz_class A, mpz_class D) Divisions involving `mpz_class' round towards zero, as per the @@ -5369,6 +5373,11 @@ called. If the string is not a valid rational, an `std::invalid_argument' exception is thrown. The same applies to `operator='. + -- Function: mpq_class operator"" _mpq (const char *STR) + With C++11 compilers, integral rationals can be constructed with + the syntax `123_mpq' which is equivalent to `mpq_class(123_mpz)'. + Other rationals can be built as `-1_mpq/2' or `0xb_mpq/123456_mpz'. + -- Function: void mpq_class::canonicalize () Put an `mpq_class' into canonical form, as per *note Rational Number Functions::. All arithmetic operators require their @@ -5463,6 +5472,10 @@ used if this doesn't suit. If the string is not a valid float, an `std::invalid_argument' exception is thrown. The same applies to `operator='. + -- Function: mpf_class operator"" _mpf (const char *STR) + With C++11 compilers, floats can be constructed with the syntax + `1.23e-1_mpf' which is equivalent to `mpf_class("1.23e-1")'. + -- Function: mpf_class& mpf_class::operator= (type OP) Convert and store the given OP value to an `mpf_class' object. The same types are accepted as for the constructors above. diff --git a/doc/mpir.info-2 b/doc/mpir.info-2 index b2dc771f..df817965 100644 --- a/doc/mpir.info-2 +++ b/doc/mpir.info-2 @@ -2777,21 +2777,21 @@ Function and Type Index * _mpz_realloc: Integer Special Functions. (line 54) * abs <1>: C++ Interface Floats. - (line 69) + (line 73) * abs <2>: C++ Interface Rationals. - (line 43) + (line 48) * abs: C++ Interface Integers. - (line 41) + (line 45) * ceil: C++ Interface Floats. - (line 70) + (line 74) * cmp <1>: C++ Interface Floats. - (line 71) + (line 75) * cmp <2>: C++ Interface Rationals. - (line 44) + (line 49) * cmp: C++ Interface Integers. - (line 42) + (line 46) * floor: C++ Interface Floats. - (line 79) + (line 83) * gmp_asprintf: Formatted Output Functions. (line 65) * gmp_fprintf: Formatted Output Functions. @@ -2871,7 +2871,7 @@ Function and Type Index * gmp_vsscanf: Formatted Input Functions. (line 31) * hypot: C++ Interface Floats. - (line 80) + (line 84) * long: MPIR on Windows x64. (line 28) * mp_bitcnt_t: Nomenclature and Types. (line 41) @@ -2893,41 +2893,41 @@ Function and Type Index * mpf_class: C++ Interface General. (line 20) * mpf_class::fits_sint_p: C++ Interface Floats. - (line 73) -* mpf_class::fits_slong_p: C++ Interface Floats. - (line 74) -* mpf_class::fits_sshort_p: C++ Interface Floats. - (line 75) -* mpf_class::fits_uint_p: C++ Interface Floats. - (line 76) -* mpf_class::fits_ulong_p: C++ Interface Floats. (line 77) -* mpf_class::fits_ushort_p: C++ Interface Floats. +* mpf_class::fits_slong_p: C++ Interface Floats. (line 78) -* mpf_class::get_d: C++ Interface Floats. +* mpf_class::fits_sshort_p: C++ Interface Floats. + (line 79) +* mpf_class::fits_uint_p: C++ Interface Floats. + (line 80) +* mpf_class::fits_ulong_p: C++ Interface Floats. (line 81) +* mpf_class::fits_ushort_p: C++ Interface Floats. + (line 82) +* mpf_class::get_d: C++ Interface Floats. + (line 85) * mpf_class::get_mpf_t: C++ Interface General. (line 66) * mpf_class::get_prec: C++ Interface Floats. - (line 101) + (line 105) * mpf_class::get_si: C++ Interface Floats. - (line 82) + (line 86) * mpf_class::get_str: C++ Interface Floats. - (line 84) + (line 88) * mpf_class::get_ui: C++ Interface Floats. - (line 85) + (line 89) * mpf_class::mpf_class: C++ Interface Floats. (line 12) * mpf_class::operator=: C++ Interface Floats. - (line 46) + (line 50) * mpf_class::set_prec: C++ Interface Floats. - (line 102) + (line 106) * mpf_class::set_prec_raw: C++ Interface Floats. - (line 103) + (line 107) * mpf_class::set_str: C++ Interface Floats. - (line 86) -* mpf_class::swap: C++ Interface Floats. (line 90) +* mpf_class::swap: C++ Interface Floats. + (line 94) * mpf_clear: Initializing Floats. (line 37) * mpf_clears: Initializing Floats. (line 41) * mpf_cmp: Float Comparison. (line 7) @@ -3071,27 +3071,27 @@ Function and Type Index * mpq_class: C++ Interface General. (line 19) * mpq_class::canonicalize: C++ Interface Rationals. - (line 37) + (line 42) * mpq_class::get_d: C++ Interface Rationals. - (line 46) + (line 51) * mpq_class::get_den: C++ Interface Rationals. - (line 60) + (line 65) * mpq_class::get_den_mpz_t: C++ Interface Rationals. - (line 70) + (line 75) * mpq_class::get_mpq_t: C++ Interface General. (line 65) * mpq_class::get_num: C++ Interface Rationals. - (line 59) + (line 64) * mpq_class::get_num_mpz_t: C++ Interface Rationals. - (line 69) + (line 74) * mpq_class::get_str: C++ Interface Rationals. - (line 47) + (line 52) * mpq_class::mpq_class: C++ Interface Rationals. (line 11) * mpq_class::set_str: C++ Interface Rationals. - (line 48) + (line 53) * mpq_class::swap: C++ Interface Rationals. - (line 51) + (line 56) * mpq_clear: Initializing Rationals. (line 16) * mpq_clears: Initializing Rationals. @@ -3175,33 +3175,33 @@ Function and Type Index * mpz_class: C++ Interface General. (line 18) * mpz_class::fits_sint_p: C++ Interface Integers. - (line 44) -* mpz_class::fits_slong_p: C++ Interface Integers. - (line 45) -* mpz_class::fits_sshort_p: C++ Interface Integers. - (line 46) -* mpz_class::fits_uint_p: C++ Interface Integers. - (line 47) -* mpz_class::fits_ulong_p: C++ Interface Integers. (line 48) -* mpz_class::fits_ushort_p: C++ Interface Integers. +* mpz_class::fits_slong_p: C++ Interface Integers. (line 49) -* mpz_class::get_d: C++ Interface Integers. +* mpz_class::fits_sshort_p: C++ Interface Integers. (line 50) +* mpz_class::fits_uint_p: C++ Interface Integers. + (line 51) +* mpz_class::fits_ulong_p: C++ Interface Integers. + (line 52) +* mpz_class::fits_ushort_p: C++ Interface Integers. + (line 53) +* mpz_class::get_d: C++ Interface Integers. + (line 54) * mpz_class::get_mpz_t: C++ Interface General. (line 64) * mpz_class::get_si: C++ Interface Integers. - (line 51) + (line 55) * mpz_class::get_str: C++ Interface Integers. - (line 52) + (line 56) * mpz_class::get_ui: C++ Interface Integers. - (line 53) + (line 57) * mpz_class::mpz_class: C++ Interface Integers. (line 7) * mpz_class::set_str: C++ Interface Integers. - (line 54) -* mpz_class::swap: C++ Interface Integers. (line 58) +* mpz_class::swap: C++ Interface Integers. + (line 62) * mpz_clear: Initializing Integers. (line 41) * mpz_clears: Initializing Integers. @@ -3422,32 +3422,38 @@ Function and Type Index (line 23) * mpz_xor: Integer Logic and Bit Fiddling. (line 17) -* operator%: C++ Interface Integers. - (line 29) -* operator/: C++ Interface Integers. +* operator"" <1>: C++ Interface Floats. + (line 46) +* operator"" <2>: C++ Interface Rationals. + (line 37) +* operator"": C++ Interface Integers. (line 28) +* operator%: C++ Interface Integers. + (line 33) +* operator/: C++ Interface Integers. + (line 32) * operator<<: C++ Formatted Output. (line 11) * operator>> <1>: C++ Interface Rationals. - (line 79) + (line 84) * operator>>: C++ Formatted Input. (line 11) * sgn <1>: C++ Interface Floats. - (line 88) -* sgn <2>: C++ Interface Rationals. - (line 50) -* sgn: C++ Interface Integers. - (line 56) -* sqrt <1>: C++ Interface Floats. - (line 89) -* sqrt: C++ Interface Integers. - (line 57) -* swap <1>: C++ Interface Floats. - (line 91) -* swap <2>: C++ Interface Rationals. - (line 52) -* swap: C++ Interface Integers. - (line 59) -* trunc: C++ Interface Floats. (line 92) +* sgn <2>: C++ Interface Rationals. + (line 55) +* sgn: C++ Interface Integers. + (line 60) +* sqrt <1>: C++ Interface Floats. + (line 93) +* sqrt: C++ Interface Integers. + (line 61) +* swap <1>: C++ Interface Floats. + (line 95) +* swap <2>: C++ Interface Rationals. + (line 57) +* swap: C++ Interface Integers. + (line 63) +* trunc: C++ Interface Floats. + (line 96) diff --git a/doc/mpir.texi b/doc/mpir.texi index 81496428..892c7b06 100644 --- a/doc/mpir.texi +++ b/doc/mpir.texi @@ -6345,6 +6345,11 @@ If the string is not a valid integer, an @code{std::invalid_argument} exception is thrown. The same applies to @code{operator=}. @end deftypefun +@deftypefun mpz_class operator"" _mpz (const char *@var{str}) +With C++11 compilers, integers can be constructed with the syntax +@code{123_mpz} which is equivalent to @code{mpz_class("123")}. +@end deftypefun + @deftypefun mpz_class operator/ (mpz_class @var{a}, mpz_class @var{d}) @deftypefunx mpz_class operator% (mpz_class @var{a}, mpz_class @var{d}) Divisions involving @code{mpz_class} round towards zero, as per the @@ -6440,6 +6445,12 @@ If the string is not a valid rational, an @code{std::invalid_argument} exception is thrown. The same applies to @code{operator=}. @end deftypefun +@deftypefun mpq_class operator"" _mpq (const char *@var{str}) +With C++11 compilers, integral rationals can be constructed with the syntax +@code{123_mpq} which is equivalent to @code{mpq_class(123_mpz)}. Other +rationals can be built as @code{-1_mpq/2} or @code{0xb_mpq/123456_mpz}. +@end deftypefun + @deftypefun void mpq_class::canonicalize () Put an @code{mpq_class} into canonical form, as per @ref{Rational Number Functions}. All arithmetic operators require their operands in canonical @@ -6540,6 +6551,11 @@ If the string is not a valid float, an @code{std::invalid_argument} exception is thrown. The same applies to @code{operator=}. @end deftypefun +@deftypefun mpf_class operator"" _mpf (const char *@var{str}) +With C++11 compilers, floats can be constructed with the syntax +@code{1.23e-1_mpf} which is equivalent to @code{mpf_class("1.23e-1")}. +@end deftypefun + @deftypefun {mpf_class&} mpf_class::operator= (type @var{op}) Convert and store the given @var{op} value to an @code{mpf_class} object. The same types are accepted as for the constructors above.