[][src]Struct rug::Complex

#[repr(transparent)]pub struct Complex { /* fields omitted */ }

A multi-precision complex number with arbitrarily large precision and correct rounding.

The precision has to be set during construction. The rounding method of the required operations can be specified, and the direction of the rounding is returned.

Examples

use rug::{Assign, Complex, Float};
let c = Complex::with_val(53, (40, 30));
assert_eq!(format!("{:.3}", c), "(40.0 30.0)");
let mut f = Float::with_val(53, c.abs_ref());
assert_eq!(f, 50);
f.assign(c.arg_ref());
assert_eq!(f, 0.75_f64.atan());

Operations on two borrowed Complex numbers result in an incomplete-computation value that has to be assigned to a new Complex number.

use rug::Complex;
let a = Complex::with_val(53, (10.5, -11));
let b = Complex::with_val(53, (-1.25, -1.5));
let a_b_ref = &a + &b;
let a_b = Complex::with_val(53, a_b_ref);
assert_eq!(a_b, (9.25, -12.5));

As a special case, when an incomplete-computation value is obtained from multiplying two Complex number references, it can be added to or subtracted from another Complex number (or reference). This will result in a fused multiply-accumulate operation, with only one rounding operation taking place.

use rug::Complex;
let mut acc = Complex::with_val(53, (1000, 1000));
let m1 = Complex::with_val(53, (10, 0));
let m2 = Complex::with_val(53, (1, -1));
// (1000 + 1000i) − (10 + 0i) × (1 − i) = (990 + 1010i)
acc -= &m1 * &m2;
assert_eq!(acc, (990, 1010));

The Complex number type supports various functions. Most methods have four versions:

  1. The first method consumes the operand and rounds the returned Complex number to the nearest representable value.
  2. The second method has a “_mut” suffix, mutates the operand and rounds it the nearest representable value.
  3. The third method has a “_round” suffix, mutates the operand, applies the specified rounding method to the real and imaginary parts, and returns the rounding direction for both:
    • Ordering::Less if the stored part is less than the exact result,
    • Ordering::Equal if the stored part is equal to the exact result,
    • Ordering::Greater if the stored part is greater than the exact result.
  4. The fourth method has a “_ref” suffix and borrows the operand. The returned item is an incomplete-computation value that can be assigned to a Complex number; the rounding method is selected during the assignment.
use core::cmp::Ordering;
use rug::{float::Round, Complex};
let expected = Complex::with_val(53, (1.2985, 0.6350));

// 1. consume the operand, round to nearest
let a = Complex::with_val(53, (1, 1));
let sin_a = a.sin();
assert!(*(sin_a - &expected).abs().real() < 0.0001);

// 2. mutate the operand, round to nearest
let mut b = Complex::with_val(53, (1, 1));
b.sin_mut();
assert!(*(b - &expected).abs().real() < 0.0001);

// 3. mutate the operand, apply specified rounding
let mut c = Complex::with_val(4, (1, 1));
// using 4 significant bits, 1.2985 is rounded down to 1.25
// and 0.6350 is rounded down to 0.625.
let dir = c.sin_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (1.25, 0.625));
assert_eq!(dir, (Ordering::Less, Ordering::Less));

// 4. borrow the operand
let d = Complex::with_val(53, (1, 1));
let r = d.sin_ref();
let sin_d = Complex::with_val(53, r);
assert!(*(sin_d - &expected).abs().real() < 0.0001);
// d was not consumed
assert_eq!(d, (1, 1));

Implementations

impl Complex[src]

pub fn new<P: Prec>(prec: P) -> Self[src]

Create a new Complex number with the specified precisions for the real and imaginary parts and with value 0.

Panics

Panics if the precision is out of the allowed range.

Examples

use rug::Complex;
let c1 = Complex::new(32);
assert_eq!(c1.prec(), (32, 32));
assert_eq!(c1, 0);
let c2 = Complex::new((32, 64));
assert_eq!(c2.prec(), (32, 64));
assert_eq!(c2, 0);

pub fn with_val<P, T>(prec: P, val: T) -> Self where
    Self: Assign<T>,
    P: Prec
[src]

Create a new Complex number with the specified precision and with the given value, rounding to the nearest.

Panics

Panics if prec is out of the allowed range.

Examples

use rug::Complex;
let c1 = Complex::with_val(53, (1.3f64, -12));
assert_eq!(c1.prec(), (53, 53));
assert_eq!(c1, (1.3f64, -12));
let c2 = Complex::with_val(53, 42.0);
assert_eq!(c2.prec(), (53, 53));
assert_eq!(c2, 42);
assert_eq!(c2, (42, 0));

pub fn with_val_round<P, T>(
    prec: P,
    val: T,
    round: (Round, Round)
) -> (Self, (Ordering, Ordering)) where
    Self: AssignRound<T, Round = (Round, Round), Ordering = (Ordering, Ordering)>,
    P: Prec
[src]

Create a new Complex number with the specified precision and with the given value, applying the specified rounding method.

Panics

Panics if prec is out of the allowed range.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let round = (Round::Down, Round::Up);
let (c, dir) = Complex::with_val_round(4, (3.3, 2.3), round);
// 3.3 is rounded down to 3.25, 2.3 is rounded up to 2.5
assert_eq!(c.prec(), (4, 4));
assert_eq!(c, (3.25, 2.5));
assert_eq!(dir, (Ordering::Less, Ordering::Greater));

pub fn prec(&self) -> (u32, u32)[src]

Returns the precision of the real and imaginary parts.

Examples

use rug::Complex;
let r = Complex::new((24, 53));
assert_eq!(r.prec(), (24, 53));

pub fn set_prec<P: Prec>(&mut self, prec: P)[src]

Sets the precision of the real and imaginary parts, rounding to the nearest.

Panics

Panics if the precision is out of the allowed range.

Examples

use rug::Complex;
let mut r = Complex::with_val(6, (4.875, 4.625));
assert_eq!(r, (4.875, 4.625));
r.set_prec(4);
assert_eq!(r, (5.0, 4.5));

pub fn set_prec_round<P: Prec>(
    &mut self,
    prec: P,
    round: (Round, Round)
) -> (Ordering, Ordering)
[src]

Sets the precision of the real and imaginary parts, applying the specified rounding method.

Panics

Panics if the precision is out of the allowed range.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let mut r = Complex::with_val(6, (4.875, 4.625));
assert_eq!(r, (4.875, 4.625));
let dir = r.set_prec_round(4, (Round::Down, Round::Up));
assert_eq!(r, (4.5, 5.0));
assert_eq!(dir, (Ordering::Less, Ordering::Greater));

pub unsafe fn from_raw(raw: mpc_t) -> Self[src]

Creates a Complex number from an initialized MPC complex number.

Safety

  • The value must be initialized.
  • The mpc_t type can be considered as a kind of pointer, so there can be multiple copies of it. Since this function takes over ownership, no other copies of the passed value should exist.

Examples

use gmp_mpfr_sys::mpc;
use core::mem::MaybeUninit;
use rug::Complex;
let c = unsafe {
    let mut m = MaybeUninit::uninit();
    mpc::init3(m.as_mut_ptr(), 53, 53);
    let mut m = m.assume_init();
    mpc::set_d_d(&mut m, -14.5, 3.25, mpc::RNDNN);
    // m is initialized and unique
    Complex::from_raw(m)
};
assert_eq!(c, (-14.5, 3.25));
// since c is a Complex now, deallocation is automatic

pub fn into_raw(self) -> mpc_t[src]

Converts a Complex number into an MPC complex number.

The returned object should be freed to avoid memory leaks.

Examples

use gmp_mpfr_sys::{
    mpc,
    mpfr::{self, rnd_t},
};
use rug::Complex;
let c = Complex::with_val(53, (-14.5, 3.25));
let mut m = c.into_raw();
unsafe {
    let re_ptr = mpc::realref_const(&m);
    let re = mpfr::get_d(re_ptr, rnd_t::RNDN);
    assert_eq!(re, -14.5);
    let im_ptr = mpc::imagref_const(&m);
    let im = mpfr::get_d(im_ptr, rnd_t::RNDN);
    assert_eq!(im, 3.25);
    // free object to prevent memory leak
    mpc::clear(&mut m);
}

pub fn as_raw(&self) -> *const mpc_t[src]

Returns a pointer to the inner MPC complex number.

The returned pointer will be valid for as long as self is valid.

Examples

use gmp_mpfr_sys::{
    mpc,
    mpfr::{self, rnd_t},
};
use rug::Complex;
let c = Complex::with_val(53, (-14.5, 3.25));
let m_ptr = c.as_raw();
unsafe {
    let re_ptr = mpc::realref_const(m_ptr);
    let re = mpfr::get_d(re_ptr, rnd_t::RNDN);
    assert_eq!(re, -14.5);
    let im_ptr = mpc::imagref_const(m_ptr);
    let im = mpfr::get_d(im_ptr, rnd_t::RNDN);
    assert_eq!(im, 3.25);
}
// c is still valid
assert_eq!(c, (-14.5, 3.25));

pub fn as_raw_mut(&mut self) -> *mut mpc_t[src]

Returns an unsafe mutable pointer to the inner MPC complex number.

The returned pointer will be valid for as long as self is valid.

Examples

use gmp_mpfr_sys::mpc;
use rug::Complex;
let mut c = Complex::with_val(53, (-14.5, 3.25));
let m_ptr = c.as_raw_mut();
unsafe {
    mpc::conj(m_ptr, m_ptr, mpc::RNDNN);
}
assert_eq!(c, (-14.5, -3.25));

pub fn parse<S: AsRef<[u8]>>(
    src: S
) -> Result<ParseIncomplete, ParseComplexError>
[src]

Parses a decimal string slice (&str) or byte slice (&[u8]) into a Complex number.

AssignRound<Src> for Complex is implemented with the unwrapped returned incomplete-computation value as Src.

