NdArray::resize

Resize an array

Description

SciPhp\NdArray NdArray::resize( 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: Resize a range to a 3*3 matrix

use SciPhp\NumPhp as np;

$x np::ar([123])->resize(33);

print 
$x;

The above example will output:

[[1  2  3]
 [1  2  3]
 [1  2  3]]

Example #2: Resize a 3*3 matrix to 2*2

use SciPhp\NumPhp as np;

$x np::ar([123])->resize(33);

print 
$x->resize(22);

The above example will output:

[[1  2]
 [3  1]]

See Also