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: adderiv.m
    path of file: ./repos/d2d/arFramework3/ThirdParty/StrucID/adimat/opt_derivclass/@adderiv
    
    the code of the file until where you have to start completion: function g= adderiv(n,sz,mode)
%ADDERIV Construct a derivate-object for automatic differentiation.
%
% g= adderriv(adobj) Copies information from the adobj to the new
%     derivative object g. A lightweight copy is used, i.e., no directional
%     derivatives are copied. The meta information is copied, only.
%
% g= adderiv(ndd, sz, 'zeros') Creates a new derivative object with storage
%     for ndd many directional derivatives. Each directional derivative has
%     size sz storage allocated and is filled with zeros. The keyword 'zeros'
%     may be omited.
%
% g= adderiv(ndd, sz, 'sparse') The same as using 'zeros' but this time
%     a sparse datastructure is used.

    
function g= adderiv(n,sz,mode)
%ADDERIV Construct a derivate-object for automatic differentiation.
%
% g= adderriv(adobj) Copies information from the adobj to the new
%     derivative object g. A lightweight copy is used, i.e., no directional
%     derivatives are copied. The meta information is copied, only.
%
% g= adderiv(ndd, sz, 'zeros') Creates a new derivative object with storage
%     for ndd many directional derivatives. Each directional derivative has
%     size sz storage allocated and is filled with zeros. The keyword 'zeros'
%     may be omited.
%
% g= adderiv(ndd, sz, 'sparse') The same as using 'zeros' but this time
%     a sparse datastructure is used.
%
% g= adderiv(ndd, sz, 'object') Uses copies of the object sz to stored in
%     every directional derivative.
%
% g= adderiv(ndd, sz, 'empty') Does not care about the data in sz. I.e.,
%     sz can be []. This command initializes the metainformation only.
%
% This constructor can be used to initialize Hessains, too. ndd has to be
% twodimensional then.
%
% If ndd is [], then the number of directional derivatives is read using the
% option-method.
%
% It is currently not implemented to use derivative object of higher order
% than two.
%
% Copyright 2014 Johannes Willkomm
% Copyright 2001-2004 Andre Vehreschild, Institute for Scientific Computing
%                     RWTH Aachen University
% This code is under development! Use at your own risk! Duplication,
% modification and distribution FORBIDDEN!

persistent intval_exists

if isempty(intval_exists)
  intval_exists= (exist('intval')==2);
end