@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param int $dtype |
136 | 136 | * @return vector |
137 | 137 | */ |
138 | - public static function full(int $col, int|float $val, int $dtype = self::FLOAT): vector { |
|
138 | + public static function full(int $col, int | float $val, int $dtype = self::FLOAT): vector { |
|
139 | 139 | $ar = self::factory($col, $dtype); |
140 | 140 | for ($i = 0; $i < $col; ++$i) { |
141 | 141 | $ar->data[$i] = $val; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param int $dtype |
153 | 153 | * @return vector |
154 | 154 | */ |
155 | - public static function range(int|float $start, int|float $end, int|float $interval = 1, int $dtype = self::FLOAT): vector { |
|
155 | + public static function range(int | float $start, int | float $end, int | float $interval = 1, int $dtype = self::FLOAT): vector { |
|
156 | 156 | return self::ar(range($start, $end, $interval, $dtype)); |
157 | 157 | } |
158 | 158 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $a[] = end($a) + $interval; |
228 | 228 | } |
229 | 229 | $a[] = $max; |
230 | - return self::ar($a,$dtype); |
|
230 | + return self::ar($a, $dtype); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | public function maximum(\Np\vector $vector): vector { |
248 | 248 | if ($this->checkDimensions($vector) && $this->checkDtype($vector)) { |
249 | 249 | $v = new self($this->ndim, $this->dtype); |
250 | - for($i = 0; $i<$v->ndim; ++$i) { |
|
251 | - $v->data[$i] = max($this->data[$i],$vector->data[$i]); |
|
250 | + for ($i = 0; $i < $v->ndim; ++$i) { |
|
251 | + $v->data[$i] = max($this->data[$i], $vector->data[$i]); |
|
252 | 252 | } |
253 | 253 | return $v; |
254 | 254 | } |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | public function minium(\Np\vector $vector): vector { |
264 | 264 | if ($this->checkDimensions($vector) && $this->checkDtype($vector)) { |
265 | 265 | $v = new self($this->ndim, $this->dtype); |
266 | - for($i = 0; $i<$v->ndim; ++$i) { |
|
267 | - $v->data[$i] = min($this->data[$i],$vector->data[$i]); |
|
266 | + for ($i = 0; $i < $v->ndim; ++$i) { |
|
267 | + $v->data[$i] = min($this->data[$i], $vector->data[$i]); |
|
268 | 268 | } |
269 | 269 | return $v; |
270 | 270 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @param int|float|matrix|vector $d |
341 | 341 | * @return matrix|vector |
342 | 342 | */ |
343 | - public function divide(int|float|matrix|vector $d): matrix|vector { |
|
343 | + public function divide(int | float | matrix | vector $d): matrix | vector { |
|
344 | 344 | if ($d instanceof matrix) { |
345 | 345 | return $this->divideMatrix($d); |
346 | 346 | } elseif ($d instanceof self) { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @param int|float $s |
388 | 388 | * @return vector |
389 | 389 | */ |
390 | - protected function divideScalar(int|float $s): vector { |
|
390 | + protected function divideScalar(int | float $s): vector { |
|
391 | 391 | $vr = self::factory($this->col, $this->dtype); |
392 | 392 | for ($i = 0; $i < $this->col; ++$i) { |
393 | 393 | $vr->data[$i] = $this->data[$i] / $s; |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param int|float|matrix|vector $d |
401 | 401 | * @return matrix|vector |
402 | 402 | */ |
403 | - public function multiply(int|float|matrix|vector $d): matrix|vector { |
|
403 | + public function multiply(int | float | matrix | vector $d): matrix | vector { |
|
404 | 404 | if ($d instanceof matrix) { |
405 | 405 | return $this->multiplyMatrix($d); |
406 | 406 | } elseif ($d instanceof self) { |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @param int|float $s |
448 | 448 | * @return vector |
449 | 449 | */ |
450 | - protected function multiplyScalar(int|float $s): vector { |
|
450 | + protected function multiplyScalar(int | float $s): vector { |
|
451 | 451 | $vr = $this->copyVector(); |
452 | 452 | blas::scale($s, $vr); |
453 | 453 | return $vr; |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @param int|float|matrix|vector $d |
459 | 459 | * @return matrix|vector |
460 | 460 | */ |
461 | - public function add(int|float|matrix|vector $d): matrix|vector { |
|
461 | + public function add(int | float | matrix | vector $d): matrix | vector { |
|
462 | 462 | if ($d instanceof matrix) { |
463 | 463 | return $this->addMatrix($d); |
464 | 464 | } elseif ($d instanceof self) { |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param int|float $s |
507 | 507 | * @return vector |
508 | 508 | */ |
509 | - protected function addScalar(int|float $s): vector { |
|
509 | + protected function addScalar(int | float $s): vector { |
|
510 | 510 | $vr = $this->copyVector(); |
511 | 511 | for ($i = 0; $i < $this->col; ++$i) { |
512 | 512 | $vr->data[$i] += $s; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @param int|float|matrix|vector $d |
550 | 550 | * @return matrix|vector |
551 | 551 | */ |
552 | - public function subtract(int|float|matrix|vector $d): matrix|vector { |
|
552 | + public function subtract(int | float | matrix | vector $d): matrix | vector { |
|
553 | 553 | if ($d instanceof matrix) { |
554 | 554 | return $this->subtractMatrix($d); |
555 | 555 | } elseif ($d instanceof self) { |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @param \Np\vector $scalar |
598 | 598 | * @return \Np\vector |
599 | 599 | */ |
600 | - protected function substractScalar(int|float $scalar): vector { |
|
600 | + protected function substractScalar(int | float $scalar): vector { |
|
601 | 601 | $vr = self::factory($this->col, $this->dtype); |
602 | 602 | for ($i = 0; $i < $this->col; ++$i) { |
603 | 603 | $vr->data[$i] = $this->data[$i] - $scalar; |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | * set data to vector |
648 | 648 | * @param int|float|array $data |
649 | 649 | */ |
650 | - public function setData(int|float|array $data) { |
|
650 | + public function setData(int | float | array $data) { |
|
651 | 651 | if (is_array($data) && !is_array($data[0])) { |
652 | 652 | for ($i = 0; $i < $this->col; ++$i) { |
653 | 653 | $this->data[$i] = $data[$i]; |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | } |
661 | 661 | |
662 | 662 | public function asMatrix(): matrix { |
663 | - $size = (int) sqrt($this->col); |
|
663 | + $size = (int)sqrt($this->col); |
|
664 | 664 | $ar = matrix::factory($size, $size, $this->dtype); |
665 | 665 | for ($i = 0; $i < $ar->ndim; ++$i) { |
666 | 666 | $ar->data[$i] = $this->data[$i]; |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | public function __toString() { |
699 | - return (string) $this->printVector(); |
|
699 | + return (string)$this->printVector(); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | protected function checkDimensions(vector $vector) { |