Esempio n. 1
0
 /**
  * Gets the square of the vector's length.
  *
  * @return float
  */
 public function getLengthSquared()
 {
     $result = new BigNumber();
     $vectorSize = $this->getSize();
     for ($i = 0; $i < $vectorSize; ++$i) {
         $pow = new BigNumber($this->getElement($i));
         $pow->pow(2);
         $result->add($pow);
     }
     return $result;
 }
Esempio n. 2
0
 public function testWithMutableTrue()
 {
     // Arrange
     $bigNumber = new BigNumber('2', 10, true);
     // Act
     $newBigNumber = $bigNumber->pow(2);
     // Assert
     $this->assertInstanceOf('PHP\\Math\\BigNumber\\BigNumber', $bigNumber);
     $this->assertInstanceOf('PHP\\Math\\BigNumber\\BigNumber', $newBigNumber);
     $this->assertEquals('4', $bigNumber->getValue());
     $this->assertEquals('4', $newBigNumber->getValue());
 }