Passed
Push — main ( 748618...1afffd )
by Shubham
10:21
created
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/exceptions/dtypeException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,6 +8,6 @@
 block discarded – undo
8 8
  *
9 9
  * @author ghost
10 10
  */
11
-class dtypeException extends invalidArgumentException{
11
+class dtypeException extends invalidArgumentException {
12 12
     //put your code here
13 13
 }
Please login to merge, or discard this patch.
examples/vector.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 use Np\vector;
6 6
 vector::time();
7 7
 vector::getMemory();
8
-$v = vector::ar(range(random_int(1,2), random_int(99999,9999999))); 
8
+$v = vector::ar(range(random_int(1, 2), random_int(99999, 9999999))); 
9 9
 
10 10
 echo $v->sum() . PHP_EOL;
11 11
 vector::getMemory();
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/vector.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@
 block discarded – undo
17 17
  * @copyright (c) 2020-2021, Shubham Chaudhary
18 18
  * 
19 19
  */
20
- class vector extends nd {
21
-     use ops,linAlgb\linAlg;
20
+    class vector extends nd {
21
+        use ops,linAlgb\linAlg;
22 22
 
23 23
     /**
24 24
      * Factory method to build a new vector.
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 namespace Np;
6 6
 
7
-use Np\core\{nd,blas,lapack};
7
+use Np\core\{nd, blas, lapack};
8 8
 use Np\exceptions\invalidArgumentException;
9 9
 
10 10
 /** 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * 
19 19
  */
20 20
  class vector extends nd {
21
-     use ops,linAlgb\linAlg;
21
+     use ops, linAlgb\linAlg;
22 22
 
23 23
     /**
24 24
      * Factory method to build a new vector.
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param int|float|double $val
123 123
      * @return vector
124 124
      */
125
-    public static function full(int $col, int|float $val): vector {
125
+    public static function full(int $col, int | float $val): vector {
126 126
         $ar = self::factory($col);
127 127
         for ($i = 0; $i < $col; ++$i) {
128 128
             $ar->data[$i] = $val;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @param int|float $interval
139 139
      * @return vector
140 140
      */
141
-    public static function range(int|float $start, int|float $end, int|float $interval = 1): vector {
141
+    public static function range(int | float $start, int | float $end, int | float $interval = 1): vector {
142 142
         return self::ar(range($start, $end, $interval));
143 143
     }
144 144
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      * @param int|float|matrix|vector $d
270 270
      * @return matrix|vector
271 271
      */
272
-    public function divide(int|float|matrix|vector $d): matrix|vector {
272
+    public function divide(int | float | matrix | vector $d): matrix | vector {
273 273
         if ($d instanceof matrix) {
274 274
             return $this->divideMatrix($d);
275 275
         }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * @param int|float $s
317 317
      * @return vector
318 318
      */
319
-    protected function divideScalar(int|float $s): vector {
319
+    protected function divideScalar(int | float $s): vector {
320 320
         $vr = self::factory($this->col);
321 321
         for ($i = 0; $i < $this->col; ++$i) {
322 322
             $vr->data[$i] = $this->data[$i] / $s;
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      * @param int|float|matrix|vector $d
330 330
      * @return matrix|vector
331 331
      */
332
-    public function multiply(int|float|matrix|vector $d): matrix|vector {
332
+    public function multiply(int | float | matrix | vector $d): matrix | vector {
333 333
         if ($d instanceof matrix) {
334 334
             return $this->multiplyMatrix($d);
335 335
         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
      * @param int|float $s
377 377
      * @return vector
378 378
      */
379
-    protected function multiplyScalar(int|float $s): vector {
379
+    protected function multiplyScalar(int | float $s): vector {
380 380
         $vr = $this->copy();
381 381
         blas::scale($s, $vr);
382 382
         return $vr;
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
      * @param int|float|matrix|vector $d
388 388
      * @return matrix|vector
389 389
      */
390
-    public function add(int|float|matrix|vector $d): matrix|vector {
390
+    public function add(int | float | matrix | vector $d): matrix | vector {
391 391
         if ($d instanceof matrix) {
392 392
             return $this->addMatrix($d);
393 393
         }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
      * @param int|float $s
435 435
      * @return vector
436 436
      */
437
-    protected function addScalar(int|float $s): vector {
437
+    protected function addScalar(int | float $s): vector {
438 438
         $vr = $this->copy();
439 439
         for ($i = 0; $i < $this->col; ++$i) {
440 440
             $vr->data[$i] += $s;
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
      * @param int|float|\Np\matrix|\Np\vector $d
448 448
      * @return matrix|vector
449 449
      */
450
-    public function pow(int|float|\Np\matrix|\Np\vector $d): matrix|vector {
450
+    public function pow(int | float | \Np\matrix | \Np\vector $d): matrix | vector {
451 451
         if ($d instanceof matrix) {
452 452
             return $this->powMatrix($d);
453 453
         }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
      * @param int|float $s
496 496
      * @return vector
497 497
      */
498
-    protected function powScalar(int|float $s): vector {
498
+    protected function powScalar(int | float $s): vector {
499 499
         $v = $this->copy();
500 500
         for ($i = 0; $i < $this->col; ++$i) {
501 501
             $v->data[$i] = $v->data[$i] ** $s;
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
      * @param int|float|\Np\matrix|\Np\vector $d
509 509
      * @return matrix|vector
510 510
      */
511
-    public function mod(int|float|\Np\matrix|\Np\vector $d): matrix|vector {
511
+    public function mod(int | float | \Np\matrix | \Np\vector $d): matrix | vector {
512 512
         if ($d instanceof matrix) {
513 513
             return $this->powMatrix($d);
514 514
         }
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
      * 
555 555
      * @param int|float $s
556 556
      */
557
-    protected function modScalar(int|float $s) {
557
+    protected function modScalar(int | float $s) {
558 558
         $v = $this->copy();
559 559
         for ($i = 0; $i < $this->col; ++$i) {
560 560
             $v->data[$i] = $v->data[$i] % $s;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
      * @param int|float|matrix|vector $d
567 567
      * @return matrix|vector
568 568
      */
569
-    public function subtract(int|float|matrix|vector $d): matrix|vector {
569
+    public function subtract(int | float | matrix | vector $d): matrix | vector {
570 570
         if ($d instanceof matrix) {
571 571
             return $this->subtractMatrix($d);
572 572
         }
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
      * @return vector
600 600
      */
601 601
     protected function subtractVector(\Np\vector $vector): vector {
602
-        if ($this->checkShape($this, $vector) ) {
602
+        if ($this->checkShape($this, $vector)) {
603 603
             $vr = self::factory($this->col);
604 604
             for ($i = 0; $i < $this->col; ++$i) {
605 605
                 $vr->data[$i] = $this->data[$i] - $vector->data[$i];
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
      * @param \Np\vector $scalar
614 614
      * @return \Np\vector
615 615
      */
616
-    protected function substractScalar(int|float $scalar): vector {
616
+    protected function substractScalar(int | float $scalar): vector {
617 617
         $vr = self::factory($this->col);
618 618
         for ($i = 0; $i < $this->col; ++$i) {
619 619
             $vr->data[$i] = $this->data[$i] - $scalar;
@@ -685,15 +685,15 @@  discard block
 block discarded – undo
685 685
      * 
686 686
      * @return int|float
687 687
      */
688
-    public function mean():int|float {
689
-        return $this->sum()/ $this->col;
688
+    public function mean():int | float {
689
+        return $this->sum() / $this->col;
690 690
     }
691 691
     
692 692
     /**
693 693
      * 
694 694
      * @return int|float
695 695
      */
696
-    public function median():int|float {
696
+    public function median():int | float {
697 697
         $mid = intdiv($this->col, 2);
698 698
 
699 699
         $a = $this->copy()->sort();
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
      * set data to vector
739 739
      * @param int|float|array $data
740 740
      */
741
-    public function setData(int|float|array $data) {
741
+    public function setData(int | float | array $data) {
742 742
         if (is_array($data) && !is_array($data[0])) {
743 743
             for ($i = 0; $i < $this->col; ++$i) {
744 744
                 $this->data[$i] = $data[$i];
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
     }
781 781
 
782 782
     public function __toString() {
783
-        return (string) $this->printVector();
783
+        return (string)$this->printVector();
784 784
     }
785 785
 
786 786
     protected function __construct(public int $col, int $dtype = self::DOUBLE) {
Please login to merge, or discard this patch.
src/ops.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * @param matrix|vector $d
20 20
      * @return matrix|vector
21 21
      */
22
-    public function max(matrix|vector $d): matrix|vector {
22
+    public function max(matrix | vector $d): matrix | vector {
23 23
         if ($this instanceof matrix && $d instanceof matrix && $this->checkShape($this, $d)) {
24 24
             $r = self::factory($this->row, $this->col);
25 25
         } elseif ($this instanceof vector && $d instanceof vector && $this->checkShape($this, $d)) {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @param matrix|vector $d
37 37
      * @return matrix|vector
38 38
      */
39
-    public function min(matrix|vector $d): matrix|vector {
39
+    public function min(matrix | vector $d): matrix | vector {
40 40
         if ($this instanceof matrix && $d instanceof matrix && $this->checkShape($this, $d)) {
41 41
             $r = self::factory($this->row, $this->col);
42 42
         } elseif ($this instanceof vector && $d instanceof vector && $this->checkShape($this, $d)) {
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param callable $func
54 54
      * @return matrix|vector
55 55
      */
56
-    public function map(callable $func): matrix|vector {
56
+    public function map(callable $func): matrix | vector {
57 57
         if ($this instanceof matrix) {
58 58
             $r = self::factory($this->row, $this->col);
59 59
         } else {
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
         return $r;
66 66
     }
67 67
 
68
-    public function abs(): matrix|vector {
68
+    public function abs(): matrix | vector {
69 69
         return $this->map('abs');
70 70
     }
71 71
 
72
-    public function sqrt(): matrix|vector {
72
+    public function sqrt(): matrix | vector {
73 73
         return $this->map('sqrt');
74 74
     }
75 75
 
76
-    public function exp(): matrix|vector {
76
+    public function exp(): matrix | vector {
77 77
         return $this->map('exp');
78 78
     }
79 79
 
80
-    public function exp1(): matrix|vector {
80
+    public function exp1(): matrix | vector {
81 81
         return $this->map('exp1');
82 82
     }
83 83
 
84
-    public function log(float $b = M_E): matrix|vector {
84
+    public function log(float $b = M_E): matrix | vector {
85 85
         $ar = $this->copy();
86 86
         for ($i = 0; $i < $ar->ndim; ++$i) {
87 87
             log($ar->data[$i], $b);
@@ -89,52 +89,52 @@  discard block
 block discarded – undo
89 89
         return $ar;
90 90
     }
91 91
 
92
-    public function log1p(): matrix|vector {
92
+    public function log1p(): matrix | vector {
93 93
         return $this->map('log1p');
94 94
     }
95 95
 
96
-    public function sin(): matrix|vector {
96
+    public function sin(): matrix | vector {
97 97
         return $this->map('sin');
98 98
     }
99 99
 
100
-    public function asin(): matrix|vector {
100
+    public function asin(): matrix | vector {
101 101
         return $this->map('asin');
102 102
     }
103 103
 
104
-    public function cos(): matrix|vector {
104
+    public function cos(): matrix | vector {
105 105
         return $this->map('cos');
106 106
     }
107 107
 
108
-    public function acos(): matrix|vector {
108
+    public function acos(): matrix | vector {
109 109
         return $this->map('acos');
110 110
     }
111 111
 
112
-    public function tan(): matrix|vector {
112
+    public function tan(): matrix | vector {
113 113
         return $this->map('tan');
114 114
     }
115 115
 
116
-    public function atan(): matrix|vector {
116
+    public function atan(): matrix | vector {
117 117
         return $this->map('atan');
118 118
     }
119 119
 
120
-    public function radToDeg(): matrix|vector {
120
+    public function radToDeg(): matrix | vector {
121 121
         return $this->map('rad2deg');
122 122
     }
123 123
 
124
-    public function degToRad(): matrix|vector {
124
+    public function degToRad(): matrix | vector {
125 125
         return $this->map('deg2rad');
126 126
     }
127 127
 
128
-    public function floor(): matrix|vector {
128
+    public function floor(): matrix | vector {
129 129
         return $this->map('floor');
130 130
     }
131 131
 
132
-    public function ceil(): matrix|vector {
132
+    public function ceil(): matrix | vector {
133 133
         return $this->map('ceil');
134 134
     }
135 135
     
136 136
     public function free():void {
137
-        if($this instanceof matrix) {
137
+        if ($this instanceof matrix) {
138 138
             unset($this->row);
139 139
             unset($this->col);
140 140
             unset($this->ndim);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      * make a copy of matrix|vector;
154 154
      * @return matrix|vector
155 155
      */
156
-    public function copy(): matrix|vector {
156
+    public function copy(): matrix | vector {
157 157
         return clone $this;
158 158
     }
159 159
     
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @param float $max
166 166
      * @return matrix
167 167
      */
168
-    public function clip(float $min, float $max): matrix|vector {
168
+    public function clip(float $min, float $max): matrix | vector {
169 169
         if ($this instanceof matrix) {
170 170
             $ar = self::factory($this->row, $this->col);
171 171
         } else {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      * @param float $min
191 191
      * @return matrix
192 192
      */
193
-    public function clipLower(float $min): matrix|vector {
193
+    public function clipLower(float $min): matrix | vector {
194 194
         if ($this instanceof matrix) {
195 195
             $ar = self::factory($this->row, $this->col);
196 196
         } else {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      * @param float $max
213 213
      * @return matrix
214 214
      */
215
-    public function clipUpper(float $max): matrix|vector {
215
+    public function clipUpper(float $max): matrix | vector {
216 216
         if ($this instanceof matrix) {
217 217
             $ar = self::factory($this->row, $this->col);
218 218
         } else {
Please login to merge, or discard this patch.
src/linAlgb/reductions/rref.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,10 @@
 block discarded – undo
26 26
         $lead = 0;
27 27
         $ar = $m->copy();
28 28
         for ($r = 0; $r < $ar->row; ++$r) {
29
-            if ($lead >= $ar->col)
30
-                break; {
29
+            if ($lead >= $ar->col) {
30
+                            break;
31
+            }
32
+            {
31 33
                 $i = $r;
32 34
                 while ($ar->data[$i * $ar->col + $lead] == 0) {
33 35
                     $i++;
Please login to merge, or discard this patch.
src/linAlgb/reductions/ref.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
 
20 20
 class ref { 
21 21
     
22
-     /**
23
-      * 
24
-      * @param \Np\matrix $m
25
-      * @return matrix|null
26
-      */
22
+        /**
23
+         * 
24
+         * @param \Np\matrix $m
25
+         * @return matrix|null
26
+         */
27 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->copy();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 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->copy();
30 30
         $lp = lapack::getrf($ar, $ipiv);
Please login to merge, or discard this patch.