Passed
Push — main ( c6ea82...2b687d )
by Shubham
01:44
created
benchmarks/vector/signalProcessing/convolveBench.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@
 block discarded – undo
21 21
     protected $b;
22 22
 
23 23
     public function setUp() : void {
24
-        $this->a = matrix::uniform(500,500);
24
+        $this->a = matrix::uniform(500, 500);
25 25
 
26
-        $this->b = matrix::uniform(50,50);
26
+        $this->b = matrix::uniform(50, 50);
27 27
     }
28 28
 
29 29
     /**
Please login to merge, or discard this patch.
benchmarks/matrix/arithmetic/sumMatrixBench.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     /**
14 14
      * @var \Np\matrix
15 15
      */
16
-    protected $a,$b;
16
+    protected $a, $b;
17 17
 
18 18
     public function setUp() : void {
19 19
         $this->a = matrix::uniform(500, 500);
Please login to merge, or discard this patch.
benchmarks/matrix/arithmetic/matrixVectorMultiplyBench.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace Np\benchmarks\matrix\arithmetic;
4 4
 
5
-use Np\{matrix,vector};
5
+use Np\{matrix, vector};
6 6
 
7 7
 /**
8 8
  * @Groups({"Arithmetic"})
Please login to merge, or discard this patch.
src/reductions/ref.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@
 block discarded – undo
24 24
       * @param \Np\matrix $m
25 25
       * @return matrix|null
26 26
       */
27
-    public static function factory(\Np\matrix $m): matrix|null {
27
+    public static function factory(\Np\matrix $m): matrix | null {
28 28
         $ipiv = vector::factory(min($m->row, $m->col), vector::INT);
29 29
         $ar = $m->copyMatrix();
30
-        if($m->dtype == matrix::FLOAT) {
30
+        if ($m->dtype == matrix::FLOAT) {
31 31
             $lp = lapack::sgetrf($ar, $ipiv);
32 32
             if ($lp != 0) {
33 33
                 return null;
Please login to merge, or discard this patch.
src/decompositions/svd.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 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
 
Please login to merge, or discard this patch.
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
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @return matrix|null
29 29
      * @throws RuntimeException
30 30
      */
31
-    public static function factory(matrix $m): matrix|null {
31
+    public static function factory(matrix $m): matrix | null {
32 32
         if ($m->isSquare()) {
33 33
             $ar = $m->copyMatrix();
34 34
             $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
@@ -439,7 +439,7 @@
 block discarded – undo
439 439
      * @param \Np\vector|\Np\matrix $v
440 440
      * @return type
441 441
      */
442
-    public static function scale(float $alpha, \Np\vector|\Np\matrix $v) {
442
+    public static function scale(float $alpha, \Np\vector | \Np\matrix $v) {
443 443
         self::init();
444 444
         if ($v->dtype == \Np\vector::DOUBLE) {
445 445
             return self::$ffi_blas->cblas_dscal($v->ndim, $alpha, $v->data, 1);
Please login to merge, or discard this patch.
src/core/lapack.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public static function getri(\Np\matrix $mat, \Np\vector $ipiv, int $matLayout = self::ROW_MAJOR) {
53 53
         self::init();
54
-        if($mat->dtype == \Np\matrix::FLOAT){
54
+        if ($mat->dtype == \Np\matrix::FLOAT) {
55 55
             return self::$ffi_lapack->LAPACKE_sgetri($matLayout, $mat->row, $mat->data, $mat->row, $ipiv->data);
56 56
         }
57 57
         else {
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public static function lange(string $norm, \Np\matrix $m, int $matLayout = self::ROW_MAJOR) {
138 138
         self::init();
139
-        if($m->dtype == \Np\matrix::FLOAT){
139
+        if ($m->dtype == \Np\matrix::FLOAT) {
140 140
             return self::$ffi_lapack->LAPACKE_slange($matLayout, $norm, $m->row, $m->col, $m->data, $m->col);
141 141
         }
142
-        else{
142
+        else {
143 143
             return self::$ffi_lapack->LAPACKE_dlange($matLayout, $norm, $m->row, $m->col, $m->data, $m->col);
144 144
         }   
145 145
     }
Please login to merge, or discard this patch.
src/matrix.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  * @email     [email protected]
23 23
  * @copyright (c) 2020-2021, Shubham Chaudhary
24 24
  */
25
-class matrix extends nd{
25
+class matrix extends nd {
26 26
 
27 27
     public $row, $col;
28 28
     /**
@@ -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 {
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
      * @param int|float|matrix|vector $m
389 389
      * @return matrix|vector
390 390
      */
391
-    public function multiply(int|float|matrix|vector $m): matrix|vector {
391
+    public function multiply(int | float | matrix | vector $m): matrix | vector {
392 392
         if ($m instanceof self) {
393 393
             return $this->multiplyMatrix($m);
394 394
         } else if ($m instanceof vector) {
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      * @param int|float $scalar
438 438
      * @return matrix
439 439
      */
440
-    public function scale(int|float $scalar): matrix {
440
+    public function scale(int | float $scalar): matrix {
441 441
         if ($scalar == 0) {
442 442
             return self::zeros($this->row, $this->col, $this->dtype);
443 443
         }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
      * @param int|float|matrix|vector $m
473 473
      * @return matrix
474 474
      */
475
-    public function sum(int|float|matrix|vector $m): matrix {
475
+    public function sum(int | float | matrix | vector $m): matrix {
476 476
         if ($m instanceof self) {
477 477
             return $this->sumMatrix($m);
478 478
         } elseif ($m instanceof vector) {
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         }
483 483
     }
484 484
 
485
-    protected function sumScalar(int|float $s): matrix {
485
+    protected function sumScalar(int | float $s): matrix {
486 486
         $ar = self::factory($this->row, $this->col, $this->dtype);
487 487
         for ($i = 0; $i < $this->ndim; ++$i) {
488 488
             $ar->data[$i] = $this->data[$i] + $s;
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
      * @param int|float|matrix|vector $d matrix|$scalar to subtract this matrix
518 518
      * @return \Np\matrix
519 519
      */
520
-    public function subtract(int|float|matrix|vector $d): matrix {
520
+    public function subtract(int | float | matrix | vector $d): matrix {
521 521
         if ($d instanceof self) {
522 522
             return $this->subtractMatrix($d);
523 523
         } elseif ($d instanceof vector) {
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         }
528 528
     }
529 529
 
530
-    protected function subtractScalar(int|float $s): matrix {
530
+    protected function subtractScalar(int | float $s): matrix {
531 531
         $ar = self::factory($this->row, $this->col, $this->dtype);
532 532
         for ($i = 0; $i < $this->ndim; ++$i) {
533 533
             $ar->data[$i] = $this->data[$i] - $s;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
      * @param int|float|matrix $d
590 590
      * @return matrix
591 591
      */
592
-    public function divide(int|float|matrix|vector $d): matrix {
592
+    public function divide(int | float | matrix | vector $d): matrix {
593 593
         if ($d instanceof self) {
594 594
             return $this->divideMatrix($d);
595 595
         } elseif ($d instanceof vector) {
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
         }
626 626
     }
627 627
 
628
-    protected function divideScalar(int|float $s): matrix {
628
+    protected function divideScalar(int | float $s): matrix {
629 629
         $ar = self::factory($this->row, $this->col, $this->dtype);
630 630
         for ($i = 0; $i < $this->ndim; ++$i) {
631 631
             $ar->data[$i] = $this->data[$i] / $s;
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      * @param int|float|matrix $m
641 641
      * @return matrix
642 642
      */
643
-    public function pow(int|float|matrix|vector $d): matrix {
643
+    public function pow(int | float | matrix | vector $d): matrix {
644 644
         if ($d instanceof self) {
645 645
             return $this->powMatrix($d);
646 646
         } else if ($d instanceof vector) {
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
         }
673 673
     }
674 674
 
675
-    protected function powScalar(int|float $s): matrix {
675
+    protected function powScalar(int | float $s): matrix {
676 676
         $ar = $this->copyMatrix();
677 677
         for ($i = 0; $i < $this->ndim; ++$i) {
678 678
             $ar->data[$i] **= $s;
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
      * @param int|float|matrix|vector $d
686 686
      * @return matrix
687 687
      */
688
-    public function mod(int|float|matrix|vector $d): matrix {
688
+    public function mod(int | float | matrix | vector $d): matrix {
689 689
         if ($d instanceof self) {
690 690
             $this->modMatrix($d);
691 691
         } else if ($d instanceof vector) {
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
         }
720 720
     }
721 721
 
722
-    protected function modScalar(int|float $s): matrix {
722
+    protected function modScalar(int | float $s): matrix {
723 723
         $ar = $this->copyMatrix();
724 724
         for ($i = 0; $i < $this->ndim; ++$i) {
725 725
             $ar->data[$i] %= $s;
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
      *
945 945
      * @return matrix|null
946 946
      */
947
-    public function ref(): matrix|null {
947
+    public function ref(): matrix | null {
948 948
         return ref::factory($this);
949 949
     }
950 950
 
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
      *
954 954
      * @return matrix|null
955 955
      */
956
-    public function cholesky(): matrix|null {
956
+    public function cholesky(): matrix | null {
957 957
         return cholesky::factory($this);
958 958
     }
959 959
 
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
      * @param bool $dignoal
1037 1037
      * @return void
1038 1038
      */
1039
-    public function setData(int|float|array $data, bool $dignoal = false): void {
1039
+    public function setData(int | float | array $data, bool $dignoal = false): void {
1040 1040
         if ($dignoal == false) {
1041 1041
             if (is_array($data) && is_array($data[0])) {
1042 1042
                 $f = $this->flattenArray($data);
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
      * @return object
1061 1061
      */
1062 1062
     public function getShape(): object {
1063
-        return (object) ['m' => $this->row, 'n' => $this->col];
1063
+        return (object)['m' => $this->row, 'n' => $this->col];
1064 1064
     }
1065 1065
 
1066 1066
     /**
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
      * Compute the (Moore-Penrose) pseudo inverse of the general matrix.
1193 1193
      * @return matrix|null
1194 1194
      */
1195
-    public function pseudoInverse(): matrix|null {
1195
+    public function pseudoInverse(): matrix | null {
1196 1196
         $k = min($this->row, $this->col);
1197 1197
         $s = vector::factory($k, $this->dtype);
1198 1198
         $u = self::factory($this->row, $this->row, $this->dtype);
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
      * @param vector|null $mean
1377 1377
      * @return vector
1378 1378
      */
1379
-    public function variance(vector|null $mean = null): vector {
1379
+    public function variance(vector | null $mean = null): vector {
1380 1380
         if (isset($mean)) {
1381 1381
             if (!$mean instanceof vector) {
1382 1382
                 self::_invalidArgument('mean must be a vector!');
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
      * @param vector|null $mean
1419 1419
      * @return matrix
1420 1420
      */
1421
-    public function covariance(vector|null $mean = null): matrix {
1421
+    public function covariance(vector | null $mean = null): matrix {
1422 1422
         if (isset($mean)) {
1423 1423
             if ($mean->col !== $this->row) {
1424 1424
                 self::_err('Err:: given mean vector dimensionality mismatched!');
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
      * @param int|float|matrix|vector $d
1506 1506
      * @return matrix
1507 1507
      */
1508
-    public function equal(int|float|matrix|vector $d): matrix {
1508
+    public function equal(int | float | matrix | vector $d): matrix {
1509 1509
         if ($d instanceof self) {
1510 1510
             return $this->equalMatrix($d);
1511 1511
         } elseif ($d instanceof vector) {
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
         }
1538 1538
     }
1539 1539
 
1540
-    protected function equalScalar(int|float $s): matrix {
1540
+    protected function equalScalar(int | float $s): matrix {
1541 1541
         $ar = self::factory($this->row, $this->col, $this->dtype);
1542 1542
         for ($i = 0; $i < $this->ndim; ++$i) {
1543 1543
             $ar->data[$i] = $this->data[$i] == $s ? 1 : 0;
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
      * @param int|float|matrix|vector $d
1551 1551
      * @return matrix
1552 1552
      */
1553
-    public function greater(int|float|matrix|vector $d): matrix {
1553
+    public function greater(int | float | matrix | vector $d): matrix {
1554 1554
         if ($d instanceof self) {
1555 1555
             return $this->greaterMatrix($d);
1556 1556
         } elseif ($d instanceof vector) {
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
         }
1583 1583
     }
1584 1584
 
1585
-    protected function greaterScalar(int|float $s): matrix {
1585
+    protected function greaterScalar(int | float $s): matrix {
1586 1586
         $ar = self::factory($this->row, $this->col, $this->dtype);
1587 1587
         for ($i = 0; $i < $this->ndim; ++$i) {
1588 1588
             $ar->data[$i] = $this->data[$i] > $s ? 1 : 0;
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
      * @param int|float|matrix $m
1596 1596
      * @return matrix
1597 1597
      */
1598
-    public function less(int|float|matrix $m): matrix {
1598
+    public function less(int | float | matrix $m): matrix {
1599 1599
         $ar = self::factory($this->row, $this->col, $this->dtype);
1600 1600
         if ($m instanceof self) {
1601 1601
             if ($this->checkShape($m)) {
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
     }
1647 1647
 
1648 1648
     public function __toString() {
1649
-        return (string) $this->printMatrix();
1649
+        return (string)$this->printMatrix();
1650 1650
     }
1651 1651
 
1652 1652
     protected function flattenArray(array $ar) {
@@ -1686,7 +1686,7 @@  discard block
 block discarded – undo
1686 1686
         if ($row < 1 || $col < 1) {
1687 1687
             self::_invalidArgument('* To create Numphp/Matrix row & col must be greater than 0!, Op Failed! * ');
1688 1688
         }
1689
-        parent::__construct($row*$col, $dtype);
1689
+        parent::__construct($row * $col, $dtype);
1690 1690
         $this->row = $row;
1691 1691
         $this->col = $col;
1692 1692
         return $this;
Please login to merge, or discard this patch.