This is an example script demonstrating how PARDISO works on a small, sparse, real non-symmetric matrix. It computes the m solutions X to the collection of linear systems A * X = B using the PARDISO solver, where A is a symmetric n x n matrix, B is an n x m matrix, and X is another n x m matrix.
0001 % This is an example script demonstrating how PARDISO works on a small, 0002 % sparse, real non-symmetric matrix. It computes the m solutions X to the 0003 % collection of linear systems 0004 % 0005 % A * X = B 0006 % 0007 % using the PARDISO solver, where A is a symmetric n x n matrix, B is an 0008 % n x m matrix, and X is another n x m matrix. 0009 clear 0010 verbose = false; 0011 0012 dkepath = load_structures_yp('dkepath','',''); 0013 0014 n = 4; % The number of equations. 0015 m = 3; % The number of right-hand sides. 0016 0017 A = sparse([ 0 -2 3 0 0018 -2 4 -4 1 0019 -3 5 1 1 0020 1 -3 0 2 ]); 0021 0022 % Generate a random collection of right-hand sides. 0023 B = ones(n,m); 0024 0025 % Initialize the PARDISO internal data structures. We've told PARDISO to 0026 % handle real non-symmetric matrices using the sparse direct solver. 0027 info = pardisoinit(11,0); 0028 0029 % Analyze the matrix and compute a symbolic factorization. 0030 info = pardisoreorder(A,info,verbose); 0031 fprintf('The factors have %d nonzero entries.\n',info.iparm(18)); 0032 0033 % Compute the numeric factorization. 0034 info = pardisofactor(A,info,verbose); 0035 0036 % Compute the solutions X using the symbolic factorization. 0037 [X info] = pardisosolve(A,B,info,verbose); 0038 fprintf('PARDISO performed %d iterative refinement steps.\n',info.iparm(7)); 0039 0040 % Compute the residuals. 0041 R = max(abs(A*X - B)); 0042 fprintf('The maximum residual for the solution X is %0.3g.\n',max(R(:))); 0043 0044 % Free the PARDISO data structures. 0045 % pardisofree(info); 0046 % clear info