public function testMatrixTranspose() { $T = MatrixFactory::fromString('1, 3; 2, 4; 3, 5'); $this->assertEquals($T->getArray(), $this->A->T()->getArray()); }
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()); }
/** * 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(); } }