const { INVALID_MATRIX } = require('../../Error');
/**
* Creates a copy of Matrix. Note that it resets the cached data.
* @memberof Matrix
* @static
* @param {Matrix} A - Any Matrix
* @returns {Matrix} Copy of A
*/
function clone(A) {
if (!(A instanceof this)) {
throw new Error(INVALID_MATRIX);
}
const [row, col] = A.size();
const matrix = A._matrix;
return this.generate(row, col, (i, j) => matrix[i][j]);
};
module.exports = clone;