pub struct SSPEncoder { /* private fields */ }
Expand description
The SSPEncoder
converts an input sample (a point in some domain) into an SSP vector.
For simplicity, it assumes the input is a slice of f32
values with length equal to domain_dim
.
Internally, it stores a set of frequency means to compute phase values that are then converted
into cosine/sine pairs to form the SSP vector.
Implementations§
Source§impl SSPEncoder
impl SSPEncoder
Sourcepub fn update_lengthscale(&mut self, ls: f32)
pub fn update_lengthscale(&mut self, ls: f32)
Updates the lengthscale parameter.
The lengthscale is used to scale the dot products when computing phases.
§Arguments
ls
- The new lengthscale value.
Sourcepub fn encode(&self, x: &[f32]) -> Vec<f32>
pub fn encode(&self, x: &[f32]) -> Vec<f32>
Encodes a single input sample into an SSP vector.
The input sample is expected to have length equal to domain_dim
.
The encoder computes phase values using dot products with the frequency means,
scales them by the lengthscale, and then converts each phase into a cosine and sine pair.
§Arguments
x
- A slice off32
values representing the input sample.
§Returns
A vector of f32
values of length ssp_dim
representing the encoded SSP.
§Panics
Panics if the length of x
does not equal domain_dim
.