Properties

$rows

$rows : integer

The number of rows in the matrix

Type

integer

$columns

$columns : integer

The number of columns in the matrix

Type

integer

$rows

$rows : 

Type

$columns

$columns : 

Type

$grid

$grid : 

Type

$getters

$getters : 

Type

$functions

$functions : 

Type

$operations

$operations : 

Type

Methods

__construct()

__construct(array  $grid) 

Parameters

array $grid

validateRow()

validateRow(integer  $row) : integer

Validate that a row number is a positive integer

Parameters

integer $row

Throws

\Matrix\Exception

Returns

integer

validateColumn()

validateColumn(integer  $column) : integer

Validate that a column number is a positive integer

Parameters

integer $column

Throws

\Matrix\Exception

Returns

integer

getRows()

getRows(integer  $row, integer  $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

integer $row
integer $rowCount

Throws

\Matrix\Exception

Returns

static

getColumns()

getColumns(integer  $column, integer  $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

integer $column
integer $columnCount

Throws

\Matrix\Exception

Returns

\Matrix\Matrix

dropRows()

dropRows(integer  $row, integer  $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

integer $row
integer $rowCount

Throws

\Matrix\Exception

Returns

static

dropColumns()

dropColumns(integer  $column, integer  $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

integer $column
integer $columnCount

Throws

\Matrix\Exception

Returns

static

getValue()

getValue(integer  $row, integer  $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

integer $row
integer $column

Throws

\Matrix\Exception

Returns

mixed

rows()

rows() : \Generator|array<mixed,\Matrix\Matrix>|array<mixed,mixed>

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 vector

Returns

\Generator|array<mixed,\Matrix\Matrix>|array<mixed,mixed>

columns()

columns() : \Generator|array<mixed,\Matrix\Matrix>|array<mixed,mixed>

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 vector

Returns

\Generator|array<mixed,\Matrix\Matrix>|array<mixed,mixed>

isSquare()

isSquare() : boolean

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

Returns

boolean

isVector()

isVector() : boolean

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

Returns

boolean

toArray()

toArray() : array

Return the matrix as a 2-dimensional array

Returns

array

__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<mixed,mixed>  $arguments) : \Matrix\Matrix|float

Returns the result of the function call or operation

Parameters

string $functionName
array<mixed,mixed> $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

buildFromArray()

buildFromArray(array  $grid) 

Parameters

array $grid

validateRowInRange()

validateRowInRange(integer  $row) : integer

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

Parameters

integer $row

Throws

\Matrix\Exception

Returns

integer

validateColumnInRange()

validateColumnInRange(integer  $column) : integer

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

Parameters

integer $column

Throws

\Matrix\Exception

Returns

integer