Module hpo::matrix

source ·
Expand description

A custom matrix for quick row and column-based data access

Matrix is only used within the SimilarityCombiner trait and should not be used for other purposes, as it does not contain many safety guarantees.

Imagine the following matrix / Dataframe

Index0123
011121314
121222324
231323334
use hpo::matrix::Matrix;
let data = vec![11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34];
let m = Matrix::new(3, 4, &data);

for row in m.rows() {
    let v: Vec<String> = row.map(|v| format!("{}", v)).collect();
    println!("[{}]", v.join(", "));
}

// >> [11, 12, 13, 14]
// >> [21, 22, 23, 24]
// >> [31, 32, 33, 34]


for col in m.cols() {
    let v: Vec<String> = col.map(|v| format!("{}", v)).collect();
    println!("[{}]", v.join(", "));
}

// >> [11, 21, 31]
// >> [12, 22, 32]
// >> [13, 23, 33]
// >> [14, 24, 34]

There are no logic checks to ensure that the rows and column match the data length, so callers must ensure this

Structs§

  • An iterator of the values of a single column of a Matrix
  • Iterates the columns of a Matrix, returning an Iterator over individual column values
  • A custom matrix for quick row and column-based data access
  • An iterator of the values of a single row of a Matrix
  • Iterates the rows of a Matrix, returning an Iterator over individual row values