pub fn distances_to_point_indices(
        &self,
        is: &[PointIndex],
        js: &[PointIndex],
    ) -> PointCloudResult<Vec<f32>> {
        let mut dists: Vec<f32> = vec![0.0;is.len()*js.len()];
        if is.len()*js.len() > self.chunk  {
            let dist_iter = dists.par_chunks_mut(js.len());
            let indexes_iter = is.par_iter().map(|i| (i,js));
            let error: Mutex<Result<(), PointCloudError>> = Mutex::new(Ok(()));
            dist_iter.zip(indexes_iter).for_each(|(chunk_dists,(i,chunk_indexes))| {
                match self.get_point(*i) {
                    Ok(x) => {
                        for (d,j) in chunk_dists.iter_mut().zip(chunk_indexes) {
                            match self.get_point(*j) {
                                Ok(y) => *d = (M::dense)(x, y),
                                Err(e) => {
                                    *error.lock().unwrap() = Err(e);
                                }
                            }
                        }
                    },
                    Err(e) => {
                        *error.lock().unwrap() = Err(e);
                    }
                };
                
            });
            (error.into_inner().unwrap())?;
        } else {
            for (k,i) in is.iter().enumerate() {
                let x = self.get_point(*i)?;
                for (l,j) in js.iter().enumerate() {
                    let y = self.get_point(*j)?;
                    dists[k*js.len() + l] = (M::dense)(x, y);
                }
            }
        }
        Ok(dists)
    }
/// The main distance function. This paralizes if there are more than 100 points.
The main distance function. This paralizes if there are more than 100 points.
The main distance function . This paralizes if there are more than 100 points .
pub fn distances_to_point_indices(
        &self,
        is: &[PointIndex],
        js: &[PointIndex],
    ) -> PointCloudResult<Vec<f32>> {
        let mut dists: Vec<f32> = vec![0.0;is.len()*js.len()];
        if is.len()*js.len() > self.chunk  {
            let dist_iter = dists.par_chunks_mut(js.len());
            let indexes_iter = is.par_iter().map(|i| (i,js));
            let error: Mutex<Result<(), PointCloudError>> = Mutex::new(Ok(()));
            dist_iter.zip(indexes_iter).for_each(|(chunk_dists,(i,chunk_indexes))| {
                match self.get_point(*i) {
                    Ok(x) => {
                        for (d,j) in chunk_dists.iter_mut().zip(chunk_indexes) {
                            match self.get_point(*j) {
                                Ok(y) => *d = (M::dense)(x, y),
                                Err(e) => {
                                    *error.lock().unwrap() = Err(e);
                                }
                            }
                        }
                    },
                    Err(e) => {
                        *error.lock().unwrap() = Err(e);
                    }
                };
            });
            (error.into_inner().unwrap())?;
        } else {
            for (k,i) in is.iter().enumerate() {
                let x = self.get_point(*i)?;
                for (l,j) in js.iter().enumerate() {
                    let y = self.get_point(*j)?;
                    dists[k*js.len() + l] = (M::dense)(x, y);
                }
            }
        }
        Ok(dists)
    }
pub fn distances_to_point_indices ( & self , is : & [ PointIndex ] , js : & [ PointIndex ] , ) -> PointCloudResult < Vec < f32 > > { let mut dists : Vec < f32 > = vec ! [ 0.0 is len ( ) js len ( ) ] ; if is . len ( ) * js . len ( ) > self . chunk { let dist_iter = dists . par_chunks_mut ( js . len ( ) ) ; let indexes_iter = is . par_iter ( ) . map ( | i | ( i , js ) ) ; let error : Mutex < Result < ( ) , PointCloudError > > = Mutex :: new ( Ok ( ( ) ) ) ; dist_iter . zip ( indexes_iter ) . for_each ( | ( chunk_dists , ( i , chunk_indexes ) ) | { match self . get_point ( * i ) { Ok ( x ) => { for ( d , j ) in chunk_dists . iter_mut ( ) . zip ( chunk_indexes ) { match self . get_point ( * j ) { Ok ( y ) => * d = ( M :: dense ) ( x , y ) , Err ( e ) => { * error . lock ( ) . unwrap ( ) = Err ( e ) ; } } } } , Err ( e ) => { * error . lock ( ) . unwrap ( ) = Err ( e ) ; } } ; } ) ; ( error . into_inner ( ) . unwrap ( ) ) ? ; } else { for ( k , i ) in is . iter ( ) . enumerate ( ) { let x = self . get_point ( * i ) ? ; for ( l , j ) in js . iter ( ) . enumerate ( ) { let y = self . get_point ( * j ) ? ; dists [ k * js . len ( ) + l ] = ( M :: dense ) ( x , y ) ; } } } Ok ( dists ) }
The main distance function.
The main distance function .
&self
is
&[PointIndex]
js
&[PointIndex]
&self
is
&[PointIndex]
js
&[PointIndex]