The string can contain either of the following three:

  1. One floating-point number that can be parsed by Float::parse. ASCII whitespace is treated in the same way as well.
  2. Two floating-point numbers inside round brackets separated by one comma. ASCII whitespace is treated in the same way as 1 above, and is also allowed around the brackets and the comma.
  3. Two floating-point numbers inside round brackets separated by ASCII whitespace. Since the real and imaginary parts are separated by whitespace, they themselves cannot contain whitespace. ASCII whitespace is still allowed around the brackets and between the two parts.

Examples

use core::f64;
use rug::Complex;

let valid1 = Complex::parse("(12.5, -13.5)");
let c1 = Complex::with_val(53, valid1.unwrap());
assert_eq!(c1, (12.5, -13.5));
let valid2 = Complex::parse("(inf 0.0)");
let c2 = Complex::with_val(53, valid2.unwrap());
assert_eq!(c2, (f64::INFINITY, 0.0));

let invalid = Complex::parse("(1 2 3)");
assert!(invalid.is_err());

pub fn parse_radix<S: AsRef<[u8]>>(
    src: S,
    radix: i32
) -> Result<ParseIncomplete, ParseComplexError>
[src]

Parses a string slice (&str) or byte slice (&[u8]) into a Complex number.

AssignRound<Src> for Complex is implemented with the unwrapped returned incomplete-computation value as Src.

The string can contain either of the following three:

  1. One floating-point number that can be parsed by Float::parse_radix. ASCII whitespace is treated in the same way as well.
  2. Two floating-point numbers inside round brackets separated by one comma. ASCII whitespace is treated in the same way as 1 above, and is also allowed around the brackets and the comma.
  3. Two floating-point numbers inside round brackets separated by ASCII whitespace. Since the real and imaginary parts are separated by whitespace, they themselves cannot contain whitespace. ASCII whitespace is still allowed around the brackets and between the two parts.

Panics

Panics if radix is less than 2 or greater than 36.

Examples

use core::f64;
use rug::Complex;

let valid1 = Complex::parse_radix("(12, 1a)", 16);
let c1 = Complex::with_val(53, valid1.unwrap());
assert_eq!(c1, (0x12, 0x1a));
let valid2 = Complex::parse_radix("(@inf@ zz)", 36);
let c2 = Complex::with_val(53, valid2.unwrap());
assert_eq!(c2, (f64::INFINITY, 35 * 36 + 35));

let invalid = Complex::parse_radix("(1 2 3)", 10);
assert!(invalid.is_err());

pub fn to_string_radix(&self, radix: i32, num_digits: Option<usize>) -> String[src]

Returns a string representation of the value for the specified radix rounding to the nearest.

The exponent is encoded in decimal. If the number of digits is not specified, the output string will have enough precision such that reading it again will give the exact same number.

Panics

Panics if radix is less than 2 or greater than 36.

Examples

use rug::Complex;
let c1 = Complex::with_val(53, 0);
assert_eq!(c1.to_string_radix(10, None), "(0 0)");
let c2 = Complex::with_val(12, (15, 5));
assert_eq!(c2.to_string_radix(16, None), "(f.000 5.000)");
let c3 = Complex::with_val(53, (10, -4));
assert_eq!(c3.to_string_radix(10, Some(3)), "(10.0 -4.00)");
assert_eq!(c3.to_string_radix(5, Some(3)), "(20.0 -4.00)");
// 2 raised to the power of 80 in hex is 1 followed by 20 zeros
let c4 = Complex::with_val(53, (80f64.exp2(), 0.25));
assert_eq!(c4.to_string_radix(10, Some(3)), "(1.21e24 2.50e-1)");
assert_eq!(c4.to_string_radix(16, Some(3)), "(1.00@20 4.00@-1)");

pub fn to_string_radix_round(
    &self,
    radix: i32,
    num_digits: Option<usize>,
    round: (Round, Round)
) -> String
[src]

Returns a string representation of the value for the specified radix applying the specified rounding method.

The exponent is encoded in decimal. If the number of digits is not specified, the output string will have enough precision such that reading it again will give the exact same number.

Panics

Panics if radix is less than 2 or greater than 36.

Examples

use rug::{float::Round, Complex};
let c = Complex::with_val(10, 10.4);
let down = (Round::Down, Round::Down);
let nearest = (Round::Nearest, Round::Nearest);
let up = (Round::Up, Round::Up);
let nd = c.to_string_radix_round(10, None, down);
assert_eq!(nd, "(10.406 0)");
let nu = c.to_string_radix_round(10, None, up);
assert_eq!(nu, "(10.407 0)");
let sd = c.to_string_radix_round(10, Some(2), down);
assert_eq!(sd, "(10 0)");
let sn = c.to_string_radix_round(10, Some(2), nearest);
assert_eq!(sn, "(10 0)");
let su = c.to_string_radix_round(10, Some(2), up);
assert_eq!(su, "(11 0)");

pub fn real(&self) -> &Float[src]

Borrows the real part as a Float.

Examples

use rug::Complex;
let c = Complex::with_val(53, (12.5, -20.75));
assert_eq!(*c.real(), 12.5)

pub fn imag(&self) -> &Float[src]

Borrows the imaginary part as a Float.

Examples

use rug::Complex;
let c = Complex::with_val(53, (12.5, -20.75));
assert_eq!(*c.imag(), -20.75)

pub fn mut_real(&mut self) -> &mut Float[src]

Borrows the real part mutably.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (12.5, -20.75));
assert_eq!(c, (12.5, -20.75));
*c.mut_real() /= 2;
assert_eq!(c, (6.25, -20.75));

pub fn mut_imag(&mut self) -> &mut Float[src]

Borrows the imaginary part mutably.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (12.5, -20.75));
assert_eq!(c, (12.5, -20.75));
*c.mut_imag() *= 4;
assert_eq!(c, (12.5, -83));

pub fn as_mut_real_imag(&mut self) -> (&mut Float, &mut Float)[src]

Borrows the real and imaginary parts mutably.

Examples

use rug::Complex;

let mut c = Complex::with_val(53, (12.5, -20.75));
{
    let (real, imag) = c.as_mut_real_imag();
    *real /= 2;
    *imag *= 4;
    // borrow ends here
}
assert_eq!(c, (6.25, -83));

pub fn into_real_imag(self) -> (Float, Float)[src]

Consumes and converts the value into real and imaginary Float values.

This function reuses the allocated memory and does not allocate any new memory.

use rug::Complex;
let c = Complex::with_val(53, (12.5, -20.75));
let (real, imag) = c.into_real_imag();
assert_eq!(real, 12.5);
assert_eq!(imag, -20.75);

pub fn as_neg(&self) -> BorrowComplex<'_>[src]

Borrows a negated copy of the Complex number.

The returned object implements Deref<Target = Complex>.

This method performs a shallow copy and negates it, and negation does not change the allocated data.

Examples

use rug::Complex;
let c = Complex::with_val(53, (4.2, -2.3));
let neg_c = c.as_neg();
assert_eq!(*neg_c, (-4.2, 2.3));
// methods taking &self can be used on the returned object
let reneg_c = neg_c.as_neg();
assert_eq!(*reneg_c, (4.2, -2.3));
assert_eq!(*reneg_c, c);

pub fn as_conj(&self) -> BorrowComplex<'_>[src]

Borrows a conjugate copy of the Complex number.

The returned object implements Deref<Target = Complex>.

This method performs a shallow copy and negates its imaginary part, and negation does not change the allocated data.

Examples

use rug::Complex;
let c = Complex::with_val(53, (4.2, -2.3));
let conj_c = c.as_conj();
assert_eq!(*conj_c, (4.2, 2.3));
// methods taking &self can be used on the returned object
let reconj_c = conj_c.as_conj();
assert_eq!(*reconj_c, (4.2, -2.3));
assert_eq!(*reconj_c, c);

pub fn as_mul_i(&self, negative: bool) -> BorrowComplex<'_>[src]

Borrows a rotated copy of the Complex number.

The returned object implements Deref<Target = Complex>.

This method operates by performing some shallow copying; unlike the mul_i method and friends, this method swaps the precision of the real and imaginary parts if they have unequal precisions.

Examples

use rug::Complex;
let c = Complex::with_val(53, (4.2, -2.3));
let mul_i_c = c.as_mul_i(false);
assert_eq!(*mul_i_c, (2.3, 4.2));
// methods taking &self can be used on the returned object
let mul_ii_c = mul_i_c.as_mul_i(false);
assert_eq!(*mul_ii_c, (-4.2, 2.3));
let mul_1_c = mul_i_c.as_mul_i(true);
assert_eq!(*mul_1_c, (4.2, -2.3));
assert_eq!(*mul_1_c, c);

pub fn as_ord(&self) -> &OrdComplex[src]

Borrows the Complex number as an ordered complex number of type OrdComplex.

The same result can be obtained using the implementation of AsRef<OrdComplex> which is provided for Complex.

Examples

use core::cmp::Ordering;
use rug::{float::Special, Complex};

let nan_c = Complex::with_val(53, (Special::Nan, Special::Nan));
let nan = nan_c.as_ord();
assert_eq!(nan.cmp(nan), Ordering::Equal);

let one_neg0_c = Complex::with_val(53, (1, Special::NegZero));
let one_neg0 = one_neg0_c.as_ord();
let one_pos0_c = Complex::with_val(53, (1, Special::Zero));
let one_pos0 = one_pos0_c.as_ord();
assert_eq!(one_neg0.cmp(one_pos0), Ordering::Less);

let zero_inf_s = (Special::Zero, Special::Infinity);
let zero_inf_c = Complex::with_val(53, zero_inf_s);
let zero_inf = zero_inf_c.as_ord();
assert_eq!(one_pos0.cmp(zero_inf), Ordering::Greater);

pub fn eq0(&self) -> bool[src]

Returns the same result as self.eq(&0), but is faster.

Examples

use rug::{float::Special, Assign, Complex};
let mut c = Complex::with_val(53, (Special::NegZero, Special::Zero));
assert!(c.eq0());
c += 5.2;
assert!(!c.eq0());
c.mut_real().assign(Special::Nan);
assert!(!c.eq0());

