Properties

$rows

$rows : int

The number of rows in the matrix

Type

int

$columns

$columns : int

The number of columns in the matrix

Type

int

$rows

$rows

$columns

$columns

$grid

$grid

$getters

$getters

$functions

$functions

$operations

$operations

Methods

__construct()

__construct(array  $grid) : mixed

Parameters

array $grid

Returns

mixed —

validateRow()

validateRow(int  $row) : int

Validate that a row number is a positive integer

Parameters

int $row

Throws

\Matrix\Exception

Returns

int —

validateColumn()

validateColumn(int  $column) : int

Validate that a column number is a positive integer

Parameters

int $column

Throws

\Matrix\Exception

Returns

int —

getRows()

getRows(int  $row, int  $rowCount = 1) : static

Return a new matrix as a subset of rows from this matrix, starting at row number $row, and $rowCount rows A $rowCount value of 0 will return all rows of the matrix from $row A negative $rowCount value will return rows until that many rows from the end of the matrix

Note that row numbers start from 1, not from 0

Parameters

int $row
int $rowCount

Throws

\Matrix\Exception

Returns

static —

getColumns()

getColumns(int  $column, int  $columnCount = 1) : \Matrix\Matrix

Return a new matrix as a subset of columns from this matrix, starting at column number $column, and $columnCount columns A $columnCount value of 0 will return all columns of the matrix from $column A negative $columnCount value will return columns until that many columns from the end of the matrix

Note that column numbers start from 1, not from 0

Parameters

int $column
int $columnCount

Throws

\Matrix\Exception

Returns

\Matrix\Matrix —

dropRows()

dropRows(int  $row, int  $rowCount = 1) : static

Return a new matrix as a subset of rows from this matrix, dropping rows starting at row number $row, and $rowCount rows A negative $rowCount value will drop rows until that many rows from the end of the matrix A $rowCount value of 0 will remove all rows of the matrix from $row

Note that row numbers start from 1, not from 0

Parameters

int $row
int $rowCount

Throws

\Matrix\Exception

Returns

static —

dropColumns()

dropColumns(int  $column, int  $columnCount = 1) : static

Return a new matrix as a subset of columns from this matrix, dropping columns starting at column number $column, and $columnCount columns A negative $columnCount value will drop columns until that many columns from the end of the matrix A $columnCount value of 0 will remove all columns of the matrix from $column

Note that column numbers start from 1, not from 0

Parameters

int $column
int $columnCount

Throws

\Matrix\Exception

Returns

static —

getValue()

getValue(int  $row, int  $column) : mixed

Return a value from this matrix, from the "cell" identified by the row and column numbers Note that row and column numbers start from 1, not from 0

Parameters

int $row
int $column

Throws

\Matrix\Exception

Returns

mixed —

rows()

rows() : \Generator|\Matrix\Matrix[]|array

Returns a Generator that will yield each row of the matrix in turn as a vector matrix or the value of each cell if the matrix is a column vector

Returns

\Generator|\Matrix\Matrix[]|array —

columns()

columns() : \Generator|\Matrix\Matrix[]|array

Returns a Generator that will yield each column of the matrix in turn as a vector matrix or the value of each cell if the matrix is a row vector

Returns

\Generator|\Matrix\Matrix[]|array —

isSquare()

isSquare() : bool

Identify if the row and column dimensions of this matrix are equal, i.e. if it is a "square" matrix

Returns

bool —

isVector()

isVector() : bool

Identify if this matrix is a vector i.e. if it comprises only a single row or a single column

Returns

bool —

toArray()

toArray() : array

Return the matrix as a 2-dimensional array

Returns

array —

solve()

solve(\Matrix\Matrix  $B) : \Matrix\Matrix

Solve A*X = B.

Parameters

\Matrix\Matrix $B

Right hand side

Throws

\Matrix\Exception

Returns

\Matrix\Matrix —

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

__get()

__get(string  $propertyName) : mixed

Access specific properties as read-only (no setters)

Parameters

string $propertyName

Throws

\Matrix\Exception

Returns

mixed —

__call()

__call(string  $functionName, array  $arguments) : \Matrix\Matrix|float

Returns the result of the function call or operation

Parameters

string $functionName
array $arguments

Throws

\Matrix\Exception

Returns

\Matrix\Matrix|float —

antidiagonal()

antidiagonal() : \Matrix\Matrix

Returns

\Matrix\Matrix —

adjoint()

adjoint() : \Matrix\Matrix

Returns

\Matrix\Matrix —

cofactors()

cofactors() : \Matrix\Matrix

Returns

\Matrix\Matrix —

determinant()

determinant() : float

Returns

float —

diagonal()

diagonal() : \Matrix\Matrix

Returns

\Matrix\Matrix —

identity()

identity() : \Matrix\Matrix

Returns

\Matrix\Matrix —

inverse()

inverse() : \Matrix\Matrix

Returns

\Matrix\Matrix —

pseudoInverse()

pseudoInverse() : \Matrix\Matrix

Returns

\Matrix\Matrix —

minors()

minors() : \Matrix\Matrix

Returns

\Matrix\Matrix —

trace()

trace() : float

Returns

float —

transpose()

transpose() : \Matrix\Matrix

Returns

\Matrix\Matrix —

add()

add(mixed  $matrices) : \Matrix\Matrix

Parameters

mixed $matrices

Returns

\Matrix\Matrix —

subtract()

subtract(mixed  $matrices) : \Matrix\Matrix

Parameters

mixed $matrices

Returns

\Matrix\Matrix —

multiply()

multiply(mixed  $matrices) : \Matrix\Matrix

Parameters

mixed $matrices

Returns

\Matrix\Matrix —

divideby()

divideby(mixed  $matrices) : \Matrix\Matrix

Parameters

mixed $matrices

Returns

\Matrix\Matrix —

divideinto()

divideinto(mixed  $matrices) : \Matrix\Matrix

Parameters

mixed $matrices

Returns

\Matrix\Matrix —

directsum()

directsum(mixed  $matrices) : \Matrix\Matrix

Parameters

mixed $matrices

Returns

\Matrix\Matrix —

buildFromArray()

buildFromArray(array  $grid) : void

Parameters

array $grid

validateRowInRange()

validateRowInRange(int  $row) : int

Validate that a row number falls within the set of rows for this matrix

Parameters

int $row

Throws

\Matrix\Exception

Returns

int —

validateColumnInRange()

validateColumnInRange(int  $column) : int

Validate that a column number falls within the set of columns for this matrix

Parameters

int $column

Throws

\Matrix\Exception

Returns

int —