gmp_mpfr_sys/mpc.rs
1// Copyright © 2017–2025 Trevor Spiteri
2
3// This program is free software: you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public License
5// as published by the Free Software Foundation, either version 3 of
6// the License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful, but
9// WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License and a copy of the GNU General Public License along with
15// this program. If not, see <https://www.gnu.org/licenses/>.
16
17/*!
18Function and type bindings for the [MPC] library.
19
20# Examples
21
22```rust
23use core::f64;
24use core::mem::MaybeUninit;
25use gmp_mpfr_sys::{mpc, mpfr};
26let one_third = 1.0_f64 / 3.0;
27let neg_inf = f64::NEG_INFINITY;
28unsafe {
29 let mut c = {
30 let mut c = MaybeUninit::uninit();
31 mpc::init3(c.as_mut_ptr(), 53, 53);
32 c.assume_init()
33 };
34 let dirs = mpc::set_d_d(&mut c, one_third, neg_inf, mpc::RNDNN);
35 assert_eq!(dirs, 0);
36 let re = mpfr::get_d(mpc::realref_const(&c), mpfr::rnd_t::RNDN);
37 assert_eq!(re, one_third);
38 let im = mpfr::get_d(mpc::imagref_const(&c), mpfr::rnd_t::RNDN);
39 assert_eq!(im, neg_inf);
40 mpc::clear(&mut c);
41}
42```
43
44[MPC]: https://www.multiprecision.org/
45*/
46#![allow(non_camel_case_types, non_snake_case)]
47
48use crate::gmp::{mpf_t, mpq_t, mpz_t, randstate_t};
49use crate::mpfr::{mpfr_t, prec_t, rnd_t as mpfr_rnd_t};
50use core::ffi::{c_char, c_int, c_long, c_ulong};
51use core::ptr;
52use libc::{intmax_t, uintmax_t, FILE};
53
54include!(concat!(env!("OUT_DIR"), "/mpc_h.rs"));
55
56#[inline]
57const extern "C" fn INEX_NEG(inex: c_int) -> c_int {
58 match inex {
59 2 => -1,
60 0 => 0,
61 _ => 1,
62 }
63}
64/// See: [Return Value](../C/MPC/constant.GNU_MPC_Basics.html#return_002dvalue)
65#[inline]
66pub const extern "C" fn INEX_RE(inex: c_int) -> c_int {
67 INEX_NEG((inex) & 3)
68}
69/// See: [Return Value](../C/MPC/constant.GNU_MPC_Basics.html#return_002dvalue)
70#[inline]
71pub const extern "C" fn INEX_IM(inex: c_int) -> c_int {
72 INEX_NEG((inex) >> 2)
73}
74/// See: [Return Value](../C/MPC/constant.GNU_MPC_Basics.html#return_002dvalue)
75#[inline]
76pub const extern "C" fn INEX1(inex: c_int) -> c_int {
77 inex & 15
78}
79/// See: [Return Value](../C/MPC/constant.GNU_MPC_Basics.html#return_002dvalue)
80#[inline]
81pub const extern "C" fn INEX2(inex: c_int) -> c_int {
82 inex >> 4
83}
84
85/// See: [`mpc_rnd_t`](../C/MPC/constant.GNU_MPC_Basics.html#index-mpc_005frnd_005ft)
86pub type rnd_t = c_int;
87
88const RNDN: c_int = mpfr_rnd_t::RNDN as c_int;
89const RNDZ: c_int = mpfr_rnd_t::RNDZ as c_int;
90const RNDU: c_int = mpfr_rnd_t::RNDU as c_int;
91const RNDD: c_int = mpfr_rnd_t::RNDD as c_int;
92const RNDA: c_int = mpfr_rnd_t::RNDA as c_int;
93
94/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
95pub const RNDNN: c_int = RNDN + (RNDN << 4);
96/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
97pub const RNDNZ: c_int = RNDN + (RNDZ << 4);
98/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
99pub const RNDNU: c_int = RNDN + (RNDU << 4);
100/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
101pub const RNDND: c_int = RNDN + (RNDD << 4);
102/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
103pub const RNDNA: c_int = RNDN + (RNDA << 4);
104/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
105pub const RNDZN: c_int = RNDZ + (RNDN << 4);
106/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
107pub const RNDZZ: c_int = RNDZ + (RNDZ << 4);
108/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
109pub const RNDZU: c_int = RNDZ + (RNDU << 4);
110/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
111pub const RNDZD: c_int = RNDZ + (RNDD << 4);
112/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
113pub const RNDZA: c_int = RNDZ + (RNDA << 4);
114/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
115pub const RNDUN: c_int = RNDU + (RNDN << 4);
116/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
117pub const RNDUZ: c_int = RNDU + (RNDZ << 4);
118/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
119pub const RNDUU: c_int = RNDU + (RNDU << 4);
120/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
121pub const RNDUD: c_int = RNDU + (RNDD << 4);
122/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
123pub const RNDUA: c_int = RNDU + (RNDA << 4);
124/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
125pub const RNDDN: c_int = RNDD + (RNDN << 4);
126/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
127pub const RNDDZ: c_int = RNDD + (RNDZ << 4);
128/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
129pub const RNDDU: c_int = RNDD + (RNDU << 4);
130/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
131pub const RNDDD: c_int = RNDD + (RNDD << 4);
132/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
133pub const RNDDA: c_int = RNDD + (RNDA << 4);
134/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
135pub const RNDAN: c_int = RNDA + (RNDN << 4);
136/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
137pub const RNDAZ: c_int = RNDA + (RNDZ << 4);
138/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
139pub const RNDAU: c_int = RNDA + (RNDU << 4);
140/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
141pub const RNDAD: c_int = RNDA + (RNDD << 4);
142/// See: [Rounding Modes](../C/MPC/constant.GNU_MPC_Basics.html#Rounding-Modes)
143pub const RNDAA: c_int = RNDA + (RNDA << 4);
144
145/// See: [`mpc_t`](../C/MPC/constant.GNU_MPC_Basics.html#index-mpc_005ft)
146///
147#[doc = include_str!("internal_fields.md")]
148#[repr(C)]
149#[derive(Clone, Copy, Debug)]
150pub struct mpc_t {
151 /// Internal implementation detail: real part.
152 pub re: mpfr_t,
153 /// Internal implementation detail: imaginary part.
154 pub im: mpfr_t,
155}
156
157/// Experimental struct.
158/// See: [`mpcr_t`](../C/MPC/constant.Ball_Arithmetic.html#index-mpcr_005ft)
159///
160#[doc = include_str!("internal_fields.md")]
161#[repr(C)]
162#[derive(Clone, Copy, Debug)]
163pub struct mpcr_t {
164 /// Internal implementation detail: positive mantissa.
165 pub mant: i64,
166 /// Internal implementation detail: exponent.
167 pub exp: i64,
168}
169
170/// Experimental struct.
171/// See: [`mpcb_t`](../C/MPC/constant.Ball_Arithmetic.html#index-mpcb_005ft)
172///
173#[doc = include_str!("internal_fields.md")]
174#[repr(C)]
175#[derive(Clone, Copy, Debug)]
176pub struct mpcb_t {
177 /// Internal implementation detail: center.
178 pub c: mpc_t,
179 /// Internal implementation detail: radius.
180 pub r: mpcr_t,
181}
182
183// Types for function declarations in this file.
184
185type mpz_srcptr = *const mpz_t;
186type mpq_srcptr = *const mpq_t;
187type mpf_srcptr = *const mpf_t;
188type randstate_ptr = *mut randstate_t;
189type mpfr_srcptr = *const mpfr_t;
190type mpfr_ptr = *mut mpfr_t;
191type mpc_ptr = *mut mpc_t;
192type mpc_srcptr = *const mpc_t;
193type mpcr_ptr = *mut mpcr_t;
194type mpcr_srcptr = *const mpcr_t;
195type mpcb_ptr = *mut mpcb_t;
196type mpcb_srcptr = *const mpcb_t;
197
198extern "C" {
199 // Initialization Functions
200
201 /// See: [`mpc_init2`](../C/MPC/constant.Complex_Functions.html#index-mpc_005finit2)
202 #[link_name = "mpc_init2"]
203 pub fn init2(z: mpc_ptr, prec: prec_t);
204 /// See: [`mpc_init3`](../C/MPC/constant.Complex_Functions.html#index-mpc_005finit3)
205 #[link_name = "mpc_init3"]
206 pub fn init3(z: mpc_ptr, prec_r: prec_t, prec_i: prec_t);
207 /// See: [`mpc_clear`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fclear)
208 #[link_name = "mpc_clear"]
209 pub fn clear(z: mpc_ptr);
210 /// See: [`mpc_set_prec`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fprec)
211 #[link_name = "mpc_set_prec"]
212 pub fn set_prec(x: mpc_ptr, prec: prec_t);
213 /// See: [`mpc_get_prec`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fget_005fprec)
214 #[link_name = "mpc_get_prec"]
215 pub fn get_prec(x: mpc_srcptr) -> prec_t;
216 /// See: [`mpc_get_prec2`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fget_005fprec2)
217 #[link_name = "mpc_get_prec2"]
218 pub fn get_prec2(pr: *mut prec_t, pi: *mut prec_t, x: mpc_srcptr);
219
220 // Assignment Functions
221
222 /// See: [`mpc_set`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset)
223 #[link_name = "mpc_set"]
224 pub fn set(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
225 /// See: [`mpc_set_ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fui)
226 #[link_name = "mpc_set_ui"]
227 pub fn set_ui(rop: mpc_ptr, op: c_ulong, rnd: rnd_t) -> c_int;
228 /// See: [`mpc_set_si`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fsi)
229 #[link_name = "mpc_set_si"]
230 pub fn set_si(rop: mpc_ptr, op: c_long, rnd: rnd_t) -> c_int;
231 /// See: [`mpc_set_uj`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fuj)
232 #[link_name = "mpc_set_uj"]
233 pub fn set_uj(rop: mpc_ptr, op: uintmax_t, rnd: rnd_t) -> c_int;
234 /// See: [`mpc_set_sj`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fsj)
235 #[link_name = "mpc_set_sj"]
236 pub fn set_sj(rop: mpc_ptr, op: intmax_t, rnd: rnd_t) -> c_int;
237 /// See: [`mpc_set_d`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fd)
238 #[link_name = "mpc_set_d"]
239 pub fn set_d(rop: mpc_ptr, op: f64, rnd: rnd_t) -> c_int;
240 /// See: [`mpc_set_z`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fz)
241 #[link_name = "mpc_set_z"]
242 pub fn set_z(rop: mpc_ptr, op: mpz_srcptr, rnd: rnd_t) -> c_int;
243 /// See: [`mpc_set_q`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fq)
244 #[link_name = "mpc_set_q"]
245 pub fn set_q(rop: mpc_ptr, op: mpq_srcptr, rnd: rnd_t) -> c_int;
246 /// See: [`mpc_set_f`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005ff)
247 #[link_name = "mpc_set_f"]
248 pub fn set_f(rop: mpc_ptr, op: mpf_srcptr, rnd: rnd_t) -> c_int;
249 /// See: [`mpc_set_fr`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005ffr)
250 #[link_name = "mpc_set_fr"]
251 pub fn set_fr(rop: mpc_ptr, op: mpfr_srcptr, rnd: rnd_t) -> c_int;
252 /// See: [`mpc_set_ui_ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fui_005fui)
253 #[link_name = "mpc_set_ui_ui"]
254 pub fn set_ui_ui(rop: mpc_ptr, op1: c_ulong, op2: c_ulong, rnd: rnd_t) -> c_int;
255 /// See: [`mpc_set_si_si`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fsi_005fsi)
256 #[link_name = "mpc_set_si_si"]
257 pub fn set_si_si(rop: mpc_ptr, op1: c_long, op2: c_long, rnd: rnd_t) -> c_int;
258 /// See: [`mpc_set_uj_uj`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fuj_005fuj)
259 #[link_name = "mpc_set_uj_uj"]
260 pub fn set_uj_uj(rop: mpc_ptr, op1: uintmax_t, op2: uintmax_t, rnd: rnd_t) -> c_int;
261 /// See: [`mpc_set_sj_sj`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fsj_005fsj)
262 #[link_name = "mpc_set_sj_sj"]
263 pub fn set_sj_sj(rop: mpc_ptr, op1: intmax_t, op2: intmax_t, rnd: rnd_t) -> c_int;
264 /// See: [`mpc_set_d_d`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fd_005fd)
265 #[link_name = "mpc_set_d_d"]
266 pub fn set_d_d(rop: mpc_ptr, op1: f64, op2: f64, rnd: rnd_t) -> c_int;
267 /// See: [`mpc_set_z_z`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fz_005fz)
268 #[link_name = "mpc_set_z_z"]
269 pub fn set_z_z(rop: mpc_ptr, op1: mpz_srcptr, op2: mpz_srcptr, rnd: rnd_t) -> c_int;
270 /// See: [`mpc_set_q_q`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fq_005fq)
271 #[link_name = "mpc_set_q_q"]
272 pub fn set_q_q(rop: mpc_ptr, op1: mpq_srcptr, op2: mpq_srcptr, rnd: rnd_t) -> c_int;
273 /// See: [`mpc_set_f_f`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005ff_005ff)
274 #[link_name = "mpc_set_f_f"]
275 pub fn set_f_f(rop: mpc_ptr, op1: mpf_srcptr, op2: mpf_srcptr, rnd: rnd_t) -> c_int;
276 /// See: [`mpc_set_fr_fr`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005ffr_005ffr)
277 #[link_name = "mpc_set_fr_fr"]
278 pub fn set_fr_fr(rop: mpc_ptr, op1: mpfr_srcptr, op2: mpfr_srcptr, rnd: rnd_t) -> c_int;
279 /// See: [`mpc_set_nan`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fnan)
280 #[link_name = "mpc_set_nan"]
281 pub fn set_nan(rop: mpc_ptr);
282 /// See: [`mpc_swap`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fswap)
283 #[link_name = "mpc_swap"]
284 pub fn swap(op1: mpc_ptr, op2: mpc_ptr);
285
286 // String and Stream Input and Output
287
288 /// See: [`mpc_strtoc`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fstrtoc)
289 #[link_name = "mpc_strtoc"]
290 pub fn strtoc(
291 rop: mpc_ptr,
292 nptr: *const c_char,
293 endptr: *mut *mut c_char,
294 base: c_int,
295 rnd: rnd_t,
296 ) -> c_int;
297 /// See: [`mpc_set_str`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fset_005fstr)
298 #[link_name = "mpc_set_str"]
299 pub fn set_str(rop: mpc_ptr, s: *const c_char, base: c_int, rnd: rnd_t) -> c_int;
300 /// See: [`mpc_get_str`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fget_005fstr)
301 #[link_name = "mpc_get_str"]
302 pub fn get_str(b: c_int, n: usize, op: mpc_srcptr, rnd: rnd_t) -> *mut c_char;
303 /// See: [`mpc_free_str`](../C/MPC/constant.Complex_Functions.html#index-mpc_005ffree_005fstr)
304 #[link_name = "mpc_free_str"]
305 pub fn free_str(rop: *mut c_char);
306 /// See: [`mpc_inp_str`](../C/MPC/constant.Complex_Functions.html#index-mpc_005finp_005fstr)
307 #[link_name = "mpc_inp_str"]
308 pub fn inp_str(
309 rop: mpc_ptr,
310 stream: *mut FILE,
311 read: *mut usize,
312 base: c_int,
313 rnd: rnd_t,
314 ) -> c_int;
315 /// See: [`mpc_out_str`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fout_005fstr)
316 #[link_name = "mpc_out_str"]
317 pub fn out_str(
318 stream: *mut FILE,
319 base: c_int,
320 n_digits: usize,
321 op: mpc_srcptr,
322 rnd: rnd_t,
323 ) -> usize;
324
325 // Comparison Functions
326
327 /// See: [`mpc_cmp`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fcmp)
328 #[link_name = "mpc_cmp"]
329 pub fn cmp(op1: mpc_srcptr, op2: mpc_srcptr) -> c_int;
330 /// See: [`mpc_cmp_si_si`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fcmp_005fsi_005fsi)
331 #[link_name = "mpc_cmp_si_si"]
332 pub fn cmp_si_si(op1: mpc_srcptr, op2r: c_long, op2i: c_long) -> c_int;
333}
334/// See: [`mpc_cmp_si`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fcmp_005fsi)
335#[inline]
336pub unsafe extern "C" fn cmp_si(op1: mpc_srcptr, op2: c_long) -> c_int {
337 unsafe { cmp_si_si(op1, op2, 0) }
338}
339extern "C" {
340 /// See: [`mpc_cmp_abs`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fcmp_005fabs)
341 #[link_name = "mpc_cmp_abs"]
342 pub fn cmp_abs(op1: mpc_srcptr, op2: mpc_srcptr) -> c_int;
343
344 // Projection and Decomposing Functions
345 /// See: [`mpc_real`](../C/MPC/constant.Complex_Functions.html#index-mpc_005freal)
346 #[link_name = "mpc_real"]
347 pub fn real(rop: mpfr_ptr, arg2: mpc_srcptr, rnd: mpfr_rnd_t) -> c_int;
348 /// See: [`mpc_imag`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fimag)
349 #[link_name = "mpc_imag"]
350 pub fn imag(rop: mpfr_ptr, arg2: mpc_srcptr, rnd: mpfr_rnd_t) -> c_int;
351}
352/// See: [`mpc_realref`](../C/MPC/constant.Complex_Functions.html#index-mpc_005frealref)
353#[inline]
354pub const unsafe extern "C" fn realref(op: mpc_ptr) -> mpfr_ptr {
355 unsafe { realref_const(op) as mpfr_ptr }
356}
357/// Constant version of [`realref`](fn.realref.html).
358#[inline]
359pub const unsafe extern "C" fn realref_const(op: mpc_srcptr) -> mpfr_srcptr {
360 unsafe { ptr::addr_of!((*op).re) }
361}
362/// See: [`mpc_imagref`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fimagref)
363#[inline]
364pub const unsafe extern "C" fn imagref(op: mpc_ptr) -> mpfr_ptr {
365 unsafe { imagref_const(op) as mpfr_ptr }
366}
367/// Constant version of [`imagref`](fn.imagref.html).
368#[inline]
369pub const unsafe extern "C" fn imagref_const(op: mpc_srcptr) -> mpfr_srcptr {
370 unsafe { ptr::addr_of!((*op).im) }
371}
372extern "C" {
373 /// See: [`mpc_arg`](../C/MPC/constant.Complex_Functions.html#index-mpc_005farg)
374 #[link_name = "mpc_arg"]
375 pub fn arg(rop: mpfr_ptr, op: mpc_srcptr, rnd: mpfr_rnd_t) -> c_int;
376 /// See: [`mpc_proj`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fproj)
377 #[link_name = "mpc_proj"]
378 pub fn proj(rop: mpc_ptr, arg2: mpc_srcptr, rnd: rnd_t) -> c_int;
379
380 // Basic Arithmetic Functions
381
382 /// See: [`mpc_add`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fadd)
383 #[link_name = "mpc_add"]
384 pub fn add(rop: mpc_ptr, op1: mpc_srcptr, op2: mpc_srcptr, rnd: rnd_t) -> c_int;
385 /// See: [`mpc_add_ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fadd_005fui)
386 #[link_name = "mpc_add_ui"]
387 pub fn add_ui(rop: mpc_ptr, op1: mpc_srcptr, op2: c_ulong, rnd: rnd_t) -> c_int;
388 /// See: [`mpc_add_fr`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fadd_005ffr)
389 #[link_name = "mpc_add_fr"]
390 pub fn add_fr(rop: mpc_ptr, op1: mpc_srcptr, op2: mpfr_srcptr, rnd: rnd_t) -> c_int;
391 /// See: [`mpc_fr_sub`](../C/MPC/constant.Complex_Functions.html#index-mpc_005ffr_005fsub)
392 #[link_name = "mpc_sub"]
393 pub fn sub(rop: mpc_ptr, op1: mpc_srcptr, op2: mpc_srcptr, rnd: rnd_t) -> c_int;
394 /// See: [`mpc_sub_fr`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fsub_005ffr)
395 #[link_name = "mpc_sub_fr"]
396 pub fn sub_fr(rop: mpc_ptr, op1: mpc_srcptr, op2: mpfr_srcptr, rnd: rnd_t) -> c_int;
397 /// See: [`mpc_fr_sub`](../C/MPC/constant.Complex_Functions.html#index-mpc_005ffr_005fsub)
398 #[link_name = "mpc_fr_sub"]
399 pub fn fr_sub(rop: mpc_ptr, op1: mpfr_srcptr, op2: mpc_srcptr, rnd: rnd_t) -> c_int;
400 /// See: [`mpc_sub_ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fsub_005fui)
401 #[link_name = "mpc_sub_ui"]
402 pub fn sub_ui(rop: mpc_ptr, op1: mpc_srcptr, op2: c_ulong, rnd: rnd_t) -> c_int;
403}
404/// See: [`mpc_ui_sub`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fui_005fsub)
405#[inline]
406pub unsafe extern "C" fn ui_sub(rop: mpc_ptr, op1: c_ulong, op2: mpc_srcptr, rnd: rnd_t) -> c_int {
407 unsafe { ui_ui_sub(rop, op1, 0, op2, rnd) }
408}
409extern "C" {
410 /// See: [`mpc_ui_ui_sub`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fui_005fui_005fsub)
411 #[link_name = "mpc_ui_ui_sub"]
412 pub fn ui_ui_sub(
413 rop: mpc_ptr,
414 re1: c_ulong,
415 im1: c_ulong,
416 op2: mpc_srcptr,
417 rnd: rnd_t,
418 ) -> c_int;
419 /// See: [`mpc_neg`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fneg)
420 #[link_name = "mpc_neg"]
421 pub fn neg(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
422 /// See: [`mpc_sum`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fsum)
423 #[link_name = "mpc_sum"]
424 pub fn sum(rop: mpc_ptr, op: *const mpc_ptr, n: c_ulong, rnd: rnd_t) -> c_int;
425 /// See: [`mpc_mul`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fmul)
426 #[link_name = "mpc_mul"]
427 pub fn mul(rop: mpc_ptr, op1: mpc_srcptr, op2: mpc_srcptr, rnd: rnd_t) -> c_int;
428 /// See: [`mpc_mul_ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fmul_005fui)
429 #[link_name = "mpc_mul_ui"]
430 pub fn mul_ui(rop: mpc_ptr, op1: mpc_srcptr, op2: c_ulong, rnd: rnd_t) -> c_int;
431 /// See: [`mpc_mul_si`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fmul_005fsi)
432 #[link_name = "mpc_mul_si"]
433 pub fn mul_si(rop: mpc_ptr, op1: mpc_srcptr, op2: c_long, rnd: rnd_t) -> c_int;
434 /// See: [`mpc_mul_fr`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fmul_005ffr)
435 #[link_name = "mpc_mul_fr"]
436 pub fn mul_fr(rop: mpc_ptr, op1: mpc_srcptr, op2: mpfr_srcptr, rnd: rnd_t) -> c_int;
437 /// See: [`mpc_mul_i`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fmul_005fi)
438 #[link_name = "mpc_mul_i"]
439 pub fn mul_i(rop: mpc_ptr, op: mpc_srcptr, sgn: c_int, rnd: rnd_t) -> c_int;
440 /// See: [`mpc_sqr`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fsqr)
441 #[link_name = "mpc_sqr"]
442 pub fn sqr(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
443 /// See: [`mpc_fma`](../C/MPC/constant.Complex_Functions.html#index-mpc_005ffma)
444 #[link_name = "mpc_fma"]
445 pub fn fma(
446 rop: mpc_ptr,
447 op1: mpc_srcptr,
448 op2: mpc_srcptr,
449 op3: mpc_srcptr,
450 rnd: rnd_t,
451 ) -> c_int;
452 /// See: [`mpc_dot`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fdot)
453 #[link_name = "mpc_dot"]
454 pub fn dot(
455 rop: mpc_ptr,
456 op1: *const mpc_ptr,
457 op2: *const mpc_ptr,
458 n: c_ulong,
459 rnd: rnd_t,
460 ) -> c_int;
461 /// See: [`mpc_div`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fdiv)
462 #[link_name = "mpc_div"]
463 pub fn div(rop: mpc_ptr, op1: mpc_srcptr, op2: mpc_srcptr, rnd: rnd_t) -> c_int;
464 /// See: [`mpc_div_ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fdiv_005fui)
465 #[link_name = "mpc_div_ui"]
466 pub fn div_ui(rop: mpc_ptr, op1: mpc_srcptr, op2: c_ulong, rnd: rnd_t) -> c_int;
467 /// See: [`mpc_div_fr`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fdiv_005ffr)
468 #[link_name = "mpc_div_fr"]
469 pub fn div_fr(rop: mpc_ptr, op1: mpc_srcptr, op2: mpfr_srcptr, rnd: rnd_t) -> c_int;
470 /// See: [`mpc_ui_div`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fui_005fdiv)
471 #[link_name = "mpc_ui_div"]
472 pub fn ui_div(rop: mpc_ptr, op1: c_ulong, op2: mpc_srcptr, rnd: rnd_t) -> c_int;
473 /// See: [`mpc_fr_div`](../C/MPC/constant.Complex_Functions.html#index-mpc_005ffr_005fdiv)
474 #[link_name = "mpc_fr_div"]
475 pub fn fr_div(rop: mpc_ptr, op1: mpfr_srcptr, op2: mpc_srcptr, rnd: rnd_t) -> c_int;
476 /// See: [`mpc_conj`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fconj)
477 #[link_name = "mpc_conj"]
478 pub fn conj(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
479 /// See: [`mpc_abs`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fabs)
480 #[link_name = "mpc_abs"]
481 pub fn abs(rop: mpfr_ptr, op: mpc_srcptr, rnd: mpfr_rnd_t) -> c_int;
482 /// See: [`mpc_norm`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fnorm)
483 #[link_name = "mpc_norm"]
484 pub fn norm(rop: mpfr_ptr, op: mpc_srcptr, rnd: mpfr_rnd_t) -> c_int;
485 /// See: [`mpc_mul_2ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fmul_005f2ui)
486 #[link_name = "mpc_mul_2ui"]
487 pub fn mul_2ui(rop: mpc_ptr, op1: mpc_srcptr, op2: c_ulong, rnd: rnd_t) -> c_int;
488 /// See: [`mpc_mul_2si`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fmul_005f2si)
489 #[link_name = "mpc_mul_2si"]
490 pub fn mul_2si(rop: mpc_ptr, op1: mpc_srcptr, op2: c_long, rnd: rnd_t) -> c_int;
491 /// See: [`mpc_div_2ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fdiv_005f2ui)
492 #[link_name = "mpc_div_2ui"]
493 pub fn div_2ui(rop: mpc_ptr, op1: mpc_srcptr, op2: c_ulong, rnd: rnd_t) -> c_int;
494 /// See: [`mpc_div_2si`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fdiv_005f2si)
495 #[link_name = "mpc_div_2si"]
496 pub fn div_2si(rop: mpc_ptr, op1: mpc_srcptr, op2: c_long, rnd: rnd_t) -> c_int;
497
498 // Power Functions and Logarithms
499
500 /// See: [`mpc_sqrt`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fsqrt)
501 #[link_name = "mpc_sqrt"]
502 pub fn sqrt(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
503 /// See: [`mpc_pow`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fpow)
504 #[link_name = "mpc_pow"]
505 pub fn pow(rop: mpc_ptr, op1: mpc_srcptr, op2: mpc_srcptr, rnd: rnd_t) -> c_int;
506 /// See: [`mpc_pow_d`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fpow_005fd)
507 #[link_name = "mpc_pow_d"]
508 pub fn pow_d(rop: mpc_ptr, op1: mpc_srcptr, op2: f64, rnd: rnd_t) -> c_int;
509 /// See: [`mpc_pow_si`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fpow_005fsi)
510 #[link_name = "mpc_pow_si"]
511 pub fn pow_si(rop: mpc_ptr, op1: mpc_srcptr, op2: c_long, rnd: rnd_t) -> c_int;
512 /// See: [`mpc_pow_ui`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fpow_005fui)
513 #[link_name = "mpc_pow_ui"]
514 pub fn pow_ui(rop: mpc_ptr, op1: mpc_srcptr, op2: c_ulong, rnd: rnd_t) -> c_int;
515 /// See: [`mpc_pow_z`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fpow_005fz)
516 #[link_name = "mpc_pow_z"]
517 pub fn pow_z(rop: mpc_ptr, op1: mpc_srcptr, op2: mpz_srcptr, rnd: rnd_t) -> c_int;
518 /// See: [`mpc_pow_fr`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fpow_005ffr)
519 #[link_name = "mpc_pow_fr"]
520 pub fn pow_fr(rop: mpc_ptr, op1: mpc_srcptr, op2: mpfr_srcptr, rnd: rnd_t) -> c_int;
521 /// See: [`mpc_exp`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fexp)
522 #[link_name = "mpc_exp"]
523 pub fn exp(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
524 /// See: [`mpc_log`](../C/MPC/constant.Complex_Functions.html#index-mpc_005flog)
525 #[link_name = "mpc_log"]
526 pub fn log(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
527 /// See: [`mpc_log10`](../C/MPC/constant.Complex_Functions.html#index-mpc_005flog10)
528 #[link_name = "mpc_log10"]
529 pub fn log10(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
530 /// See: [`mpc_rootofunity`](../C/MPC/constant.Complex_Functions.html#index-mpc_005frootofunity)
531 #[link_name = "mpc_rootofunity"]
532 pub fn rootofunity(rop: mpc_ptr, n: c_ulong, k: c_ulong, rnd: rnd_t) -> c_int;
533 /// See: [`mpc_agm`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fagm)
534 #[link_name = "mpc_agm"]
535 pub fn agm(rop: mpc_ptr, a: mpc_srcptr, b: mpc_srcptr, rnd: rnd_t) -> c_int;
536
537 // Trigonometric Functions
538
539 /// See: [`mpc_sin`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fsin)
540 #[link_name = "mpc_sin"]
541 pub fn sin(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
542 /// See: [`mpc_cos`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fcos)
543 #[link_name = "mpc_cos"]
544 pub fn cos(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
545 /// See: [`mpc_sin_cos`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fsin_005fcos)
546 #[link_name = "mpc_sin_cos"]
547 pub fn sin_cos(
548 rop_sin: mpc_ptr,
549 rop_cos: mpc_ptr,
550 op: mpc_srcptr,
551 rnd_sin: rnd_t,
552 rnd_cos: rnd_t,
553 ) -> c_int;
554 /// See: [`mpc_tan`](../C/MPC/constant.Complex_Functions.html#index-mpc_005ftan)
555 #[link_name = "mpc_tan"]
556 pub fn tan(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
557 /// See: [`mpc_sinh`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fsinh)
558 #[link_name = "mpc_sinh"]
559 pub fn sinh(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
560 /// See: [`mpc_cosh`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fcosh)
561 #[link_name = "mpc_cosh"]
562 pub fn cosh(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
563 /// See: [`mpc_tanh`](../C/MPC/constant.Complex_Functions.html#index-mpc_005ftanh)
564 #[link_name = "mpc_tanh"]
565 pub fn tanh(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
566 /// See: [`mpc_asin`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fasin)
567 #[link_name = "mpc_asin"]
568 pub fn asin(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
569 /// See: [`mpc_acos`](../C/MPC/constant.Complex_Functions.html#index-mpc_005facos)
570 #[link_name = "mpc_acos"]
571 pub fn acos(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
572 /// See: [`mpc_atan`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fatan)
573 #[link_name = "mpc_atan"]
574 pub fn atan(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
575 /// See: [`mpc_asinh`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fasinh)
576 #[link_name = "mpc_asinh"]
577 pub fn asinh(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
578 /// See: [`mpc_acosh`](../C/MPC/constant.Complex_Functions.html#index-mpc_005facosh)
579 #[link_name = "mpc_acosh"]
580 pub fn acosh(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
581 /// See: [`mpc_atanh`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fatanh)
582 #[link_name = "mpc_atanh"]
583 pub fn atanh(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
584
585 // Modular Functions
586
587 /// Experimental function.
588 /// See: [`mpc_eta_fund`](../C/MPC/constant.Complex_Functions.html#index-mpc_005feta_005ffund)
589 #[link_name = "mpc_eta_fund"]
590 pub fn eta_fund(rop: mpc_ptr, op: mpc_srcptr, rnd: rnd_t) -> c_int;
591
592 // Miscellaneous Functions
593
594 /// See: [`mpc_urandom`](../C/MPC/constant.Complex_Functions.html#index-mpc_005furandom)
595 #[link_name = "mpc_urandom"]
596 pub fn urandom(rop: mpc_ptr, state: randstate_ptr) -> c_int;
597 /// See: [`mpc_get_version`](../C/MPC/constant.Complex_Functions.html#index-mpc_005fget_005fversion)
598 #[link_name = "mpc_get_version"]
599 pub fn get_version() -> *const c_char;
600}
601/// See: [`MPC_VERSION`](../C/MPC/constant.Complex_Functions.html#index-MPC_005fVERSION)
602pub const VERSION: c_int = (VERSION_MAJOR << 16) | (VERSION_MINOR << 8) | VERSION_PATCHLEVEL;
603/// See: [`MPC_VERSION_MAJOR`](../C/MPC/constant.Complex_Functions.html#index-MPC_005fVERSION_005fMAJOR)
604pub const VERSION_MAJOR: c_int = MPC_VERSION_MAJOR;
605/// See: [`MPC_VERSION_MINOR`](../C/MPC/constant.Complex_Functions.html#index-MPC_005fVERSION_005fMINOR)
606pub const VERSION_MINOR: c_int = MPC_VERSION_MINOR;
607/// See: [`MPC_VERSION_PATCHLEVEL`](../C/MPC/constant.Complex_Functions.html#index-MPC_005fVERSION_005fPATCHLEVEL)
608pub const VERSION_PATCHLEVEL: c_int = MPC_VERSION_PATCHLEVEL;
609/// See: [`MPC_VERSION_STRING`](../C/MPC/constant.Complex_Functions.html#index-MPC_005fVERSION_005fSTRING)
610pub const VERSION_STRING: *const c_char = MPC_VERSION_STRING;
611/// See: [`MPC_VERSION_NUM`](../C/MPC/constant.Complex_Functions.html#index-MPC_005fVERSION_005fNUM)
612#[inline]
613pub const extern "C" fn VERSION_NUM(major: c_int, minor: c_int, patchlevel: c_int) -> c_int {
614 (major << 16) | (minor << 8) | patchlevel
615}
616
617extern "C" {
618 // Ball Arithmetic
619
620 // Radius functions
621
622 /// Experimental function.
623 /// See: [`mpcr_inf_p`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005finf_005fp)
624 #[link_name = "mpcr_inf_p"]
625 pub fn mpcr_inf_p(r: mpcr_srcptr) -> c_int;
626 /// Experimental function.
627 /// See: [`mpcr_zero_p`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fzero_005fp)
628 #[link_name = "mpcr_zero_p"]
629 pub fn mpcr_zero_p(r: mpcr_srcptr) -> c_int;
630 /// Experimental function.
631 /// See: [`mpcr_lt_half_p`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005flt_005fhalf_005fp)
632 #[link_name = "mpcr_lt_half_p"]
633 pub fn mpcr_lt_half_p(r: mpcr_srcptr) -> c_int;
634 /// Experimental function.
635 /// See: [`mpcr_cmp`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fcmp)
636 #[link_name = "mpcr_cmp"]
637 pub fn mpcr_cmp(r: mpcr_srcptr, s: mpcr_srcptr) -> c_int;
638 /// Experimental function.
639 /// See: [`mpcr_set_inf`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fset_005finf)
640 #[link_name = "mpcr_set_inf"]
641 pub fn mpcr_set_inf(r: mpcr_ptr);
642 /// Experimental function.
643 /// See: [`mpcr_set_zero`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fset_005fzero)
644 #[link_name = "mpcr_set_zero"]
645 pub fn mpcr_set_zero(r: mpcr_ptr);
646 /// Experimental function.
647 /// See: [`mpcr_set_one`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fset_005f)
648 #[link_name = "mpcr_set_one"]
649 pub fn mpcr_set_one(r: mpcr_ptr);
650 /// Experimental function.
651 /// See: [`mpcr_set`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fset)
652 #[link_name = "mpcr_set"]
653 pub fn mpcr_set(r: mpcr_ptr, s: mpcr_srcptr);
654 /// Experimental function.
655 /// See: [`mpcr_set_ui64_2si64`](../C/MPC/constant.Ball_Arithmetic.html#index-mpcr_005fset_005fui64_005f2si64)
656 #[link_name = "mpcr_set_ui64_2si64"]
657 pub fn mpcr_set_ui64_2si64(r: mpcr_ptr, mant: u64, exp: i64);
658 /// Experimental function.
659 /// See: [`mpcr_max`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fmax)
660 #[link_name = "mpcr_max"]
661 pub fn mpcr_max(r: mpcr_ptr, s: mpcr_srcptr, t: mpcr_srcptr);
662 /// Experimental function.
663 /// See: [`mpcr_get_exp`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fget_005fexp)
664 #[link_name = "mpcr_get_exp"]
665 pub fn mpcr_get_exp(r: mpcr_srcptr) -> i64;
666 /// Experimental function.
667 /// See: [`mpcr_out_str`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fout_005fstr)
668 #[link_name = "mpcr_out_str"]
669 pub fn mpcr_out_str(f: *mut FILE, r: mpcr_srcptr);
670 /// Experimental function.
671 /// See: [`mpcr_add`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fadd)
672 #[link_name = "mpcr_add"]
673 pub fn mpcr_add(r: mpcr_ptr, s: mpcr_srcptr, t: mpcr_srcptr);
674 /// Experimental function.
675 /// See: [`mpcr_sub`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fsub)
676 #[link_name = "mpcr_sub"]
677 pub fn mpcr_sub(r: mpcr_ptr, s: mpcr_srcptr, t: mpcr_srcptr);
678 /// Experimental function.
679 /// See: [`mpcr_mul`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fmul)
680 #[link_name = "mpcr_mul"]
681 pub fn mpcr_mul(r: mpcr_ptr, s: mpcr_srcptr, t: mpcr_srcptr);
682 /// Experimental function.
683 /// See: [`mpcr_div`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fdiv)
684 #[link_name = "mpcr_div"]
685 pub fn mpcr_div(r: mpcr_ptr, s: mpcr_srcptr, t: mpcr_srcptr);
686 /// Experimental function.
687 /// See: [`mpcr_mul_2ui`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fmul_005f2ui)
688 #[link_name = "mpcr_mul_2ui"]
689 pub fn mpcr_mul_2ui(r: mpcr_ptr, s: mpcr_srcptr, t: c_ulong);
690 /// Experimental function.
691 /// See: [`mpcr_div_2ui`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fdiv_005f2ui)
692 #[link_name = "mpcr_div_2ui"]
693 pub fn mpcr_div_2ui(r: mpcr_ptr, s: mpcr_srcptr, t: c_ulong);
694 /// Experimental function.
695 /// See: [`mpcr_sqr`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fsqr)
696 #[link_name = "mpcr_sqr"]
697 pub fn mpcr_sqr(r: mpcr_ptr, s: mpcr_srcptr);
698 /// Experimental function.
699 /// See: [`mpcr_sqrt`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fsqrt)
700 #[link_name = "mpcr_sqrt"]
701 pub fn mpcr_sqrt(r: mpcr_ptr, s: mpcr_srcptr);
702 /// Experimental function.
703 /// See: [`mpcr_sub_rnd`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fsub_005frnd)
704 #[link_name = "mpcr_sub_rnd"]
705 pub fn mpcr_sub_rnd(r: mpcr_ptr, s: mpcr_srcptr, t: mpcr_srcptr, rnd: mpfr_rnd_t);
706 /// Experimental function.
707 /// See: [`mpcr_c_abs_rnd`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fc_005fabs_005frnd)
708 #[link_name = "mpcr_c_abs_rnd"]
709 pub fn mpcr_c_abs_rnd(r: mpcr_ptr, z: mpcr_srcptr, rnd: mpfr_rnd_t);
710 /// Experimental function.
711 /// See: [`mpcr_add_rounding_error`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcr_005fadd_005frounding_005ferror)
712 #[link_name = "mpcr_add_rounding_error"]
713 pub fn mpcr_add_rounding_error(r: mpcr_ptr, p: prec_t, rnd: mpfr_rnd_t);
714
715 // Ball functions
716
717 /// Experimental function.
718 /// See: [`mpcb_init`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005finit)
719 #[link_name = "mpcb_init"]
720 pub fn mpcb_init(z: mpcb_ptr);
721 /// Experimental function.
722 /// See: [`mpcb_clear`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fclear)
723 #[link_name = "mpcb_clear"]
724 pub fn mpcb_clear(z: mpcb_ptr);
725 /// Experimental function.
726 /// See: [`mpcb_get_prec`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fget_005fprec)
727 #[link_name = "mpcb_get_prec"]
728 pub fn mpcb_get_prec(z: mpcb_srcptr) -> prec_t;
729 /// Experimental function.
730 /// See: [`mpcb_set`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fset)
731 #[link_name = "mpcb_set"]
732 pub fn mpcb_set(z: mpcb_ptr, z1: mpcb_srcptr);
733 /// Experimental function.
734 /// See: [`mpcb_set_inf`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fset_005finf)
735 #[link_name = "mpcb_set_inf"]
736 pub fn mpcb_set_inf(z: mpcb_ptr);
737 /// Experimental function.
738 /// See: [`mpcb_set_c`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fset_005fc)
739 #[link_name = "mpcb_set_c"]
740 pub fn mpcb_set_c(z: mpcb_ptr, c: mpc_srcptr, prec: prec_t, err_re: c_ulong, err_im: c_ulong);
741 /// Experimental function.
742 /// See: [`mpcb_set_ui_ui`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fset_005fui_005fui)
743 #[link_name = "mpcb_set_ui_ui"]
744 pub fn mpcb_set_ui_ui(z: mpcb_ptr, re: c_ulong, im: c_ulong, prec: prec_t);
745 /// Experimental function.
746 /// See: [`mpcb_neg`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fneg)
747 #[link_name = "mpcb_neg"]
748 pub fn mpcb_neg(z: mpcb_ptr, z1: mpcb_srcptr);
749 /// Experimental function.
750 /// See: [`mpcb_add`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fadd)
751 #[link_name = "mpcb_add"]
752 pub fn mpcb_add(z: mpcb_ptr, z1: mpcb_srcptr, z2: mpcb_srcptr);
753 /// Experimental function.
754 /// See: [`mpcb_mul`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fmul)
755 #[link_name = "mpcb_mul"]
756 pub fn mpcb_mul(z: mpcb_ptr, z1: mpcb_srcptr, z2: mpcb_srcptr);
757 /// Experimental function.
758 /// See: [`mpcb_sqr`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fsqr)
759 #[link_name = "mpcb_sqr"]
760 pub fn mpcb_sqr(z: mpcb_ptr, z1: mpcb_srcptr);
761 /// Experimental function.
762 /// See: [`mpcb_pow_ui`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fpow_005fui)
763 #[link_name = "mpcb_pow_ui"]
764 pub fn mpcb_pow_ui(z: mpcb_ptr, z1: mpcb_srcptr, e: c_ulong);
765 /// Experimental function.
766 /// See: [`mpcb_sqrt`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fsqrt)
767 #[link_name = "mpcb_sqrt"]
768 pub fn mpcb_sqrt(z: mpcb_ptr, z1: mpcb_srcptr);
769 /// Experimental function.
770 /// See: [`mpcb_div`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fdiv)
771 #[link_name = "mpcb_div"]
772 pub fn mpcb_div(z: mpcb_ptr, z1: mpcb_srcptr, z2: mpcb_srcptr);
773 /// Experimental function.
774 /// See: [`mpcb_div_2ui`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fdiv_005f2ui)
775 #[link_name = "mpcb_div_2ui"]
776 pub fn mpcb_div_2ui(z: mpcb_ptr, z1: mpcb_srcptr, e: c_ulong);
777 /// Experimental function.
778 /// See: [`mpcb_can_round`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fcan_005fround)
779 #[link_name = "mpcb_can_round"]
780 pub fn mpcb_can_round(z: mpcb_srcptr, prec_re: prec_t, prec_im: prec_t, rnd: rnd_t) -> c_int;
781 /// Experimental function.
782 /// See: [`mpcb_round`](../C/MPC/constant.Basic_Arithmetic.html#index-mpcb_005fround)
783 #[link_name = "mpcb_round"]
784 pub fn mpcb_round(c: mpc_ptr, z: mpcb_srcptr, rnd: rnd_t) -> c_int;
785}
786
787#[cfg(test)]
788mod tests {
789 use crate::gmp;
790 use crate::mpc;
791 use crate::mpfr;
792 use core::ptr::NonNull;
793
794 #[test]
795 fn check_real_imag_offsets() {
796 let mut limbs: [gmp::limb_t; 2] = [1 << (gmp::LIMB_BITS - 1), 1 << (gmp::LIMB_BITS - 1)];
797 let mut c = mpc::mpc_t {
798 re: mpfr::mpfr_t {
799 prec: 1,
800 sign: 1,
801 exp: 0,
802 d: NonNull::from(&mut limbs[0]),
803 },
804 im: mpfr::mpfr_t {
805 prec: 1,
806 sign: 1,
807 exp: 0,
808 d: NonNull::from(&mut limbs[1]),
809 },
810 };
811 unsafe {
812 assert_eq!(&c.re as *const mpfr::mpfr_t, mpc::realref_const(&c));
813 assert_eq!(&c.im as *const mpfr::mpfr_t, mpc::imagref_const(&c));
814 assert_eq!(&mut c.re as *mut mpfr::mpfr_t, mpc::realref(&mut c));
815 assert_eq!(&mut c.im as *mut mpfr::mpfr_t, mpc::imagref(&mut c));
816 }
817 }
818
819 #[test]
820 fn check_version() {
821 use crate::tests;
822
823 let (major, minor, patchlevel) = (1, 3, 1);
824 let version = "1.3.1";
825
826 assert_eq!(mpc::VERSION_MAJOR, major);
827 assert!(mpc::VERSION_MINOR >= minor);
828 if cfg!(not(feature = "use-system-libs")) {
829 assert!(mpc::VERSION_MINOR > minor || mpc::VERSION_PATCHLEVEL >= patchlevel);
830 if mpc::VERSION_MINOR == minor && mpc::VERSION_PATCHLEVEL == patchlevel {
831 assert_eq!(unsafe { tests::str_from_cstr(mpc::get_version()) }, version);
832 assert_eq!(
833 unsafe { tests::str_from_cstr(mpc::VERSION_STRING) },
834 version
835 );
836 }
837 }
838 }
839}