pub fn cmp_abs(&self, other: &Self) -> Option<Ordering>[src]

Compares the absolute values of self and other.

Examples

use core::cmp::Ordering;
use rug::Complex;
let five = Complex::with_val(53, (5, 0));
let five_rotated = Complex::with_val(53, (3, -4));
let greater_than_five = Complex::with_val(53, (-4, -4));
let has_nan = Complex::with_val(53, (5, 0.0 / 0.0));
assert_eq!(five.cmp_abs(&five_rotated), Some(Ordering::Equal));
assert_eq!(five.cmp_abs(&greater_than_five), Some(Ordering::Less));
assert_eq!(five.cmp_abs(&has_nan), None);

pub fn sum<'a, I>(values: I) -> SumIncomplete<'a, I> where
    I: Iterator<Item = &'a Self>, 
[src]

Adds a list of Complex numbers with correct rounding.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;

// Give each value only 4 bits of precision for example purposes.
let values = [
    Complex::with_val(4, (5.0, 1024.0)),
    Complex::with_val(4, (1024.0, 15.0)),
    Complex::with_val(4, (-1024.0, -1024.0)),
    Complex::with_val(4, (-4.5, -16.0)),
];

// The result should still be exact if it fits.
let r1 = Complex::sum(values.iter());
let sum1 = Complex::with_val(4, r1);
assert_eq!(sum1, (0.5, -1.0));

let r2 = Complex::sum(values.iter());
let sum2 = Complex::with_val(4, (1.0, -1.0)) + r2;
assert_eq!(sum2, (1.5, -2.0));

let r3 = Complex::sum(values.iter());
let mut sum3 = Complex::with_val(4, (16, 16));
sum3 += r3;
// (16.5, 15) rounded to (16, 15)
assert_eq!(sum3, (16, 15));

pub fn dot<'a, I>(values: I) -> DotIncomplete<'a, I> where
    I: Iterator<Item = (&'a Self, &'a Self)>, 
[src]

Finds the dot product of a list of Complex numbers pairs with correct rounding.

The following are implemented with the returned incomplete-computation value as Src:

This method will produce a result with correct rounding, except for some cases where underflow and/or overflow occur in intermediate products.

Examples

use rug::Complex;

let a = [
    Complex::with_val(53, (5.0, 10.25)),
    Complex::with_val(53, (10.25, 5.0)),
];
let b = [
    Complex::with_val(53, (-2.75, -11.5)),
    Complex::with_val(53, (-4.5, 16.0)),
];

let r = Complex::dot(a.iter().zip(b.iter()));
let dot = Complex::with_val(53, r);
let expected = Complex::with_val(53, &a[0] * &b[0]) + &a[1] * &b[1];
assert_eq!(dot, expected);

let r = Complex::dot(a.iter().zip(b.iter()));
let add_dot = Complex::with_val(53, (1.0, 2.0)) + r;
let add_expected = Complex::with_val(53, (1.0, 2.0)) + &expected;
assert_eq!(add_dot, add_expected);

let r = Complex::dot(a.iter().zip(b.iter()));
let mut add_dot2 = Complex::with_val(53, (1.0, 2.0));
add_dot2 += r;
assert_eq!(add_dot2, add_expected);

pub fn mul_add(self, mul: &Self, add: &Self) -> Self[src]

Multiplies and adds in one fused operation, rounding to the nearest with only one rounding error.

a.mul_add(&b, &c) produces a result like &a * &b + &c, but a is consumed and the result produced uses its precision.

Examples

use rug::Complex;
let a = Complex::with_val(53, (10, 0));
let b = Complex::with_val(53, (1, -1));
let c = Complex::with_val(53, (1000, 1000));
// (10 + 0i) × (1 − i) + (1000 + 1000i) = (1010 + 990i)
let mul_add = a.mul_add(&b, &c);
assert_eq!(mul_add, (1010, 990));

pub fn mul_add_mut(&mut self, mul: &Self, add: &Self)[src]

Multiplies and adds in one fused operation, rounding to the nearest with only one rounding error.

a.mul_add_mut(&b, &c) produces a result like &a * &b + &c, but stores the result in a using its precision.

Examples

use rug::Complex;
let mut a = Complex::with_val(53, (10, 0));
let b = Complex::with_val(53, (1, -1));
let c = Complex::with_val(53, (1000, 1000));
// (10 + 0i) × (1 − i) + (1000 + 1000i) = (1010 + 990i)
a.mul_add_mut(&b, &c);
assert_eq!(a, (1010, 990));

pub fn mul_add_round(
    &mut self,
    mul: &Self,
    add: &Self,
    round: (Round, Round)
) -> (Ordering, Ordering)
[src]

Multiplies and adds in one fused operation, applying the specified rounding method with only one rounding error.

a.mul_add_round(&b, &c, round) produces a result like ans.assign_round(&a * &b + &c, round), but stores the result in a using its precision rather than in another Complex number like ans.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let mut a = Complex::with_val(53, (10, 0));
let b = Complex::with_val(53, (1, -1));
let c = Complex::with_val(53, (1000, 1000));
// (10 + 0i) × (1 − i) + (1000 + 1000i) = (1010 + 990i)
let dir = a.mul_add_round(&b, &c, (Round::Nearest, Round::Nearest));
assert_eq!(a, (1010, 990));
assert_eq!(dir, (Ordering::Equal, Ordering::Equal));

pub fn mul_add_ref<'a>(
    &'a self,
    mul: &'a Self,
    add: &'a Self
) -> AddMulIncomplete<'a>
[src]

Multiplies and adds in one fused operation.

The following are implemented with the returned incomplete-computation value as Src:

a.mul_add_ref(&b, &c) produces the exact same result as &a * &b + &c.

Examples

use rug::Complex;
let a = Complex::with_val(53, (10, 0));
let b = Complex::with_val(53, (1, -1));
let c = Complex::with_val(53, (1000, 1000));
// (10 + 0i) × (1 − i) + (1000 + 1000i) = (1010 + 990i)
let ans = Complex::with_val(53, a.mul_add_ref(&b, &c));
assert_eq!(ans, (1010, 990));

pub fn mul_sub(self, mul: &Self, sub: &Self) -> Self[src]

Multiplies and subtracts in one fused operation, rounding to the nearest with only one rounding error.

a.mul_sub(&b, &c) produces a result like &a * &b - &c, but a is consumed and the result produced uses its precision.

Examples

use rug::Complex;
let a = Complex::with_val(53, (10, 0));
let b = Complex::with_val(53, (1, -1));
let c = Complex::with_val(53, (1000, 1000));
// (10 + 0i) × (1 − i) − (1000 + 1000i) = (−990 − 1010i)
let mul_sub = a.mul_sub(&b, &c);
assert_eq!(mul_sub, (-990, -1010));

pub fn mul_sub_mut(&mut self, mul: &Self, sub: &Self)[src]

Multiplies and subtracts in one fused operation, rounding to the nearest with only one rounding error.

a.mul_sub_mut(&b, &c) produces a result like &a * &b - &c, but stores the result in a using its precision.

Examples

use rug::Complex;
let mut a = Complex::with_val(53, (10, 0));
let b = Complex::with_val(53, (1, -1));
let c = Complex::with_val(53, (1000, 1000));
// (10 + 0i) × (1 − i) − (1000 + 1000i) = (−990 − 1010i)
a.mul_sub_mut(&b, &c);
assert_eq!(a, (-990, -1010));

pub fn mul_sub_round(
    &mut self,
    mul: &Self,
    sub: &Self,
    round: (Round, Round)
) -> (Ordering, Ordering)
[src]

Multiplies and subtracts in one fused operation, applying the specified rounding method with only one rounding error.

a.mul_sub_round(&b, &c, round) produces a result like ans.assign_round(&a * &b - &c, round), but stores the result in a using its precision rather than in another Complex number like ans.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let mut a = Complex::with_val(53, (10, 0));
let b = Complex::with_val(53, (1, -1));
let c = Complex::with_val(53, (1000, 1000));
// (10 + 0i) × (1 − i) − (1000 + 1000i) = (−990 − 1010i)
let dir = a.mul_sub_round(&b, &c, (Round::Nearest, Round::Nearest));
assert_eq!(a, (-990, -1010));
assert_eq!(dir, (Ordering::Equal, Ordering::Equal));

pub fn mul_sub_ref<'a>(
    &'a self,
    mul: &'a Self,
    sub: &'a Self
) -> SubMulFromIncomplete<'a>
[src]

Multiplies and subtracts in one fused operation.

The following are implemented with the returned incomplete-computation value as Src:

a.mul_sub_ref(&b, &c) produces the exact same result as &a * &b - &c.

Examples

use rug::Complex;
let a = Complex::with_val(53, (10, 0));
let b = Complex::with_val(53, (1, -1));
let c = Complex::with_val(53, (1000, 1000));
// (10 + 0i) × (1 − i) − (1000 + 1000i) = (−990 − 1010i)
let ans = Complex::with_val(53, a.mul_sub_ref(&b, &c));
assert_eq!(ans, (-990, -1010));

pub fn proj(self) -> Self[src]

Computes a projection onto the Riemann sphere, rounding to the nearest.

If no parts of the number are infinite, the result is unchanged. If any part is infinite, the real part of the result is set to +∞ and the imaginary part of the result is set to 0 with the same sign as the imaginary part of the input.

Examples

use core::f64;
use rug::Complex;
let c1 = Complex::with_val(53, (1.5, 2.5));
let proj1 = c1.proj();
assert_eq!(proj1, (1.5, 2.5));
let c2 = Complex::with_val(53, (f64::NAN, f64::NEG_INFINITY));
let proj2 = c2.proj();
assert_eq!(proj2, (f64::INFINITY, 0.0));
// imaginary was negative, so now it is minus zero
assert!(proj2.imag().is_sign_negative());

pub fn proj_mut(&mut self)[src]

