Phpml\Math\Matrix::getColumnValues PHP Method

getColumnValues() public method

public getColumnValues ( $column ) : array
$column
return array
    public function getColumnValues($column)
    {
        if ($column >= $this->columns) {
            throw MatrixException::columnOutOfRange();
        }
        $values = [];
        for ($i = 0; $i < $this->rows; ++$i) {
            $values[] = $this->matrix[$i][$column];
        }
        return $values;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @expectedException \Phpml\Exception\MatrixException
  */
 public function testThrowExceptionOnInvalidColumnNumber()
 {
     $matrix = new Matrix([[1, 2, 3], [4, 5, 6]]);
     $matrix->getColumnValues(4);
 }