1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
% ********************************************************************
% Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
% ********************************************************************
function isok = printall(modo,A,T,Q,L=0,U=0,P=0)
%{
-----------------------------------------------------------
This function prints into files all the involved
matrices and vectors of the LU factorization
P * A * Q = L * U, T = L - I + U
if modo is "lu", or the Cholesky factorization
Q' * A * Q = T * T'
otherwise.
Additionaly, it generates and prints matrix B and
solution matrix X of the linear systems
A * X = B
for 1, 10 and 30 right-hand-sides.
printall("lu", A, T, Q, L, U, P)
printall("po", A, T, Q)
Inputs:
A, L, U, T The matrix A and its corresponding
triangular factors (sparse matrices)
P, Q vectors with the indices corresponding
to the row and column re-orderings (these could be
row or column full vectors)
Outputs:
isok This will be -1 if any of the matrix/vectors could not
be printed
The resulting files are created in the working directory.
See print_mat.m, print_x.m and print_vec.m for more details.
(This script is for internal use only. It is not part of
rocSOLVER library interface and could change or be removed
without any notice)
-----------------------------------------------------------
%}
isok = print_mat('A',A);
if (!isok),
error(sprintf('Error writting files for matrix A'));
end;
isok = print_mat('T',T);
if (!isok),
error(sprintf('Error writting files for matrix T'));
end;
isok = print_vec('Q',Q);
if (!isok),
error(sprintf('Error writting files for vector Q'));
end;
if modo=="lu",
isok = print_mat('L',L);
if (!isok),
error(sprintf('Error writting files for matrix L'));
end;
isok = print_mat('U',U);
if (!isok),
error(sprintf('Error writting files for matrix U'));
end;
isok = print_vec('P',P);
if (!isok),
error(sprintf('Error writting files for vector P'));
end;
end;
n=size(A,1);
X=rand(n,1);
B=A*X;
isok = print_x('X_1',X);
if (!isok),
error(sprintf('Error writting files for matrix X with 1 rhs'));
end;
isok = print_x('B_1',B);
if (!isok),
error(sprintf('Error writting files for matrix B with 1 rhs'));
end;
X=rand(n,10);
B=A*X;
isok = print_x('X_10',X);
if (!isok),
error(sprintf('Error writting files for matrix X with 10 rhs'));
end;
isok = print_x('B_10',B);
if (!isok),
error(sprintf('Error writting files for matrix B with 10 rhs'));
end;
X=rand(n,30);
B=A*X;
isok = print_x('X_30',X);
if (!isok),
error(sprintf('Error writting files for matrix X with 30 rhs'));
end;
isok = print_x('B_30',B);
if (!isok),
error(sprintf('Error writting files for matrix B with 30 rhs'));
end;
end
|