@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | foreach ($this->rows[0]->toArray() as $key => $value) { |
94 | 94 | $childMatrixData = []; |
95 | 95 | |
96 | - for ($i = 1;$i < $this->numRows;$i++) { |
|
96 | + for ($i = 1; $i < $this->numRows; $i++) { |
|
97 | 97 | $childMatrixData[$i-1] = $this->rows[$i]->filterByKeys([$key]); |
98 | 98 | } |
99 | 99 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | |
344 | 344 | foreach ($this->rows as $rowKey => $row) { |
345 | 345 | $resultArray[$rowKey] = new NumberCollection(); |
346 | - for ($i = 0;$i < $value->getColumnCount();$i++) { |
|
346 | + for ($i = 0; $i < $value->getColumnCount(); $i++) { |
|
347 | 347 | $cellVal = Numbers::makeZero(); |
348 | 348 | /** @var NumberInterface $num */ |
349 | 349 | foreach ($row->toArray() as $index => $num) { |
@@ -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 |
@@ -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 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | while (true) { |
227 | 227 | /** @var ImmutableDecimal $u */ |
228 | - $u = PolyfillProvider::randomInt(0, PHP_INT_MAX) / PHP_INT_MAX; |
|
228 | + $u = PolyfillProvider::randomInt(0, PHP_INT_MAX)/PHP_INT_MAX; |
|
229 | 229 | /** @var ImmutableDecimal $x */ |
230 | 230 | $x = $alpha->subtract($one->subtract($u)->divide($u)->ln(20)->divide($beta)); |
231 | 231 | /** @var ImmutableDecimal $n */ |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | /** @var ImmutableDecimal $v */ |
239 | - $v = PolyfillProvider::randomInt(0, PHP_INT_MAX) / PHP_INT_MAX; |
|
239 | + $v = PolyfillProvider::randomInt(0, PHP_INT_MAX)/PHP_INT_MAX; |
|
240 | 240 | /** @var ImmutableDecimal $y */ |
241 | 241 | $y = $alpha->subtract($beta->multiply($x)); |
242 | 242 | /** @var ImmutableDecimal $lhs */ |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | do { |
278 | 278 | $k = $k->add(1); |
279 | 279 | /** @var ImmutableDecimal $u */ |
280 | - $u = PolyfillProvider::randomInt(0, PHP_INT_MAX) / PHP_INT_MAX; |
|
280 | + $u = PolyfillProvider::randomInt(0, PHP_INT_MAX)/PHP_INT_MAX; |
|
281 | 281 | $p = $p->multiply($u); |
282 | 282 | } while ($p->isGreaterThan($L)); |
283 | 283 |
@@ -198,16 +198,16 @@ |
||
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); |
@@ -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 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $rounded = $whole.'.'; |
50 | 50 | |
51 | - for ($i = 0;$i < $decimals;$i++) { |
|
51 | + for ($i = 0; $i < $decimals; $i++) { |
|
52 | 52 | $rounded .= $fractionalArr[$i]; |
53 | 53 | } |
54 | 54 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $total = strlen($fractional); |
131 | 131 | $fractional = ltrim($fractional, '0'); |
132 | 132 | |
133 | - return ($total - strlen($fractional)); |
|
133 | + return ($total-strlen($fractional)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -216,9 +216,9 @@ |
||
216 | 216 | |
217 | 217 | if ($check == 1) { |
218 | 218 | $checkVal = $this->getDecimalPart(); |
219 | - $checkVal = trim($checkVal,'0'); |
|
219 | + $checkVal = trim($checkVal, '0'); |
|
220 | 220 | |
221 | - if (strlen($checkVal) > 0 ) { |
|
221 | + if (strlen($checkVal) > 0) { |
|
222 | 222 | return false; |
223 | 223 | } else { |
224 | 224 | return true; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $this->imaginary = false; |
49 | 49 | } |
50 | 50 | |
51 | - $value = (string)$value; |
|
51 | + $value = (string) $value; |
|
52 | 52 | $this->value = $this->translateValue($value); |
53 | 53 | |
54 | 54 | if (!is_null($precision)) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->precision = ($precision > strlen($this->getDecimalPart())) ? $precision : strlen($this->getDecimalPart()); |
64 | 64 | } else { |
65 | 65 | $checkVal = $this->getDecimalPart(); |
66 | - $checkVal = trim($checkVal,'0'); |
|
66 | + $checkVal = trim($checkVal, '0'); |
|
67 | 67 | |
68 | 68 | if (strlen($checkVal) > 0) { |
69 | 69 | $this->precision = (strlen($this->getDecimalPart()) > 10) ? strlen($this->getDecimalPart()) : 10; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | } elseif ($this->isEqual(0)) { |
26 | 26 | $answer = Numbers::makeZero(); |
27 | 27 | } else { |
28 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
28 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
29 | 29 | $one = Numbers::makeOne($precision+2); |
30 | 30 | |
31 | 31 | if ($z->abs()->isGreaterThan(1)) { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | ); |
37 | 37 | } |
38 | 38 | |
39 | - $answer = $z->divide($one->subtract($z->pow(2))->sqrt($precision + 2), $precision + 2)->arctan($precision + 2, false); |
|
39 | + $answer = $z->divide($one->subtract($z->pow(2))->sqrt($precision+2), $precision+2)->arctan($precision+2, false); |
|
40 | 40 | } |
41 | 41 | if ($round) { |
42 | 42 | $answer = $answer->roundToPrecision($precision); |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | } elseif ($this->isEqual(1)) { |
62 | 62 | $answer = Numbers::makeZero(); |
63 | 63 | } else { |
64 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
65 | - $one = Numbers::makeOne($precision + 2); |
|
64 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
65 | + $one = Numbers::makeOne($precision+2); |
|
66 | 66 | |
67 | 67 | if ($z->abs()->isGreaterThan(1)) { |
68 | 68 | throw new IntegrityConstraint( |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | $answer = $one->subtract($z->pow(2)) |
76 | - ->sqrt($precision + 2) |
|
77 | - ->divide($z, $precision + 2) |
|
78 | - ->arctan($precision + 2, false); |
|
76 | + ->sqrt($precision+2) |
|
77 | + ->divide($z, $precision+2) |
|
78 | + ->arctan($precision+2, false); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | if ($round) { |
@@ -93,24 +93,24 @@ discard block |
||
93 | 93 | |
94 | 94 | $precision = $precision ?? $this->getPrecision(); |
95 | 95 | |
96 | - $one = Numbers::makeOne($precision + 2); |
|
96 | + $one = Numbers::makeOne($precision+2); |
|
97 | 97 | |
98 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
98 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
99 | 99 | |
100 | 100 | if ($z->isEqual(1)) { |
101 | - $answer = Numbers::makePi($precision + 2)->divide(4, $precision + 2); |
|
101 | + $answer = Numbers::makePi($precision+2)->divide(4, $precision+2); |
|
102 | 102 | } elseif ($z->isEqual(-1)) { |
103 | - $answer = Numbers::makePi($precision + 2)->divide(4, $precision +2)->multiply(-1); |
|
103 | + $answer = Numbers::makePi($precision+2)->divide(4, $precision+2)->multiply(-1); |
|
104 | 104 | } else { |
105 | 105 | |
106 | 106 | if ($z->abs()->isGreaterThan(1)) { |
107 | - $rangeAdjust = Numbers::makePi($precision + 2)->divide(2, $precision + 2); |
|
107 | + $rangeAdjust = Numbers::makePi($precision+2)->divide(2, $precision+2); |
|
108 | 108 | |
109 | 109 | if ($z->isNegative()) { |
110 | 110 | $rangeAdjust = $rangeAdjust->multiply(-1); |
111 | 111 | } |
112 | 112 | |
113 | - $z = $one->divide($z, $precision + 2); |
|
113 | + $z = $one->divide($z, $precision+2); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $y = $z->pow(2)->divide($z->pow(2)->add(1)); |
@@ -118,21 +118,21 @@ discard block |
||
118 | 118 | |
119 | 119 | $answer = SeriesProvider::maclaurinSeries( |
120 | 120 | $y, |
121 | - function ($n) { |
|
121 | + function($n) { |
|
122 | 122 | $nthOdd = SequenceProvider::nthOddNumber($n)->subtract(1); |
123 | 123 | |
124 | 124 | return $nthOdd->doubleFactorial(); |
125 | 125 | }, |
126 | - function ($n) { |
|
126 | + function($n) { |
|
127 | 127 | return $n; |
128 | 128 | }, |
129 | - function ($n) { |
|
129 | + function($n) { |
|
130 | 130 | $nthOdd = SequenceProvider::nthOddNumber($n); |
131 | 131 | |
132 | 132 | return $nthOdd->doubleFactorial(); |
133 | 133 | }, |
134 | 134 | 0, |
135 | - $precision + 1 |
|
135 | + $precision+1 |
|
136 | 136 | ); |
137 | 137 | |
138 | 138 | $answer = $answer->add(1); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | |
159 | 159 | $precision = $precision ?? $this->getPrecision(); |
160 | 160 | |
161 | - $piDivTwo = Numbers::makePi($precision + 2)->divide(2, $precision + 2); |
|
161 | + $piDivTwo = Numbers::makePi($precision+2)->divide(2, $precision+2); |
|
162 | 162 | |
163 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
163 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
164 | 164 | |
165 | 165 | $arctan = $z->arctan($precision+2, false); |
166 | 166 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | $precision = $precision ?? $this->getPrecision(); |
183 | 183 | |
184 | - $one = Numbers::makeOne($precision + 2); |
|
184 | + $one = Numbers::makeOne($precision+2); |
|
185 | 185 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
186 | 186 | |
187 | 187 | if ($z->abs()->isLessThan(1)) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | ); |
193 | 193 | } |
194 | 194 | |
195 | - $answer = $one->divide($z, $precision + 2)->arccos($precision + 2); |
|
195 | + $answer = $one->divide($z, $precision+2)->arccos($precision+2); |
|
196 | 196 | |
197 | 197 | if ($round) { |
198 | 198 | $answer = $answer->roundToPrecision($precision); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | $precision = $precision ?? $this->getPrecision(); |
211 | 211 | |
212 | - $one = Numbers::makeOne($precision + 2); |
|
212 | + $one = Numbers::makeOne($precision+2); |
|
213 | 213 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
214 | 214 | |
215 | 215 | if ($z->abs()->isLessThan(1)) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ); |
221 | 221 | } |
222 | 222 | |
223 | - $answer = $one->divide($z, $precision + 2)->arcsin($precision + 2); |
|
223 | + $answer = $one->divide($z, $precision+2)->arcsin($precision+2); |
|
224 | 224 | |
225 | 225 | if ($round) { |
226 | 226 | $answer = $answer->roundToPrecision($precision); |