PHPackages                             vermotr/php-matrix - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. vermotr/php-matrix

ActiveLibrary

vermotr/php-matrix
==================

Matrix basic implementation.

0.1.0(10y ago)24512MITPHPPHP &gt;=5.4.0

Since Dec 1Pushed 10y ago1 watchersCompare

[ Source](https://github.com/vermotr/php-matrix)[ Packagist](https://packagist.org/packages/vermotr/php-matrix)[ RSS](/packages/vermotr-php-matrix/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Matrix
======

[](#matrix)

Matrix basic implementation.

Installation
------------

[](#installation)

```
composer require vermotr/php-matrix:0.1.0

```

Alternatively you can add the following to the require section of your `composer.json` manually:

```
"vermotr/php-matrix": "0.1.0"

```

Usage
-----

[](#usage)

There are three ways to instantiate a matrix:

```
use vermotr\Math\Matrix;

// Create a Matrix with its size
$matrix = new Matrix(4, 2);

// With a bi-dimensional array
$matrix = new Matrix([
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8]
]);

// With another Matrix
$matrix = new Matrix($anotherMatrix);
```

You can access each element like a bi-dimensional array and display the matrix like so:

```
$matrix[4][2] = 42;

echo $matrix;

```

To know the matrix' size, you have access to two getters:

```
$matrix->getRows();
$matrix->getCols();
```

In this class, you will find basic operations: add, subtract and multiply (by scalars and Matrices):

```
$addedScalar = $matrix->add(4);
$addedMatrix = $matrix->add($anotherMatrix);
$subtractedScalar = $matrix->subtract(2);
$subtractedMatrix = $matrix->subtract($anotherMatrix);
$multipliedByScalar = $matrix->multiply(2);
$multipliedByMatrix = $matrix->multiply($anotherMatrix);
```

You can also compare two matrices with the `equals` method:

```
if ($matrix1->equals($matrix2)) {
    // Do something!
}
```

There are some useful methods implemented in this class:

```
$matrix->adjugate();
$matrix->cofactor();
$matrix->determinant();
$matrix->inverse();
$matrix->subMatrix();
$matrix->transpose();
```

Changelog
=========

[](#changelog)

- 0.1.0
    - Created the Matrix type
    - Scalar Addition
    - Matrix Addition
    - Scalar Subtraction
    - Matrix Subtraction
    - Scalar Multiplication
    - Matrix Multiplication
    - Adjugate
    - Cofactor
    - Determinant
    - Inverse
    - Submatrix
    - Transpose

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3813d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ca5896ec16137f7ea412ca5fec96d53cb42e05b9cc0730cf915a5da7fc16d08?d=identicon)[vermotr](/maintainers/vermotr)

---

Tags

matrixmathlinear algebra

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vermotr-php-matrix/health.svg)

```
[![Health](https://phpackages.com/badges/vermotr-php-matrix/health.svg)](https://phpackages.com/packages/vermotr-php-matrix)
```

###  Alternatives

[markrogoyski/math-php

Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra

2.4k7.1M40](/packages/markrogoyski-math-php)[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M276](/packages/brick-math)[markbaker/matrix

PHP Class for working with matrices

1.5k279.7M38](/packages/markbaker-matrix)[rubix/tensor

A library and extension that provides objects for scientific computing in PHP.

2751.4M5](/packages/rubix-tensor)[mcordingley/linearalgebra

Matrix math for PHP.

85146.3k1](/packages/mcordingley-linearalgebra)[sciphp/numphp

PHP library for scientific computing.

6618.9k](/packages/sciphp-numphp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
