GetSubMatrix BaseMatrix::column(int first_col) const { REPORT Tracer tr("SubMatrix(column)"); int c = first_col - 1; if (c<0) Throw(SubMatrixDimensionException()); return GetSubMatrix(this, 0, -1, c, 1, false); }
GetSubMatrix BaseMatrix::row(int first_row) const { REPORT Tracer tr("SubMatrix(row)"); int a = first_row - 1; if (a<0) Throw(SubMatrixDimensionException()); return GetSubMatrix(this, a, 1, 0, -1, false); }
GetSubMatrix BaseMatrix::columns(int first_col, int last_col) const { REPORT Tracer tr("SubMatrix(columns)"); int c = first_col - 1; int d = last_col - first_col + 1; if (c<0 || d<0) Throw(SubMatrixDimensionException()); // allow zero rows or columns return GetSubMatrix(this, 0, -1, c, d, false); }
GetSubMatrix BaseMatrix::rows(int first_row, int last_row) const { REPORT Tracer tr("SubMatrix(rows)"); int a = first_row - 1; int b = last_row - first_row + 1; if (a<0 || b<0) Throw(SubMatrixDimensionException()); // allow zero rows or columns return GetSubMatrix(this, a, b, 0, -1, false); }
GetSubMatrix BaseMatrix::sym_submatrix(int first_row, int last_row) const { REPORT Tracer tr("sym_submatrix"); int a = first_row - 1; int b = last_row - first_row + 1; if (a<0 || b<0) Throw(SubMatrixDimensionException()); // allow zero rows or columns return GetSubMatrix( this, a, b, a, b, true); }
void GetSubMatrix::SetUpLHS() { REPORT Tracer tr("SubMatrix(LHS)"); const BaseMatrix* bm1 = bm; GeneralMatrix* gm1 = ((BaseMatrix*&)bm)->Evaluate(); if ((BaseMatrix*)gm1!=bm1) Throw(ProgramException("Invalid LHS")); if (row_number < 0) row_number = gm1->Nrows(); if (col_number < 0) col_number = gm1->Ncols(); if (row_skip+row_number > gm1->Nrows() || col_skip+col_number > gm1->Ncols()) Throw(SubMatrixDimensionException()); }
void GetSubMatrix::operator<<(const int* r) { REPORT Tracer tr("SubMatrix(<<int*)"); SetUpLHS(); if (row_skip+row_number > gm->Nrows() || col_skip+col_number > gm->Ncols()) Throw(SubMatrixDimensionException()); MatrixRow mr(gm, LoadOnEntry+StoreOnExit+DirectPart, row_skip); // do need LoadOnEntry MatrixRowCol sub; int i = row_number; while (i--) { mr.SubRowCol(sub, col_skip, col_number); // put values in sub sub.Copy(r); mr.Next(); } }
GetSubMatrix& BaseMatrix::Row(int first_row) const #else GetSubMatrix BaseMatrix::Row(int first_row) const #endif { REPORT Tracer tr("SubMatrix(row)"); int a = first_row - 1; if (a<0) Throw(SubMatrixDimensionException()); #ifdef TEMPS_DESTROYED_QUICKLY GetSubMatrix* x = new GetSubMatrix(this, a, 1, 0, -1, false); MatrixErrorNoSpace(x); return *x; #else return GetSubMatrix(this, a, 1, 0, -1, false); #endif }
GetSubMatrix& BaseMatrix::Column(int first_col) const #else GetSubMatrix BaseMatrix::Column(int first_col) const #endif { REPORT Tracer tr("SubMatrix(column)"); int c = first_col - 1; if (c<0) Throw(SubMatrixDimensionException()); #ifdef TEMPS_DESTROYED_QUICKLY GetSubMatrix* x = new GetSubMatrix(this, 0, -1, c, 1, false); MatrixErrorNoSpace(x); return *x; #else return GetSubMatrix(this, 0, -1, c, 1, false); #endif }
GetSubMatrix& BaseMatrix::Rows(int first_row, int last_row) const #else GetSubMatrix BaseMatrix::Rows(int first_row, int last_row) const #endif { REPORT Tracer tr("SubMatrix(rows)"); int a = first_row - 1; int b = last_row - first_row + 1; if (a<0 || b<0) Throw(SubMatrixDimensionException()); // allow zero rows or columns #ifdef TEMPS_DESTROYED_QUICKLY GetSubMatrix* x = new GetSubMatrix(this, a, b, 0, -1, false); MatrixErrorNoSpace(x); return *x; #else return GetSubMatrix(this, a, b, 0, -1, false); #endif }
GetSubMatrix& BaseMatrix::Columns(int first_col, int last_col) const #else GetSubMatrix BaseMatrix::Columns(int first_col, int last_col) const #endif { REPORT Tracer tr("SubMatrix(columns)"); int c = first_col - 1; int d = last_col - first_col + 1; if (c<0 || d<0) Throw(SubMatrixDimensionException()); // allow zero rows or columns #ifdef TEMPS_DESTROYED_QUICKLY GetSubMatrix* x = new GetSubMatrix(this, 0, -1, c, d, false); MatrixErrorNoSpace(x); return *x; #else return GetSubMatrix(this, 0, -1, c, d, false); #endif }