1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
//! Native complex floating point types whose real and imaginary parts are stored contiguously.
//!
//! The types [`c32`] and [`c64`] respectively have the same layout as [`num_complex::Complex32`]
//! and [`num_complex::Complex64`].
//!
//! They differ in the way they are treated by the `faer` library: When stored in a matrix,
//! `Mat<c32>` and `Mat<c64>` internally contain a single container of contiguously stored
//! `c32` and `c64` values, whereas `Mat<num_complex::Complex32>` and
//! `Mat<num_complex::Complex64>` internally contain two containers, separately storing the real
//! and imaginary parts of the complex values.
//!
//! Matrix operations using `c32` and `c64` are usually more efficient and should be preferred in
//! most cases. `num_complex::Complex` matrices have better support for generic data types.
//!
//! The drawing below represents a simplified layout of the `Mat` structure for each of `c32` and
//! `num_complex::Complex32`.
//!
//! ```notcode
//! ┌──────────────────┐
//! │ Mat<c32> │
//! ├──────────────────┤
//! │ ptr: *mut c32 ─ ─│─ ─ ─ ─ ┐
//! │ nrows: usize │ ┌─────────┐
//! │ ncols: usize │ │ z0: c32 │
//! │ ... │ │ z1: c32 │
//! └──────────────────┘ │ z2: c32 │
//! │ ... │
//! └─────────┘
//!
//! ┌───────────────────────┐
//! │ Mat<Complex32> │
//! ├───────────────────────┤
//! │ ptr_real: *mut f32 ─ ─│─ ─ ─ ─ ┐
//! │ ptr_imag: *mut f32 ─ ─│─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ─ ┐
//! │ nrows: usize │ ┌──────────┐ ┌──────────┐
//! │ ncols: usize │ │ re0: f32 │ │ im0: f32 │
//! │ ... │ │ re1: f32 │ │ im1: f32 │
//! └───────────────────────┘ │ re2: f32 │ │ im2: f32 │
//! │ ... │ │ ... │
//! └──────────┘ └──────────┘
//! ```
mod c32_conj_impl;
mod c32_impl;
mod c64_conj_impl;
mod c64_impl;
/// 32-bit complex floating point type. See the module-level documentation for more details.
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, PartialEq)]
pub struct c32 {
/// Real part.
pub re: f32,
/// Negated imaginary part.
pub im: f32,
}
/// 64-bit complex floating point type. See the module-level documentation for more details.
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, PartialEq)]
pub struct c64 {
/// Real part.
pub re: f64,
/// Negated imaginary part.
pub im: f64,
}
/// 32-bit implicitly conjugated complex floating point type.
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, PartialEq)]
pub struct c32conj {
/// Real part.
pub re: f32,
/// Negated imaginary part.
pub neg_im: f32,
}
/// 64-bit implicitly conjugated complex floating point type.
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, PartialEq)]
pub struct c64conj {
/// Real part.
pub re: f64,
/// Negated imaginary part.
pub neg_im: f64,
}