src/Malenki/Math/Matrix.php
public function addCol($arr_col)
    {
        if (isset($this->arr[0]) && (count($this->arr[0]) == $this->size->cols)) {
            throw new \OutOfRangeException(sprintf('You cannot add another column! Max number of columns is %d', $this->size->cols));
        }

        if (count($arr_col) != $this->size->rows) {
            throw new \InvalidArgumentException('New column must have same amout of rows than previous columns.');
        }

        $arr_col = array_values($arr_col); //to be sure to have index 0, 1, 2…

        foreach ($arr_col as $k => $v) {
            $this->arr[$k][] = $arr_col[$k];
        }

        return $this;
    }
public function addCol($arr_col)
    {
        if (isset($this->arr[0]) && (count($this->arr[0]) == $this->size->cols)) {
            throw new \OutOfRangeException(sprintf('You cannot add another column! Max number of columns is %d', $this->size->cols));
        }

        if (count($arr_col) != $this->size->rows) {
            throw new \InvalidArgumentException('New column must have same amout of rows than previous columns.');
        }

        $arr_col = array_values($arr_col); //to be sure to have index 0, 1, 2…

        foreach ($arr_col as $k => $v) {
            $this->arr[$k][] = $arr_col[$k];
        }

        return $this;
    }
public function addCol ( $ arr_col ) { if ( isset ( $ this -> arr [ 0 ] ) && ( count ( $ this -> arr [ 0 ] ) == $ this -> size -> cols ) ) { throw new \ OutOfRangeException ( sprintf ( 'You cannot add another column! Max number of columns is %d' , $ this -> size -> cols ) ) ; } if ( count ( $ arr_col ) != $ this -> size -> rows ) { throw new \ InvalidArgumentException ( 'New column must have same amout of rows than previous columns.' ) ; } $ arr_col = array_values ( $ arr_col ) ; //to be sure to have index 0, 1, 2… foreach ( $ arr_col as $ k => $ v ) { $ this -> arr [ $ k ] [ ] = $ arr_col [ $ k ] ; } return $ this ; }
Adds a column to populate step by step the matrix

@throw \OutOfRangeException If this is called and the number of columns is full.
@throw \InvalidArgumentException If colmun has not the same number of rows that previous one.
@param  array  $arr_col Data to add
@access public
@return Matrix
Adds a column to populate step by step the matrix