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: gnansum.m
    path of file: ./repos/GIBBON/lib
    
    the code of the file until where you have to start completion: function [y]=gnansum(varargin)
% function [y]=gnansum(A,[],dimDir)

    
function [y]=gnansum(varargin)
% function [y]=gnansum(A,[],dimDir)
%------------------------------------------------------------------------
% this function is a replacement for nansum which is part of the
% statistics and machine learning toolbox. 
% The use of sum with the omitnan flag is used or if this does not work
% (for old MATLAB versions) a custom implementation is used. 
%
% Change log:
% 2020/01/09 Created
%------------------------------------------------------------------------

%%
if nargin==1
    varargin{2}=[];
end