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: StiffMa.m
    path of file: ./repos/StiffMa/tbx/StiffMa
    
    the code of the file until where you have to start completion: function K = StiffMa(Mesh, MP, dev, sets)
% STIFFMA Creates the global sparse stiffness matrix on the GPU by dividing
% [iK, jK, Ke] arrays if the device memory is not enough to process all data
% together.
% 
%   K = STIFFMA(Mesh, MP, dev, sets) returns the lower-triangle of a sparse
%   matrix K from finite element analysis of scalar/vector problems in a 
%   three-dimensional domain taking advantage of symmetry and GPU
%   computing, where the required inputs are:
%   - "Mesh.elements" is the connectivity matrix,
%   - "Mesh.nodes" is the nodal coordinates, 
%   - "MP.E" is the Young's modulus and
%   - "MP.nu" is the Poisson ratio are the material property for an isotropic
%   material in the vector case, while 
%   - "MP.c" (thermal conductivity) is needed for the scalar problem. The
%   struct "sets" must contain several similation parameters: 
%   - sets.prob_type defines the problem type 'Scalar' or 'Vector'
%   - sets.sf is the safety factor. Positive integer to add more partitions
%   - sets.dTE is the data precision of "Mesh.elements"
%   - sets.dTN is the data precision of "Mesh.nodes"
%   - sets.nel is the number of finite elements
%   - sets.nxe is the number of nodes per element

    
function K = StiffMa(Mesh, MP, dev, sets)
% STIFFMA Creates the global sparse stiffness matrix on the GPU by dividing
% [iK, jK, Ke] arrays if the device memory is not enough to process all data
% together.
% 
%   K = STIFFMA(Mesh, MP, dev, sets) returns the lower-triangle of a sparse
%   matrix K from finite element analysis of scalar/vector problems in a 
%   three-dimensional domain taking advantage of symmetry and GPU
%   computing, where the required inputs are:
%   - "Mesh.elements" is the connectivity matrix,
%   - "Mesh.nodes" is the nodal coordinates, 
%   - "MP.E" is the Young's modulus and
%   - "MP.nu" is the Poisson ratio are the material property for an isotropic
%   material in the vector case, while 
%   - "MP.c" (thermal conductivity) is needed for the scalar problem. The
%   struct "sets" must contain several similation parameters: 
%   - sets.prob_type defines the problem type 'Scalar' or 'Vector'
%   - sets.sf is the safety factor. Positive integer to add more partitions
%   - sets.dTE is the data precision of "Mesh.elements"
%   - sets.dTN is the data precision of "Mesh.nodes"
%   - sets.nel is the number of finite elements
%   - sets.nxe is the number of nodes per element
%   - sets.nnod is the number of nodes in the mesh 
%   - sets.dim is the space dimension
%   - sets.dxn is the number of DOFs per node. 1 for the scalar problem or 3 for the vector problem
%   - sets.edof is the umber of DOFs per element
%   - sets.tdofs is the number of total DOFs in the mesh
%   - sets.sz  is the number of symmetry entries
%   - sets.tbs is the Thread Block Size
%   - sets.numSMs is the number of multiprocessors on the device
%   - sets.WarpSize is the GPU warp size

%   For more information, see the <a href="matlab:
%   web('https://github.com/fjramireg/StiffMa')">StiffMa</a> web site.
%
%   Written by Francisco Javier Ramirez-Gil, fjramireg@gmail.com
%   Universidad Nacional de Colombia - Medellin
%   Created:  21 May 2020. Version: 1.0
%   Modified: 15 June 2020. Version: 1.1


%% Determination of number of chunks based on current GPU memory

% Element data type used for storing connectivity array (Mesh.elements)
d_et  = zeros(1,1,sets.dTE); %#ok
d_et1 = whos('d_et');
szInd = d_et1.bytes;

% Nodal data type used for storing nodal coordinates array (Mesh.nodes)
d_nt  = zeros(1,1,sets.dTN); %#ok
d_nt1 = whos('d_nt');
szNNZ = d_nt1.bytes;

% Memory requirements
Mmesh  = szInd*numel(Mesh.elements) + szNNZ*numel(Mesh.nodes);	% Memory required to store the mesh
Mtrip  = (2*szInd + szNNZ)*sets.sz*sets.nel;                    % Memory required to store triplet format iK, jK, Ke
Maccum = 3*Mtrip;                                               % Memory required for accumarray
Mcsc   = 0.5*Mtrip;                                             % Memory required for output (sparse metrix in CSC format)
Mtotal = Mmesh + Mtrip + Maccum + Mcsc;                        	% Total required memory

% Chunks determination
ndiv = ceil(Mtotal/dev.AvailableMemory);                          % Number of divisions.
ndiv = ndiv + sets.sf*(ndiv>1);                                      % Sums safety factor only if ndiv > 1
while mod(sets.nel,ndiv) ~= 0                                   % Guarantee that sets.nel is divisible by ndiv
    ndiv = ndiv + 1;
end