Store solution in linear iterative solver using CGS/biCG

1 次查看(过去 30 天)
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 !

回答(1 个)

JK
JK 2018-2-7
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.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by