Store solution in linear iterative solver using CGS/biCG

1 Ansicht (letzte 30 Tage)
Chaitanya Sanghavi
Chaitanya Sanghavi am 6 Feb. 2018
Beantwortet: JK am 7 Feb. 2018
Hello All, This might be a stupid question but I could not find an answer before. Lets say I use, [iter,flag,res.error] = cgs(A,b); where A is square matrix and b is a vector. I get convergence at 46th iteration.
Is is possible to store the solution at each iteration ? I see in Matlab this has been implemented using multi-threads and I assume the solver does not store the solution at each iteration and only updates the memory.
But for my analysis, I need to solution at each iteration. Is this possible ? Ofcourse I can write my own algorithm but would be nice if there is a easier way out !

Antworten (1)

JK
JK am 7 Feb. 2018
Not sure if this will work, but might worth a try: Have you tried to provide A with a function handle @(x) A(x)? In the function A you can put:
global xx if xx(:,end) ~= x xx(:,end+1)=x; end
xx then contains an array of column vectors of x in global workspace. You must set it up to the proper number of rows for the first call.

Kategorien

Mehr zu Symbolic Math Toolbox 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!

Translated by