mmatrix v2.0.5
MMatrix
MMatrix (class for creating and processing matrix)
var Matrix=require("mmatrix");
var matrix = new Matrix(3, 5);
//CopyRowFromArray test console.log("%c**Matrix 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("%c**Same 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("%c**Copy 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("%c**Previous Matrix with CopyColumnFromArray Test**", "color:red;font-weight:bold;"); copyMatrix.CopyColumnFromArray(1, 44, 55, 66); console.log(copyMatrix.toString());
//GetColumnSum Test
console.log("%c**GetColumnSum 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("%c**GetRowsum 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("%c**Matrix with GetCopy Test**", "color:red;font-weight:bold;");
console.log(This is a copy of previous matrix \n${copyMatrix.GetCopy()}
);
//GetCopyOfColumn Test
console.log("%c**Matrix 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("%c**Matrix 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("%c**Matrix 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("%c**Matrix 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("%c**Matrix 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}
);