Decomposition.php 530 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Matrix\Decomposition;
  3. use Matrix\Exception;
  4. use Matrix\Matrix;
  5. class Decomposition
  6. {
  7. const LU = 'LU';
  8. const QR = 'QR';
  9. /**
  10. * @throws Exception
  11. */
  12. public static function decomposition($type, Matrix $matrix)
  13. {
  14. switch (strtoupper($type)) {
  15. case self::LU:
  16. return new LU($matrix);
  17. case self::QR:
  18. return new QR($matrix);
  19. default:
  20. throw new Exception('Invalid Decomposition');
  21. }
  22. }
  23. }