Link with the parallel matrix solver package PARDISO written in C/C++ for MEX file (single processor). Solve the linear system of equation AX=B INPUTS: - A: Matrix [n,n] - B: Vector for solving the linear system of equations AX=B [n,1] - job: PARDISO job type (1,2,3,5,6,-2) see MUMPS documentation OUTPUTS: - X: Solution of the linear system of equation [n,1] - flag: execution flag (see the PARDISO documentation) [1,1] By Yves Peysson (CEA/DSM/IRFM, yves.peysson@cea.fr) and Joan Decker (CEA/DSM/IRFM, joan.decker@cea.fr) and
0001 % 0002 %Link with the parallel matrix solver package PARDISO written in C/C++ 0003 %for MEX file (single processor). 0004 % 0005 %Solve the linear system of equation AX=B 0006 % 0007 % INPUTS: 0008 % 0009 % - A: Matrix [n,n] 0010 % - B: Vector for solving the linear system of equations AX=B [n,1] 0011 % - job: PARDISO job type (1,2,3,5,6,-2) see MUMPS documentation 0012 % 0013 % OUTPUTS: 0014 % 0015 % - X: Solution of the linear system of equation [n,1] 0016 % - flag: execution flag (see the PARDISO documentation) [1,1] 0017 % 0018 %By Yves Peysson (CEA/DSM/IRFM, yves.peysson@cea.fr) and Joan Decker (CEA/DSM/IRFM, joan.decker@cea.fr) and 0019 % 0020 verbose_PARDISO = false; 0021 % 0022 if job_PARDISOMEX == 1, 0023 % Initialize the PARDISO internal data structures. We've told PARDISO to 0024 % handle real non-symmetric matrices using the sparse direct solver. 0025 % 0026 info_PARDISO = pardisoinit(11,0); 0027 % info_PARDISO.iparm(3) = 6; 0028 % info_PARDISO.iparm(4) = 61; 0029 % info_PARDISO.iparm(8) = 10; 0030 % 0031 elseif job_PARDISOMEX == 2, 0032 % 0033 A_PARDISOMEX = MMXPC_f_t; 0034 % 0035 % Analyze the matrix and compute a symbolic factorization. 0036 % 0037 info_PARDISO = pardisoreorder(A_PARDISOMEX,info_PARDISO,verbose_PARDISO); 0038 %fprintf('The factors have %d nonzero entries.\n',info_PARDISO.iparm(18)); 0039 % 0040 % Compute the numeric factorization. 0041 % 0042 info_PARDISO = pardisofactor(A_PARDISOMEX,info_PARDISO,verbose_PARDISO); 0043 % 0044 elseif job_PARDISOMEX == 3, 0045 % 0046 B_PARDISOMEX = MMXR_t; 0047 % 0048 % Compute the solutions X using the symbolic factorization. 0049 % 0050 [X_PARDISOMEX,info_PARDISO] = pardisosolve(A_PARDISOMEX,B_PARDISOMEX,info_PARDISO,verbose_PARDISO); 0051 % 0052 fprintf('PARDISO performed %d iterative refinement steps.\n',info_PARDISO.iparm(7)); 0053 % 0054 % Compute the residuals. 0055 R_PARDISOMEX = max(abs(A_PARDISOMEX*X_PARDISOMEX - B_PARDISOMEX)); 0056 fprintf('The maximum residual for the solution X is %0.3g.\n',max(R_PARDISOMEX(:))); 0057 flag_PARDISOMEX = 0; 0058 elseif job_PARDISOMEX == -2, 0059 % Free the PARDISO data structures. 0060 pardisofree(info_PARDISO); 0061 % clear info 0062 end 0063 0064 0065 0066 0067 0068 0069 0070