21 if (!is_array($matrixValues)) {
22 $matrixValues = [[$matrixValues]];
26 foreach ($matrixValues as $matrixRow) {
27 if (!is_array($matrixRow)) {
28 $matrixRow = [$matrixRow];
31 foreach ($matrixRow as $matrixCell) {
32 if ((is_string($matrixCell)) || ($matrixCell ===
null)) {
35 $matrixData[
$row][$column] = $matrixCell;
41 return new Matrix($matrixData);
62 }
catch (MatrixException $ex) {
65 return $e->getMessage();
81 public static function inverse($matrixValues)
86 return $matrix->inverse()->toArray();
87 }
catch (MatrixException $e) {
90 return $e->getMessage();
102 public static function multiply($matrixData1, $matrixData2)
108 return $matrixA->multiply($matrixB)->toArray();
109 }
catch (MatrixException $ex) {
112 return $e->getMessage();
129 for (
$x = 0;
$x < $dimension; ++
$x) {
135 return $e->getMessage();
An exception for terminatinating execution or to throw for unit testing.
static createFilledMatrix($fillValue, $rows, $columns=null)
Create a new matrix of specified dimensions, and filled with a specified value If the column argument...
static validateNumericNullBool($number)
Many functions accept null/false/true argument treated as 0/0/1.
static validatePositive($number, ?string $except=null)
Confirm number > 0.
static getMatrix($matrixValues)
Convert parameter to matrix.
static inverse($matrixValues)
MINVERSE.
static determinant($matrixValues)
MDETERM.
static multiply($matrixData1, $matrixData2)
MMULT.
static identity($dimension)
MUnit.
Class for the creating "special" Matrices.