%%
%% Run this script in Matlab command window 
%%

   function Installmex 

   curdir = pwd;  
   fprintf(' current directory is:  %s\n',curdir);    
   if isunix 
      src = [curdir,'/Solver/mexsrc']; 
      dst = [curdir,'/Solver/mexexec']; 
      cd Solver/mexsrc
   elseif ispc 
      src = [curdir,'\Solver\mexsrc']; 
      dst = [curdir,'\Solver\mexexec']; 
      cd Solver\mexsrc
   end
   fprintf ('\n Now compiling the mexFunctions in:\n'); 
   fprintf (' %s\n',src);    
%%
   fname{1} = 'mexProd2.c'; 
   fname{2} = 'mexProd2nz.c';
   fname{3} = 'mexinprod.c';
   fname{4} = 'mexmat.c';
   fname{5} = 'mexsmat.c';
   fname{6} = 'mexsvec.c';
   fname{7} = 'mexschur.c';
   fname{8} = 'mexbsolve.c';
   fname{9} = 'mexchol.c';
   fname{10} = 'mexqops.c';
   fname{11} = 'mexqprod.c';
   fname{12} = 'ordmmd.c  ordmmdg.c';
   fname{13} = 'symfct.c  symfctg.c';
   fname{14} = 'inpnv.c   inpnvg.c';
   fname{15} = 'blkfct.c  blkfctg.c';
   fname{16} = 'blkslv.c  blkslvg.c';

   for k = 1:length(fname)
       cmd(['mex  -O ',fname{k}]);  
   end      
   if isunix
      unix(['mv *.mex*  ../mexexec/']);  
   end
   cd .. 
   cd ..
%%***********************************************
%%***********************************************
   function cmd(s) 
   
   fprintf(' %s\n',s); 
   eval(s); 
%%***********************************************
