Passed
Push — main ( 16ad7b...83c0b8 )
by Shubham
01:42
created
src/decompositions/cholesky.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Np\decompositions;
6 6
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      * @return matrix|null
28 28
      * 
29 29
      */
30
-    public static function factory(matrix $m): matrix|null {
30
+    public static function factory(matrix $m): matrix | null {
31 31
         if ($m->isSquare()) {
32 32
             $ar = $m->copyMatrix();
33 33
             $lp = lapack::potrf($ar);
Please login to merge, or discard this patch.
src/core/blas.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -398,7 +398,7 @@
 block discarded – undo
398 398
      * @param \Np\vector|\Np\matrix $v
399 399
      * @return \FFI\CData
400 400
      */
401
-    public static function scale(float $alpha, \Np\vector|\Np\matrix $v) {
401
+    public static function scale(float $alpha, \Np\vector | \Np\matrix $v) {
402 402
         self::init();
403 403
         if ($v->dtype == \Np\vector::DOUBLE) {
404 404
             return self::$ffi_blas->cblas_dscal($v->ndim, $alpha, $v->data, 1);
Please login to merge, or discard this patch.
src/convolve.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
                 $r->data[$i] = $sigma;
30 30
             }
31 31
             return $r;
32
-        }
33
-        else {
32
+        } else {
34 33
             throw new dtypeException('Err::given vectors has diffrent data type!');
35 34
         }
36 35
     }
@@ -69,8 +68,7 @@  discard block
 block discarded – undo
69 68
                 }
70 69
             }
71 70
             return $rc;
72
-        }
73
-        else {
71
+        } else {
74 72
             throw new \Exception('Err::given matrixes has different data type!');
75 73
         }
76 74
     }
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
     protected $_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.
examples/matrix.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
 $a = matrix::randn(1000, 1000);
8 8
 $b = matrix::randn(1000, 1000);
9 9
 $a->dot($b);
10
-$a->getMemory();           // get memory use
11
-$a->time();               // get time
10
+$a->getMemory(); // get memory use
11
+$a->time(); // get time
12 12
 /**
13 13
  * Memory-Consumed 7.7mb
14 14
  * Time-Consumed:- 0.18390893936157
Please login to merge, or discard this patch.
src/matrix.php 2 patches
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * @email     [email protected]
25 25
  * @copyright (c) 2020-2021, Shubham Chaudhary
26 26
  */
