19 if (is_array($value)) {
20 $value =
new Matrix($value);
23 if ($value instanceof
Matrix) {
27 throw new Exception(
'Invalid argument for addition');
38 $originalColumnCount = count($this->matrix[0]);
39 $originalRowCount = count($this->matrix);
40 $valColumnCount = $value->columns;
41 $valRowCount = $value->rows;
42 $value = $value->toArray();
45 $this->matrix[
$row] = array_merge($this->matrix[
$row], array_fill(0, $valColumnCount, 0));
48 $this->matrix = array_merge(
50 array_fill(0, $valRowCount, array_fill(0, $originalColumnCount, 0))
53 for (
$row = $originalRowCount;
$row < $originalRowCount + $valRowCount; ++
$row) {
58 $value[$row - $originalRowCount]
$rows
Number of rows in the matrix.
execute($value)
Execute the addition.
Class for the creating "special" Matrices.
directSumMatrix($value)
Execute the direct sum for a matrix.