Struct rdir_encoding::IntegerEncoding
[−]
[src]
pub struct IntegerEncoding;
Integer encoding.
In integer encoding, floating point numbers are converted to integer values by multiplying with a factor and discard everything after the decimal point. Depending on the multiplication factor this can change the precision but with a sufficiently large factor it is lossless. The integer values can then often be compressed with delta encoding which is the main motivation for it.
Examples
use rdir_encoding::IntegerEncoding; let data = [1.00, 1.00, 0.50]; let encoded = IntegerEncoding::encode(&data, 100).unwrap(); assert_eq!(encoded, vec![100, 100, 50]); let decoded = IntegerEncoding::decode(&encoded, 100).unwrap(); assert_eq!(decoded, data);
Methods
impl IntegerEncoding
[src]
pub fn decode<T>(values: &[T], factor: i32) -> Result<Vec<f32>, RdirError> where
T: Integer + NumCast + PrimInt,
[src]
T: Integer + NumCast + PrimInt,
Decode and return the decoded data
pub fn encode<T>(values: &[T], factor: i32) -> Result<Vec<i32>, RdirError> where
T: Float,
[src]
T: Float,
Encode any array of 'T' where T
can be any Integer with an desired factor