examplesym

PURPOSE ^

This is an example script demonstrating how PARDISO works on a small,

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 This is an example script demonstrating how PARDISO works on a small,
 sparse, real 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % This is an example script demonstrating how PARDISO works on a small,
0002 % sparse, real 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([ 1  0 -2  3
0018              0  5  1  2
0019             -2  1  4 -7
0020              3  2 -7  5 ]);
0021 
0022 % Generate a random collection of right-hand sides.
0023 B = randn(n,m);
0024 
0025 % Initialize the PARDISO internal data structures. We've told PARDISO to
0026 % handle real symmetric matrices using the sparse direct solver.
0027 % info = pardisoinit(-2,0);
0028 info = pardisoinit(-2,0);
0029 
0030 % Analyze the matrix and compute a symbolic factorization.
0031 p    = randperm(n);
0032 info = pardisoreorder(tril(A),info,verbose,p);
0033 fprintf('The factors have %d nonzero entries.\n',info.iparm(18));
0034 
0035 % Compute the numeric factorization.
0036 info = pardisofactor(tril(A),info,verbose);
0037 fprintf('The matrix has %d positive and %d negative eigenvalues.\n',...
0038     info.iparm(22),info.iparm(23));
0039 
0040 % Compute the solutions X using the symbolic factorization.
0041 [X info] = pardisosolve(tril(A),B,info,verbose);
0042 fprintf('PARDISO performed %d iterative refinement steps.\n',info.iparm(7));
0043 
0044 % Compute the residuals.
0045 R = max(abs(A*X - B));
0046 fprintf('The maximum residual for the solution X is %0.3g.\n',max(R(:)));
0047 
0048 % Free the PARDISO data structures.
0049 pardisofree(info);
0050 clear info
0051 
0052

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.