pocketmine\math\Matrix::product PHP Метод

product() публичный Метод

Naive Matrix product, O(n^3)
public product ( Matrix $matrix )
$matrix Matrix
    public function product(Matrix $matrix)
    {
        if ($this->columns !== $matrix->getRows()) {
            return false;
        }
        $c = $matrix->getColumns();
        $result = new Matrix($this->rows, $c);
        for ($i = 0; $i < $this->rows; ++$i) {
            for ($j = 0; $j < $c; ++$j) {
                $sum = 0;
                for ($k = 0; $k < $this->columns; ++$k) {
                    $sum += $this->matrix[$i][$k] * $matrix->getElement($k, $j);
                }
                $result->setElement($i, $j, $sum);
            }
        }
        return $result;
    }