MCPcopy Create free account
hub / github.com/Open-Quant/openquant / to_matrix

Function to_matrix

crates/openquant/src/structural_breaks.rs:317–331  ·  view source on GitHub ↗
(data: &[Vec<f64>])

Source from the content-addressed store, hash-verified

315}
316
317fn to_matrix(data: &[Vec<f64>]) -> StructuralBreakResult<DMatrix<f64>> {
318 let rows = data.len();
319 if rows == 0 {
320 return Err(StructuralBreakError::InputTooShort);
321 }
322 let cols = data[0].len();
323 if cols == 0 {
324 return Err(StructuralBreakError::InputTooShort);
325 }
326 if data.iter().any(|row| row.len() != cols) {
327 return Err(StructuralBreakError::InputTooShort);
328 }
329 let flat = data.iter().flat_map(|row| row.iter().cloned()).collect::<Vec<_>>();
330 Ok(DMatrix::from_row_slice(rows, cols, &flat))
331}
332
333fn matrix_to_vec(matrix: DMatrix<f64>) -> Vec<Vec<f64>> {
334 let mut rows = Vec::with_capacity(matrix.nrows());

Callers 1

_get_betasFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected