Create random symmetric matrix with given cond number to pass it to pcg
7 次查看(过去 30 天)
显示 更早的评论
I want to generate random positive definitive symmetric matrix with given cond number, but the requirement is that PCG method should be able to solve it.
For now I use generation algorithm from this question. It does generate positive definitive symmetric random matrix with given cond number, but that is insufficient - pcg can't solve it even for smaller cond numbers. Pcg returns flag 4, which means that during algo it simply couldn't converge.
What am I doing wrong? Maybe there is better generating algorithm?
3 个评论
Bruno Luong
2023-3-11
编辑:Bruno Luong
2023-3-11
" I don't know the exact requirements of pcg honestly"
positive definitive symmetric matrix.
For now I use generation algorithm from this question. It does generate positive definitive symmetric
That's the problem, the algo in the question you quote: it does not generate positive matrix as you freely believe.
采纳的回答
Bruno Luong
2023-3-11
编辑:Bruno Luong
2023-3-11
n=10; % size of the system
condtarget = 1000;
% generate ransom spd matrix
[Q,~]=qr(randn(n));
r = rand(n,1);
r = (r-min(r))/(max(r)-min(r));
d=exp(r*log(condtarget));
A=Q'*diag(d)*Q
cond(A)
b=rand(n,1) % random rhs
x=pcg(A,b)
A*x % should close to b
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!