A weird expression in c++ - what does this mean? -
i've seen code finding minor of matrix:
regmatrix regmatrix::minor(const int row, const int col)const{ //printf("minor(row=%i, col=%i), rows=%i, cols=%i\n", row, col, rows, cols); assert((row >= 0) && (row < numrow) && (col >= 0) && (col < numcol)); regmatrix result(numrow-1,numcol-1); // copy content of matrix minor, except selected (int r = 0; r < (numrow - (row >= numrow)); r++){ (int c = 0; c < (numcol - (col > numcol)); c++){ //printf("r=%i, c=%i, value=%f, rr=%i, cc=%i \n", r, c, p[r-1][c-1], r - (r > row), c - (c > col)); result.setelement(r - (r > row), c - (c > col),_matrix[r-1][c-1]); } } return result; }
this first time encounter code line this: r < (numrow - (row >= numrow)).
what mean?
(row >= numrow)
boolean expression. if operator>=
has not been overloaded, should evaluate true
if row
greater or equal numrow
, , false
otherwise. when casting boolean integer subtraction, become 1 if true, 0 else.
Comments
Post a Comment