Computes a projection onto the Riemann sphere, rounding to the nearest.

If no parts of the number are infinite, the result is unchanged. If any part is infinite, the real part of the result is set to +∞ and the imaginary part of the result is set to 0 with the same sign as the imaginary part of the input.

Examples

use core::f64;
use rug::Complex;
let mut c1 = Complex::with_val(53, (1.5, 2.5));
c1.proj_mut();
assert_eq!(c1, (1.5, 2.5));
let mut c2 = Complex::with_val(53, (f64::NAN, f64::NEG_INFINITY));
c2.proj_mut();
assert_eq!(c2, (f64::INFINITY, 0.0));
// imaginary was negative, so now it is minus zero
assert!(c2.imag().is_sign_negative());

pub fn proj_ref(&self) -> ProjIncomplete<'_>[src]

Computes the projection onto the Riemann sphere.

If no parts of the number are infinite, the result is unchanged. If any part is infinite, the real part of the result is set to +∞ and the imaginary part of the result is set to 0 with the same sign as the imaginary part of the input.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use core::f64;
use rug::Complex;
let c1 = Complex::with_val(53, (f64::INFINITY, 50));
let proj1 = Complex::with_val(53, c1.proj_ref());
assert_eq!(proj1, (f64::INFINITY, 0.0));
let c2 = Complex::with_val(53, (f64::NAN, f64::NEG_INFINITY));
let proj2 = Complex::with_val(53, c2.proj_ref());
assert_eq!(proj2, (f64::INFINITY, 0.0));
// imaginary was negative, so now it is minus zero
assert!(proj2.imag().is_sign_negative());

pub fn square(self) -> Self[src]

Computes the square, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, -2));
// (1 − 2i) squared is (−3 − 4i)
let square = c.square();
assert_eq!(square, (-3, -4));

pub fn square_mut(&mut self)[src]

Computes the square, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, -2));
// (1 − 2i) squared is (−3 − 4i)
c.square_mut();
assert_eq!(c, (-3, -4));

pub fn square_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the square, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let mut c = Complex::with_val(4, (1.25, 1.25));
// (1.25 + 1.25i) squared is (0 + 3.125i).
// With 4 bits of precision, 3.125 is rounded down to 3.
let dir = c.square_round((Round::Down, Round::Down));
assert_eq!(c, (0, 3));
assert_eq!(dir, (Ordering::Equal, Ordering::Less));

pub fn square_ref(&self) -> SquareIncomplete<'_>[src]

Computes the square.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let c = Complex::with_val(53, (1.25, 1.25));
// (1.25 + 1.25i) squared is (0 + 3.125i).
let r = c.square_ref();
// With 4 bits of precision, 3.125 is rounded down to 3.
let round = (Round::Down, Round::Down);
let (square, dir) = Complex::with_val_round(4, r, round);
assert_eq!(square, (0, 3));
assert_eq!(dir, (Ordering::Equal, Ordering::Less));

pub fn sqrt(self) -> Self[src]

Computes the square root, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (-1, 0));
// square root of (−1 + 0i) is (0 + i)
let sqrt = c.sqrt();
assert_eq!(sqrt, (0, 1));

pub fn sqrt_mut(&mut self)[src]

Computes the square root, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (-1, 0));
// square root of (−1 + 0i) is (0 + i)
c.sqrt_mut();
assert_eq!(c, (0, 1));

pub fn sqrt_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the square root, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let mut c = Complex::with_val(4, (2, 2.25));
// Square root of (2 + 2.25i) is (1.5828 + 0.7108i).
// Nearest with 4 bits of precision: (1.625 + 0.6875i)
let dir = c.sqrt_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (1.625, 0.6875));
assert_eq!(dir, (Ordering::Greater, Ordering::Less));

pub fn sqrt_ref(&self) -> SqrtIncomplete<'_>[src]

Computes the square root.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let c = Complex::with_val(53, (2, 2.25));
// Square root of (2 + 2.25i) is (1.5828 + 0.7108i).
let r = c.sqrt_ref();
// Nearest with 4 bits of precision: (1.625 + 0.6875i)
let nearest = (Round::Nearest, Round::Nearest);
let (sqrt, dir) = Complex::with_val_round(4, r, nearest);
assert_eq!(sqrt, (1.625, 0.6875));
assert_eq!(dir, (Ordering::Greater, Ordering::Less));

pub fn conj(self) -> Self[src]

Computes the complex conjugate.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1.5, 2.5));
let conj = c.conj();
assert_eq!(conj, (1.5, -2.5));

pub fn conj_mut(&mut self)[src]

Computes the complex conjugate.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1.5, 2.5));
c.conj_mut();
assert_eq!(c, (1.5, -2.5));

pub fn conj_ref(&self) -> ConjIncomplete<'_>[src]

Computes the complex conjugate.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1.5, 2.5));
let conj = Complex::with_val(53, c.conj_ref());
assert_eq!(conj, (1.5, -2.5));

pub fn abs(self) -> Complex[src]

Computes the absolute value, rounding to the nearest.

The real part is set to the absolute value and the imaginary part is set to zero.

Examples

use rug::Complex;
let c = Complex::with_val(53, (30, 40));
let abs = c.abs();
assert_eq!(abs, 50);

pub fn abs_mut(&mut self)[src]

Computes the absolute value, rounding to the nearest.

The real part is set to the absolute value and the imaginary part is set to zero.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (30, 40));
c.abs_mut();
assert_eq!(c, (50, 0));

pub fn abs_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the absolute value, applying the specified rounding method.

The real part is set to the absolute value and the imaginary part is set to zero.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (30, 40));
// 50 rounded up using 4 bits is 52
let dir = c.abs_round((Round::Up, Round::Up));
assert_eq!(c, (52, 0));
assert_eq!(dir, (Ordering::Greater, Ordering::Equal));

pub fn abs_ref(&self) -> AbsIncomplete<'_>[src]

Computes the absolute value.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::{Complex, Float};
let c = Complex::with_val(53, (30, 40));
let f = Float::with_val(53, c.abs_ref());
assert_eq!(f, 50);

pub fn arg(self) -> Complex[src]

Computes the argument, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (4, 3));
let f = c.arg();
assert_eq!(f, 0.75_f64.atan());

Special values are handled like atan2 in IEEE 754-2008.

use rug::Complex;
let c = Complex::with_val(53, (40, 30));
let arg = c.arg();
assert_eq!(arg, (0.75_f64.atan(), 0));

pub fn arg_mut(&mut self)[src]

Computes the argument, rounding to the nearest.

The real part is set to the argument and the imaginary part is set to zero.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (40, 30));
c.arg_mut();
assert_eq!(c, (0.75_f64.atan(), 0));

pub fn arg_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the argument, applying the specified rounding method.

The real part is set to the argument and the imaginary part is set to zero.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// use only 4 bits of precision
let mut c = Complex::with_val(4, (3, 4));
// arg(3 + 4i) = 0.9316.
// 0.9316 rounded to the nearest is 0.9375.
let dir = c.arg_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.9375, 0));
assert_eq!(dir, (Ordering::Greater, Ordering::Equal));

pub fn arg_ref(&self) -> ArgIncomplete<'_>[src]

Computes the argument.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use core::f64;
use rug::{Assign, Complex, Float};
// f has precision 53, just like f64, so PI constants match.
let mut arg = Float::new(53);
let c_pos = Complex::with_val(53, 1);
arg.assign(c_pos.arg_ref());
assert!(arg.is_zero());
let c_neg = Complex::with_val(53, -1.3);
arg.assign(c_neg.arg_ref());
assert_eq!(arg, f64::consts::PI);
let c_pi_4 = Complex::with_val(53, (1.333, 1.333));
arg.assign(c_pi_4.arg_ref());
assert_eq!(arg, f64::consts::FRAC_PI_4);

pub fn mul_i(self, negative: bool) -> Self[src]

Multiplies the complex number by ±i, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (13, 24));
let rot1 = c.mul_i(false);
assert_eq!(rot1, (-24, 13));
let rot2 = rot1.mul_i(false);
assert_eq!(rot2, (-13, -24));
let rot2_less1 = rot2.mul_i(true);
assert_eq!(rot2_less1, (-24, 13));

pub fn mul_i_mut(&mut self, negative: bool)[src]

Multiplies the complex number by ±i, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (13, 24));
c.mul_i_mut(false);
assert_eq!(c, (-24, 13));
c.mul_i_mut(false);
assert_eq!(c, (-13, -24));
c.mul_i_mut(true);
assert_eq!(c, (-24, 13));

pub fn mul_i_round(
    &mut self,
    negative: bool,
    round: (Round, Round)
) -> (Ordering, Ordering)
[src]

Multiplies the complex number by ±i, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// only 4 bits of precision for imaginary part
let mut c = Complex::with_val((53, 4), (127, 15));
assert_eq!(c, (127, 15));
let dir = c.mul_i_round(false, (Round::Down, Round::Down));
assert_eq!(c, (-15, 120));
assert_eq!(dir, (Ordering::Equal, Ordering::Less));
let dir = c.mul_i_round(true, (Round::Down, Round::Down));
assert_eq!(c, (120, 15));
assert_eq!(dir, (Ordering::Equal, Ordering::Equal));

pub fn mul_i_ref(&self, negative: bool) -> MulIIncomplete<'_>[src]

Multiplies the complex number by ±i.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (13, 24));
let rotated = Complex::with_val(53, c.mul_i_ref(false));
assert_eq!(rotated, (-24, 13));

pub fn recip(self) -> Self[src]

Computes the reciprocal, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
// 1/(1 + i) = (0.5 − 0.5i)
let recip = c.recip();
assert_eq!(recip, (0.5, -0.5));

pub fn recip_mut(&mut self)[src]

Computes the reciprocal, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
// 1/(1 + i) = (0.5 − 0.5i)
c.recip_mut();
assert_eq!(c, (0.5, -0.5));

