getData() public method

Returns the data of the NumArray
Since: 1.0.0
public getData ( ) : mixed
return mixed
Ejemplo n.º 1
0
 /**
  * Combines all elements of an NumArray at a given axis with the `$callback`
  * function
  *
  * @param NumArray $numArray given NumArray
  * @param callback $callback callback function
  * @param int      $axis     given axis
  *
  * @return NumArray
  *
  * @throws InvalidArgumentException will be thrown, if axis is out of bounds
  *
  * @since 1.0.0
  */
 public static function reduceArray(NumArray $numArray, $callback, $axis)
 {
     if ($axis && $axis >= $numArray->getNDim()) {
         throw new InvalidArgumentException('Axis ' . $axis . ' out of bounds');
     }
     return new NumArray(self::reduceRecursive($numArray->getData(), $callback, $axis));
 }
Ejemplo n.º 2
0
 /**
  * Multiplies an array, NumArray or numeric value to the existing NumArray
  *
  * @param mixed $factor an other int, float, array or NumArray
  *
  * @return $this
  *
  * @api
  * @since 1.0.0
  */
 public function dot($factor)
 {
     if (!$factor instanceof NumArray) {
         $factor = new NumArray($factor);
     }
     $result = Dot::dotArray($this->data, $this->shape, $factor->getData(), $factor->getShape());
     $this->data = $result['data'];
     $this->shape = $result['shape'];
     $this->flushCache();
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Tests NumArray::getData
  */
 public function testGetData()
 {
     $array = [1, 2, 3];
     $numArray = new NumArray($array);
     $this->assertSame($array, $numArray->getData());
 }