rug-maths 0.2.2

rug wrapper implementing maths-traits
Documentation

rug-maths

A wrapper for the rug structs, implementing maths-traits traits. It enables computing with arbitrary precision, with algebra & analysis traits.

Example

let z = Complex::with_val(53, (123, 369)); // 123 + 369i
let a = z.real(); // 123
let b = z.imag(); // 369

let n = Integer::from(101);
assert!(n.prime()); // Check primality
assert!(!(n+1).prime());

let a = Integer::from(27);
let b = Integer::from(72);
assert_eq!(a.clone().gcd(b.clone()), Integer::from(9)); // Compute GCD
assert_eq!(a.lcm(b), Integer::from(216)); // Compute LCM

ToDo

Some traits impls and tests are missing. Trigonometric functions should be verified & corrected for Complex.

Due to missing conversion functions in rug and some requirements in maths-traits, some conversions and operations are very ugly and could be longer than simple implementations (useless clones, intermediary conversion into i128, etc). Lots of functions do the same thing by different ways, so please choose carefully. (generally, avoid the more abstract traits)