2dmatrix
v1.0.1
Published
Create 2d Matrix
Readme
2DMatrix
A simple yet powerful TypeScript library for generating and displaying 2D matrices with CLI table formatting.
Installation
npm install 2dmatrixFeatures
- Generate random 2D matrices with customizable dimensions and value ranges.
- Display matrices in a well-formatted CLI table with coordinates.
- Fully written in TypeScript with type definitions included.
Usage
import mx from "2dmatrix";
mx.openCLI = true; // Enable CLI table display
mx.tableWidth = 20; // Set column width
const createRandomMatrix = mx.randomMx(2, 3, 50);
console.log(createRandomMatrix);Output Example
╔══════╤══════╤══════╗
║ 12 │ 34 │ 23 ║
║ (1,1)│ (1,2)│ (1,3)║
╟──────┼──────┼──────╢
║ 45 │ 32 │ 11 ║
║ (2,1)│ (2,2)│ (2,3)║
╚══════╧══════╧══════╝API
randomMx(rows: number, cols: number, range: number): RandomMx
Generates a random matrix with given rows and columns, and fills it with random numbers up to the specified range.
Parameters:
rows- Number of rows in the matrix.cols- Number of columns in the matrix.range- Maximum value for random numbers.
Returns:
{
randomMatrix: number[][];
coordinates: Coordinate[];
matrixSize: string;
}License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Developed by Hamza Atmaca.
