Create random symmetric matrix with given cond number to pass it to pcg
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Fedor
am 11 Mär. 2023
Kommentiert: Fedor
am 11 Mär. 2023
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 Kommentare
Bruno Luong
am 11 Mär. 2023
Bearbeitet: Bruno Luong
am 11 Mär. 2023
" 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.
Akzeptierte Antwort
Bruno Luong
am 11 Mär. 2023
Bearbeitet: Bruno Luong
am 11 Mär. 2023
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!