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: spm_dexpm.m
    path of file: ./repos/spm/toolbox/Longitudinal
    
    the code of the file until where you have to start completion: function [E,dE] = spm_dexpm(A,dA)
% Differentiate a matrix exponential

    
function [E,dE] = spm_dexpm(A,dA)
% Differentiate a matrix exponential
% FORMAT [E,dE] = spm_dexpm(A,dA)
% A  - Lie algebra
% dA - basis function to differentiate with respect to
%
% E  - expm(A)
% dE - (expm(A+eps*dA)-expm(A-eps*dA))/(2*eps)
%
% Note that the algorithm is a bit slow, and should perhaps be re-written
% to use eg scaling and squaring (see Moler's dubious matrix exponentials
% paper).
%__________________________________________________________________________

% John Ashburner
% Copyright (C) 2012-2022 Wellcome Centre for Human Neuroimaging


if nargin < 2
    dA = zeros([size(A) 0]);
else
    if (size(A,1)==1 && size(A,2)==size(dA,3)) ...
    || (size(A,2)==1 && size(A,1)==size(dA,3))
        p = A(:);
        A = zeros(size(dA,1),size(dA,2));
        for m=1:size(dA,3)
            A = A + p(m)*dA(:,:,m);
        end