
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
node-matrix
Advanced tools
A tiny matrix library written in JavaScript
$ npm install node-matrix
var m1 = Matrix([
[1, 3, 1],
[1, 0, 0]
]);
var m2 = Matrix([
[0, 0, 5],
[7, 5, 0]
]);
Matrix.add(m1, m2); // [ [1, 3, 6], [8, 5, 0] ]
Create a new instance of Matrix. You can pass in a multidimensional array:
var matrix = Matrix([
[4, 1, 9],
[3, 8, 2]
]);
Or you can pass in an object specifying the dimensions and default values. If you don't pass in a default value, or a function to be executed for each element to calculate it's value, then it will set the value of each element to 0.
var matrix = Matrix({ rows: 3, columns: 2 }); // Set the value of each element to 0
var matrix = Matrix({ rows: 3, columns: 2, values: 5 }); // // Set the value of each element to 5
var matrix = Matrix({ rows: 3, columns: 2, values: Math.random }); // Set the value of each element to a random number
You can access the matrix's values the same way you can access them from an array: matrix[0][1], with 0 corresponding to the row number and 1 corresponding to the column number. You also now have access to matrix.dimensions, which will return an array where the first element is the number of rows in the matrix, and the second element is the number of columns in the matrix.
Matrix.add(m1, m2);
Matrix.subtract(m1, m2);
Matrix.multiply(m1, m2); // matrix multiplication
Matrix.multiplyScalar(m1, 4); // scalar multiplication
Matrix.multiplyElements(m1, m2); // element-wise multiplication
matrix.transpose();
matrix.transform(function(num) { return num - 2 }); // subtract two from each element in the matrix
FAQs
A tiny matrix library
We found that node-matrix demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.