本文整理汇总了PHP中PHPExcel_Shared_JAMA_Matrix::times方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Shared_JAMA_Matrix::times方法的具体用法?PHP PHPExcel_Shared_JAMA_Matrix::times怎么用?PHP PHPExcel_Shared_JAMA_Matrix::times使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Shared_JAMA_Matrix
的用法示例。
在下文中一共展示了PHPExcel_Shared_JAMA_Matrix::times方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MMULT
/**
* MMULT
*
* @param array $matrixData1 A matrix of values
* @param array $matrixData2 A matrix of values
* @return array
*/
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();
}
}
示例2: MMULT
/**
* MMULT
*
* @param array $matrixData1 A matrix of values
* @param array $matrixData2 A matrix of values
* @return array
*/
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));
}
$rowA = 0;
foreach ($matrixData1 as $matrixRow) {
$columnA = 0;
foreach ($matrixRow as $matrixCell) {
if (is_string($matrixCell) || $matrixCell === null) {
return PHPExcel_Calculation_Functions::VALUE();
}
$matrixAData[$rowA][$columnA] = $matrixCell;
++$columnA;
}
++$rowA;
}
try {
$matrixA = new PHPExcel_Shared_JAMA_Matrix($matrixAData);
$rowB = 0;
foreach ($matrixData2 as $matrixRow) {
$columnB = 0;
foreach ($matrixRow as $matrixCell) {
if (is_string($matrixCell) || $matrixCell === null) {
return PHPExcel_Calculation_Functions::VALUE();
}
$matrixBData[$rowB][$columnB] = $matrixCell;
++$columnB;
}
++$rowB;
}
$matrixB = new PHPExcel_Shared_JAMA_Matrix($matrixBData);
if ($rowA != $columnB || $rowB != $columnA) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $matrixA->times($matrixB)->getArray();
} catch (Exception $ex) {
return PHPExcel_Calculation_Functions::VALUE();
}
}