NumPhp
final class NumPhp extends Decorator (View source)
Entry point for np calls.
Traits
Methods
Construct a diagonal array
Create a two-dimensional array with the flattened input as a diagonal.
Fill a line among diagonal, offset and indexes
The non-negative square-root of an array, element-wise.
Load data from a text file.
Returns element-wise true where signbit is set (less than zero).
Change the sign of m-element to that of n-element, element-wise.
Creates a NdArray with null as default value 'empty' can not be used in PHP
Creates a NdArray with a default value
Construct a n-dim array with a default value
Construct a new array of nulls with the same shape and type as a given array.
Construct a new array of zeros with the same shape and type as a given array.
Construct a new array of ones with the same shape and type as a given array.
Construct a new array with the same shape and type as a given array, filled with a given value
Creates a NdArray with a range of values
No description
Creates a NdArray with a range of values
Fill zeros from first item to a position
Fill zeros from a position to the end of the array
Construct an array with ones at and below the given diagonal and zeros elsewhere
Return a closure that fill a line item with ones
Parse args as a tuple or an array
Transform a PHP array in a NdArray
Check that all values are numeric
Details
final static
reciprocal(NdArray|array|float|int $m)
Return the reciprocal of the argument, element-wise.
final static
subtract(NdArray|array|float|int $m, NdArray|array|float|int $n)
Subtract a matrix from matrix
final static NdArray|int|float
add(NdArray|array|int|float $m, NdArray|array|int|float $n)
Add two array_like
final static NdArray|float|int
divide(NdArray|array|float|int $m, NdArray|array|float|int $n)
Divide two arrays, element-wise
final static NdArray|float|int
multiply(NdArray|array|float|int $m, NdArray|array|float|int $n)
Multiply two arrays, element-wise
final static NdArray|float|int
dot(NdArray|array|float|int $m, NdArray|array|float|int $n)
Dot product of two arrays
final static protected callable
colDot($row_m, NdArray $m, NdArray $n)
Browse p cols and sum products
final static int|float|array
trace(NdArray|array $m, int $k = 0)
Sum along diagonals
final static NdArray
identity(int $n)
Construct an identity array
final static NdArray
eye(int $rows, int $cols = 0, int $k = 0)
Construct a diagonal array
final static NdArray
diag(array|NdArray $m, int $k = 0)
Extract a diagonal or construct a diagonal array
final static NdArray
diagflat(mixed $m, int $k = 0)
Create a two-dimensional array with the flattened input as a diagonal.
final static protected NdArray
fromDiagonal(array $diagonal, int $k)
Construct a diagonal array
final static protected callable
itemFromDiagonal(int $col, array $diagonal, int $k, int $line = 1)
Fill a line among diagonal, offset and indexes
final static NdArray|int|float
exp(NdArray|array|int|float $m)
Calculate the exponential of all elements in the input array.
final static NdArray|int|float
expm1(NdArray|array|int|float $m)
Calculate exp(x) - 1 for all elements in the array.
final static NdArray|int|float
exp2(NdArray|array|int|float $m)
Calculate 2**p for all p in the input array.
final static
power(float|int|array|NdArray $matrix, float|int $exponent)
Matrix elements raised to powers.
final static float|int|NdArray
square(float|int|array|NdArray $matrix)
The element-wise square of the input.
final static NdArray
sqrt($matrix)
The non-negative square-root of an array, element-wise.
final static LinAlg
linalg()
Loads Linear Algebra extension
final static Random
random()
Loads Random generator extension
final static NdArray
loadtxt(string $file, array $options = [])
Load data from a text file.
final static NdArray|bool
signbit(NdArray|array|int|float $m)
Returns element-wise true where signbit is set (less than zero).
final static NdArray|int|float
copysign(NdArray|array|int|float $m, NdArray|array|int|float $n)
Change the sign of m-element to that of n-element, element-wise.
final static NdArray|int|float
log(NdArray|array|int|float $m, int|float $base = M_E)
Natural logarithm, element-wise.
final static NdArray|int|float
tan(NdArray|array|int|float $m)
Compute tangent element-wise.
Equivalent to np::sin(x)->divide(np::cos(x)) element-wise.
final static bool
is_square(NdArray|array $m)
Is given matrix a square matrix ?
final static NdArray|int|float
negative(NdArray|array|int|float $m)
Numerical negative, element-wise.
final static NdArray
zeros()
Creates a NdArray with zero as default value
final static NdArray
ones()
Creates a NdArray with one as default value
final static NdArray
nulls()
Creates a NdArray with null as default value 'empty' can not be used in PHP
final static NdArray
full(array $shape, mixed $value)
Creates a NdArray with a default value
final static protected mixed|array
createArray(array $params, mixed $value)
Construct a n-dim array with a default value
final static NdArray
nulls_like(array|NdArray $matrix)
Construct a new array of nulls with the same shape and type as a given array.
final static NdArray
zeros_like(array|NdArray $matrix)
Construct a new array of zeros with the same shape and type as a given array.
final static NdArray
ones_like(array|NdArray $matrix)
Construct a new array of ones with the same shape and type as a given array.
final static NdArray
full_like(array|NdArray $matrix, $value = null)
Construct a new array with the same shape and type as a given array, filled with a given value
final static NdArray
broadcast_to(array|NdArray $matrix, array $shape)
Broadcast an array to a new shape.
final static int|float|NdArray
sum(NdArray|array|int|float $m, int|null $axis = null, bool $keepdims = false)
Sum all elements.
final static int|float|array
trapz(NdArray|array $m)
Integrate along the given axis using the composite trapezoidal rule.
final static NdArray
arange(int|float $start, int|float $end = null, int|float $step = 1)
Creates a NdArray with a range of values
final static
linspace($start, $end, int $num = 50, bool $endpoint = true, bool $retstep = false)
final static NdArray
logspace(int|float $start, int|float $end, int $num = 50, bool $endpoint = true, float $base = 10)
Creates a NdArray with a range of values
final static protected callable
itemTriu(int $col, int $k, int $count, int $line = 1)
Fill zeros from first item to a position
final static protected callable
itemTril(int $col, int $k, int $count, int $line = 1)
Fill zeros from a position to the end of the array
final static NdArray
tri(int $rows, int $cols = null, int $k = 0)
Construct an array with ones at and below the given diagonal and zeros elsewhere
final static protected callable
itemTri(int $col, int $k, int $maxCols, int|null $line = 1)
Return a closure that fill a line item with ones
final static protected callable
itemVander(int $num)
Apply decreasing power on each row values
static NdArray
ar(array $data, string|null $identifier = null)
Construct a n-dimensional array
static array
parseArgs(array $args)
Parse args as a tuple or an array
static void
transform(array|NdArray $m, bool $required = false)
Transform a PHP array in a NdArray
static bool
allNumeric()
Check that all values are numeric