package and depencies
This commit is contained in:
64
vendor/markbaker/matrix/README.md
vendored
64
vendor/markbaker/matrix/README.md
vendored
@@ -5,7 +5,11 @@ PHPMatrix
|
||||
|
||||
PHP Class for handling Matrices
|
||||
|
||||
[](http://travis-ci.org/MarkBaker/PHPMatrix)
|
||||
[](https://github.com/MarkBaker/PHPMatrix/actions)
|
||||
[](https://packagist.org/packages/markbaker/matrix)
|
||||
[](https://packagist.org/packages/markbaker/matrix)
|
||||
[](https://packagist.org/packages/markbaker/matrix)
|
||||
|
||||
|
||||
[](https://xkcd.com/184/)
|
||||
|
||||
@@ -60,6 +64,24 @@ and classes for
|
||||
|
||||
---
|
||||
|
||||
# Installation
|
||||
|
||||
```shell
|
||||
composer require markbaker/matrix:^3.0
|
||||
```
|
||||
|
||||
# Important BC Note
|
||||
|
||||
If you've previously been using procedural calls to functions and operations using this library, then from version 3.0 you should use [MarkBaker/PHPMatrixFunctions](https://github.com/MarkBaker/PHPMatrixFunctions) instead (available on packagist as [markbaker/matrix-functions](https://packagist.org/packages/markbaker/matrix-functions)).
|
||||
|
||||
You'll need to replace `markbaker/matrix`in your `composer.json` file with the new library, but otherwise there should be no difference in the namespacing, or in the way that you have called the Matrix functions in the past, so no actual code changes are required.
|
||||
|
||||
```shell
|
||||
composer require markbaker/matrix-functions:^1.0
|
||||
```
|
||||
|
||||
You should not reference this library (`markbaker/matrix`) in your `composer.json`, composer wil take care of that for you.
|
||||
|
||||
# Usage
|
||||
|
||||
To create a new Matrix object, provide an array as the constructor argument
|
||||
@@ -105,7 +127,7 @@ $matrix2 = new Matrix\Matrix([
|
||||
|
||||
var_dump($matrix1->multiply($matrix2)->toArray());
|
||||
```
|
||||
or pass all values to the appropriate function
|
||||
or pass all values to the appropriate static method
|
||||
```php
|
||||
$matrix1 = new Matrix\Matrix([
|
||||
[2, 7, 6],
|
||||
@@ -118,7 +140,7 @@ $matrix2 = new Matrix\Matrix([
|
||||
[7, 8, 9],
|
||||
]);
|
||||
|
||||
var_dump(Matrix\multiply($matrix1, $matrix2)->toArray());
|
||||
var_dump(Matrix\Operations::multiply($matrix1, $matrix2)->toArray());
|
||||
```
|
||||
You can pass in the arguments as Matrix objects, or as arrays.
|
||||
|
||||
@@ -139,30 +161,7 @@ $matrix = new Matrix\Matrix($grid);
|
||||
|
||||
echo $matrix->trace();
|
||||
```
|
||||
or you can call the function as you would in procedural code, passing the Matrix object as an argument
|
||||
```php
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
[ 5, 10, 11, 8],
|
||||
[ 9, 6, 7, 12],
|
||||
[ 4, 15, 14, 1],
|
||||
];
|
||||
|
||||
$matrix = new Matrix\Matrix($grid);
|
||||
echo Matrix\trace($matrix);
|
||||
```
|
||||
When called procedurally using the function, you can pass in the argument as a Matrix object, or as an array.
|
||||
```php
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
[ 5, 10, 11, 8],
|
||||
[ 9, 6, 7, 12],
|
||||
[ 4, 15, 14, 1],
|
||||
];
|
||||
|
||||
echo Matrix\trace($grid);
|
||||
```
|
||||
As an alternative, it is also possible to call the method directly from the `Functions` class.
|
||||
or you can call the static method, passing the Matrix object or array as an argument
|
||||
```php
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
@@ -174,7 +173,16 @@ $grid = [
|
||||
$matrix = new Matrix\Matrix($grid);
|
||||
echo Matrix\Functions::trace($matrix);
|
||||
```
|
||||
Used this way, methods must be called statically, and the argument must be the Matrix object, and cannot be an array.
|
||||
```php
|
||||
$grid = [
|
||||
[16, 3, 2, 13],
|
||||
[ 5, 10, 11, 8],
|
||||
[ 9, 6, 7, 12],
|
||||
[ 4, 15, 14, 1],
|
||||
];
|
||||
|
||||
echo Matrix\Functions::trace($grid);
|
||||
```
|
||||
|
||||
## Decomposition
|
||||
|
||||
|
||||
Reference in New Issue
Block a user