@@ -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); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $this->base = $base; |
| 39 | 39 | |
| 40 | - $value = (string)$value; |
|
| 40 | + $value = (string) $value; |
|
| 41 | 41 | |
| 42 | 42 | if (strpos($value, 'i') !== false) { |
| 43 | 43 | $this->imaginary = true; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->precision = ($precision > strlen($this->getDecimalPart())) ? $precision : strlen($this->getDecimalPart()); |
| 65 | 65 | } else { |
| 66 | 66 | $checkVal = $this->getDecimalPart(); |
| 67 | - $checkVal = trim($checkVal,'0'); |
|
| 67 | + $checkVal = trim($checkVal, '0'); |
|
| 68 | 68 | |
| 69 | 69 | if (strlen($checkVal) > 0) { |
| 70 | 70 | $this->precision = (strlen($this->getDecimalPart()) > 10) ? strlen($this->getDecimalPart()) : 10; |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | if ($exp > 0) { |
| 103 | 103 | $exp -= strlen($right); |
| 104 | 104 | if ($exp >= 0) { |
| 105 | - $right = str_pad($right, $exp - 1, '0').'.0'; |
|
| 105 | + $right = str_pad($right, $exp-1, '0').'.0'; |
|
| 106 | 106 | } else { |
| 107 | - $right = substr($right, 0, strlen($right) + $exp).'.'.substr($right, strlen($right) + $exp + 1); |
|
| 107 | + $right = substr($right, 0, strlen($right)+$exp).'.'.substr($right, strlen($right)+$exp+1); |
|
| 108 | 108 | } |
| 109 | 109 | } else { |
| 110 | 110 | $exp += strlen($left); |
| 111 | 111 | if ($exp >= 0) { |
| 112 | - $left = substr($left, 0, $exp).'.'.substr($left, $exp + 1); |
|
| 112 | + $left = substr($left, 0, $exp).'.'.substr($left, $exp+1); |
|
| 113 | 113 | } else { |
| 114 | 114 | $left = '0.'.str_pad($left, $exp, '0', STR_PAD_LEFT); |
| 115 | 115 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | foreach ($this->rows as $rowKey => $row) { |
| 232 | 232 | $resultArray[$rowKey] = new NumberCollection(); |
| 233 | - for ($i = 0;$i < $value->getColumnCount();$i++) { |
|
| 233 | + for ($i = 0; $i < $value->getColumnCount(); $i++) { |
|
| 234 | 234 | $cellVal = Numbers::makeZero(); |
| 235 | 235 | /** @var NumberInterface $num */ |
| 236 | 236 | foreach ($row->toArray() as $index => $num) { |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | $newMatrixData = []; |
| 274 | 274 | |
| 275 | 275 | // TODO: Implement minors & cofactors method https://www.mathsisfun.com/algebra/matrix-inverse-minors-cofactors-adjugate.html |
| 276 | - for ($i = 0;$i < $columnCount;$i++) { |
|
| 277 | - for ($r = 0;$r < $columnCount;$r++) { |
|
| 276 | + for ($i = 0; $i < $columnCount; $i++) { |
|
| 277 | + for ($r = 0; $r < $columnCount; $r++) { |
|
| 278 | 278 | |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | $newRows = []; |
| 303 | 303 | |
| 304 | - for ($i = 0;$i < $this->getRowCount();$i++) { |
|
| 304 | + for ($i = 0; $i < $this->getRowCount(); $i++) { |
|
| 305 | 305 | if ($i === $excludeRow) { |
| 306 | 306 | continue; |
| 307 | 307 | } |
@@ -93,7 +93,7 @@ |
||
| 93 | 93 | */ |
| 94 | 94 | public function rotate(bool $clockwise = true): MatrixInterface |
| 95 | 95 | { |
| 96 | - $tempData = $clockwise ? $this->rows : $this->columns; |
|
| 96 | + $tempData = $clockwise ? $this->rows : $this->columns; |
|
| 97 | 97 | $mode = $clockwise ? self::MODE_COLUMNS_INPUT : self::MODE_ROWS_INPUT; |
| 98 | 98 | |
| 99 | 99 | $tempData = array_reverse($tempData); |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | ->multiply($e->pow($eExponent)) |
| 50 | 50 | ->multiply(SeriesProvider::maclaurinSeries( |
| 51 | 51 | $x, |
| 52 | - function ($n) { |
|
| 52 | + function($n) { |
|
| 53 | 53 | return Numbers::makeOne(); |
| 54 | 54 | }, |
| 55 | - function ($n) { |
|
| 55 | + function($n) { |
|
| 56 | 56 | return SequenceProvider::nthOddNumber($n); |
| 57 | 57 | }, |
| 58 | - function ($n) { |
|
| 58 | + function($n) { |
|
| 59 | 59 | return SequenceProvider::nthOddNumber($n)->doubleFactorial(); |
| 60 | 60 | }, |
| 61 | 61 | 0, |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x); |
| 96 | 96 | |
| 97 | 97 | $precision = $x->getPrecision(); |
| 98 | - $internalPrecision = $precision + 2; |
|
| 98 | + $internalPrecision = $precision+2; |
|
| 99 | 99 | |
| 100 | 100 | $answer = Numbers::makeOne($internalPrecision); |
| 101 | 101 | $pi = Numbers::makePi($internalPrecision); |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | $answer = $answer->multiply( |
| 106 | 106 | SeriesProvider::maclaurinSeries( |
| 107 | 107 | $x, |
| 108 | - function ($n) { |
|
| 108 | + function($n) { |
|
| 109 | 109 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1); |
| 110 | 110 | |
| 111 | 111 | return $negOne->pow($n); |
| 112 | 112 | }, |
| 113 | - function ($n) { |
|
| 113 | + function($n) { |
|
| 114 | 114 | return SequenceProvider::nthOddNumber($n); |
| 115 | 115 | }, |
| 116 | - function ($n) { |
|
| 116 | + function($n) { |
|
| 117 | 117 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n); |
| 118 | 118 | |
| 119 | 119 | return $n->factorial()->multiply(SequenceProvider::nthOddNumber($n->asInt())); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $p = Numbers::makeOrDont(Numbers::IMMUTABLE, $p); |
| 141 | 141 | |
| 142 | 142 | $precision = $precision ?? $p->getPrecision(); |
| 143 | - $internalPrecision = $precision + 2; |
|
| 143 | + $internalPrecision = $precision+2; |
|
| 144 | 144 | |
| 145 | 145 | $two = Numbers::make(Numbers::IMMUTABLE, 2, $internalPrecision); |
| 146 | 146 | $invErfArg = $two->multiply($p)->subtract(1); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | public static function inverseErrorCoefficients(int $termIndex): ImmutableFraction |
| 186 | 186 | { |
| 187 | 187 | |
| 188 | - $terms =& static::$inverseErrorCoefs; |
|
| 188 | + $terms = & static::$inverseErrorCoefs; |
|
| 189 | 189 | |
| 190 | 190 | if (is_null(static::$inverseErrorCoefs)) { |
| 191 | 191 | $terms = new Vector(); |
@@ -199,13 +199,13 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $nextTerm = $terms->count(); |
| 201 | 201 | |
| 202 | - for ($k = $nextTerm;$k <= $termIndex;$k++) { |
|
| 202 | + for ($k = $nextTerm; $k <= $termIndex; $k++) { |
|
| 203 | 203 | $termValue = new ImmutableFraction(new ImmutableDecimal('0'), new ImmutableDecimal('1')); |
| 204 | - for ($m = 0;$m <= ($k - 1);$m++) { |
|
| 204 | + for ($m = 0; $m <= ($k-1); $m++) { |
|
| 205 | 205 | $part1 = $terms->get($m); |
| 206 | - $part2 = $terms->get($k - 1 - $m); |
|
| 206 | + $part2 = $terms->get($k-1-$m); |
|
| 207 | 207 | $part3 = $part1->multiply($part2); |
| 208 | - $part4 = ($m + 1)*($m*2 + 1); |
|
| 208 | + $part4 = ($m+1)*($m*2+1); |
|
| 209 | 209 | $part5 = $part3->divide($part4); |
| 210 | 210 | $termValue = $termValue->add($part5); |
| 211 | 211 | } |
@@ -234,23 +234,23 @@ discard block |
||
| 234 | 234 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $z); |
| 235 | 235 | |
| 236 | 236 | $precision = $precision ?? $z->getPrecision(); |
| 237 | - $internalPrecision = $precision + 1; |
|
| 237 | + $internalPrecision = $precision+1; |
|
| 238 | 238 | |
| 239 | 239 | $pi = Numbers::makePi($internalPrecision); |
| 240 | 240 | |
| 241 | 241 | $answer = SeriesProvider::maclaurinSeries( |
| 242 | 242 | $z, |
| 243 | - static function ($n) use ($pi) { |
|
| 243 | + static function($n) use ($pi) { |
|
| 244 | 244 | if ($n > 0) { |
| 245 | 245 | return $pi->pow($n)->multiply(StatsProvider::inverseErrorCoefficients($n)); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | return Numbers::makeOne(); |
| 249 | 249 | }, |
| 250 | - static function ($n) { |
|
| 250 | + static function($n) { |
|
| 251 | 251 | return SequenceProvider::nthOddNumber($n); |
| 252 | 252 | }, |
| 253 | - static function ($n) { |
|
| 253 | + static function($n) { |
|
| 254 | 254 | if ($n > 0) { |
| 255 | 255 | $extra = Numbers::make(Numbers::IMMUTABLE, 2)->pow(SequenceProvider::nthEvenNumber($n)); |
| 256 | 256 | } else { |
@@ -17,9 +17,9 @@ 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 | - return $radians->multiply(180)->divide($pi, $radians->getPrecision() + 2)->round($radians->getPrecision() - 2)->getValue(); |
|
| 22 | + return $radians->multiply(180)->divide($pi, $radians->getPrecision()+2)->round($radians->getPrecision()-2)->getValue(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -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 | } |
@@ -237,7 +237,7 @@ |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | if ($precision > 100) {
|
| 240 | - $pi = self::make(self::IMMUTABLE, ConstantProvider::makePi($precision), $precision + 2); |
|
| 240 | + $pi = self::make(self::IMMUTABLE, ConstantProvider::makePi($precision), $precision+2); |
|
| 241 | 241 | return $pi->multiply(2)->truncateToPrecision($precision); |
| 242 | 242 | } |
| 243 | 243 | |