NumPHP\Core\NumArray::reshape PHP Метод

reshape() публичный Метод

Reshapes the NumArray
С версии: 1.0.0
public reshape ( ) : NumArray
Результат NumArray
    public function reshape()
    {
        if (!is_array($this->data)) {
            throw new BadMethodCallException('NumArray data is not an array');
        }
        $args = func_get_args();
        $this->data = Shape::reshape($this->data, $this->getShape(), $args);
        $this->shape = $args;
        $this->flushCache();
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Tests NumArray::reshape with matrix 3x4 to matrix 2x6
  */
 public function testReshape3x4To2x6()
 {
     $numArray = new NumArray([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]);
     $expectedNumArray = new NumArray([[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]);
     $this->assertNumArrayEquals($expectedNumArray, $numArray->reshape(2, 6));
 }