Passed
Push — main ( 051221...b63ebb )
by Shubham
02:26
created
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
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.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  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
-    use ops,linAlg;
29
+    use ops, linAlg;
30 30
     /**
31 31
      * create empty 2d matrix for given data type
32 32
      * @param int $row  num of rows 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      * @param int|float|matrix|vector $m
311 311
      * @return matrix|vector
312 312
      */
313
-    public function multiply(int|float|matrix|vector $m): matrix|vector {
313
+    public function multiply(int | float | matrix | vector $m): matrix | vector {
314 314
         if ($m instanceof self) {
315 315
             return $this->multiplyMatrix($m);
316 316
         } else if ($m instanceof vector) {
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
      * @param int|float|matrix|vector $m
377 377
      * @return matrix
378 378
      */
379
-    public function sum(int|float|matrix|vector $m): matrix {
379
+    public function sum(int | float | matrix | vector $m): matrix {
380 380
         if ($m instanceof self) {
381 381
             return $this->sumMatrix($m);
382 382
         } elseif ($m instanceof vector) {
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
         }
387 387
     }
388 388
 
389
-    protected function sumScalar(int|float $s): matrix {
389
+    protected function sumScalar(int | float $s): matrix {
390 390
         $ar = self::factory($this->row, $this->col, $this->dtype);
391 391
         for ($i = 0; $i < $this->ndim; ++$i) {
392 392
             $ar->data[$i] = $this->data[$i] + $s;
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      * @param int|float|matrix|vector $d matrix|$scalar to subtract this matrix
422 422
      * @return \Np\matrix
423 423
      */
424
-    public function subtract(int|float|matrix|vector $d): matrix {
424
+    public function subtract(int | float | matrix | vector $d): matrix {
425 425
         if ($d instanceof self) {
426 426
             return $this->subtractMatrix($d);
427 427
         } elseif ($d instanceof vector) {
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
         }
432 432
     }
433 433
 
434
-    protected function subtractScalar(int|float $s): matrix {
434
+    protected function subtractScalar(int | float $s): matrix {
435 435
         $ar = self::factory($this->row, $this->col, $this->dtype);
436 436
         for ($i = 0; $i < $this->ndim; ++$i) {
437 437
             $ar->data[$i] = $this->data[$i] - $s;
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
      * @return matrix
461 461
      */
462 462
     protected function subtractVector(vector $v): matrix {
463
-        if ($this->checkDimensions($v, $this) && $this->checkDtype($this,$v)) {
463
+        if ($this->checkDimensions($v, $this) && $this->checkDtype($this, $v)) {
464 464
             $ar = self::factory($this->row, $this->col, $this->dtype);
465 465
             for ($i = 0; $i < $this->row; ++$i) {
466 466
                 for ($j = 0; $j < $this->col; ++$j) {
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
      * @param int|float|matrix $d
494 494
      * @return matrix
495 495
      */
496
-    public function divide(int|float|matrix|vector $d): matrix {
496
+    public function divide(int | float | matrix | vector $d): matrix {
497 497
         if ($d instanceof self) {
498 498
             return $this->divideMatrix($d);
499 499
         } elseif ($d instanceof vector) {
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
         }
526 526
     }
527 527
 
528
-    protected function divideScalar(int|float $s): matrix {
528
+    protected function divideScalar(int | float $s): matrix {
529 529
         $ar = self::factory($this->row, $this->col, $this->dtype);
530 530
         for ($i = 0; $i < $this->ndim; ++$i) {
531 531
             $ar->data[$i] = $this->data[$i] / $s;
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
      * @param int|float|matrix $m
541 541
      * @return matrix
542 542
      */
543
-    public function pow(int|float|matrix|vector $d): matrix {
543
+    public function pow(int | float | matrix | vector $d): matrix {
544 544
         if ($d instanceof self) {
545 545
             return $this->powMatrix($d);
546 546
         } else if ($d instanceof vector) {
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
         }
573 573
     }
574 574
 
575
-    protected function powScalar(int|float $s): matrix {
575
+    protected function powScalar(int | float $s): matrix {
576 576
         $ar = $this->copy();
577 577
         for ($i = 0; $i < $this->ndim; ++$i) {
578 578
             $ar->data[$i] **= $s;
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
      * @param int|float|matrix|vector $d
586 586
      * @return matrix
587 587
      */
588
-    public function mod(int|float|matrix|vector $d): matrix {
588
+    public function mod(int | float | matrix | vector $d): matrix {
589 589
         if ($d instanceof self) {
590 590
             $this->modMatrix($d);
591 591
         } else if ($d instanceof vector) {
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
         }
618 618
     }
619 619
 
620
-    protected function modScalar(int|float $s): matrix {
620
+    protected function modScalar(int | float $s): matrix {
621 621
         $ar = $this->copy();
622 622
         for ($i = 0; $i < $this->ndim; ++$i) {
623 623
             $ar->data[$i] %= $s;
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
      * @param int|float $scalar
730 730
      * @return matrix
731 731
      */
732
-    public function scale(int|float $scalar): matrix {
732
+    public function scale(int | float $scalar): matrix {
733 733
         if ($scalar == 0) {
734 734
             return self::zeros($this->row, $this->col, $this->dtype);
735 735
         }
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
      * @param int $row
748 748
      * @param int|float $c
749 749
      */
750
-    public function scaleRow(int $row, int|float $c) {
750
+    public function scaleRow(int $row, int | float $c) {
751 751
         for ($i = 0; $i < $this->col; ++$i) {
752 752
             $this->data[$row * $this->col + $i] *= $c;
753 753
         }
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
      * @param int $col
759 759
      * @param int|float $c
760 760
      */
761
-    public function scaleCol(int $col, int|float $c) {
761
+    public function scaleCol(int $col, int | float $c) {
762 762
         for ($i = 0; $i < $this->row; ++$i) {
763 763
             $this->data[$i * $this->col + $col] *= $c;
764 764
         }
@@ -769,14 +769,14 @@  discard block
 block discarded – undo
769 769
      * @param int|float $c
770 770
      * @param bool $lDig
771 771
      */
772
-    public function scaleDigonalCol(int|float $c, bool $lDig = true) {
773
-        if($lDig){
774
-            for ($i = 0; $i < $this->row ; ++$i) {
772
+    public function scaleDigonalCol(int | float $c, bool $lDig = true) {
773
+        if ($lDig) {
774
+            for ($i = 0; $i < $this->row; ++$i) {
775 775
                 $this->data[$i * $this->col + $i] *= $c;
776 776
             }
777 777
         }
778
-        else{
779
-            for ($i = $this->row; $i > 0 ; --$i) {
778
+        else {
779
+            for ($i = $this->row; $i > 0; --$i) {
780 780
                 $this->data[$i * $this->col - $i] *= $c;
781 781
             }
782 782
         }
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
      * @return matrix
824 824
      */
825 825
     public function joinRight(matrix $m): matrix {
826
-        if ($this->row != $m->row && !$this->checkDtype($this,$m)) {
826
+        if ($this->row != $m->row && !$this->checkDtype($this, $m)) {
827 827
             self::_err('Error::Invalid size! or DataType!');
828 828
         }
829 829
         $col = $this->col + $m->col;
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
      *
890 890
      * @return matrix|null
891 891
      */
892
-    public function ref(): matrix|null {
892
+    public function ref(): matrix | null {
893 893
         return ref::factory($this);
894 894
     }
895 895
 
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
      *
899 899
      * @return matrix|null
900 900
      */
901
-    public function cholesky(): matrix|null {
901
+    public function cholesky(): matrix | null {
902 902
         return cholesky::factory($this);
903 903
     }
904 904
 
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
      * @param bool $dignoal
974 974
      * @return void
975 975
      */
976
-    public function setData(int|float|array $data): void {
976
+    public function setData(int | float | array $data): void {
977 977
 
978 978
         if (is_array($data) && is_array($data[0])) {
979 979
             $f = $this->flattenArray($data);
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
      * @return object
1005 1005
      */
1006 1006
     public function getShape(): object {
1007
-        return (object) ['m' => $this->row, 'n' => $this->col];
1007
+        return (object)['m' => $this->row, 'n' => $this->col];
1008 1008
     }
1009 1009
 
1010 1010
     /**
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
      * @param vector|null $mean
1187 1187
      * @return vector
1188 1188
      */
1189
-    public function variance(vector|null $mean = null): vector {
1189
+    public function variance(vector | null $mean = null): vector {
1190 1190
         if (isset($mean)) {
1191 1191
             if (!$mean instanceof vector) {
1192 1192
                 self::_invalidArgument('mean must be a vector!');
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
      * @param vector|null $mean
1229 1229
      * @return matrix
1230 1230
      */
1231
-    public function covariance(vector|null $mean = null): matrix {
1231
+    public function covariance(vector | null $mean = null): matrix {
1232 1232
         if (isset($mean)) {
1233 1233
             if ($mean->col !== $this->row) {
1234 1234
                 self::_err('Err:: given mean vector dimensionality mismatched!');
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
      * @param int|float|matrix|vector $d
1257 1257
      * @return matrix
1258 1258
      */
1259
-    public function equal(int|float|matrix|vector $d): matrix {
1259
+    public function equal(int | float | matrix | vector $d): matrix {
1260 1260
         if ($d instanceof self) {
1261 1261
             return $this->equalMatrix($d);
1262 1262
         } elseif ($d instanceof vector) {
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
         }
1289 1289
     }
1290 1290
 
1291
-    protected function equalScalar(int|float $s): matrix {
1291
+    protected function equalScalar(int | float $s): matrix {
1292 1292
         $ar = self::factory($this->row, $this->col, $this->dtype);
1293 1293
         for ($i = 0; $i < $this->ndim; ++$i) {
1294 1294
             $ar->data[$i] = $this->data[$i] == $s ? 1 : 0;
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
      * @param int|float|matrix|vector $d
1302 1302
      * @return matrix
1303 1303
      */
1304
-    public function greater(int|float|matrix|vector $d): matrix {
1304
+    public function greater(int | float | matrix | vector $d): matrix {
1305 1305
         if ($d instanceof self) {
1306 1306
             return $this->greaterMatrix($d);
1307 1307
         } elseif ($d instanceof vector) {
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
     }
1313 1313
 
1314 1314
     protected function greaterMatrix(matrix $m): matrix {
1315
-        if ($this->checkShape($this, $m) && $this->checkDtype($this,$m)) {
1315
+        if ($this->checkShape($this, $m) && $this->checkDtype($this, $m)) {
1316 1316
             $ar = self::factory($this->row, $this->col, $this->dtype);
1317 1317
             for ($i = 0; $i < $this->ndim; ++$i) {
1318 1318
                 $ar->data[$i] = $this->data[$i] > $m->data[$i] ? 1 : 0;
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
     }
1323 1323
 
1324 1324
     protected function greaterVector(vector $v): matrix {
1325
-        if ($this->checkDimensions($v, $this) && $this->checkDtype($this,$v)) {
1325
+        if ($this->checkDimensions($v, $this) && $this->checkDtype($this, $v)) {
1326 1326
             $ar = self::factory($this->row, $this->col, $this->dtype);
1327 1327
             for ($i = 0; $i < $this->row; ++$i) {
1328 1328
                 for ($j = 0; $j < $this->col; ++$j) {
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
         }
1334 1334
     }
1335 1335
 
1336
-    protected function greaterScalar(int|float $s): matrix {
1336
+    protected function greaterScalar(int | float $s): matrix {
1337 1337
         $ar = self::factory($this->row, $this->col, $this->dtype);
1338 1338
         for ($i = 0; $i < $this->ndim; ++$i) {
1339 1339
             $ar->data[$i] = $this->data[$i] > $s ? 1 : 0;
@@ -1346,10 +1346,10 @@  discard block
 block discarded – undo
1346 1346
      * @param int|float|matrix $m
1347 1347
      * @return matrix
1348 1348
      */
1349
-    public function less(int|float|matrix $m): matrix {
1349
+    public function less(int | float | matrix $m): matrix {
1350 1350
         $ar = self::factory($this->row, $this->col, $this->dtype);
1351 1351
         if ($m instanceof self) {
1352
-            if ($this->checkShape($this,$m)) {
1352
+            if ($this->checkShape($this, $m)) {
1353 1353
                 for ($i = 0; $i < $this->ndim; ++$i) {
1354 1354
                     $ar->data[$i] = $this->data[$i] < $m->data[$i] ? 1 : 0;
1355 1355
                 }
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
     }
1398 1398
 
1399 1399
     public function __toString() {
1400
-        return (string) $this->printMatrix();
1400
+        return (string)$this->printMatrix();
1401 1401
     }
1402 1402
 
1403 1403
     private function flattenArray(array $ar) {
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
 
@@ -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->copy();
33 33
             $lp = lapack::potrf($ar);
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
@@ -24,8 +24,8 @@
 block discarded – undo
24 24
  * @copyright (c) 2020-2021, Shubham Chaudhary
25 25
  * 
26 26
  */
27
- class vector extends nd {
28
-     use ops, linAlg;
27
+    class vector extends nd {
28
+        use ops, linAlg;
29 29
 
30 30
     /**
31 31
      * Factory method to build a new vector.
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      * @param int $dtype
135 135
      * @return vector
136 136
      */
137
-    public static function full(int $col, int|float $val, int $dtype = self::FLOAT): vector {
137
+    public static function full(int $col, int | float $val, int $dtype = self::FLOAT): vector {
138 138
         $ar = self::factory($col, $dtype);
139 139
         for ($i = 0; $i < $col; ++$i) {
140 140
             $ar->data[$i] = $val;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @param int $dtype 
152 152
      * @return vector
153 153
      */
154
-    public static function range(int|float $start, int|float $end, int|float $interval = 1, int $dtype = self::FLOAT): vector {
154
+    public static function range(int | float $start, int | float $end, int | float $interval = 1, int $dtype = self::FLOAT): vector {
155 155
         return self::ar(range($start, $end, $interval), $dtype);
156 156
     }
157 157
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      * @param int|float|matrix|vector $d
286 286
      * @return matrix|vector
287 287
      */
288
-    public function divide(int|float|matrix|vector $d): matrix|vector {
288
+    public function divide(int | float | matrix | vector $d): matrix | vector {
289 289
         if ($d instanceof matrix) {
290 290
             return $this->divideMatrix($d);
291 291
         } elseif ($d instanceof self) {
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
      * @param int|float $s
333 333
      * @return vector
334 334
      */
335
-    protected function divideScalar(int|float $s): vector {
335
+    protected function divideScalar(int | float $s): vector {
336 336
         $vr = self::factory($this->col, $this->dtype);
337 337
         for ($i = 0; $i < $this->col; ++$i) {
338 338
             $vr->data[$i] = $this->data[$i] / $s;
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      * @param int|float|matrix|vector $d
346 346
      * @return matrix|vector
347 347
      */
348
-    public function multiply(int|float|matrix|vector $d): matrix|vector {
348
+    public function multiply(int | float | matrix | vector $d): matrix | vector {
349 349
         if ($d instanceof matrix) {
350 350
             return $this->multiplyMatrix($d);
351 351
         } elseif ($d instanceof self) {
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      * @param int|float $s
393 393
      * @return vector
394 394
      */
395
-    protected function multiplyScalar(int|float $s): vector {
395
+    protected function multiplyScalar(int | float $s): vector {
396 396
         $vr = $this->copy();
397 397
         blas::scale($s, $vr);
398 398
         return $vr;
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
      * @param int|float|matrix|vector $d
404 404
      * @return matrix|vector
405 405
      */
406
-    public function add(int|float|matrix|vector $d): matrix|vector {
406
+    public function add(int | float | matrix | vector $d): matrix | vector {
407 407
         if ($d instanceof matrix) {
408 408
             return $this->addMatrix($d);
409 409
         } elseif ($d instanceof self) {
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      * @param int|float $s
451 451
      * @return vector
452 452
      */
453
-    protected function addScalar(int|float $s): vector {
453
+    protected function addScalar(int | float $s): vector {
454 454
         $vr = $this->copy();
455 455
         for ($i = 0; $i < $this->col; ++$i) {
456 456
             $vr->data[$i] += $s;
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
      * @param int|float|\Np\matrix|\Np\vector $d
464 464
      * @return matrix|vector
465 465
      */
466
-    public function pow(int|float|\Np\matrix|\Np\vector $d): matrix|vector {
466
+    public function pow(int | float | \Np\matrix | \Np\vector $d): matrix | vector {
467 467
         if ($d instanceof matrix) {
468 468
             return $this->powMatrix($d);
469 469
         } elseif ($d instanceof vector) {
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
      * @param int|float $s
511 511
      * @return vector
512 512
      */
513
-    protected function powScalar(int|float $s): vector {
513
+    protected function powScalar(int | float $s): vector {
514 514
         $v = $this->copy();
515 515
         for ($i = 0; $i < $this->col; ++$i) {
516 516
             $v->data[$i] = $v->data[$i] ** $s;
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
      * @param int|float|\Np\matrix|\Np\vector $d
524 524
      * @return matrix|vector
525 525
      */
526
-    public function mod(int|float|\Np\matrix|\Np\vector $d): matrix|vector {
526
+    public function mod(int | float | \Np\matrix | \Np\vector $d): matrix | vector {
527 527
         if ($d instanceof matrix) {
528 528
             return $this->powMatrix($d);
529 529
         } elseif ($d instanceof vector) {
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
      * 
570 570
      * @param int|float $s
571 571
      */
572
-    protected function modScalar(int|float $s) {
572
+    protected function modScalar(int | float $s) {
573 573
         $v = $this->copy();
574 574
         for ($i = 0; $i < $this->col; ++$i) {
575 575
             $v->data[$i] = $v->data[$i] % $s;
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
      * @param int|float|matrix|vector $d
582 582
      * @return matrix|vector
583 583
      */
584
-    public function subtract(int|float|matrix|vector $d): matrix|vector {
584
+    public function subtract(int | float | matrix | vector $d): matrix | vector {
585 585
         if ($d instanceof matrix) {
586 586
             return $this->subtractMatrix($d);
587 587
         } elseif ($d instanceof self) {
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
      * @param \Np\vector $scalar
629 629
      * @return \Np\vector
630 630
      */
631
-    protected function substractScalar(int|float $scalar): vector {
631
+    protected function substractScalar(int | float $scalar): vector {
632 632
         $vr = self::factory($this->col, $this->dtype);
633 633
         for ($i = 0; $i < $this->col; ++$i) {
634 634
             $vr->data[$i] = $this->data[$i] - $scalar;
@@ -701,15 +701,15 @@  discard block
 block discarded – undo
701 701
      * 
702 702
      * @return int|float
703 703
      */
704
-    public function mean():int|float {
705
-        return $this->sum()/ $this->col;
704
+    public function mean():int | float {
705
+        return $this->sum() / $this->col;
706 706
     }
707 707
     
708 708
     /**
709 709
      * 
710 710
      * @return int|float
711 711
      */
712
-    public function median():int|float {
712
+    public function median():int | float {
713 713
         $mid = intdiv($this->col, 2);
714 714
 
715 715
         $a = $this->copy()->sort();
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
      * set data to vector
757 757
      * @param int|float|array $data
758 758
      */
759
-    public function setData(int|float|array $data) {
759
+    public function setData(int | float | array $data) {
760 760
         if (is_array($data) && !is_array($data[0])) {
761 761
             for ($i = 0; $i < $this->col; ++$i) {
762 762
                 $this->data[$i] = $data[$i];
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
     }
797 797
 
798 798
     public function __toString() {
799
-        return (string) $this->printVector();
799
+        return (string)$this->printVector();
800 800
     }
801 801
 
802 802
     protected function __construct(public int $col, int $dtype = self::FLOAT) {
Please login to merge, or discard this patch.
src/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/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.
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) && $this->checkDtype($this, $d)) {
24 24
             $r = self::factory($this->row, $this->col, $this->dtype);
25 25
         } elseif ($this instanceof vector && $d instanceof vector && $this->checkShape($this, $d) && $this->checkDtype($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) && $this->checkDtype($this, $d)) {
41 41
             $r = self::factory($this->row, $this->col, $this->dtype);
42 42
         } elseif ($this instanceof vector && $d instanceof vector && $this->checkShape($this, $d) && $this->checkDtype($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, $this->dtype);
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);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * make a copy of matrix|vector;
152 152
      * @return matrix|vector
153 153
      */
154
-    public function copy(): matrix|vector {
154
+    public function copy(): matrix | vector {
155 155
         return clone $this;
156 156
     }
157 157
     
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * @param float $max
164 164
      * @return matrix
165 165
      */
166
-    public function clip(float $min, float $max): matrix|vector {
166
+    public function clip(float $min, float $max): matrix | vector {
167 167
         if ($this instanceof matrix) {
168 168
             $ar = self::factory($this->row, $this->col, $this->dtype);
169 169
         } else {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      * @param float $min
189 189
      * @return matrix
190 190
      */
191
-    public function clipLower(float $min): matrix|vector {
191
+    public function clipLower(float $min): matrix | vector {
192 192
         if ($this instanceof matrix) {
193 193
             $ar = self::factory($this->row, $this->col, $this->dtype);
194 194
         } else {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      * @param float $max
211 211
      * @return matrix
212 212
      */
213
-    public function clipUpper(float $max): matrix|vector {
213
+    public function clipUpper(float $max): matrix | vector {
214 214
         if ($this instanceof matrix) {
215 215
             $ar = self::factory($this->row, $this->col, $this->dtype);
216 216
         } else {
Please login to merge, or discard this patch.
src/core/lapack.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -167,10 +167,10 @@
 block discarded – undo
167 167
         self::init();
168 168
         if($m->dtype == \Np\matrix::FLOAT){
169 169
             return self::$ffi_lapack->LAPACKE_sgels( $matLayout, $trans, $m->row, $m->col, $b->col, $m->data,
170
-                          $m->col, $b->data, $b->col );
170
+                            $m->col, $b->data, $b->col );
171 171
         }
172 172
         return self::$ffi_lapack->LAPACKE_dgels( $matLayout, $trans, $m->row, $m->col, $b->col, $m->data,
173
-                          $m->col, $b->data, $b->col );
173
+                            $m->col, $b->data, $b->col );
174 174
     }
175 175
 
176 176
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -163,14 +163,14 @@
 block discarded – undo
163 163
      * @param string $trans
164 164
      * @return type
165 165
      */
166
-    public static function gels(\Np\matrix $m, \Np\matrix|\Np\vector $b, int $matLayout = self::ROW_MAJOR,string $trans = 'N') {
166
+    public static function gels(\Np\matrix $m, \Np\matrix | \Np\vector $b, int $matLayout = self::ROW_MAJOR, string $trans = 'N') {
167 167
         self::init();
168
-        if($m->dtype == \Np\matrix::FLOAT){
169
-            return self::$ffi_lapack->LAPACKE_sgels( $matLayout, $trans, $m->row, $m->col, $b->col, $m->data,
170
-                          $m->col, $b->data, $b->col );
168
+        if ($m->dtype == \Np\matrix::FLOAT) {
169
+            return self::$ffi_lapack->LAPACKE_sgels($matLayout, $trans, $m->row, $m->col, $b->col, $m->data,
170
+                          $m->col, $b->data, $b->col);
171 171
         }
172
-        return self::$ffi_lapack->LAPACKE_dgels( $matLayout, $trans, $m->row, $m->col, $b->col, $m->data,
173
-                          $m->col, $b->data, $b->col );
172
+        return self::$ffi_lapack->LAPACKE_dgels($matLayout, $trans, $m->row, $m->col, $b->col, $m->data,
173
+                          $m->col, $b->data, $b->col);
174 174
     }
175 175
 
176 176
 }
Please login to merge, or discard this patch.
src/linAlg.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * @param \Np\matrix|\Np\vector $d
25 25
      * @return matrix|vector
26 26
      */
27
-    public function dot(matrix|vector $d): matrix|vector {
27
+    public function dot(matrix | vector $d): matrix | vector {
28 28
         if ($this instanceof matrix) {
29 29
             if ($d instanceof self) {
30 30
                 return $this->dotMatrix($d);
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @return \Np\matrix
45 45
      */
46 46
     protected function dotMatrix(matrix $matrix): matrix {
47
-        if ($this->checkDtype($this, $matrix) && $this->checkDimensions($this,$matrix)) {
47
+        if ($this->checkDtype($this, $matrix) && $this->checkDimensions($this, $matrix)) {
48 48
             $ar = self::factory($this->row, $matrix->col, $this->dtype);
49 49
             blas::gemm($this, $matrix, $ar);
50 50
             return $ar;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * Compute the multiplicative inverse of the matrix.
70 70
      * @return matrix|null
71 71
      */
72
-    public function inverse(): matrix|null {
72
+    public function inverse(): matrix | null {
73 73
         if (!$this->isSquare()) {
74 74
             self::_err('Error::invalid Size of matrix!');
75 75
         }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * Compute the (Moore-Penrose) pseudo inverse of the general matrix.
94 94
      * @return matrix|null
95 95
      */
96
-    public function pseudoInverse(): matrix|null {
96
+    public function pseudoInverse(): matrix | null {
97 97
         $k = min($this->row, $this->col);
98 98
         $s = vector::factory($k, $this->dtype);
99 99
         $u = self::factory($this->row, $this->row, $this->dtype);
Please login to merge, or discard this patch.