diff options
Diffstat (limited to 'vendor/markbaker/matrix/examples/test.php')
-rw-r--r-- | vendor/markbaker/matrix/examples/test.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/markbaker/matrix/examples/test.php b/vendor/markbaker/matrix/examples/test.php new file mode 100644 index 0000000..001f9c6 --- /dev/null +++ b/vendor/markbaker/matrix/examples/test.php @@ -0,0 +1,33 @@ +<?php
+
+use Matrix\Matrix;
+use Matrix\Decomposition\QR;
+
+include __DIR__ . '/../vendor/autoload.php';
+
+$grid = [
+ [1, 2],
+ [3, 4],
+];
+
+$targetGrid = [
+ [-1],
+ [-2],
+];
+
+$matrix = new Matrix($grid);
+$target = new Matrix($targetGrid);
+
+$decomposition = new QR($matrix);
+
+$X = $decomposition->solve($target);
+
+echo 'X', PHP_EOL;
+var_export($X->toArray());
+echo PHP_EOL;
+
+$resolve = $matrix->multiply($X);
+
+echo 'Resolve', PHP_EOL;
+var_export($resolve->toArray());
+echo PHP_EOL;
|