Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

   1  <?php
   2  
   3  use Matrix\Matrix;
   4  use Matrix\Decomposition\QR;
   5  
   6  include __DIR__ . '/../vendor/autoload.php';
   7  
   8  $grid = [
   9      [0, 1],
  10      [-1, 0],
  11  ];
  12  
  13  $targetGrid = [
  14      [-1],
  15      [2],
  16  ];
  17  
  18  $matrix = new Matrix($grid);
  19  $target = new Matrix($targetGrid);
  20  
  21  $decomposition = new QR($matrix);
  22  
  23  $X = $decomposition->solve($target);
  24  
  25  echo 'X', PHP_EOL;
  26  var_export($X->toArray());
  27  echo PHP_EOL;
  28  
  29  $resolve = $matrix->multiply($X);
  30  
  31  echo 'Resolve', PHP_EOL;
  32  var_export($resolve->toArray());
  33  echo PHP_EOL;