inconsistentMatrixSupplied() 공개 정적인 메소드

public static inconsistentMatrixSupplied ( ) : InvalidArgumentException
리턴 InvalidArgumentException
예제 #1
0
파일: Matrix.php 프로젝트: php-ai/php-ml
 /**
  * @param Matrix $matrix
  *
  * @return Matrix
  *
  * @throws InvalidArgumentException
  */
 public function multiply(Matrix $matrix)
 {
     if ($this->columns != $matrix->getRows()) {
         throw InvalidArgumentException::inconsistentMatrixSupplied();
     }
     $product = [];
     $multiplier = $matrix->toArray();
     for ($i = 0; $i < $this->rows; ++$i) {
         $columns = $matrix->getColumns();
         for ($j = 0; $j < $columns; ++$j) {
             $product[$i][$j] = 0;
             for ($k = 0; $k < $this->columns; ++$k) {
                 $product[$i][$j] += $this->matrix[$i][$k] * $multiplier[$k][$j];
             }
         }
     }
     return new self($product, false);
 }