27
-class matrix extends nd{
27
+class matrix extends nd {
28 28
 
29 29
     /**
30 30
      * create empty 2d matrix for given data type
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      * @return matrix
251 251
      */
252 252
     public function minimum(matrix $m): matrix {
253
-        if ($this->checkShape($this,$m)) {
253
+        if ($this->checkShape($this, $m)) {
254 254
             $ar = self::factory($this->row, $this->col, $this->dtype);
255 255
             for ($i = 0; $i < $this->ndim; ++$i) {
256 256
                 $ar->data[$i] = min($this->data[$i], $m->data[$i]);
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
      * @param \Np\matrix|\Np\vector $d
343 343
      * @return matrix|vector
344 344
      */
345
-    public function dot(matrix|vector $d): matrix|vector {
345
+    public function dot(matrix | vector $d): matrix | vector {
346 346
         if ($d instanceof self) {
347 347
             return $this->dotMatrix($d);
348 348
         } else {
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      * @return \Np\matrix
357 357
      */
358 358
     protected function dotMatrix(matrix $matrix): matrix {
359
-        if ($this->checkDtype($this, $matrix) && $this->checkDimensions($this,$matrix)) {
359
+        if ($this->checkDtype($this, $matrix) && $this->checkDimensions($this, $matrix)) {
360 360
             $ar = self::factory($this->row, $this->col, $this->dtype);
361 361
             blas::gemm($this, $matrix, $ar);
362 362
             return $ar;
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
      * @param int|float|matrix|vector $m
385 385
      * @return matrix|vector
386 386
      */
387
-    public function multiply(int|float|matrix|vector $m): matrix|vector {
387
+    public function multiply(int | float | matrix | vector $m): matrix | vector {
388 388
         if ($m instanceof self) {
389 389
             return $this->multiplyMatrix($m);
390 390
         } else if ($m instanceof vector) {
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      * @param int|float|matrix|vector $m
451 451
      * @return matrix
452 452
      */
453
-    public function sum(int|float|matrix|vector $m): matrix {
453
+    public function sum(int | float | matrix | vector $m): matrix {
454 454
         if ($m instanceof self) {
455 455
             return $this->sumMatrix($m);
456 456
         } elseif ($m instanceof vector) {
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         }
461 461
     }
462 462
 
463
-    protected function sumScalar(int|float $s): matrix {
463
+    protected function sumScalar(int | float $s): matrix {
464 464
         $ar = self::factory($this->row, $this->col, $this->dtype);
465 465
         for ($i = 0; $i < $this->ndim; ++$i) {
466 466
             $ar->data[$i] = $this->data[$i] + $s;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
      * @param int|float|matrix|vector $d matrix|$scalar to subtract this matrix
496 496
      * @return \Np\matrix
497 497
      */
498
-    public function subtract(int|float|matrix|vector $d): matrix {
498
+    public function subtract(int | float | matrix | vector $d): matrix {
499 499
         if ($d instanceof self) {
500 500
             return $this->subtractMatrix($d);
501 501
         } elseif ($d instanceof vector) {
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
         }
506 506
     }
507 507
 
508
-    protected function subtractScalar(int|float $s): matrix {
508
+    protected function subtractScalar(int | float $s): matrix {
509 509
         $ar = self::factory($this->row, $this->col, $this->dtype);
510 510
         for ($i = 0; $i < $this->ndim; ++$i) {
511 511
             $ar->data[$i] = $this->data[$i] - $s;
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
      * @return matrix
535 535
      */
536 536
     protected function subtractVector(vector $v): matrix {
537
-        if ($this->checkDimensions($v, $this) && $this->checkDtype($this,$v)) {
537
+        if ($this->checkDimensions($v, $this) && $this->checkDtype($this, $v)) {
538 538
             $ar = self::factory($this->row, $this->col, $this->dtype);
539 539
             for ($i = 0; $i < $this->row; ++$i) {
540 540
                 for ($j = 0; $j < $this->col; ++$j) {
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
      * @param int|float|matrix $d
568 568
      * @return matrix
569 569
      */
570
-    public function divide(int|float|matrix|vector $d): matrix {
570
+    public function divide(int | float | matrix | vector $d): matrix {
571 571
         if ($d instanceof self) {
572 572
             return $this->divideMatrix($d);
573 573
         } elseif ($d instanceof vector) {
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
         }
600 600
     }
601 601
 
602
-    protected function divideScalar(int|float $s): matrix {
602
+    protected function divideScalar(int | float $s): matrix {
603 603
         $ar = self::factory($this->row, $this->col, $this->dtype);
604 604
         for ($i = 0; $i < $this->ndim; ++$i) {
605 605
             $ar->data[$i] = $this->data[$i] / $s;
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
      * @param int|float|matrix $m
615 615
      * @return matrix
616 616
      */
617
-    public function pow(int|float|matrix|vector $d): matrix {
617
+    public function pow(int | float | matrix | vector $d): matrix {
618 618
         if ($d instanceof self) {
619 619
             return $this->powMatrix($d);
620 620
         } else if ($d instanceof vector) {
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
         }
647 647
     }
648 648
 
649
-    protected function powScalar(int|float $s): matrix {
649
+    protected function powScalar(int | float $s): matrix {
650 650
         $ar = $this->copyMatrix();
651 651
         for ($i = 0; $i < $this->ndim; ++$i) {
652 652
             $ar->data[$i] **= $s;
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
      * @param int|float|matrix|vector $d
660 660
      * @return matrix
661 661
      */
662
-    public function mod(int|float|matrix|vector $d): matrix {
662
+    public function mod(int | float | matrix | vector $d): matrix {
663 663
         if ($d instanceof self) {
664 664
             $this->modMatrix($d);
665 665
         } else if ($d instanceof vector) {
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         }
692 692
     }
693 693
 
694
-    protected function modScalar(int|float $s): matrix {
694
+    protected function modScalar(int | float $s): matrix {
695 695
         $ar = $this->copyMatrix();
696 696
         for ($i = 0; $i < $this->ndim; ++$i) {
697 697
             $ar->data[$i] %= $s;
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
      * @param int|float $scalar
804 804
      * @return matrix
805 805
      */
806
-    public function scale(int|float $scalar): matrix {
806
+    public function scale(int | float $scalar): matrix {
807 807
         if ($scalar == 0) {
808 808
             return self::zeros($this->row, $this->col, $this->dtype);
809 809
         }
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
      * @param int $row
822 822
      * @param int|float $c
823 823
      */
824
-    public function scaleRow(int $row, int|float $c) {
824
+    public function scaleRow(int $row, int | float $c) {
825 825
         for ($i = 0; $i < $this->col; ++$i) {
826 826
             $this->data[$row * $this->col + $i] *= $c;
827 827
         }
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
      * @param int $col
833 833
      * @param int|float $c
834 834
      */
835
-    public function scaleCol(int $col, int|float $c) {
835
+    public function scaleCol(int $col, int | float $c) {
836 836
         for ($i = 0; $i < $this->row; ++$i) {
837 837
             $this->data[$i * $this->col + $col] *= $c;
838 838
         }
@@ -843,14 +843,14 @@  discard block
 block discarded – undo
843 843
      * @param int|float $c
844 844
      * @param bool $lDig
845 845
      */
846
-    public function scaleDigonalCol(int|float $c, bool $lDig = true) {
847
-        if($lDig){
848
-            for ($i = 0; $i < $this->row ; ++$i) {
846
+    public function scaleDigonalCol(int | float $c, bool $lDig = true) {
847
+        if ($lDig) {
848
+            for ($i = 0; $i < $this->row; ++$i) {
849 849
                 $this->data[$i * $this->col + $i] *= $c;
850 850
             }
851 851
         }
852
-        else{
853
-            for ($i = $this->row; $i > 0 ; --$i) {
852
+        else {
853
+            for ($i = $this->row; $i > 0; --$i) {
854 854
                 $this->data[$i * $this->col - $i] *= $c;
855 855
             }
856 856
         }
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
      * @return matrix
898 898
      */
899 899
     public function joinRight(matrix $m): matrix {
900
-        if ($this->row != $m->row && !$this->checkDtype($this,$m)) {
900
+        if ($this->row != $m->row && !$this->checkDtype($this, $m)) {
901 901
             self::_err('Error::Invalid size! or DataType!');
902 902
         }
903 903
         $col = $this->col + $m->col;
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
      *
964 964
      * @return matrix|null
965 965
      */
966
-    public function ref(): matrix|null {
966
+    public function ref(): matrix | null {
967 967
         return ref::factory($this);
968 968
     }
969 969
 
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
      *
973 973
      * @return matrix|null
974 974
      */
975
-    public function cholesky(): matrix|null {
975
+    public function cholesky(): matrix | null {
976 976
         return cholesky::factory($this);
977 977
     }
978 978
 
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
      * @param bool $dignoal
1056 1056
      * @return void
1057 1057
      */
1058
-    public function setData(int|float|array $data, bool $dignoal = false): void {
1058
+    public function setData(int | float | array $data, bool $dignoal = false): void {
1059 1059
         if ($dignoal == false) {
1060 1060
             if (is_array($data) && is_array($data[0])) {
1061 1061
                 $f = $this->flattenArray($data);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
      * @return object
1088 1088
      */
1089 1089
     public function getShape(): object {
1090
-        return (object) ['m' => $this->row, 'n' => $this->col];
1090
+        return (object)['m' => $this->row, 'n' => $this->col];
1091 1091
     }
1092 1092
 
1093 1093
     /**
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
      * Compute the (Moore-Penrose) pseudo inverse of the general matrix.
1217 1217
      * @return matrix|null
1218 1218
      */
1219
-    public function pseudoInverse(): matrix|null {
1219
+    public function pseudoInverse(): matrix | null {
1220 1220
         $k = min($this->row, $this->col);
1221 1221
         $s = vector::factory($k, $this->dtype);
1222 1222
         $u = self::factory($this->row, $this->row, $this->dtype);
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
      * @param vector|null $mean
1401 1401
      * @return vector
1402 1402
      */
1403
-    public function variance(vector|null $mean = null): vector {
1403
+    public function variance(vector | null $mean = null): vector {
1404 1404
         if (isset($mean)) {
1405 1405
             if (!$mean instanceof vector) {
1406 1406
                 self::_invalidArgument('mean must be a vector!');
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
      * @param vector|null $mean
1443 1443
      * @return matrix
1444 1444
      */
1445
-    public function covariance(vector|null $mean = null): matrix {
1445
+    public function covariance(vector | null $mean = null): matrix {
1446 1446
         if (isset($mean)) {
1447 1447
             if ($mean->col !== $this->row) {
1448 1448
                 self::_err('Err:: given mean vector dimensionality mismatched!');
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
      * @param int|float|matrix|vector $d
1530 1530
      * @return matrix
1531 1531
      */
1532
-    public function equal(int|float|matrix|vector $d): matrix {
1532
+    public function equal(int | float | matrix | vector $d): matrix {
1533 1533
         if ($d instanceof self) {
1534 1534
             return $this->equalMatrix($d);
1535 1535
         } elseif ($d instanceof vector) {
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
         }
1562 1562
     }
1563 1563
 
1564
-    protected function equalScalar(int|float $s): matrix {
1564
+    protected function equalScalar(int | float $s): matrix {
1565 1565
         $ar = self::factory($this->row, $this->col, $this->dtype);
1566 1566
         for ($i = 0; $i < $this->ndim; ++$i) {
1567 1567
             $ar->data[$i] = $this->data[$i] == $s ? 1 : 0;
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
      * @param int|float|matrix|vector $d
1575 1575
      * @return matrix
1576 1576
      */
1577
-    public function greater(int|float|matrix|vector $d): matrix {
1577
+    public function greater(int | float | matrix | vector $d): matrix {
1578 1578
         if ($d instanceof self) {
1579 1579
             return $this->greaterMatrix($d);
1580 1580
         } elseif ($d instanceof vector) {
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
     }
1586 1586
 
1587 1587
     protected function greaterMatrix(matrix $m): matrix {
1588
-        if ($this->checkShape($this, $m) && $this->checkDtype($this,$m)) {
1588
+        if ($this->checkShape($this, $m) && $this->checkDtype($this, $m)) {
1589 1589
             $ar = self::factory($this->row, $this->col, $this->dtype);
1590 1590
             for ($i = 0; $i < $this->ndim; ++$i) {
1591 1591
                 $ar->data[$i] = $this->data[$i] > $m->data[$i] ? 1 : 0;
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
     }
1596 1596
 
1597 1597
     protected function greaterVector(vector $v): matrix {
1598
-        if ($this->checkDimensions($v, $this) && $this->checkDtype($this,$v)) {
1598
+        if ($this->checkDimensions($v, $this) && $this->checkDtype($this, $v)) {
1599 1599
             $ar = self::factory($this->row, $this->col, $this->dtype);
1600 1600
             for ($i = 0; $i < $this->row; ++$i) {
1601 1601
                 for ($j = 0; $j < $this->col; ++$j) {
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
         }
1607 1607
     }
1608 1608
 
1609
-    protected function greaterScalar(int|float $s): matrix {
1609
+    protected function greaterScalar(int | float $s): matrix {
1610 1610
         $ar = self::factory($this->row, $this->col, $this->dtype);
1611 1611
         for ($i = 0; $i < $this->ndim; ++$i) {
1612 1612
             $ar->data[$i] = $this->data[$i] > $s ? 1 : 0;
@@ -1619,10 +1619,10 @@  discard block
 block discarded – undo
1619 1619
      * @param int|float|matrix $m
1620 1620
      * @return matrix
1621 1621
      */
1622
-    public function less(int|float|matrix $m): matrix {
1622
+    public function less(int | float | matrix $m): matrix {
1623 1623
         $ar = self::factory($this->row, $this->col, $this->dtype);
1624 1624
         if ($m instanceof self) {
1625
-            if ($this->checkShape($this,$m)) {
1625
+            if ($this->checkShape($this, $m)) {
1626 1626
                 for ($i = 0; $i < $this->ndim; ++$i) {
1627 1627
                     $ar->data[$i] = $this->data[$i] < $m->data[$i] ? 1 : 0;
1628 1628
                 }
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
      * @return matrix
1664 1664
      */
1665 1665
     public function reshape(int $row, int $col):matrix {
1666
-        if($this->ndim != $row * $col) {
1666
+        if ($this->ndim != $row * $col) {
1667 1667
             self::_dimensionaMisMatchErr('given dimenssion is not valid for current bufferData');
1668 1668
         }
1669 1669
         $this->row = $row;
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
     }
1686 1686
 
1687 1687
     public function __toString() {
1688
-        return (string) $this->printMatrix();
1688
+        return (string)$this->printMatrix();
1689 1689
     }
1690 1690
 
1691 1691
     private function flattenArray(array $ar) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -848,8 +848,7 @@
 block discarded – undo
848 848
             for ($i = 0; $i < $this->row ; ++$i) {
849 849
                 $this->data[$i * $this->col + $i] *= $c;
850 850
             }
851
-        }
852
-        else{
851
+        } else{
853 852
             for ($i = $this->row; $i > 0 ; --$i) {
854 853
                 $this->data[$i * $this->col - $i] *= $c;
855 854
             }
Please login to merge, or discard this patch.
src/vector.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
  * @copyright (c) 2020-2021, Shubham Chaudhary
25 25
  * 
26 26
  */
27
- class vector extends nd {
27
+    class vector extends nd {
28 28
 
29 29
     /**
30 30
      * Factory method to build a new vector.
Please login to merge, or discard this 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) {
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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];
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
      * @return matrix
959 959
      */
960 960
     public function reshape(int $row, int $col): matrix {
961
-        if($this->col != $row * $col) {
961
+        if ($this->col != $row * $col) {
962 962
             self::_dimensionaMisMatchErr('given dimenssion is not valid for current bufferData');
963 963
         }
964 964
         $ar = matrix::factory($row, $col, $this->dtype);
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
     }
995 995
 
996 996
     public function __toString() {
997
-        return (string) $this->printVector();
997
+        return (string)$this->printVector();
998 998
     }
999 999
 
1000 1000
     protected function __construct(public int $col, int $dtype = self::FLOAT) {
Please login to merge, or discard this patch.