assign5/mat.cpp
// extracts a matrix from another starting at (minr, minc) and of
// the stride length given for rows and cols.
// WARNING: allocates new matrix for answer
extracts a matrix from another starting at (minr, minc) and of
the stride length given for rows and cols.
WARNING: allocates new matrix for answer
extracts a matrix from another starting at ( minr minc ) and of the stride length given for rows and cols . WARNING : allocates new matrix for answer
Matrix Matrix::extractStride(int minr, int minc, int stepr, int stepc)
{
    int newr, newc;
    checkBounds(minr, minc, "lower bounds extract");
    newr = (maxr-minr + (stepr - 1))/stepr + 1;
    newc = (maxc-minc + (stepc - 1))/stepc + 1;
    Matrix out(newr, newc);
    for (int r=minr; r<maxr; r+=stepr) {
        for (int c=minc; c<maxc; c+=stepc) {
            out.m[(r-minr)/stepr][(c-minc)/stepc] = m[r][c];
        }
    }
    out.defined = true;
    return out;
}
Matrix Matrix :: extractStride ( int minr , int minc , int stepr , int stepc ) { int newr , newc ; checkBounds ( minr , minc , " " ) ; newr = ( maxr - minr + ( stepr - 1 ) ) / stepr + 1 ; newc = ( maxc - minc + ( stepc - 1 ) ) / stepc + 1 ; Matrix out ( newr , newc ) ; for ( int r = minr ; r < maxr ; r += stepr ) { for ( int c = minc ; c < maxc ; c += stepc ) { out . m [ ( r - minr ) / stepr ] [ ( c - minc ) / stepc ] = m [ r ] [ c ] ; } } out . defined = true ; return out ; }
extracts a matrix from another starting at (minr, minc) and of
the stride length given for rows and cols.
extracts a matrix from another starting at ( minr minc ) and of the stride length given for rows and cols .