You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ref.m
    path of file: ./repos/fieldtrip/external/afni
    
    the code of the file until where you have to start completion: function [U,pivcol,nonpivcol] = ref(A,tol)
%REF    The (R)educed (E)chelon (F)orm of A.
%       Computes the reduced row echelon form of A using partial pivoting.
%
%       Formats:   U = ref(A)
%                  U = ref(A,tol)     User specifies tolerance to determine
%                                     when an entry should be zero.
%                  [U,pivcol] = ref(A)    Also lists the pivot columns of A.
%                  [U,pivcol,nonpivcol] = ref(A)   And the nonpivot columns.


    
function [U,pivcol,nonpivcol] = ref(A,tol)
%REF    The (R)educed (E)chelon (F)orm of A.
%       Computes the reduced row echelon form of A using partial pivoting.
%
%       Formats:   U = ref(A)
%                  U = ref(A,tol)     User specifies tolerance to determine
%                                     when an entry should be zero.
%                  [U,pivcol] = ref(A)    Also lists the pivot columns of A.
%                  [U,pivcol,nonpivcol] = ref(A)   And the nonpivot columns.

%Written by David Lay, University of Maryland, College Park, 6/20/94
%Based on the original rref(A) program written by Cleve B. Moler in 1985.
%       Version 12/15/96

[m,n] = size(A);
tiny = max(m,n)*eps*max(1,norm(A,'inf'))*10;    %default tolerance for zeros
if (nargin==2), tiny = tol; end