pub fn recip_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the reciprocal, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
let mut c = Complex::with_val(4, (1, 2));
// 1/(1 + 2i) = (0.2 − 0.4i), binary (0.00110011..., −0.01100110...)
// 4 bits of precision: (0.001101, −0.01101) = (13/64, −13/32)
let dir = c.recip_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (13.0/64.0, -13.0/32.0));
assert_eq!(dir, (Ordering::Greater, Ordering::Less));

pub fn recip_ref(&self) -> RecipIncomplete<'_>[src]

Computes the reciprocal.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
// 1/(1 + i) = (0.5 − 0.5i)
let recip = Complex::with_val(53, c.recip_ref());
assert_eq!(recip, (0.5, -0.5));

pub fn norm(self) -> Complex[src]

Computes the norm, that is the square of the absolute value, rounding it to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (3, 4));
let norm = c.norm();
assert_eq!(norm, 25);

pub fn norm_mut(&mut self)[src]

Computes the norm, that is the square of the absolute value, rounding to the nearest.

The real part is set to the norm and the imaginary part is set to zero.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (3, 4));
c.norm_mut();
assert_eq!(c, (25, 0));

pub fn norm_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the norm, that is the square of the absolute value, applying the specified rounding method.

The real part is set to the norm and the imaginary part is set to zero.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// use only 4 bits of precision
let mut c = Complex::with_val(4, (3, 4));
// 25 rounded up using 4 bits is 26
let dir = c.norm_round((Round::Up, Round::Up));
assert_eq!(c, (26, 0));
assert_eq!(dir, (Ordering::Greater, Ordering::Equal));

pub fn norm_ref(&self) -> NormIncomplete<'_>[src]

Computes the norm, that is the square of the absolute value.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::{Complex, Float};
let c = Complex::with_val(53, (3, 4));
let f = Float::with_val(53, c.norm_ref());
assert_eq!(f, 25);

pub fn ln(self) -> Self[src]

Computes the natural logarithm, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1.5, -0.5));
let ln = c.ln();
let expected = Complex::with_val(53, (0.4581, -0.3218));
assert!(*(ln - expected).abs().real() < 0.0001);

pub fn ln_mut(&mut self)[src]

Computes the natural logarithm, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1.5, -0.5));
c.ln_mut();
let expected = Complex::with_val(53, (0.4581, -0.3218));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn ln_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the natural logarithm, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1.5, -0.5));
// ln(1.5 − 0.5i) = (0.4581 − 0.3218i)
// using 4 significant bits: (0.46875 − 0.3125i)
let dir = c.ln_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.46875, -0.3125));
assert_eq!(dir, (Ordering::Greater, Ordering::Greater));

pub fn ln_ref(&self) -> LnIncomplete<'_>[src]

Computes the natural logarithm;

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1.5, -0.5));
let ln = Complex::with_val(53, c.ln_ref());
let expected = Complex::with_val(53, (0.4581, -0.3218));
assert!(*(ln - expected).abs().real() < 0.0001);

pub fn log10(self) -> Self[src]

Computes the logarithm to base 10, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1.5, -0.5));
let log10 = c.log10();
let expected = Complex::with_val(53, (0.1990, -0.1397));
assert!(*(log10 - expected).abs().real() < 0.0001);

pub fn log10_mut(&mut self)[src]

Computes the logarithm to base 10, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1.5, -0.5));
c.log10_mut();
let expected = Complex::with_val(53, (0.1990, -0.1397));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn log10_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the logarithm to base 10, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1.5, -0.5));
// log10(1.5 − 0.5i) = (0.1990 − 0.1397i)
// using 4 significant bits: (0.203125 − 0.140625i)
let dir = c.log10_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.203125, -0.140625));
assert_eq!(dir, (Ordering::Greater, Ordering::Less));

pub fn log10_ref(&self) -> Log10Incomplete<'_>[src]

Computes the logarithm to base 10.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1.5, -0.5));
let log10 = Complex::with_val(53, c.log10_ref());
let expected = Complex::with_val(53, (0.1990, -0.1397));
assert!(*(log10 - expected).abs().real() < 0.0001);

pub fn root_of_unity(n: u32, k: u32) -> RootOfUnityIncomplete[src]

Generates a root of unity, rounding to the nearest.

The generated number is the nth root of unity raised to the power k, that is its magnitude is 1 and its argument is 2πk/n.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let r = Complex::root_of_unity(3, 2);
let c = Complex::with_val(53, r);
let expected = Complex::with_val(53, (-0.5, -0.8660));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn exp(self) -> Self[src]

Computes the exponential, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (0.5, -0.75));
let exp = c.exp();
let expected = Complex::with_val(53, (1.2064, -1.1238));
assert!(*(exp - expected).abs().real() < 0.0001);

pub fn exp_mut(&mut self)[src]

Computes the exponential, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (0.5, -0.75));
c.exp_mut();
let expected = Complex::with_val(53, (1.2064, -1.1238));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn exp_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the exponential, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (0.5, -0.75));
// exp(0.5 − 0.75i) = (1.2064 − 1.1238i)
// using 4 significant bits: (1.25 − 1.125)
let dir = c.exp_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (1.25, -1.125));
assert_eq!(dir, (Ordering::Greater, Ordering::Less));

pub fn exp_ref(&self) -> ExpIncomplete<'_>[src]

Computes the exponential.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (0.5, -0.75));
let exp = Complex::with_val(53, c.exp_ref());
let expected = Complex::with_val(53, (1.2064, -1.1238));
assert!(*(exp - expected).abs().real() < 0.0001);

pub fn sin(self) -> Self[src]

Computes the sine, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let sin = c.sin();
let expected = Complex::with_val(53, (1.2985, 0.6350));
assert!(*(sin - expected).abs().real() < 0.0001);

pub fn sin_mut(&mut self)[src]

Computes the sine, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.sin_mut();
let expected = Complex::with_val(53, (1.2985, 0.6350));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn sin_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the sine, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// sin(1 + i) = (1.2985 + 0.6350i)
// using 4 significant bits: (1.25 + 0.625i)
let dir = c.sin_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (1.25, 0.625));
assert_eq!(dir, (Ordering::Less, Ordering::Less));

pub fn sin_ref(&self) -> SinIncomplete<'_>[src]

Computes the sine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let sin = Complex::with_val(53, c.sin_ref());
let expected = Complex::with_val(53, (1.2985, 0.6350));
assert!(*(sin - expected).abs().real() < 0.0001);

pub fn cos(self) -> Self[src]

Computes the cosine, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let cos = c.cos();
let expected = Complex::with_val(53, (0.8337, -0.9889));
assert!(*(cos - expected).abs().real() < 0.0001);

pub fn cos_mut(&mut self)[src]

Computes the cosine, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.cos_mut();
let expected = Complex::with_val(53, (0.8337, -0.9889));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn cos_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the cosine, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// cos(1 + i) = (0.8337 − 0.9889i)
// using 4 significant bits: (0.8125 − i)
let dir = c.cos_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.8125, -1));
assert_eq!(dir, (Ordering::Less, Ordering::Less));

pub fn cos_ref(&self) -> CosIncomplete<'_>[src]

Computes the cosine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let cos = Complex::with_val(53, c.cos_ref());
let expected = Complex::with_val(53, (0.8337, -0.9889));
assert!(*(cos - expected).abs().real() < 0.0001);

pub fn sin_cos(self, cos: Self) -> (Self, Self)[src]

Computes the sine and cosine of self, rounding to the nearest.

The sine keeps the precision of self while the cosine keeps the precision of cos.

The initial value of cos is ignored.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let (sin, cos) = c.sin_cos(Complex::new(53));
let expected_sin = Complex::with_val(53, (1.2985, 0.6350));
let expected_cos = Complex::with_val(53, (0.8337, -0.9889));
assert!(*(sin - expected_sin).abs().real() < 0.0001);
assert!(*(cos - expected_cos).abs().real() < 0.0001);

pub fn sin_cos_mut(&mut self, cos: &mut Self)[src]

Computes the sine and cosine of self, rounding to the nearest.

The sine is stored in self and keeps its precision, while the cosine is stored in cos keeping its precision.

The initial value of cos is ignored.

Examples

use rug::Complex;
let mut sin = Complex::with_val(53, (1, 1));
let mut cos = Complex::new(53);
sin.sin_cos_mut(&mut cos);
let expected_sin = Complex::with_val(53, (1.2985, 0.6350));
let expected_cos = Complex::with_val(53, (0.8337, -0.9889));
assert!(*(sin - expected_sin).abs().real() < 0.0001);
assert!(*(cos - expected_cos).abs().real() < 0.0001);

pub fn sin_cos_round(
    &mut self,
    cos: &mut Self,
    round: (Round, Round)
) -> ((Ordering, Ordering), (Ordering, Ordering))
[src]

Computes the sine and cosine of self, applying the specified rounding methods.

The sine is stored in self and keeps its precision, while the cosine is stored in cos keeping its precision.

The initial value of cos is ignored.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut sin = Complex::with_val(4, (1, 1));
let mut cos = Complex::new(4);
// sin(1 + i) = (1.2985 + 0.6350)
// using 4 significant bits: (1.25 + 0.625i)
// cos(1 + i) = (0.8337 − 0.9889i)
// using 4 significant bits: (0.8125 − i)
let (dir_sin, dir_cos) =
    sin.sin_cos_round(&mut cos, (Round::Nearest, Round::Nearest));
assert_eq!(sin, (1.25, 0.625));
assert_eq!(dir_sin, (Ordering::Less, Ordering::Less));
assert_eq!(cos, (0.8125, -1));
assert_eq!(dir_cos, (Ordering::Less, Ordering::Less));

pub fn sin_cos_ref(&self) -> SinCosIncomplete<'_>[src]

Computes the sine and cosine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use core::cmp::Ordering;
use rug::{float::Round, ops::AssignRound, Assign, Complex};
let phase = Complex::with_val(53, (1, 1));

