@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param int $dtype |
134 | 134 | * @return vector |
135 | 135 | */ |
136 | - public static function full(int $col, int|float $val, int $dtype = self::FLOAT): vector { |
|
136 | + public static function full(int $col, int | float $val, int $dtype = self::FLOAT): vector { |
|
137 | 137 | $ar = self::factory($col, $dtype); |
138 | 138 | for ($i = 0; $i < $col; ++$i) { |
139 | 139 | $ar->data[$i] = $val; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param int $dtype |
151 | 151 | * @return vector |
152 | 152 | */ |
153 | - public static function range(int|float $start, int|float $end, int|float $interval = 1, int $dtype = self::FLOAT): vector { |
|
153 | + public static function range(int | float $start, int | float $end, int | float $interval = 1, int $dtype = self::FLOAT): vector { |
|
154 | 154 | return self::ar(range($start, $end, $interval), $dtype); |
155 | 155 | } |
156 | 156 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param int|float|matrix|vector $d |
338 | 338 | * @return matrix|vector |
339 | 339 | */ |
340 | - public function divide(int|float|matrix|vector $d): matrix|vector { |
|
340 | + public function divide(int | float | matrix | vector $d): matrix | vector { |
|
341 | 341 | if ($d instanceof matrix) { |
342 | 342 | return $this->divideMatrix($d); |
343 | 343 | } elseif ($d instanceof self) { |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param int|float $s |
385 | 385 | * @return vector |
386 | 386 | */ |
387 | - protected function divideScalar(int|float $s): vector { |
|
387 | + protected function divideScalar(int | float $s): vector { |
|
388 | 388 | $vr = self::factory($this->col, $this->dtype); |
389 | 389 | for ($i = 0; $i < $this->col; ++$i) { |
390 | 390 | $vr->data[$i] = $this->data[$i] / $s; |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @param int|float|matrix|vector $d |
398 | 398 | * @return matrix|vector |
399 | 399 | */ |
400 | - public function multiply(int|float|matrix|vector $d): matrix|vector { |
|
400 | + public function multiply(int | float | matrix | vector $d): matrix | vector { |
|
401 | 401 | if ($d instanceof matrix) { |
402 | 402 | return $this->multiplyMatrix($d); |
403 | 403 | } elseif ($d instanceof self) { |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @param int|float $s |
445 | 445 | * @return vector |
446 | 446 | */ |
447 | - protected function multiplyScalar(int|float $s): vector { |
|
447 | + protected function multiplyScalar(int | float $s): vector { |
|
448 | 448 | $vr = $this->copyVector(); |
449 | 449 | blas::scale($s, $vr); |
450 | 450 | return $vr; |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | * @param int|float|matrix|vector $d |
456 | 456 | * @return matrix|vector |
457 | 457 | */ |
458 | - public function add(int|float|matrix|vector $d): matrix|vector { |
|
458 | + public function add(int | float | matrix | vector $d): matrix | vector { |
|
459 | 459 | if ($d instanceof matrix) { |
460 | 460 | return $this->addMatrix($d); |
461 | 461 | } elseif ($d instanceof self) { |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param int|float $s |
503 | 503 | * @return vector |
504 | 504 | */ |
505 | - protected function addScalar(int|float $s): vector { |
|
505 | + protected function addScalar(int | float $s): vector { |
|
506 | 506 | $vr = $this->copyVector(); |
507 | 507 | for ($i = 0; $i < $this->col; ++$i) { |
508 | 508 | $vr->data[$i] += $s; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @param int|float|\Np\matrix|\Np\vector $d |
516 | 516 | * @return matrix|vector |
517 | 517 | */ |
518 | - public function pow(int|float|\Np\matrix|\Np\vector $d): matrix|vector { |
|
518 | + public function pow(int | float | \Np\matrix | \Np\vector $d): matrix | vector { |
|
519 | 519 | if ($d instanceof matrix) { |
520 | 520 | return $this->powMatrix($d); |
521 | 521 | } elseif ($d instanceof vector) { |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @param int|float $s |
563 | 563 | * @return vector |
564 | 564 | */ |
565 | - protected function powScalar(int|float $s): vector { |
|
565 | + protected function powScalar(int | float $s): vector { |
|
566 | 566 | $v = $this->copyVector(); |
567 | 567 | for ($i = 0; $i < $this->col; ++$i) { |
568 | 568 | $v->data[$i] = $v->data[$i] ** $s; |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @param int|float|\Np\matrix|\Np\vector $d |
576 | 576 | * @return matrix|vector |
577 | 577 | */ |
578 | - public function mod(int|float|\Np\matrix|\Np\vector $d): matrix|vector { |
|
578 | + public function mod(int | float | \Np\matrix | \Np\vector $d): matrix | vector { |
|
579 | 579 | if ($d instanceof matrix) { |
580 | 580 | return $this->powMatrix($d); |
581 | 581 | } elseif ($d instanceof vector) { |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * |
622 | 622 | * @param int|float $s |
623 | 623 | */ |
624 | - protected function modScalar(int|float $s) { |
|
624 | + protected function modScalar(int | float $s) { |
|
625 | 625 | $v = $this->copyVector(); |
626 | 626 | for ($i = 0; $i < $this->col; ++$i) { |
627 | 627 | $v->data[$i] = $v->data[$i] % $s; |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * @param int|float|matrix|vector $d |
634 | 634 | * @return matrix|vector |
635 | 635 | */ |
636 | - public function subtract(int|float|matrix|vector $d): matrix|vector { |
|
636 | + public function subtract(int | float | matrix | vector $d): matrix | vector { |
|
637 | 637 | if ($d instanceof matrix) { |
638 | 638 | return $this->subtractMatrix($d); |
639 | 639 | } elseif ($d instanceof self) { |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | * @param \Np\vector $scalar |
681 | 681 | * @return \Np\vector |
682 | 682 | */ |
683 | - protected function substractScalar(int|float $scalar): vector { |
|
683 | + protected function substractScalar(int | float $scalar): vector { |
|
684 | 684 | $vr = self::factory($this->col, $this->dtype); |
685 | 685 | for ($i = 0; $i < $this->col; ++$i) { |
686 | 686 | $vr->data[$i] = $this->data[$i] - $scalar; |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | |
802 | 802 | $vr = self::factory($this->col, $this->dtype); |
803 | 803 | |
804 | - for($i = 0; $i < $this->col; ++$i) { |
|
804 | + for ($i = 0; $i < $this->col; ++$i) { |
|
805 | 805 | if ($this->data[$i] > $max) { |
806 | 806 | $vr->data[$i] = $max; |
807 | 807 | continue; |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | |
818 | 818 | public function clipUpper(float $min) : vector { |
819 | 819 | $vr = self::factory($this->col, $this->dtype); |
820 | - for($i = 0; $i < $this->col; ++$i) { |
|
820 | + for ($i = 0; $i < $this->col; ++$i) { |
|
821 | 821 | if ($this->data[$i] > $min) { |
822 | 822 | $vr->data[$i] = $min; |
823 | 823 | continue; |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | |
829 | 829 | public function clipLower(float $min) : vector { |
830 | 830 | $vr = self::factory($this->col, $this->dtype); |
831 | - for($i = 0; $i < $this->col; ++$i) { |
|
831 | + for ($i = 0; $i < $this->col; ++$i) { |
|
832 | 832 | if ($this->data[$i] < $min) { |
833 | 833 | $vr->data[$i] = $min; |
834 | 834 | continue; |
@@ -884,15 +884,15 @@ discard block |
||
884 | 884 | * |
885 | 885 | * @return int|float |
886 | 886 | */ |
887 | - public function mean():int|float { |
|
888 | - return $this->sum()/ $this->col; |
|
887 | + public function mean():int | float { |
|
888 | + return $this->sum() / $this->col; |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
892 | 892 | * |
893 | 893 | * @return int|float |
894 | 894 | */ |
895 | - public function median():int|float { |
|
895 | + public function median():int | float { |
|
896 | 896 | $mid = intdiv($this->col, 2); |
897 | 897 | |
898 | 898 | $a = $this->copyVector()->sort(); |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | * set data to vector |
940 | 940 | * @param int|float|array $data |
941 | 941 | */ |
942 | - public function setData(int|float|array $data) { |
|
942 | + public function setData(int | float | array $data) { |
|
943 | 943 | if (is_array($data) && !is_array($data[0])) { |
944 | 944 | for ($i = 0; $i < $this->col; ++$i) { |
945 | 945 | $this->data[$i] = $data[$i]; |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | } |
953 | 953 | |
954 | 954 | public function asMatrix(): matrix { |
955 | - $size = (int) sqrt($this->col); |
|
955 | + $size = (int)sqrt($this->col); |
|
956 | 956 | $ar = matrix::factory($size, $size, $this->dtype); |
957 | 957 | for ($i = 0; $i < $ar->ndim; ++$i) { |
958 | 958 | $ar->data[$i] = $this->data[$i]; |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | } |
989 | 989 | |
990 | 990 | public function __toString() { |
991 | - return (string) $this->printVector(); |
|
991 | + return (string)$this->printVector(); |
|
992 | 992 | } |
993 | 993 | |
994 | 994 | protected function __construct(public int $col, int $dtype = self::FLOAT) { |