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_get_def.m
    path of file: ./repos/bspm/thirdparty/spm8
    
    the code of the file until where you have to start completion: function def = spm_get_def(Bx,By,Bz,beta)
% Calculating deformation field from coefficient vector.
%
% FORMAT [def] = get_def(Bx,By,Bz,beta);
% Bx, By, Bz  - Separable basis sets such that B=kron(Bz,kron(By,Bx));
% beta        - Coefficient vector for basis set.
% or
% FORMAT [def] = get_def(dim,order,beta);
% dim         - Dimensionality of image in x,y and z directions.
% order       - Order of DCT set in x,y and z directions.
% beta        - Coefficient vector for basis set.
%_______________________________________________________________________
%
% Calculates the equivalent to kron(Bz,kron(By,Bx))*beta

    
function def = spm_get_def(Bx,By,Bz,beta)
% Calculating deformation field from coefficient vector.
%
% FORMAT [def] = get_def(Bx,By,Bz,beta);
% Bx, By, Bz  - Separable basis sets such that B=kron(Bz,kron(By,Bx));
% beta        - Coefficient vector for basis set.
% or
% FORMAT [def] = get_def(dim,order,beta);
% dim         - Dimensionality of image in x,y and z directions.
% order       - Order of DCT set in x,y and z directions.
% beta        - Coefficient vector for basis set.
%_______________________________________________________________________
%
% Calculates the equivalent to kron(Bz,kron(By,Bx))*beta
% in a faster and more efficient way. Note that this routine
% can be used to calculate AtY efficiently as well since 
% A'*y = (diag(dfdy)*kron(Bz,kron(By,Bx)))'*y = 
% kron(Bz',kron(By',Bx'))*(diag(dfdy)*y) = get_def(Bx',By',Bz',dfdy.*y)
%
%_______________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Jesper Andersson
% $Id: spm_get_def.m 1143 2008-02-07 19:33:33Z spm $


if nargin == 4
   [nx,mx] = size(Bx);
   [ny,my] = size(By);
   [nz,mz] = size(Bz);
   if mx*my*mz ~= size(beta,1)
      warning('get_def: Size mismatch between beta and basis-set');
      return
   end