Expand description
Function and type bindings for the MPFR library.
§Examples
use core::mem::MaybeUninit;
use gmp_mpfr_sys::mpfr;
let one_third = 1.0_f64 / 3.0;
unsafe {
let mut f = {
let mut f = MaybeUninit::uninit();
mpfr::init2(f.as_mut_ptr(), 53);
f.assume_init()
};
let dir = mpfr::set_d(&mut f, one_third, mpfr::rnd_t::RNDN);
assert_eq!(dir, 0);
let d = mpfr::get_d(&f, mpfr::rnd_t::RNDN);
assert_eq!(d, one_third);
mpfr::clear(&mut f);
}
The following example is a translation of the MPFR sample found on the MPFR website. The program computes a lower bound on 1 + 1/1! + 1/2! + … + 1/100! using 200-bit precision. The program outputs:
Sum is 2.7182818284590452353602874713526624977572470936999595749669131e0
use core::ffi::c_int;
use core::mem::MaybeUninit;
use gmp_mpfr_sys::mpfr;
use gmp_mpfr_sys::mpfr::rnd_t;
use libc::STDOUT_FILENO;
fn main() {
unsafe {
let mut t = {
let mut t = MaybeUninit::uninit();
mpfr::init2(t.as_mut_ptr(), 200);
t.assume_init()
};
mpfr::set_d(&mut t, 1.0, rnd_t::RNDD);
let mut s = {
let mut s = MaybeUninit::uninit();
mpfr::init2(s.as_mut_ptr(), 200);
s.assume_init()
};
mpfr::set_d(&mut s, 1.0, rnd_t::RNDD);
let mut u = {
let mut u = MaybeUninit::uninit();
mpfr::init2(u.as_mut_ptr(), 200);
u.assume_init()
};
for i in 1..=100 {
mpfr::mul_ui(&mut t, &t, i, rnd_t::RNDU);
mpfr::set_d(&mut u, 1.0, rnd_t::RNDD);
mpfr::div(&mut u, &u, &t, rnd_t::RNDD);
mpfr::add(&mut s, &s, &u, rnd_t::RNDD);
}
let stdout = libc::fdopen(STDOUT_FILENO, b"w\0".as_ptr().cast());
libc::fputs(b"Sum is \0".as_ptr().cast(), stdout);
mpfr::out_str(stdout, 10, 0, &s, rnd_t::RNDD);
libc::fputc(b'\n' as c_int, stdout);
libc::fclose(stdout);
mpfr::clear(&mut s);
mpfr::clear(&mut t);
mpfr::clear(&mut u);
mpfr::free_cache();
}
}
Structs§
Enums§
- rnd_t
- See:
mpfr_rnd_t
Constants§
- FREE_
GLOBAL_ CACHE - See:
mpfr_free_cache2
- FREE_
LOCAL_ CACHE - See:
mpfr_free_cache2
- INF_
KIND - See:
mpfr_custom_init_set
- NAN_
KIND - See:
mpfr_custom_init_set
- PREC_
MAX - See: Nomenclature and Types
- PREC_
MIN - See: Nomenclature and Types
- REGULAR_
KIND - See:
mpfr_custom_init_set
- VERSION
- See:
MPFR_VERSION
- VERSION_
MAJOR - See:
MPFR_VERSION_MAJOR
- VERSION_
MINOR - See:
MPFR_VERSION_MINOR
- VERSION_
PATCHLEVEL - See:
MPFR_VERSION_PATCHLEVEL
- VERSION_
STRING - See:
MPFR_VERSION_STRING
- ZERO_
KIND - See:
mpfr_custom_init_set
Functions§
- VERSION_
NUM - See:
MPFR_VERSION_NUM
- abs⚠
- See:
mpfr_abs
- acos⚠
- See:
mpfr_acos
- acosh⚠
- See:
mpfr_acosh
- acospi⚠
- See:
mpfr_acospi
- acosu⚠
- See:
mpfr_acosu
- add⚠
- See:
mpfr_add
- add_d⚠
- See:
mpfr_add_d
- add_q⚠
- See:
mpfr_add_q
- add_si⚠
- See:
mpfr_add_si
- add_ui⚠
- See:
mpfr_add_ui
- add_z⚠
- See:
mpfr_add_z
- agm⚠
- See:
mpfr_agm
- ai⚠
- See:
mpfr_ai
- asin⚠
- See:
mpfr_asin
- asinh⚠
- See:
mpfr_asinh
- asinpi⚠
- See:
mpfr_asinpi
- asinu⚠
- See:
mpfr_asinu
- asprintf⚠
- See:
mpfr_asprintf
- atan⚠
- See:
mpfr_atan
- atan2⚠
- See:
mpfr_atan2
- atan2pi⚠
- See:
mpfr_atan2pi
- atan2u⚠
- See:
mpfr_atan2u
- atanh⚠
- See:
mpfr_atanh
- atanpi⚠
- See:
mpfr_atanpi
- atanu⚠
- See:
mpfr_atanu
- beta⚠
- See:
mpfr_beta
- buildopt_
decimal_ ⚠p - See:
mpfr_buildopt_decimal_p
- buildopt_
float128_ ⚠p - See:
mpfr_buildopt_float128_p
- buildopt_
gmpinternals_ ⚠p - See:
mpfr_buildopt_gmpinternals_p
- buildopt_
sharedcache_ ⚠p - See:
mpfr_buildopt_sharedcache_p
- buildopt_
tls_ ⚠p - See:
mpfr_buildopt_tls_p
- buildopt_
tune_ ⚠case - See:
mpfr_buildopt_tune_case
- can_
round ⚠ - See:
mpfr_can_round
- cbrt⚠
- See:
mpfr_cbrt
- ceil⚠
- See:
mpfr_ceil
- check_
range ⚠ - See:
mpfr_check_range
- clear⚠
- See:
mpfr_clear
- clear_
divby0 ⚠ - See:
mpfr_clear_divby0
- clear_
erangeflag ⚠ - See:
mpfr_clear_erangeflag
- clear_
flags ⚠ - See:
mpfr_clear_flags
- clear_
inexflag ⚠ - See:
mpfr_clear_inexflag
- clear_
nanflag ⚠ - See:
mpfr_clear_nanflag
- clear_
overflow ⚠ - See:
mpfr_clear_overflow
- clear_
underflow ⚠ - See:
mpfr_clear_underflow
- clears⚠
- See:
mpfr_clears
- cmp⚠
- See:
mpfr_cmp
- cmp_d⚠
- See:
mpfr_cmp_d
- cmp_f⚠
- See:
mpfr_cmp_f
- cmp_q⚠
- See:
mpfr_cmp_q
- cmp_si⚠
- See:
mpfr_cmp_si
- cmp_
si_ ⚠2exp - See:
mpfr_cmp_si_2exp
- cmp_ui⚠
- See:
mpfr_cmp_ui
- cmp_
ui_ ⚠2exp - See:
mpfr_cmp_ui_2exp
- cmp_z⚠
- See:
mpfr_cmp_z
- cmpabs⚠
- See:
mpfr_cmpabs
- cmpabs_
ui ⚠ - See:
mpfr_cmpabs_ui
- compound_
si ⚠ - See:
mpfr_compound_si
- const_
catalan ⚠ - See:
mpfr_const_catalan
- const_
euler ⚠ - See:
mpfr_const_euler
- const_
log2 ⚠ - See:
mpfr_const_log2
- const_
pi ⚠ - See:
mpfr_const_pi
- copysign⚠
- See:
mpfr_copysign
- cos⚠
- See:
mpfr_cos
- cosh⚠
- See:
mpfr_cosh
- cospi⚠
- See:
mpfr_cospi
- cosu⚠
- See:
mpfr_cosu
- cot⚠
- See:
mpfr_cot
- coth⚠
- See:
mpfr_coth
- csc⚠
- See:
mpfr_csc
- csch⚠
- See:
mpfr_csch
- custom_
get_ ⚠exp - See:
mpfr_custom_get_exp
- custom_
get_ ⚠kind - See:
mpfr_custom_get_kind
- custom_
get_ ⚠significand - See:
mpfr_custom_get_significand
- custom_
get_ ⚠size - See:
mpfr_custom_get_size
- custom_
init ⚠ - See:
mpfr_custom_init
- custom_
init_ ⚠set - See:
mpfr_custom_init_set
- custom_
move ⚠ - See:
mpfr_custom_move
- d_div⚠
- See:
mpfr_d_div
- d_sub⚠
- See:
mpfr_d_sub
- digamma⚠
- See:
mpfr_digamma
- dim⚠
- See:
mpfr_dim
- div⚠
- See:
mpfr_div
- div_
2exp ⚠ - See:
mpfr_div_2exp
- div_2si⚠
- See:
mpfr_div_2si
- div_2ui⚠
- See:
mpfr_div_2ui
- div_d⚠
- See:
mpfr_div_d
- div_q⚠
- See:
mpfr_div_q
- div_si⚠
- See:
mpfr_div_si
- div_ui⚠
- See:
mpfr_div_ui
- div_z⚠
- See:
mpfr_div_z
- divby0_
p ⚠ - See:
mpfr_divby0_p
- dot⚠
- See:
mpfr_dot
- dump⚠
- See:
mpfr_dump
- eint⚠
- See:
mpfr_eint
- eq⚠
- See:
mpfr_eq
- equal_p⚠
- See:
mpfr_equal_p
- erandom⚠
- See:
mpfr_erandom
- erangeflag_
p ⚠ - See:
mpfr_erangeflag_p
- erf⚠
- See:
mpfr_erf
- erfc⚠
- See:
mpfr_erfc
- exp⚠
- See:
mpfr_exp
- exp2⚠
- See:
mpfr_exp2
- exp2m1⚠
- See:
mpfr_exp2m1
- exp10⚠
- See:
mpfr_exp10
- exp10m1⚠
- See:
mpfr_exp10m1
- expm1⚠
- See:
mpfr_expm1
- fac_ui⚠
- See:
mpfr_fac_ui
- fits_
intmax_ ⚠p - See:
mpfr_fits_intmax_p
- fits_
sint_ ⚠p - See:
mpfr_fits_sint_p
- fits_
slong_ ⚠p - See:
mpfr_fits_slong_p
- fits_
sshort_ ⚠p - See:
mpfr_fits_sshort_p
- fits_
uint_ ⚠p - See:
mpfr_fits_uint_p
- fits_
uintmax_ ⚠p - See:
mpfr_fits_uintmax_p
- fits_
ulong_ ⚠p - See:
mpfr_fits_ulong_p
- fits_
ushort_ ⚠p - See:
mpfr_fits_ushort_p
- flags_
clear ⚠ - See:
mpfr_flags_clear
- flags_
restore ⚠ - See:
mpfr_flags_restore
- flags_
save ⚠ - See:
mpfr_flags_save
- flags_
set ⚠ - See:
mpfr_flags_set
- flags_
test ⚠ - See:
mpfr_flags_test
- floor⚠
- See:
mpfr_floor
- fma⚠
- See:
mpfr_fma
- fmma⚠
- See:
mpfr_fmma
- fmms⚠
- See:
mpfr_fmms
- fmod⚠
- See:
mpfr_fmod
- fmod_ui⚠
- See:
mpfr_fmod_ui
- fmodquo⚠
- See:
mpfr_fmodquo
- fms⚠
- See:
mpfr_fms
- fpif_
export ⚠ - See:
mpfr_fpif_export
- fpif_
import ⚠ - See:
mpfr_fpif_import
- fprintf⚠
- See:
mpfr_fprintf
- frac⚠
- See:
mpfr_frac
- free_
cache ⚠ - See:
mpfr_free_cache
- free_
cache2 ⚠ - See:
mpfr_free_cache2
- free_
pool ⚠ - See:
mpfr_free_pool
- free_
str ⚠ - See:
mpfr_free_str
- frexp⚠
- See:
mpfr_frexp
- gamma⚠
- See:
mpfr_gamma
- gamma_
inc ⚠ - See:
mpfr_gamma_inc
- get_d⚠
- See:
mpfr_get_d
- get_
d_ ⚠2exp - See:
mpfr_get_d_2exp
- get_
default_ ⚠prec - See:
mpfr_get_default_prec
- get_
default_ ⚠rounding_ mode - See:
mpfr_get_default_rounding_mode
- get_
emax ⚠ - See:
mpfr_get_emax
- get_
emax_ ⚠max - See:
mpfr_get_emax_max
- get_
emax_ ⚠min - See:
mpfr_get_emax_min
- get_
emin ⚠ - See:
mpfr_get_emin
- get_
emin_ ⚠max - See:
mpfr_get_emin_max
- get_
emin_ ⚠min - See:
mpfr_get_emin_min
- get_exp⚠
- See:
mpfr_get_exp
- get_f⚠
- See:
mpfr_get_f
- get_flt⚠
- See:
mpfr_get_flt
- get_
patches ⚠ - See:
mpfr_get_patches
- get_
prec ⚠ - See:
mpfr_get_prec
- get_q⚠
- See:
mpfr_get_q
- get_si⚠
- See:
mpfr_get_si
- get_sj⚠
- See:
mpfr_get_sj
- get_str⚠
- See:
mpfr_get_str
- get_
str_ ⚠ndigits - See:
mpfr_get_str_ndigits
- get_ui⚠
- See:
mpfr_get_ui
- get_uj⚠
- See:
mpfr_get_uj
- get_
version ⚠ - See:
mpfr_get_version
- get_z⚠
- See:
mpfr_get_z
- get_
z_ ⚠2exp - See:
mpfr_get_z_2exp
- grandom⚠
Deprecated - See:
mpfr_grandom
- greater_
p ⚠ - See:
mpfr_greater_p
- greaterequal_
p ⚠ - See:
mpfr_greaterequal_p
- hypot⚠
- See:
mpfr_hypot
- inexflag_
p ⚠ - See:
mpfr_inexflag_p
- inf_p⚠
- See:
mpfr_inf_p
- init⚠
- See:
mpfr_init
- init2⚠
- See:
mpfr_init2
- init_
set ⚠ - See:
mpfr_init_set
- init_
set_ ⚠d - See:
mpfr_init_set_d
- init_
set_ ⚠f - See:
mpfr_init_set_f
- init_
set_ ⚠q - See:
mpfr_init_set_q
- init_
set_ ⚠si - See:
mpfr_init_set_si
- init_
set_ ⚠str - See:
mpfr_init_set_str
- init_
set_ ⚠ui - See:
mpfr_init_set_ui
- init_
set_ ⚠z - See:
mpfr_init_set_z
- inits⚠
- See:
mpfr_inits
- inits2⚠
- See:
mpfr_inits2
- inp_str⚠
- See:
mpfr_inp_str
- integer_
p ⚠ - See:
mpfr_integer_p
- j0⚠
- See:
mpfr_j0
- j1⚠
- See:
mpfr_j1
- jn⚠
- See:
mpfr_jn
- less_p⚠
- See:
mpfr_less_p
- lessequal_
p ⚠ - See:
mpfr_lessequal_p
- lessgreater_
p ⚠ - See:
mpfr_lessgreater_p
- lgamma⚠
- See:
mpfr_lgamma
- li2⚠
- See:
mpfr_li2
- lngamma⚠
- See:
mpfr_lngamma
- log⚠
- See:
mpfr_log
- log2⚠
- See:
mpfr_log2
- log1p⚠
- See:
mpfr_log1p
- log2p1⚠
- See:
mpfr_log2p1
- log10⚠
- See:
mpfr_log10
- log10p1⚠
- See:
mpfr_log10p1
- log_ui⚠
- See:
mpfr_log_ui
- max⚠
- See:
mpfr_max
- min⚠
- See:
mpfr_min
- min_
prec ⚠ - See:
mpfr_min_prec
- modf⚠
- See:
mpfr_modf
- mp_
memory_ ⚠cleanup - See:
mpfr_mp_memory_cleanup
- mul⚠
- See:
mpfr_mul
- mul_
2exp ⚠ - See:
mpfr_mul_2exp
- mul_2si⚠
- See:
mpfr_mul_2si
- mul_2ui⚠
- See:
mpfr_mul_2ui
- mul_d⚠
- See:
mpfr_mul_d
- mul_q⚠
- See:
mpfr_mul_q
- mul_si⚠
- See:
mpfr_mul_si
- mul_ui⚠
- See:
mpfr_mul_ui
- mul_z⚠
- See:
mpfr_mul_z
- nan_p⚠
- See:
mpfr_nan_p
- nanflag_
p ⚠ - See:
mpfr_nanflag_p
- neg⚠
- See:
mpfr_neg
- nextabove⚠
- See:
mpfr_nextabove
- nextbelow⚠
- See:
mpfr_nextbelow
- nexttoward⚠
- See:
mpfr_nexttoward
- nrandom⚠
- See:
mpfr_nrandom
- number_
p ⚠ - See:
mpfr_number_p
- out_str⚠
- See:
mpfr_out_str
- overflow_
p ⚠ - See:
mpfr_overflow_p
- pow⚠
- See:
mpfr_pow
- pow_si⚠
- See:
mpfr_pow_si
- pow_sj⚠
- See:
mpfr_pow_sj
- pow_ui⚠
- See:
mpfr_pow_ui
- pow_uj⚠
- See:
mpfr_pow_uj
- pow_z⚠
- See:
mpfr_pow_z
- pown⚠
- See:
mpfr_pown
- powr⚠
- See:
mpfr_powr
- prec_
round ⚠ - See:
mpfr_prec_round
- print_
rnd_ ⚠mode - See:
mpfr_print_rnd_mode
- printf⚠
- See:
mpfr_printf
- rec_
sqrt ⚠ - See:
mpfr_rec_sqrt
- regular_
p ⚠ - See:
mpfr_regular_p
- reldiff⚠
- See:
mpfr_reldiff
- remainder⚠
- See:
mpfr_remainder
- remquo⚠
- See:
mpfr_remquo
- rint⚠
- See:
mpfr_rint
- rint_
ceil ⚠ - See:
mpfr_rint_ceil
- rint_
floor ⚠ - See:
mpfr_rint_floor
- rint_
round ⚠ - See:
mpfr_rint_round
- rint_
roundeven ⚠ - See:
mpfr_rint_roundeven
- rint_
trunc ⚠ - See:
mpfr_rint_trunc
- root⚠
Deprecated - See:
mpfr_root
- rootn_
si ⚠ - See:
mpfr_rootn_si
- rootn_
ui ⚠ - See:
mpfr_rootn_ui
- round⚠
- See:
mpfr_round
- roundeven⚠
- See:
mpfr_roundeven
- sec⚠
- See:
mpfr_sec
- sech⚠
- See:
mpfr_sech
- set⚠
- See:
mpfr_set
- set_d⚠
- See:
mpfr_set_d
- set_
default_ ⚠prec - See:
mpfr_set_default_prec
- set_
default_ ⚠rounding_ mode - See:
mpfr_set_default_rounding_mode
- set_
divby0 ⚠ - See:
mpfr_set_divby0
- set_
emax ⚠ - See:
mpfr_set_emax
- set_
emin ⚠ - See:
mpfr_set_emin
- set_
erangeflag ⚠ - See:
mpfr_set_erangeflag
- set_exp⚠
- See:
mpfr_set_exp
- set_f⚠
- See:
mpfr_set_f
- set_flt⚠
- See:
mpfr_set_flt
- set_
inexflag ⚠ - See:
mpfr_set_inexflag
- set_inf⚠
- See:
mpfr_set_inf
- set_nan⚠
- See:
mpfr_set_nan
- set_
nanflag ⚠ - See:
mpfr_set_nanflag
- set_
overflow ⚠ - See:
mpfr_set_overflow
- set_
prec ⚠ - See:
mpfr_set_prec
- set_
prec_ ⚠raw - See:
mpfr_set_prec_raw
- set_q⚠
- See:
mpfr_set_q
- set_si⚠
- See:
mpfr_set_si
- set_
si_ ⚠2exp - See:
mpfr_set_si_2exp
- set_sj⚠
- See:
mpfr_set_sj
- set_
sj_ ⚠2exp - See:
mpfr_set_sj_2exp
- set_str⚠
- See:
mpfr_set_str
- set_ui⚠
- See:
mpfr_set_ui
- set_
ui_ ⚠2exp - See:
mpfr_set_ui_2exp
- set_uj⚠
- See:
mpfr_set_uj
- set_
uj_ ⚠2exp - See:
mpfr_set_uj_2exp
- set_
underflow ⚠ - See:
mpfr_set_underflow
- set_z⚠
- See:
mpfr_set_z
- set_
z_ ⚠2exp - See:
mpfr_set_z_2exp
- set_
zero ⚠ - See:
mpfr_set_zero
- setsign⚠
- See:
mpfr_setsign
- sgn⚠
- See:
mpfr_sgn
- si_div⚠
- See:
mpfr_si_div
- si_sub⚠
- See:
mpfr_si_sub
- signbit⚠
- See:
mpfr_signbit
- sin⚠
- See:
mpfr_sin
- sin_cos⚠
- See:
mpfr_sin_cos
- sinh⚠
- See:
mpfr_sinh
- sinh_
cosh ⚠ - See:
mpfr_sinh_cosh
- sinpi⚠
- See:
mpfr_sinpi
- sinu⚠
- See:
mpfr_sinu
- snprintf⚠
- See:
mpfr_snprintf
- sprintf⚠
- See:
mpfr_sprintf
- sqr⚠
- See:
mpfr_sqr
- sqrt⚠
- See:
mpfr_sqrt
- sqrt_ui⚠
- See:
mpfr_sqrt_ui
- strtofr⚠
- See:
mpfr_strtofr
- sub⚠
- See:
mpfr_sub
- sub_d⚠
- See:
mpfr_sub_d
- sub_q⚠
- See:
mpfr_sub_q
- sub_si⚠
- See:
mpfr_sub_si
- sub_ui⚠
- See:
mpfr_sub_ui
- sub_z⚠
- See:
mpfr_sub_z
- subnormalize⚠
- See:
mpfr_subnormalize
- sum⚠
- See:
mpfr_sum
- swap⚠
- See:
mpfr_swap
- tan⚠
- See:
mpfr_tan
- tanh⚠
- See:
mpfr_tanh
- tanpi⚠
- See:
mpfr_tanpi
- tanu⚠
- See:
mpfr_tanu
- total_
order_ ⚠p - See:
mpfr_total_order_p
- trunc⚠
- See:
mpfr_trunc
- ui_div⚠
- See:
mpfr_ui_div
- ui_pow⚠
- See:
mpfr_ui_pow
- ui_
pow_ ⚠ui - See:
mpfr_ui_pow_ui
- ui_sub⚠
- See:
mpfr_ui_sub
- underflow_
p ⚠ - See:
mpfr_underflow_p
- unordered_
p ⚠ - See:
mpfr_unordered_p
- urandom⚠
- See:
mpfr_urandom
- urandomb⚠
- See:
mpfr_urandomb
- y0⚠
- See:
mpfr_y0
- y1⚠
- See:
mpfr_y1
- yn⚠
- See:
mpfr_yn
- z_sub⚠
- See:
mpfr_z_sub
- zero_p⚠
- See:
mpfr_zero_p
- zeta⚠
- See:
mpfr_zeta
- zeta_ui⚠
- See:
mpfr_zeta_ui