Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

(no description)

File Size: 376 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Functions:: (16 methods):
  validateMatrix()
  getAdjoint()
  adjoint()
  getCofactors()
  cofactors()
  getDeterminantSegment()
  getDeterminant()
  determinant()
  diagonal()
  antidiagonal()
  identity()
  inverse()
  getMinors()
  minors()
  trace()
  transpose()


Class: Functions  - X-Ref

validateMatrix($matrix)   X-Ref
Validates an array of matrix, converting an array to a matrix if required.

return: Matrix The new matrix
param: Matrix|array $matrix Matrix or an array to treat as a matrix.

getAdjoint(Matrix $matrix)   X-Ref
Calculate the adjoint of the matrix

return: Matrix
param: Matrix $matrix The matrix whose adjoint we wish to calculate

adjoint($matrix)   X-Ref
Return the adjoint of this matrix
The adjugate, classical adjoint, or adjunct of a square matrix is the transpose of its cofactor matrix.
The adjugate has sometimes been called the "adjoint", but today the "adjoint" of a matrix normally refers
to its corresponding adjoint operator, which is its conjugate transpose.

return: Matrix
param: Matrix|array $matrix The matrix whose adjoint we wish to calculate

getCofactors(Matrix $matrix)   X-Ref
Calculate the cofactors of the matrix

return: Matrix
param: Matrix $matrix The matrix whose cofactors we wish to calculate

cofactors($matrix)   X-Ref
Return the cofactors of this matrix

return: Matrix
param: Matrix|array $matrix The matrix whose cofactors we wish to calculate

getDeterminantSegment(Matrix $matrix, $row, $column)   X-Ref

return: float
param: Matrix $matrix
param: int $row
param: int $column

getDeterminant(Matrix $matrix)   X-Ref
No description

determinant($matrix)   X-Ref
Return the determinant of this matrix

return: float
param: Matrix|array $matrix The matrix whose determinant we wish to calculate

diagonal($matrix)   X-Ref
Return the diagonal of this matrix

return: Matrix
param: Matrix|array $matrix The matrix whose diagonal we wish to calculate

antidiagonal($matrix)   X-Ref
Return the antidiagonal of this matrix

return: Matrix
param: Matrix|array $matrix The matrix whose antidiagonal we wish to calculate

identity($matrix)   X-Ref
Return the identity matrix
The identity matrix, or sometimes ambiguously called a unit matrix, of size n is the n × n square matrix
with ones on the main diagonal and zeros elsewhere

return: Matrix
param: Matrix|array $matrix The matrix whose identity we wish to calculate

inverse($matrix, string $type = 'inverse')   X-Ref
Return the inverse of this matrix

return: Matrix
param: Matrix|array $matrix The matrix whose inverse we wish to calculate

getMinors(Matrix $matrix)   X-Ref
Calculate the minors of the matrix

return: array[]
param: Matrix $matrix The matrix whose minors we wish to calculate

minors($matrix)   X-Ref
Return the minors of the matrix
The minor of a matrix A is the determinant of some smaller square matrix, cut down from A by removing one or
more of its rows or columns.
Minors obtained by removing just one row and one column from square matrices (first minors) are required for
calculating matrix cofactors, which in turn are useful for computing both the determinant and inverse of
square matrices.

return: Matrix
param: Matrix|array $matrix The matrix whose minors we wish to calculate

trace($matrix)   X-Ref
Return the trace of this matrix
The trace is defined as the sum of the elements on the main diagonal (the diagonal from the upper left to the lower right)
of the matrix

return: float
param: Matrix|array $matrix The matrix whose trace we wish to calculate

transpose($matrix)   X-Ref
Return the transpose of this matrix

return: Matrix
param: Matrix|\a $matrix The matrix whose transpose we wish to calculate