assign3/mat.cpp
// extracts a matrix from another starting at (minr, minc) and of
// the size given.
// NOTE: zero size means "to the end of row or column"!
// WARNING: allocates new matrix for answer
extracts a matrix from another starting at (minr, minc) and of
the size given.
NOTE: zero size means "to the end of row or column".
WARNING: allocates new matrix for answer
extracts a matrix from another starting at ( minr minc ) and of the size given . NOTE : zero size means " to the end of row or column " . WARNING : allocates new matrix for answer
Matrix Matrix::extract(int minr, int minc, int sizer, int sizec)
{
    if (sizer==0) sizer = maxr - minr;
    if (sizec==0) sizec = maxc - minc;
    checkBounds(minr, minc, "lower bounds extract");
    checkBounds(minr+sizer-1, minc+sizec-1, "upper bounds extract");
    Matrix out(sizer, sizec);
    for (int r=minr; r<minr+sizer; r++) {
        for (int c=minc; c<minc+sizec; c++) {
            out.m[r-minr][c-minc] = m[r][c];
        }
    }
    out.defined = true;
    return out;
}
Matrix Matrix :: extract ( int minr , int minc , int sizer , int sizec ) { if ( sizer == 0 ) sizer = maxr - minr ; if ( sizec == 0 ) sizec = maxc - minc ; checkBounds ( minr , minc , " " ) ; checkBounds ( minr + sizer - 1 , minc + sizec - 1 , " " ) ; Matrix out ( sizer , sizec ) ; for ( int r = minr ; r < minr + sizer ; r ++ ) { for ( int c = minc ; c < minc + sizec ; c ++ ) { out . m [ r - minr ] [ c - minc ] = m [ r ] [ c ] ; } } out . defined = true ; return out ; }
extracts a matrix from another starting at (minr, minc) and of
the size given.
extracts a matrix from another starting at ( minr minc ) and of the size given .