(
csc: &CscMatrix<T>,
shape: Shape,
row_selection: &SelectInfoElem,
col_selection: &SelectInfoElem,
)
| 394 | } |
| 395 | |
| 396 | fn convert_to_array_f64_csc_selected<T: NumericOps>( |
| 397 | csc: &CscMatrix<T>, |
| 398 | shape: Shape, |
| 399 | row_selection: &SelectInfoElem, |
| 400 | col_selection: &SelectInfoElem, |
| 401 | ) -> anyhow::Result<Array2<f64>> { |
| 402 | let row_indices = select_info_elem_to_indices(row_selection, shape[0])?; |
| 403 | let col_indices = select_info_elem_to_indices(col_selection, shape[1])?; |
| 404 | let mut dense = Array2::<f64>::zeros((row_indices.len(), col_indices.len())); |
| 405 | |
| 406 | // Create a mapping from original row indices to output row indices |
| 407 | let row_map: HashMap<usize, usize> = row_indices |
| 408 | .iter() |
| 409 | .enumerate() |
| 410 | .map(|(i, &row)| (row, i)) |
| 411 | .collect(); |
| 412 | |
| 413 | for (out_col, &col) in col_indices.iter().enumerate() { |
| 414 | if col < csc.ncols() { |
| 415 | let col_start = csc.col_offsets()[col]; |
| 416 | let col_end = csc.col_offsets()[col + 1]; |
| 417 | for (&row, &value) in csc.row_indices()[col_start..col_end] |
| 418 | .iter() |
| 419 | .zip(csc.values()[col_start..col_end].iter()) |
| 420 | { |
| 421 | if let Some(&out_row) = row_map.get(&row) { |
| 422 | dense[[out_row, out_col]] = NumCast::from(value) |
| 423 | .ok_or_else(|| anyhow!("Failed to convert value to f64"))?; |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | Ok(dense) |
| 429 | } |
| 430 | |
| 431 | pub fn convert_to_array_f64_selected( |
| 432 | data: &ArrayData, |
nothing calls this directly
no test coverage detected