@@ -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); |
@@ -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->scale = ($scale > strlen($this->getDecimalPart())) ? $scale : 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->scale = (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 | } |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | if (!$num->isWhole()) { |
| 71 | 71 | $scale += 5; |
| 72 | 72 | $exponent = $num->multiply($this->ln($scale)); |
| 73 | - return $exponent->exp($scale)->truncateToScale($scale - 5)->getValue(); |
|
| 73 | + return $exponent->exp($scale)->truncateToScale($scale-5)->getValue(); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | return ArithmeticProvider::pow($this->asReal(), $num->asReal(), $scale); |
@@ -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, $scale + 2); |
|
| 30 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale+2); |
|
| 31 | 31 | $one = Numbers::makeOne($scale+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, $scale + 2); |
|
| 81 | - $one = Numbers::makeOne($scale + 2); |
|
| 80 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale+2); |
|
| 81 | + $one = Numbers::makeOne($scale+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 | $scale = $scale ?? $this->getScale(); |
| 130 | 130 | |
| 131 | - $piDivTwo = Numbers::makePi($scale + 2)->divide(2, $scale + 2); |
|
| 131 | + $piDivTwo = Numbers::makePi($scale+2)->divide(2, $scale+2); |
|
| 132 | 132 | |
| 133 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale + 2); |
|
| 133 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale+2); |
|
| 134 | 134 | |
| 135 | 135 | $arctan = $z->arctan($scale+2, false); |
| 136 | 136 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | $scale = $scale ?? $this->getScale(); |
| 153 | 153 | |
| 154 | - $one = Numbers::makeOne($scale + 2); |
|
| 154 | + $one = Numbers::makeOne($scale+2); |
|
| 155 | 155 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale+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, $scale + 2)->arccos($scale + 2); |
|
| 165 | + $answer = $one->divide($z, $scale+2)->arccos($scale+2); |
|
| 166 | 166 | |
| 167 | 167 | if ($round) { |
| 168 | 168 | $answer = $answer->roundToScale($scale); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | $scale = $scale ?? $this->getScale(); |
| 181 | 181 | |
| 182 | - $one = Numbers::makeOne($scale + 2); |
|
| 182 | + $one = Numbers::makeOne($scale+2); |
|
| 183 | 183 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale+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, $scale + 2)->arcsin($scale + 2); |
|
| 193 | + $answer = $one->divide($z, $scale+2)->arcsin($scale+2); |
|
| 194 | 194 | |
| 195 | 195 | if ($round) { |
| 196 | 196 | $answer = $answer->roundToScale($scale); |
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $answer = SeriesProvider::maclaurinSeries( |
| 31 | 31 | $modulo, |
| 32 | - function ($n) { |
|
| 32 | + function($n) { |
|
| 33 | 33 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1, 100); |
| 34 | 34 | |
| 35 | 35 | return $negOne->pow($n); |
| 36 | 36 | }, |
| 37 | - function ($n) { |
|
| 37 | + function($n) { |
|
| 38 | 38 | return SequenceProvider::nthOddNumber($n); |
| 39 | 39 | }, |
| 40 | - function ($n) { |
|
| 40 | + function($n) { |
|
| 41 | 41 | return SequenceProvider::nthOddNumber($n)->factorial(); |
| 42 | 42 | }, |
| 43 | 43 | 0, |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $answer = SeriesProvider::maclaurinSeries( |
| 76 | 76 | $modulo, |
| 77 | - function ($n) { |
|
| 77 | + function($n) { |
|
| 78 | 78 | return SequenceProvider::nthPowerNegativeOne($n); |
| 79 | 79 | }, |
| 80 | - function ($n) { |
|
| 80 | + function($n) { |
|
| 81 | 81 | return SequenceProvider::nthEvenNumber($n); |
| 82 | 82 | }, |
| 83 | - function ($n) { |
|
| 83 | + function($n) { |
|
| 84 | 84 | return SequenceProvider::nthEvenNumber($n)->factorial(); |
| 85 | 85 | }, |
| 86 | 86 | 0, |
@@ -159,20 +159,20 @@ discard block |
||
| 159 | 159 | } else { |
| 160 | 160 | $answer = SeriesProvider::maclaurinSeries( |
| 161 | 161 | $modulo, |
| 162 | - function ($n) { |
|
| 162 | + function($n) { |
|
| 163 | 163 | $nthOddNumber = SequenceProvider::nthOddNumber($n); |
| 164 | 164 | |
| 165 | 165 | return SequenceProvider::nthEulerZigzag($nthOddNumber->asInt()); |
| 166 | 166 | }, |
| 167 | - function ($n) { |
|
| 167 | + function($n) { |
|
| 168 | 168 | |
| 169 | 169 | return SequenceProvider::nthOddNumber($n); |
| 170 | 170 | }, |
| 171 | - function ($n) { |
|
| 171 | + function($n) { |
|
| 172 | 172 | return SequenceProvider::nthOddNumber($n)->factorial(); |
| 173 | 173 | }, |
| 174 | 174 | 0, |
| 175 | - $scale + 1 |
|
| 175 | + $scale+1 |
|
| 176 | 176 | ); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | if ($mod2Pi->isEqual(0)) { |
| 207 | 207 | return $this->setValue(static::INFINITY); |
| 208 | - } elseif($modPi->isEqual(0)) { |
|
| 208 | + } elseif ($modPi->isEqual(0)) { |
|
| 209 | 209 | return $this->setValue(static::NEG_INFINITY); |
| 210 | 210 | } |
| 211 | 211 | |
@@ -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 | |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | public static function makePi(int $digits): string |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - $internalScale = $digits + 10; |
|
| 17 | + $internalScale = $digits+10; |
|
| 18 | 18 | |
| 19 | 19 | $C = Numbers::make(Numbers::IMMUTABLE, '10005', $internalScale)->sqrt($internalScale)->multiply(426880); |
| 20 | 20 | $M = Numbers::make(Numbers::IMMUTABLE, '1', $internalScale); |
| 21 | 21 | $L = Numbers::make(Numbers::IMMUTABLE, '13591409', $internalScale); |
| 22 | 22 | $K = Numbers::make(Numbers::IMMUTABLE, '6', $internalScale); |
| 23 | 23 | $X = Numbers::make(Numbers::IMMUTABLE, '1'); |
| 24 | - $sum = Numbers::make(Numbers::MUTABLE,'0', $internalScale + 2); |
|
| 24 | + $sum = Numbers::make(Numbers::MUTABLE, '0', $internalScale+2); |
|
| 25 | 25 | $termNum = 0; |
| 26 | 26 | $one = Numbers::makeOne($internalScale); |
| 27 | 27 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | public static function makeE(int $digits): string |
| 68 | 68 | { |
| 69 | 69 | |
| 70 | - $internalScale = $digits + 3; |
|
| 70 | + $internalScale = $digits+3; |
|
| 71 | 71 | |
| 72 | 72 | $one = Numbers::makeOne($internalScale+5)->setMode(Selectable::CALC_MODE_PRECISION); |
| 73 | 73 | $denominator = Numbers::make(Numbers::MUTABLE, '1', $internalScale)->setMode(Selectable::CALC_MODE_PRECISION); |
@@ -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 | $scale = $x->getScale(); |
| 98 | - $internalScale = $scale + 2; |
|
| 98 | + $internalScale = $scale+2; |
|
| 99 | 99 | |
| 100 | 100 | $answer = Numbers::makeOne($internalScale); |
| 101 | 101 | $pi = Numbers::makePi($internalScale); |
@@ -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 | $scale = $scale ?? $p->getScale(); |
| 143 | - $internalScale = $scale + 2; |
|
| 143 | + $internalScale = $scale+2; |
|
| 144 | 144 | |
| 145 | 145 | $two = Numbers::make(Numbers::IMMUTABLE, 2, $internalScale); |
| 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 | $scale = $scale ?? $z->getScale(); |
| 237 | - $internalScale = $scale + 1; |
|
| 237 | + $internalScale = $scale+1; |
|
| 238 | 238 | |
| 239 | 239 | $pi = Numbers::makePi($internalScale); |
| 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->getScale() + 2); |
|
| 20 | + $pi = Numbers::makePi($radians->getScale()+2); |
|
| 21 | 21 | |
| 22 | - return $radians->multiply(180)->divide($pi, $radians->getScale() + 2)->round($radians->getScale() - 2)->getValue(); |
|
| 22 | + return $radians->multiply(180)->divide($pi, $radians->getScale()+2)->round($radians->getScale()-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->getScale() + 1); |
|
| 34 | + $pi = Numbers::makePi($degrees->getScale()+1); |
|
| 35 | 35 | |
| 36 | 36 | return $degrees->multiply($pi)->divide(180)->round($degrees->getScale())->getValue(); |
| 37 | 37 | } |