pub struct RandomRotation { /* private fields */ }linalg only.Expand description
A distance-perserving transformation from N-dimensions to N-dimensions.
This struct materializes a full NxN transformation matrix and mechanically applies
transformations via matrix multiplication.
Implementations§
Source§impl RandomRotation
impl RandomRotation
Sourcepub fn new<R>(dim: NonZeroUsize, target_dim: TargetDim, rng: &mut R) -> Self
pub fn new<R>(dim: NonZeroUsize, target_dim: TargetDim, rng: &mut R) -> Self
Construct a new RandomRotation that transforms input vectors of dimension dim.
The parameter rng is used to randomly sample the transformation matrix.
The following dimensionalities will be configured depending on the value of target:
TargetDim::Sameself.input_dim() == dim.get()self.output_dim() == dim.get()
TargetDim::Naturalself.input_dim() == dim.get()self.output_dim() == dim.get()
TargetDim::Overrideself.input_dim() == dim.get()self.output_dim(): The value provided by the override.
Sub-sampling occurs if self.output_dim() is less than self.input_dim().
Sourcepub fn output_dim(&self) -> usize
pub fn output_dim(&self) -> usize
Return the output dimension for the transformation.
Sourcepub fn preserves_norms(&self) -> bool
pub fn preserves_norms(&self) -> bool
Return whether or not the transform preserves norms.
For this transform, norms are not preserved when the output dimensionality is less than the input dimensionality.
Sourcepub fn transform_into(
&self,
dst: &mut [f32],
src: &[f32],
) -> Result<(), TransformFailed>
pub fn transform_into( &self, dst: &mut [f32], src: &[f32], ) -> Result<(), TransformFailed>
Perform the transformation of the src vector into the dst vector.
§Errors
Returns an error if
src.len() != self.input_dim().dst.len() != self.output_dim().
Trait Implementations§
Source§impl Clone for RandomRotation
impl Clone for RandomRotation
Source§fn clone(&self) -> RandomRotation
fn clone(&self) -> RandomRotation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RandomRotation
impl RefUnwindSafe for RandomRotation
impl Send for RandomRotation
impl Sync for RandomRotation
impl Unpin for RandomRotation
impl UnsafeUnpin for RandomRotation
impl UnwindSafe for RandomRotation
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more