PHP Class NumPHP\Core\NumArray

Since: 1.0.0
Author: Gordon Lesti ([email protected])
Inheritance: extends NumPHP\Core\Cache
Show file Open project: numphp/numphp Class Usage Examples

Protected Properties

Property Type Description
$data array | mixed The data of the NumArray
$shape array The shape of the NumArray

Public Methods

Method Description
__construct ( mixed $data ) Creates an new NumArray
__toString ( ) : string Returns a string representing the NumArray
abs ( ) Applies abs on every value of the NumArray
add ( mixed $addend ) Adds an array, NumArray or numeric value to the existing NumArray
div ( mixed $divisor ) Divides the NumArray with a divisor
dot ( mixed $factor ) Multiplies an array, NumArray or numeric value to the existing NumArray
get ( ) : NumArray Returns a sliced part the NumArray
getData ( ) : mixed Returns the data of the NumArray
getNDim ( ) : integer Returns the number of axis (dimensions) the NumArray
getShape ( ) : array Returns the dimensions of the NumArray
getSize ( ) : integer Returns the number of elements the NumArray
getTranspose ( ) : NumArray Returns the transposed NumArray
max ( integer $axis = null ) : NumArray Returns the max of the NumArray for the given axis
mean ( integer $axis = null ) : NumArray Returns the mean of the NumArray for the given axis
min ( integer $axis = null ) : NumArray Returns the min of the NumArray for the given axis
mult ( mixed $factor ) Multiplies the NumArray with a factor
reshape ( ) : NumArray Reshapes the NumArray
set ( ) Replaces a value or complete parts in the NumArray. The new value is always the last argument
sub ( mixed $subtrahend ) Subtracts an array, NumArray or numeric value from the existing NumArray
sum ( integer $axis = null ) : NumArray Summed all elements of an NumArray for the given axis

Method Details

__construct() public method

Creates an new NumArray
Since: 1.0.0
public __construct ( mixed $data )
$data mixed given data

__toString() public method

Returns a string representing the NumArray
Since: 1.0.0
public __toString ( ) : string
return string

abs() public method

Applies abs on every value of the NumArray
Since: 1.0.0
public abs ( )

add() public method

Adds an array, NumArray or numeric value to the existing NumArray
Since: 1.0.0
public add ( mixed $addend )
$addend mixed an other int, float, array or NumArray

div() public method

Divides the NumArray with a divisor
Since: 1.0.4
public div ( mixed $divisor )
$divisor mixed divisor

dot() public method

Multiplies an array, NumArray or numeric value to the existing NumArray
Since: 1.0.0
public dot ( mixed $factor )
$factor mixed an other int, float, array or NumArray

get() public method

Returns a sliced part the NumArray
Since: 1.0.0
public get ( ) : NumArray
return NumArray

getData() public method

Returns the data of the NumArray
Since: 1.0.0
public getData ( ) : mixed
return mixed

getNDim() public method

Returns the number of axis (dimensions) the NumArray
Since: 1.0.0
public getNDim ( ) : integer
return integer

getShape() public method

Returns the dimensions of the NumArray
Since: 1.0.0
public getShape ( ) : array
return array

getSize() public method

Returns the number of elements the NumArray
Since: 1.0.0
public getSize ( ) : integer
return integer

getTranspose() public method

Returns the transposed NumArray
Since: 1.0.0
public getTranspose ( ) : NumArray
return NumArray

max() public method

Returns the max of the NumArray for the given axis
Since: 1.0.0
public max ( integer $axis = null ) : NumArray
$axis integer given axis of max
return NumArray

mean() public method

Returns the mean of the NumArray for the given axis
Since: 1.0.0
public mean ( integer $axis = null ) : NumArray
$axis integer given axis of mean
return NumArray

min() public method

Returns the min of the NumArray for the given axis
Since: 1.0.0
public min ( integer $axis = null ) : NumArray
$axis integer given axis of min
return NumArray

mult() public method

Multiplies the NumArray with a factor
Since: 1.0.4
public mult ( mixed $factor )
$factor mixed factor

reshape() public method

Reshapes the NumArray
Since: 1.0.0
public reshape ( ) : NumArray
return NumArray

set() public method

Replaces a value or complete parts in the NumArray. The new value is always the last argument
Since: 1.0.0
public set ( )

sub() public method

Subtracts an array, NumArray or numeric value from the existing NumArray
Since: 1.0.0
public sub ( mixed $subtrahend )
$subtrahend mixed an other int, float, array or NumArray

sum() public method

Summed all elements of an NumArray for the given axis
Since: 1.0.0
public sum ( integer $axis = null ) : NumArray
$axis integer given axis of sum
return NumArray

Property Details

$data protected property

The data of the NumArray
protected array|mixed $data
return array | mixed

$shape protected property

The shape of the NumArray
protected array $shape
return array