pub struct RotationMatrix { /* private fields */ }Expand description
Deterministically generated orthogonal matrix for vector preconditioning.
The inner storage is Arc<[f64]> so Clone is O(1) — callers can
pass copies between tasks without reallocating the dim * dim buffer.
Implementations§
Source§impl RotationMatrix
impl RotationMatrix
Sourcepub fn from_config(config: &CodecConfig) -> Self
pub fn from_config(config: &CodecConfig) -> Self
Build a rotation matrix for the given CodecConfig.
Sourcepub fn build(seed: u64, dimension: u32) -> Self
pub fn build(seed: u64, dimension: u32) -> Self
Build a rotation matrix for the (seed, dimension) pair.
§Panics
Panics if dimension == 0. In the normal flow, dimensions reach
this function only via a validated CodecConfig, so this cannot
be triggered by safe public APIs of the crate.
Sourcepub fn apply_into(
&self,
input: &[f32],
output: &mut [f32],
) -> Result<(), CodecError>
pub fn apply_into( &self, input: &[f32], output: &mut [f32], ) -> Result<(), CodecError>
Rotate input into output: output = matrix @ input.
§Errors
Returns CodecError::LengthMismatch if either slice length
differs from Self::dimension.
Sourcepub fn apply_inverse_into(
&self,
input: &[f32],
output: &mut [f32],
) -> Result<(), CodecError>
pub fn apply_inverse_into( &self, input: &[f32], output: &mut [f32], ) -> Result<(), CodecError>
Apply the inverse rotation: output = matrix^T @ input.
Valid because the matrix is orthogonal.
§Errors
Returns CodecError::LengthMismatch if either slice length
differs from Self::dimension.
Sourcepub fn verify_orthogonality(&self, tol: f64) -> bool
pub fn verify_orthogonality(&self, tol: f64) -> bool
Return true if matrix @ matrix^T equals the identity within
tol on every entry.
This is O(n^3); reserve for tests and low-frequency sanity checks.
Trait Implementations§
Source§impl Clone for RotationMatrix
impl Clone for RotationMatrix
Source§fn clone(&self) -> RotationMatrix
fn clone(&self) -> RotationMatrix
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more