PHP Class MCordingley\LinearAlgebra\Matrix

ファイルを表示 Open project: mcordingley/linearalgebra Class Usage Examples

Public Methods

Method Description
__construct ( array $literal ) Example: $transform = new Matrix([ [0, 1, 2], [3, 4, 5], [6, 7, 8] ]);
addMatrix ( self $value ) : self
addScalar ( float $value ) : self
adjugate ( ) : self
concatenateBottom ( self $other ) : self
concatenateRight ( self $other ) : self
determinant ( ) : float
diagonal ( ) : self
entrywise ( self $value ) : self
equals ( Matrix $matrix ) : boolean
get ( integer $row, integer $column ) : float
getColumnCount ( ) : integer
getRowCount ( ) : integer
identity ( integer $size ) : self
inverse ( ) : self
isSquare ( ) : boolean
lower ( boolean $unitriangular ) : self
map ( callable $callback ) : self Iterates over the current matrix with a callback function to return a new matrix with the mapped values. $callback takes four arguments: - The current matrix element - The current row - The current column - The matrix being iterated over
multiplyMatrix ( self $value ) : self
multiplyScalar ( float $value ) : self
sliceColumns ( integer $offset, integer $length = null ) : self
sliceRows ( integer $offset, integer $length = null ) : self
spliceColumns ( integer $offset, integer $length = null, array $replacement = null ) : self
spliceRows ( integer $offset, integer $length = null, array $replacement = null ) : self
subtractMatrix ( self $value ) : self
subtractScalar ( float $value ) : self
toArray ( ) : array
trace ( ) : float
transpose ( ) : self
upper ( boolean $unitriangular ) : self

Private Methods

Method Description
checkEqualSize ( self $matrix )
checkSquare ( )
isLiteralValid ( array $literal ) : boolean
pad ( integer $size ) : self
recursiveSolveInverse ( self $source ) : self
subArraysAreEqualSize ( array $subArrays ) : boolean

Method Details

__construct() public method

Example: $transform = new Matrix([ [0, 1, 2], [3, 4, 5], [6, 7, 8] ]);
public __construct ( array $literal )
$literal array Array representation of the matrix.

addMatrix() public method

public addMatrix ( self $value ) : self
$value self
return self

addScalar() public method

public addScalar ( float $value ) : self
$value float
return self

adjugate() public method

public adjugate ( ) : self
return self

concatenateBottom() public method

public concatenateBottom ( self $other ) : self
$other self
return self

concatenateRight() public method

public concatenateRight ( self $other ) : self
$other self
return self

determinant() public method

public determinant ( ) : float
return float

diagonal() public method

public diagonal ( ) : self
return self

entrywise() public method

public entrywise ( self $value ) : self
$value self
return self

equals() public method

public equals ( Matrix $matrix ) : boolean
$matrix Matrix
return boolean

get() public method

public get ( integer $row, integer $column ) : float
$row integer
$column integer
return float

getColumnCount() public method

public getColumnCount ( ) : integer
return integer

getRowCount() public method

public getRowCount ( ) : integer
return integer

identity() public static method

public static identity ( integer $size ) : self
$size integer How many rows and columns the identity matrix should have
return self

inverse() public method

public inverse ( ) : self
return self

isSquare() public method

public isSquare ( ) : boolean
return boolean

lower() public method

public lower ( boolean $unitriangular ) : self
$unitriangular boolean True to have ones along the diagonal. False to include parent matrix values, instead.
return self

map() public method

Iterates over the current matrix with a callback function to return a new matrix with the mapped values. $callback takes four arguments: - The current matrix element - The current row - The current column - The matrix being iterated over
public map ( callable $callback ) : self
$callback callable
return self

multiplyMatrix() public method

public multiplyMatrix ( self $value ) : self
$value self
return self

multiplyScalar() public method

public multiplyScalar ( float $value ) : self
$value float
return self

sliceColumns() public method

public sliceColumns ( integer $offset, integer $length = null ) : self
$offset integer
$length integer
return self

sliceRows() public method

public sliceRows ( integer $offset, integer $length = null ) : self
$offset integer
$length integer
return self

spliceColumns() public method

public spliceColumns ( integer $offset, integer $length = null, array $replacement = null ) : self
$offset integer
$length integer
$replacement array
return self

spliceRows() public method

public spliceRows ( integer $offset, integer $length = null, array $replacement = null ) : self
$offset integer
$length integer
$replacement array
return self

subtractMatrix() public method

public subtractMatrix ( self $value ) : self
$value self
return self

subtractScalar() public method

public subtractScalar ( float $value ) : self
$value float
return self

toArray() public method

public toArray ( ) : array
return array

trace() public method

public trace ( ) : float
return float

transpose() public method

public transpose ( ) : self
return self

upper() public method

public upper ( boolean $unitriangular ) : self
$unitriangular boolean True to have ones along the diagonal. False to include parent matrix values, instead.
return self