NdArray::copy

Copy an array

Description

SciPhp\NdArray NdArray::copy()

Parameters

This function has no parameters.

Return Values

The new SciPhp\NdArray

Examples

Example #1: Copy a matrix

use SciPhp\NumPhp as np;

$x = np::linspace(1, 6, 6)->resize(3, 3);
$y = $x->copy()->resize(2, 6);

echo 
"x\n$x", "y\n$y";

The above example will output:

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

See Also