|
static | adjoint (Matrix $matrix) |
| Return the adjoint of this matrix The adjugate, classical adjoint, or adjunct of a square matrix is the transpose of its cofactor matrix. More...
|
|
static | cofactors (Matrix $matrix) |
| Return the cofactors of this matrix. More...
|
|
static | determinant (Matrix $matrix) |
| Return the determinant of this matrix. More...
|
|
static | diagonal (Matrix $matrix) |
| Return the diagonal of this matrix. More...
|
|
static | antidiagonal (Matrix $matrix) |
| Return the antidiagonal of this matrix. More...
|
|
static | identity (Matrix $matrix) |
| 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. More...
|
|
static | inverse (Matrix $matrix, string $type='inverse') |
| Return the inverse of this matrix. More...
|
|
static | minors (Matrix $matrix) |
| 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. More...
|
|
static | trace (Matrix $matrix) |
| 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. More...
|
|
static | transpose (Matrix $matrix) |
| Return the transpose of this matrix. More...
|
|
Definition at line 5 of file Functions.php.
◆ adjoint()
static Matrix\Functions::adjoint |
( |
Matrix |
$matrix | ) |
|
|
static |
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.
- Parameters
-
Matrix | $matrix | The matrix whose adjoint we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 32 of file Functions.php.
33 {
35 throw new Exception('Adjoint can only be calculated for a square matrix');
36 }
37
39 }
static getAdjoint(Matrix $matrix)
Calculate the adjoint of the matrix.
References $matrix.
◆ antidiagonal()
static Matrix\Functions::antidiagonal |
( |
Matrix |
$matrix | ) |
|
|
static |
Return the antidiagonal of this matrix.
- Parameters
-
Matrix | $matrix | The matrix whose antidiagonal we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 188 of file Functions.php.
189 {
191 throw new Exception('Anti-Diagonal can only be extracted from a square matrix');
192 }
193
196 ->toArray();
197
198 for (
$i = 0;
$i < $dimensions; ++
$i) {
200 }
201
203 }
static createFilledMatrix($fillValue, $rows, $columns=null)
Create a new matrix of specified dimensions, and filled with a specified value If the column argument...
Class for the creating "special" Matrices.
References $grid, $i, and $matrix.
◆ cofactors()
static Matrix\Functions::cofactors |
( |
Matrix |
$matrix | ) |
|
|
static |
Return the cofactors of this matrix.
- Parameters
-
Matrix | $matrix | The matrix whose cofactors we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 75 of file Functions.php.
76 {
78 throw new Exception('Cofactors can only be calculated for a square matrix');
79 }
80
82 }
static getCofactors(Matrix $matrix)
Calculate the cofactors of the matrix.
References $matrix.
◆ determinant()
static Matrix\Functions::determinant |
( |
Matrix |
$matrix | ) |
|
|
static |
Return the determinant of this matrix.
- Parameters
-
Matrix | $matrix | The matrix whose determinant we wish to calculate |
- Returns
- float
- Exceptions
-
Definition at line 148 of file Functions.php.
149 {
151 throw new Exception('Determinant can only be calculated for a square matrix');
152 }
153
155 }
static getDeterminant(Matrix $matrix)
Calculate the determinant of the matrix.
References $matrix.
◆ diagonal()
static Matrix\Functions::diagonal |
( |
Matrix |
$matrix | ) |
|
|
static |
Return the diagonal of this matrix.
- Parameters
-
Matrix | $matrix | The matrix whose diagonal we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 164 of file Functions.php.
165 {
167 throw new Exception('Diagonal can only be extracted from a square matrix');
168 }
169
172 ->toArray();
173
174 for (
$i = 0;
$i < $dimensions; ++
$i) {
176 }
177
179 }
References $grid, $i, and $matrix.
◆ getAdjoint()
static Matrix\Functions::getAdjoint |
( |
Matrix |
$matrix | ) |
|
|
staticprivate |
Calculate the adjoint of the matrix.
- Parameters
-
Matrix | $matrix | The matrix whose adjoint we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 15 of file Functions.php.
16 {
19 );
20 }
static transpose(Matrix $matrix)
Return the transpose of this matrix.
References $matrix.
◆ getCofactors()
static Matrix\Functions::getCofactors |
( |
Matrix |
$matrix | ) |
|
|
staticprivate |
Calculate the cofactors of the matrix.
- Parameters
-
Matrix | $matrix | The matrix whose cofactors we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 49 of file Functions.php.
50 {
53
54 $cof = 1;
55 for (
$i = 0;
$i < $dimensions; ++
$i) {
56 $cofs = $cof;
57 for ($j = 0; $j < $dimensions; ++$j) {
58 $cofactors[
$i][$j] *= $cofs;
59 $cofs = -$cofs;
60 }
61 $cof = -$cof;
62 }
63
64 return new Matrix($cofactors);
65 }
static getMinors(Matrix $matrix)
Calculate the minors of the matrix.
References $i, and $matrix.
◆ getDeterminant()
static Matrix\Functions::getDeterminant |
( |
Matrix |
$matrix | ) |
|
|
staticprivate |
Calculate the determinant of the matrix.
- Parameters
-
Matrix | $matrix | The matrix whose determinant we wish to calculate |
- Returns
- float
- Exceptions
-
Definition at line 113 of file Functions.php.
114 {
116 $determinant = 0;
117
118 switch ($dimensions) {
119 case 1:
120 $determinant =
$matrix->getValue(1, 1);
121 break;
122 case 2:
123 $determinant =
$matrix->getValue(1, 1) *
$matrix->getValue(2, 2) -
125 break;
126 default:
127 for (
$i = 1;
$i <= $dimensions; ++
$i) {
130 $determinant -= $det;
131 } else {
132 $determinant += $det;
133 }
134 }
135 break;
136 }
137
138 return $determinant;
139 }
static getDeterminantSegment(Matrix $matrix, $row, $column)
References $i, and $matrix.
◆ getDeterminantSegment()
static Matrix\Functions::getDeterminantSegment |
( |
Matrix |
$matrix, |
|
|
|
$row, |
|
|
|
$column |
|
) |
| |
|
staticprivate |
- Parameters
-
Matrix | $matrix | |
int | $row | |
int | $column | |
- Returns
- float
- Exceptions
-
Definition at line 91 of file Functions.php.
92 {
93 $tmpMatrix =
$matrix->toArray();
94 unset($tmpMatrix[
$row]);
95 array_walk(
96 $tmpMatrix,
97 function (&
$row) use ($column) {
99 }
100 );
101
103 }
References $matrix, and $row.
◆ getMinors()
static Matrix\Functions::getMinors |
( |
Matrix |
$matrix | ) |
|
|
staticprotected |
Calculate the minors of the matrix.
- Parameters
-
Matrix | $matrix | The matrix whose minors we wish to calculate |
- Returns
- array[]
- Exceptions
-
Definition at line 259 of file Functions.php.
260 {
263 if ($dimensions == 1) {
264 return $minors;
265 }
266
267 for (
$i = 0;
$i < $dimensions; ++
$i) {
268 for ($j = 0; $j < $dimensions; ++$j) {
270 }
271 }
272
273 return $minors;
274 }
References $i, and $matrix.
◆ identity()
static Matrix\Functions::identity |
( |
Matrix |
$matrix | ) |
|
|
static |
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.
- Parameters
-
Matrix | $matrix | The matrix whose identity we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 214 of file Functions.php.
215 {
217 throw new Exception('Identity can only be created for a square matrix');
218 }
219
221
223 }
static createIdentityMatrix($dimensions, $fillValue=null)
Create a new identity matrix of specified dimensions This will always be a square matrix,...
References $matrix.
◆ inverse()
static Matrix\Functions::inverse |
( |
Matrix |
$matrix, |
|
|
string |
$type = 'inverse' |
|
) |
| |
|
static |
Return the inverse of this matrix.
- Parameters
-
Matrix | $matrix | The matrix whose inverse we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 232 of file Functions.php.
233 {
235 throw new Exception(ucfirst(
$type) .
' can only be calculated for a square matrix');
236 }
237
239 if ($determinant == 0.0) {
240 throw new Div0Exception(ucfirst(
$type) .
' can only be calculated for a matrix with a non-zero determinant');
241 }
242
245 }
246
248 ->multiply(1 / $determinant);
249 }
References $matrix, and $type.
Referenced by Matrix\Operators\Division\execute().
◆ minors()
static Matrix\Functions::minors |
( |
Matrix |
$matrix | ) |
|
|
static |
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.
- Parameters
-
Matrix | $matrix | The matrix whose minors we wish to calculate |
- Returns
- Matrix
- Exceptions
-
Definition at line 288 of file Functions.php.
289 {
291 throw new Exception('Minors can only be calculated for a square matrix');
292 }
293
295 }
References $matrix.
◆ trace()
static Matrix\Functions::trace |
( |
Matrix |
$matrix | ) |
|
|
static |
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.
- Parameters
-
Matrix | $matrix | The matrix whose trace we wish to calculate |
- Returns
- float
- Exceptions
-
Definition at line 306 of file Functions.php.
307 {
309 throw new Exception('Trace can only be extracted from a square matrix');
310 }
311
314 for (
$i = 1;
$i <= $dimensions; ++
$i) {
316 }
317
319 }
References $i, $matrix, and $result.
◆ transpose()
static Matrix\Functions::transpose |
( |
Matrix |
$matrix | ) |
|
|
static |
Return the transpose of this matrix.
- Parameters
-
Matrix | $matrix | The matrix whose transpose we wish to calculate |
- Returns
- Matrix
Definition at line 327 of file Functions.php.
328 {
329 $array = array_values(array_merge([
null],
$matrix->toArray()));
330 $grid = call_user_func_array(
331 'array_map',
332 $array
333 );
334
336 }
References $grid, and $matrix.
The documentation for this class was generated from the following file: