Skip to content

Commit

Permalink
Update README icons (no longer using Travis for the CI pipeline, and …
Browse files Browse the repository at this point in the history
…adding latest release version, downloads, and license)
  • Loading branch information
MarkBaker authored and MarkBaker committed Jul 1, 2021
1 parent 918ce02 commit c66aefc
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ PHPMatrix

PHP Class for handling Matrices

[![Build Status](https://travis-ci.org/MarkBaker/PHPMatrix.png?branch=2.0)](http://travis-ci.org/MarkBaker/PHPMatrix)
[![Build Status](https://github.com/MarkBaker/PHPMatrix/workflows/main/badge.svg)](https://github.com/MarkBaker/PHPMatrix/actions)
[![Total Downloads](https://img.shields.io/packagist/dt/markbaker/matrix)](https://packagist.org/packages/markbaker/matrix)
[![Latest Stable Version](https://img.shields.io/github/v/release/MarkBaker/PHPMatrix)](https://packagist.org/packages/markbaker/matrix)
[![License](https://img.shields.io/github/license/MarkBaker/PHPMatrix)](https://packagist.org/packages/markbaker/matrix)


[![Matrix Transform](https://imgs.xkcd.com/comics/matrix_transform.png)](https://xkcd.com/184/)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand All @@ -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.

Expand All @@ -139,7 +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
or you can call the static method, passing the Matrix object or array as an argument
```php
$grid = [
[16, 3, 2, 13],
Expand All @@ -149,20 +171,8 @@ $grid = [
];

$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);
echo Matrix\Functions::trace($matrix);
```
As an alternative, it is also possible to call the method directly from the `Functions` class.
```php
$grid = [
[16, 3, 2, 13],
Expand All @@ -171,10 +181,8 @@ $grid = [
[ 4, 15, 14, 1],
];

$matrix = new Matrix\Matrix($grid);
echo Matrix\Functions::trace($matrix);
echo Matrix\Functions::trace($grid);
```
Used this way, methods must be called statically, and the argument must be the Matrix object, and cannot be an array.

## Decomposition

Expand Down

0 comments on commit c66aefc

Please sign in to comment.