faer_core/complex_native/
mod.rs

1//! Native complex floating point types whose real and imaginary parts are stored contiguously.
2//!
3//! The types [`c32`] and [`c64`] respectively have the same layout as [`num_complex::Complex32`]
4//! and [`num_complex::Complex64`].
5//!
6//! They differ in the way they are treated by the `faer` library: When stored in a matrix,
7//! `Mat<c32>` and `Mat<c64>` internally contain a single container of contiguously stored
8//! `c32` and `c64` values, whereas `Mat<num_complex::Complex32>` and
9//! `Mat<num_complex::Complex64>` internally contain two containers, separately storing the real
10//! and imaginary parts of the complex values.
11//!
12//! Matrix operations using `c32` and `c64` are usually more efficient and should be preferred in
13//! most cases. `num_complex::Complex` matrices have better support for generic data types.
14//!
15//! The drawing below represents a simplified layout of the `Mat` structure for each of `c32` and
16//! `num_complex::Complex32`.
17//!
18//! ```notcode
19//! ┌──────────────────┐
20//! │ Mat<c32>         │
21//! ├──────────────────┤
22//! │ ptr: *mut c32 ─ ─│─ ─ ─ ─ ┐
23//! │ nrows: usize     │   ┌─────────┐
24//! │ ncols: usize     │   │ z0: c32 │
25//! │        ...       │   │ z1: c32 │
26//! └──────────────────┘   │ z2: c32 │
27//!                        │   ...   │
28//!                        └─────────┘
29//!
30//! ┌───────────────────────┐
31//! │ Mat<Complex32>        │
32//! ├───────────────────────┤
33//! │ ptr_real: *mut f32 ─ ─│─ ─ ─ ─ ┐
34//! │ ptr_imag: *mut f32 ─ ─│─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ─ ┐
35//! │ nrows: usize          │   ┌──────────┐   ┌──────────┐
36//! │ ncols: usize          │   │ re0: f32 │   │ im0: f32 │
37//! │           ...         │   │ re1: f32 │   │ im1: f32 │
38//! └───────────────────────┘   │ re2: f32 │   │ im2: f32 │
39//!                             │    ...   │   │    ...   │
40//!                             └──────────┘   └──────────┘
41//! ```
42
43mod c32_impl;
44mod c32conj_impl;
45mod c64_impl;
46mod c64conj_impl;
47
48pub use c32_impl::c32;
49pub use c32conj_impl::c32conj;
50pub use c64_impl::c64;
51pub use c64conj_impl::c64conj;