X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=mpfr%2FFAQ.html;fp=mpfr%2FFAQ.html;h=dea99502bbded12bbb14cfc830ac73072a8b8fea;hb=6fed43773c9b0ce596dca5686f37ac3fc0fa11c0;hp=0000000000000000000000000000000000000000;hpb=27b11d56b743098deb193d510b337ba22dc52e5c;p=msp430-gcc.git diff --git a/mpfr/FAQ.html b/mpfr/FAQ.html new file mode 100644 index 00000000..dea99502 --- /dev/null +++ b/mpfr/FAQ.html @@ -0,0 +1,317 @@ + + + + + + + +
+Important notice: Problems with a particular version of +MPFR are discussed in the corresponding +bugs page.
+ +The latest version of this FAQ is available at +http://www.mpfr.org/faq.html. +Please look at this version if possible.
+ +__gmp_get_memory_functions
.__gmpXXXX
.The main differences are:
+The precision of a MPFR variable +is the exact number of bits used for its mantissa, whereas in +MPF, the precision requested by the user +is a minimum value (MPF generally uses a +higher precision). With the additional difference below, this implies that +the MPFR results do not depend on the +number of bits (16, 32, 64 or more) of the underlying architecture.
As a consequence, MPFR uses a +base-2 exponent, whereas in MPF, this +is a base-232 or base-264 exponent, depending on +the limb size. For this reason (and other internal ones), the maximum +exponent range in MPFR is different +(and smaller, if the exponent is represented by the same type as in +MPF).
MPFR provides an additional rounding +mode argument to its functions; furthermore, it is guaranteed that the +result of any operation is the nearest possible floating-point value from +the exact result (considering the input variables as exact values), taking +into account the precision of the destination variable and the rounding +mode. MPFR also says whether the rounded +result is above or below the exact result.
MPFR supports much more functions +(in particular transcendental functions such as exponentials, logarithms, +trigonometric functions and so on) and special values: signed zeros, +infinities, not-a-number (NaN).
You need to add
to the function names, and to
+specify the rounding mode (r
GMP_RNDN
for rounding to nearest,
+GMP_RNDZ
for rounding towards zero, GMP_RNDU
+for rounding towards plus infinity, GMP_RNDD
for rounding
+towards minus infinity). You can also define macros as follows:
+#define mpf_add(a, b, c) mpfr_add(a, b, c, GMP_RNDN)
The header file mpf2mpfr.h from the
+MPFR distribution automatically
+redefines all MPF functions in this
+way, using the default MPFR rounding
+mode. Thus you simply need to add the following line in all your files
+using MPF functions:
+#include <mpf2mpfr.h>
+just after the gmp.h and mpfr.h
+header files. If the program uses MPF
+internals (such as direct access to __mpf_struct
members),
+additional changes will be needed.
__gmp_get_memory_functions
.If you get such an error, in particular when running +make check, then this probably means that you are using +the header file from GMP 4.2.x but the +GMP 4.1.4 library. This can happen if +several GMP versions are installed on +your machine (e.g., one provided by the system in +/usr/{include,lib} and a new one installed by the owner or +administrator of the machine in /usr/local/{include,lib}) +and your include and library search paths are inconsistent. On various +GNU/Linux machines, this is unfortunately the case +by default (/usr/local/include is in the default include +search path, but /usr/local/lib is not in the +default library search path). Typical errors are: +undefined reference to `__gmp_get_memory_functions' +in make check. The best solution is to add +/usr/local/include to your C_INCLUDE_PATH +environment variable and to add /usr/local/lib to your +LIBRARY_PATH and LD_LIBRARY_PATH +environment variables (and/or LD_RUN_PATH). +Alternatively, you can use --with-gmp* configure options, +e.g. --with-gmp=/usr/local, but this is +not guaranteed to work (in particular with gcc and +system directories such as /usr or /usr/local), +and other software that uses GMP and/or +MPFR will need correct paths too; +environment variables allow you to set them in a global way.
+Other information can be given in the INSTALL file and +ld manual. Please look at them for more details. See also +the next question.
__gmpXXXX
.Link your program with GMP. Assuming +that your program is foo.c, you should link it using: +cc link.c -lmpfr -lgmp +MPFR library reference (-lmpfr) +should be before GMP's one +(-lgmp). Another solution is, with GNU +ld, to give all the libraries inside a group: +gcc link.c -Wl,--start-group libgmp.a libmpfr.a -Wl,--end-group +See INSTALL file and ld manual for more +details.
+If you used correct link options, but still get an error, this may mean +that your include and library search paths are inconsistent. Please see the +previous question.
Your stack size limit may be too small; indeed, by default, +GMP 4.1.4 and below allocates all +temporary results on the stack, and in very high precisions, this +limit may be reached. You can solve this problem in different ways:
+You can upgrade to GMP 4.2 (or above), +which now makes temporary allocations on the stack only when they are +small.
You can increase the stack size limit with the limit, +unlimit or ulimit command, depending on your +shell. This may fail on some systems, where the maximum stack size cannot +be increased above some value.
You can rebuild both GMP and +MPFR to use another allocation method.
The reason may be the use of C floating-point numbers. If you want
+to store a floating-point constant to a mpfr_t
, you should use
+mpfr_set_str
(or one of the MPFR
+constant functions, such as mpfr_const_pi
for π) instead
+of mpfr_set_d
or mpfr_set_ld
. Otherwise the
+floating-point constant will be first converted into a reduced-precision
+(e.g., 53-bit) binary number before
+MPFR can work with it. This is the case
+in particular for most exact decimal numbers, such as 0.17, which are
+not exactly representable in binary.
Also remember that MPFR does not track
+the accuracy of the results: copying a value x to y
+with mpfr_set (y, x, GMP_RNDN)
where the variable y
+is more precise than the variable x will not make it more
+accurate; the (binary) value will remain unchanged.
The MPFR team does not currently +recommend any autoconf code, but a section will later +be added to the MPFR manual. The +MPFR team does not wish to support +pkg-config yet.
To properly cite MPFR in a scientific +publication, please cite the +ACM +TOMS +paper +(BibTeX) +and/or the library web page +http://www.mpfr.org. If your publication +is related to a particular release of MPFR, +for example if you report timings, please also indicate the release number +for future reference.