Constants

POLYMORPHIC_ARGUMENT_EXCEPTION

POLYMORPHIC_ARGUMENT_EXCEPTION = 'Invalid argument pattern for polymorphic function.'

ARGUMENT_TYPE_EXCEPTION

ARGUMENT_TYPE_EXCEPTION = 'Invalid argument type.'

ARGUMENT_BOUNDS_EXCEPTION

ARGUMENT_BOUNDS_EXCEPTION = 'Invalid argument range.'

MATRIX_DIMENSION_EXCEPTION

MATRIX_DIMENSION_EXCEPTION = 'Matrix dimensions are not equal.'

ARRAY_LENGTH_EXCEPTION

ARRAY_LENGTH_EXCEPTION = 'Array length must be a multiple of m.'

MATRIX_SPD_EXCEPTION

MATRIX_SPD_EXCEPTION = 'Can only perform operation on symmetric positive definite matrix.'

Properties

$A

$A : array

Matrix storage.

Type

array

$m

$m : int

Matrix row dimension.

Type

int

$n

$n : int

Matrix column dimension.

Type

int

Methods

__construct()

__construct(mixed  ...$args) : mixed

Polymorphic constructor.

As PHP has no support for polymorphic constructors, we use tricks to make our own sort of polymorphism using func_num_args, func_get_arg, and gettype. In essence, we're just implementing a simple RTTI filter and calling the appropriate constructor.

Parameters

mixed $args variadic

Returns

mixed —

getArray()

getArray() : array

getArray.

Returns

array —

Matrix array

getRowDimension()

getRowDimension() : int

getRowDimension.

Returns

int —

Row dimension

getColumnDimension()

getColumnDimension() : int

getColumnDimension.

Returns

int —

Column dimension

get()

get(int  $i = null, int  $j = null) : mixed

get.

Get the i,j-th element of the matrix.

Parameters

int $i

Row position

int $j

Column position

Returns

mixed —

Element (int/float/double)

getMatrix()

getMatrix(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

getMatrix.

Get a submatrix

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Submatrix

checkMatrixDimensions()

checkMatrixDimensions(\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix  $B = null) : bool

checkMatrixDimensions.

Is matrix B the same size?

Parameters

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix $B

Matrix B

Returns

bool —

set()

set(int  $i = null, int  $j = null, mixed  $c = null) : mixed

set.

Set the i,j-th element of the matrix.

Parameters

int $i

Row position

int $j

Column position

mixed $c

Int/float/double value

Returns

mixed —

Element (int/float/double)

identity()

identity(int  $m = null, int  $n = null) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

identity.

Generate an identity matrix.

Parameters

int $m

Row dimension

int $n

Column dimension

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Identity matrix

diagonal()

diagonal(int  $m = null, int  $n = null, mixed  $c = 1) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

diagonal.

Generate a diagonal matrix

Parameters

int $m

Row dimension

int $n

Column dimension

mixed $c

Diagonal value

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Diagonal matrix

getMatrixByRow()

getMatrixByRow(int  $i0 = null, int  $iF = null) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

getMatrixByRow.

Get a submatrix by row index/range

Parameters

int $i0

Initial row index

int $iF

Final row index

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Submatrix

getMatrixByCol()

getMatrixByCol(int  $j0 = null, int  $jF = null) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

getMatrixByCol.

Get a submatrix by column index/range

Parameters

int $j0

Initial column index

int $jF

Final column index

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Submatrix

transpose()

transpose() : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

transpose.

Tranpose matrix

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Transposed matrix

trace()

trace() : float

trace.

Sum of diagonal elements

Returns

float —

Sum of diagonal elements

uminus()

uminus() : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

uminus.

Unary minus matrix -A

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Unary minus matrix

plus()

plus(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

plus.

A + B

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Sum

plusEquals()

plusEquals(mixed  ...$args) : $this

plusEquals.

A = A + B

Parameters

mixed $args variadic

Returns

$this —

minus()

minus(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

minus.

A - B

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Sum

minusEquals()

minusEquals(mixed  ...$args) : $this

minusEquals.

A = A - B

Parameters

mixed $args variadic

Returns

$this —

arrayTimes()

arrayTimes(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

arrayTimes.

Element-by-element multiplication Cij = Aij * Bij

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Matrix Cij

arrayTimesEquals()

arrayTimesEquals(mixed  ...$args) : $this

arrayTimesEquals.

Element-by-element multiplication Aij = Aij * Bij

Parameters

mixed $args variadic

Returns

$this —

arrayRightDivide()

arrayRightDivide(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

arrayRightDivide.

Element-by-element right division A / B

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Division result

arrayRightDivideEquals()

arrayRightDivideEquals(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

arrayRightDivideEquals.

Element-by-element right division Aij = Aij / Bij

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Matrix Aij

arrayLeftDivide()

arrayLeftDivide(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

arrayLeftDivide.

Element-by-element Left division A / B

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Division result

arrayLeftDivideEquals()

arrayLeftDivideEquals(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

arrayLeftDivideEquals.

Element-by-element Left division Aij = Aij / Bij

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Matrix Aij

times()

times(mixed  ...$args) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

times.

Matrix multiplication

Parameters

mixed $args variadic

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

Product

power()

power(mixed  ...$args) : $this

power.

A = A ^ B

Parameters

mixed $args variadic

Returns

$this —

concat()

concat(mixed  ...$args) : $this

concat.

A = A & B

Parameters

mixed $args variadic

Returns

$this —

solve()

solve(\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix  $B) : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

Solve A*X = B.

Parameters

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix $B

Right hand side

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

... Solution if A is square, least squares solution otherwise

inverse()

inverse() : \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix

Matrix inverse or pseudoinverse.

Returns

\PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix —

... Inverse(A) if A is square, pseudoinverse otherwise.

det()

det() : float

det.

Calculate determinant

Returns

float —

Determinant