void SciDoc::moveUp() { if ( int_->curEdit_ == NULL ) return; if ( hasSelectedText() ) { int line1, line2, col1, col2; getSelection(line1, col1, line2, col2); if ( line1 == 0 ) return; int realLine2 = line2; if ( col2 == 0 ) --line2; int_->curEdit_->beginUndoAction(); for (int line = line1; line <= line2; ++line) { int_->curEdit_->setCursorPosition(line, 0); swapLines(); } setSelection(line1 - 1, col1, realLine2 - 1, col2); int_->curEdit_->endUndoAction(); } else { int line, col; int_->curEdit_->getCursorPosition(&line, &col); if ( line > 0 ) { swapLines(); int_->curEdit_->setCursorPosition(line - 1, col); } } }
void SciDoc::moveDown() { if ( int_->curEdit_ == NULL ) return; if ( hasSelectedText() ) { int line1, line2, col1, col2; getSelection(line1, col1, line2, col2); int realLine2 = line2; if ( col2 == 0 ) --line2; if ( line2 == lineCount() - 1 ) return; int_->curEdit_->beginUndoAction(); for (int line = line2 + 1; line >= line1 + 1; --line) { int_->curEdit_->setCursorPosition(line, 0); swapLines(); } setSelection(line1 + 1, col1, realLine2 + 1, col2); int_->curEdit_->endUndoAction(); } else { int line, col; int_->curEdit_->getCursorPosition(&line, &col); if ( line < lineCount() - 1 ) { int_->curEdit_->setCursorPosition(line + 1, 0); swapLines(); int_->curEdit_->setCursorPosition(line + 1, col); } } }
double getDeterminant(pmatrix mx){ if (mx == NULL || mx->rowCount != mx->colCount || mx->size == 0) return NULL; pmatrix res = mxInitMx(mx); for (uint i = 0; i < res->rowCount; ++i) for (uint j = 0; j < res->colCount; ++j) res->cells[i][j] = mx->cells[i][j]; if (res->size == 1) return res->cells[0][0]; double det = 1.0; int swapCount = 0; for (uint i = 0; i < res->rowCount; ++i) { if (res->cells[i][i] == 0.0) { for (uint j = i + 1; j < res->rowCount; ++j) { if (res->cells[j][i] != 0.0) { swapLines(res, i, j); ++swapCount; } } if (res->cells[i][i] == 0.0) return 0.0; } double divisor = res->cells[i][i]; for (uint j = 0; j < res->colCount; ++j) res->cells[i][j] /= divisor; det *= divisor; for (uint j = i + 1; j < res->rowCount; ++j) { double mult = res->cells[j][i]; for (uint k = 0; k < res->colCount; ++k) res->cells[j][k] -= res->cells[i][k] * mult; } } return det * pow(-1.0, swapCount); }
void gauss(int n, ll p) { // nx(n+1)-Matrix, Körper F_p. for (int line = 0; line < n; line++) { int swappee = line; while (mat[swappee][line] == 0) swappee++; swapLines(n, line, swappee); normalLine(n, line, p); takeAll(n, line, p); }}