1 | <?php |
||
7 | class Matrix |
||
8 | { |
||
9 | /** |
||
10 | * @param int $rowSize |
||
11 | * @param int $colSize |
||
12 | * @return static |
||
13 | */ |
||
14 | 1 | public static function zeros($rowSize, $colSize) |
|
18 | |||
19 | /** @var int */ |
||
20 | protected $rowSize; |
||
21 | |||
22 | /** @var int */ |
||
23 | protected $colSize; |
||
24 | |||
25 | /** @var array */ |
||
26 | protected $items = []; |
||
27 | |||
28 | /** |
||
29 | * Matrix constructor. |
||
30 | * @param int $rowSize |
||
31 | * @param int $colSize |
||
32 | * @param array $items |
||
33 | */ |
||
34 | 7 | public function __construct($rowSize, $colSize, array $items = []) |
|
40 | |||
41 | 7 | protected function removeSparse($rowSize, $colSize, array $items = []) |
|
57 | |||
58 | 1 | public function __toString() |
|
73 | |||
74 | /** |
||
75 | * @return int |
||
76 | */ |
||
77 | public function getRowSize() |
||
81 | |||
82 | /** |
||
83 | * @return int |
||
84 | */ |
||
85 | public function getColSize() |
||
89 | |||
90 | 1 | public function equal($matrix) |
|
99 | |||
100 | /** |
||
101 | * @param int $index |
||
102 | * @return \Wandu\Math\LinearAlgebra\Vector |
||
103 | */ |
||
104 | 2 | public function getRowVector($index) |
|
108 | |||
109 | 2 | public function getColVector($index) |
|
117 | |||
118 | 2 | public function multiply($other) |
|
128 | |||
129 | /** |
||
130 | * @param $other |
||
131 | * @return \Wandu\Math\LinearAlgebra\Matrix |
||
132 | */ |
||
133 | public function multiplyWithScalar($other) |
||
139 | |||
140 | /** |
||
141 | * @return \Wandu\Math\LinearAlgebra\Matrix |
||
142 | */ |
||
143 | 1 | public function transpose() |
|
153 | |||
154 | /** |
||
155 | * @param \Wandu\Math\LinearAlgebra\Matrix $other |
||
156 | * @return \Wandu\Math\LinearAlgebra\Matrix |
||
157 | */ |
||
158 | 1 | public function multiplyWithMatrix(Matrix $other) |
|
173 | |||
174 | /** |
||
175 | * @param \Closure $handler |
||
176 | * @return \Wandu\Math\LinearAlgebra\Matrix |
||
177 | */ |
||
178 | 2 | public function map(Closure $handler) |
|
188 | |||
189 | /** |
||
190 | * @param \Closure $handler |
||
191 | * @return bool |
||
192 | */ |
||
193 | 1 | public function each(Closure $handler) |
|
207 | } |
||
208 |