PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.9
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.9
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/markbaker/matrix/classes/src/Operators/DirectSum.php +10 -11 3.1.33.4.9 View file →
@@ -10,11 +10,11 @@
10 10 /**
11 11 * Execute the addition
12 12 *
13 13 * @param mixed $value The matrix or numeric value to add to the current base value
14 + * @return $this The operation object, allowing multiple additions to be chained
14 15 * @throws Exception If the provided argument is not appropriate for the operation
15 - * @return $this The operation object, allowing multiple additions to be chained
16 - **/
16 + */
17 17 public function execute($value)
18 18 {
19 19 if (is_array($value)) {
20 20 $value = new Matrix($value);
@@ -19,9 +19,9 @@
19 19 if (is_array($value)) {
20 20 $value = new Matrix($value);
21 21 }
22 22
23 - if (is_object($value) && ($value instanceof Matrix)) {
23 + if ($value instanceof Matrix) {
24 24 return $this->directSumMatrix($value);
25 25 }
26 26
27 27 throw new Exception('Invalid argument for addition');
@@ -31,32 +31,31 @@
31 31 * Execute the direct sum for a matrix
32 32 *
33 33 * @param Matrix $value The numeric value to concatenate/direct sum with the current base value
34 34 * @return $this The operation object, allowing multiple additions to be chained
35 - * @throws Exception If the provided argument is not appropriate for the operation
36 35 **/
37 - protected function directSumMatrix(Matrix $value)
36 + private function directSumMatrix($value)
38 37 {
39 38 $originalColumnCount = count($this->matrix[0]);
40 39 $originalRowCount = count($this->matrix);
41 - $additionalColumnCount = $value->columns;
42 - $additionalRowCount = $value->rows;
40 + $valColumnCount = $value->columns;
41 + $valRowCount = $value->rows;
43 42 $value = $value->toArray();
44 43
45 44 for ($row = 0; $row < $this->rows; ++$row) {
46 - $this->matrix[$row] = array_merge($this->matrix[$row], array_fill(0, $additionalColumnCount, 0));
45 + $this->matrix[$row] = array_merge($this->matrix[$row], array_fill(0, $valColumnCount, 0));
47 46 }
48 47
49 48 $this->matrix = array_merge(
50 49 $this->matrix,
51 - array_fill(0, $additionalRowCount, array_fill(0, $originalColumnCount, 0))
50 + array_fill(0, $valRowCount, array_fill(0, $originalColumnCount, 0))
52 51 );
53 52
54 - for ($row = $originalRowCount; $row < $originalRowCount + $additionalRowCount; ++$row) {
53 + for ($row = $originalRowCount; $row < $originalRowCount + $valRowCount; ++$row) {
55 54 array_splice(
56 55 $this->matrix[$row],
57 56 $originalColumnCount,
58 - $additionalColumnCount,
57 + $valColumnCount,
59 58 $value[$row - $originalRowCount]
60 59 );
61 60 }
62 61