/** * This method tests the "subtract" method. * * @dataProvider data_subtract */ public function test_subtract(array $provided, array $expected) { $p0 = IDouble\Module::subtract(IDouble\Type::box($provided[0]), IDouble\Type::box($provided[1])); $e0 = $expected[0]; $this->assertInstanceOf('\\Saber\\Data\\IDouble\\Type', $p0); $this->assertSame($e0, $p0->unbox()); }
/** * This method returns a list of all numbers for the specified sequence. * * @access public * @static * @param IDouble\Type $x where to start * @param Core\Type $y either an integer representing * the end of the sequence or a * tuple describing the sequence * @return IArrayList\Type an empty array list */ public static function sequence(IDouble\Type $x, Core\Type $y) : IArrayList\Type { $buffer = array(); if ($y instanceof ITuple\Type) { $s = IDouble\Module::subtract($y->first(), $x); $n = $y->second(); } else { // ($y instanceof IDouble\Type) $s = IDouble\Type::one(); $n = $y; } if (IDouble\Module::isNegative($s)->unbox()) { for ($i = $x; IDouble\Module::ge($i, $n)->unbox(); $i = IDouble\Module::add($i, $s)) { $buffer[] = $i; } } else { for ($i = $x; IDouble\Module::le($i, $n)->unbox(); $i = IDouble\Module::add($i, $s)) { $buffer[] = $i; } } return IArrayList\Type::box($buffer); }