bool SMatrix::CutIn2_Across(SMatrix& Upper,SMatrix& Lower,int iRow) { int i,j; if (nCol()==0) { Upper.ReSize(0,0); Lower.ReSize(0,0); return TRUE; } if(iRow>nRow()||iRow<0) return FALSE; if(!Upper.ReSize(iRow,nCol(),ERRORVAL)) return FALSE; if(!Lower.ReSize(nRow()-iRow,nCol(),ERRORVAL)) return FALSE; for(i=0;i<iRow;i++) for(j=0;j<nCol();j++) Upper[i][j] = GetElem(i,j); for(i=0;i<Lower.nRow();i++) for(j=0;j<nCol();j++) Lower[i][j] = GetElem(i+iRow,j); return TRUE; }
bool SMatrix::CutIn2_Vertical(SMatrix& Left,SMatrix& Right,int iCol) { int i,j; if (nCol()==0) { Left.ReSize(0,0); Right.ReSize(0,0); return TRUE; } if(iCol>nCol()||iCol<0) return FALSE; if(!Left.ReSize(nRow(),iCol,ERRORVAL)) return FALSE; if(!Right.ReSize(nRow(),nCol()-iCol,ERRORVAL)) return FALSE; for(i=0;i<nRow();i++) for(j=0;j<iCol;j++) Left[i][j] = GetElem(i,j); for(i=0;i<nRow();i++) for(j=0;j<Right.nCol();j++) Right[i][j] = GetElem(i,j+iCol); return TRUE; }
SMatrix SMatrix::GetPart(int left,int top,int bottom,int right) const { int i,j; SMatrix result; if(left>right||top>bottom||right>=nCol()||bottom>=nRow()||left<0||top<0||right<0||bottom<0) return result; if(!result.ReSize(bottom-top+1,right-left+1,ERRORVAL)) return result; for(i=0;i<result.nRow();i++) for(j=0;j<result.nCol();j++) result[i][j] = GetElem(i+left,j+top); return result; }