Merge branch 'march-2023-improvements' into kmeans-with-fastpair
This commit is contained in:
@@ -186,7 +186,10 @@ impl<'a, T: RealNumber + FloatNumber, M: Array2<T>> FastPair<'a, T, M> {
|
|||||||
pub fn ordered_pairs(&self) -> std::vec::IntoIter<&PairwiseDistance<T>> {
|
pub fn ordered_pairs(&self) -> std::vec::IntoIter<&PairwiseDistance<T>> {
|
||||||
// improvement: implement this to return `impl Iterator<Item = &PairwiseDistance<T>>`
|
// improvement: implement this to return `impl Iterator<Item = &PairwiseDistance<T>>`
|
||||||
// need to implement trait `Iterator` for `Vec<&PairwiseDistance<T>>`
|
// need to implement trait `Iterator` for `Vec<&PairwiseDistance<T>>`
|
||||||
let mut distances = self.distances.values().collect::<Vec<&PairwiseDistance<T>>>();
|
let mut distances = self
|
||||||
|
.distances
|
||||||
|
.values()
|
||||||
|
.collect::<Vec<&PairwiseDistance<T>>>();
|
||||||
distances.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
distances.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
||||||
distances.into_iter()
|
distances.into_iter()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1570,7 +1570,7 @@ pub trait Array2<T: Debug + Display + Copy + Sized>: MutArrayView2<T> + Sized +
|
|||||||
mean
|
mean
|
||||||
}
|
}
|
||||||
|
|
||||||
/// copy coumn as a vector
|
/// copy column as a vector
|
||||||
fn copy_col_as_vec(&self, col: usize, result: &mut Vec<T>) {
|
fn copy_col_as_vec(&self, col: usize, result: &mut Vec<T>) {
|
||||||
for (r, result_r) in result.iter_mut().enumerate().take(self.shape().0) {
|
for (r, result_r) in result.iter_mut().enumerate().take(self.shape().0) {
|
||||||
*result_r = *self.get((r, col));
|
*result_r = *self.get((r, col));
|
||||||
|
|||||||
Reference in New Issue
Block a user