@@ 540-576 (lines=37) @@ | ||
537 | * |
|
538 | * @return float |
|
539 | */ |
|
540 | public static function MDETERM($matrixValues) |
|
541 | { |
|
542 | $matrixData = []; |
|
543 | if (!is_array($matrixValues)) { |
|
544 | $matrixValues = [[$matrixValues]]; |
|
545 | } |
|
546 | ||
547 | $row = $maxColumn = 0; |
|
548 | foreach ($matrixValues as $matrixRow) { |
|
549 | if (!is_array($matrixRow)) { |
|
550 | $matrixRow = [$matrixRow]; |
|
551 | } |
|
552 | $column = 0; |
|
553 | foreach ($matrixRow as $matrixCell) { |
|
554 | if ((is_string($matrixCell)) || ($matrixCell === null)) { |
|
555 | return Functions::VALUE(); |
|
556 | } |
|
557 | $matrixData[$column][$row] = $matrixCell; |
|
558 | ++$column; |
|
559 | } |
|
560 | if ($column > $maxColumn) { |
|
561 | $maxColumn = $column; |
|
562 | } |
|
563 | ++$row; |
|
564 | } |
|
565 | if ($row != $maxColumn) { |
|
566 | return Functions::VALUE(); |
|
567 | } |
|
568 | ||
569 | try { |
|
570 | $matrix = new \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix($matrixData); |
|
571 | ||
572 | return $matrix->det(); |
|
573 | } catch (\PhpOffice\PhpSpreadsheet\Exception $ex) { |
|
574 | return Functions::VALUE(); |
|
575 | } |
|
576 | } |
|
577 | ||
578 | /** |
|
579 | * MINVERSE. |
|
@@ 592-630 (lines=39) @@ | ||
589 | * |
|
590 | * @return array |
|
591 | */ |
|
592 | public static function MINVERSE($matrixValues) |
|
593 | { |
|
594 | $matrixData = []; |
|
595 | if (!is_array($matrixValues)) { |
|
596 | $matrixValues = [[$matrixValues]]; |
|
597 | } |
|
598 | ||
599 | $row = $maxColumn = 0; |
|
600 | foreach ($matrixValues as $matrixRow) { |
|
601 | if (!is_array($matrixRow)) { |
|
602 | $matrixRow = [$matrixRow]; |
|
603 | } |
|
604 | $column = 0; |
|
605 | foreach ($matrixRow as $matrixCell) { |
|
606 | if ((is_string($matrixCell)) || ($matrixCell === null)) { |
|
607 | return Functions::VALUE(); |
|
608 | } |
|
609 | $matrixData[$column][$row] = $matrixCell; |
|
610 | ++$column; |
|
611 | } |
|
612 | if ($column > $maxColumn) { |
|
613 | $maxColumn = $column; |
|
614 | } |
|
615 | ++$row; |
|
616 | } |
|
617 | foreach ($matrixValues as $matrixRow) { |
|
618 | if (count($matrixRow) != $maxColumn) { |
|
619 | return Functions::VALUE(); |
|
620 | } |
|
621 | } |
|
622 | ||
623 | try { |
|
624 | $matrix = new \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix($matrixData); |
|
625 | ||
626 | return $matrix->inverse()->getArray(); |
|
627 | } catch (\PhpOffice\PhpSpreadsheet\Exception $ex) { |
|
628 | return Functions::VALUE(); |
|
629 | } |
|
630 | } |
|
631 | ||
632 | /** |
|
633 | * MMULT. |