Passed
Push — master ( 5e8c3b...31fead )
by Ruben
02:18
created
src/Matrix.php 1 patch
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,10 +24,14 @@  discard block
 block discarded – undo
24 24
     public static function submatrix($matrix, $columns)
25 25
     {
26 26
         $n = count($matrix);
27
-        if ($n == 0) return [];
27
+        if ($n == 0) {
28
+            return [];
29
+        }
28 30
        
29 31
         $m = count($matrix[0]);
30
-        if ($m == 0) return $matrix;
32
+        if ($m == 0) {
33
+            return $matrix;
34
+        }
31 35
        
32 36
         $result = [];       
33 37
         for ($i=0; $i<$n; $i++) {
@@ -47,7 +51,9 @@  discard block
 block discarded – undo
47 51
     public static function toSquareMatrix($matrix, $ncol, mcol, $val, $sparse = False)
48 52
     {
49 53
         $n = count($matrix);
50
-        if ($n == 0) return [];
54
+        if ($n == 0) {
55
+            return [];
56
+        }
51 57
         
52 58
         $labels = {};
53 59
         $id = 0;
@@ -58,7 +64,9 @@  discard block
 block discarded – undo
58 64
             $val = $matrix[$i][$val];
59 65
             $data[] = [$nid, $mid, $val];
60 66
         }
61
-        if ($sparse) return ["data" => $data, "labels" => $labels];
67
+        if ($sparse) {
68
+            return ["data" => $data, "labels" => $labels];
69
+        }
62 70
         
63 71
         $nlab = count($labels);
64 72
         $result = [];
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
         $n2 = count($matrix2);        
84 92
         $m2 = count($matrix2[0]);
85 93
         
86
-        if ($n2 !== $m1) throw new Exception("Incompatible matrices: matrix1.columns != matrix2.rows");
94
+        if ($n2 !== $m1) {
95
+            throw new Exception("Incompatible matrices: matrix1.columns != matrix2.rows");
96
+        }
87 97
 
88 98
         $result = [];
89 99
         for ($i=0; $i<$n1; $i++) {           
@@ -104,9 +114,13 @@  discard block
 block discarded – undo
104 114
      */
105 115
     public static function power($matrix, $n)
106 116
     {
107
-        if($n <= 1) return $matrix;        
117
+        if($n <= 1) {
118
+            return $matrix;
119
+        }
108 120
         $resp = multiply($matrix, $matrix);
109
-        if($n == 2) return $resp;
121
+        if($n == 2) {
122
+            return $resp;
123
+        }
110 124
         for($i=2; $i<$n; $i++) {
111 125
             $resp = multiply($resp, $matrix);
112 126
         }
Please login to merge, or discard this patch.