@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | foreach ($this->rows[0]->toArray() as $key => $value) { |
151 | 151 | $childMatrixData = []; |
152 | 152 | |
153 | - for ($i = 1;$i < $this->numRows;$i++) { |
|
153 | + for ($i = 1; $i < $this->numRows; $i++) { |
|
154 | 154 | $childMatrixData[$i-1] = $this->rows[$i]->filterByKeys([$key]); |
155 | 155 | } |
156 | 156 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | */ |
317 | 317 | public function rotate(bool $clockwise = true): MatrixInterface |
318 | 318 | { |
319 | - $tempData = $clockwise ? $this->rows : $this->columns; |
|
319 | + $tempData = $clockwise ? $this->rows : $this->columns; |
|
320 | 320 | $mode = $clockwise ? self::MODE_COLUMNS_INPUT : self::MODE_ROWS_INPUT; |
321 | 321 | |
322 | 322 | $tempData = array_reverse($tempData); |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | |
469 | 469 | foreach ($this->rows as $rowKey => $row) { |
470 | 470 | $resultArray[$rowKey] = new NumberCollection(); |
471 | - for ($i = 0;$i < $value->getColumnCount();$i++) { |
|
471 | + for ($i = 0; $i < $value->getColumnCount(); $i++) { |
|
472 | 472 | $cellVal = Numbers::makeZero(); |
473 | 473 | /** @var NumberInterface $num */ |
474 | 474 | foreach ($row->toArray() as $index => $num) { |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | $newMatrixData = []; |
512 | 512 | |
513 | 513 | // TODO: Implement minors & cofactors method https://www.mathsisfun.com/algebra/matrix-inverse-minors-cofactors-adjugate.html |
514 | - for ($i = 0;$i < $columnCount;$i++) { |
|
515 | - for ($r = 0;$r < $columnCount;$r++) { |
|
514 | + for ($i = 0; $i < $columnCount; $i++) { |
|
515 | + for ($r = 0; $r < $columnCount; $r++) { |
|
516 | 516 | |
517 | 517 | } |
518 | 518 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | |
539 | 539 | $newRows = []; |
540 | 540 | |
541 | - for ($i = 0;$i < $this->getRowCount();$i++) { |
|
541 | + for ($i = 0; $i < $this->getRowCount(); $i++) { |
|
542 | 542 | if ($i === $excludeRow) { |
543 | 543 | continue; |
544 | 544 | } |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | { |
18 | 18 | $matrixData = []; |
19 | 19 | |
20 | - for ($i = 0;$i < $rows;$i++) { |
|
20 | + for ($i = 0; $i < $rows; $i++) { |
|
21 | 21 | $matrixData[$i] = new NumberCollection(); |
22 | - for ($n = 0;$n < $columns;$n++) { |
|
22 | + for ($n = 0; $n < $columns; $n++) { |
|
23 | 23 | $matrixData[$i]->push(Numbers::makeZero()); |
24 | 24 | } |
25 | 25 | } |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | { |
32 | 32 | $matrixData = []; |
33 | 33 | |
34 | - for ($i = 0;$i < $rows;$i++) { |
|
34 | + for ($i = 0; $i < $rows; $i++) { |
|
35 | 35 | $matrixData[$i] = new NumberCollection(); |
36 | - for ($n = 0;$n < $columns;$n++) { |
|
36 | + for ($n = 0; $n < $columns; $n++) { |
|
37 | 37 | $matrixData[$i]->push(Numbers::makeOne()); |
38 | 38 | } |
39 | 39 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | { |
46 | 46 | $matrixData = []; |
47 | 47 | |
48 | - for ($i = 0;$i < $size;$i++) { |
|
48 | + for ($i = 0; $i < $size; $i++) { |
|
49 | 49 | $matrixData[$i] = new NumberCollection(); |
50 | - for ($n = 0;$n < $size;$n++) { |
|
50 | + for ($n = 0; $n < $size; $n++) { |
|
51 | 51 | if ($n === $i) { |
52 | 52 | $matrixData[$i]->push(Numbers::makeOne()); |
53 | 53 | } else { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | $p = 0; |
68 | 68 | |
69 | - for ($i = 0;$i < $size;$i++) { |
|
69 | + for ($i = 0; $i < $size; $i++) { |
|
70 | 70 | $matrixData[$i] = SequenceProvider::nthPowerNegativeOne($p, true, $size); |
71 | 71 | $p = ($p === 0 ? 1 : 0); |
72 | 72 | } |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public static function createFromFoil(array $group1, array $group2): PolynomialFunction |
174 | 174 | { |
175 | - $group1exp = count($group1) - 1; |
|
176 | - $group2exp = count($group2) - 1; |
|
175 | + $group1exp = count($group1)-1; |
|
176 | + $group2exp = count($group2)-1; |
|
177 | 177 | |
178 | 178 | /** @var ImmutableDecimal[] $finalCoefs */ |
179 | 179 | $finalCoefs = []; |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | * @var ImmutableDecimal $value1 |
199 | 199 | */ |
200 | 200 | foreach ($largerGroup as $key1 => $value1) { |
201 | - $largerKey = $largerExp - $key1; |
|
201 | + $largerKey = $largerExp-$key1; |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * @var int $key2 |
205 | 205 | * @var ImmutableDecimal $value2 |
206 | 206 | */ |
207 | 207 | foreach ($smallerGroup as $key2 => $value2) { |
208 | - $smallerKey = $smallerExp - $key2; |
|
208 | + $smallerKey = $smallerExp-$key2; |
|
209 | 209 | $newVal = $value1->multiply($value2); |
210 | - $newExp = $largerKey + $smallerKey; |
|
210 | + $newExp = $largerKey+$smallerKey; |
|
211 | 211 | |
212 | 212 | if (isset($finalCoefs[$newExp])) { |
213 | 213 | $finalCoefs[$newExp] = $finalCoefs[$newExp]->add($newVal); |
@@ -70,7 +70,7 @@ |
||
70 | 70 | if (!$num->isWhole()) { |
71 | 71 | $precision += 5; |
72 | 72 | $exponent = $num->multiply($this->ln($precision)); |
73 | - return $exponent->exp($precision)->truncateToPrecision($precision - 5)->getValue(); |
|
73 | + return $exponent->exp($precision)->truncateToPrecision($precision-5)->getValue(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return ArithmeticProvider::pow($this->asReal(), $num->asReal(), $precision); |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $left = self::translateToNative($this); |
37 | 37 | $right = self::translateToNative($num); |
38 | 38 | |
39 | - $value = $left + $right; |
|
40 | - $value = (string)$value; |
|
39 | + $value = $left+$right; |
|
40 | + $value = (string) $value; |
|
41 | 41 | |
42 | 42 | return $value; |
43 | 43 | } |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | $left = self::translateToNative($this); |
48 | 48 | $right = self::translateToNative($num); |
49 | 49 | |
50 | - $value = $left - $right; |
|
51 | - $value = (string)$value; |
|
50 | + $value = $left-$right; |
|
51 | + $value = (string) $value; |
|
52 | 52 | |
53 | 53 | return $value; |
54 | 54 | } |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | $left = self::translateToNative($this); |
59 | 59 | $right = self::translateToNative($num); |
60 | 60 | |
61 | - $value = $left * $right; |
|
62 | - $value = (string)$value; |
|
61 | + $value = $left*$right; |
|
62 | + $value = (string) $value; |
|
63 | 63 | |
64 | 64 | return $value; |
65 | 65 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | $left = self::translateToNative($this); |
70 | 70 | $right = self::translateToNative($num); |
71 | 71 | |
72 | - $value = $left / $right; |
|
73 | - $value = (string)$value; |
|
72 | + $value = $left/$right; |
|
73 | + $value = (string) $value; |
|
74 | 74 | |
75 | 75 | return $value; |
76 | 76 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $right = self::translateToNative($num); |
82 | 82 | |
83 | 83 | $value = pow($left, $right); |
84 | - $value = (string)$value; |
|
84 | + $value = (string) $value; |
|
85 | 85 | |
86 | 86 | return $value; |
87 | 87 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | protected function sqrtNative() |
90 | 90 | { |
91 | 91 | $value = sqrt($this->asFloat()); |
92 | - $value = (string)$value; |
|
92 | + $value = (string) $value; |
|
93 | 93 | |
94 | 94 | return $value; |
95 | 95 | } |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | |
29 | 29 | $answer = SeriesProvider::maclaurinSeries( |
30 | 30 | $modulo, |
31 | - function ($n) { |
|
31 | + function($n) { |
|
32 | 32 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1, 100); |
33 | 33 | |
34 | 34 | return $negOne->pow($n); |
35 | 35 | }, |
36 | - function ($n) { |
|
36 | + function($n) { |
|
37 | 37 | return SequenceProvider::nthOddNumber($n); |
38 | 38 | }, |
39 | - function ($n) { |
|
39 | + function($n) { |
|
40 | 40 | return SequenceProvider::nthOddNumber($n)->factorial(); |
41 | 41 | }, |
42 | 42 | 0, |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | |
74 | 74 | $answer = SeriesProvider::maclaurinSeries( |
75 | 75 | $modulo, |
76 | - function ($n) { |
|
76 | + function($n) { |
|
77 | 77 | return SequenceProvider::nthPowerNegativeOne($n); |
78 | 78 | }, |
79 | - function ($n) { |
|
79 | + function($n) { |
|
80 | 80 | return SequenceProvider::nthEvenNumber($n); |
81 | 81 | }, |
82 | - function ($n) { |
|
82 | + function($n) { |
|
83 | 83 | return SequenceProvider::nthEvenNumber($n)->factorial(); |
84 | 84 | }, |
85 | 85 | 0, |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | } else { |
159 | 159 | $answer = SeriesProvider::maclaurinSeries( |
160 | 160 | $modulo, |
161 | - function ($n) { |
|
161 | + function($n) { |
|
162 | 162 | $nthOddNumber = SequenceProvider::nthOddNumber($n); |
163 | 163 | |
164 | 164 | return SequenceProvider::nthEulerZigzag($nthOddNumber->asInt()); |
165 | 165 | }, |
166 | - function ($n) { |
|
166 | + function($n) { |
|
167 | 167 | |
168 | 168 | return SequenceProvider::nthOddNumber($n); |
169 | 169 | }, |
170 | - function ($n) { |
|
170 | + function($n) { |
|
171 | 171 | return SequenceProvider::nthOddNumber($n)->factorial(); |
172 | 172 | }, |
173 | 173 | 0, |
174 | - $precision + 1 |
|
174 | + $precision+1 |
|
175 | 175 | ); |
176 | 176 | } |
177 | 177 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | if ($mod2Pi->isEqual(0)) { |
206 | 206 | return $this->setValue(static::INFINITY); |
207 | - } elseif($modPi->isEqual(0)) { |
|
207 | + } elseif ($modPi->isEqual(0)) { |
|
208 | 208 | return $this->setValue(static::NEG_INFINITY); |
209 | 209 | } |
210 | 210 |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $rounded = $whole.'.'; |
56 | 56 | |
57 | - for ($i = 0;$i < $decimals;$i++) { |
|
57 | + for ($i = 0; $i < $decimals; $i++) { |
|
58 | 58 | $rounded .= $fractionalArr[$i]; |
59 | 59 | } |
60 | 60 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $total = strlen($fractional); |
143 | 143 | $fractional = ltrim($fractional, '0'); |
144 | 144 | |
145 | - return ($total - strlen($fractional)); |
|
145 | + return ($total-strlen($fractional)); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | public function isFloat(): bool |
225 | 225 | { |
226 | 226 | |
227 | - return (bool)ArithmeticProvider::compare($this->getDecimalPart(), '0'); |
|
227 | + return (bool) ArithmeticProvider::compare($this->getDecimalPart(), '0'); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | throw new IncompatibleObjectState('Cannot export number as integer because it is out of range'); |
236 | 236 | } |
237 | 237 | |
238 | - return (float)$this->asReal(); |
|
238 | + return (float) $this->asReal(); |
|
239 | 239 | |
240 | 240 | } |
241 | 241 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | } elseif ($this->isEqual(0)) { |
28 | 28 | $answer = Numbers::makeZero(); |
29 | 29 | } else { |
30 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
30 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
31 | 31 | $one = Numbers::makeOne($precision+2); |
32 | 32 | |
33 | 33 | if ($z->abs()->isGreaterThan(1)) { |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | } elseif ($this->isEqual(1)) { |
78 | 78 | $answer = Numbers::makeZero(); |
79 | 79 | } else { |
80 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
81 | - $one = Numbers::makeOne($precision + 2); |
|
80 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
81 | + $one = Numbers::makeOne($precision+2); |
|
82 | 82 | |
83 | 83 | if ($z->abs()->isGreaterThan(1)) { |
84 | 84 | throw new IntegrityConstraint( |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | $precision = $precision ?? $this->getPrecision(); |
130 | 130 | |
131 | - $piDivTwo = Numbers::makePi($precision + 2)->divide(2, $precision + 2); |
|
131 | + $piDivTwo = Numbers::makePi($precision+2)->divide(2, $precision+2); |
|
132 | 132 | |
133 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
133 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
134 | 134 | |
135 | 135 | $arctan = $z->arctan($precision+2, false); |
136 | 136 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | $precision = $precision ?? $this->getPrecision(); |
153 | 153 | |
154 | - $one = Numbers::makeOne($precision + 2); |
|
154 | + $one = Numbers::makeOne($precision+2); |
|
155 | 155 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
156 | 156 | |
157 | 157 | if ($z->abs()->isLessThan(1)) { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ); |
163 | 163 | } |
164 | 164 | |
165 | - $answer = $one->divide($z, $precision + 2)->arccos($precision + 2); |
|
165 | + $answer = $one->divide($z, $precision+2)->arccos($precision+2); |
|
166 | 166 | |
167 | 167 | if ($round) { |
168 | 168 | $answer = $answer->roundToPrecision($precision); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | $precision = $precision ?? $this->getPrecision(); |
181 | 181 | |
182 | - $one = Numbers::makeOne($precision + 2); |
|
182 | + $one = Numbers::makeOne($precision+2); |
|
183 | 183 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
184 | 184 | |
185 | 185 | if ($z->abs()->isLessThan(1)) { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | ); |
191 | 191 | } |
192 | 192 | |
193 | - $answer = $one->divide($z, $precision + 2)->arcsin($precision + 2); |
|
193 | + $answer = $one->divide($z, $precision+2)->arcsin($precision+2); |
|
194 | 194 | |
195 | 195 | if ($round) { |
196 | 196 | $answer = $answer->roundToPrecision($precision); |