Very Minor Simplification to Matrix Functions (#2222)
The external Matrix library has introduced some changes which permit the matrix functions to be slightly simplified.
This commit is contained in:
parent
11bf051c94
commit
3c5750bddc
|
|
@ -3,6 +3,7 @@
|
|||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Matrix\Builder;
|
||||
use Matrix\Div0Exception as MatrixDiv0Exception;
|
||||
use Matrix\Exception as MatrixException;
|
||||
use Matrix\Matrix;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
|
@ -84,8 +85,10 @@ class MatrixFunctions
|
|||
$matrix = self::getMatrix($matrixValues);
|
||||
|
||||
return $matrix->inverse()->toArray();
|
||||
} catch (MatrixDiv0Exception $e) {
|
||||
return Functions::NAN();
|
||||
} catch (MatrixException $e) {
|
||||
return (strpos($e->getMessage(), 'determinant') === false) ? Functions::VALUE() : Functions::NAN();
|
||||
return Functions::VALUE();
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
|
@ -125,10 +128,7 @@ class MatrixFunctions
|
|||
try {
|
||||
$dimension = (int) Helpers::validateNumericNullBool($dimension);
|
||||
Helpers::validatePositive($dimension, Functions::VALUE());
|
||||
$matrix = Builder::createFilledMatrix(0, $dimension)->toArray();
|
||||
for ($x = 0; $x < $dimension; ++$x) {
|
||||
$matrix[$x][$x] = 1;
|
||||
}
|
||||
$matrix = Builder::createIdentityMatrix($dimension, 0)->toArray();
|
||||
|
||||
return $matrix;
|
||||
} catch (Exception $e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue