refloxide_core/output.rs
1//! Result containers returned by the CPU uniaxial drivers.
2//!
3//! Plain data only: no solver logic and no backend dependencies.
4
5use nalgebra::Matrix3;
6use num_complex::Complex;
7
8use crate::layer::Layer;
9
10/// Complex alias used throughout the kernel.
11type C = Complex<f64>;
12
13/// Polarized reflectance and amplitude transmission for a single energy.
14///
15/// Index layout mirrors the Python reference: `refl[i][k][l]` and
16/// `tran[i][k][l]` with `(0, 0) = ss`, `(1, 1) = pp`, `(0, 1) = sp`,
17/// `(1, 0) = ps`.
18#[derive(Debug, Clone)]
19pub struct UniaxialOutput {
20 /// Power reflectance with shape `(numpnts, 2, 2)`.
21 pub refl: Vec<[[f64; 2]; 2]>,
22 /// Complex amplitude transmission with shape `(numpnts, 2, 2)`.
23 pub tran: Vec<[[C; 2]; 2]>,
24}
25
26/// Batched polarized reflectance and transmission over energies and q-points.
27#[derive(Debug, Clone)]
28pub struct UniaxialBatchOutput {
29 /// Power reflectance with shape `(n_energies, n_q, 2, 2)`.
30 pub refl: Vec<Vec<[[f64; 2]; 2]>>,
31 /// Complex amplitude transmission with the same layout.
32 pub tran: Vec<Vec<[[C; 2]; 2]>>,
33}
34
35/// Reflectance and Jacobian-vector products for `(q, stack)` points.
36#[derive(Debug, Clone)]
37pub struct PointsJvpOutput {
38 /// `[R_pp, R_ss]` per point, length `n_points`.
39 pub refl: Vec<[f64; 2]>,
40 /// Row-major `(n_dirs, n_points)` derivatives `[dR_pp, dR_ss]`.
41 pub jac: Vec<[f64; 2]>,
42}
43
44/// Direction-major tangent inputs for `uniaxial_reflectivity_points_jvp`.
45#[derive(Debug, Clone)]
46pub struct PointsTangents {
47 /// `(n_dirs, n_points)` tangent of `q`.
48 pub dq: Vec<Vec<f64>>,
49 /// `(n_dirs, n_stacks, n_layers)` tangent of the slab rows.
50 pub dlayers: Vec<Vec<Vec<Layer>>>,
51 /// `(n_dirs, n_stacks, n_layers)` tangent of the dispersion tensors.
52 pub dtensor: Vec<Vec<Vec<Matrix3<C>>>>,
53}