Methods

Polymorphic constructor

__construct() 

As PHP has no support for polymorphic constructors, we hack 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.

arrayLeftDivide

arrayLeftDivide() : \Matrix

Element-by-element Left division A / B

Returns

\MatrixDivision result

arrayLeftDivideEquals

arrayLeftDivideEquals() : \Matrix

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

Returns

\MatrixMatrix Aij

arrayRightDivide

arrayRightDivide() : \Matrix

Element-by-element right division A / B

Returns

\MatrixDivision result

arrayRightDivideEquals

arrayRightDivideEquals() : \Matrix

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

Returns

\MatrixMatrix Aij

arrayTimes

arrayTimes() : \Matrix

Element-by-element multiplication Cij = Aij * Bij

Returns

\MatrixMatrix Cij

arrayTimesEquals

arrayTimesEquals() : \Matrix

Element-by-element multiplication Aij = Aij * Bij

Returns

\MatrixMatrix Aij

checkMatrixDimensions

checkMatrixDimensions(\Matrix $B) : boolean

Is matrix B the same size?

Parameters

$B

\Matrix

Matrix B

Returns

boolean

concat

concat() : \Matrix

A = A & B

Returns

\MatrixSum

det

det() : float

Calculate determinant

Returns

floatDeterminant

diagonal

diagonal(int $m, int $n, mixed $c) : \Matrix

Generate a diagonal matrix

Parameters

$m

int

Row dimension

$n

int

Column dimension

$c

mixed

Diagonal value

Returns

\MatrixDiagonal matrix

get

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

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

Parameters

$i

int

Row position

$j

int

Column position

Returns

mixedElement (int/float/double)

getArray

getArray() : array

Returns

arrayMatrix array

getColumnDimension

getColumnDimension() : int

Returns

intColumn dimension

getMatrix

getMatrix() : \Matrix

Get a submatrix

Returns

\MatrixSubmatrix

getMatrixByCol

getMatrixByCol($j0, $jF) : \Matrix

Get a submatrix by column index/range

Parameters

$j0

$jF

Returns

\MatrixSubmatrix

getMatrixByRow

getMatrixByRow(int $i0, int $iF) : \Matrix

Get a submatrix by row index/range

Parameters

$i0

int

Initial row index

$iF

int

Final row index

Returns

\MatrixSubmatrix

getRowDimension

getRowDimension() : int

Returns

intRow dimension

identity

identity(int $m, int $n) : \Matrix

Generate an identity matrix.

Parameters

$m

int

Row dimension

$n

int

Column dimension

Returns

\MatrixIdentity matrix

Matrix inverse or pseudoinverse.

inverse() : \Matrix

Returns

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

minus

minus() : \Matrix

A - B

Returns

\MatrixSum

minusEquals

minusEquals() : \Matrix

A = A - B

Returns

\MatrixSum

plus

plus() : \Matrix

A + B

Returns

\MatrixSum

plusEquals

plusEquals() : \Matrix

A = A + B

Returns

\MatrixSum

power

power() : \Matrix

A = A ^ B

Returns

\MatrixSum

set

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

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

Parameters

$i

int

Row position

$j

int

Column position

$c

mixed

Int/float/double value

Returns

mixedElement (int/float/double)

Solve A*X = B.

solve(\Matrix $B) : \Matrix

Parameters

$B

\Matrix

Right hand side

Returns

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

times

times() : \Matrix

Matrix multiplication

Returns

\MatrixProduct

trace

trace() : float

Sum of diagonal elements

Returns

floatSum of diagonal elements

transpose

transpose() : \Matrix

Tranpose matrix

Returns

\MatrixTransposed matrix

uminus

uminus() : \Matrix

Unary minus matrix -A

Returns

\MatrixUnary minus matrix

 Properties

 

$A : array
access public
 

$m : int
access private
 

$n : int
access private

 Constants

 

ArgumentBoundsException

ArgumentBoundsException 
 

ArgumentTypeException

ArgumentTypeException 
 

ArrayLengthException

ArrayLengthException 
 

MatrixDimensionException

MatrixDimensionException 
 

PolymorphicArgumentException

PolymorphicArgumentException