Passed
Push — main ( cb3172...6ba222 )
by Shubham
01:56
created
src/vector.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
      * 
562 562
      * @param int|float $s
563 563
      */
564
-    protected function powScalar(int|float $s) {
564
+    protected function powScalar(int | float $s) {
565 565
         $v = $this->copyVector();
566 566
         for ($i = 0; $i < $this->col; ++$i) {
567 567
             $v->data[$i] = $v->data[$i] ** $s;
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
      * @param int|float|\Np\matrix|\Np\vector $d
574 574
      * @return matrix|vector
575 575
      */
576
-    public function mod(int|float|\Np\matrix|\Np\vector $d): matrix|vector {
576
+    public function mod(int | float | \Np\matrix | \Np\vector $d): matrix | vector {
577 577
         if ($d instanceof matrix) {
578 578
             return $this->powMatrix($d);
579 579
         } elseif ($d instanceof vector) {
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
      * 
620 620
      * @param int|float $s
621 621
      */
622
-    protected function modScalar(int|float $s) {
622
+    protected function modScalar(int | float $s) {
623 623
         $v = $this->copyVector();
624 624
         for ($i = 0; $i < $this->col; ++$i) {
625 625
             $v->data[$i] = $v->data[$i] % $s;
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
      * @param int|float|matrix|vector $d
632 632
      * @return matrix|vector
633 633
      */
634
-    public function subtract(int|float|matrix|vector $d): matrix|vector {
634
+    public function subtract(int | float | matrix | vector $d): matrix | vector {
635 635
         if ($d instanceof matrix) {
636 636
             return $this->subtractMatrix($d);
637 637
         } elseif ($d instanceof self) {
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
      * @param \Np\vector $scalar
679 679
      * @return \Np\vector
680 680
      */
681
-    protected function substractScalar(int|float $scalar): vector {
681
+    protected function substractScalar(int | float $scalar): vector {
682 682
         $vr = self::factory($this->col, $this->dtype);
683 683
         for ($i = 0; $i < $this->col; ++$i) {
684 684
             $vr->data[$i] = $this->data[$i] - $scalar;
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 
800 800
         $vr = self::factory($this->col, $this->dtype);
801 801
         
802
-        for($i = 0; $i < $this->col; ++$i) {
802
+        for ($i = 0; $i < $this->col; ++$i) {
803 803
             if ($this->data[$i] > $max) {
804 804
                 $vr->data[$i] = $max;
805 805
                 continue;
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
     
816 816
     public function clipUpper(float $min) : vector {
817 817
         $vr = self::factory($this->col, $this->dtype);
818
-        for($i = 0; $i < $this->col; ++$i) {
818
+        for ($i = 0; $i < $this->col; ++$i) {
819 819
             if ($this->data[$i] > $min) {
820 820
                 $vr->data[$i] = $min;
821 821
                 continue;
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
     
827 827
     public function clipLower(float $min) : vector {
828 828
         $vr = self::factory($this->col, $this->dtype);
829
-        for($i = 0; $i < $this->col; ++$i) {
829
+        for ($i = 0; $i < $this->col; ++$i) {
830 830
             if ($this->data[$i] < $min) {
831 831
                 $vr->data[$i] = $min;
832 832
                 continue;
@@ -882,15 +882,15 @@  discard block
 block discarded – undo
882 882
      * 
883 883
      * @return int|float
884 884
      */
885
-    public function mean():int|float {
886
-        return $this->sum()/ $this->col;
885
+    public function mean():int | float {
886
+        return $this->sum() / $this->col;
887 887
     }
888 888
     
889 889
     /**
890 890
      * 
891 891
      * @return int|float
892 892
      */
893
-    public function median():int|float {
893
+    public function median():int | float {
894 894
         $mid = intdiv($this->col, 2);
895 895
 
896 896
         $a = $this->copyVector()->sort();
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
      * set data to vector
938 938
      * @param int|float|array $data
939 939
      */
940
-    public function setData(int|float|array $data) {
940
+    public function setData(int | float | array $data) {
941 941
         if (is_array($data) && !is_array($data[0])) {
942 942
             for ($i = 0; $i < $this->col; ++$i) {
943 943
                 $this->data[$i] = $data[$i];
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
     }
951 951
 
952 952
     public function asMatrix(): matrix {
953
-        $size = (int) sqrt($this->col);
953
+        $size = (int)sqrt($this->col);
954 954
         $ar = matrix::factory($size, $size, $this->dtype);
955 955
         for ($i = 0; $i < $ar->ndim; ++$i) {
956 956
             $ar->data[$i] = $this->data[$i];
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
     }
987 987
 
988 988
     public function __toString() {
989
-        return (string) $this->printVector();
989
+        return (string)$this->printVector();
990 990
     }
991 991
 
992 992
     protected function __construct(public int $col, int $dtype = self::FLOAT) {
Please login to merge, or discard this patch.
src/core/nd.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@
 block discarded – undo
30 30
     public $data;
31 31
     public static $_time = null, $_mem = null;
32 32
     
33
-    public function checkDimensions(\Np\matrix|\Np\vector $Obj1, \Np\matrix $Obj2) {
34
-        if($Obj1->col == $Obj2->row){
33
+    public function checkDimensions(\Np\matrix | \Np\vector $Obj1, \Np\matrix $Obj2) {
34
+        if ($Obj1->col == $Obj2->row) {
35 35
             return true;
36 36
         }
37 37
         self::_dimensionaMisMatchErr('Mismatch Dimensions of given Objects! Obj-A col & Obj-B row amount need to be the same!');
38 38
     }
39 39
     
40
-    public function checkDtype(\Np\matrix|\Np\vector $Obj1, \Np\matrix|\Np\vector $Obj2){
41
-        if($Obj1->dtype == $Obj2->dtype) {
40
+    public function checkDtype(\Np\matrix | \Np\vector $Obj1, \Np\matrix | \Np\vector $Obj2) {
41
+        if ($Obj1->dtype == $Obj2->dtype) {
42 42
             return true;
43 43
         }
44 44
         self::_dtypeErr('mismatch data type of given Np\Objects!');
45 45
     }
46 46
     
47
-    public function checkShape(\Np\matrix|\Np\vector $Obj1, \Np\matrix|\Np\vector $Obj2) {
47
+    public function checkShape(\Np\matrix | \Np\vector $Obj1, \Np\matrix | \Np\vector $Obj2) {
48 48
         if ($Obj1 instanceof \Np\vector && $Obj2 instanceof \Np\vector) {
49 49
             if ($Obj1->col == $Obj2->col) {
50 50
                 return true;
Please login to merge, or discard this patch.