Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/Matrix.php
public function times(...$args)
    {
        if (count() > 0) {
            $match = implode(',', array_map('gettype', $args));

            switch ($match) {
                case 'object':
                    if ($args[0] instanceof self) {
                        $B = $args[0];
                    } else {
                        throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
                    }
                    if ($this->n == $B->m) {
                        $C = new self($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;
                    }

                    throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
                case 'array':
                    $B = new self($args[0]);
                    if ($this->n == $B->m) {
                        $C = new self($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;
                    }

                    throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
                case 'integer':
                    $C = new self($this->A);
                    for ($i = 0; $i < $C->m; ++$i) {
                        for ($j = 0; $j < $C->n; ++$j) {
                            $C->A[$i][$j] *= $args[0];
                        }
                    }

                    return $C;
                case 'double':
                    $C = new self($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;
                case 'float':
                    $C = new self($this->A);
                    for ($i = 0; $i < $C->m; ++$i) {
                        for ($j = 0; $j < $C->n; ++$j) {
                            $C->A[$i][$j] *= $args[0];
                        }
                    }

                    return $C;
                default:
                    throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
            }
        } else {
            throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
        }
    }
public function times(...$args)
    {
        if (count() > 0) {
            $match = implode(',', array_map('gettype', $args));

            switch ($match) {
                case 'object':
                    if ($args[0] instanceof self) {
                        $B = $args[0];
                    } else {
                        throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
                    }
                    if ($this->n == $B->m) {
                        $C = new self($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;
                    }

                    throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
                case 'array':
                    $B = new self($args[0]);
                    if ($this->n == $B->m) {
                        $C = new self($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;
                    }

                    throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
                case 'integer':
                    $C = new self($this->A);
                    for ($i = 0; $i < $C->m; ++$i) {
                        for ($j = 0; $j < $C->n; ++$j) {
                            $C->A[$i][$j] *= $args[0];
                        }
                    }

                    return $C;
                case 'double':
                    $C = new self($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;
                case 'float':
                    $C = new self($this->A);
                    for ($i = 0; $i < $C->m; ++$i) {
                        for ($j = 0; $j < $C->n; ++$j) {
                            $C->A[$i][$j] *= $args[0];
                        }
                    }

                    return $C;
                default:
                    throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
            }
        } else {
            throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
        }
    }
public function times ( ... $ args ) { if ( count ( ) > 0 ) { $ match = implode ( ',' , array_map ( 'gettype' , $ args ) ) ; switch ( $ match ) { case 'object' : if ( $ args [ 0 ] instanceof self ) { $ B = $ args [ 0 ] ; } else { throw new CalculationException ( self :: ARGUMENT_TYPE_EXCEPTION ) ; } if ( $ this -> n == $ B -> m ) { $ C = new self ( $ 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 ; } throw new CalculationException ( self :: MATRIX_DIMENSION_EXCEPTION ) ; case 'array' : $ B = new self ( $ args [ 0 ] ) ; if ( $ this -> n == $ B -> m ) { $ C = new self ( $ 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 ; } throw new CalculationException ( self :: MATRIX_DIMENSION_EXCEPTION ) ; case 'integer' : $ C = new self ( $ this -> A ) ; for ( $ i = 0 ; $ i < $ C -> m ; ++ $ i ) { for ( $ j = 0 ; $ j < $ C -> n ; ++ $ j ) { $ C -> A [ $ i ] [ $ j ] *= $ args [ 0 ] ; } } return $ C ; case 'double' : $ C = new self ( $ 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 ; case 'float' : $ C = new self ( $ this -> A ) ; for ( $ i = 0 ; $ i < $ C -> m ; ++ $ i ) { for ( $ j = 0 ; $ j < $ C -> n ; ++ $ j ) { $ C -> A [ $ i ] [ $ j ] *= $ args [ 0 ] ; } } return $ C ; default : throw new CalculationException ( self :: POLYMORPHIC_ARGUMENT_EXCEPTION ) ; } } else { throw new CalculationException ( self :: POLYMORPHIC_ARGUMENT_EXCEPTION ) ; } }
times.

Matrix multiplication

@param mixed $n Matrix/Array/Scalar

@return Matrix Product
times .