MCPcopy Create free account
hub / github.com/daniel-e/rustml / all_pair_distances

Function all_pair_distances

src/distance.rs:116–130  ·  view source on GitHub ↗
(m: &Matrix<f64>)

Source from the content-addressed store, hash-verified

114}
115
116pub fn all_pair_distances(m: &Matrix<f64>) -> Matrix<f64> {
117
118 let mut r = Matrix::fill(0.0, m.rows(), m.rows());
119
120 // TODO handling of NaN and stuff like this
121 for (i, row1) in m.row_iter().enumerate() {
122 for (j, row2) in m.row_iter_at(i + 1).enumerate() {
123 let p = j + i + 1;
124 let d = Euclid::compute(row1, row2).unwrap();
125 r.set(i, p, d);
126 r.set(p, i, d);
127 }
128 }
129 r
130}
131
132#[cfg(test)]
133mod tests {

Callers 1

test_all_pair_distancesFunction · 0.85

Calls 4

rowsMethod · 0.80
row_iterMethod · 0.80
row_iter_atMethod · 0.80
setMethod · 0.80

Tested by 1

test_all_pair_distancesFunction · 0.68