Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

   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;