@@ -142,23 +142,23 @@ |
||
142 | 142 | throw new InvalidArgumentException('Inconsistent matrix supplied'); |
143 | 143 | } |
144 | 144 | |
145 | - $array1 = $this->toArray(); |
|
146 | - $array2 = $matrix->toArray(); |
|
147 | - $colCount = $matrix->columns; |
|
148 | - |
|
149 | - $product = []; |
|
150 | - foreach($array1 as $row => $rowData){ |
|
151 | - for($col = 0; $col < $colCount; ++$col) { |
|
152 | - $columnData = array_column($array2, $col); |
|
153 | - $sum = 0; |
|
154 | - foreach($rowData as $key => $valueData) { |
|
155 | - $sum += $valueData * $columnData[$key]; |
|
156 | - } |
|
157 | - $product[$row][$col] = $sum; |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - return new self($product, false); |
|
145 | + $array1 = $this->toArray(); |
|
146 | + $array2 = $matrix->toArray(); |
|
147 | + $colCount = $matrix->columns; |
|
148 | + |
|
149 | + $product = []; |
|
150 | + foreach($array1 as $row => $rowData){ |
|
151 | + for($col = 0; $col < $colCount; ++$col) { |
|
152 | + $columnData = array_column($array2, $col); |
|
153 | + $sum = 0; |
|
154 | + foreach($rowData as $key => $valueData) { |
|
155 | + $sum += $valueData * $columnData[$key]; |
|
156 | + } |
|
157 | + $product[$row][$col] = $sum; |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + return new self($product, false); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | public function divideByScalar($value): self |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\Math; |
6 | 6 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public function transpose(): self |
127 | 127 | { |
128 | 128 | if ($this->rows == 1) { |
129 | - $matrix = array_map(function ($el) { |
|
129 | + $matrix = array_map(function($el) { |
|
130 | 130 | return [$el]; |
131 | 131 | }, $this->matrix[0]); |
132 | 132 | } else { |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | $colCount = $matrix->columns; |
148 | 148 | |
149 | 149 | $product = []; |
150 | - foreach($array1 as $row => $rowData){ |
|
151 | - for($col = 0; $col < $colCount; ++$col) { |
|
150 | + foreach ($array1 as $row => $rowData) { |
|
151 | + for ($col = 0; $col < $colCount; ++$col) { |
|
152 | 152 | $columnData = array_column($array2, $col); |
153 | 153 | $sum = 0; |
154 | - foreach($rowData as $key => $valueData) { |
|
154 | + foreach ($rowData as $key => $valueData) { |
|
155 | 155 | $sum += $valueData * $columnData[$key]; |
156 | 156 | } |
157 | 157 | $product[$row][$col] = $sum; |