pub struct CalibrationMatrix {
pub name: String,
pub rows: usize,
pub cols: usize,
pub data: Vec<f64>,
pub input_unit: String,
pub output_unit: String,
pub calibration_timestamp: f64,
}Expand description
A labelled calibration matrix with row/column metadata.
Can represent misalignment corrections, scale-factor matrices, cross-axis coupling matrices, or any linear mapping used for sensor compensation.
Fields§
§name: StringHuman-readable name (e.g., "accel_misalignment").
rows: usizeNumber of rows.
cols: usizeNumber of columns.
data: Vec<f64>Elements in row-major order, length rows × cols.
input_unit: StringUnit string for the input quantities (e.g., "m/s²").
output_unit: StringUnit string for the output quantities (e.g., "m/s²").
calibration_timestamp: f64Calibration date as a Unix timestamp in seconds.
Implementations§
Source§impl CalibrationMatrix
impl CalibrationMatrix
Sourcepub fn identity(
name: impl Into<String>,
rows: usize,
cols: usize,
input_unit: impl Into<String>,
output_unit: impl Into<String>,
) -> Self
pub fn identity( name: impl Into<String>, rows: usize, cols: usize, input_unit: impl Into<String>, output_unit: impl Into<String>, ) -> Self
Create a new identity-like calibration matrix (diagonal 1, off-diagonal 0).
The matrix must be square (rows == cols) for the identity to make sense;
for non-square matrices the main diagonal up to min(rows,cols) is set to 1.
Sourcepub fn apply(&self, v: &[f64]) -> Option<Vec<f64>>
pub fn apply(&self, v: &[f64]) -> Option<Vec<f64>>
Apply the calibration matrix to input vector v (length == cols).
Returns None when v.len() != cols.
Sourcepub fn frobenius_norm(&self) -> f64
pub fn frobenius_norm(&self) -> f64
Frobenius norm of the matrix.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize to bytes.
Layout: [rows u64][cols u64][calib_ts f64][data… f64s]
(name and units are not persisted in this binary format).
Sourcepub fn from_bytes(data: &[u8]) -> Option<Self>
pub fn from_bytes(data: &[u8]) -> Option<Self>
Deserialize from bytes.
Trait Implementations§
Source§impl Clone for CalibrationMatrix
impl Clone for CalibrationMatrix
Source§fn clone(&self) -> CalibrationMatrix
fn clone(&self) -> CalibrationMatrix
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CalibrationMatrix
impl RefUnwindSafe for CalibrationMatrix
impl Send for CalibrationMatrix
impl Sync for CalibrationMatrix
impl Unpin for CalibrationMatrix
impl UnsafeUnpin for CalibrationMatrix
impl UnwindSafe for CalibrationMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.