NumPhp::arange

Create a range of values based on a step.

Description

SciPhp\NdArray NumPhp::arange( mixed $start [, mixed $stop ] [, mixed $step = 1 ])

This range does not contain the maximum value.

Parameters

$start
A float or an integer.
$stop
A float or an integer.
$step
A float or an integer.

Return Values

The new SciPhp\NdArray

Examples

Example #1: Creating a range of integers

use SciPhp\NumPhp as np;

$x np::arange(15);

echo 
$x;

The above example will output:

[1  2  3  4]

Example #2: Creating a range with a short call

use SciPhp\NumPhp as np;

$x1 np::arange(5);
$x2 np::arange(-5);

echo 
"x1\n$x1""x2\n$x2";

The above example will output:

x1
[0  1  2  3  4]
x2
[-5  -4  -3  -2  -1]

Example #3: Creating a range of float numbers

use SciPhp\NumPhp as np;

$x np::arange(120.2);

echo 
$x;

The above example will output:

[1    1.2  1.4  1.6  1.8]

Example #4: Creating a decreasing range of float numbers

use SciPhp\NumPhp as np;

$x np::arange(210.2);

echo 
$x;

The above example will output:

[2    1.8  1.6  1.4  1.2]

See Also