PHPackages                             elgigi/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. elgigi/matrix

ActiveLibrary

elgigi/matrix
=============

Matrix

00PHP

Since Jan 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ElGigi/Matrix)[ Packagist](https://packagist.org/packages/elgigi/matrix)[ RSS](/packages/elgigi-matrix/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Matrix
======

[](#matrix)

Library implements the notions of matrices and vectors in PHP. The motivation of this library is first to optimize the large big size of the matrices.

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

[](#installation)

### Composer

[](#composer)

You can install **ElGigi Matrix** with [Composer](https://getcomposer.org/), it's the recommended installation.

```
composer require elgigi/matrix
```

### Dependencies

[](#dependencies)

- **PHP** ^8.0

Usage
-----

[](#usage)

Instanciation of `Matrix` object:

```
use ElGigi\Matrix\Matrix;

$matrix = new Matrix([
    [1, 2, 3],
    [2, 4, 1],
    [3, 2, 4],
]);
```

Uses builder to make `Matrix` object:

```
use ElGigi\Matrix\MatrixBuilder;

$builder = new MatrixBuilder();
$builder->addRow([1, 2, 3]);
$builder->addRow([2, 4, 1]);
$builder->addRow([3, 2, 4]);

$matrix = $builder->getMatrix();
```

API
---

[](#api)

Matrix and vectors implement default interfaces:

- `\Countable`: object can be used with `count()` function
- `\JsonSearialize`: object can be used with `json_encode()` function
- `\IteratorAggregate`: object can be used with `foreach` statement
- `\ArrayAccess`: object can be used like an array to get values

### Matrix

[](#matrix-1)

- `Matrix::isSquare(): bool`: returns if matrix is a square
- `Matrix::count(): int`: get number of elements
- `Matrix::countRows(): int`: get number of rows
- `Matrix::countColumns(): int`: get number of columns
- `Matrix::rows(): Generator`: get rows as generator
- `Matrix::columns(): Generator`: get columns as generator
- `Matrix::getRow(int $offset): VectorInterface`: get specified indexed row as vector
- `Matrix::getColumn(int $offset): VectorInterface`: get specified indexed column as vector
- `Matrix::getValue(int $y, int $x): mixed`: get specified value at coordinates
- `Matrix::map(callable $callback, mixed ...$arg): static`: apply callback on each value and returns a new matrix object
- `Matrix::max(): int|float`: get max value of matrix
- `Matrix::min(): int|float`: get min value of matrix
- `Matrix::sum(): int|float`: get sum of matrix values
- `Matrix::avg(): int|float`: get average of matrix values
- `Matrix::median(): int|float`: get median of matrix values
- `Matrix::variance(): int|float`: get variance of matrix values
- `Matrix::deviation(): int|float`: get deviation of matrix values

### Vector

[](#vector)

- `Vector::values(): array`: get vector values as array
- `Vector::extend(int $length, mixed $value = null): static`: extend vector of specified length with given value
- `Vector::reduce(int $length): static`: reduce vector of specified length
- `Vector::map(callable $callback, mixed ...$arg): static`: apply callback on each value and returns a new vector object
- `Vector::max(): int|float`: get max value of vector
- `Vector::min(): int|float`: get min value of vector
- `Vector::sum(): int|float`: get sum of vector values
- `Vector::avg(): int|float`: get average of vector values
- `Vector::median(): int|float`: get median of vector values
- `Vector::variance(): int|float`: get variance of vector values
- `Vector::deviation(): int|float`: get deviation of vector values

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18268216?v=4)[Ronan Giron](/maintainers/ElGigi)[@ElGigi](https://github.com/ElGigi)

---

Top Contributors

[![ElGigi](https://avatars.githubusercontent.com/u/18268216?v=4)](https://github.com/ElGigi "ElGigi (2 commits)")

### Embed Badge

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

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

PHPackages © 2026

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