Np

vector extends nd
in package
Uses ops, linAlg

A fast lite memory efficient Scientific Computing in php Vector (rank-1)

Tags
version

V0.0.1

category

Scientific Library for PHP

author

ghost (Shubham Chaudhary)

email

ghost.jat@gmail.com

copyright

(c) 2020-2021, Shubham Chaudhary

Table of Contents

DOUBLE  = 2
EPSILON  = 1.0E-8
FLOAT  = 1
INT  = 3
TWO_PI  = 2.0 * M_PI
$data  : mixed
$_mem  : mixed
$_time  : mixed
__toString()  : mixed
abs()  : matrix|vector
acos()  : matrix|vector
add()  : matrix|vector
ar()  : vector
Build a new vector from a php array.
argMax()  : int
Return the index of the maximum element in the vector.
argMin()  : int
Return the index of the minimum element in the vector.
asArray()  : mixed
asin()  : matrix|vector
atan()  : matrix|vector
ceil()  : matrix|vector
checkDimensions()  : mixed
checkDtype()  : mixed
checkShape()  : mixed
clip()  : matrix
Clip the elements in the matrix to be between given minimum and maximum and return a new matrix.
clipLower()  : matrix
Clip the matrix|vector to be lower bounded by a given minimum.
clipUpper()  : matrix
Clip the matrix|vector to be upper bounded by a given maximum.
convolve()  : vector
copy()  : matrix|vector
make a copy of matrix|vector;
cos()  : matrix|vector
degToRad()  : matrix|vector
divide()  : matrix|vector
dot()  : matrix|vector
get dot product of m.m | m.v | v.v
dotMatrix()  : vector
Compute the vector-matrix dot product of this vector and matrix .
exp()  : matrix|vector
exp1()  : matrix|vector
factory()  : vector
Factory method to build a new vector.
floor()  : matrix|vector
free()  : void
full()  : vector
create a vector with given scalar value
gaussian()  : self
Return a Gaussian random vector with mean 0 and unit variance.
getDtype()  : mixed
getMemory()  : mixed
set memory dog, get total memory
getSize()  : int
get the size of vector
inner()  : mixed
Return the inner product of two vectors.
inverse()  : matrix|null
FIXEME:-Bug noticed on 10/06/21 Compute the multiplicative inverse of the matrix.
linspace()  : vector
Return a vector of n evenly spaced numbers between minimum and maximum.
log()  : matrix|vector
log1p()  : matrix|vector
map()  : matrix|vector
Run a function over all of the elements in the matrix|vector.
max()  : mixed
mean()  : int|float
median()  : int|float
min()  : mixed
mod()  : matrix|vector
multiply()  : matrix|vector
normL1()  : float
Calculate the L1 norm of the vector.
normL2()  : mixed
normMax()  : mixed
normP()  : mixed
null()  : vector
create a null like vector
ones()  : vector
create one like vector
poisson()  : vector
Generate a vector with n elements from a Poisson distribution.
pow()  : matrix|vector
printVector()  : mixed
product()  : int|float
Return the product of the vector.
pseudoInverse()  : matrix|null
FIXEME:-Bug noticed on 10/06/21 Compute the (Moore-Penrose) pseudo inverse of the general matrix.
radToDeg()  : matrix|vector
randn()  : vector
Return vector with random values
range()  : vector
Return evenly spaced values within a given interval.
reciprocal()  : self
Return the reciprocal of the vector element-wise.
reshape()  : matrix
return a reshaped data buffer as matrix
setData()  : mixed
set data to vector
sin()  : matrix|vector
sort()  : mixed
sort the vector
sqrt()  : matrix|vector
square()  : vector
subtract()  : matrix|vector
sum()  : float
The sum of the vector.
tan()  : matrix|vector
time()  : mixed
set Timer, get total time
uniform()  : vector
Return vector with uniform values
variance()  : mixed
zeros()  : vector
Build a vector of zeros with n elements.
__construct()  : mixed
_dimensionaMisMatchErr()  : dimensionalityMismatch
_dtypeErr()  : dtypeException
_err()  : runtimeException
_invalidArgument()  : invalidArgumentException
_ndDouble()  : mixed
_ndFloat()  : mixed
_ndInt()  : mixed
addMatrix()  : matrix
addScalar()  : vector
addVector()  : vector
divideMatrix()  : matrix
divideScalar()  : vector
divideVector()  : vector
dotVector()  : vector
get dot product of matrix & a vector
modMatrix()  : matrix
modScalar()  : mixed
modVector()  : vector
multiplyMatrix()  : matrix
multiplyScalar()  : vector
multiplyVector()  : vector
powMatrix()  : matrix
powScalar()  : vector
powVector()  : vector
substractScalar()  : vector
subtractMatrix()  : matrix
subtractVector()  : vector

