https://github.com/tdebatty/php-vector-matrix
A PHP library for vectors and matrices algebra
https://github.com/tdebatty/php-vector-matrix
Last synced: 9 months ago
JSON representation
A PHP library for vectors and matrices algebra
- Host: GitHub
- URL: https://github.com/tdebatty/php-vector-matrix
- Owner: tdebatty
- Created: 2013-07-30T07:43:07.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-21T10:20:20.000Z (over 12 years ago)
- Last Synced: 2025-03-26T02:51:07.011Z (10 months ago)
- Language: PHP
- Size: 188 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
php-vector-matrix
=================
A PHP library for vectors and matrices algebra
Usage
-----
```php
add($v2);
$v3->display();
// If you have PECL extension operator installed,
// this returns a Vector with value (5,7,9)
$v4 = $v1 - $v2;
var_dump($v4);
var_dump($v1 - 1);
var_dump($v1 . $v2); // Dot product
var_dump($v1 * $v2); // Cross product
$v2_normalized = $v2->normalize();
var_dump($v2_normalized);
var_dump($v2_normalized->length()); // Should be 1!
$v4 = new Vector(1, 2, 5, 4.2, 8, 5, 10.9, 1, 7, 4);
var_dump($v4->mean());
var_dump($v4->standardDeviation());
$v5 = $v4 - $v4->mean();
$v5 = $v5 / $v4->standardDeviation();
var_dump($v5);
var_dump($v5->mean()); // Should be close to 0
var_dump($v5->standardDeviation()); // Should be close to 1
```