pub fn find(&self, x: &[f64]) -> Result<Option<usize>, StrError> {
        // check
        if x.len() != self.ndim {
            return Err("x.len() must equal ndim");
        }

        // find index of container where x should be
        let index = match self.container_index(x) {
            Some(i) => i,
            None => return Err("cannot find point with coordinates outside the grid"),
        };

        // find container that should have a point close to `x`
        let container = match self.containers.get(&index) {
            Some(c) => c,
            None => return Ok(None), // no container has a point close to `x`
        };

        // find closest point to `x` in the container
        for item in container.values() {
            let distance = point_point_distance(&item.x, x)?;
            if distance <= self.radius_tol {
                return Ok(Some(item.id));
            }
        }
        Ok(None)
    }
/// Find previously inserted item to the grid
///
/// # Input
///
/// * `x` -- coordinates (ndim) of the item
///
/// # Output
///
/// * `id` -- if found, returns the identification number of the item
Find previously inserted item to the grid
Find previously inserted item to the grid
pub fn find(&self, x: &[f64]) -> Result<Option<usize>, StrError> {
        // check
        if x.len() != self.ndim {
            return Err("x.len() must equal ndim");
        }
        // find index of container where x should be
        let index = match self.container_index(x) {
            Some(i) => i,
            None => return Err("cannot find point with coordinates outside the grid"),
        };
        // find container that should have a point close to `x`
        let container = match self.containers.get(&index) {
            Some(c) => c,
            None => return Ok(None), // no container has a point close to `x`
        };
        // find closest point to `x` in the container
        for item in container.values() {
            let distance = point_point_distance(&item.x, x)?;
            if distance <= self.radius_tol {
                return Ok(Some(item.id));
            }
        }
        Ok(None)
    }
pub fn find ( & self , x : & [ f64 ] ) -> Result < Option < usize > , StrError > { // check if x . len ( ) != self . ndim { return Err ( " " ) ; } // find index of container where x should be let index = match self . container_index ( x ) { Some ( i ) => i , None => return Err ( " " ) , } ; // find container that should have a point close to `x` let container = match self . containers . get ( & index ) { Some ( c ) => c , None => return Ok ( None ) , // no container has a point close to `x` } ; // find closest point to `x` in the container for item in container . values ( ) { let distance = point_point_distance ( & item . x , x ) ? ; if distance <= self . radius_tol { return Ok ( Some ( item . id ) ) ; } } Ok ( None ) }
Find previously inserted item to the grid
Find previously inserted item to the grid
&self
x
&[f64]
&self
x
&[f64]
input
`x` -- coordinates (ndim) of the item
` x ` -- coordinates ( ndim ) of the item
output
`id` -- if found, returns the identification number of the item
` id ` -- if found returns the identification number of the item