Struct rug::complex::OrdComplex [] [src]

pub struct OrdComplex { /* fields omitted */ }

A complex number that supports ordering and hashing.

For ordering, the real part has precedence over the imaginary part. Negative zero is ordered as less than positive zero. All NaNs are ordered as equal and as less than negative infinity, with the NaN sign ignored.

Examples

use rug::Complex;
use rug::complex::OrdComplex;
use rug::float::Special;
use std::cmp::Ordering;

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

let one_neg0_c = Complex::with_val(53, (1, Special::NegZero));
let one_neg0 = OrdComplex::from(one_neg0_c);
let one_pos0_c = Complex::with_val(53, (1, Special::Zero));
let one_pos0 = OrdComplex::from(one_pos0_c);
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 = OrdComplex::from(zero_inf_c);
assert_eq!(one_pos0.cmp(&zero_inf), Ordering::Greater);

Methods

impl OrdComplex
[src]

Extracts the underlying Complex.

Examples

use rug::Complex;
use rug::complex::OrdComplex;
let c = Complex::with_val(53, (1.5, 2.5));
let ord = OrdComplex::from(c);
let c_ref = ord.as_complex();
let (re, im) = c_ref.as_real_imag();
assert_eq!(*re, 1.5);
assert_eq!(*im, 2.5);

Extracts the underlying Complex.

Examples

use rug::Complex;
use rug::complex::OrdComplex;
let c = Complex::with_val(53, (1.5, -2.5));
let mut ord = OrdComplex::from(c);
ord.as_complex_mut().conj_mut();
let (re, im) = ord.as_complex().as_real_imag();
assert_eq!(*re, 1.5);
assert_eq!(*im, 2.5);

Trait Implementations

impl Clone for OrdComplex
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for OrdComplex
[src]

Formats the value using the given formatter.

impl Default for OrdComplex
[src]

Returns the "default value" for a type. Read more

impl Hash for OrdComplex
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialEq for OrdComplex
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for OrdComplex
[src]

impl PartialOrd for OrdComplex
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for OrdComplex
[src]

This method returns an Ordering between self and other. Read more

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

impl From<Complex> for OrdComplex
[src]

Performs the conversion.