예제 #1
0
    public function testMatrixTranspose()
    {
        $T = MatrixFactory::fromString('1, 3;
			 2, 4;
			 3, 5');
        $this->assertEquals($T->getArray(), $this->A->T()->getArray());
    }
예제 #2
0
    public function testProd()
    {
        $a = $this->X;
        $b = $this->Y->T();
        $c = MatrixFactory::fromString('5,  31;
			18, 100');
        $this->assertEquals($c->getArray(), $a->prod($b)->getArray());
    }
예제 #3
0
파일: matrix.php 프로젝트: nosun/Matrix
 /**
  * Return column
  *
  * @param $col
  * @param bool $return_array
  * @return array|Matrix
  * @throws OutOfRangeException
  */
 public function getColumn($col, $return_array = false)
 {
     list($rows, $cols) = $this->getSize();
     if ($col >= $cols) {
         throw new OutOfRangeException("Invalid offset. col = {$col} must be lower {$cols}");
     }
     $res = array();
     for ($row = 0; $row < $rows; $row++) {
         $res[$row] = $this->getElem($row, $col);
     }
     if ($return_array) {
         return $res;
     } else {
         $res = new Matrix($res);
         return $res->T();
     }
 }