protected function doTransform(Matrix $mA, $extra = null)
    {
        $this->assertMatrixIsComplete($mA);

        if ($mA->is('empty')) {
            return new Matrix(array());
        }

        if (!is_callable($extra)) {
            throw new MatrixException('Function parameter is not callable');
        }

        $data = array();
        $mAData = $mA->toArray();
        $rows = $mA->rows();
        $cols = $mA->columns();
        for ($row=0; $row<$rows; $row++) {
            for ($col=0; $col<$cols; $col++) {
                $data[$row][$col] = $extra($row+1, $col+1, $mAData[$row][$col]);
            }
        }

        return new Matrix($data);
    }
protected function doTransform(Matrix $mA, $extra = null)
    {
        $this->assertMatrixIsComplete($mA);

        if ($mA->is('empty')) {
            return new Matrix(array());
        }

        if (!is_callable($extra)) {
            throw new MatrixException('Function parameter is not callable');
        }

        $data = array();
        $mAData = $mA->toArray();
        $rows = $mA->rows();
        $cols = $mA->columns();
        for ($row=0; $row<$rows; $row++) {
            for ($col=0; $col<$cols; $col++) {
                $data[$row][$col] = $extra($row+1, $col+1, $mAData[$row][$col]);
            }
        }

        return new Matrix($data);
    }
protected function doTransform ( Matrix $ mA , $ extra = null ) { $ this -> assertMatrixIsComplete ( $ mA ) ; if ( $ mA -> is ( 'empty' ) ) { return new Matrix ( array ( ) ) ; } if ( ! is_callable ( $ extra ) ) { throw new MatrixException ( 'Function parameter is not callable' ) ; } $ data = array ( ) ; $ mAData = $ mA -> toArray ( ) ; $ rows = $ mA -> rows ( ) ; $ cols = $ mA -> columns ( ) ; for ( $ row = 0 ; $ row < $ rows ; $ row ++ ) { for ( $ col = 0 ; $ col < $ cols ; $ col ++ ) { $ data [ $ row ] [ $ col ] = $ extra ( $ row + 1 , $ col + 1 , $ mAData [ $ row ] [ $ col ] ) ; } } return new Matrix ( $ data ) ; }
Apply a function to every entry in the matrix

Parameter signature for function to be used is:
function($row, $col, $value)

@param Matrix $mA First matrix operand - required
@param callable $extra The function to apply

@return Matrix

@throws MatrixException
Apply a function to every entry in the matrix