[−][src]Struct hilbert::normalize::FloatDataRange
The observed range of values seen in a set of points whose coordinates are signed 64-bit floats.
From this information we can determine how to translate the coordinates so that their normalized range has a low of zero. This permits us to use the fewest number of bits to represent them when constructing a Hilbert index.
Motivation.
- The Hilbert Curve transformation requires non-negative numbers, so all values must be translated until the lowest is zero. That means that if the lowest value is negative, we shift to the positive direction, or contrariwise to the negative direction.
- The execution time of the Hilbert transformation is directly proportional to the number of bits used to represent each value. Thus if we can sacrifice some precision, each value can be multiplied by a scale factor and rounded to the nearest integer to compress the value (and sacrifice information).
Fields
low: f64
Lowest value of any coordinate of any point in a collection of points.
high: f64
Highest value of any coordinate of any point in a collection of points.
scale: f64
Multiplier to apply before rounding to an integer value, sacrificing some precision.
For example, if you want to encode values such that you preserve precision to the hundredth place, scale
should be 100.
bits_required: usize
Minimum number of bits required to represent a normalized value without loss of information for the given scale factor.
Example:
- If
low
is -5.02 andhigh
is 3.13 then the range is 8.15. Ifscale
is 100, the range becomes 815, so 10 bits are required to represent all values in that range.
Methods
impl FloatDataRange
[src]
pub fn new(low: f64, high: f64, scale: f64) -> Self
[src]
Create a FloatDataRange
without reference to particular data.
pub fn from_f64<I>(points: &[I], scale: f64) -> Self where
&'a I: IntoIterator<Item = &'a f64>,
[src]
&'a I: IntoIterator<Item = &'a f64>,
Study all f64
coordinates in all points to find the minimum and maximum values.
pub fn range(&self) -> f64
[src]
Range from low to high value.
pub fn normalize(&self, coordinate: f64) -> u32
[src]
Normalize an f64
coordinate
value, shifting it enough so that the minimum value found in any point
is shifted to zero and the maximum value is shifted to range
, and using the full number of bits required for the range
multiplied by the scale.
pub fn compress(&self, coordinate: f64, bits_allocated: usize) -> u32
[src]
Normalize an f64
coordinate
value, shifting it enough so that the minimum value found in any point
is shifted to zero and the maximum value is shifted to range
, then optionally compressing the range by bit shifting
such that no more than the given number of bits are required for the largest value.
Trait Implementations
impl Clone for FloatDataRange
[src]
fn clone(&self) -> FloatDataRange
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl PartialEq<FloatDataRange> for FloatDataRange
[src]
fn eq(&self, other: &FloatDataRange) -> bool
[src]
fn ne(&self, other: &FloatDataRange) -> bool
[src]
impl Debug for FloatDataRange
[src]
impl StructuralPartialEq for FloatDataRange
[src]
Auto Trait Implementations
impl Send for FloatDataRange
impl Sync for FloatDataRange
impl Unpin for FloatDataRange
impl UnwindSafe for FloatDataRange
impl RefUnwindSafe for FloatDataRange
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,