Version 1.0.5
There are many ways to install NumPHP, but the installation with Composer is recommended.
NumPHP requires PHP 5.4 or greater.
Simply add a dependency on numphp/numphp
to your project’s composer.json file.
{
"require": {
"numphp/numphp": "*"
}
}
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";
The source code can be found under Github.
This section will give an short overview about vectors and matrices.
The NumArray
can present a scalar, a vector, a matrix or even a multidimensional array.
5 | 5/6 | -2.8 |
0.65 | -3 | 7/2 |
$matrix = new NumArray(
[
[ 5, 5/6, -2.8],
[0.65, -3, 7/2]
]
);
78 |
3.85 |
1/45 |
0 |
$vector = new NumArray(
[78, 3.85, 1/45, 0]
);
$scalar = new NumArray(6);
Here are some basic operations for matrices and vectors
$sum = $matrix1->add($matrix2);
$sub = $vector1->sub($vector2);
$prod = $matrix->dot($vector);