The rugcom
crate provides multiple-precision complex numbers using
GNU MPC, a library for the
arithmetic of complex numbers with arbitrarily high precision and
correct rounding of the result. It is one of a group of four crates:
rugint
for arbitrary-precision integers,rugrat
for arbitrary-precision rational numbers,rugflo
for multiple-precision floating-point numbers, andrugcom
for multiple-precision complex numbers.Documentation for this crate is available.
It can also be helpful to refer to the documentation at the MPC page.
The crate provides the
Complex
type, which holds a multiple-precision complex number.
```rust extern crate rugint; extern crate rugcom; use rugint::Assign; use rugcom::Complex;
fn main() { // Create complex number with 16 bits of precision. let mut com = Complex::new((16, 16)); com.assign((1.5, 3.5)); assert!(com.real() == 1.5); assert!(com.imag() == 3.5); } ```
To use this crate, add rugcom
as a dependency in Cargo.toml
:
toml
[dependencies]
rugcom = "0.1.2"
This crate depends on the low-level bindings in the crate
gmp-mpfr-sys
. This
should be transparent on GNU/Linux and macOS, but may need some work
on Windows. See the gmp-mpfr-sys
README
for some details.
This crate is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
See LICENSE-LGPL and LICENSE-GPL for details.