Struct num::Complex [−][src]
#[repr(C)]pub struct Complex<T> {
pub re: T,
pub im: T,
}Expand description
A complex number in Cartesian form.
Representation and Foreign Function Interface Compatibility
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.
Examples
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);
}Fields
re: TReal portion of the complex number
im: TImaginary portion of the complex number
Implementations
Returns the square of the norm (since T doesn’t necessarily
have a sqrt function), i.e. re^2 + im^2.
Convert to polar form (r, theta), such that
self = r * exp(i * theta)
Convert a polar representation into a complex number.
Computes e^(self), where e is the base of the natural logarithm.
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)) ≤ π.
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.
Returns the logarithm of self with respect to an arbitrary base.
Raises a floating point number to the complex power self.
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.
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)) ≤ π.
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.
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.
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)) < ∞.
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.
Checks if the given complex number is infinite
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
pub fn from_str_radix(
s: &str,
radix: u32
) -> Result<Complex<T>, <Complex<T> as Num>::FromStrRadixErr>
pub fn from_str_radix(
s: &str,
radix: u32
) -> Result<Complex<T>, <Complex<T> as Num>::FromStrRadixErr>
Parses a +/- bi; ai +/- b; a; or bi where a and b are of type T
type FromStrRadixErr = ParseComplexError<<T as Num>::FromStrRadixErr>
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
impl<T> RefUnwindSafe for Complex<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Complex<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
