Matrix
in package
Matrix object.
Table of Contents
Properties
- $columns : int
- $rows : int
- $columns : mixed
- $functions : mixed
- $getters : mixed
- $grid : mixed
- $operations : mixed
- $rows : mixed
Methods
- __call() : Matrix|float
- Returns the result of the function call or operation
- __construct() : mixed
- __get() : mixed
- Access specific properties as read-only (no setters)
- add() : Matrix
- adjoint() : Matrix
- antidiagonal() : Matrix
- cofactors() : Matrix
- columns() : Generator|array<string|int, Matrix>|array<string|int, 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 row vector
- determinant() : float
- diagonal() : Matrix
- directsum() : Matrix
- divideby() : Matrix
- divideinto() : Matrix
- dropColumns() : 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
- dropRows() : 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
- getColumns() : 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
- getRows() : 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
- getValue() : 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
- identity() : Matrix
- inverse() : Matrix
- isSquare() : bool
- Identify if the row and column dimensions of this matrix are equal, i.e. if it is a "square" matrix
- isVector() : bool
- Identify if this matrix is a vector i.e. if it comprises only a single row or a single column
- minors() : Matrix
- multiply() : Matrix
- rows() : Generator|array<string|int, Matrix>|array<string|int, 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 column vector
- solve() : Matrix
- Solve A*X = B.
- subtract() : Matrix
- toArray() : array<string|int, mixed>
- Return the matrix as a 2-dimensional array
- trace() : float
- transpose() : Matrix
- validateColumn() : int
- Validate that a column number is a positive integer
- validateRow() : int
- Validate that a row number is a positive integer
- buildFromArray() : void
- validateColumnInRange() : int
- Validate that a column number falls within the set of columns for this matrix
- validateRowInRange() : int
- Validate that a row number falls within the set of rows for this matrix
Properties
$columns read-only
public
int
$columns
The number of columns in the matrix
$rows read-only
public
int
$rows
The number of rows in the matrix
$columns
protected
mixed
$columns
$functions
protected
static mixed
$functions
= ['adjoint', 'antidiagonal', 'cofactors', 'determinant', 'diagonal', 'identity', 'inverse', 'minors', 'trace', 'transpose']
$getters
protected
static mixed
$getters
= ['rows', 'columns']
$grid
protected
mixed
$grid
= []
$operations
protected
static mixed
$operations
= ['add', 'subtract', 'multiply', 'divideby', 'divideinto', 'directsum']
$rows
protected
mixed
$rows
Methods
__call()
Returns the result of the function call or operation
public
__call(string $functionName, array<string|int, mixed> $arguments) : Matrix|float
Parameters
- $functionName : string
- $arguments : array<string|int, mixed>
Tags
Return values
Matrix|float__construct()
public
final __construct(array<string|int, mixed> $grid) : mixed
Parameters
- $grid : array<string|int, mixed>
__get()
Access specific properties as read-only (no setters)
public
__get(string $propertyName) : mixed
Parameters
- $propertyName : string
Tags
add()
public
add([mixed ...$matrices = ]) : Matrix
Parameters
- $matrices : mixed =
Return values
Matrixadjoint()
public
adjoint() : Matrix
Return values
Matrixantidiagonal()
public
antidiagonal() : Matrix
Return values
Matrixcofactors()
public
cofactors() : Matrix
Return values
Matrixcolumns()
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
public
columns() : Generator|array<string|int, Matrix>|array<string|int, mixed>
Return values
Generator|array<string|int, Matrix>|array<string|int, mixed>determinant()
public
determinant() : float
Return values
floatdiagonal()
public
diagonal() : Matrix
Return values
Matrixdirectsum()
public
directsum([mixed ...$matrices = ]) : Matrix
Parameters
- $matrices : mixed =
Return values
Matrixdivideby()
public
divideby([mixed ...$matrices = ]) : Matrix
Parameters
- $matrices : mixed =
Return values
Matrixdivideinto()
public
divideinto([mixed ...$matrices = ]) : Matrix
Parameters
- $matrices : mixed =
Return values
MatrixdropColumns()
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
public
dropColumns(int $column[, int $columnCount = 1 ]) : static
Note that column numbers start from 1, not from 0
Parameters
- $column : int
- $columnCount : int = 1
Tags
Return values
staticdropRows()
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
public
dropRows(int $row[, int $rowCount = 1 ]) : static
Note that row numbers start from 1, not from 0
Parameters
- $row : int
- $rowCount : int = 1
Tags
Return values
staticgetColumns()
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
public
getColumns(int $column[, int $columnCount = 1 ]) : Matrix
Note that column numbers start from 1, not from 0
Parameters
- $column : int
- $columnCount : int = 1
Tags
Return values
MatrixgetRows()
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
public
getRows(int $row[, int $rowCount = 1 ]) : static
Note that row numbers start from 1, not from 0
Parameters
- $row : int
- $rowCount : int = 1
Tags
Return values
staticgetValue()
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
public
getValue(int $row, int $column) : mixed
Parameters
- $row : int
- $column : int
Tags
identity()
public
identity() : Matrix
Return values
Matrixinverse()
public
inverse() : Matrix
Return values
MatrixisSquare()
Identify if the row and column dimensions of this matrix are equal, i.e. if it is a "square" matrix
public
isSquare() : bool
Return values
boolisVector()
Identify if this matrix is a vector i.e. if it comprises only a single row or a single column
public
isVector() : bool
Return values
boolminors()
public
minors() : Matrix
Return values
Matrixmultiply()
public
multiply([mixed ...$matrices = ]) : Matrix
Parameters
- $matrices : mixed =
Return values
Matrixrows()
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
public
rows() : Generator|array<string|int, Matrix>|array<string|int, mixed>
Return values
Generator|array<string|int, Matrix>|array<string|int, mixed>solve()
Solve A*X = B.
public
solve(Matrix $B) : Matrix
Parameters
- $B : Matrix
-
Right hand side
Tags
Return values
Matrix —... Solution if A is square, least squares solution otherwise
subtract()
public
subtract([mixed ...$matrices = ]) : Matrix
Parameters
- $matrices : mixed =
Return values
MatrixtoArray()
Return the matrix as a 2-dimensional array
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>trace()
public
trace() : float
Return values
floattranspose()
public
transpose() : Matrix
Return values
MatrixvalidateColumn()
Validate that a column number is a positive integer
public
static validateColumn(int $column) : int
Parameters
- $column : int
Tags
Return values
intvalidateRow()
Validate that a row number is a positive integer
public
static validateRow(int $row) : int
Parameters
- $row : int
Tags
Return values
intbuildFromArray()
protected
buildFromArray(array<string|int, mixed> $grid) : void
Parameters
- $grid : array<string|int, mixed>
validateColumnInRange()
Validate that a column number falls within the set of columns for this matrix
protected
validateColumnInRange(int $column) : int
Parameters
- $column : int
Tags
Return values
intvalidateRowInRange()
Validate that a row number falls within the set of rows for this matrix
protected
validateRowInRange(int $row) : int
Parameters
- $row : int