* This code computes a score for each non-zero matrix entry in * aMat[r1..r2, c1..c2]. If all entries are zero, false is returned, * otherwise true. In the latter case, the minimum of all scores * is sought, and the row and column indices of the corresponding * matrix entry are stored in bestR and bestC. **/
| 66 | * matrix entry are stored in bestR and bestC. |
| 67 | **/ |
| 68 | bool pivot(const matrix aMat, const int r1, const int r2, const int c1, |
| 69 | const int c2, int* bestR, int* bestC, const ring R) |
| 70 | { |
| 71 | int bestScore; int score; bool foundBestScore = false; poly matEntry; |
| 72 | |
| 73 | for (int c = c1; c <= c2; c++) |
| 74 | { |
| 75 | for (int r = r1; r <= r2; r++) |
| 76 | { |
| 77 | matEntry = MATELEM(aMat, r, c); |
| 78 | if (matEntry != NULL) |
| 79 | { |
| 80 | score = pivotScore(pGetCoeff(matEntry), R); |
| 81 | if ((!foundBestScore) || (score < bestScore)) |
| 82 | { |
| 83 | bestScore = score; |
| 84 | *bestR = r; |
| 85 | *bestC = c; |
| 86 | } |
| 87 | foundBestScore = true; |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return foundBestScore; |
| 93 | } |
| 94 | |
| 95 | bool unitMatrix(const int n, matrix &unitMat, const ring R) |
| 96 | { |
no test coverage detected