pub fn closest_mean<V: Value>(point: &ArrayView1<V>, means: &ArrayView2<V>) -> Ix {
    assert!(means.dim().0 > 0);
    let mut iter = means.outer_iter().enumerate();
    if let Some(compare) = iter.next() {
        let mut index = compare.0;
        let mut shortest_distance = distance_squared(point, &compare.1);
        for compare in iter {
            let distance = distance_squared(point, &compare.1);
            if distance < shortest_distance {
                shortest_distance = distance;
                index = compare.0;
            }
        }
        return index;
    }
    0 // Should never hit this due to the assertion of the precondition
}
/// Find the closest mean to a particular data point.
Find the closest mean to a particular data point.
Find the closest mean to a particular data point .
pub fn closest_mean<V: Value>(point: &ArrayView1<V>, means: &ArrayView2<V>) -> Ix {
    assert!(means.dim().0 > 0);
    let mut iter = means.outer_iter().enumerate();
    if let Some(compare) = iter.next() {
        let mut index = compare.0;
        let mut shortest_distance = distance_squared(point, &compare.1);
        for compare in iter {
            let distance = distance_squared(point, &compare.1);
            if distance < shortest_distance {
                shortest_distance = distance;
                index = compare.0;
            }
        }
        return index;
    }
    0 // Should never hit this due to the assertion of the precondition
}
pub fn closest_mean < V : Value > ( point : & ArrayView1 < V > , means : & ArrayView2 < V > ) -> Ix { assert ! ( means dim ( ) 0 0 ) ; let mut iter = means . outer_iter ( ) . enumerate ( ) ; if let Some ( compare ) = iter . next ( ) { let mut index = compare . 0 ; let mut shortest_distance = distance_squared ( point , & compare . 1 ) ; for compare in iter { let distance = distance_squared ( point , & compare . 1 ) ; if distance < shortest_distance { shortest_distance = distance ; index = compare . 0 ; } } return index ; } 0 // Should never hit this due to the assertion of the precondition }
Find the closest mean to a particular data point.
Find the closest mean to a particular data point .
point
&ArrayView1<V>
means
&ArrayView2<V>
point
&ArrayView1<V>
means
&ArrayView2<V>