let (mut sin, mut cos) = (Complex::new(53), Complex::new(53));
let sin_cos = phase.sin_cos_ref();
(&mut sin, &mut cos).assign(sin_cos);
let expected_sin = Complex::with_val(53, (1.2985, 0.6350));
let expected_cos = Complex::with_val(53, (0.8337, -0.9889));
assert!(*(sin - expected_sin).abs().real() < 0.0001);
assert!(*(cos - expected_cos).abs().real() < 0.0001);

// using 4 significant bits: sin = (1.25 + 0.625i)
// using 4 significant bits: cos = (0.8125 − i)
let (mut sin_4, mut cos_4) = (Complex::new(4), Complex::new(4));
let sin_cos = phase.sin_cos_ref();
let (dir_sin, dir_cos) = (&mut sin_4, &mut cos_4)
    .assign_round(sin_cos, (Round::Nearest, Round::Nearest));
assert_eq!(sin_4, (1.25, 0.625));
assert_eq!(dir_sin, (Ordering::Less, Ordering::Less));
assert_eq!(cos_4, (0.8125, -1));
assert_eq!(dir_cos, (Ordering::Less, Ordering::Less));

pub fn tan(self) -> Self[src]

Computes the tangent, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let tan = c.tan();
let expected = Complex::with_val(53, (0.2718, 1.0839));
assert!(*(tan - expected).abs().real() < 0.0001);

pub fn tan_mut(&mut self)[src]

Computes the tangent, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.tan_mut();
let expected = Complex::with_val(53, (0.2718, 1.0839));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn tan_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the tangent, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// tan(1 + i) = (0.2718 + 1.0839)
// using 4 significant bits: (0.28125 + 1.125i)
let dir = c.tan_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.28125, 1.125));
assert_eq!(dir, (Ordering::Greater, Ordering::Greater));

pub fn tan_ref(&self) -> TanIncomplete<'_>[src]

Computes the tangent.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let tan = Complex::with_val(53, c.tan_ref());
let expected = Complex::with_val(53, (0.2718, 1.0839));
assert!(*(tan - expected).abs().real() < 0.0001);

pub fn sinh(self) -> Self[src]

Computes the hyperbolic sine, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let sinh = c.sinh();
let expected = Complex::with_val(53, (0.6350, 1.2985));
assert!(*(sinh - expected).abs().real() < 0.0001);

pub fn sinh_mut(&mut self)[src]

Computes the hyperbolic sine, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.sinh_mut();
let expected = Complex::with_val(53, (0.6350, 1.2985));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn sinh_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the hyperbolic sine, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// sinh(1 + i) = (0.6350 + 1.2985i)
// using 4 significant bits: (0.625 + 1.25i)
let dir = c.sinh_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.625, 1.25));
assert_eq!(dir, (Ordering::Less, Ordering::Less));

pub fn sinh_ref(&self) -> SinhIncomplete<'_>[src]

Computes the hyperbolic sine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let sinh = Complex::with_val(53, c.sinh_ref());
let expected = Complex::with_val(53, (0.6350, 1.2985));
assert!(*(sinh - expected).abs().real() < 0.0001);

pub fn cosh(self) -> Self[src]

Computes the hyperbolic cosine, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let cosh = c.cosh();
let expected = Complex::with_val(53, (0.8337, 0.9889));
assert!(*(cosh - expected).abs().real() < 0.0001);

pub fn cosh_mut(&mut self)[src]

Computes the hyperbolic cosine, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.cosh_mut();
let expected = Complex::with_val(53, (0.8337, 0.9889));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn cosh_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the hyperbolic cosine, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// cosh(1 + i) = (0.8337 + 0.9889)
// using 4 significant bits: (0.8125 + i)
let dir = c.cosh_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.8125, 1));
assert_eq!(dir, (Ordering::Less, Ordering::Greater));

pub fn cosh_ref(&self) -> CoshIncomplete<'_>[src]

Computes the hyperbolic cosine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let cosh = Complex::with_val(53, c.cosh_ref());
let expected = Complex::with_val(53, (0.8337, 0.9889));
assert!(*(cosh - expected).abs().real() < 0.0001);

pub fn tanh(self) -> Self[src]

Computes the hyperbolic tangent, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let tanh = c.tanh();
let expected = Complex::with_val(53, (1.0839, 0.2718));
assert!(*(tanh - expected).abs().real() < 0.0001);

pub fn tanh_mut(&mut self)[src]

Computes the hyperbolic tangent, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.tanh_mut();
let expected = Complex::with_val(53, (1.0839, 0.2718));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn tanh_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the hyperbolic tangent, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// tanh(1 + i) = (1.0839 + 0.2718i)
// using 4 significant bits: (1.125 + 0.28125i)
let dir = c.tanh_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (1.125, 0.28125));
assert_eq!(dir, (Ordering::Greater, Ordering::Greater));

pub fn tanh_ref(&self) -> TanhIncomplete<'_>[src]

Computes the hyperbolic tangent.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let tanh = Complex::with_val(53, c.tanh_ref());
let expected = Complex::with_val(53, (1.0839, 0.2718));
assert!(*(tanh - expected).abs().real() < 0.0001);

pub fn asin(self) -> Self[src]

Computes the inverse sine, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let asin = c.asin();
let expected = Complex::with_val(53, (0.6662, 1.0613));
assert!(*(asin - expected).abs().real() < 0.0001);

pub fn asin_mut(&mut self)[src]

Computes the inverse sine, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.asin_mut();
let expected = Complex::with_val(53, (0.6662, 1.0613));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn asin_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the inverse sine, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// asin(1 + i) = (0.6662 + 1.0613i)
// using 4 significant bits: (0.6875 + i)
let dir = c.asin_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.6875, 1));
assert_eq!(dir, (Ordering::Greater, Ordering::Less));

pub fn asin_ref(&self) -> AsinIncomplete<'_>[src]

Computes the inverse sine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let asin = Complex::with_val(53, c.asin_ref());
let expected = Complex::with_val(53, (0.6662, 1.0613));
assert!(*(asin - expected).abs().real() < 0.0001);

pub fn acos(self) -> Self[src]

Computes the inverse cosine, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let acos = c.acos();
let expected = Complex::with_val(53, (0.9046, -1.0613));
assert!(*(acos - expected).abs().real() < 0.0001);

pub fn acos_mut(&mut self)[src]

Computes the inverse cosine, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.acos_mut();
let expected = Complex::with_val(53, (0.9046, -1.0613));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn acos_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the inverse cosine, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// acos(1 + i) = (0.9046 − 1.0613i)
// using 4 significant bits: (0.875 − i)
let dir = c.acos_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.875, -1));
assert_eq!(dir, (Ordering::Less, Ordering::Greater));

pub fn acos_ref(&self) -> AcosIncomplete<'_>[src]

Computes the inverse cosine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let acos = Complex::with_val(53, c.acos_ref());
let expected = Complex::with_val(53, (0.9046, -1.0613));
assert!(*(acos - expected).abs().real() < 0.0001);

pub fn atan(self) -> Self[src]

Computes the inverse tangent, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let atan = c.atan();
let expected = Complex::with_val(53, (1.0172, 0.4024));
assert!(*(atan - expected).abs().real() < 0.0001);

pub fn atan_mut(&mut self)[src]

Computes the inverse tangent, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.atan_mut();
let expected = Complex::with_val(53, (1.0172, 0.4024));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn atan_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the inverse tangent, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// atan(1 + i) = (1.0172 + 0.4024i)
// using 4 significant bits: (1 + 0.40625i)
let dir = c.atan_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (1, 0.40625));
assert_eq!(dir, (Ordering::Less, Ordering::Greater));

pub fn atan_ref(&self) -> AtanIncomplete<'_>[src]

Computes the inverse tangent.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let atan = Complex::with_val(53, c.atan_ref());
let expected = Complex::with_val(53, (1.0172, 0.4024));
assert!(*(atan - expected).abs().real() < 0.0001);

pub fn asinh(self) -> Self[src]

Computes the inverse hyperbolic sine, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let asinh = c.asinh();
let expected = Complex::with_val(53, (1.0613, 0.6662));
assert!(*(asinh - expected).abs().real() < 0.0001);

pub fn asinh_mut(&mut self)[src]

Computes the inverse hyperbolic sine, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.asinh_mut();
let expected = Complex::with_val(53, (1.0613, 0.6662));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn asinh_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the inverse hyperbolic sine, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// asinh(1 + i) = (1.0613 + 0.6662i)
// using 4 significant bits: (1 + 0.6875i)
let dir = c.asinh_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (1, 0.6875));
assert_eq!(dir, (Ordering::Less, Ordering::Greater));

pub fn asinh_ref(&self) -> AsinhIncomplete<'_>[src]

Computes the inverse hyperboic sine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let asinh = Complex::with_val(53, c.asinh_ref());
let expected = Complex::with_val(53, (1.0613, 0.6662));
assert!(*(asinh - expected).abs().real() < 0.0001);

pub fn acosh(self) -> Self[src]

Computes the inverse hyperbolic cosine, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let acosh = c.acosh();
let expected = Complex::with_val(53, (1.0613, 0.9046));
assert!(*(acosh - expected).abs().real() < 0.0001);

pub fn acosh_mut(&mut self)[src]

Computes the inverse hyperbolic cosine, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.acosh_mut();
let expected = Complex::with_val(53, (1.0613, 0.9046));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn acosh_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the inverse hyperbolic cosine, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// acosh(1 + i) = (1.0613 + 0.9046i)
// using 4 significant bits: (1 + 0.875i)
let dir = c.acosh_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (1, 0.875));
assert_eq!(dir, (Ordering::Less, Ordering::Less));

pub fn acosh_ref(&self) -> AcoshIncomplete<'_>[src]

Computes the inverse hyperbolic cosine.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let acosh = Complex::with_val(53, c.acosh_ref());
let expected = Complex::with_val(53, (1.0613, 0.9046));
assert!(*(acosh - expected).abs().real() < 0.0001);

pub fn atanh(self) -> Self[src]

