Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //chatgpt optimized submatrix to reduce branching
- constexpr auto submatrix(size_type remove_row, size_type remove_column) const noexcept {
- assert(remove_row < rows() && remove_column < columns() && "submatrix: row and column to remove must be inside the original matrix.");
- Matrix<ROWS - 1, COLUMNS - 1> r;
- uint8_t ri = 0;
- for (size_type i = 0; i < rows(); i++) {
- if (i == remove_row) {
- continue;
- }
- for (size_type j = 0; j < columns(); j++) {
- if (j == remove_column) {
- continue;
- }
- r[ri++] = _data[i * columns() + j];
- }
- }
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement