| @@ -9,12 +9,8 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | namespace Matrix; |
| 12 | 12 | |
| 13 | -use Generator; | |
| 14 | -use Matrix\Decomposition\LU; | |
| 15 | -use Matrix\Decomposition\QR; | |
| 16 | - | |
| 17 | 13 | /** |
| 18 | 14 | * Matrix object. |
| 19 | 15 | * |
| 20 | 16 | * @package Matrix |
| @@ -36,9 +32,8 @@ | ||
| 36 | 32 | * @method Matrix subtract(...$matrices) |
| 37 | 33 | * @method Matrix multiply(...$matrices) |
| 38 | 34 | * @method Matrix divideby(...$matrices) |
| 39 | 35 | * @method Matrix divideinto(...$matrices) |
| 40 | - * @method Matrix directsum(...$matrices) | |
| 41 | 36 | */ |
| 42 | 37 | class Matrix |
| 43 | 38 | { |
| 44 | 39 | protected $rows; |
| @@ -274,11 +269,11 @@ | ||
| 274 | 269 | } |
| 275 | 270 | |
| 276 | 271 | /** |
| 277 | 272 | * Returns a Generator that will yield each row of the matrix in turn as a vector matrix |
| 278 | - * or the value of each cell if the matrix is a column vector | |
| 273 | + * or the value of each cell if the matrix is a vector | |
| 279 | 274 | * |
| 280 | - * @return Generator|Matrix[]|mixed[] | |
| 275 | + * @return \Generator|Matrix[]|mixed[] | |
| 281 | 276 | */ |
| 282 | 277 | public function rows() |
| 283 | 278 | { |
| 284 | 279 | foreach ($this->grid as $i => $row) { |
| @@ -289,11 +284,11 @@ | ||
| 289 | 284 | } |
| 290 | 285 | |
| 291 | 286 | /** |
| 292 | 287 | * Returns a Generator that will yield each column of the matrix in turn as a vector matrix |
| 293 | - * or the value of each cell if the matrix is a row vector | |
| 288 | + * or the value of each cell if the matrix is a vector | |
| 294 | 289 | * |
| 295 | - * @return Generator|Matrix[]|mixed[] | |
| 290 | + * @return \Generator|Matrix[]|mixed[] | |
| 296 | 291 | */ |
| 297 | 292 | public function columns() |
| 298 | 293 | { |
| 299 | 294 | for ($i = 0; $i < $this->columns; ++$i) { |
| @@ -334,26 +329,8 @@ | ||
| 334 | 329 | { |
| 335 | 330 | return $this->grid; |
| 336 | 331 | } |
| 337 | 332 | |
| 338 | - /** | |
| 339 | - * Solve A*X = B. | |
| 340 | - * | |
| 341 | - * @param Matrix $B Right hand side | |
| 342 | - * | |
| 343 | - * @throws Exception | |
| 344 | - * | |
| 345 | - * @return Matrix ... Solution if A is square, least squares solution otherwise | |
| 346 | - */ | |
| 347 | - public function solve(Matrix $B) | |
| 348 | - { | |
| 349 | - if ($this->columns === $this->rows) { | |
| 350 | - return (new LU($this))->solve($B); | |
| 351 | - } | |
| 352 | - | |
| 353 | - return (new QR($this))->solve($B); | |
| 354 | - } | |
| 355 | - | |
| 356 | 333 | protected static $getters = [ |
| 357 | 334 | 'rows', |
| 358 | 335 | 'columns', |
| 359 | 336 | ]; |
| @@ -410,9 +387,9 @@ | ||
| 410 | 387 | public function __call($functionName, $arguments) |
| 411 | 388 | { |
| 412 | 389 | $functionName = strtolower(str_replace('_', '', $functionName)); |
| 413 | 390 | |
| 414 | - if (in_array($functionName, self::$functions, true) || in_array($functionName, self::$operations, true)) { | |
| 391 | + if (in_array($functionName, self::$functions) || in_array($functionName, self::$operations)) { | |
| 415 | 392 | $functionName = "\\" . __NAMESPACE__ . "\\{$functionName}"; |
| 416 | 393 | if (is_callable($functionName)) { |
| 417 | 394 | $arguments = array_values(array_merge([$this], $arguments)); |
| 418 | 395 | return call_user_func_array($functionName, $arguments); |