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 @@ + + + + + + + + +Frequently Asked Questions about MPFR + + + + + +

Frequently Asked Questions about MPFR

+ +

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.

+ +
    +
  1. What are the differences between +MPF from GMP +and MPFR?
  2. +
  3. How to convert my program written using +MPF to +MPFR?
  4. +
  5. I get undefined reference to __gmp_get_memory_functions.
  6. +
  7. When I link my program with +MPFR, I get undefined reference +to __gmpXXXX.
  8. +
  9. My program crashes with high precisions.
  10. +
  11. Though I have increased the precision, the results +are not more accurate.
  12. +
  13. How can I detect MPFR +installation using autoconf or pkg-config?
  14. +
  15. How to cite MPFR in a +scientific publication?
  16. +
+ +
+ +
1. What are the differences between +MPF from GMP +and MPFR?
+ +

The main differences are:

+
+ +
2. How to convert my program written using +MPF to +MPFR?
+ +

You need to add r to the function names, and to +specify the rounding mode (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.

+ +
3. I get undefined reference to __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.

+ +
4. When I link my program with +MPFR, I get undefined reference +to __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.

+ +
5. My program crashes with high precisions.
+ +

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:

+
+ +
6. Though I have increased the precision, the results +are not more accurate.
+ +

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.

+ +
7. How can I detect MPFR +installation using autoconf or pkg-config?
+ +

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.

+ +
8. How to cite MPFR in a +scientific publication?
+ +

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.

+ +
+ + + +