@@ -252,6 +252,8 @@ template <typename T>
252252 int rowsLhs = lhs.size () / columnsLhs;
253253 int rowsRhs = columnsLhs;
254254 int columnsRhs = rhs.size () / rowsRhs;
255+ assert (rowsLhs * columnsLhs == lhs.size ());
256+ assert (rowsRhs * columnsRhs == rhs.size ());
255257
256258 std::vector<T> result (rowsLhs * columnsRhs, T{});
257259 for (int i = 0 ; i < rowsLhs; i++) {
@@ -364,15 +366,15 @@ auto submatrix(Container&& matrix, int rowStart, int columnStart, int numRows,
364366
365367template <typename Lhs, typename Rhs>
366368auto assignSubmatrix (Lhs&& lhs, Rhs&& rhs, int rowStart, int columnStart,
367- int rowSize , int columnSize ) {
369+ int numRows , int numColumns ) {
368370 const int n = std::sqrt (lhs.size ());
369- assert ((rowStart + rowSize ) < n);
370- assert ((columnStart + columnSize ) < n);
371- assert (columnSize * rowSize == rhs.size ());
371+ assert ((rowStart + numRows ) <= n);
372+ assert ((columnStart + numColumns ) <= n);
373+ assert (numColumns * numRows == rhs.size ());
372374
373- for (int i = 0 ; i < columnSize ; ++i) {
374- for (int j = 0 ; j < rowSize ; ++j) {
375- lhs[(rowStart + j) * 4 + (columnStart + i)] = rhs[j * rowSize + i];
375+ for (int i = 0 ; i < numColumns ; ++i) {
376+ for (int j = 0 ; j < numRows ; ++j) {
377+ lhs[(rowStart + j) * n + (columnStart + i)] = rhs[j * numColumns + i];
376378 }
377379 }
378380}
0 commit comments