NumPHP\Core\NumPHP::randLike PHP Метод

randLike() публичный статический Метод

Returns a NumArray with the same size, but filled with random values
С версии: 1.0.0
public static randLike ( NumArray $numArray ) : NumArray
$numArray NumArray given NumArray
Результат NumArray
    public static function randLike(NumArray $numArray)
    {
        return new NumArray(Generate::generateArray($numArray->getShape()));
    }

Usage Example

Пример #1
0
 /**
  * Tests NumPHP::randLike with vector
  */
 public function testRandLike()
 {
     $numArray = new NumArray([1, 2, 3]);
     $rand = NumPHP::randLike($numArray);
     $this->assertInstanceOf('\\NumPHP\\Core\\NumArray', $rand);
     $this->assertSame([3], $rand->getShape());
     $randData = $rand->getData();
     $this->assertCount(3, $randData);
     foreach ($randData as $entry) {
         $this->assertInternalType('float', $entry);
     }
 }