pub fn block(start: (usize, usize), end: (usize, usize), matrix: &DMatrix<f32>) -> DMatrix<f32> {
    //TODO check for start and end valid for matrix

    let (_nrows, _ncols) = matrix.shape();

    let (dx, dy) = (end.0 - start.0, end.1 - start.1); // assume that start < end

    let mut work = DMatrix::<f32>::zeros(dx + 1, dy + 1);

    // iterate over matrix
    for i in start.0..end.0 + 1 {
        for j in start.1..end.1 + 1 {
            work[(i - start.0, j - start.1)] = matrix[(i, j)];
        }
    }

    work
}
/// Extracts desired block from a matrix
Extracts desired block from a matrix
Extracts desired block from a matrix
pub fn block(start: (usize, usize), end: (usize, usize), matrix: &DMatrix<f32>) -> DMatrix<f32> {
    //TODO check for start and end valid for matrix
    let (_nrows, _ncols) = matrix.shape();
    let (dx, dy) = (end.0 - start.0, end.1 - start.1); // assume that start < end
    let mut work = DMatrix::<f32>::zeros(dx + 1, dy + 1);
    // iterate over matrix
    for i in start.0..end.0 + 1 {
        for j in start.1..end.1 + 1 {
            work[(i - start.0, j - start.1)] = matrix[(i, j)];
        }
    }
    work
}
pub fn block ( start : ( usize , usize ) , end : ( usize , usize ) , matrix : & DMatrix < f32 > ) -> DMatrix < f32 > { //TODO check for start and end valid for matrix let ( _nrows , _ncols ) = matrix . shape ( ) ; let ( dx , dy ) = ( end . 0 - start . 0 , end . 1 - start . 1 ) ; // assume that start < end let mut work = DMatrix :: < f32 > :: zeros ( dx + 1 , dy + 1 ) ; // iterate over matrix for i in start . 0 .. end . 0 + 1 { for j in start . 1 .. end . 1 + 1 { work [ ( i - start . 0 , j - start . 1 ) ] = matrix [ ( i , j ) ] ; } } work }
Extracts desired block from a matrix
Extracts desired block from a matrix
start
(usize, usize)
end
(usize, usize)
matrix
&DMatrix<f32>
start
(usize, usize)
end
(usize, usize)
matrix
&DMatrix<f32>