@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | ->multiply($e->pow($eExponent)) |
| 49 | 49 | ->multiply(SeriesProvider::maclaurinSeries( |
| 50 | 50 | $x, |
| 51 | - function ($n) { |
|
| 51 | + function($n) { |
|
| 52 | 52 | return Numbers::makeOne(); |
| 53 | 53 | }, |
| 54 | - function ($n) { |
|
| 54 | + function($n) { |
|
| 55 | 55 | return SequenceProvider::nthOddNumber($n); |
| 56 | 56 | }, |
| 57 | - function ($n) { |
|
| 57 | + function($n) { |
|
| 58 | 58 | return SequenceProvider::nthOddNumber($n)->doubleFactorial(); |
| 59 | 59 | }, |
| 60 | 60 | 0, |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x); |
| 95 | 95 | |
| 96 | 96 | $precision = $x->getPrecision(); |
| 97 | - $internalPrecision = $precision + 2; |
|
| 97 | + $internalPrecision = $precision+2; |
|
| 98 | 98 | |
| 99 | 99 | $answer = Numbers::makeOne($internalPrecision); |
| 100 | 100 | $pi = Numbers::makePi($internalPrecision); |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | $answer = $answer->multiply( |
| 105 | 105 | SeriesProvider::maclaurinSeries( |
| 106 | 106 | $x, |
| 107 | - function ($n) { |
|
| 107 | + function($n) { |
|
| 108 | 108 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1); |
| 109 | 109 | |
| 110 | 110 | return $negOne->pow($n); |
| 111 | 111 | }, |
| 112 | - function ($n) { |
|
| 112 | + function($n) { |
|
| 113 | 113 | return SequenceProvider::nthOddNumber($n); |
| 114 | 114 | }, |
| 115 | - function ($n) { |
|
| 115 | + function($n) { |
|
| 116 | 116 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n); |
| 117 | 117 | |
| 118 | 118 | return $n->factorial()->multiply(SequenceProvider::nthOddNumber($n->asInt())); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $p = Numbers::makeOrDont(Numbers::IMMUTABLE, $p); |
| 140 | 140 | |
| 141 | 141 | $precision = $precision ?? $p->getPrecision(); |
| 142 | - $internalPrecision = $precision + 2; |
|
| 142 | + $internalPrecision = $precision+2; |
|
| 143 | 143 | |
| 144 | 144 | $two = Numbers::make(Numbers::IMMUTABLE, 2, $internalPrecision); |
| 145 | 145 | $invErfArg = $two->multiply($p)->subtract(1); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | public static function inverseErrorCoefficients(int $termIndex): ImmutableFraction |
| 185 | 185 | { |
| 186 | 186 | |
| 187 | - $terms =& static::$inverseErrorCoefs; |
|
| 187 | + $terms = & static::$inverseErrorCoefs; |
|
| 188 | 188 | |
| 189 | 189 | if (is_null(static::$inverseErrorCoefs)) { |
| 190 | 190 | $terms = new Vector(); |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | $nextTerm = $terms->count(); |
| 200 | 200 | |
| 201 | - for ($k = $nextTerm;$k <= $termIndex;$k++) { |
|
| 201 | + for ($k = $nextTerm; $k <= $termIndex; $k++) { |
|
| 202 | 202 | $termValue = new ImmutableFraction(new ImmutableDecimal('0'), new ImmutableDecimal('1')); |
| 203 | - for ($m = 0;$m <= ($k - 1);$m++) { |
|
| 203 | + for ($m = 0; $m <= ($k-1); $m++) { |
|
| 204 | 204 | $part1 = $terms->get($m); |
| 205 | - $part2 = $terms->get($k - 1 - $m); |
|
| 205 | + $part2 = $terms->get($k-1-$m); |
|
| 206 | 206 | $part3 = $part1->multiply($part2); |
| 207 | - $part4 = ($m + 1)*($m*2 + 1); |
|
| 207 | + $part4 = ($m+1)*($m*2+1); |
|
| 208 | 208 | $part5 = $part3->divide($part4); |
| 209 | 209 | $termValue = $termValue->add($part5); |
| 210 | 210 | } |
@@ -233,23 +233,23 @@ discard block |
||
| 233 | 233 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $z); |
| 234 | 234 | |
| 235 | 235 | $precision = $precision ?? $z->getPrecision(); |
| 236 | - $internalPrecision = $precision + 1; |
|
| 236 | + $internalPrecision = $precision+1; |
|
| 237 | 237 | |
| 238 | 238 | $pi = Numbers::makePi($internalPrecision); |
| 239 | 239 | |
| 240 | 240 | $answer = SeriesProvider::maclaurinSeries( |
| 241 | 241 | $z, |
| 242 | - function ($n) use ($pi) { |
|
| 242 | + function($n) use ($pi) { |
|
| 243 | 243 | if ($n > 0) { |
| 244 | 244 | return $pi->pow($n)->multiply(StatsProvider::inverseErrorCoefficients($n)); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | return Numbers::makeOne(); |
| 248 | 248 | }, |
| 249 | - function ($n) { |
|
| 249 | + function($n) { |
|
| 250 | 250 | return SequenceProvider::nthOddNumber($n); |
| 251 | 251 | }, |
| 252 | - function ($n) { |
|
| 252 | + function($n) { |
|
| 253 | 253 | if ($n > 0) { |
| 254 | 254 | $extra = Numbers::make(Numbers::IMMUTABLE, 2)->pow(SequenceProvider::nthEvenNumber($n)); |
| 255 | 255 | } else { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $cumulative = Numbers::makeZero(); |
| 80 | 80 | |
| 81 | - for ($i = 0;$x->isGreaterThanOrEqualTo($i);$i++) {
|
|
| 81 | + for ($i = 0; $x->isGreaterThanOrEqualTo($i); $i++) {
|
|
| 82 | 82 | $cumulative = $cumulative->add($this->pmf($i)); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $cumulative = Numbers::makeZero(); |
| 147 | 147 | |
| 148 | - for (;$larger->isGreaterThanOrEqualTo($smaller);$smaller->add(1)) {
|
|
| 148 | + for (;$larger->isGreaterThanOrEqualTo($smaller); $smaller->add(1)) {
|
|
| 149 | 149 | $cumulative = $cumulative->add($this->pmf($smaller)); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | while (true) {
|
| 229 | 229 | /** @var ImmutableDecimal $u */ |
| 230 | - $u = PolyfillProvider::randomInt(0, PHP_INT_MAX) / PHP_INT_MAX; |
|
| 230 | + $u = PolyfillProvider::randomInt(0, PHP_INT_MAX)/PHP_INT_MAX; |
|
| 231 | 231 | /** @var ImmutableDecimal $x */ |
| 232 | 232 | $x = $alpha->subtract($one->subtract($u)->divide($u)->ln(20)->divide($beta)); |
| 233 | 233 | /** @var ImmutableDecimal $n */ |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | do {
|
| 280 | 280 | $k = $k->add(1); |
| 281 | 281 | /** @var ImmutableDecimal $u */ |
| 282 | - $u = PolyfillProvider::randomInt(0, PHP_INT_MAX) / PHP_INT_MAX; |
|
| 282 | + $u = PolyfillProvider::randomInt(0, PHP_INT_MAX)/PHP_INT_MAX; |
|
| 283 | 283 | $p = $p->multiply($u); |
| 284 | 284 | } while ($p->isGreaterThan($L)); |
| 285 | 285 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | public static function radiansToDegrees($radians) |
| 18 | 18 | { |
| 19 | 19 | $radians = Numbers::makeOrDont(Numbers::IMMUTABLE, $radians); |
| 20 | - $pi = Numbers::makePi($radians->getPrecision() + 2); |
|
| 20 | + $pi = Numbers::makePi($radians->getPrecision()+2); |
|
| 21 | 21 | |
| 22 | 22 | return $radians->multiply(180)->divide($pi)->round($radians->getPrecision()-2)->getValue(); |
| 23 | 23 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public static function degreesToRadians($degrees) |
| 32 | 32 | { |
| 33 | 33 | $degrees = Numbers::makeOrDont(Numbers::IMMUTABLE, $degrees); |
| 34 | - $pi = Numbers::makePi($degrees->getPrecision() + 1); |
|
| 34 | + $pi = Numbers::makePi($degrees->getPrecision()+1); |
|
| 35 | 35 | |
| 36 | 36 | return $degrees->multiply($pi)->divide(180)->round($degrees->getPrecision())->getValue(); |
| 37 | 37 | } |
@@ -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); |