Global functions
Complete reference for namespaced functions that proxy to NDArray instance methods and static factories. They mirror the behavior documented on the rest of this API reference.
For full parameter lists, edge cases, and examples, follow the links to the corresponding class methods.
Overview
- Each function delegates to
NDArray; there is no second implementation in PHP. - Binary-style operations take the receiver array as the first argument:
add($a, $b)is the same as$a->add($b). - Canonical list and signatures always match the current
src/Functions.phpin the repository.
The catalogue is split into base, linear algebra, FFT / DCT, and windows sections.
Importing
Import only what you need with use function:
php
<?php
use function PhpMlKit\NDArray\nd_array;
use function PhpMlKit\NDArray\add;
use function PhpMlKit\NDArray\Linalg\matmul;
$a = nd_array([[1, 2], [3, 4]]);
$b = add($a, $a);
$c = matmul($a, $a);You can combine imports from the base namespace and sub-namespaces in one use function block if you prefer.
Base namespace
Array creation and factories
| Function | Maps to | See |
|---|---|---|
nd_array | NDArray::fromArray() | Array Creation — fromArray |
zeros | NDArray::zeros() | Array Creation — zeros |
ones | NDArray::ones() | Array Creation — ones |
full | NDArray::full() | Array Creation — full |
from_buffer | NDArray::fromBuffer() | Array Creation — fromBuffer |
from_bytes | NDArray::fromBytes() | Array Creation — fromBytes |
from_scalar | NDArray::fromScalar() | Array Creation — fromScalar |
zeros_like | NDArray::zerosLike() | Array Creation |
ones_like | NDArray::onesLike() | Array Creation |
full_like | NDArray::fullLike() | Array Creation |
eye | NDArray::eye() | Array Creation — eye |
arange | NDArray::arange() | Array Creation — arange |
linspace | NDArray::linspace() | Array Creation — linspace |
logspace | NDArray::logspace() | Array Creation - logspace |
geomspace | NDArray::geomspace() | Array Creation - geomspace |
meshgrid | NDArray::meshgrid() | Array Creation - meshgrid |
random | NDArray::random() | Array Creation - random |
random_int | NDArray::randomInt() | Array Creation |
randn | NDArray::randn() | Array Creation |
normal | NDArray::normal() | Array Creation - normal |
uniform | NDArray::uniform() | Array Creation - uniform |
tile | NDArray::tile() | Array Manipulation - tile |
repeat | NDArray::repeat() | Array Manipulation - repeat |
copy | $a->copy() | Array Manipulation |
astype | $a->astype() | Array Manipulation |
cast | $a->cast() | Array Manipulation |
Element-wise math and arithmetic
Bitwise and shifts
| Function | Maps to | See |
|---|---|---|
bitand | $a->bitand() | Bitwise Operations – bitand |
bitor | $a->bitor() | Bitwise Operations – bitor |
bitxor | $a->bitxor() | Bitwise Operations – bitxor |
left_shift | $a->leftShift() | Bitwise Operations – left_shift |
right_shift | $a->rightShift() | Bitwise Operations – right_shift |
Clipping and extrema
| Function | Maps to | See |
|---|---|---|
clamp | $a->clamp() | Mathematical Functions – clamp |
clip | $a->clip() | Mathematical Functions – clip |
minimum | $a->minimum() | Mathematical Functions – minimum |
maximum | $a->maximum() | Mathematical Functions – maximum |
sigmoid | $a->sigmoid() | Mathematical Functions – sigmoid |
softmax | $a->softmax() | Mathematical Functions – softmax |
Comparisons
| Function | Maps to | See |
|---|---|---|
eq | $a->eq() | Logic Functions – eq |
ne | $a->ne() | Logic Functions – ne |
gt | $a->gt() | Logic Functions – gt |
gte | $a->gte() | Logic Functions – gte |
lt | $a->lt() | Logic Functions – lt |
lte | $a->lte() | Logic Functions – lte |
Logical (boolean element-wise)
| Function | Maps to | See |
|---|---|---|
and | $a->and() | Logic Functions – and |
or | $a->or() | Logic Functions – or |
not | $a->not() | Logic Functions – not |
xor | $a->xor() | Logic Functions – xor |
Statistics and reductions
| Function | Maps to | See |
|---|---|---|
sum | $a->sum() | Statistics – sum |
mean | $a->mean() | Statistics – mean |
amin | $a->min() | Statistics – min |
amax | $a->max() | Statistics – max |
argmin | $a->argmin() | Sorting & Searching – argmin |
argmax | $a->argmax() | Sorting & Searching – argmax |
sort | $a->sort() | Sorting & Searching – sort |
argsort | $a->argsort() | Sorting & Searching – argsort |
topk | $a->topk() | Sorting & Searching – topk |
product | $a->product() | Statistics – product |
cumsum | $a->cumsum() | Statistics – cumsum |
cumprod | $a->cumprod() | Statistics – cumprod |
var | $a->var() | Statistics – var |
std | $a->std() | Statistics – std |
bincount | $a->bincount() | Statistics – bincount |
Shape, padding, tiling
| Function | Maps to | See |
|---|---|---|
pad | $a->pad() | Array Manipulation – pad |
reshape | $a->reshape() | Array Manipulation – reshape |
transpose | $a->transpose() | Array Manipulation – transpose |
swapaxes | $a->swapaxes() | Array Manipulation – swapaxes |
permute | $a->permute() | Array Manipulation – permute |
mergeaxes | $a->mergeaxes() | Array Manipulation – mergeaxes |
flip | $a->flip() | Array Manipulation – flip |
insertaxis | $a->insertaxis() | Array Manipulation – insertaxis |
flatten | $a->flatten() | Array Manipulation – flatten |
ravel | $a->ravel() | Array Manipulation – ravel |
squeeze | $a->squeeze() | Array Manipulation – squeeze |
expand_dims | $a->expandDims() | Array Manipulation – expandDims |
tile | $a->tile() | Array Manipulation – tile |
repeat | $a->repeat() | Array Manipulation – repeat |
Stacking and splitting
| Function | Maps to | See |
|---|---|---|
concatenate | NDArray::concatenate() | Array Manipulation – concatenate |
stack | NDArray::stack() | Array Manipulation – stack |
vstack | NDArray::vstack() | Array Manipulation – vstack |
hstack | NDArray::hstack() | Array Manipulation – hstack |
split | $a->split() | Array Manipulation – split |
vsplit | $a->vsplit() | Array Manipulation – vsplit |
hsplit | $a->hsplit() | Array Manipulation – hsplit |
Indexing, take/put, selection
| Function | Maps to | See |
|---|---|---|
get | $a->get() | Indexing Routines – get |
set | $a->set() | Indexing Routines – set |
set_at | $a->setAt() | Indexing Routines – setAt |
get_at | $a->getAt() | Indexing Routines – getAt |
take | $a->take() | Indexing Routines – take |
take_along_axis | $a->takeAlongAxis() | Indexing Routines – takeAlongAxis |
put | $a->put() | Indexing Routines – put |
put_along_axis | $a->putAlongAxis() | Indexing Routines – putAlongAxis |
scatter_add | $a->scatterAdd() | Indexing Routines – scatterAdd |
where | NDArray::where() | Indexing Routines – where |
Slicing and assignment
| Function | Maps to | See |
|---|---|---|
slice | $a->slice() | Indexing Routines – slice |
assign | $a->assign() | Indexing Routines – assign |
Linear algebra namespace
Import with:
php
use function PhpMlKit\NDArray\Linalg\norm;
use function PhpMlKit\NDArray\Linalg\matmul;| Function | Maps to | See |
|---|---|---|
norm | $a->norm() | Linear Algebra – norm |
dot | $a->dot() | Linear Algebra – dot |
matmul | $a->matmul() | Linear Algebra – matmul |
einsum | $a->einsum() | Linear Algebra – einsum |
diagonal | $a->diagonal() | Linear Algebra – diagonal |
diag | $a->diag() | Linear Algebra – diag |
trace | $a->trace() | Linear Algebra – trace |
solve | $a->solve() | Linear Algebra – solve |
inv | $a->inv() | Linear Algebra – inv |
det | $a->det() | Linear Algebra – det |
svd | $a->svd() | Linear Algebra – svd |
qr | $a->qr() | Linear Algebra – qr |
eig | $a->eig() | Linear Algebra – eig |
eigvals | $a->eigvals() | Linear Algebra – eigvals |
eigh | $a->eigh() | Linear Algebra – eigh |
eigvalsh | $a->eigvalsh() | Linear Algebra – eigvalsh |
cholesky | $a->cholesky() | Linear Algebra – cholesky |
lstsq | $a->lstsq() | Linear Algebra – lstsq |
least_squares | $a->leastSquares() | Linear Algebra – leastSquares |
pinv | $a->pinv() | Linear Algebra – pinv |
cond | $a->cond() | Linear Algebra – cond |
rank | $a->rank() | Linear Algebra – rank |
FFT and DCT namespace
Import with:
php
use function PhpMlKit\NDArray\Fft\fft;
use function PhpMlKit\NDArray\Fft\ifft;| Function | Maps to | See |
|---|---|---|
fft | $a->fft() | Signal Processing – fft |
ifft | $a->ifft() | Signal Processing – ifft |
fftn | $a->fftn() | Signal Processing – fftn |
ifftn | $a->ifftn() | Signal Processing – ifftn |
rfft | $a->rfft() | Signal Processing – rfft |
irfft | $a->irfft() | Signal Processing – irfft |
fft2 | $a->fft2() | Signal Processing – fft2 |
ifft2 | $a->ifft2() | Signal Processing – ifft2 |
dct | $a->dct() | Signal Processing – dct |
idct | $a->idct() | Signal Processing – idct |
dctn | $a->dctn() | Signal Processing – dctn |
idctn | $a->idctn() | Signal Processing – idctn |
dct2 | $a->dct2() | Signal Processing – dct2 |
idct2 | $a->idct2() | Signal Processing – idct2 |
Window functions namespace
Import with:
php
use function PhpMlKit\NDArray\Windows\hanning;Each function wraps the matching static method on NDArray and returns a Float64 vector of length $m.
| Function | Maps to | See |
|---|---|---|
bartlett | NDArray::bartlett() | Window Functions – bartlett |
blackman | NDArray::blackman() | Window Functions – blackman |
bohman | NDArray::bohman() | Window Functions – bohman |
boxcar | NDArray::boxcar() | Window Functions – boxcar |
hamming | NDArray::hamming() | Window Functions – hamming |
hanning | NDArray::hanning() | Window Functions – hanning |
hann | NDArray::hann() | Window Functions – hann |
kaiser | NDArray::kaiser() | Window Functions – kaiser |
lanczos | NDArray::lanczos() | Window Functions – lanczos |
triang | NDArray::triang() | Window Functions – triang |
See also
- API Reference overview
- NDArray class
- Source:
src/Functions.phpin the package repository
