Lines Matching defs:row

72   assert(elems.size() == nColumns && "elems must match row length!");
73 unsigned row = appendExtraRow();
75 at(row, col) = elems[col];
76 return row;
82 for (unsigned row = 0; row < nRows; ++row)
84 transp(col, row) = at(row, col);
110 void Matrix<T>::swapRows(unsigned row, unsigned otherRow) {
111 assert((row < getNumRows() && otherRow < getNumRows()) &&
112 "Given row out of bounds");
113 if (row == otherRow)
116 std::swap(at(row, col), at(otherRow, col));
125 for (unsigned row = 0; row < nRows; row++)
126 std::swap(at(row, column), at(row, otherColumn));
130 MutableArrayRef<T> Matrix<T>::getRow(unsigned row) {
131 return {&data[row * nReservedColumns], nColumns};
135 ArrayRef<T> Matrix<T>::getRow(unsigned row) const {
136 return {&data[row * nReservedColumns], nColumns};
140 void Matrix<T>::setRow(unsigned row, ArrayRef<T> elems) {
142 "elems size must match row length!");
144 at(row, i) = elems[i];
182 // The columns before the inserted columns stay at the same (row, col)
252 void Matrix<T>::fillRow(unsigned row, const T &value) {
254 at(row, col) = value;
305 void Matrix<T>::addToRow(unsigned row, ArrayRef<T> rowVec, const T &scale) {
309 at(row, col) += scale * rowVec[col];
313 void Matrix<T>::scaleRow(unsigned row, const T &scale) {
315 at(row, col) *= scale;
323 for (unsigned row = 0, e = getNumRows(); row < e; ++row)
324 at(row, targetColumn) += scale * at(row, sourceColumn);
329 for (unsigned row = 0, e = getNumRows(); row < e; ++row)
330 at(row, column) = -at(row, column);
334 void Matrix<T>::negateRow(unsigned row) {
336 at(row, column) = -at(row, column);
341 for (unsigned row = 0; row < nRows; ++row)
342 negateRow(row);
347 assert(rowVec.size() == getNumRows() && "Invalid row vector dimension!");
362 for (unsigned row = 0, e = getNumRows(); row < e; row++)
364 result[row] += at(row, i) * colVec[i];
368 /// Set M(row, targetCol) to its remainder on division by M(row, sourceCol)
370 /// sourceCol. This brings M(row, targetCol) to the range [0, M(row,
373 static void modEntryColumnOperation(Matrix<DynamicAPInt> &m, unsigned row,
376 assert(m(row, sourceCol) != 0 && "Cannot divide by zero!");
377 assert(m(row, sourceCol) > 0 && "Source must be positive!");
378 DynamicAPInt ratio = -floorDiv(m(row, targetCol), m(row, sourceCol));
387 assert(fromRow <= toRow && "end of row range must be after beginning!");
388 assert(toRow < nRows && "end of row range out of bounds!");
402 for (unsigned row = 0; row < nRows; ++row)
404 updatePrintMetrics<T>(at(row, column), ptm);
406 for (unsigned row = 0; row < nRows; ++row) {
408 printWithPrintMetrics<T>(os, at(row, column), MIN_SPACING, ptm);
471 // Invariant: in all rows above row, all columns from echelonCol onwards
472 // are all zero elements. In an iteration, if the curent row has any non-zero
475 for (unsigned row = 0; row < h.getNumRows(); ++row) {
476 // Search row for a non-empty entry, starting at echelonCol.
479 if (h(row, nonZeroCol) == 0)
484 // Continue to the next row with the same echelonCol if this row is all
496 // Make h(row, echelonCol) non-negative.
497 if (h(row, echelonCol) < 0) {
502 // Make all the entries in row after echelonCol zero.
504 // We make h(row, i) non-negative, and then apply the Euclidean GCD
505 // algorithm to (row, i) and (row, echelonCol). At the end, one of them
508 if (h(row, i) < 0) {
514 // At every step, we set h(row, targetCol) %= h(row, sourceCol), and
517 // h(row, targetCol) -= quotient * h(row, sourceCol),
518 // where quotient = floor(h(row, targetCol) / h(row, sourceCol)),
519 // which brings h(row, targetCol) to the range [0, h(row, sourceCol)).
522 // for every row, i.e., the above subtraction is done as a column
525 while (h(row, targetCol) != 0 && h(row, sourceCol) != 0) {
526 modEntryColumnOperation(h, row, sourceCol, targetCol, u);
530 // One of (row, echelonCol) and (row, i) is zero and the other is the gcd.
531 // Make it so that (row, echelonCol) holds the non-zero value.
532 if (h(row, echelonCol) == 0) {
541 modEntryColumnOperation(h, row, echelonCol, i, u);
549 DynamicAPInt IntMatrix::normalizeRow(unsigned row, unsigned cols) {
550 return normalizeRange(getRow(row).slice(0, cols));
553 DynamicAPInt IntMatrix::normalizeRow(unsigned row) {
554 return normalizeRow(row, getNumColumns());
602 // gaussian elimination with row operations.
613 // it with a nonzero row.
635 // by subtracting the ith row,
649 // by subtracting the ith row,
681 // For each vector (row) in the matrix, subtract its unit
688 assert(jNormSquared != 0 && "some row became zero! Inputs to this "
698 // Convert the matrix, interpreted (row-wise) as a basis
711 // We iterate starting from the second row to the last row.
713 // For the kth row, we first check μ_kj for all rows j < k.
734 // We start from the second row.
756 // going beyond the second row).
771 // For a row, first compute the LCM of the denominators.