public static function PHPExcel_Calculation_MathTrig::MMULT in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php \PHPExcel_Calculation_MathTrig::MMULT()
* MMULT * *
Parameters
array $matrixData1 A matrix of values: * @param array $matrixData2 A matrix of values * @return array
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ MathTrig.php, line 607
Class
- PHPExcel_Calculation_MathTrig
- PHPExcel_Calculation_MathTrig
Code
public static function MMULT($matrixData1, $matrixData2) {
$matrixAData = $matrixBData = array();
if (!is_array($matrixData1)) {
$matrixData1 = array(
array(
$matrixData1,
),
);
}
if (!is_array($matrixData2)) {
$matrixData2 = array(
array(
$matrixData2,
),
);
}
try {
$rowA = 0;
foreach ($matrixData1 as $matrixRow) {
if (!is_array($matrixRow)) {
$matrixRow = array(
$matrixRow,
);
}
$columnA = 0;
foreach ($matrixRow as $matrixCell) {
if (!is_numeric($matrixCell) || $matrixCell === null) {
return PHPExcel_Calculation_Functions::VALUE();
}
$matrixAData[$rowA][$columnA] = $matrixCell;
++$columnA;
}
++$rowA;
}
$matrixA = new PHPExcel_Shared_JAMA_Matrix($matrixAData);
$rowB = 0;
foreach ($matrixData2 as $matrixRow) {
if (!is_array($matrixRow)) {
$matrixRow = array(
$matrixRow,
);
}
$columnB = 0;
foreach ($matrixRow as $matrixCell) {
if (!is_numeric($matrixCell) || $matrixCell === null) {
return PHPExcel_Calculation_Functions::VALUE();
}
$matrixBData[$rowB][$columnB] = $matrixCell;
++$columnB;
}
++$rowB;
}
$matrixB = new PHPExcel_Shared_JAMA_Matrix($matrixBData);
if ($columnA != $rowB) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $matrixA
->times($matrixB)
->getArray();
} catch (PHPExcel_Exception $ex) {
var_dump($ex
->getMessage());
return PHPExcel_Calculation_Functions::VALUE();
}
}