ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
directsum.php
Go to the documentation of this file.
1<?php
2
11namespace Matrix;
12
14
22if (!function_exists(__NAMESPACE__ . '\\directsum')) {
23 function directsum(...$matrixValues): Matrix
24 {
25 if (count($matrixValues) < 2) {
26 throw new Exception('DirectSum operation requires at least 2 arguments');
27 }
28
29 $matrix = array_shift($matrixValues);
30
31 if (is_array($matrix)) {
32 $matrix = new Matrix($matrix);
33 }
34 if (!$matrix instanceof Matrix) {
35 throw new Exception('DirectSum arguments must be Matrix or array');
36 }
37
38 $result = new DirectSum($matrix);
39
40 foreach ($matrixValues as $matrix) {
41 $result->execute($matrix);
42 }
43
44 return $result->result();
45 }
46}
$result
An exception for terminatinating execution or to throw for unit testing.
$matrix
Definition: test.php:18
Class for the creating "special" Matrices.
Definition: Builder.php:11