import { matrixCheckRanges } from "./matrixCheckRanges.js";
/**
 * Get a subMatrix from matrix, the function checks if the subMatrix
 * lies within the dimensions of the matrix.
 * @param matrix - the original matrix from which the subMatrix will be extracted.
 * @param options - options to define the subMatrix boundaries and duplication behavior.
 * @returns the subMatrix extracted from the original matrix.
 */
export function matrixGetSubMatrix(matrix, options) {
    const { startRow, endRow, startColumn, endColumn, duplicate = true, } = options;
    matrixCheckRanges(matrix, { startColumn, startRow, endColumn, endRow });
    const nbRows = endRow - startRow + 1;
    const subMatrix = [];
    if (duplicate) {
        for (let i = 0; i < nbRows; i++) {
            subMatrix.push(matrix[startRow + i].slice(startColumn, endColumn + 1));
        }
    }
    else {
        for (let i = 0; i < nbRows; i++) {
            subMatrix.push(matrix[startRow + i].subarray(startColumn, endColumn + 1));
        }
    }
    return subMatrix;
}
//# sourceMappingURL=matrixGetSubMatrix.js.map