Constants

DOUBLE

public mixed DOUBLE = 2

EPSILON

public mixed EPSILON = 1.0E-8

FLOAT

public mixed FLOAT = 1

INT

public mixed INT = 3

TWO_PI

public mixed TWO_PI = 2.0 * M_PI

Properties

$data

public mixed $data

$_mem

protected mixed $_mem = null

$_time

protected mixed $_time = null

Methods

__toString()

public __toString() : mixed
Return values
mixed

ar()

Build a new vector from a php array.

public static ar(array<string|int, mixed> $data[, int $dtype = self::FLOAT ]) : vector
Parameters
$data : array<string|int, mixed>
$dtype : int = self::FLOAT
Return values
vector

argMax()

Return the index of the maximum element in the vector.

public argMax() : int
Return values
int

argMin()

Return the index of the minimum element in the vector.

public argMin() : int
Return values
int

asArray()

public asArray() : mixed
Return values
mixed

clip()

Clip the elements in the matrix to be between given minimum and maximum and return a new matrix.

public clip(float $min, float $max) : matrix
Parameters
$min : float
$max : float
Return values
matrix

clipLower()

Clip the matrix|vector to be lower bounded by a given minimum.

public clipLower(float $min) : matrix
Parameters
$min : float
Return values
matrix

clipUpper()

Clip the matrix|vector to be upper bounded by a given maximum.

public clipUpper(float $max) : matrix
Parameters
$max : float
Return values
matrix

dotMatrix()

Compute the vector-matrix dot product of this vector and matrix .

public dotMatrix(matrix $m) : vector
Parameters
$m : matrix
Return values
vector

factory()

Factory method to build a new vector.

public static factory(int $col[, int $dtype = self::FLOAT ]) : vector
Parameters
$col : int
$dtype : int = self::FLOAT
Return values
vector

free()

public free() : void
Return values
void

full()

create a vector with given scalar value

public static full(int $col, int|float $val[, int $dtype = self::FLOAT ]) : vector
Parameters
$col : int
$val : int|float
$dtype : int = self::FLOAT
Return values
vector

gaussian()

Return a Gaussian random vector with mean 0 and unit variance.

public static gaussian(int $n[, int $dtype = self::FLOAT ]) : self
Parameters
$n : int
$dtype : int = self::FLOAT
Return values
self

getDtype()

public getDtype() : mixed
Return values
mixed

getMemory()

set memory dog, get total memory

public getMemory() : mixed
Return values
mixed

getSize()

get the size of vector

public getSize() : int
Return values
int

inner()

Return the inner product of two vectors.

public inner(vector $vector) : mixed
Parameters
$vector : vector
Return values
mixed

inverse()

FIXEME:-Bug noticed on 10/06/21 Compute the multiplicative inverse of the matrix.

public inverse() : matrix|null
Return values
matrix|null

linspace()

Return a vector of n evenly spaced numbers between minimum and maximum.

public static linspace(float $min, float $max, int $n[, int $dtype = self::FLOAT ]) : vector
Parameters
$min : float
$max : float
$n : int
$dtype : int = self::FLOAT
Tags
throws
invalidArgumentException
Return values
vector

map()

Run a function over all of the elements in the matrix|vector.

public map(callable $func) : matrix|vector
Parameters
$func : callable
Return values
matrix|vector

max()

public max() : mixed
Return values
mixed

mean()

public mean() : int|float
Return values
int|float

median()

public median() : int|float
Return values
int|float

min()

