Decode a PQ code back to an approximate FP32 vector. Charges `dim * size_of:: ()` bytes to the governor (if set) before allocating the output buffer.
(&self, code: &[u8])
| 191 | /// Charges `dim * size_of::<f32>()` bytes to the governor (if set) |
| 192 | /// before allocating the output buffer. |
| 193 | pub fn decode(&self, code: &[u8]) -> Result<Vec<f32>, VectorError> { |
| 194 | debug_assert_eq!(code.len(), self.m); |
| 195 | let _g = try_reserve_or_skip(&self.governor, self.dim * size_of::<f32>())?; |
| 196 | let mut out = Vec::with_capacity(self.dim); |
| 197 | for (sub, &c) in code.iter().enumerate() { |
| 198 | out.extend_from_slice(&self.codebooks[sub][c as usize]); |
| 199 | } |
| 200 | Ok(out) |
| 201 | } |
| 202 | |
| 203 | /// Serialize the codec to bytes with a versioned magic header. |
| 204 | /// |