pub fn kendall_dist<K: OrDistElement>(v1: &[K], v2: &[K]) -> Result<usize, OrDistError<K>> {
    let (om1, om2) = ordmaps_identical(v1, v2)?;
    let keys: Vec<&&K> = om1.data.keys().collect();
    let n = keys.len();
    Ok((0..n)
        .map(|i| {
            let ri1 = om1.get(keys[i]);
            let ri2 = om2.get(keys[i]);
            (i + 1..n)
                .map({
                    |j| {
                        let rj1 = om1.get(keys[j]);
                        let rj2 = om2.get(keys[j]);
                        if ri1 > rj1 {
                            if ri2 > rj2 {
                                0
                            } else {
                                1
                            }
                        } else {
                            if ri2 < rj2 {
                                0
                            } else {
                                1
                            }
                        }
                    }
                })
                .sum::<usize>()
        })
        .sum())
}
/// Kendall distance between 2 orders.
/// 
/// The number of pairs of elements that are in mismatched order.
Kendall distance between 2 orders.
The number of pairs of elements that are in mismatched order.
Kendall distance between 2 orders . The number of pairs of elements that are in mismatched order .
pub fn kendall_dist<K: OrDistElement>(v1: &[K], v2: &[K]) -> Result<usize, OrDistError<K>> {
    let (om1, om2) = ordmaps_identical(v1, v2)?;
    let keys: Vec<&&K> = om1.data.keys().collect();
    let n = keys.len();
    Ok((0..n)
        .map(|i| {
            let ri1 = om1.get(keys[i]);
            let ri2 = om2.get(keys[i]);
            (i + 1..n)
                .map({
                    |j| {
                        let rj1 = om1.get(keys[j]);
                        let rj2 = om2.get(keys[j]);
                        if ri1 > rj1 {
                            if ri2 > rj2 {
                                0
                            } else {
                                1
                            }
                        } else {
                            if ri2 < rj2 {
                                0
                            } else {
                                1
                            }
                        }
                    }
                })
                .sum::<usize>()
        })
        .sum())
}
pub fn kendall_dist < K : OrDistElement > ( v1 : & [ K ] , v2 : & [ K ] ) -> Result < usize , OrDistError < K > > { let ( om1 , om2 ) = ordmaps_identical ( v1 , v2 ) ? ; let keys : Vec < & & K > = om1 . data . keys ( ) . collect ( ) ; let n = keys . len ( ) ; Ok ( ( 0 .. n ) . map ( | i | { let ri1 = om1 . get ( keys [ i ] ) ; let ri2 = om2 . get ( keys [ i ] ) ; ( i + 1 .. n ) . map ( { | j | { let rj1 = om1 . get ( keys [ j ] ) ; let rj2 = om2 . get ( keys [ j ] ) ; if ri1 > rj1 { if ri2 > rj2 { 0 } else { 1 } } else { if ri2 < rj2 { 0 } else { 1 } } } } ) . sum :: < usize > ( ) } ) . sum ( ) ) }
Kendall distance between 2 orders.
Kendall distance between 2 orders .
v1
&[K]
v2
&[K]
v1
&[K]
v2
&[K]