pub fn vcombine(
    umatrix: &DMatrix<f32>,
    bmatrix: &DMatrix<f32>,
) -> Result<DMatrix<f32>, MatrixCompareError> {
    // Check for matching number of rows
    if umatrix.shape().1 != bmatrix.shape().1 {
        return Err(MatrixCompareError);
    }

    // Allocate new matrix
    let rows = umatrix.shape().0 + bmatrix.shape().0;
    let cols = umatrix.shape().1;
    let mut concatenated = DMatrix::<f32>::zeros(rows, cols);

    for i in 0..umatrix.shape().0 {
        for j in 0..umatrix.shape().1 {
            concatenated[(i, j)] = umatrix[(i, j)];
        }
    }

    let dx = umatrix.shape().0;
    for j in 0..bmatrix.shape().1 {
        let mut i_bmatrix = 0;
        for i_shifted in dx..dx + bmatrix.shape().0 {
            concatenated[(i_shifted, j)] = bmatrix[(i_bmatrix, j)];
            i_bmatrix += 1;
        }
    }

    Ok(concatenated)
}
/// Vertically combines two matrices of similar dimensions
Vertically combines two matrices of similar dimensions
Vertically combines two matrices of similar dimensions
pub fn vcombine(
    umatrix: &DMatrix<f32>,
    bmatrix: &DMatrix<f32>,
) -> Result<DMatrix<f32>, MatrixCompareError> {
    // Check for matching number of rows
    if umatrix.shape().1 != bmatrix.shape().1 {
        return Err(MatrixCompareError);
    }
    // Allocate new matrix
    let rows = umatrix.shape().0 + bmatrix.shape().0;
    let cols = umatrix.shape().1;
    let mut concatenated = DMatrix::<f32>::zeros(rows, cols);
    for i in 0..umatrix.shape().0 {
        for j in 0..umatrix.shape().1 {
            concatenated[(i, j)] = umatrix[(i, j)];
        }
    }
    let dx = umatrix.shape().0;
    for j in 0..bmatrix.shape().1 {
        let mut i_bmatrix = 0;
        for i_shifted in dx..dx + bmatrix.shape().0 {
            concatenated[(i_shifted, j)] = bmatrix[(i_bmatrix, j)];
            i_bmatrix += 1;
        }
    }
    Ok(concatenated)
}
pub fn vcombine ( umatrix : & DMatrix < f32 > , bmatrix : & DMatrix < f32 > , ) -> Result < DMatrix < f32 > , MatrixCompareError > { // Check for matching number of rows if umatrix . shape ( ) . 1 != bmatrix . shape ( ) . 1 { return Err ( MatrixCompareError ) ; } // Allocate new matrix let rows = umatrix . shape ( ) . 0 + bmatrix . shape ( ) . 0 ; let cols = umatrix . shape ( ) . 1 ; let mut concatenated = DMatrix :: < f32 > :: zeros ( rows , cols ) ; for i in 0 .. umatrix . shape ( ) . 0 { for j in 0 .. umatrix . shape ( ) . 1 { concatenated [ ( i , j ) ] = umatrix [ ( i , j ) ] ; } } let dx = umatrix . shape ( ) . 0 ; for j in 0 .. bmatrix . shape ( ) . 1 { let mut i_bmatrix = 0 ; for i_shifted in dx .. dx + bmatrix . shape ( ) . 0 { concatenated [ ( i_shifted , j ) ] = bmatrix [ ( i_bmatrix , j ) ] ; i_bmatrix += 1 ; } } Ok ( concatenated ) }
Vertically combines two matrices of similar dimensions
Vertically combines two matrices of similar dimensions
umatrix
&DMatrix<f32>
bmatrix
&DMatrix<f32>
umatrix
&DMatrix<f32>
bmatrix
&DMatrix<f32>