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: arap_dof.m
    path of file: ./repos/gptoolbox/mesh
    
    the code of the file until where you have to start completion: function [L,new_C] = arap_dof(varargin)
  % ARAP_DOF compute automatic dof (linear transformation, for now) for point
  % handles in a linear blend skinning deformation. Provided are only the
  % displacements (translations) at each control point.
  % 
  % [L] = arap_dof(V,F,W,C,P,BE,new_C)
  % [L] = arap_dof(V,F,W,C,P,BE,new_C,'PropertyName','PropertyValue',...)
  %
  % Inputs:
  %   V  #V by dim list of vertex positions
  %   F  #F by 3 list of face indices
  %   W  #V by #C list of skinning weights
  %   C  #C by dim list of control vertex positions
  %   P  #P list of indices into C for point controls, { 1:size(C,1) }
  %   BE  #BE by 2 list of bones, pairs of indices into C, connecting control 
  %      vertices in C
  %   %b  #C list of control point indices in V
  %   new_C  #C by dim list of control point pose positions
  %   Optional properties:
  %     'L0'
  %       dim by dim by #C list of linear transformations initial guesses,
  %       optional (default is to use identity transformations)
  %%     'CovarianceScatterMatrix'
  %%       followed by CSM a dim*n by dim*n sparse matrix, see Outputs
  %     'Groups'
  %       followed by #V list of group indices (1 to k) for each 
    
function of L, namely V' = LBS(W,V,L,D).
  % Because V' is a linear combination of the unknowns L, the complexity of our
  % energy is only reduced.
  %
  % Recall from Sorkine and Alexa, the best rotatitions Ri are well defined
  % functions of V' and thus in our case become a functions of L. 
  % 
  % We may minimize (1) by the same iterative method of Sorkine and Alexa. That
  % is we first treat L as fixed and solve (1) for Ri. Then fixing these Ri
  % solve (1) for L. The continous until convergence is reached. Note as in
  % Sorkine and Alexa each step cannot increase the energy so a converging to a
  % local minimum is guaranteed.
  %
  % So to start the iterations we fix L = L0, perhaps the identity or their
  % values from the last frame. Now V' are known values so we may solve for Ri
  % in (1) in the same manner as Sorkine and Alexa (SVD) or better by polar
  % decomposition.
  %
  % Now that we have values for Ri, call them R0. We solve (1) for new L
  % values. Notice when we fix Ri = R0, (1) becomes quadratic and finding its
  % minimum is straight-forward.
  %
  % First let's write V' = LBS(W,V,L,D) in matrix form, so it's clear V' is
  % just a linear combination of L
  %
  % ...
  % 
  % So know we have V' = MLBS * L, where L is a column vector containing
  % dim*dim*m unknowns.
  %
  % Because both Ri and Vi are known we can write Ri (vi - vj) = bij
  %
  %  E = ???   ??? ||(vi' - vj') - bij||^2    (2)
  %     i???V j???N(i)
  %
  % We can write (1) in matrix form:
  %
  % E = -1 V' * Lapl * V  + 2 V' * Ab * 1 + 1 * Abb * 1  (3)
  % 
  % where Lapl is the discrete mesh laplacian and Ab is an adjacency matrix
  %
  % Abij = cwij * (bji - bij)
  %
  % Abij = cwij * bij * bij
  %
  % Then we may replace V' with MLBS * L:
  %
  % E = -1 (MLBS * L)' * Lapl * (MLBS * L) +
  %     2 (MLBS * L)' * Ab * 1 + 
  %     1 * Abb * 1
  %
  % E = -1 L' * MLBS' * Lapl * MLBS * L +
  %     2 L' * MLBS' * Ab * 1 + 
  %     1 * Abb * 1
  %
  % E = L' * Quad * L + L' * Lin  + C
  %
  % where
  %
  % Quad = -1 * MLBS' * Lapl * MLBS
  % Lin = 2 * MLBS' * Ab * 1
  % C = 1 * Abb * 1
  % 

  % compute matrix MLBS, such that U = reshape(MLBS*L,[n dim]) gives 
  % U = lbs(V,W,L)
  MLBS = lbs_matrix(V,W);

  % cotangent laplacian matrix
  Lcot = cotmatrix(V,F);
  % laplacian matrix
  Lapl = 2 * Lcot;

  %% indices of translations in L, so that L(known) == D
  %known = (dim*dim*m+1):(dim*(dim+1)*m);

  % default 'no-groups' G_sum
  switch energy
  case 'elements'
    G_sum = speye(size(F,1));
    k = size(F,1);
  case {'spokes','spokes-and-rims'}
    G_sum = speye(size(V,1));
    k = size(V,1);
  end