@@ -52,6 +52,9 @@ discard block |
||
| 52 | 52 | return $this->precision; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | + /** |
|
| 56 | + * @param NumberInterface $num |
|
| 57 | + */ |
|
| 55 | 58 | public function add($num) |
| 56 | 59 | {
|
| 57 | 60 | $num = Numbers::makeOrDont($this, $num, $this->getPrecision()); |
@@ -101,7 +104,7 @@ discard block |
||
| 101 | 104 | * Note about precision: it uses the smaller of the two precisions (significant figures). |
| 102 | 105 | * |
| 103 | 106 | * @param $num |
| 104 | - * @return mixed |
|
| 107 | + * @return NumberInterface |
|
| 105 | 108 | */ |
| 106 | 109 | public function divide($num) |
| 107 | 110 | {
|
@@ -398,6 +401,9 @@ discard block |
||
| 398 | 401 | |
| 399 | 402 | } |
| 400 | 403 | |
| 404 | + /** |
|
| 405 | + * @param ImmutableNumber $num |
|
| 406 | + */ |
|
| 401 | 407 | public function getGreatestCommonDivisor($num) |
| 402 | 408 | {
|
| 403 | 409 | /** @var ImmutableNumber $num */ |
@@ -2,16 +2,16 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Samsara\Fermat\Types; |
| 4 | 4 | |
| 5 | -use Ds\Hashable; |
|
| 6 | -use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState; |
|
| 7 | -use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
| 8 | -use Samsara\Fermat\Numbers; |
|
| 9 | -use Samsara\Fermat\Provider\BCProvider; |
|
| 10 | -use Riimu\Kit\BaseConversion\BaseConverter; |
|
| 11 | -use Samsara\Fermat\Provider\SequenceProvider; |
|
| 12 | -use Samsara\Fermat\Provider\SeriesProvider; |
|
| 13 | -use Samsara\Fermat\Types\Base\DecimalInterface; |
|
| 14 | -use Samsara\Fermat\Types\Base\NumberInterface; |
|
| 5 | +use Ds\Hashable; |
|
| 6 | +use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState; |
|
| 7 | +use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
| 8 | +use Samsara\Fermat\Numbers; |
|
| 9 | +use Samsara\Fermat\Provider\BCProvider; |
|
| 10 | +use Riimu\Kit\BaseConversion\BaseConverter; |
|
| 11 | +use Samsara\Fermat\Provider\SequenceProvider; |
|
| 12 | +use Samsara\Fermat\Provider\SeriesProvider; |
|
| 13 | +use Samsara\Fermat\Types\Base\DecimalInterface; |
|
| 14 | +use Samsara\Fermat\Types\Base\NumberInterface; |
|
| 15 | 15 | use Samsara\Fermat\Values\ImmutableNumber; |
| 16 | 16 | |
| 17 | 17 | abstract class Number implements Hashable |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $cumulative = Numbers::makeZero(); |
| 34 | 34 | $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x); |
| 35 | 35 | |
| 36 | - for ($i = 0;$x->isGreaterThanOrEqualTo($i);$i++) {
|
|
| 36 | + for ($i = 0; $x->isGreaterThanOrEqualTo($i); $i++) {
|
|
| 37 | 37 | $cumulative = $cumulative->add($this->pmf($i)); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $cumulative = Numbers::makeZero(); |
| 64 | 64 | |
| 65 | - for (;$larger->isGreaterThanOrEqualTo($smaller);$smaller->add(1)) {
|
|
| 65 | + for (;$larger->isGreaterThanOrEqualTo($smaller); $smaller->add(1)) {
|
|
| 66 | 66 | $cumulative = $cumulative->add($this->pmf($smaller)); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | while ($p->isLessThan($L)) {
|
| 98 | 98 | $k = $k->add(1); |
| 99 | - $u = $randFactory->getMediumStrengthGenerator()->generateInt() / PHP_INT_MAX; |
|
| 99 | + $u = $randFactory->getMediumStrengthGenerator()->generateInt()/PHP_INT_MAX; |
|
| 100 | 100 | $p = $p->multiply($u); |
| 101 | 101 | } |
| 102 | 102 | |