Create a range with a defined number of values.
SciPhp\NdArray
NumPhp::linspace(
mixed
$start
,
mixed
$stop
[,
int
$num = 50
]
[,
bool
$endpoint = true
])
$start
$stop
$num
$endpoint
The new SciPhp\NdArray
use SciPhp\NumPhp as np;
$x = np::linspace(1, 50);
echo $x;
The above example will output:
[1 2 3 ... 48 49 50]
The default number of values is 50
use SciPhp\NumPhp as np;
$x = np::linspace(1, 2, 9);
echo $x;
The above example will output:
[1 1.125 1.25 1.375 1.5 1.625 1.75 1.875 2 ]
use SciPhp\NumPhp as np;
$x = np::linspace(1, 2, 10, false);
echo $x;
The above example will output:
[1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9]