Computes the inverse hyperbolic tangent, rounding to the nearest.

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let atanh = c.atanh();
let expected = Complex::with_val(53, (0.4024, 1.0172));
assert!(*(atanh - expected).abs().real() < 0.0001);

pub fn atanh_mut(&mut self)[src]

Computes the inverse hyperbolic tangent, rounding to the nearest.

Examples

use rug::Complex;
let mut c = Complex::with_val(53, (1, 1));
c.atanh_mut();
let expected = Complex::with_val(53, (0.4024, 1.0172));
assert!(*(c - expected).abs().real() < 0.0001);

pub fn atanh_round(&mut self, round: (Round, Round)) -> (Ordering, Ordering)[src]

Computes the inverse hyperbolic tangent, applying the specified rounding method.

Examples

use core::cmp::Ordering;
use rug::{float::Round, Complex};
// Use only 4 bits of precision to show rounding.
let mut c = Complex::with_val(4, (1, 1));
// atanh(1 + i) = (0.4024 + 1.0172i)
// using 4 significant bits: (0.40625 + i)
let dir = c.atanh_round((Round::Nearest, Round::Nearest));
assert_eq!(c, (0.40625, 1));
assert_eq!(dir, (Ordering::Greater, Ordering::Less));

pub fn atanh_ref(&self) -> AtanhIncomplete<'_>[src]

Computes the inverse hyperbolic tangent.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::Complex;
let c = Complex::with_val(53, (1, 1));
let atanh = Complex::with_val(53, c.atanh_ref());
let expected = Complex::with_val(53, (0.4024, 1.0172));
assert!(*(atanh - expected).abs().real() < 0.0001);

pub fn random_bits(rng: &mut dyn MutRandState) -> RandomBitsIncomplete<'_>[src]

Generates a random complex number with both the real and imaginary parts in the range 0 ≤ x < 1.

This is equivalent to generating a random integer in the range 0 ≤ x < 2p for each part, where 2p is two raised to the power of the precision, and then dividing the integer by 2p. The smallest non-zero result will thus be 2p, and will only have one bit set. In the smaller possible results, many bits will be zero, and not all the precision will be used.

There is a corner case where the generated random number part is converted to NaN: if the precision is very large, the generated random number could have an exponent less than the allowed minimum exponent, and NaN is used to indicate this. For this to occur in practice, the minimum exponent has to be set to have a very small magnitude using the low-level MPFR interface, or the random number generator has to be designed specifically to trigger this case.

Assign<Src> for Complex is implemented with the returned incomplete-computation value as Src.

Examples

use rug::{rand::RandState, Assign, Complex};
let mut rand = RandState::new();
let mut c = Complex::new(2);
c.assign(Complex::random_bits(&mut rand));
let (re, im) = c.into_real_imag();
assert!(re == 0.0 || re == 0.25 || re == 0.5 || re == 0.75);
assert!(im == 0.0 || im == 0.25 || im == 0.5 || im == 0.75);
println!("0.0 ≤ {} < 1.0", re);
println!("0.0 ≤ {} < 1.0", im);

pub fn random_cont(rng: &mut dyn MutRandState) -> RandomContIncomplete<'_>[src]

Generates a random complex number with both the real and imaginary parts in the continous range 0 ≤ x < 1, and rounds to the nearest.

The result parts can be rounded up to be equal to one. Unlike the assign_random_bits method which generates a discrete random number at intervals depending on the precision, this method is equivalent to generating a continuous random number with infinite precision and then rounding the result. This means that even the smaller numbers will be using all the available precision bits, and rounding is performed in all cases, not in some corner case.

Rounding directions for generated random numbers cannot be Ordering::Equal, as the random numbers generated can be considered to have infinite precision before rounding.

The following are implemented with the returned incomplete-computation value as Src:

Examples

use rug::{rand::RandState, Complex};
let mut rand = RandState::new();
let c = Complex::with_val(2, Complex::random_cont(&mut rand));
let (re, im) = c.into_real_imag();
// The significand is either 0b10 or 0b11
assert!(
    re == 1.0
        || re == 0.75
        || re == 0.5
        || re == 0.375
        || re == 0.25
        || re <= 0.1875
);
assert!(
    im == 1.0
        || im == 0.75
        || im == 0.5
        || im == 0.375
        || im == 0.25
        || im <= 0.1875
);

Trait Implementations

impl<'_> Add<&'_ Complex> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<&'_ Float> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<&'_ Integer> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<&'_ Rational> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<&'_ f32> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ f32> for &'b Complex[src]

type Output = AddF32Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ f64> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ f64> for &'b Complex[src]

type Output = AddF64Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ i128> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ i128> for &'b Complex[src]

type Output = AddI128Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ i16> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ i16> for &'b Complex[src]

type Output = AddI16Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ i32> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ i32> for &'b Complex[src]

type Output = AddI32Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ i64> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ i64> for &'b Complex[src]

type Output = AddI64Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ i8> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ i8> for &'b Complex[src]

type Output = AddI8Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ u128> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ u128> for &'b Complex[src]

type Output = AddU128Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ u16> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ u16> for &'b Complex[src]

type Output = AddU16Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ u32> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ u32> for &'b Complex[src]

type Output = AddU32Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ u64> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ u64> for &'b Complex[src]

type Output = AddU64Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> Add<&'_ u8> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b, '_> Add<&'_ u8> for &'b Complex[src]

type Output = AddU8Incomplete<'b>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for &'a Complex[src]

type Output = AddIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for Float[src]

type Output = AddOwnedFloatIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for u32[src]

type Output = AddU32Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for u64[src]

type Output = AddU64Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for u128[src]

type Output = AddU128Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for f32[src]

type Output = AddF32Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for f64[src]

type Output = AddF64Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for Integer[src]

type Output = AddOwnedIntegerIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for &'a Integer[src]

type Output = AddIntegerIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for Rational[src]

type Output = AddOwnedRationalIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for &'a Rational[src]

type Output = AddRationalIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for &'a Float[src]

type Output = AddFloatIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for i8[src]

type Output = AddI8Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for i16[src]

type Output = AddI16Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for i32[src]

type Output = AddI32Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for i64[src]

type Output = AddI64Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for i128[src]

type Output = AddI128Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for u8[src]

type Output = AddU8Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Complex> for u16[src]

type Output = AddU16Incomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Float> for &'a Complex[src]

type Output = AddFloatIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Integer> for &'a Complex[src]

type Output = AddIntegerIncomplete<'a>

The resulting type after applying the + operator.

impl<'a> Add<&'a Rational> for &'a Complex[src]

type Output = AddRationalIncomplete<'a>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ i8[src]

type Output = AddI8Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ i16[src]

type Output = AddI16Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ f32[src]

type Output = AddF32Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ f64[src]

type Output = AddF64Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ i32[src]

type Output = AddI32Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ i64[src]

type Output = AddI64Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ i128[src]

type Output = AddI128Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ u8[src]

type Output = AddU8Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ u16[src]

type Output = AddU16Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ u32[src]

type Output = AddU32Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ u64[src]

type Output = AddU64Incomplete<'b>

The resulting type after applying the + operator.

impl<'b, '_> Add<&'b Complex> for &'_ u128[src]

type Output = AddU128Incomplete<'b>

The resulting type after applying the + operator.

