1function id=dmumps(id,mat)
2
3//**************************************************************************************************************
4// [id] = dmumps(id,mat)
5// id is a structure (see details in initmumps.m and MUMPS documentation)
6// mat is an optional parameter if the job id.job = -1 or -2
7// mat is a square sparse matrix
8// informations are return in id fields
9//
10// *************************************************************************************************************
11
12
13if (typeof(id) ~= "StructMumps") then
14  disp("Error. Please call initmumps first.");
15  return;
16end
17arithtype=1;
18
19if id.JOB == -2 then
20     if id.INST==-9999 then
21         disp('Error. Uninitialized instance. MUMPS should be called with JOB=-1 first.');
22         return;
23     end
24     if id.TYPE ~= arithtype then
25	disp('Error. You are trying to call z/d version on a d/z instance');
26        return;
27     end
28     // call the C routine dmumpsc
29
30     dmumpsc(id.SYM,id.JOB,id.ICNTL,id.CNTL,id.PERM_IN,id.COLSCA,id.ROWSCA,id.RHS,id.VAR_SCHUR,id.INST,id.REDRHS);
31     id = [];
32     return;
33end
34
35
36if id.JOB == -1 then
37	if id.INST~=-9999 then
38		disp('Error. Already initialized instance.');
39	return;
40	end
41	// call the C routine dmumpsc
42	[inform,rinform,sol,inst,schu,redrhs,pivnul_list,sym_perm,uns_perm,icntl,cntl] = dmumpsc(id.SYM,id.JOB,id.ICNTL,id.CNTL,id.PERM_IN,id.COLSCA,id.ROWSCA,id.RHS,id.VAR_SCHUR,id.INST,id.REDRHS);
43        id.INFOG = inform;
44	id.RINFOG = rinform;
45	id.SOL = sol;
46	id.INST = inst;
47	id.SCHUR = schu;
48	id.REDRHS = redrhs;
49	id.PIVNUL_LIST = pivnul_list;
50	id.SYM_PERM = sym_perm;
51	id.UNS_PERM = uns_perm;
52        id.TYPE=arithtype;
53        id.ICNTL=icntl;
54	id.CNTL=cntl;
55 	clear inform rinform sol inst schu redrhs pivnul_list sym_perm uns_perm icntl cntl
56	return;
57
58end
59
60if id.INST ==-9999 then
61	disp('Uninitialized instance');
62	return;
63end
64// call the C routine dmumpsc
65
66if id.TYPE ~= arithtype then
67	disp('You are trying to call z/d version on a d/z instance');
68end
69
70[inform,rinform,sol,inst,schu,redrhs,pivnul_list,sym_perm,uns_perm,icntl,cntl] = dmumpsc(id.SYM,id.JOB,id.ICNTL,id.CNTL,id.PERM_IN,id.COLSCA,id.ROWSCA,id.RHS,id.VAR_SCHUR,id.INST,id.REDRHS, mat);
71id.INFOG = inform;
72id.RINFOG = rinform;
73id.SOL = sol;
74id.INST = inst;
75if (id.JOB == 2|id.JOB==4|id.JOB==6) then
76	if id.SYM == 0 then
77                id.SCHUR=schu';
78        else
79        	id.SCHUR=triu(schu)+tril(schu',-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;
88clear inform rinform sol inst schu redrhs pivnul_list sym_perm uns_perm icntl cntl
89
90endfunction
91