Generate pseudorandom well conditioned equation system

545 Views Asked by At

I need to test my GMRES_C(k) implementation, however for random matrices the convergence is very bad (does not converge with restarts).

Is there any special (complex) matrix which is "pseudorandom" and well conditioned?

I have already thought about Gram-Schmidt and searched for recent publications, however it was not really useful.

1

There are 1 best solutions below

0
On

A general trick for constructing a matrix by their conditioning is as following. This is Matlab code. You can construct an arbitrarily conditioned matrix by generating the singular values and constructing the diagonal.

function A = randommatrix(m,n,kappa)
% Returns an m x n matrix with condition number kappa,
% exponentially graded singular values
k = min(m,n);
[Q1,R1] = qr(randn(m,m));
[Q2,R2] = qr(randn(n,n));
% Originally thought we would evaluate for any m x n matrix, so if not square took minimum dimension
U = Q1(1:m,1:k);
V = Q2(1:k,1:n);
j=k-1;
% Take k-1 root of condition number to get number for grade
l = kappa^(1/j);
% Construct the singular value matrix, l^0 = 1, then l^(k-1)= 1/kappa 
S = diag(l.^(0:-1:-j));

A = U*S*V;


end

I'm not sure if this is right here. Now just multiply through afterward.

m=10;
n=m;
kappa=1;

A = randommatrix(m,n,kappa)

B = A*i;