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: openmeeg_dsm.m
    path of file: ./repos/fieldtrip/external/openmeeg
    
    the code of the file until where you have to start completion: function [dsm] = openmeeg_dsm(pos, vol, flag)

% OPENMEEG_DSM computes the OpenMEEG DSM matrix
%              i.e. Right hand side in the potential equation
%
% Use as
%   [dsm] = openmeeg_dsm(po, vol, flag)
%
% flag = 1 non adaptive algorithm: does not try to approximate the
% potential in the neighborhodd of the leads, by locally refining the BEM surface

% Copyright (C) 2010-2017, OpenMEEG developers

openmeeg_license;              % show 
    
function cleaner(vol,bndfile,condfile,geomfile,exefile,dipfile,dsmfile)
% delete the temporary files
for i=1:length(vol.bnd)
    if exist(bndfile{i},'file'),delete(bndfile{i}),end
end
if exist(condfile,'file'),delete(condfile);end
if exist(geomfile,'file'),delete(geomfile);end
if exist(exefile,'file'),delete(exefile);end
if exist(dipfile,'file'),delete(dipfile);end
if exist(dsmfile,'file'),delete(dsmfile);end

function ok = checknormals(bnd)
% FIXME: this method is rigorous only for star shaped surfaces
ok = 0;
pos = bnd.pos;
tri = bnd.tri;
% translate to the center
org = mean(pos,1);
pos(:,1) = pos(:,1) - org(1);
pos(:,2) = pos(:,2) - org(2);
pos(:,3) = pos(:,3) - org(3);

w = sum(solid_angle(pos, tri));

if w<0 && (abs(w)-4*pi)<1000*eps
  ok = 0;
%   warning('your normals are outwards oriented\n')
elseif w>0 && (abs(w)-4*pi)<1000*eps
  ok = 1;
%   warning('your normals are inwards oriented')
else
  error('your surface probably is irregular\n')
  ok = 0;
end