NdArray::reshape

Reshape an array

Description

SciPhp\NdArray NdArray::reshape( mixed $tuple )

Parameters

$tuple
This parameter can be an array [1, 2, 3] or a tuple of integers (1, 2, 3).

Return Values

The new SciPhp\NdArray

Examples

Example #1: Reshape a 2*3 matrix to 3*2

use SciPhp\NumPhp as np;

// Create a 2*3 matrix
$x np::linspace(166)->reshape(23);

$x->reshape(32);

echo 
$x;

The above example will output:

[[1  2]
 [3  4]
 [5  6]]

See Also