markbaker/matrix
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The PHPMatrix (markbaker/matrix) package is a PHP library designed for working with matrices. The library provides numerous operations such as addition, subtraction, multiplication, division and functions like finding the adjoint, diagonal, determinant, inverse, trace, transposing and more to facilitate the efficient handling and manipulation of matrices.
The installation and usage of the PHPMatrix package is relatively straightforward. It begins with creating a new Matrix object by providing an array as the constructor argument:
$grid = [
[16, 3, 2, 13],
[ 5, 10, 11, 8],
[ 9, 6, 7, 12],
[ 4, 15, 14, 1],
];
$matrix = new Matrix\Matrix($grid);
You can also use the Builder class to create specific matrices:
$matrix = Matrix\Builder::createFilledMatrix(1, 5, 3); // creates a 5x3 matrix filled with 1s
$matrix = Matrix\Builder::createIdentityMatrix(3); // creates a 3x3 identity matrix
Mathematical operations can be conducted by calling appropriate methods:
$matrix1 = new Matrix\Matrix([
[2, 7, 6],
[9, 5, 1],
[4, 3, 8],
]);
$matrix2 = new Matrix\Matrix([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]);
$result = $matrix1->multiply($matrix2)->toArray(); // multiplies two matrices
Unfortunately, specific documentation for PHPMatrix does not seem to be directly mentioned in the readme, nor can it be found in the GitHub repository. It seems most likely that the readme file itself and the comments in the source code act as the primary documentation source for users of PHPMatrix.