public function PHPExcel_Shared_JAMA_Matrix::times in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/Matrix.php \PHPExcel_Shared_JAMA_Matrix::times()
* times * * Matrix multiplication *
Parameters
mixed $n Matrix/Array/Scalar: * @return Matrix Product
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ JAMA/ Matrix.php, line 851
Class
Code
public function times() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch ($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
$B = $args[0];
}
else {
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
}
if ($this->n == $B->m) {
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n);
for ($j = 0; $j < $B->n; ++$j) {
for ($k = 0; $k < $this->n; ++$k) {
$Bcolj[$k] = $B->A[$k][$j];
}
for ($i = 0; $i < $this->m; ++$i) {
$Arowi = $this->A[$i];
$s = 0;
for ($k = 0; $k < $this->n; ++$k) {
$s += $Arowi[$k] * $Bcolj[$k];
}
$C->A[$i][$j] = $s;
}
}
return $C;
}
else {
throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch));
}
break;
case 'array':
$B = new PHPExcel_Shared_JAMA_Matrix($args[0]);
if ($this->n == $B->m) {
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n);
for ($i = 0; $i < $C->m; ++$i) {
for ($j = 0; $j < $C->n; ++$j) {
$s = "0";
for ($k = 0; $k < $C->n; ++$k) {
$s += $this->A[$i][$k] * $B->A[$k][$j];
}
$C->A[$i][$j] = $s;
}
}
return $C;
}
else {
throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch));
}
return $M;
break;
case 'integer':
$C = new PHPExcel_Shared_JAMA_Matrix($this->A);
for ($i = 0; $i < $C->m; ++$i) {
for ($j = 0; $j < $C->n; ++$j) {
$C->A[$i][$j] *= $args[0];
}
}
return $C;
break;
case 'double':
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $this->n);
for ($i = 0; $i < $C->m; ++$i) {
for ($j = 0; $j < $C->n; ++$j) {
$C->A[$i][$j] = $args[0] * $this->A[$i][$j];
}
}
return $C;
break;
case 'float':
$C = new PHPExcel_Shared_JAMA_Matrix($this->A);
for ($i = 0; $i < $C->m; ++$i) {
for ($j = 0; $j < $C->n; ++$j) {
$C->A[$i][$j] *= $args[0];
}
}
return $C;
break;
default:
throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException);
break;
}
}
else {
throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException);
}
}