1function [id]=dmumps(id,mat)
2%
3% [id]=dmumps(id,mat)
4% id is a structure (see details in initmumps.m and MUMPS documentation)
5% mat is optional if the job is -1 or -2
6% mat is a square sparse matrice
7% information are return in id fields
8%
9% Use help mumps_help for detailed information
10%
11
12errmsg = nargoutchk(1,1,nargout);
13if(~isempty(errmsg))
14     disp(errmsg);
15     return;
16end
17
18arithtype = 1;
19
20if(id.JOB == -2)
21     if(id.INST==-9999)
22         disp('Uninitialized instance');
23         return;
24     end
25     if(id.TYPE ~= arithtype)
26       disp('You are trying to call z/d version on a d/z instance');
27       return;
28     end
29     dmumpsmex(id.SYM,id.JOB,id.ICNTL,id.CNTL,id.PERM_IN,id.COLSCA,id.ROWSCA,id.RHS,id.VAR_SCHUR,id.INST,id.REDRHS,id.KEEP,id.DKEEP);
30     id = [];
31     return;
32end
33
34
35if(id.JOB == -1)
36     if(id.INST~=-9999)
37         disp('Already initialized instance');
38         return;
39     end
40     [inform,rinform,sol,inst,schur,redrhs,pivnul_list,sym_perm,uns_perm,icntl,cntl,colsca_out,rowsca_out,keep_out,dkeep_out] = dmumpsmex(id.SYM,id.JOB,id.ICNTL,id.CNTL,id.PERM_IN,id.COLSCA,id.ROWSCA,id.RHS,id.VAR_SCHUR,id.INST,id.REDRHS,id.KEEP,id.DKEEP);
41     id.INFOG = inform;
42     id.RINFOG = rinform;
43     id.SOL = sol;
44     id.INST = inst;
45     id.SCHUR = schur;
46     id.REDRHS = redrhs;
47     id.PIVNUL_LIST = pivnul_list;
48     id.SYM_PERM = sym_perm;
49     id.UNS_PERM = uns_perm;
50     id.TYPE = arithtype;
51     id.ICNTL = icntl;
52     id.CNTL = cntl;
53     id.COLSCA = colsca_out;
54     id.ROWSCA = rowsca_out;
55     id.KEEP = keep_out;
56     id.DKEEP = dkeep_out;
57     return;
58end
59
60if(id.INST==-9999)
61         disp('Uninitialized instance');
62         return;
63end
64
65if(id.TYPE ~= arithtype)
66   disp('You are trying to call z/d version on a d/z instance');
67   return;
68end
69
70[inform,rinform,sol,inst,schur,redrhs,pivnul_list,sym_perm,uns_perm,icntl,cntl,colsca_out,rowsca_out,keep_out,dkeep_out] = dmumpsmex(id.SYM,id.JOB,id.ICNTL,id.CNTL,id.PERM_IN,id.COLSCA,id.ROWSCA,id.RHS,id.VAR_SCHUR,id.INST,id.REDRHS,id.KEEP,id.DKEEP,mat);
71id.INFOG = inform;
72id.RINFOG = rinform;
73id.SOL = sol;
74id.INST = inst;
75if(id.JOB == 2 | id.JOB == 4 | id.JOB == 6)
76  if(id.SYM == 0)
77	id.SCHUR = schur';
78  else
79        id.SCHUR = triu(schur)+tril(schur',-1);
80  end
81end
82id.REDRHS = redrhs;
83id.PIVNUL_LIST = pivnul_list;
84id.SYM_PERM(sym_perm) = [1:size(mat,1)];
85id.UNS_PERM = uns_perm;
86id.ICNTL=icntl;
87id.CNTL=cntl;
88id.COLSCA=colsca_out;
89id.ROWSCA=rowsca_out;
90id.KEEP=keep_out;
91id.DKEEP=dkeep_out;
92