NumPHP

Mathematical PHP library for scientific computing

Install

The NumArray is the main object, it can represent a matrix, a vector or a scalar

Matrix

$matrix = new NumArray(
    [
        [ 1/7,    6, -1.34],
        [   2,  3.1,  -2/3],
        [-4/9, 2.65,     1],
    ]
);

Vector

$vector = new NumArray(
    [0.12, 6/7, -9]
);

The basic operations get and set are inspired by the simplicity of MATLAB

Get

$matrix->get('1:3', 5);

Set

$matrix->set(3, '1:', $vector);

There are all basic operations for matrices and vectors: add, sub, dot, min, max, abs, getShape, getSize and many more

Multiplication

$matrix1->dot($matrix2);

Many known functions from the linear algebra: det, lud, inv, cholesky and more

Determinant

$det = LinAlg::det($matrix);

Inverse Matrix

$inv = LinAlg::inv($matrix);