UNPKG

@rayyamhk/matrix

Version:

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

24 lines (22 loc) 867 B
"use strict"; /** * Generates a random Matrix. * @memberof Matrix * @static * @param {number} row - Number of rows of a Matrix * @param {number} col - Number of columns of a Matrix * @param {number} min - Lower bound of each entry * @param {number} max - Upper bound of each entry * @param {number} toFixed - Number of decimal places * @returns {Matrix} Generated random Matrix */ function getRandomMatrix(row, col) { var min = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var max = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; var toFixed = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; return this.generate(row, col, function () { return Number.parseFloat((Math.random() * (max - min) + min).toFixed(toFixed)); }); } ; module.exports = getRandomMatrix;