public min() : mixed
Return values
mixed

normL1()

Calculate the L1 norm of the vector.

public normL1() : float
Return values
float

normL2()

public normL2() : mixed
Return values
mixed

normMax()

public normMax() : mixed
Return values
mixed

normP()

public normP([float $p = 2.5 ]) : mixed
Parameters
$p : float = 2.5
Return values
mixed

null()

create a null like vector

public static null(int $col[, int $dtype = self::FLOAT ]) : vector
Parameters
$col : int
$dtype : int = self::FLOAT
Return values
vector

ones()

create one like vector

public static ones(int $col[, int $dtype = self::FLOAT ]) : vector
Parameters
$col : int
$dtype : int = self::FLOAT
Return values
vector

poisson()

Generate a vector with n elements from a Poisson distribution.

public static poisson(int $n[, float $lambda = 1.0 ][, int $dtype = self::FLOAT ]) : vector
Parameters
$n : int
$lambda : float = 1.0
$dtype : int = self::FLOAT
Return values
vector

printVector()

public printVector() : mixed
Return values
mixed

product()

Return the product of the vector.

public product() : int|float
Return values
int|float

pseudoInverse()

FIXEME:-Bug noticed on 10/06/21 Compute the (Moore-Penrose) pseudo inverse of the general matrix.

public pseudoInverse() : matrix|null
Return values
matrix|null

randn()

Return vector with random values

public static randn(int $col[, int $dtype = self::FLOAT ]) : vector
Parameters
$col : int
$dtype : int = self::FLOAT
Return values
vector

range()

Return evenly spaced values within a given interval.

public static range(int|float $start, int|float $end[, int|float $interval = 1 ][, int $dtype = self::FLOAT ]) : vector
Parameters
$start : int|float
$end : int|float
$interval : int|float = 1
$dtype : int = self::FLOAT
Return values
vector

reciprocal()

Return the reciprocal of the vector element-wise.

public reciprocal() : self
Return values
self

reshape()

return a reshaped data buffer as matrix

public reshape(int $row, int $col) : matrix
Parameters
$row : int
$col : int
Return values
matrix

setData()

set data to vector

public setData(int|float|array<string|int, mixed> $data) : mixed
Parameters
$data : int|float|array<string|int, mixed>
Return values
mixed

sort()

sort the vector

public sort([string $type = 'i' ]) : mixed
Parameters
$type : string = 'i'

i or d

Return values
mixed

sum()

The sum of the vector.

public sum() : float
Return values
float

time()

set Timer, get total time

public time() : mixed
Return values
mixed

uniform()

Return vector with uniform values

public static uniform(int $col[, int $dtype = self::FLOAT ]) : vector
Parameters
$col : int
$dtype : int = self::FLOAT
Return values
vector

variance()

public variance([mixed $mean = null ]) : mixed
Parameters
$mean : mixed = null
Return values
mixed

zeros()

Build a vector of zeros with n elements.

public static zeros(int $col[, int $dtype = self::FLOAT ]) : vector
Parameters
$col : int
$dtype : int = self::FLOAT
Return values
vector

__construct()

protected __construct(int $col[, int $dtype = self::FLOAT ]) : mixed
Parameters
$col : int
$dtype : int = self::FLOAT
Return values
mixed

_ndDouble()

protected static _ndDouble(int $size) : mixed
Parameters
$size : int
Return values
mixed

_ndFloat()

protected static _ndFloat(int $size) : mixed
Parameters
$size : int
Return values
mixed

_ndInt()

protected static _ndInt(int $size) : mixed
Parameters
$size : int
Return values
mixed

addScalar()

protected addScalar(int|float $s) : vector
Parameters
$s : int|float
Return values
vector

divideScalar()

protected divideScalar(int|float $s) : vector
Parameters
$s : int|float
Return values
vector

modScalar()

protected modScalar(int|float $s) : mixed
Parameters
$s : int|float
Return values
mixed

multiplyScalar()

protected multiplyScalar(int|float $s) : vector
Parameters
$s : int|float
Return values
vector

powScalar()

protected powScalar(int|float $s) : vector
Parameters
$s : int|float
Return values
vector

Search results