Download the PHP package chippyash/matrix without Composer

On this page you can find all versions of the php package chippyash/matrix. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package matrix

chippyash/Matrix

Quality Assurance

PHP 5.6 PHP 7 Build Status Test Coverage Code Climate

The above badges represent the current development branch. As a rule, I don't push to GitHub unless tests, coverage and usability are acceptable. This may not be true for short periods of time; on holiday, need code for some other downstream project etc. If you need stable code, use a tagged version. Read 'Further Documentation' and 'Installation'.

Test Contract in the docs directory.

Please note that developer support for PHP5.4 & 5.5 was withdrawn at version 3.0.0 of this library. If you need support for PHP 5.4 or 5.5, please use a version >=2,<3

What?

This library aims to provide matrix transformation functionality given that:

The matrix supplied in this library is a generic one. It treats a matrix as a data structure giving the ability to create matrices and carry out transformations.

The library is released under the GNU GPL V3 or later license

Why?

I finally got round, after too may years, to investigate TDD as a serious methodology. Always interested in something a bit maths related, I thought that having a go at matrices would brush up on old forgotten things and provide a bit of entertainment. So this library is as much about using TDD as it is about matrices. The bonus for taking the TDD approach is that as I've (re)learnt something about matrices, I've been able to refactor in safety.

When

The current library covers basic matrix manipulation. The library will cover most well known generic matrix transformations and derivatives.

If you want more, either suggest it, or better still, fork it and provide a pull request.

Check out chippyash/Logical-Matrix for logical matrix operations

Check out chippyash/Math-Matrix for mathematical matrix operations

Check out chippyash/Strong-Type for strong type including numeric, rational and complex type support

Check out chippyash/Math-Type-Calculator for arithmetic operations on aforementioned strong types

Check out ZF4 Packages for more packages

How

Coding Basics

In PHP terms a matrix is an array of arrays, 2 dimensional i.e

A shortcut for a single item matrix is to supply a single array

    use Chippyash/Matrix/Matrix;

    $mA = new Matrix([]);  //empty matrix
    $mA = new Matrix([[]]);  //empty matrix
    $mA = new Matrix([1]);  //single item matrix

As with any TDD application, the tests tell you everything you need to know about the SUT. Read them! However for the short of temper amongst us, the salient points are:

A basic Matrix type is supplied

Matrices are 1 based, not 0 (zero) based

The following methods on a matrix are supported:

Matrices are immutable

No operation on a matrix will change the internal structure of the matrix. Any transformation or similar will return another matrix, leaving the original alone. This allows for arithmetic stability.

However, a Mutability trait is provided for you to create a mutable matrix for special purposes.

use Chippyash\Matrix\Traits\Mutability;

class MutableMatrix extends Matrix
{
    use Mutability;
}

This provides a set() method:

    /**
     * Set a matrix vertex, row or column vector
     * If row == 0 && col > 0, then set the column vector indicated by col
     * If col == 0 && row > 0, then set the row vector indicated by row
     * if row > 0 && col > 0, set the vertex
     * row == col == 0 is an error
     *
     * @param int $row
     * @param int $col
     * @param mixed|Matrix $data If setting a vector, supply the correct vector matrix
     *
     * @return Matrix

     * @throws VerticeOutOfBoundsException
     * @throws MatrixException
     */
    public function set($row, $col, $data);

Matrices have attributes

Attributes supported:

Matrices can be transformed

    $mB = $mA("Transpose");
    //same as :
    $comp = new Matrix\Transformation\Transpose;
    $mB = $comp($mA);
    //or
    $mB = $mA->transform($comp);

Transformations supported:

The magic invoke methods allow you to write in a functional way

For example (taken from Transformation\Cofactor):

        $fC = new Colreduce();
        $fR = new Rowreduce();
        //R(C(mA))
        return $fR($fC($mA,[$col]),[$row]);

or this (from Transformation\Colreduce):


        $fT = new Transpose();
        $fR = new Rowreduce();

        return $fT($fR($fT($mA), [$col, $numCols]));

Matrices can be output for display

You can supply a formatter to create output via the display() method. The library currently has an Ascii formatter. To use it

    use Chippyash\Matrix\Formatter\Ascii;
    use Chippyash\Matrix\Matrix;

    $mA = new Matrix([[1,2,3],['a','b','c'],[true, false, 'foo']]);
    echo $mA->setFormatter(new Asciii())->display();

You can debug a Matrix

If you find something weird happening, utilise the Debug trait to dump out the matrix to screen using the Ascii formatter.

Changing the library

  1. fork it
  2. write the test
  3. amend it
  4. do a pull request

Found a bug you can't figure out?

  1. fork it
  2. write the test
  3. do a pull request

NB. Make sure you rebase to HEAD before your pull request

Where?

The library is hosted at Github. It is available at Packagist.org

Installation

Install Composer

For production

add

    "chippyash/matrix": ">=3,<4"

to your composer.json "requires" section

For development

Clone this repo, and then run Composer in local repo root to pull in dependencies

    git clone [email protected]:chippyash/Matrix.git Matrix
    cd Matrix
    composer update

To run the tests:

    cd Matrix
    vendor/bin/phpunit -c test/phpunit.xml test/

License

This software library is released under the BSD 3 Clause license

This software library is Copyright (c) 2014-2018, Ashley Kitson, UK

History

V1.0.0 Original release

V1.0.1 Minor bug fixes

V1.1.0 New transformations

V1.1.1 Code analysis conformance

V1.1.2 Update readme

V1.2.0 New transformation

V1.2.1 Code analysis conformance

V1.2.2 Fix Ascii formatter to work with descendent matrices

V1.2.3 Fix transformations to work with descendent matrices

V1.2.4 Amend IsSquare attribute test to accept empty matrix as square

Update documentation

V1.2.5 Add equality() method

V1.2.6 Add ability to set the formatter on Debug trait

V1.2.7 Add ability to set the formatter options for debug

V1.2.8 update phpunit to ~V4.3.0

V2.0.0 BC Break: change chippyash\Matrix namespace to Chippyash\Matrix

V2.0.1 remove duplicated tests

V2.0.2 Add link to packages

V2.0.3 code cleanup

V2.1.0 Add Circshift transformation

V2.2.0 Add Shift transformation

V2.3.0 Add IsVector attribute

V2.3.1 Add ability to get() method to return vectors

V2.4.0 Add Mutable Set Trait

V2.4.1 code cleanup

V2.4.2 remove user config files

V2.5.0 add Resize transformation

V2.5.1 update build script

V3.0.0 BC Break. Withdraw support for old PHP versions

V3.1.0 Change of license from GPL V3 to BSD 3 Clause


All versions of matrix with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
zendframework/zend-stdlib Version ~2.3.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package chippyash/matrix contains the following files

Loading the files please wait ....