Documentation

Version 1.0.5

There are many ways to install NumPHP, but the installation with Composer is recommended.

Requirements

NumPHP requires PHP 5.4 or greater.

Installing with Composer

Simply add a dependency on numphp/numphp to your project’s composer.json file.

{
    "require": {
        "numphp/numphp": "*"
    }
}

Manual Installation

Download the latest package, extract it and include the file vendor/autoload.php in your project.

require_once "path_to_your_lib_dir/numphp/vendor/autoload.php";

Source

The source code can be found under Github.

This section will give an short overview about vectors and matrices.

Creation

The NumArray can present a scalar, a vector, a matrix or even a multidimensional array.

Example: Matrix

5 5/6 -2.8
0.65 -3 7/2
$matrix = new NumArray(
    [
        [   5, 5/6, -2.8],
        [0.65,  -3,  7/2]
    ]
);

Example: Vector

78
3.85
1/45
0
$vector = new NumArray(
    [78, 3.85, 1/45, 0]
);

Example: Scalar

6
$scalar = new NumArray(6);

Arithmetic

Here are some basic operations for matrices and vectors

Example: Addition

$sum = $matrix1->add($matrix2);

Example: Subtraction

$sub = $vector1->sub($vector2);

Example: Multiplication

$prod = $matrix->dot($vector);