1#![cfg_attr(not(feature = "std"), no_std)]
4#![deny(missing_docs)]
5#![deny(unused)]
6#![deny(clippy::suspicious)]
7#![deny(clippy::float_arithmetic)]
8#![allow(clippy::manual_div_ceil)]
9#![allow(clippy::manual_is_multiple_of)]
10#![allow(clippy::neg_cmp_op_on_partial_ord)]
11#![allow(clippy::len_zero)]
12#![allow(clippy::slow_vector_initialization)]
13#![allow(clippy::comparison_chain)]
14#![allow(clippy::collapsible_else_if)]
15#![allow(clippy::collapsible_if)]
16
17extern crate alloc;
18
19mod ball;
20mod binfmt;
21mod chebyshev;
22mod common;
23mod complex;
24mod complex_airy;
25mod complex_bessel;
26mod complex_ei;
27mod complex_elliptic;
28mod complex_hypergeom;
29mod complex_special;
30mod conv;
31mod csvfmt;
32#[cfg(feature = "hdf5")]
33mod hdf5fmt;
34pub mod ctx;
35mod defs;
36mod dist;
37mod dsp;
38mod ext;
39mod hash;
40mod ieee_soft;
41mod integer;
42mod mantissa;
43mod modular;
44mod num;
45mod ode;
46mod ops;
47mod orthopoly;
48mod parser;
49mod poly;
50mod quadrature;
51mod radix_float;
52#[cfg(any(test, feature = "random"))]
53mod random_dist;
54mod rational;
55mod roots;
56mod strop;
57
58#[cfg(feature = "std")]
59mod for_3rd;
60
61#[doc(hidden)]
62pub mod macro_util;
63
64pub use crate::ball::ziv_round;
65pub use crate::ball::ziv_round_vec;
66pub use crate::ball::Ball;
67pub use crate::ball::ComplexBall;
68pub use crate::binfmt::InlineBinaryBuffer;
69pub use crate::binfmt::BINARY_FLAG_ARRAY;
70pub use crate::binfmt::BINARY_FLAG_HEAP_NEG;
71pub use crate::binfmt::BINARY_FLAG_HEAP_POS;
72pub use crate::binfmt::BINARY_FLAG_INF_NEG;
73pub use crate::binfmt::BINARY_FLAG_INF_POS;
74pub use crate::binfmt::BINARY_FLAG_NAN_BARE;
75pub use crate::binfmt::BINARY_FLAG_NAN_DIV0;
76pub use crate::binfmt::BINARY_FORMAT_VERSION;
77pub use crate::binfmt::BINARY_HEADER_LEN;
78pub use crate::binfmt::BINARY_INLINE_LEN;
79pub use crate::binfmt::BINARY_INLINE_MANT_BITS;
80pub use crate::binfmt::BINARY_INLINE_U32_WORDS;
81pub use crate::binfmt::BINARY_MAX_ELEMS;
82pub use crate::binfmt::BINARY_MAX_U32;
83pub use crate::chebyshev::chebyshev_coeffs;
84pub use crate::chebyshev::chebyshev_error_bound;
85pub use crate::chebyshev::chebyshev_eval;
86pub use crate::chebyshev::clenshaw;
87pub use crate::chebyshev::CHEBYSHEV_MAX_DEGREE;
88pub use crate::common::buf::INLINE_WORDS;
89pub use crate::complex::ExactComplex;
90pub use crate::defs::Error;
91pub use crate::defs::Exponent;
92pub use crate::defs::Radix;
93pub use crate::defs::RoundingMode;
94pub use crate::defs::Sign;
95pub use crate::defs::Word;
96pub use crate::dsp::blackman_window;
97pub use crate::dsp::dct;
98pub use crate::dsp::dst;
99pub use crate::dsp::fft_real;
100pub use crate::dsp::hamming_window;
101pub use crate::dsp::hann_window;
102pub use crate::dsp::idct;
103pub use crate::dsp::idst;
104pub use crate::dsp::ifft_real;
105pub use crate::dsp::kaiser_window;
106pub use crate::dsp::rectangular_window;
107pub use crate::dsp::DSP_MAX_POINTS;
108pub use crate::ext::ExactNum;
109pub use crate::ext::FromExt;
110pub use crate::ext::INF_NEG;
111pub use crate::ext::INF_POS;
112pub use crate::ext::NAN;
113pub use crate::hash::constant_time_eq;
114pub use crate::hash::hmac_sha256;
115pub use crate::hash::sha256;
116pub use crate::hash::sha512;
117pub use crate::ieee_soft::{
118 ExactNumArray, Ieee32, Ieee32Array, Ieee64, Ieee64Array, IEEE_SIMD_LANE_WIDTH,
119};
120pub use crate::integer::ExactInt;
121pub use crate::modular::miller_rabin;
122pub use crate::modular::mod_inv;
123pub use crate::modular::mod_pow;
124pub use crate::modular::pollard_rho;
125pub use crate::modular::POLLARD_RHO_ITER_MAX;
126pub use crate::ode::euler;
127pub use crate::ode::ode_min_step;
128pub use crate::ode::rk4;
129pub use crate::ode::rk45_adaptive;
130pub use crate::ode::ODE_MAX_STEPS;
131pub use crate::ode::ODE_MIN_STEP;
132pub use crate::ops::consts::CachedFBig;
133pub use crate::ops::consts::ConstCache;
134pub use crate::ops::consts::ConstCacheInfo;
135pub use crate::ops::JACOBI_AGM_MAX;
136pub use crate::ops::consts::Consts;
137#[cfg(feature = "std")]
138pub use crate::ops::consts::SharedConsts;
139pub use crate::orthopoly::ORTHOPOLY_N_MAX;
140pub use crate::poly::ExactNumPoly;
141pub use crate::poly::POLY_COMPANION_CLOSED_DEG;
142pub use crate::quadrature::gauss_hermite;
143pub use crate::quadrature::gauss_laguerre;
144pub use crate::quadrature::gauss_legendre;
145pub use crate::quadrature::tanh_sinh;
146pub use crate::quadrature::QUADRATURE_MAX_NODES;
147pub use crate::quadrature::TANH_SINH_LEVELS_MAX;
148pub use crate::radix_float::RadixFloat;
149#[cfg(any(test, feature = "random"))]
150pub use crate::random_dist::RandomDist;
151pub use crate::rational::ExactRational;
152pub use crate::roots::bisect;
153pub use crate::roots::brent;
154pub use crate::roots::illinois;
155pub use crate::roots::newton;
156pub use crate::roots::root_default_tol;
157pub use crate::roots::ROOT_DEFAULT_TOL;
158pub use crate::roots::ROOT_MAX_ITER;
159
160pub use crate::defs::PROPTEST_CASES;
161pub use crate::defs::EXPONENT_BIT_SIZE;
162pub use crate::defs::EXPONENT_MAX;
163pub use crate::defs::EXPONENT_MIN;
164pub use crate::defs::WORD_BASE;
165pub use crate::defs::WORD_BIT_SIZE;
166pub use crate::defs::WORD_MAX;
167pub use crate::defs::WORD_SIGNIFICANT_BIT;
168
169pub use crate::common::util::MAX_PREC_RETRY;
170pub use crate::csvfmt::CSV_MAX_COLS;
171pub use crate::csvfmt::CSV_MAX_ROWS;
172#[cfg(feature = "hdf5")]
173pub use hdf5_rust::{HDF5DType, HDF5Error, Hdf5File};
174
175#[cfg(feature = "random")]
176pub use crate::common::test_rng::{random_seed, reseed_random, seeded_random, DEFAULT_RANDOM_SEED};
177
178#[cfg(test)]
179mod tests {
180
181 #[test]
182 fn test_bigfloat() {
183 use crate::Consts;
184 use crate::ExactNum;
185 use crate::RoundingMode;
186
187 let p = 1024 + 8;
189
190 let rm = RoundingMode::ToEven;
192
193 let mut cc = Consts::new().expect("An error occured when initializing constants");
195
196 let six = ExactNum::from_word(6, 1);
198 let three = ExactNum::from_word(3, p);
199
200 let n = three.sqrt(p, rm);
201 let n = n.reciprocal(p, rm);
202 let n = n.atan(p, rm, &mut cc);
203 let mut pi = six.mul(&n, p, rm);
204
205 pi.set_precision(1024, rm).expect("Precision updated");
207
208 let pi_lib = cc.pi_num(1024, rm).unwrap().into();
210
211 assert_eq!(pi.cmp(&pi_lib), Some(0));
213
214 }
217}