GeezerVison is showing docs.rs (truncated) — num_complex::Complex - Rust
#[repr(C)]
pub struct Complex<T> {
pub re: T,
pub im: T,
}A complex number in Cartesian form.
Complex<T> is memory layout compatible with an array [T; 2].
Note that Complex<F> where F is a floating point type is only memory
layout compatible with C's complex types, not necessarily calling
convention compatible. This means that for FFI you can only pass
Complex<F> behind a pointer, not as a value.
Example of extern function declaration.
use num_complex::Complex;
use std::os::raw::c_int;
extern "C" {
fn zaxpy_(n: *const c_int, alpha: *const Complex<f64>,
x: *const Complex<f64>, incx: *const c_int,
y: *mut Complex<f64>, incy: *const c_int);
}
Fieldsre: TReal portion of the complex number
im: TImaginary portion of the complex number
Methodspub const fn new(re: T, im: T) -> Self[src]
pub fn i() -> Self[src]
Returns the square of the norm (since T doesn't necessarily
have a sqrt function), i.e. re^2 + im^2.
pub fn scale(&self, t: T) -> Self[src]
Multiplies self by the scalar t.
pub fn unscale(&self, t: T) -> Self[src]
Divides self by the scalar t.
pub fn powu(&self, exp: u32) -> Self[src]
Raises self to an unsigned integer power.
pub fn conj(&self) -> Self[src]
Returns the complex conjugate. i.e. re - i im
pub fn inv(&self) -> Self[src]
pub fn powi(&self, exp: i32) -> Self[src]
Raises self to a signed integer power.
pub fn norm(&self) -> T[src]
pub fn arg(&self) -> T[src]
Calculate the principal Arg of self.
Convert to polar form (r, theta), such that
self = r * exp(i * theta)
Convert a polar representation into a complex number.
pub fn exp(&self) -> Self[src]
Computes e^(self), where e is the base of the natural logarithm.
pub fn ln(&self) -> Self[src]
Computes the principal value of natural logarithm of self.
This function has one branch cut:
(-∞, 0], continuous from above.
The branch satisfies -π ≤ arg(ln(z)) ≤ π.
pub fn sqrt(&self) -> Self[src]
Computes the principal value of the square root of self.
This function has one branch cut:
(-∞, 0), continuous from above.
The branch satisfies -π/2 ≤ arg(sqrt(z)) ≤ π/2.
pub fn cbrt(&self) -> Self[src]
Computes the principal value of the cube root of self.
This function has one branch cut:
(-∞, 0), continuous from above.
The branch satisfies -π/3 ≤ arg(cbrt(z)) ≤ π/3.
Note that this does not match the usual result for the cube root of
negative real numbers. For example, the real cube root of -8 is -2,
but the principal complex cube root of -8 is 1 + i√3.
pub fn powf(&self, exp: T) -> Self[src]
Raises self to a floating point power.
pub fn log(&self, base: T) -> Self[src]
Returns the logarithm of self with respect to an arbitrary base.
pub fn powc(&self, exp: Self) -> Self[src]
Raises self to a complex power.
pub fn expf(&self, base: T) -> Self[src]
Raises a floating point number to the complex power self.
pub fn sin(&self) -> Self[src]
Computes the sine of self.
pub fn cos(&self) -> Self[src]
Computes the cosine of self.
pub fn tan(&self) -> Self[src]
Computes the tangent of self.
pub fn asin(&self) -> Self[src]
Computes the principal value of the inverse sine of self.
This function has two branch cuts:
(-∞, -1), continuous from above.
(1, ∞), continuous from below.
The branch satisfies -π/2 ≤ Re(asin(z)) ≤ π/2.
pub fn acos(&self) -> Self[src]
Computes the principal value of the inverse cosine of self.
This function has two branch cuts:
(-∞, -1), continuous from above.
(1, ∞), continuous from below.
The branch satisfies 0 ≤ Re(acos(z)) ≤ π.
pub fn atan(&self) -> Self[src]
Computes the principal value of the inverse tangent of self.
This function has two branch cuts:
(-∞i, -i], continuous from the left.
[i, ∞i), continuous from the right.
The branch satisfies -π/2 ≤ Re(atan(z)) ≤ π/2.
pub fn sinh(&self) -> Self[src]
Computes the hyperbolic sine of self.
pub fn cosh(&self) -> Self[src]
Computes the hyperbolic cosine of self.
pub fn tanh(&self) -> Self[src]
Computes the hyperbolic tangent of self.
pub fn asinh(&self) -> Self[src]
Computes the principal value of inverse hyperbolic sine of self.
This function has two branch cuts:
(-∞i, -i), continuous from the left.
(i, ∞i), continuous from the right.
The branch satisfies -π/2 ≤ Im(asinh(z)) ≤ π/2.
pub fn acosh(&self) -> Self[src]
Computes the principal value of inverse hyperbolic cosine of self.
This function has one branch cut:
(-∞, 1), continuous from above.
The branch satisfies -π ≤ Im(acosh(z)) ≤ π and 0 ≤ Re(acosh(z)) < ∞.
pub fn atanh(&self) -> Self[src]
Computes the principal value of inverse hyperbolic tangent of self.
This function has two branch cuts:
(-∞, -1], continuous from above.
[1, ∞), continuous from below.
The branch satisfies -π/2 ≤ Im(atanh(z)) ≤ π/2.
Returns 1/self using floating-point operations.
This may be more accurate than the generic self.inv() in cases
where self.norm_sqr() would overflow to ∞ or underflow to 0.
use num_complex::Complex64;
let c = Complex64::new(1e300, 1e300);
// The generic `inv()` will overflow.
assert!(!c.inv().is_normal());
// But we can do better for `Float` types.
let inv = c.finv();
assert!(inv.is_normal());
println!("{:e}", inv);
let expected = Complex64::new(5e-301, -5e-301);
assert!((inv - expected).norm() < 1e-315);
Returns self/other using floating-point operations.
This may be more accurate than the generic Div implementation in cases
where other.norm_sqr() would overflow to ∞ or underflow to 0.
use num_complex::Complex64;
let a = Complex64::new(2.0, 3.0);
let b = Complex64::new(1e300, 1e300);
// Generic division will overflow.
assert!(!(a / b).is_normal());
// But we can do better for `Float` types.
let quotient = a.fdiv(b);
assert!(quotient.is_normal());
println!("{:e}", quotient);
let expected = Complex64::new(2.5e-300, 5e-301);
assert!((quotient - expected).norm() < 1e-315);
Checks if the given complex number is NaN
Checks if the given complex number is infinite
Checks if the given complex number is finite
Checks if the given complex number is normal
Trait ImplementationsThe resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
fn add(self, other: Self) -> Self::Output[src]
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
Performs the + operation.
The resulting type after applying the + operator.
fn add(self, other: T) -> Self::Output[src]
Performs the + operation.
The resulting type after applying the + operator.
fn add(self, other: T) -> Self::Output[src]
Performs the + operation.
Performs the += operation.
Performs the += operation.
Performs the += operation.
Performs the += operation.
Convert a value to another, using the as operator.
Formats the value using the given formatter.
Formats the value using the given formatter. Read more
Returns the "default value" for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Generate a random value of T, using rng as the source of randomness.
Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Generate a random value of T, using rng as the source of randomness.
Create an iterator that generates random values of T, using rng as the source of randomness. Read more
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
fn div(self, other: Self) -> Self::Output[src]
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
Performs the / operation.
The resulting type after applying the / operator.
fn div(self, other: T) -> Self::Output[src]
Performs the / operation.
The resulting type after applying the / operator.
fn div(self, other: T) -> Self::Output[src]
Performs the / operation.
Performs the /= operation.
Performs the /= operation.
Performs the /= operation.
Performs the /= operation.
Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
The associated error which can be returned from parsing.
Parses a +/- bi; ai +/- b; a; or bi where a and b are of type T
Feeds this value into the given [Hasher]. Read more
Feeds a slice of this type into the given [Hasher]. Read more
The result after applying the operator.
Returns the multiplicative inverse of self. Read more
The result after applying the operator.
Returns the multiplicative inverse of self. Read more
Formats the value using the given formatter.
Formats the value using the given formatter.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
fn mul(self, other: Self) -> Self::Output[src]
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
The resulting type after applying the * operator.
Performs the * operation.
< [Page truncated to keep GeezerVison snappy.] |