impl Add<Complex> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for i64[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ i64[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for i128[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ i128[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for u8[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ u8[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for u16[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ u16[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for u32[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ u32[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for Float[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for u64[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ u64[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for u128[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ u128[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for f32[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ f32[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for f64[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ f64[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for Integer[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ Integer[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ Float[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for Rational[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ Rational[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for i8[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ i8[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for i16[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ i16[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Complex> for i32[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'_> Add<Complex> for &'_ i32[src]

type Output = Complex

The resulting type after applying the + operator.

impl Add<Float> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'a> Add<Float> for &'a Complex[src]

type Output = AddOwnedFloatIncomplete<'a>

The resulting type after applying the + operator.

impl Add<Integer> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'a> Add<Integer> for &'a Complex[src]

type Output = AddOwnedIntegerIncomplete<'a>

The resulting type after applying the + operator.

impl Add<Rational> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'a> Add<Rational> for &'a Complex[src]

type Output = AddOwnedRationalIncomplete<'a>

The resulting type after applying the + operator.

impl Add<f32> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<f32> for &'b Complex[src]

type Output = AddF32Incomplete<'b>

The resulting type after applying the + operator.

impl Add<f64> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<f64> for &'b Complex[src]

type Output = AddF64Incomplete<'b>

The resulting type after applying the + operator.

impl Add<i128> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<i128> for &'b Complex[src]

type Output = AddI128Incomplete<'b>

The resulting type after applying the + operator.

impl Add<i16> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<i16> for &'b Complex[src]

type Output = AddI16Incomplete<'b>

The resulting type after applying the + operator.

impl Add<i32> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<i32> for &'b Complex[src]

type Output = AddI32Incomplete<'b>

The resulting type after applying the + operator.

impl Add<i64> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<i64> for &'b Complex[src]

type Output = AddI64Incomplete<'b>

The resulting type after applying the + operator.

impl Add<i8> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<i8> for &'b Complex[src]

type Output = AddI8Incomplete<'b>

The resulting type after applying the + operator.

impl Add<u128> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<u128> for &'b Complex[src]

type Output = AddU128Incomplete<'b>

The resulting type after applying the + operator.

impl Add<u16> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<u16> for &'b Complex[src]

type Output = AddU16Incomplete<'b>

The resulting type after applying the + operator.

impl Add<u32> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<u32> for &'b Complex[src]

type Output = AddU32Incomplete<'b>

The resulting type after applying the + operator.

impl Add<u64> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<u64> for &'b Complex[src]

type Output = AddU64Incomplete<'b>

The resulting type after applying the + operator.

impl Add<u8> for Complex[src]

type Output = Complex

The resulting type after applying the + operator.

impl<'b> Add<u8> for &'b Complex[src]

type Output = AddU8Incomplete<'b>

The resulting type after applying the + operator.

impl<'_> AddAssign<&'_ Complex> for Complex[src]

impl<'_> AddAssign<&'_ Float> for Complex[src]

impl<'_> AddAssign<&'_ Integer> for Complex[src]

impl<'_> AddAssign<&'_ Rational> for Complex[src]

impl<'_> AddAssign<&'_ f32> for Complex[src]

impl<'_> AddAssign<&'_ f64> for Complex[src]

impl<'_> AddAssign<&'_ i128> for Complex[src]

impl<'_> AddAssign<&'_ i16> for Complex[src]

impl<'_> AddAssign<&'_ i32> for Complex[src]

impl<'_> AddAssign<&'_ i64> for Complex[src]

impl<'_> AddAssign<&'_ i8> for Complex[src]

impl<'_> AddAssign<&'_ u128> for Complex[src]

impl<'_> AddAssign<&'_ u16> for Complex[src]

impl<'_> AddAssign<&'_ u32> for Complex[src]

impl<'_> AddAssign<&'_ u64> for Complex[src]

impl<'_> AddAssign<&'_ u8> for Complex[src]

impl AddAssign<Complex> for Complex[src]

impl AddAssign<Float> for Complex[src]

impl AddAssign<Integer> for Complex[src]

impl AddAssign<Rational> for Complex[src]

impl AddAssign<f32> for Complex[src]

impl AddAssign<f64> for Complex[src]

impl AddAssign<i128> for Complex[src]

impl AddAssign<i16> for Complex[src]

impl AddAssign<i32> for Complex[src]

impl AddAssign<i64> for Complex[src]

impl AddAssign<i8> for Complex[src]

impl AddAssign<u128> for Complex[src]

impl AddAssign<u16> for Complex[src]

impl AddAssign<u32> for Complex[src]

impl AddAssign<u64> for Complex[src]

impl AddAssign<u8> for Complex[src]

impl<'_> AddAssignRound<&'_ Complex> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ Float> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ Integer> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ Rational> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ f32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ f64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ i128> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ i16> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ i32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ i64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ i8> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ u128> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ u16> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ u32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ u64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddAssignRound<&'_ u8> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<Complex> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<Float> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<Integer> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<Rational> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<f32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<f64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<i128> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<i16> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<i32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<i64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<i8> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<u128> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<u16> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<u32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<u64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddAssignRound<u8> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFrom<&'_ Complex> for Complex[src]

impl<'_> AddFrom<&'_ Float> for Complex[src]

impl<'_> AddFrom<&'_ Integer> for Complex[src]

impl<'_> AddFrom<&'_ Rational> for Complex[src]

impl<'_> AddFrom<&'_ f32> for Complex[src]

impl<'_> AddFrom<&'_ f64> for Complex[src]

impl<'_> AddFrom<&'_ i128> for Complex[src]

impl<'_> AddFrom<&'_ i16> for Complex[src]

impl<'_> AddFrom<&'_ i32> for Complex[src]

impl<'_> AddFrom<&'_ i64> for Complex[src]

impl<'_> AddFrom<&'_ i8> for Complex[src]

impl<'_> AddFrom<&'_ u128> for Complex[src]

impl<'_> AddFrom<&'_ u16> for Complex[src]

impl<'_> AddFrom<&'_ u32> for Complex[src]

impl<'_> AddFrom<&'_ u64> for Complex[src]

impl<'_> AddFrom<&'_ u8> for Complex[src]

impl AddFrom<Complex> for Complex[src]

impl AddFrom<Float> for Complex[src]

impl AddFrom<Integer> for Complex[src]

impl AddFrom<Rational> for Complex[src]

impl AddFrom<f32> for Complex[src]

impl AddFrom<f64> for Complex[src]

impl AddFrom<i128> for Complex[src]

impl AddFrom<i16> for Complex[src]

impl AddFrom<i32> for Complex[src]

impl AddFrom<i64> for Complex[src]

impl AddFrom<i8> for Complex[src]

impl AddFrom<u128> for Complex[src]

impl AddFrom<u16> for Complex[src]

impl AddFrom<u32> for Complex[src]

impl AddFrom<u64> for Complex[src]

impl AddFrom<u8> for Complex[src]

impl<'_> AddFromRound<&'_ Complex> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ Float> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ Integer> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ Rational> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ f32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ f64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ i128> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ i16> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ i32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ i64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ i8> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ u128> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ u16> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ u32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ u64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'_> AddFromRound<&'_ u8> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<Complex> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<Float> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<Integer> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<Rational> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<f32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<f64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<i128> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<i16> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<i32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<i64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<i8> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<u128> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<u16> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<u32> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<u64> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AddFromRound<u8> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AsMut<Complex> for OrdComplex[src]

impl AsRef<Complex> for OrdComplex[src]

impl AsRef<OrdComplex> for Complex[src]

impl<T> Assign<T> for Complex where
    Self: AssignRound<T, Round = (Round, Round), Ordering = (Ordering, Ordering)>, 
[src]

impl<'_> AssignRound<&'_ Complex> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<'a, Re, Im> AssignRound<&'a (Re, Im)> for Complex where
    Float: AssignRound<&'a Re, Round = Round, Ordering = Ordering> + AssignRound<&'a Im, Round = Round, Ordering = Ordering>, 
[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<Re, Im> AssignRound<(Re, Im)> for Complex where
    Float: AssignRound<Re, Round = Round, Ordering = Ordering> + AssignRound<Im, Round = Round, Ordering = Ordering>, 
[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl AssignRound<Complex> for Complex[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl<Re> AssignRound<Re> for Complex where
    Float: AssignRound<Re, Round = Round, Ordering = Ordering>, 
[src]

type Round = (Round, Round)

The rounding method.

type Ordering = (Ordering, Ordering)

The direction from rounding.

impl Binary for Complex[src]

impl Clone for Complex[src]

impl Debug for Complex[src]

impl<'de> Deserialize<'de> for Complex[src]

impl Display for Complex[src]

impl<'_> Div<&'_ Complex> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'_> Div<&'_ Float> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'_> Div<&'_ Integer> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'_> Div<&'_ Rational> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'_> Div<&'_ f32> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ f32> for &'b Complex[src]

type Output = DivF32Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ f64> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ f64> for &'b Complex[src]

type Output = DivF64Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ i128> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ i128> for &'b Complex[src]

type Output = DivI128Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ i16> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ i16> for &'b Complex[src]

type Output = DivI16Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ i32> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ i32> for &'b Complex[src]

type Output = DivI32Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ i64> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ i64> for &'b Complex[src]

type Output = DivI64Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ i8> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ i8> for &'b Complex[src]

type Output = DivI8Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ u128> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ u128> for &'b Complex[src]

type Output = DivU128Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ u16> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ u16> for &'b Complex[src]

type Output = DivU16Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ u32> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ u32> for &'b Complex[src]

type Output = DivU32Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ u64> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ u64> for &'b Complex[src]

type Output = DivU64Incomplete<'b>

The resulting type after applying the / operator.

impl<'_> Div<&'_ u8> for Complex[src]

type Output = Complex

The resulting type after applying the / operator.

impl<'b, '_> Div<&'_ u8> for &'b Complex[src]

type Output = DivU8Incomplete<'b>

The resulting type after applying the / operator.

impl<'a> Div<&'a Complex> for &'a Complex[src]

type Output = DivIncomplete<'a>

The resulting type after applying the / operator.

impl<'a> Div<&'a Complex> for Float[src]

type Output = DivFromOwnedFloatIncomplete<'a>

The resulting type after applying the / operator.

impl<'a> Div<&'a Complex> for &'a Float[src]

type Output = DivFromFloatIncomplete<'a>

The resulting type after applying the / operator.

impl<'a> Div<&'a Float> for &'a Complex[src]

type Output = DivFloatIncomplete<'a>

The resulting type after applying the / operator.

impl<'a> Div<&'a Integer> for &'a Complex[src]

type Output = DivIntegerIncomplete<'a>

The resulting type after applying the / operator.

impl<'a> Div<&'a Rational> for &'a Complex[src]

type Output = DivRationalIncomplete<'a>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for i8[src]

type Output = DivFromI8Incomplete<'b>

The resulting type after applying the / operator.

impl<'b, '_> Div<&'b Complex> for &'_ i8[src]

type Output = DivFromI8Incomplete<'b>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for u8[src]

type Output = DivFromU8Incomplete<'b>

The resulting type after applying the / operator.

impl<'b, '_> Div<&'b Complex> for &'_ u8[src]

type Output = DivFromU8Incomplete<'b>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for u16[src]

type Output = DivFromU16Incomplete<'b>

The resulting type after applying the / operator.

impl<'b, '_> Div<&'b Complex> for &'_ u16[src]

type Output = DivFromU16Incomplete<'b>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for u32[src]

type Output = DivFromU32Incomplete<'b>

The resulting type after applying the / operator.

impl<'b, '_> Div<&'b Complex> for &'_ u32[src]

type Output = DivFromU32Incomplete<'b>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for u64[src]

type Output = DivFromU64Incomplete<'b>

The resulting type after applying the / operator.

impl<'b, '_> Div<&'b Complex> for &'_ u64[src]

type Output = DivFromU64Incomplete<'b>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for u128[src]

type Output = DivFromU128Incomplete<'b>

The resulting type after applying the / operator.

impl<'b, '_> Div<&'b Complex> for &'_ u128[src]

type Output = DivFromU128Incomplete<'b>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for i16[src]

type Output = DivFromI16Incomplete<'b>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for f32[src]

type Output = DivFromF32Incomplete<'b>

The resulting type after applying the / operator.

impl<'b, '_> Div<&'b Complex> for &'_ f32[src]

type Output = DivFromF32Incomplete<'b>

The resulting type after applying the / operator.

impl<'b> Div<&'b Complex> for f64[src]

type Output = DivFromF64Incomplete<'b>

The resulting type after applying the / operator.

impl<'b, '_> Div<&'b Complex> for &'_ f64[src]

type Output = DivFromF64Incomplete<'b>

The resulting type after applying the / operator.