@@ -18,7 +18,7 @@ |
||
18 | 18 | { |
19 | 19 | $sample = new NumberCollection(); |
20 | 20 | |
21 | - for ($i = 1;$i < $sampleSize;$i++) { |
|
21 | + for ($i = 1; $i < $sampleSize; $i++) { |
|
22 | 22 | $sample->push($this->random()); |
23 | 23 | } |
24 | 24 |
@@ -25,6 +25,6 @@ |
||
25 | 25 | return $sample; |
26 | 26 | } |
27 | 27 | |
28 | - abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableDecimal; |
|
28 | + abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableDecimal; |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -33,7 +33,7 @@ |
||
33 | 33 | $curVal = $this->getValue(); |
34 | 34 | $calcVal = Numbers::make(Numbers::IMMUTABLE, 1); |
35 | 35 | |
36 | - for ($i = 1;$i <= $curVal;$i++) { |
|
36 | + for ($i = 1; $i <= $curVal; $i++) { |
|
37 | 37 | $calcVal = $calcVal->multiply($i); |
38 | 38 | } |
39 | 39 |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function sort(): NumberCollectionInterface |
146 | 146 | { |
147 | - $this->getCollection()->sort(function($left, $right){ |
|
147 | + $this->getCollection()->sort(function($left, $right) { |
|
148 | 148 | return ArithmeticProvider::compare($left->getAsBaseTenRealNumber(), $right->getAsBaseTenRealNumber()); |
149 | 149 | }); |
150 | 150 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function getRandom(): NumberInterface |
279 | 279 | { |
280 | - $maxKey = $this->getCollection()->count() - 1; |
|
280 | + $maxKey = $this->getCollection()->count()-1; |
|
281 | 281 | |
282 | 282 | $key = PolyfillProvider::randomInt(0, $maxKey); |
283 | 283 |
@@ -220,7 +220,7 @@ |
||
220 | 220 | |
221 | 221 | if ($check === 1) { |
222 | 222 | $checkVal = $this->getDecimalPart(); |
223 | - $checkVal = trim($checkVal,'0'); |
|
223 | + $checkVal = trim($checkVal, '0'); |
|
224 | 224 | |
225 | 225 | return !($checkVal !== ''); |
226 | 226 | } |
@@ -14,57 +14,57 @@ discard block |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | const EULER_ZIGZAG = [ |
17 | - '1', // 0 |
|
18 | - '1', // 1 |
|
19 | - '1', // 2 |
|
20 | - '2', // 3 |
|
21 | - '5', // 4 |
|
22 | - '16', // 5 |
|
23 | - '61', // 6 |
|
24 | - '272', // 7 |
|
25 | - '1385', // 8 |
|
26 | - '7936', // 9 |
|
27 | - '50521', // 10 |
|
28 | - '353792', // 11 |
|
29 | - '2702765', // 12 |
|
30 | - '22368256', // 13 |
|
31 | - '199360981', // 14 |
|
32 | - '1903757312', // 15 |
|
33 | - '19391512145', // 16 |
|
34 | - '209865342976', // 17 |
|
35 | - '2404879675441', // 18 |
|
36 | - '29088885112832', // 19 |
|
37 | - '370371188237525', // 20 |
|
38 | - '4951498053124096', // 21 |
|
39 | - '69348874393137901', // 22 |
|
40 | - '1015423886506852352', // 23 |
|
41 | - '15514534163557086905', // 24 |
|
42 | - '246921480190207983616', // 25 |
|
43 | - '4087072509293123892361', // 26 |
|
44 | - '70251601603943959887872', // 27 |
|
45 | - '1252259641403629865468285', // 28 |
|
46 | - '23119184187809597841473536', // 29 |
|
47 | - '441543893249023104553682821', // 30 |
|
48 | - '8713962757125169296170811392', // 31 |
|
49 | - '177519391579539289436664789665', // 32 |
|
50 | - '3729407703720529571097509625856', // 33 |
|
51 | - '80723299235887898062168247453281', // 34 |
|
52 | - '1798651693450888780071750349094912', // 35 |
|
53 | - '41222060339517702122347079671259045', // 36 |
|
54 | - '970982810785059112379399707952152576', // 37 |
|
55 | - '23489580527043108252017828576198947741', // 38 |
|
56 | - '583203324917310043943191641625494290432', // 39 |
|
57 | - '14851150718114980017877156781405826684425', // 40 |
|
58 | - '387635983772083031828014624002175135645696', // 41 |
|
59 | - '10364622733519612119397957304745185976310201', // 42 |
|
60 | - '283727921907431909304183316295787837183229952', // 43 |
|
61 | - '7947579422597592703608040510088070619519273805', // 44 |
|
62 | - '227681379129930886488600284336316164603920777216', // 45 |
|
63 | - '6667537516685544977435028474773748197524107684661', // 46 |
|
64 | - '199500252157859031027160499643195658166340757225472', // 47 |
|
65 | - '6096278645568542158691685742876843153976539044435185', // 48 |
|
66 | - '190169564657928428175235445073924928592047775873499136', // 49 |
|
67 | - '6053285248188621896314383785111649088103498225146815121', // 50 |
|
17 | + '1', // 0 |
|
18 | + '1', // 1 |
|
19 | + '1', // 2 |
|
20 | + '2', // 3 |
|
21 | + '5', // 4 |
|
22 | + '16', // 5 |
|
23 | + '61', // 6 |
|
24 | + '272', // 7 |
|
25 | + '1385', // 8 |
|
26 | + '7936', // 9 |
|
27 | + '50521', // 10 |
|
28 | + '353792', // 11 |
|
29 | + '2702765', // 12 |
|
30 | + '22368256', // 13 |
|
31 | + '199360981', // 14 |
|
32 | + '1903757312', // 15 |
|
33 | + '19391512145', // 16 |
|
34 | + '209865342976', // 17 |
|
35 | + '2404879675441', // 18 |
|
36 | + '29088885112832', // 19 |
|
37 | + '370371188237525', // 20 |
|
38 | + '4951498053124096', // 21 |
|
39 | + '69348874393137901', // 22 |
|
40 | + '1015423886506852352', // 23 |
|
41 | + '15514534163557086905', // 24 |
|
42 | + '246921480190207983616', // 25 |
|
43 | + '4087072509293123892361', // 26 |
|
44 | + '70251601603943959887872', // 27 |
|
45 | + '1252259641403629865468285', // 28 |
|
46 | + '23119184187809597841473536', // 29 |
|
47 | + '441543893249023104553682821', // 30 |
|
48 | + '8713962757125169296170811392', // 31 |
|
49 | + '177519391579539289436664789665', // 32 |
|
50 | + '3729407703720529571097509625856', // 33 |
|
51 | + '80723299235887898062168247453281', // 34 |
|
52 | + '1798651693450888780071750349094912', // 35 |
|
53 | + '41222060339517702122347079671259045', // 36 |
|
54 | + '970982810785059112379399707952152576', // 37 |
|
55 | + '23489580527043108252017828576198947741', // 38 |
|
56 | + '583203324917310043943191641625494290432', // 39 |
|
57 | + '14851150718114980017877156781405826684425', // 40 |
|
58 | + '387635983772083031828014624002175135645696', // 41 |
|
59 | + '10364622733519612119397957304745185976310201', // 42 |
|
60 | + '283727921907431909304183316295787837183229952', // 43 |
|
61 | + '7947579422597592703608040510088070619519273805', // 44 |
|
62 | + '227681379129930886488600284336316164603920777216', // 45 |
|
63 | + '6667537516685544977435028474773748197524107684661', // 46 |
|
64 | + '199500252157859031027160499643195658166340757225472', // 47 |
|
65 | + '6096278645568542158691685742876843153976539044435185', // 48 |
|
66 | + '190169564657928428175235445073924928592047775873499136', // 49 |
|
67 | + '6053285248188621896314383785111649088103498225146815121', // 50 |
|
68 | 68 | ]; |
69 | 69 | |
70 | 70 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | if ($asCollection) { |
83 | 83 | $sequence = new NumberCollection(); |
84 | 84 | |
85 | - for ($i = 0;$i < $collectionSize;$i++) { |
|
86 | - $sequence->push(self::nthOddNumber($n + $i)); |
|
85 | + for ($i = 0; $i < $collectionSize; $i++) { |
|
86 | + $sequence->push(self::nthOddNumber($n+$i)); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $sequence; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | if ($asCollection) { |
112 | 112 | $sequence = new NumberCollection(); |
113 | 113 | |
114 | - for ($i = 0;$i < $collectionSize;$i++) { |
|
115 | - $sequence->push(self::nthEvenNumber($n + $i)); |
|
114 | + for ($i = 0; $i < $collectionSize; $i++) { |
|
115 | + $sequence->push(self::nthEvenNumber($n+$i)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $sequence; |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | if ($asCollection) { |
141 | 141 | $sequence = new NumberCollection(); |
142 | 142 | |
143 | - for ($i = 0;$i < $collectionSize;$i++) { |
|
144 | - $sequence->push(self::nthPowerNegativeOne($n + $i)); |
|
143 | + for ($i = 0; $i < $collectionSize; $i++) { |
|
144 | + $sequence->push(self::nthPowerNegativeOne($n+$i)); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | return $sequence; |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | if ($asCollection) { |
175 | 175 | $sequence = new NumberCollection(); |
176 | 176 | |
177 | - for ($i = 0;$i < $collectionSize;$i++) { |
|
178 | - $sequence->push(self::nthEulerZigzag($n + $i)); |
|
177 | + for ($i = 0; $i < $collectionSize; $i++) { |
|
178 | + $sequence->push(self::nthEulerZigzag($n+$i)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $sequence; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $sequence = new NumberCollection(); |
263 | 263 | $sequence->push($fastFib[0]); |
264 | 264 | $sequence->push($fastFib[1]); |
265 | - for ($i = 0;$i < ($collectionSize-2);$i++) { |
|
265 | + for ($i = 0; $i < ($collectionSize-2); $i++) { |
|
266 | 266 | $sequence->push($sequence->get($i)->add($sequence[$i+1])); |
267 | 267 | } |
268 | 268 |
@@ -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 | } |
@@ -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 | } |