nalgebra icon indicating copy to clipboard operation
nalgebra copied to clipboard

Matrix Views: non contiguous/regular slices

Open diviyank opened this issue 1 year ago • 0 comments

Hello,

First of all, thank you for this awesome crate.

I have a question on views: I which to build a Matrix view out of an initial DMatrix M, rather large because it contains datapoints. This view is actually non-regular and non contiguous: it depends on a vector V :Vec<usize> of indexes that contains the columns to select.

I can use the M.select_columns(V.iter()) to obtain the correct matrix, but if I understood correctly, this actually makes a copy of the selected elements, which in my use-case, could be quite large and quite expensive as well.

Is there a way to obtain a view of the data using V ?

context: This would be to compute the regression coefficients of the regression of one column w.r.t. data[V] :

    let selected_data = M.select_columns(V.iter());

    let qr = selected_data.qr();
    let (q, r) = (qr.q().transpose(), qr.r());
    let x = r.try_inverse().unwrap() * &q * &data.column(ref_node.to_owned());

Thank you, D

diviyank avatar Feb 29 '24 11:02 diviyank