#[repr(transparent)]pub struct Complex { /* private fields */ }
Expand description
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:
- The first method consumes the operand and rounds the returned
Complex
number to the nearest representable value. - The second method has a “
_mut
” suffix, mutates the operand and rounds it the nearest representable value. - 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: - The fourth method has a “
_ref
” suffix and borrows the operand. The returned item is an incomplete-computation value that can be assigned to aComplex
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
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);
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));
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));
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));
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));
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
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);
}
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));
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));
Parses a decimal string slice (&str
) or byte slice
(&[u8]
) into a
Complex
number.
The following are implemented with the unwrapped returned
incomplete-computation value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for Src
The string can contain either of the following three:
- One floating-point number that can be parsed by
Float::parse
. ASCII whitespace is treated in the same way as well. - 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.
- 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>
pub fn parse_radix<S: AsRef<[u8]>>(
src: S,
radix: i32
) -> Result<ParseIncomplete, ParseComplexError>
Parses a string slice (&str
) or byte slice
(&[u8]
) into a
Complex
number.
The following are implemented with the unwrapped returned
incomplete-computation value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for Src
The string can contain either of the following three:
- One floating-point number that can be parsed by
Float::parse_radix
. ASCII whitespace is treated in the same way as well. - 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.
- 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());
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)");
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)");
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));
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));
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));
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);
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);
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);
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);
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);
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);
Adds a list of Complex
numbers with correct rounding.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
AddAssign<Src> for Complex
AddAssignRound<Src> for Complex
Add<Src> for Complex
,Add<Complex> for Src
SubAssign<Src> for Complex
,SubFrom<Src> for Complex
SubAssignRound<Src> for Complex
,SubFromRound<Src> for Complex
Sub<Src> for Complex
,Sub<Complex> for Src
CompleteRound<Completed = Complex> for 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));
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
:
Assign<Src> for Complex
AssignRound<Src> for Complex
AddAssign<Src> for Complex
AddAssignRound<Src> for Complex
Add<Src> for Complex
,Add<Complex> for Src
SubAssign<Src> for Complex
,SubFrom<Src> for Complex
SubAssignRound<Src> for Complex
,SubFromRound<Src> for Complex
Sub<Src> for Complex
,Sub<Complex> for Src
CompleteRound<Completed = Complex> for 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);
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));
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));
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));
Multiplies and adds in one fused operation.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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));
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));
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));
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));
Multiplies and subtracts in one fused operation.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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));
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());
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());
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
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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());
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));
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));
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));
Computes the square.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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));
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));
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));
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));
Computes the square root.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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));
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));
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));
Computes the complex conjugate.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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));
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);
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));
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));
Computes the absolute value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
Assign<Src> for Complex
AssignRound<Src> for Float
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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));
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));
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));
Computes the argument.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
Assign<Src> for Complex
AssignRound<Src> for Float
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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));
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));
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));
Multiplies the complex number by ±i.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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));
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));
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));
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));
Computes the reciprocal.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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));
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);
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));
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));
Computes the norm, that is the square of the absolute value.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Float
Assign<Src> for Complex
AssignRound<Src> for Float
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the natural logarithm.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the logarithm to base 10.
The following are implemented with the returned
incomplete-computation value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the exponential.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the sine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the sine and cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for (Complex, Complex)
Assign<Src> for (&mut Complex, &mut Complex)
AssignRound<Src> for (Complex, Complex)
AssignRound<Src> for (&mut Complex, &mut Complex)
CompleteRound<Completed = (Complex, Complex)> for 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));
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);
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);
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));
Computes the tangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the hyperbolic sine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the hyperbolic cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the hyperbolic tangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the inverse sine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the inverse cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the inverse tangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the inverse hyperboic sine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the inverse hyperbolic cosine.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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);
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);
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));
Computes the inverse hyperbolic tangent.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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 2−p, 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.
The following are implemented with the returned incomplete-computation
value as Src
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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);
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
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
:
Assign<Src> for Complex
AssignRound<Src> for Complex
CompleteRound<Completed = Complex> for 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
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the conversion.
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>,
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>,
impl<Re, Im> AssignRound<(Re, Im)> for Complex where
Float: AssignRound<Re, Round = Round, Ordering = Ordering> + AssignRound<Im, Round = Round, Ordering = Ordering>,
impl<Re, Im> AssignRound<(Re, Im)> for Complex where
Float: AssignRound<Re, Round = Round, Ordering = Ordering> + AssignRound<Im, Round = Round, Ordering = Ordering>,
impl<Re> AssignRound<Re> for Complex where
Float: AssignRound<Re, Round = Round, Ordering = Ordering>,
impl<Re> AssignRound<Re> for Complex where
Float: AssignRound<Re, Round = Round, Ordering = Ordering>,
Deserialize this value from the given Serde deserializer. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the conversion.
Performs the fused multiply-add operation.
Performs the fused multiply-add operation.
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Peforms the power operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
Casts the value.
OverflowingCasts the value.
Casts the value.
Casts the value.
Casts the value.
UnwrappedCasts the value.
Casts the value.
WrappingCasts the value.