mmatrix
v2.0.5
Published
MMatrix class is used for processing matrix and creating different mathematical operations like summtions and subtractions
Readme
MMatrix
MMatrix (class for creating and processing matrix)
var Matrix=require("mmatrix");
var matrix = new Matrix(3, 5);
//CopyRowFromArray test console.log("%cMatrix after using CopyRowFromArray Test", "color:red;font-weight:bold;"); matrix.CopyRowFromArray(0, 1, 2, 3, 4, 5); matrix.CopyRowFromArray(1, 3, 7, 6, 8, 4); matrix.CopyRowFromArray(2, 2, 99, 9, 10, 4); console.log(matrix.toString());
//AddElement test console.log("%cSame previous Matrix after using AddElement Test", "color:red;font-weight:bold;"); matrix.AddElement(0, 0, 3); console.log(matrix.toString());
// Copy from another test using CopyFromAnother console.log("%cCopy previous Matrix with CopyFromAnother Test", "color:red;font-weight:bold;"); var copyMatrix = new Matrix(matrix.RowsLen, matrix.ColumnsLen); copyMatrix.CopyFromAnother(matrix); console.log(copyMatrix.toString());
// Copy from another test using CopyColumnFromArray console.log("%cPrevious Matrix with CopyColumnFromArray Test", "color:red;font-weight:bold;"); copyMatrix.CopyColumnFromArray(1, 44, 55, 66); console.log(copyMatrix.toString());
//GetColumnSum Test
console.log("%cGetColumnSum Test", "color:red;font-weight:bold;");
console.log(Sum of elements in first column in previous matrix is ${copyMatrix.GetColumnSum(0)});
//GetRowsum Test
console.log("%cGetRowsum Test", "color:red;font-weight:bold;");
console.log(Sum of elements in first row in previous matrix is ${copyMatrix.GetRowsum(0)});
//GetCopy Test
console.log("%cMatrix with GetCopy Test", "color:red;font-weight:bold;");
console.log(This is a copy of previous matrix \n${copyMatrix.GetCopy()});
//GetCopyOfColumn Test
console.log("%cMatrix with GetCopyOfColumn Test", "color:red;font-weight:bold;");
console.log(This is the first column of previous matrix \n${copyMatrix.GetCopyOfColumn(0)});
//GetCopyOfRow Test
console.log("%cMatrix with GetCopyOfRow Test", "color:red;font-weight:bold;");
console.log(This is the second row of previous matrix \n${copyMatrix.GetCopyOfRow(1)});
//MultiplyRowBy Test
console.log("%cMatrix with Multiply Test", "color:red;font-weight:bold;");
console.log(This is result of multply previous matrix by itself \n${copyMatrix.Multiply(copyMatrix)});
//MultiplyRowBy Test
console.log("%cMatrix with MultiplyRowBy Test", "color:red;font-weight:bold;");
copyMatrix.MultiplyRowBy(1, 2);
console.log(This is result of multply second row with 2 \n${copyMatrix});
//MultiplyColumnBy Test
console.log("%cMatrix with MultiplyColumnBy Test", "color:red;font-weight:bold;");
copyMatrix.MultiplyColumnBy(1, 2);
console.log(This is result of multply second column with 2 \n${copyMatrix});
