UNPKG

@rayyamhk/matrix

Version:

A professional, comprehensive and high-performance library for you to manipulate matrices.

21 lines (18 loc) 360 B
"use strict"; /** * Generates identity Matrix with given size. * @memberof Matrix * @static * @param {number} size - The size of Matrix * @returns {Matrix} Identity Matrix */ function identity(size) { return this.generate(size, size, function (i, j) { if (i === j) { return 1; } return 0; }); } ; module.exports = identity;